@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/merchant-schema.d.ts +17032 -6261
- package/dist/theme.d.ts +2 -1
- package/dist/theme.js +11 -2
- package/package.json +1 -1
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
|
|
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
|
|
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,
|