@lincyaw/kernel 1.0.0-rc.1 → 1.0.0-rc.11
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/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/preview-frame.ts +16 -2
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -41,7 +41,7 @@ export { ANCHOR_LOCK_PATH, AnchorLock } from './lock.ts'
|
|
|
41
41
|
export { prefixedLogger } from './logging.ts'
|
|
42
42
|
export { lowerMyst, roleMark } from './lower-myst.ts'
|
|
43
43
|
export type { LinkedType, LoweredMarkdown, LowerOptions } from './lower-myst.ts'
|
|
44
|
-
export { connectPreviewFrame, isPreviewActive, isPreviewEmbedded, previewAppearance, previewFrameAncestors, reportPreview } from './preview-frame.ts'
|
|
44
|
+
export { connectPreviewFrame, isPreviewActive, isPreviewEmbedded, previewAppearance, previewFrameAncestors, reportPreview, reportStaleModule } from './preview-frame.ts'
|
|
45
45
|
export { keyBelongsToTarget, watchFocusSource } from './keyboard.ts'
|
|
46
46
|
export type { PreviewFrame, PreviewPage, PreviewProblem, PreviewTextEdit, PreviewTextHandle } from './preview-frame.ts'
|
|
47
47
|
export { previewEditBinding } from './preview-edit.ts'
|
package/src/preview-frame.ts
CHANGED
|
@@ -126,9 +126,12 @@ export function previewAppearance(): 'dark' | 'light' | undefined {
|
|
|
126
126
|
return given === 'dark' || given === 'light' ? given : undefined
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* The Content-Security-Policy that lets only the site itself and the workbench's origins embed a page: a home page
|
|
131
|
+
* that plays a document's presentation in a frame works in `presmium serve` as it does in the built site.
|
|
132
|
+
*/
|
|
130
133
|
export function previewFrameAncestors(origins: readonly string[]): string {
|
|
131
|
-
return
|
|
134
|
+
return ['frame-ancestors', "'self'", ...origins].join(' ')
|
|
132
135
|
}
|
|
133
136
|
|
|
134
137
|
/** Whether the page is embedded by a workbench as its preview (the frame may still be refused when no origin is allowed). */
|
|
@@ -1218,3 +1221,14 @@ export function connectPreviewFrame(page: PreviewPage): PreviewFrame | undefined
|
|
|
1218
1221
|
},
|
|
1219
1222
|
}
|
|
1220
1223
|
}
|
|
1224
|
+
|
|
1225
|
+
const STALE_MODULE = /dynamically imported module|Importing a module script failed|error loading dynamically imported module/i
|
|
1226
|
+
|
|
1227
|
+
/**
|
|
1228
|
+
* A module that failed to load because a new deployment removed the version this (cached) page names: the page asks to
|
|
1229
|
+
* load again (`vite:preloadError`, which the page's head answers with one reload). Other failures are left alone.
|
|
1230
|
+
*/
|
|
1231
|
+
export function reportStaleModule(error: unknown): void {
|
|
1232
|
+
if (typeof window === 'undefined' || !STALE_MODULE.test(String(error instanceof Error ? error.message : error))) return
|
|
1233
|
+
window.dispatchEvent(new Event('vite:preloadError', { cancelable: true }))
|
|
1234
|
+
}
|