@harborclient/sdk 0.6.17 → 0.7.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.
Files changed (45) hide show
  1. package/dist/components/index.d.ts +0 -1
  2. package/dist/components/index.d.ts.map +1 -1
  3. package/dist/components/index.js +0 -1
  4. package/dist/http/resolveRequest.test.js +1 -2
  5. package/dist/runtime/react.d.ts +0 -6
  6. package/dist/runtime/react.js +2 -70
  7. package/dist/runtime/reactHost.js +0 -52
  8. package/dist/runtime/store.d.ts +0 -101
  9. package/dist/runtime/store.d.ts.map +1 -1
  10. package/dist/runtime/store.js +0 -94
  11. package/dist/runtime/store.ts +0 -203
  12. package/dist/runtime/viewHost.js +1 -2
  13. package/dist/runtime-utils.d.ts +0 -59
  14. package/dist/runtime-utils.d.ts.map +1 -1
  15. package/dist/runtime-utils.js +0 -66
  16. package/dist/runtime-utils.test.js +1 -74
  17. package/dist/storage/index.d.ts +0 -1
  18. package/dist/storage/index.d.ts.map +1 -1
  19. package/dist/storage/index.js +0 -1
  20. package/dist/types.d.ts +0 -14
  21. package/dist/types.d.ts.map +1 -1
  22. package/package.json +7 -35
  23. package/dist/build/index.d.ts +0 -59
  24. package/dist/build/index.d.ts.map +0 -1
  25. package/dist/build/index.js +0 -107
  26. package/dist/components/portalToBody.d.ts +0 -10
  27. package/dist/components/portalToBody.d.ts.map +0 -1
  28. package/dist/components/portalToBody.js +0 -14
  29. package/dist/eslint/index.d.ts +0 -9
  30. package/dist/eslint/index.d.ts.map +0 -1
  31. package/dist/eslint/index.js +0 -18
  32. package/dist/runtime/jsx-runtime-host.d.ts +0 -44
  33. package/dist/runtime/jsx-runtime-host.js +0 -42
  34. package/dist/runtime/react-dom.d.ts +0 -1
  35. package/dist/runtime/react-dom.js +0 -16
  36. package/dist/storage/validate.d.ts +0 -71
  37. package/dist/storage/validate.d.ts.map +0 -1
  38. package/dist/storage/validate.js +0 -111
  39. package/dist/storage/validate.test.d.ts +0 -2
  40. package/dist/storage/validate.test.d.ts.map +0 -1
  41. package/dist/storage/validate.test.js +0 -78
  42. package/dist/store.test.d.ts +0 -2
  43. package/dist/store.test.d.ts.map +0 -1
  44. package/dist/store.test.js +0 -248
  45. package/tsconfig.base.json +0 -15
@@ -24,7 +24,6 @@ export type { Props as KeyValueEditorProps } from './KeyValueEditor/index.js';
24
24
  export { MethodSelect } from './MethodSelect/index.js';
25
25
  export { Modal, ModalFooter, ModalFormLayout } from './Modal/index.js';
26
26
  export { ModalHeader } from './Modal/ModalHeader.js';
27
- export { portalToBody } from './portalToBody.js';
28
27
  export { OverlayCloseButton } from './OverlayCloseButton/index.js';
29
28
  export { Page } from './Page/index.js';
30
29
  export { PageHeader } from './PageHeader/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,YAAY,EAAE,KAAK,IAAI,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,0BAA0B,EAC3B,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EAAE,KAAK,IAAI,eAAe,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,E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AAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
@@ -17,7 +17,6 @@ export { KeyValueEditor } from './KeyValueEditor/index.js';
17
17
  export { MethodSelect } from './MethodSelect/index.js';
18
18
  export { Modal, ModalFooter, ModalFormLayout } from './Modal/index.js';
19
19
  export { ModalHeader } from './Modal/ModalHeader.js';
20
- export { portalToBody } from './portalToBody.js';
21
20
  export { OverlayCloseButton } from './OverlayCloseButton/index.js';
22
21
  export { Page } from './Page/index.js';
23
22
  export { PageHeader } from './PageHeader/index.js';
@@ -30,8 +30,7 @@ describe('resolveRequest', () => {
30
30
  bearer: { token: '{{token}}' }
31
31
  },
32
32
  collectionHeaders: [{ key: 'Accept', value: 'application/json', enabled: true }],
33
- variables: { base: 'https://api.test', token: 'secret' },
34
- requestKey: 'POST https://api.test/users'
33
+ variables: { base: 'https://api.test', token: 'secret' }
35
34
  };
36
35
  const resolved = resolveRequest(context);
37
36
  expect(resolved.url).toBe('https://api.test/users?page=1');
@@ -6,7 +6,6 @@ export {
6
6
  useRef,
7
7
  useSyncExternalStore,
8
8
  forwardRef,
9
- useImperativeHandle,
10
9
  cloneElement,
11
10
  isValidElement,
12
11
  createContext,
@@ -15,8 +14,3 @@ export {
15
14
  useLayoutEffect,
16
15
  createElement
17
16
  } from 'react';
18
-
19
- import type * as React from 'react';
20
-
21
- declare const _default: typeof React;
22
- export default _default;
@@ -45,40 +45,9 @@ export function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)
45
45
  return hook('useSyncExternalStore')(subscribe, getSnapshot, getServerSnapshot);
46
46
  }
47
47
 
48
- /**
49
- * Defers host React lookup until render so module-level `React.forwardRef(...)`
50
- * calls (e.g. from @fortawesome/react-fontawesome) work before activate().
51
- *
52
- * @type {typeof import('react').forwardRef}
53
- */
48
+ /** @type {typeof import('react').forwardRef} */
54
49
  export function forwardRef(render) {
55
- /** @type {ReturnType<typeof import('react').forwardRef> | null} */
56
- let forwarded = null;
57
-
58
- /**
59
- * Lazily wraps the render function with host React.forwardRef on first render.
60
- *
61
- * @param {Record<string, unknown>} props - Component props.
62
- * @param {import('react').Ref<unknown>} ref - Ref forwarded from the parent.
63
- * @returns {import('react').ReactElement}
64
- */
65
- function LazyForwardRef(props, ref) {
66
- const react = requireHostReact();
67
- if (forwarded === null) {
68
- forwarded = react.forwardRef(render);
69
- }
70
- return react.createElement(forwarded, { ...props, ref });
71
- }
72
-
73
- const displayName = render.displayName ?? render.name ?? 'Component';
74
- LazyForwardRef.displayName = `ForwardRef(${displayName})`;
75
-
76
- return LazyForwardRef;
77
- }
78
-
79
- /** @type {typeof import('react').useImperativeHandle} */
80
- export function useImperativeHandle(ref, create, deps) {
81
- return hook('useImperativeHandle')(ref, create, deps);
50
+ return hook('forwardRef')(render);
82
51
  }
83
52
 
84
53
  /** @type {typeof import('react').cloneElement} */
@@ -115,40 +84,3 @@ export function useLayoutEffect(effect, deps) {
115
84
  export function createElement(type, props, ...children) {
116
85
  return hook('createElement')(type, props, ...children);
117
86
  }
118
-
119
- /**
120
- * Named SDK React exports used as the Proxy target for the default export.
121
- */
122
- const reactNamespace = {
123
- useState,
124
- useEffect,
125
- useCallback,
126
- useMemo,
127
- useRef,
128
- useSyncExternalStore,
129
- forwardRef,
130
- useImperativeHandle,
131
- cloneElement,
132
- isValidElement,
133
- createContext,
134
- useContext,
135
- useId,
136
- useLayoutEffect,
137
- createElement
138
- };
139
-
140
- /**
141
- * Default React namespace for `import React from 'react'` when aliasing bare
142
- * `react` to `@harborclient/sdk/react`. Named exports are served from the SDK;
143
- * other properties fall back to the installed host React instance.
144
- */
145
- const defaultExport = new Proxy(reactNamespace, {
146
- get(target, prop, receiver) {
147
- if (prop in target) {
148
- return Reflect.get(target, prop, receiver);
149
- }
150
- return requireHostReact()[prop];
151
- }
152
- });
153
-
154
- export default defaultExport;
@@ -1,15 +1,9 @@
1
1
  /** Global key shared across bundled plugin copies of this module and the view host. */
2
2
  const HOST_REACT_GLOBAL_KEY = '__HARBORCLIENT_HOST_REACT__';
3
3
 
4
- /** Global key for the host React DOM instance (createPortal, etc.). */
5
- const HOST_REACT_DOM_GLOBAL_KEY = '__HARBORCLIENT_HOST_REACT_DOM__';
6
-
7
4
  /** @type {typeof import('react') | null} */
8
5
  let hostReact = null;
9
6
 
10
- /** @type {typeof import('react-dom') | null} */
11
- let hostReactDom = null;
12
-
13
7
  /**
14
8
  * Reads the host React instance published on globalThis by the view host bootstrap.
15
9
  *
@@ -58,49 +52,3 @@ export function requireHostReact() {
58
52
  }
59
53
  return hostReact;
60
54
  }
61
-
62
- /**
63
- * Reads the host React DOM instance published on globalThis by the view host bootstrap.
64
- *
65
- * @returns {typeof import('react-dom') | null} Host React DOM when available.
66
- */
67
- function readGlobalHostReactDom() {
68
- if (typeof globalThis === 'undefined') {
69
- return null;
70
- }
71
- const candidate = globalThis[HOST_REACT_DOM_GLOBAL_KEY];
72
- return candidate ?? null;
73
- }
74
-
75
- /**
76
- * Installs the HarborClient renderer React DOM instance for plugin portals.
77
- *
78
- * @param {typeof import('react-dom')} reactDom - React DOM namespace from the host shim.
79
- */
80
- export function setHostReactDom(reactDom) {
81
- hostReactDom = reactDom;
82
- if (typeof globalThis !== 'undefined') {
83
- globalThis[HOST_REACT_DOM_GLOBAL_KEY] = reactDom;
84
- }
85
- }
86
-
87
- /**
88
- * Returns the installed host React DOM instance.
89
- *
90
- * @returns {typeof import('react-dom')} Host React DOM namespace.
91
- * @throws {Error} When {@link setHostReactDom} has not been called yet.
92
- */
93
- export function requireHostReactDom() {
94
- if (hostReactDom == null) {
95
- const globalReactDom = readGlobalHostReactDom();
96
- if (globalReactDom != null) {
97
- hostReactDom = globalReactDom;
98
- }
99
- }
100
- if (hostReactDom == null) {
101
- throw new Error(
102
- 'Plugin React DOM host is not installed. The view host must call setHostReactDom() before activate().'
103
- );
104
- }
105
- return hostReactDom;
106
- }
@@ -1,85 +1,4 @@
1
1
  import type { Disposable } from '../types.js';
2
- /**
3
- * Minimal storage surface used by {@link createStorageStore}.
4
- */
5
- export interface StorageLike {
6
- /**
7
- * Returns the stored value for a key.
8
- *
9
- * @param key - Storage key within the plugin namespace.
10
- */
11
- get<T>(key: string): Promise<T | undefined>;
12
- /**
13
- * Persists a JSON-serializable value.
14
- *
15
- * @param key - Storage key within the plugin namespace.
16
- * @param value - Value to persist.
17
- */
18
- set<T>(key: string, value: T): Promise<void>;
19
- }
20
- /**
21
- * Reactive store backed by plugin storage and compatible with React
22
- * `useSyncExternalStore`.
23
- */
24
- export interface StorageStore<T> {
25
- /**
26
- * Subscribes to snapshot changes for `useSyncExternalStore`.
27
- *
28
- * @param listener - Callback invoked when the snapshot changes.
29
- */
30
- subscribe(listener: () => void): () => void;
31
- /**
32
- * Returns the current in-memory snapshot.
33
- */
34
- getSnapshot(): T;
35
- /**
36
- * React hook returning the current snapshot.
37
- */
38
- useValue(): T;
39
- /**
40
- * Reloads from storage and notifies subscribers when the parsed value changed.
41
- */
42
- reloadFromStorage(): Promise<void>;
43
- /**
44
- * Updates the in-memory snapshot, notifies subscribers, and persists to storage.
45
- *
46
- * @param next - New snapshot value.
47
- */
48
- set(next: T): Promise<void>;
49
- }
50
- /**
51
- * Options for {@link createStorageStore}.
52
- */
53
- export interface CreateStorageStoreOptions<T> {
54
- /** Plugin storage API from `hc.storage`. */
55
- storage: StorageLike;
56
- /** Storage key within the plugin namespace. */
57
- key: string;
58
- /**
59
- * Validates and hydrates a raw storage value into a typed snapshot.
60
- * Called with `undefined` when the key has never been set.
61
- *
62
- * @param raw - Raw value from storage, or `undefined` when absent.
63
- */
64
- parse: (raw: unknown) => T;
65
- /**
66
- * Compares two snapshots to skip no-op reloads and writes.
67
- * Defaults to `JSON.stringify` equality.
68
- */
69
- equals?: (a: T, b: T) => boolean;
70
- /**
71
- * When true, {@link StorageStore.reloadFromStorage} leaves the snapshot
72
- * unchanged if the storage key is absent. Default false (apply `parse(undefined)`).
73
- */
74
- keepCurrentWhenMissing?: boolean;
75
- }
76
- /**
77
- * Options for {@link syncOnWindowFocus}.
78
- */
79
- export interface SyncOnWindowFocusOptions {
80
- /** Optional polling interval in milliseconds in addition to focus/visibility reloads. */
81
- intervalMs?: number;
82
- }
83
2
  /**
84
3
  * Creates a module-level external store compatible with React `useSyncExternalStore`.
85
4
  *
@@ -90,15 +9,6 @@ export declare function createExternalStore<T>(initial: T): {
90
9
  getSnapshot: () => T;
91
10
  setState: (next: T) => void;
92
11
  };
93
- /**
94
- * Creates a storage-backed external store for sharing state across plugin webviews.
95
- *
96
- * Separate plugin webviews do not share memory; use {@link syncOnWindowFocus} to
97
- * reload when another surface writes storage.
98
- *
99
- * @param options - Storage key, parse/equals helpers, and the plugin storage API.
100
- */
101
- export declare function createStorageStore<T>(options: CreateStorageStoreOptions<T>): StorageStore<T>;
102
12
  /**
103
13
  * Starts an interval and returns a disposable that clears it on deactivation.
104
14
  *
@@ -106,15 +16,4 @@ export declare function createStorageStore<T>(options: CreateStorageStoreOptions
106
16
  * @param intervalMs - Interval in milliseconds.
107
17
  */
108
18
  export declare function setIntervalDisposable(callback: () => void, intervalMs: number): Disposable;
109
- /**
110
- * Reloads one or more storage-backed stores when the window regains focus or
111
- * becomes visible, with optional polling for live cross-webview updates.
112
- *
113
- * Push the returned disposable onto `hc.subscriptions`, or dispose it from a
114
- * React effect cleanup.
115
- *
116
- * @param stores - One store or an array of stores to reload together.
117
- * @param options - Optional polling interval in milliseconds.
118
- */
119
- export declare function syncOnWindowFocus(stores: StorageStore<unknown> | StorageStore<unknown>[], options?: SyncOnWindowFocusOptions): Disposable;
120
19
  //# sourceMappingURL=store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/runtime/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C;;GAEG;AACH,MAAM,WAAW,WAAW;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AAM,IAAI,CAAC;IAChD,WAAW,EAAE,MAAM,CAAC,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;CAC7B,CAkBA;AAYD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,EAAE,yBAAyB,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CA+C5F;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,CAO1F;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,EAAE,EACvD,OAAO,CAAC,EAAE,wBAAwB,GACjC,UAAU,CA0BZ"}
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/runtime/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG;IAClD,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAChD,WAAW,EAAE,MAAM,CAAC,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;CAC7B,CAkBA;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,CAO1F"}
@@ -1,4 +1,3 @@
1
- import { useSyncExternalStore } from './react.js';
2
1
  /**
3
2
  * Creates a module-level external store compatible with React `useSyncExternalStore`.
4
3
  *
@@ -23,67 +22,6 @@ export function createExternalStore(initial) {
23
22
  }
24
23
  };
25
24
  }
26
- /**
27
- * Compares two JSON-serializable values using `JSON.stringify`.
28
- *
29
- * @param a - First value.
30
- * @param b - Second value.
31
- */
32
- function defaultEquals(a, b) {
33
- return JSON.stringify(a) === JSON.stringify(b);
34
- }
35
- /**
36
- * Creates a storage-backed external store for sharing state across plugin webviews.
37
- *
38
- * Separate plugin webviews do not share memory; use {@link syncOnWindowFocus} to
39
- * reload when another surface writes storage.
40
- *
41
- * @param options - Storage key, parse/equals helpers, and the plugin storage API.
42
- */
43
- export function createStorageStore(options) {
44
- const { storage, key, parse, equals = defaultEquals, keepCurrentWhenMissing = false } = options;
45
- const external = createExternalStore(parse(undefined));
46
- /**
47
- * Reloads from storage and updates subscribers when the parsed snapshot changed.
48
- */
49
- async function reloadFromStorage() {
50
- const raw = await storage.get(key);
51
- if (raw === undefined && keepCurrentWhenMissing) {
52
- return;
53
- }
54
- const next = parse(raw);
55
- const current = external.getSnapshot();
56
- if (!equals(current, next)) {
57
- external.setState(next);
58
- }
59
- }
60
- /**
61
- * Updates the snapshot, notifies subscribers, and persists when the value changed.
62
- *
63
- * @param next - New snapshot value.
64
- */
65
- async function set(next) {
66
- const current = external.getSnapshot();
67
- if (equals(current, next)) {
68
- return;
69
- }
70
- external.setState(next);
71
- await storage.set(key, next);
72
- }
73
- /**
74
- * React hook returning the current storage-backed snapshot.
75
- */
76
- function useValue() {
77
- return useSyncExternalStore(external.subscribe, external.getSnapshot, external.getSnapshot);
78
- }
79
- return {
80
- subscribe: external.subscribe,
81
- getSnapshot: external.getSnapshot,
82
- useValue,
83
- reloadFromStorage,
84
- set
85
- };
86
- }
87
25
  /**
88
26
  * Starts an interval and returns a disposable that clears it on deactivation.
89
27
  *
@@ -98,35 +36,3 @@ export function setIntervalDisposable(callback, intervalMs) {
98
36
  }
99
37
  };
100
38
  }
101
- /**
102
- * Reloads one or more storage-backed stores when the window regains focus or
103
- * becomes visible, with optional polling for live cross-webview updates.
104
- *
105
- * Push the returned disposable onto `hc.subscriptions`, or dispose it from a
106
- * React effect cleanup.
107
- *
108
- * @param stores - One store or an array of stores to reload together.
109
- * @param options - Optional polling interval in milliseconds.
110
- */
111
- export function syncOnWindowFocus(stores, options) {
112
- const list = Array.isArray(stores) ? stores : [stores];
113
- /**
114
- * Reloads every registered store from plugin storage.
115
- */
116
- const reload = () => {
117
- for (const store of list) {
118
- void store.reloadFromStorage();
119
- }
120
- };
121
- window.addEventListener('focus', reload);
122
- document.addEventListener('visibilitychange', reload);
123
- reload();
124
- const intervalDisposable = options?.intervalMs !== undefined ? setIntervalDisposable(reload, options.intervalMs) : null;
125
- return {
126
- dispose: () => {
127
- window.removeEventListener('focus', reload);
128
- document.removeEventListener('visibilitychange', reload);
129
- intervalDisposable?.dispose();
130
- }
131
- };
132
- }
@@ -1,99 +1,4 @@
1
1
  import type { Disposable } from '../types.js';
2
- import { useSyncExternalStore } from './react.js';
3
-
4
- /**
5
- * Minimal storage surface used by {@link createStorageStore}.
6
- */
7
- export interface StorageLike {
8
- /**
9
- * Returns the stored value for a key.
10
- *
11
- * @param key - Storage key within the plugin namespace.
12
- */
13
- get<T>(key: string): Promise<T | undefined>;
14
-
15
- /**
16
- * Persists a JSON-serializable value.
17
- *
18
- * @param key - Storage key within the plugin namespace.
19
- * @param value - Value to persist.
20
- */
21
- set<T>(key: string, value: T): Promise<void>;
22
- }
23
-
24
- /**
25
- * Reactive store backed by plugin storage and compatible with React
26
- * `useSyncExternalStore`.
27
- */
28
- export interface StorageStore<T> {
29
- /**
30
- * Subscribes to snapshot changes for `useSyncExternalStore`.
31
- *
32
- * @param listener - Callback invoked when the snapshot changes.
33
- */
34
- subscribe(listener: () => void): () => void;
35
-
36
- /**
37
- * Returns the current in-memory snapshot.
38
- */
39
- getSnapshot(): T;
40
-
41
- /**
42
- * React hook returning the current snapshot.
43
- */
44
- useValue(): T;
45
-
46
- /**
47
- * Reloads from storage and notifies subscribers when the parsed value changed.
48
- */
49
- reloadFromStorage(): Promise<void>;
50
-
51
- /**
52
- * Updates the in-memory snapshot, notifies subscribers, and persists to storage.
53
- *
54
- * @param next - New snapshot value.
55
- */
56
- set(next: T): Promise<void>;
57
- }
58
-
59
- /**
60
- * Options for {@link createStorageStore}.
61
- */
62
- export interface CreateStorageStoreOptions<T> {
63
- /** Plugin storage API from `hc.storage`. */
64
- storage: StorageLike;
65
-
66
- /** Storage key within the plugin namespace. */
67
- key: string;
68
-
69
- /**
70
- * Validates and hydrates a raw storage value into a typed snapshot.
71
- * Called with `undefined` when the key has never been set.
72
- *
73
- * @param raw - Raw value from storage, or `undefined` when absent.
74
- */
75
- parse: (raw: unknown) => T;
76
-
77
- /**
78
- * Compares two snapshots to skip no-op reloads and writes.
79
- * Defaults to `JSON.stringify` equality.
80
- */
81
- equals?: (a: T, b: T) => boolean;
82
-
83
- /**
84
- * When true, {@link StorageStore.reloadFromStorage} leaves the snapshot
85
- * unchanged if the storage key is absent. Default false (apply `parse(undefined)`).
86
- */
87
- keepCurrentWhenMissing?: boolean;
88
- }
89
-
90
- /**
91
- * Options for {@link syncOnWindowFocus}.
92
- */
93
- export interface SyncOnWindowFocusOptions {
94
- /** Optional polling interval in milliseconds in addition to focus/visibility reloads. */
95
- intervalMs?: number;
96
- }
97
2
 
98
3
  /**
99
4
  * Creates a module-level external store compatible with React `useSyncExternalStore`.
@@ -124,73 +29,6 @@ export function createExternalStore<T>(initial: T): {
124
29
  };
125
30
  }
126
31
 
127
- /**
128
- * Compares two JSON-serializable values using `JSON.stringify`.
129
- *
130
- * @param a - First value.
131
- * @param b - Second value.
132
- */
133
- function defaultEquals<T>(a: T, b: T): boolean {
134
- return JSON.stringify(a) === JSON.stringify(b);
135
- }
136
-
137
- /**
138
- * Creates a storage-backed external store for sharing state across plugin webviews.
139
- *
140
- * Separate plugin webviews do not share memory; use {@link syncOnWindowFocus} to
141
- * reload when another surface writes storage.
142
- *
143
- * @param options - Storage key, parse/equals helpers, and the plugin storage API.
144
- */
145
- export function createStorageStore<T>(options: CreateStorageStoreOptions<T>): StorageStore<T> {
146
- const { storage, key, parse, equals = defaultEquals, keepCurrentWhenMissing = false } = options;
147
- const external = createExternalStore(parse(undefined));
148
-
149
- /**
150
- * Reloads from storage and updates subscribers when the parsed snapshot changed.
151
- */
152
- async function reloadFromStorage(): Promise<void> {
153
- const raw = await storage.get(key);
154
- if (raw === undefined && keepCurrentWhenMissing) {
155
- return;
156
- }
157
- const next = parse(raw);
158
- const current = external.getSnapshot();
159
- if (!equals(current, next)) {
160
- external.setState(next);
161
- }
162
- }
163
-
164
- /**
165
- * Updates the snapshot, notifies subscribers, and persists when the value changed.
166
- *
167
- * @param next - New snapshot value.
168
- */
169
- async function set(next: T): Promise<void> {
170
- const current = external.getSnapshot();
171
- if (equals(current, next)) {
172
- return;
173
- }
174
- external.setState(next);
175
- await storage.set(key, next);
176
- }
177
-
178
- /**
179
- * React hook returning the current storage-backed snapshot.
180
- */
181
- function useValue(): T {
182
- return useSyncExternalStore(external.subscribe, external.getSnapshot, external.getSnapshot);
183
- }
184
-
185
- return {
186
- subscribe: external.subscribe,
187
- getSnapshot: external.getSnapshot,
188
- useValue,
189
- reloadFromStorage,
190
- set
191
- };
192
- }
193
-
194
32
  /**
195
33
  * Starts an interval and returns a disposable that clears it on deactivation.
196
34
  *
@@ -205,44 +43,3 @@ export function setIntervalDisposable(callback: () => void, intervalMs: number):
205
43
  }
206
44
  };
207
45
  }
208
-
209
- /**
210
- * Reloads one or more storage-backed stores when the window regains focus or
211
- * becomes visible, with optional polling for live cross-webview updates.
212
- *
213
- * Push the returned disposable onto `hc.subscriptions`, or dispose it from a
214
- * React effect cleanup.
215
- *
216
- * @param stores - One store or an array of stores to reload together.
217
- * @param options - Optional polling interval in milliseconds.
218
- */
219
- export function syncOnWindowFocus(
220
- stores: StorageStore<unknown> | StorageStore<unknown>[],
221
- options?: SyncOnWindowFocusOptions
222
- ): Disposable {
223
- const list = Array.isArray(stores) ? stores : [stores];
224
-
225
- /**
226
- * Reloads every registered store from plugin storage.
227
- */
228
- const reload = (): void => {
229
- for (const store of list) {
230
- void store.reloadFromStorage();
231
- }
232
- };
233
-
234
- window.addEventListener('focus', reload);
235
- document.addEventListener('visibilitychange', reload);
236
- reload();
237
-
238
- const intervalDisposable =
239
- options?.intervalMs !== undefined ? setIntervalDisposable(reload, options.intervalMs) : null;
240
-
241
- return {
242
- dispose: () => {
243
- window.removeEventListener('focus', reload);
244
- document.removeEventListener('visibilitychange', reload);
245
- intervalDisposable?.dispose();
246
- }
247
- };
248
- }
@@ -7,7 +7,7 @@ import {
7
7
  parseViewHostRole,
8
8
  resolveContributionKindFromUrl
9
9
  } from './createBridgedPluginContext.js';
10
- import { setHostReact, setHostReactDom } from './reactHost.js';
10
+ import { setHostReact } from './reactHost.js';
11
11
 
12
12
  /**
13
13
  * Bootstraps an isolated plugin webview shell.
@@ -47,7 +47,6 @@ export async function bootstrapViewHost(options = {}) {
47
47
  ]);
48
48
 
49
49
  setHostReact(React);
50
- setHostReactDom(ReactDOM);
51
50
 
52
51
  const manifest = await fetch(`harbor-plugin://${pluginId}/manifest.json`).then((response) =>
53
52
  response.json()