- 13 Sep, 2021 16 commits
-
-
Robert Knight authored
-
Robert Knight authored
See https://esbench.com/bench/613f1ca06c89f600a570114b for some related benchmarks.
-
Robert Knight authored
To reduce the chances of mis-anchoring quotes, check for a context match before stopping early. This helps when the quote is a word or phrase that is common in the document and the position hint is wrong, which can occur if the quote selector was created when using a different PDF viewer or version of PDF.js, which exacts text differently. For quotes captured at the start or end of a page we expect a mismatch in the prefix and suffix respectively because quote selectors can currently capture parts of the surrounding pages / DOM in `describe`, but when anchoring we only search for matches in one page of text at a time.
-
Robert Knight authored
We have a basic test of quote matching from the perspective of the `anchor` caller, but we really need to check the data passed to the quote matching logic in more detail.
-
Robert Knight authored
As described in #3705, stopping a quote search as soon as we find an approximate match could result in quotes anchoring to suboptimal matches if the position selector is no longer accurate. We want to balance finding the best match against making the search efficient in long documents. The approach taken in this commit is to continue to search pages in priority order, but instead of returning the first "good enough" match (below `matchQuote`'s error threshold), return the first exact match ignoring whitespace differences, or the nearest match in the whole document otherwise. We ignore whitespace differences because this is the main change between the current version of PDF.js that we include in Hypothesis products, and newer versions that we are trying to migrate to (see #3687). It is also likely to be the main source of text differences between PDF.js and other viewers. - Change `anchorQuote` to ignore whitespace differences when searching for approximate matches - Change `anchorQuote` to keep searching for the best match if it does not find a whitespace-insensitive exact match in the current page - Add tests for whitespace changes Fixes https://github.com/hypothesis/client/issues/3705
-
Robert Knight authored
Add tests to cover the cases where the position is on a page before the quote and where the position is negative.
-
Robert Knight authored
Refactor quote anchoring logic to use async/await instead of Promise chains to make control flow easier to follow and change. - Convert `getPageOffset` and `findPage` helper functions to use async/await rather than Promise chains. - Combine the `prioritizePages` and `findInPages` functions into a single `anchorQuote` function. Combining the two functions allows some redundant work to be eliminated. `findInPages` used to call `getPageOffset` for the current page on each iteration which would in turn fetch the text of every page until it reached the given offset. `prioritizePages` would do a very similar loop in order to enumerate pages close to the given offset. - Replace use of `TextQuoteAnchor.fromSelector` with direct use of `matchQuote`. `fromSelector` wasn't providing any value over just calling `matchQuote` directly, and it required a dummy DOM element to be created and have its text populated.
-
Eduardo Sanz García authored
In scss files, `@use "..."` has been replaced by `@use '...'" (single quotes instead of double).
-
dependabot[bot] authored
Bumps [prettier](https://github.com/prettier/prettier) from 2.3.2 to 2.4.0. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/2.3.2...2.4.0) --- updated-dependencies: - dependency-name: prettier dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
-
dependabot[bot] authored
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.4.2 to 4.4.3. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/compare/v4.4.2...v4.4.3) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
-
dependabot[bot] authored
Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.15.4 to 7.15.6. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.15.6/packages/babel-preset-env) --- updated-dependencies: - dependency-name: "@babel/preset-env" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
-
dependabot[bot] authored
Bumps [sass](https://github.com/sass/dart-sass) from 1.39.0 to 1.39.2. - [Release notes](https://github.com/sass/dart-sass/releases) - [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md) - [Commits](https://github.com/sass/dart-sass/compare/1.39.0...1.39.2) --- updated-dependencies: - dependency-name: sass dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
-
dependabot[bot] authored
Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.983.0 to 2.987.0. - [Release notes](https://github.com/aws/aws-sdk-js/releases) - [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-js/compare/v2.983.0...v2.987.0) --- updated-dependencies: - dependency-name: aws-sdk dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
-
dependabot[bot] authored
Bumps [core-js](https://github.com/zloirock/core-js) from 3.17.2 to 3.17.3. - [Release notes](https://github.com/zloirock/core-js/releases) - [Changelog](https://github.com/zloirock/core-js/blob/master/CHANGELOG.md) - [Commits](https://github.com/zloirock/core-js/compare/v3.17.2...v3.17.3) --- updated-dependencies: - dependency-name: core-js dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
-
dependabot[bot] authored
Bumps [commander](https://github.com/tj/commander.js) from 8.1.0 to 8.2.0. - [Release notes](https://github.com/tj/commander.js/releases) - [Changelog](https://github.com/tj/commander.js/blob/master/CHANGELOG.md) - [Commits](https://github.com/tj/commander.js/compare/v8.1.0...v8.2.0) --- updated-dependencies: - dependency-name: commander dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
-
dependabot[bot] authored
Bumps [@hypothesis/frontend-shared](https://github.com/hypothesis/frontend-shared) from 3.8.1 to 3.9.0. - [Release notes](https://github.com/hypothesis/frontend-shared/releases) - [Changelog](https://github.com/hypothesis/frontend-shared/blob/main/CHANGELOG.md) - [Commits](https://github.com/hypothesis/frontend-shared/compare/v3.8.1...v3.9.0) --- updated-dependencies: - dependency-name: "@hypothesis/frontend-shared" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
-
- 09 Sep, 2021 2 commits
-
-
Robert Knight authored
In https://github.com/mozilla/pdf.js/pull/13661 the API for retrieving PDF fingerprints (aka. File Identifiers) changed. In generic builds of PDF.js the old API remains available, but not in the non-generic one that Firefox's built-in viewer uses. This commit makes Hypothesis use the new API if available or the old API otherwise. The fingerprint value should be the same in both cases. Fixes #3673
-
Robert Knight authored
This is the result of running scripts/update-pdfjs.
-
- 08 Sep, 2021 19 commits
-
-
Eduardo Sanz García authored
Use async/await to simplify a test.
-
Eduardo Sanz García authored
-
Eduardo authored
* rename `embedElement` to `bootScript` * remove unused class
-
Eduardo Sanz García authored
* Created a helper function to test the addition of the Hypothesis script * Move all the helper functions before the `beforeEach`
-
Eduardo Sanz García authored
-
Eduardo Sanz García authored
`FrameObserver` could be disconnected while waiting for the loading of the iframe. We add a mechanism to avoid this race condition.
-
Eduardo Sanz García authored
Move documentation to the FrameObserver class. As suggested here: https://github.com/hypothesis/client/pull/3670#discussion_r686665805
-
Eduardo Sanz García authored
`_removeFrame` must be called in these three scenarios: - `enable-annotation` attribute is removed from iframe - `src` attribute is modified in the iframe - iframe is deleted When the iframe is deleted there are two possible paths for the execution of the `_removeFrame`: 1. First and faster execution of `_removeFrame`: `iframe.remove()` triggers the `unload` event which calls the `_removeFrame` 2. Second and delayed execution of `_removeFrame`: `iframe.remove()` triggers the `MutationObserver` (debounced by 40 ms). This could cause the `_removeFrame` to be fired if the first path would not remove the iframe from the list of `_handledFrames`. I moved the addition and deletion of the iframes to `_handledFrames` as earlier as possible in the `_addFrame` and `_removeFrame` methods to avoid racing conditions. A consequence of this is that the `_addFrame` is executed only once per iframe. If it fails (for example, because the iframe is from a different origin) it is not constantly retried.
-
Eduardo Sanz García authored
The `FrameObserver` unit test now exercise the whole class, not just the `findFrames` function. On a future commit, we will inline the `findFrames functionality.
-
Eduardo Sanz García authored
`onDocumentReady` returns now a Promise instead of calling a callback.
-
Eduardo Sanz García authored
The name of `isDocumentReady` gives the impressiong that the function would return a boolean. `onDocumentReady`, on the other hand, expresses more clearly that the execution of the callback will be triggered after the iframe's documen is ready (loaded and parsed). On a follow up commit I change the `onDocumentReady` to return a Promise instead of executing a callback.
-
Eduardo Sanz García authored
`Set` is a better data structure because it has a faster search: `Set.has` has a O(1) while `Array.includes` has a O(n).
-
Eduardo Sanz García authored
Moved `frame-util` functionality to `frame-observer.js` and `hypothesis-injector.js`: - `isAccessible`, `findFrames` and `isDocumentReady` functions to `frame-observer.js`, and - `hasHypothesis` and `injectHypothesis` functions to `hypothesis-injector.js` Renamed and move `src/annotator/util/test/frame-util-test.js` to `src/annotator/test/frame-observer-test.js`. This unit test only exercise the `findFrames` function.
-
Eduardo Sanz García authored
I run this command `prettier -w --parser html` on `shadow-dom.mustache`
-
Eduardo Sanz García authored
In the latest version of the frontent-shared package, `extraRoute` has a mandatory property `group` that must be either `"home" | "foundations" | "patterns" | "components"`; There are three ways to fix this: * make the `group` property optional in the frontend-shared package (I don't know if that's a good idea). * cast the `string` type to the one of the allowed types: ` group: /** @type {'components'} */ ('components'),` * cast the `extraRoute` (this PR).
-
Eduardo Sanz García authored
-
Eduardo Sanz García authored
Edge 17 complains if the script is outside the body.
-
Eduardo Sanz García authored
The current inter-frame communication doesn't work if an annotatable (guest) iframe is from a different origin than the host frame (see https://github.com/hypothesis/client/pull/3611#issue-696947005). This will be fixed in a more comprehensive overhaul of the inter-face communication (see https://github.com/hypothesis/client/issues/3533). Meanwhile, I add a scenario into the local dev server where the annotatable iframe is from an origin different than the host frame. For this, I needed to spawn an additional dev server at port 3002): ``` [11:32:50] Dev web server started at http://localhost:3000/ [11:32:50] Dev web server started at http://localhost:3002/ ``` Close #3629
-
Robert Knight authored
Fix an issue where the sidebar failed to appear in Safari 11 and Chrome 63 when returning a cross-origin Window from a Promise `then` callback. In these browsers an exception is triggered when the browser tries to test if the return value is a Promise that can be unwrapped. The issue was resolved in more recent browsers by adding an undefined `then` property to cross origin objects. [1] [1] https://github.com/whatwg/dom/issues/536
-
- 06 Sep, 2021 3 commits
-
-
dependabot[bot] authored
Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.15.0 to 7.15.4. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.15.4/packages/babel-preset-env) --- updated-dependencies: - dependency-name: "@babel/preset-env" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
-
dependabot[bot] authored
Bumps [@hypothesis/frontend-shared](https://github.com/hypothesis/frontend-shared) from 3.7.0 to 3.8.1. - [Release notes](https://github.com/hypothesis/frontend-shared/releases) - [Changelog](https://github.com/hypothesis/frontend-shared/blob/main/CHANGELOG.md) - [Commits](https://github.com/hypothesis/frontend-shared/compare/v3.7.0...v3.8.1) --- updated-dependencies: - dependency-name: "@hypothesis/frontend-shared" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
-
dependabot[bot] authored
Bumps [autoprefixer](https://github.com/postcss/autoprefixer) from 10.3.3 to 10.3.4. - [Release notes](https://github.com/postcss/autoprefixer/releases) - [Changelog](https://github.com/postcss/autoprefixer/blob/main/CHANGELOG.md) - [Commits](https://github.com/postcss/autoprefixer/compare/10.3.3...10.3.4) --- updated-dependencies: - dependency-name: autoprefixer dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
-