1. 18 Dec, 2021 1 commit
    • Robert Knight's avatar
      Check annotator-sidebar version consistency and sidebar origin on startup · 7b38d746
      Robert Knight authored
      When deploying the new inter-frame communication code we saw errors [1]
      setting up communication between the sidebar and host frames caused by:
      
       - Mismatches between the version of the client used in the annotator
         and the sidebar
       - The sidebar being served from an unexpected origin (eg. due to use of
         a web proxy) or an opaque origin (eg. due to the host being loaded in a
         sandboxed iframe).
      
      In some cases these issues are beyond our control and we can't reasonably
      guarantee that the client will work.
      
      This commit adds checks for these issues when the sidebar launches. If the
      checks fail client startup is allowed to continue, but we log a warning in the
      browser console and disable Sentry error reporting to reduce noise.
      
       - Add `origin` parameter to `#config` fragment in sidebar and notebook
         app launch URLs, which contains the expected origin of the app
      
       - Check the `version` and `origin` parameters from the config fragment
         on app startup. If they don't match what is expected, log a warning
         and disable error reporting, but try and continue to minimize user
         inconvenience if it does work.
      
      [1] See https://github.com/hypothesis/client/issues/3986#issuecomment-989685057
          for more details.
      7b38d746
  2. 17 Dec, 2021 8 commits
    • Eduardo's avatar
      Apply suggestions from code review · 6fd18cc4
      Eduardo authored
      Co-authored-by: 's avatarRobert Knight <robertknight@gmail.com>
      6fd18cc4
    • Eduardo Sanz García's avatar
      Fix and improve test · 011eb2bd
      Eduardo Sanz García authored
      In addition to cover the changes in the previous commit I have improved
      the test in this way:
      
      * like in frame-sync, segregate bridges according to the different
        channels and create utility functions to test the communication in
        those specific channels.
      * simplify a few test by relying on `emit[frame]Event` functions
      * remove mocking a public method
      011eb2bd
    • Eduardo Sanz García's avatar
      Reduce `Sidebar` dependency on `Guest` · a5613f9b
      Eduardo Sanz García authored
      Replace the 'sidebarLayoutChanged' event emitter for an RPC call using
      the `guest-host` communication channel. This change is a step further
      into be able to instantiate `Sidebar` independently from the `Guest`.
      This may be desirable in scenarios that has several iframes, like Ebooks
      and VitalSource.
      a5613f9b
    • Eduardo Sanz García's avatar
      Remove unused 'sidebarOpened' event emitter · 7474fc1c
      Eduardo Sanz García authored
      There is both an 'sidebarOpened' event emitter and RPC events. The RPC
      event is used, while the event emitter is not.
      7474fc1c
    • Eduardo Sanz García's avatar
      Move RPC listener together with the rest of listeners · d4b65960
      Eduardo Sanz García authored
      I moved a guest RPC listener with the rest of the listeners in the
      `Sidebar#_setupGuestEvents` method. This helps to quickly see which
      events from the `Guest` the `Sidebar` listens to.
      d4b65960
    • Robert Knight's avatar
      Increase timeout for port discovery · 62f30d3f
      Robert Knight authored
      On a slow device if the host page is heavily loaded with JavaScript, the
      10-second timeout can be exceeded. Increase this threshold to 20s to see
      what effect that has on the volume of reports we receive.
      62f30d3f
    • Lyza Danger Gardner's avatar
      Fix call to `store.focusGroup` in group-filtering test · 1ebb4e2d
      Lyza Danger Gardner authored
      The test was erroneously passing a Group object instead of a Group.id
      and was causing warnings to be logged to the test output.
      
      The immediately-following test passed because the group it was
      attempting to focus was the group that would be focused by default anyway.
      I adjusted the groups being focused and tested here to not use the
      default-focused group to assure the test is testing what it means to.
      1ebb4e2d
    • Robert Knight's avatar
      Reduce boot script cache expiry time · ee5de666
      Robert Knight authored
      Reduce the potential for mismatches between the client versions loaded
      in the annotator and sidebar when rolling out a new release by
      shortening the cache expiry time on the boot script.
      
      Set a very short expiry time on the browser cache TTL and a slightly
      longer time on the edge cache.
      ee5de666
  3. 16 Dec, 2021 10 commits
    • Robert Knight's avatar
      Limit line length in minified JS bundles · 2233d721
      Robert Knight authored
      Limit the line length in minified bundles to make them easier to examine in
      various tools which don't like very long source lines, and also mitigate an
      issue with stack traces in Firefox.
      
      Firefox stack traces report column numbers in Unicode code points whereas Sentry
      expects UTF-16 code units. If the input source contains Unicode characters which
      require multiple UTF-16 code units to represent then processed stack traces in
      Firefox will point to the wrong location.
      
      One of our dependencies (Showdown) contains a long string of emojis, which
      require multiple UTF-16 units to represent, and Terser by default tries to
      compress the code into as few lines as possible. The combined result of this is
      that stack traces from Firefox could end up being resolved to a location far
      from what is expected.
      
      Though it is not a complete fix for the issue, limiting the length of lines
      effectively mitigates this problem as only code nearby (on the same line as)
      these characters in the output is affected.
      
      I did also try Terser's `ascii_only` output option, but that increased the
      bundle size by 2% and has more potential for unexpected consequences elsewhere.
      2233d721
    • Robert Knight's avatar
      Remove all comments from minified JavaScript · 52da1f28
      Robert Knight authored
      By default Terser keeps certain comments [1] in minified output. Safari has a
      bug [2] that causes column numbers to be incorrectly reported in stack
      traces when a line contains inline comments. In minified code where the
      output is packed into a small number of lines, this can result in stack
      traces that map to the wrong source line. Stripping all comments from
      the output works around the issue.
      
      The effect on the size of the bundles is minimal. sidebar.bundle.js is
      about 2KB smaller with this change.
      
      Part of https://github.com/hypothesis/client/issues/4045
      
      [1] https://github.com/terser/terser#format-options
      [2] https://bugs.webkit.org/show_bug.cgi?id=221548
      52da1f28
    • Lyza Danger Gardner's avatar
      Extract RPC-related types into a new type module · 97ee3727
      Lyza Danger Gardner authored
      Extract RPC typing into its own module to avoid dependencies between
      the store and the RPC implementation. Clarify a few points in other
      types.
      97ee3727
    • Lyza Danger Gardner's avatar
    • Lyza Danger Gardner's avatar
    • Lyza Danger Gardner's avatar
      Define RPC payload typing in `cross-origin-rpc` · ada2f6a4
      Lyza Danger Gardner authored
      Move the typing for the parameter passed to the `changeFocusModeUser`
      RPC call into `cross-origin-rpc` and expand in preparation for
      supporting group filtering.
      ada2f6a4
    • Lyza Danger Gardner's avatar
      Add helper function for normalizing `groupid`s to `id`s · 971d844a
      Lyza Danger Gardner authored
      Add support for normalizing a set of GroupIdentifiers (which could be
      `id`s or `groupid`s or a mix) to  `id`s, for use with store layer logic.
      
      Needed to support filtering groups based on RPC calls from the LMS
      application, which sends `groupid`s.
      971d844a
    • Lyza Danger Gardner's avatar
      Restore user-focus state after changing focused group · 003d44e3
      Lyza Danger Gardner authored
      In grading mode, a student may belong to more than one group and the
      instructor may switch between groups when grading the student. Restore
      the applied user-focus filter when switching groups to maintain UI
      continuity.
      003d44e3
    • Lyza Danger Gardner's avatar
      Expand type descriptions on a couple of Group properties · 78f7899d
      Lyza Danger Gardner authored
      All Group objects have an `id`, some have a `groupid`. First party
      groups deal in `id`s only (aka `pubid`s), while LMS groups use
      `groupid`s as they include authority information and are unique across
      all authorities.
      78f7899d
    • Lyza Danger Gardner's avatar
      Show spinner in filter interface when loading · e92fe755
      Lyza Danger Gardner authored
      The only typical time that the filter interface is visible when loading
      is when loading groups for a focused student-user in grading mode.
      Other filtering happens client-side and doesn't involve loading.
      
      But when we ARE loading, don't show an inaccurate count (because we
      don't have all the results yet), show a spinner instead.
      e92fe755
  4. 15 Dec, 2021 7 commits
  5. 13 Dec, 2021 12 commits
  6. 10 Dec, 2021 2 commits