@botiverse/porthole 0.1.4 → 0.1.6
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/compile/policy.d.ts +4 -2
- package/dist/compile/policy.js +9 -3
- package/dist/config/schema.d.ts +9 -0
- package/dist/config/schema.js +2 -0
- package/dist/config/validate.js +162 -2
- package/dist/conformance/behavior.js +14 -1
- package/dist/conformance/kit.d.ts +5 -0
- package/dist/conformance/kit.js +11 -0
- package/dist/conformance/probes.js +19 -2
- package/dist/conformance/served.js +61 -12
- package/dist/guide/guide.d.ts +2 -0
- package/dist/guide/guide.js +19 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/presets/presets.js +4 -0
- package/dist/react/frame.js +11 -4
- package/dist/server/server.js +4 -0
- package/dist/shell/runtime.js +14 -1
- package/package.json +1 -1
- package/src/compile/policy.ts +12 -5
- package/src/config/schema.ts +11 -0
- package/src/config/validate.ts +178 -2
- package/src/conformance/behavior.ts +20 -1
- package/src/conformance/kit.ts +16 -0
- package/src/conformance/probes.ts +21 -2
- package/src/conformance/served.ts +75 -23
- package/src/guide/guide.ts +22 -3
- package/src/index.ts +2 -0
- package/src/presets/presets.ts +4 -0
- package/src/react/frame.tsx +11 -4
- package/src/server/server.ts +4 -0
- package/src/shell/runtime.ts +14 -1
package/src/react/frame.tsx
CHANGED
|
@@ -622,15 +622,22 @@ function Mount({ frame, page, initialHeightPx, placeholder, run }: MountProps):
|
|
|
622
622
|
attempt(() => display.annotations.focus(id), latest());
|
|
623
623
|
}
|
|
624
624
|
}, [annotates, focusToken]);
|
|
625
|
+
// A flip or a restyle after the display was made: its first scheme and values went with it.
|
|
626
|
+
const [mountScheme] = useState(scheme);
|
|
627
|
+
const flipped = useRef(false);
|
|
625
628
|
useEffect(() => {
|
|
626
|
-
|
|
627
|
-
|
|
629
|
+
if (flipped.current || scheme !== mountScheme) {
|
|
630
|
+
flipped.current = true;
|
|
631
|
+
handle.current?.setTheme(scheme);
|
|
632
|
+
}
|
|
633
|
+
}, [scheme, mountScheme]);
|
|
628
634
|
const { themeKey } = frame;
|
|
635
|
+
const [mountThemeKey] = useState(themeKey);
|
|
629
636
|
useEffect(() => {
|
|
630
|
-
if (themeKey !== undefined) {
|
|
637
|
+
if (themeKey !== undefined && themeKey !== mountThemeKey) {
|
|
631
638
|
handle.current?.refreshTheme();
|
|
632
639
|
}
|
|
633
|
-
}, [themeKey]);
|
|
640
|
+
}, [themeKey, mountThemeKey]);
|
|
634
641
|
|
|
635
642
|
return (
|
|
636
643
|
<div
|
package/src/server/server.ts
CHANGED
|
@@ -92,6 +92,10 @@ function mergeEgress(base: EgressConfig, extra: EgressConfig | undefined): Egres
|
|
|
92
92
|
merged[kind] = origins;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
+
// What the host's config opens to any https site stays; a view can't ask for it (P059).
|
|
96
|
+
if (base.anyHttps !== undefined) {
|
|
97
|
+
merged.anyHttps = base.anyHttps;
|
|
98
|
+
}
|
|
95
99
|
return merged;
|
|
96
100
|
}
|
|
97
101
|
|
package/src/shell/runtime.ts
CHANGED
|
@@ -607,12 +607,16 @@ export const SHELL_RUNTIME = String.raw`(() => {
|
|
|
607
607
|
const notify = (method, params) => send({ method, params });
|
|
608
608
|
|
|
609
609
|
const themeNames = new Set(plan.themeVariables);
|
|
610
|
+
// What the content was last told of (its scheme and values): the theme it starts with is no
|
|
611
|
+
// change, and a host context that changes neither (a host re-sending it) is none either.
|
|
612
|
+
let announced = null;
|
|
610
613
|
const applyTheme = (context) => {
|
|
611
614
|
if (context === null || typeof context !== "object") {
|
|
612
615
|
return;
|
|
613
616
|
}
|
|
614
617
|
// The spec's variables, and Porthole's own beside them (its own-prefixed field).
|
|
615
618
|
const own = context["porthole/styles"];
|
|
619
|
+
const applied = [];
|
|
616
620
|
for (const variables of [context.styles && context.styles.variables, own && own.variables]) {
|
|
617
621
|
if (variables === null || typeof variables !== "object") {
|
|
618
622
|
continue;
|
|
@@ -621,12 +625,21 @@ export const SHELL_RUNTIME = String.raw`(() => {
|
|
|
621
625
|
const value = variables[name];
|
|
622
626
|
if (themeNames.has(name) && typeof value === "string") {
|
|
623
627
|
document.documentElement.style.setProperty(name, value);
|
|
628
|
+
applied.push(name + ":" + value);
|
|
624
629
|
}
|
|
625
630
|
}
|
|
626
631
|
}
|
|
627
632
|
lastContext = context;
|
|
628
633
|
schemeFollows();
|
|
629
|
-
|
|
634
|
+
const now = JSON.stringify([context.theme, applied.sort()]);
|
|
635
|
+
if (announced === null) {
|
|
636
|
+
announced = now;
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
if (now !== announced) {
|
|
640
|
+
announced = now;
|
|
641
|
+
window.dispatchEvent(new CustomEvent(plan.themeEvent, { detail: { theme: context.theme } }));
|
|
642
|
+
}
|
|
630
643
|
};
|
|
631
644
|
|
|
632
645
|
// No size before there is something to size: an empty shell's height would make the host
|