1. 22 Nov, 2021 3 commits
  2. 19 Nov, 2021 1 commit
    • Eduardo Sanz García's avatar
      Use `WeakMap` to store `MessageChannel` · 0c0a639b
      Eduardo Sanz García authored
      We use `Window` objects as keys on a map. Windows can be removed.
      `WeakMap` has the characteristic that keys that are claimed by the
      garbage collector are removed from the map. In this way, we are memory
      friendly and don't retain any defunct object.
      0c0a639b
  3. 17 Nov, 2021 5 commits
    • Robert Knight's avatar
      492ab6d5
    • Robert Knight's avatar
      Add test page for PDF-based (aka. fixed-layout) VitalSource books · b1b81da4
      Robert Knight authored
      Create a test page for PDF-based VS books, using content adapted from
      https://bookshelf.vitalsource.com/reader/books/9781938168239/, an
      OpenStax textboot that is available for free [1] in VitalSource.
      
       - Rename vitalsource.mustache => vitalsource-epub.mustache to make the
         distinction with the PDF example clearer.
      
       - Create vitalsource-pdf.mustache which serves as the "container" page
         for a PDF-based VS book. This is a copy of vitalsource-epub.mustache
         with the Prev/Next buttons removed and slight terminology changes
         ("chapter" => "page") to reflect how PDFs are handled in VS
      
       - Revise the descriptive text at the top of the VS PDF and EPUB
         examples to explain the purpose more clearly and relate them to how
         books are presented in the Bookshelf store, where the terms
         "reflowable" and "fixed" are used instead of "EPUB" and "PDF".
      
       - Add a very lightly edited copy of a real content page from a VS book
         in vitalsource-pdf-page.mustache. This is the HTML content from the
         iframe displaying a page in a PDF book in VS. The only changes I have
         made are small block of CSS customizations at the top (see comment)
         and a change to the URL of the rendered PDF page.
      
       - Update the links to the VitalSource test pages on the dev server.
      
      [1] Even though the book is free, you have to add it to your VitalSource
          book library before you can access it. To do that, go to
          https://bookshelf.vitalsource.com and search for the book ID (9781938168239
          in this case), then click "Open Book".
      b1b81da4
    • Eduardo Sanz García's avatar
      Remove `authority` field from discovery message · 974b1de0
      Eduardo Sanz García authored
      Following these two comments:
      * https://github.com/hypothesis/client/pull/3929/files#r750399422
      * https://github.com/hypothesis/client/pull/3929/files#r750414036
      
      I am proposing in this PR to remove the anti-collision field `authority`
      from the message that is send to discover frames. I believe the message
      contains enough information to avoid to be confused by other unrelated
      `postMessage` in the host frame.
      974b1de0
    • Eduardo's avatar
      Apply suggestions from code review · 9dd2e994
      Eduardo authored
      Co-authored-by: 's avatarRobert Knight <robertknight@gmail.com>
      9dd2e994
    • Eduardo Sanz García's avatar
      Improve ergonomics of PortFinder and PortProvider · f1e042eb
      Eduardo Sanz García authored
      For PortFinder, I followed this advice:
      https://github.com/hypothesis/client/pull/3881#discussion_r743030606,
      except that I made the argument of `PorFinder#discover` and string
      (instead of an object).
      
      ```
      const portFinder = new PortFinder({ source: 'guest', hostFrame });
      portFinder.discover('sidebar');
      portFinder.discover('host');
      ```
      
      For PortProvider, I followed this advice:
      https://github.com/hypothesis/client/pull/3881#discussion_r743033013,
      except that I used a getter.
      
      ```
      cont portProvider = new PortProvider(...)
      const bridge = new Bridge();
      bridge.createChannel(portProvider.sidebarPort);
      ```
      
      I have renamed the properties of `Message`:
      - `source` becomes `authority`
      - `channel` and `port` have been replaced by `frame1` and `frame2`
      
      I did that to align `port1` and `frame1` and `port2` and `frame2`, while
      also avoiding clashing with other names (`source`, `target`) which have
      other meaning in the `window.postMessage` context.
      
      I have removed one level of nesting in the `PortProvider#discover` that
      make the method more readable.
      
      I added some other suggestions from PR #3881.
      f1e042eb
  4. 15 Nov, 2021 16 commits
  5. 12 Nov, 2021 4 commits
  6. 11 Nov, 2021 4 commits
    • Robert Knight's avatar
      Prevent Node globals from being included in typechecking environment · 63545fd3
      Robert Knight authored
      By default TypeScript includes all `@types/<name>` packages. This includes
      @types/node, though we don't use it directly, because it is a transitive
      dependency (see `yarn why @types/node`).
      
      As a result Node's globals are added to the environment TS sees, even though
      they don't really exist when our code runs in a browser. These globals
      include overloads for `setTimeout` and `setInterval` which return a different
      type (`Timeout`), causing spurious errors when assigning the result to a number.
      
      Fix the problem by using the `types` option [1] in tsconfig.json to explicitly
      specify which `@types/<name>` packages  to include when checking code in src/
      This does mean that if we ever intentionally add @types packages which declare
      globals (eg. for mocha), we'll need to explicitly list them here.
      
      In the process the ES target was updated to fix an error about a `BigInt` reference.
      
      [1] https://www.typescriptlang.org/tsconfig#types
      63545fd3
    • Robert Knight's avatar
      Adapt to `useRef` type changes · 8ee4ceca
      Robert Knight authored
      `useRef(null as T|null)` now returns a `{ current: T|null }` instead of
      `{ current: T }` as it did before. ie. it no longer drops the the null.
      This makes sense but conflicted with a pattern we used in many places to
      create a non-null ref: `useRef(/** @type {T|null} */ (null))`.
      
      Resolve this by changing all non-nullable refs, for elements which are
      set after the initial render, to cast the `useRef` result instead of the
      init value.
      
      ```
      const nonNullRef = /** @type {{ current: T }} */ (useRef());
      ```
      8ee4ceca
    • dependabot[bot]'s avatar
      Bump preact from 10.5.13 to 10.5.15 · 2bb54dcd
      dependabot[bot] authored
      Bumps [preact](https://github.com/preactjs/preact) from 10.5.13 to 10.5.15.
      - [Release notes](https://github.com/preactjs/preact/releases)
      - [Commits](https://github.com/preactjs/preact/compare/10.5.13...10.5.15)
      
      ---
      updated-dependencies:
      - dependency-name: preact
        dependency-type: direct:development
        update-type: version-update:semver-patch
      ...
      Signed-off-by: 's avatardependabot[bot] <support@github.com>
      2bb54dcd
    • Robert Knight's avatar
      Remove two unused dependencies · da7a056a
      Robert Knight authored
      - @actions/core was used when the @hypothesis/frontend-shared package was
        part of the client repo.
      - postcss-url was used prior to the introduction of
        @hypothesis/frontend-build
      da7a056a
  7. 09 Nov, 2021 7 commits