@ggui-ai/iframe-runtime 0.22.0 → 0.24.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/host-fonts.d.ts +7 -0
- package/dist/host-fonts.js +29 -5
- package/dist/iframe-runtime.js +69 -69
- package/dist/iframe-runtime.meta.json +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/meta-parse.d.ts +7 -0
- package/dist/meta-parse.js +13 -0
- package/dist/observability.d.ts +13 -1
- package/dist/protocol-error.d.ts +5 -2
- package/dist/react-renderer.js +5 -0
- package/dist/render-item.d.ts +5 -3
- package/dist/render-item.js +7 -2
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.js +27 -3
- package/dist/shims/wire.js +1 -1
- package/dist/types.d.ts +7 -4
- package/dist/wire-config.d.ts +8 -2
- package/dist/wire-config.js +15 -0
- package/package.json +7 -7
package/dist/host-fonts.d.ts
CHANGED
|
@@ -6,5 +6,12 @@ export declare const HOST_FONTS_STYLE_ID = "ggui-host-fonts";
|
|
|
6
6
|
* wholesale. Arms the CSP-violation reporter on first use.
|
|
7
7
|
*/
|
|
8
8
|
export declare function installHostFonts(fontsCss: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Track the stored theme's `@font-face` rules from the composed chrome CSS
|
|
11
|
+
* the renderer writes into `#ggui-theme-vars`, replacing the previous set.
|
|
12
|
+
* Arms the reporter on its own, so a session whose host announces no fonts
|
|
13
|
+
* still reports a blocked theme face (ggui#1147).
|
|
14
|
+
*/
|
|
15
|
+
export declare function trackThemeFontFaces(themeCss: string): void;
|
|
9
16
|
/** @internal — test isolation: drop the style, the report ledger, and the listener. */
|
|
10
17
|
export declare function __resetHostFontsForTest(): void;
|
package/dist/host-fonts.js
CHANGED
|
@@ -15,11 +15,19 @@
|
|
|
15
15
|
* cross-origin — hence the (family, host) key); the card reports it to
|
|
16
16
|
* the embedding host ONCE per (family, host) as `font-face-blocked`,
|
|
17
17
|
* so the operator sees the allowlist gap instead of a silent fallback.
|
|
18
|
+
*
|
|
19
|
+
* The stored theme's own faces are composed into the chrome CSS
|
|
20
|
+
* (`#ggui-theme-vars`) by the renderer, mid-session included, while
|
|
21
|
+
* `font-src` is fixed at mount. A face on an origin the mount did not
|
|
22
|
+
* admit is blocked, so those faces are tracked too
|
|
23
|
+
* ({@link trackThemeFontFaces}) and reported the same way (ggui#1147).
|
|
18
24
|
*/
|
|
19
25
|
import { postObservabilityToParent } from './observability.js';
|
|
20
26
|
/** The single `<style>` the host's faces live under. */
|
|
21
27
|
export const HOST_FONTS_STYLE_ID = 'ggui-host-fonts';
|
|
22
28
|
let installedFaces = [];
|
|
29
|
+
/** The stored theme's faces, from the composed chrome CSS (ggui#1147). */
|
|
30
|
+
let themeFaces = [];
|
|
23
31
|
const reported = new Set();
|
|
24
32
|
let violationListener = null;
|
|
25
33
|
function hostOf(url) {
|
|
@@ -67,7 +75,7 @@ function onViolation(ev) {
|
|
|
67
75
|
// ours only when it names one of OUR `src`s — another stylesheet's
|
|
68
76
|
// font on the same host is not this face's failure.
|
|
69
77
|
const carriesPath = /^[a-z][a-z0-9+.-]*:\/\/[^/]+\/./i.test(v.blockedURI);
|
|
70
|
-
for (const face of installedFaces) {
|
|
78
|
+
for (const face of [...installedFaces, ...themeFaces]) {
|
|
71
79
|
if (carriesPath ? !face.srcs.has(v.blockedURI) : !face.hosts.has(host))
|
|
72
80
|
continue;
|
|
73
81
|
const key = `${face.family}\u0000${host}`;
|
|
@@ -94,10 +102,25 @@ export function installHostFonts(fontsCss) {
|
|
|
94
102
|
if (el.textContent !== fontsCss)
|
|
95
103
|
el.textContent = fontsCss;
|
|
96
104
|
installedFaces = parseFaces(fontsCss);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
armViolationReporter();
|
|
106
|
+
}
|
|
107
|
+
function armViolationReporter() {
|
|
108
|
+
if (violationListener !== null)
|
|
109
|
+
return;
|
|
110
|
+
violationListener = onViolation;
|
|
111
|
+
document.addEventListener('securitypolicyviolation', violationListener);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Track the stored theme's `@font-face` rules from the composed chrome CSS
|
|
115
|
+
* the renderer writes into `#ggui-theme-vars`, replacing the previous set.
|
|
116
|
+
* Arms the reporter on its own, so a session whose host announces no fonts
|
|
117
|
+
* still reports a blocked theme face (ggui#1147).
|
|
118
|
+
*/
|
|
119
|
+
export function trackThemeFontFaces(themeCss) {
|
|
120
|
+
if (typeof document === 'undefined')
|
|
121
|
+
return;
|
|
122
|
+
themeFaces = parseFaces(themeCss);
|
|
123
|
+
armViolationReporter();
|
|
101
124
|
}
|
|
102
125
|
/** @internal — test isolation: drop the style, the report ledger, and the listener. */
|
|
103
126
|
export function __resetHostFontsForTest() {
|
|
@@ -105,6 +128,7 @@ export function __resetHostFontsForTest() {
|
|
|
105
128
|
return;
|
|
106
129
|
document.getElementById(HOST_FONTS_STYLE_ID)?.remove();
|
|
107
130
|
installedFaces = [];
|
|
131
|
+
themeFaces = [];
|
|
108
132
|
reported.clear();
|
|
109
133
|
if (violationListener !== null) {
|
|
110
134
|
document.removeEventListener('securitypolicyviolation', violationListener);
|