@usequeek/app-sdk 0.7.1 → 0.7.2

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/theme.d.ts CHANGED
@@ -89,7 +89,8 @@ export interface ThemeListenerOptions {
89
89
  replaceUrl?: (url: string) => void;
90
90
  }
91
91
  /**
92
- * Follow live dashboard theme changes: announces `ready` on subscribe (so a
92
+ * Follow live dashboard theme changes: announces `ready` on subscribe, to
93
+ * `postTarget` or, by default, the framing parent window (so a
93
94
  * non-React app gets the mode even after an in-frame reload), then every
94
95
  * bridge `theme{mode}` toggles the `dark` class, is remembered for the
95
96
  * bootstrap fallback, and notifies `onChange`. Applies nothing else on
package/dist/theme.js CHANGED
@@ -30,6 +30,14 @@ function globalSessionStorage() {
30
30
  function globalParent() {
31
31
  return globalThis.window?.parent;
32
32
  }
33
+ /** The framing parent window, or undefined when the app is the top-level document. */
34
+ function framingParent() {
35
+ const win = globalThis.window;
36
+ const parent = win?.parent;
37
+ return parent !== undefined && parent !== win && typeof parent.postMessage === "function"
38
+ ? parent
39
+ : undefined;
40
+ }
33
41
  function globalDocument() {
34
42
  const doc = globalThis.document;
35
43
  return doc?.documentElement !== undefined ? doc : null;
@@ -136,7 +144,8 @@ export function themeBootstrapScript(param = THEME_PARAM) {
136
144
  `e.classList.toggle("dark",d);e.style.colorScheme=d?"dark":"light"}catch(e){}`);
137
145
  }
138
146
  /**
139
- * Follow live dashboard theme changes: announces `ready` on subscribe (so a
147
+ * Follow live dashboard theme changes: announces `ready` on subscribe, to
148
+ * `postTarget` or, by default, the framing parent window (so a
140
149
  * non-React app gets the mode even after an in-frame reload), then every
141
150
  * bridge `theme{mode}` toggles the `dark` class, is remembered for the
142
151
  * bootstrap fallback, and notifies `onChange`. Applies nothing else on
@@ -146,7 +155,7 @@ export function themeBootstrapScript(param = THEME_PARAM) {
146
155
  export function installThemeListener(options) {
147
156
  const { dashboardOrigin, target, onChange, doc, postTarget, capabilities, sdkVersion, storage } = options;
148
157
  const expectSource = options.expectSource !== undefined ? options.expectSource : globalParent();
149
- sendReady(dashboardOrigin, postTarget, { capabilities, sdkVersion });
158
+ sendReady(dashboardOrigin, postTarget ?? framingParent(), { capabilities, sdkVersion });
150
159
  return listenToDashboard({
151
160
  dashboardOrigin,
152
161
  target,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usequeek/app-sdk",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "Queekx Technology LTD",