@serene-pub/ui-preview 0.6.0-pr-5 → 0.6.0-pr-7
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 +4 -4
- package/src/lib/framePort.ts +4 -3
- package/vite/surfaces.ts +12 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serene-pub/ui-preview",
|
|
3
|
-
"version": "0.6.0-pr-
|
|
3
|
+
"version": "0.6.0-pr-7",
|
|
4
4
|
"description": "The Serene Pub surface harness: a SvelteKit dev server that renders the UI surfaces a package announces — frame panels in a real opaque-origin sandbox, components in the host document — with hot reload. Launched by `serene-pub ui`.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/SerenePub/serene-pub-sdk/tree/main/ui-preview#readme",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@serene-pub/controls": "^0.6.0-pr-
|
|
44
|
+
"@serene-pub/controls": "^0.6.0-pr-7",
|
|
45
45
|
"@skeletonlabs/skeleton": "^5.0.0",
|
|
46
46
|
"@sveltejs/kit": "^2.22.0",
|
|
47
47
|
"@sveltejs/vite-plugin-svelte": "^5.1.0",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"vite": "^6.4.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@serene-pub/sdk": "^0.6.0-pr-
|
|
55
|
+
"@serene-pub/sdk": "^0.6.0-pr-7"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@serene-pub/sdk": "0.6.0-pr-
|
|
58
|
+
"@serene-pub/sdk": "0.6.0-pr-7",
|
|
59
59
|
"svelte-check": "^4.0.0",
|
|
60
60
|
"typescript": "~5.9.0"
|
|
61
61
|
},
|
package/src/lib/framePort.ts
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
* file. Read `nextCursor` and hand it back; never parse it.
|
|
40
40
|
*/
|
|
41
41
|
|
|
42
|
-
import { FRAME_PROTOCOL, type FrameHostMessage, type FramePoint, type HostFrameMessage } from '@serene-pub/sdk'
|
|
42
|
+
import { FRAME_PROTOCOL, SAVE_STATE_MAX_BYTES, type FrameHostMessage, type FramePoint, type HostFrameMessage } from '@serene-pub/sdk'
|
|
43
43
|
|
|
44
44
|
/** The rows the host pages over — the fixtures, as the stage holds them. */
|
|
45
45
|
export type FrameRow = Record<string, unknown>
|
|
@@ -56,11 +56,12 @@ export const FRAME_PAGE_DEFAULT = 50
|
|
|
56
56
|
/** The most rows one page may carry, whatever a frame asks for. */
|
|
57
57
|
export const FRAME_PAGE_MAX = 200
|
|
58
58
|
/**
|
|
59
|
-
* The most view state the host will hold for a surface
|
|
59
|
+
* The most view state the host will hold for a surface: 256 KB of JSON, a `SavedStateV1`
|
|
60
|
+
* `{ v, data }` kept as written. `save-state` is not
|
|
60
61
|
* storage — the declaration says the host may cap or drop it — so it does,
|
|
61
62
|
* loudly, rather than quietly becoming a database a surface comes to rely on.
|
|
62
63
|
*/
|
|
63
|
-
export const FRAME_STATE_MAX_BYTES =
|
|
64
|
+
export const FRAME_STATE_MAX_BYTES = SAVE_STATE_MAX_BYTES
|
|
64
65
|
|
|
65
66
|
/** `init`, as a protocol-2 host sends it. */
|
|
66
67
|
export const initMessage = (surface: FramePoint): Extract<HostFrameMessage, { t: 'init' }> => ({
|
package/vite/surfaces.ts
CHANGED
|
@@ -58,7 +58,14 @@ export const THEME_CSS_PATH = '/@serene-pub/themes.css'
|
|
|
58
58
|
* (as this one previously did) would let an author build against inline
|
|
59
59
|
* scripts that core will refuse the day they install.
|
|
60
60
|
*/
|
|
61
|
-
function frameCsp(): string {
|
|
61
|
+
function frameCsp(host: string, pluginId: string): string {
|
|
62
|
+
// 🚧 (M2a) Production opens `connect-src` for GET on the frame's own
|
|
63
|
+
// plugin's two doors and nothing else; so does the harness, in place of
|
|
64
|
+
// `'self'` (which would open the whole dev server). The harness serves
|
|
65
|
+
// neither door yet, so a fetch there is a 404 here and a 200 once installed.
|
|
66
|
+
const doors = /^[A-Za-z0-9.-]+(:\d+)?$|^\[[0-9A-Fa-f:.]+\](:\d+)?$/.test(host)
|
|
67
|
+
? ` ${host}/plugin-assets/${pluginId}/ ${host}/plugin-data/${pluginId}/`
|
|
68
|
+
: ''
|
|
62
69
|
return [
|
|
63
70
|
"default-src 'none'",
|
|
64
71
|
"script-src 'self'",
|
|
@@ -68,7 +75,7 @@ function frameCsp(): string {
|
|
|
68
75
|
"media-src 'self' blob:",
|
|
69
76
|
// Production is `connect-src <granted hosts>` or `'none'`; dev must
|
|
70
77
|
// additionally reach the HMR socket or nothing hot-reloads.
|
|
71
|
-
|
|
78
|
+
`connect-src${doors} ws: wss:`,
|
|
72
79
|
"form-action 'none'",
|
|
73
80
|
"base-uri 'none'",
|
|
74
81
|
].join('; ')
|
|
@@ -154,6 +161,7 @@ export function serenePubSurfaces(options: SurfacesPluginOptions): Plugin {
|
|
|
154
161
|
let server: ViteDevServer | undefined
|
|
155
162
|
let declFiles = new Set<string>()
|
|
156
163
|
let themeCss: string | undefined
|
|
164
|
+
let previewId = 'unknown'
|
|
157
165
|
|
|
158
166
|
return {
|
|
159
167
|
name: 'serene-pub:surfaces',
|
|
@@ -249,7 +257,7 @@ export function serenePubSurfaces(options: SurfacesPluginOptions): Plugin {
|
|
|
249
257
|
s.middlewares.use((req, res, next) => {
|
|
250
258
|
const url = req.url ?? ''
|
|
251
259
|
if (url.startsWith('/@fs') && /\.html(\?|$)/.test(url))
|
|
252
|
-
res.setHeader('Content-Security-Policy', frameCsp())
|
|
260
|
+
res.setHeader('Content-Security-Policy', frameCsp(req.headers.host ?? '', previewId))
|
|
253
261
|
next()
|
|
254
262
|
})
|
|
255
263
|
},
|
|
@@ -301,6 +309,7 @@ export function serenePubSurfaces(options: SurfacesPluginOptions): Plugin {
|
|
|
301
309
|
}
|
|
302
310
|
}
|
|
303
311
|
|
|
312
|
+
previewId = /^[a-z0-9]+([.-][a-z0-9]+)*$/.test(manifest.id) ? manifest.id : 'unknown'
|
|
304
313
|
const frames: Record<string, string> = {}
|
|
305
314
|
const components: string[] = []
|
|
306
315
|
for (const t of manifest.targets) {
|