@reticlehq/browser 3.8.2 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/reticle.js CHANGED
@@ -4,7 +4,7 @@ import { declareRoutes } from './observers/route.js';
4
4
  import { setOutwardPolicy } from './actions/danger-context.js';
5
5
  import { coverageMarkers, notApplicableFor } from './dom/addressing/coverage-markers.js';
6
6
  import { EventType, RETICLE_DEFAULT_PORT, RETICLE_PROTOCOL_VERSION, RETICLE_URL_PARAM, RETICLE_WS_PATH, bridgeWsUrl, ReticleCommand, MessageKind, SESSION_AUTO, SessionState, TRANSPORT_LIMITS, buildRedactionPolicy, isLoopbackHostname, isLocalPage, setActiveRedactionPolicy, wireRedactionKeys, RETICLE_ROOT_GLOBAL, RETICLE_SDK_VERSION_GLOBAL, CONTRACT_FINGERPRINT, CONTRACT_PARTS, newDocumentId, NO_EDITS_OBSERVED, PresenterMode, CommandActor, HudCorner, HudVisibility, } from '@reticlehq/core';
7
- import { rememberSessionLabel } from './session-continuity.js';
7
+ import { rememberSessionLabel, tabSessionStore } from './session-continuity.js';
8
8
  import { editEpoch } from './edit-epoch.js';
9
9
  import { createCommandRegistry, RELOAD_CACHE_BUST_PARAM, } from './commands/commands.js';
10
10
  import { Transport } from './transport/transport.js';
@@ -203,7 +203,7 @@ export class Reticle {
203
203
  : undefined;
204
204
  const identity = resolveConnectIdentity(options, window.location.search);
205
205
  const explicitSession = resolveSessionLabel(identity.session, () => '');
206
- this.#session = rememberSessionLabel(explicitSession.length > 0 ? explicitSession : undefined, 'undefined' === typeof globalThis.sessionStorage ? undefined : globalThis.sessionStorage, () => 'function' === typeof globalThis.crypto?.randomUUID
206
+ this.#session = rememberSessionLabel(explicitSession.length > 0 ? explicitSession : undefined, tabSessionStore(window), () => 'function' === typeof globalThis.crypto?.randomUUID
207
207
  ? `s${globalThis.crypto.randomUUID()}`
208
208
  : `s${Date.now().toString(36)}`);
209
209
  this.#token =
@@ -69,6 +69,10 @@ export class Annotator {
69
69
  mount() {
70
70
  if (this.#root !== undefined || 'undefined' === typeof document)
71
71
  return;
72
+ if (null === document.head || null === document.body) {
73
+ document.addEventListener('DOMContentLoaded', () => this.mount(), { once: true });
74
+ return;
75
+ }
72
76
  const style = document.createElement('style');
73
77
  style.setAttribute(MARK_ATTR, 'style');
74
78
  style.textContent = ANNOTATOR_CSS;
@@ -1 +1,2 @@
1
1
  export declare function rememberSessionLabel(explicit: string | undefined, store: Storage | undefined, generate: () => string): string;
2
+ export declare function tabSessionStore(win: Window & typeof globalThis): Storage | undefined;
@@ -22,3 +22,21 @@ export function rememberSessionLabel(explicit, store, generate) {
22
22
  write(chosen);
23
23
  return chosen;
24
24
  }
25
+ export function tabSessionStore(win) {
26
+ let topFrame;
27
+ try {
28
+ topFrame = win.top === win;
29
+ }
30
+ catch {
31
+ topFrame = false;
32
+ }
33
+ if (!topFrame) {
34
+ return undefined;
35
+ }
36
+ try {
37
+ return win.sessionStorage;
38
+ }
39
+ catch {
40
+ return undefined;
41
+ }
42
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reticlehq/browser",
3
- "version": "3.8.2",
3
+ "version": "3.9.0",
4
4
  "description": "Reticle browser SDK — installs observers, builds semantic snapshots, executes actions, talks to the bridge.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,7 +22,7 @@
22
22
  }
23
23
  },
24
24
  "dependencies": {
25
- "@reticlehq/core": "3.8.2"
25
+ "@reticlehq/core": "3.9.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@iconify-json/heroicons-outline": "^1.2.1",