@decocms/blocks 8.14.0 → 8.16.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/protocol/channel.d.ts +16 -0
- package/dist/protocol/channel.d.ts.map +1 -1
- package/dist/protocol/channel.js +9 -0
- package/dist/protocol/channel.js.map +1 -1
- package/dist/protocol/index.d.ts +1 -1
- package/dist/protocol/index.d.ts.map +1 -1
- package/dist/protocol/index.js +1 -1
- package/dist/protocol/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/deco-nextjs-site/references/studio-bridge.md +5 -3
- package/skills/deco-tanstack-site/references/document-and-security.md +8 -9
- package/src/protocol/channel.ts +18 -0
- package/src/protocol/index.ts +2 -0
|
@@ -93,6 +93,22 @@ export interface StudioChannelContext<In extends ModuleMessage = ModuleMessage,
|
|
|
93
93
|
}
|
|
94
94
|
/** A module's default export. The page answers `deco:loaded` once it returns (or its promise resolves). */
|
|
95
95
|
export type StudioChannelModule<In extends ModuleMessage = ModuleMessage, Out extends ModuleMessage = ModuleMessage> = (context: StudioChannelContext<In, Out>) => void | Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* The `window` property a binding sets when its framework can show a save by
|
|
98
|
+
* re-rendering the page in place (Next.js: `router.refresh()`): a
|
|
99
|
+
* {@link StudioPageRefresh}. Studio's HTML swap calls it instead of replacing
|
|
100
|
+
* the document, whose new scripts never run, so the page's client components
|
|
101
|
+
* would stop at their server markup (a footer revealed on scroll, a carousel).
|
|
102
|
+
* A page without it gets the document swap.
|
|
103
|
+
*/
|
|
104
|
+
export declare const STUDIO_PAGE_REFRESH = "__decoStudioRefresh";
|
|
105
|
+
/**
|
|
106
|
+
* Shows `url` (absolute, on the page's own origin: the page's URL, or a new one
|
|
107
|
+
* whose draft pointer moved) from the server without reloading, keeping the
|
|
108
|
+
* page's client state; resolves once the new content is on screen, rejects
|
|
109
|
+
* when it can't show it (Studio then reloads the frame).
|
|
110
|
+
*/
|
|
111
|
+
export type StudioPageRefresh = (url: string) => Promise<void>;
|
|
96
112
|
/** Types a module's default export: `export default defineStudioModule<In, Out>((channel) => …)`. */
|
|
97
113
|
export declare function defineStudioModule<In extends ModuleMessage = ModuleMessage, Out extends ModuleMessage = ModuleMessage>(module: StudioChannelModule<In, Out>): StudioChannelModule<In, Out>;
|
|
98
114
|
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/protocol/channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,kCAAkC;AAClC,eAAO,MAAM,qBAAqB,+BAA+B,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAGlD,CAAC;AAEH,0FAA0F;AAC1F,eAAO,MAAM,eAAe;oBACnB,YAAY;mBACb,WAAW;qBACT,aAAa;wBACV,iBAAiB;EACnB,CAAC;AAEZ,+DAA+D;AAC/D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,8EAA8E;AAC9E,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,WAAW,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,kFAAkF;AAClF,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,aAAa,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,uEAAuE;AACvE,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,iBAAiB,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,iDAAiD;AACjD,MAAM,MAAM,kBAAkB,GAC1B,mBAAmB,GACnB,oBAAoB,GACpB,uBAAuB,CAAC;AAE5B,uFAAuF;AACvF,MAAM,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAEtD;;;;GAIG;AACH,M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AAC,OAAO,EAAE,oBAAoB,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAErE;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE/D,qGAAqG;AACrG,wBAAgB,kBAAkB,CAChC,EAAE,SAAS,aAAa,GAAG,aAAa,EACxC,GAAG,SAAS,aAAa,GAAG,aAAa,EACzC,MAAM,EAAE,mBAAmB,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,mBAAmB,CAAC,EAAE,EAAE,GAAG,CAAC,CAEpE"}
|
package/dist/protocol/channel.js
CHANGED
|
@@ -51,6 +51,15 @@ export const CHANNEL_MESSAGE = Object.freeze({
|
|
|
51
51
|
loaded: "deco:loaded",
|
|
52
52
|
loadError: "deco:load-error",
|
|
53
53
|
});
|
|
54
|
+
/**
|
|
55
|
+
* The `window` property a binding sets when its framework can show a save by
|
|
56
|
+
* re-rendering the page in place (Next.js: `router.refresh()`): a
|
|
57
|
+
* {@link StudioPageRefresh}. Studio's HTML swap calls it instead of replacing
|
|
58
|
+
* the document, whose new scripts never run, so the page's client components
|
|
59
|
+
* would stop at their server markup (a footer revealed on scroll, a carousel).
|
|
60
|
+
* A page without it gets the document swap.
|
|
61
|
+
*/
|
|
62
|
+
export const STUDIO_PAGE_REFRESH = "__decoStudioRefresh";
|
|
54
63
|
/** Types a module's default export: `export default defineStudioModule<In, Out>((channel) => …)`. */
|
|
55
64
|
export function defineStudioModule(module) {
|
|
56
65
|
return module;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/protocol/channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,kCAAkC;AAClC,MAAM,CAAC,MAAM,qBAAqB,GAAG,4BAA4B,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAsB,MAAM,CAAC,MAAM,CAAC;IACrE,qBAAqB;IACrB,gCAAgC;CACjC,CAAC,CAAC;AAEH,0FAA0F;AAC1F,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3C,KAAK,EAAE,YAAY;IACnB,IAAI,EAAE,WAAW;IACjB,MAAM,EAAE,aAAa;IACrB,SAAS,EAAE,iBAAiB;CACpB,CAAC,CAAC;AAiEZ,qGAAqG;AACrG,MAAM,UAAU,kBAAkB,CAGhC,MAAoC;IACpC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/protocol/channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,kCAAkC;AAClC,MAAM,CAAC,MAAM,qBAAqB,GAAG,4BAA4B,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAsB,MAAM,CAAC,MAAM,CAAC;IACrE,qBAAqB;IACrB,gCAAgC;CACjC,CAAC,CAAC;AAEH,0FAA0F;AAC1F,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3C,KAAK,EAAE,YAAY;IACnB,IAAI,EAAE,WAAW;IACjB,MAAM,EAAE,aAAa;IACrB,SAAS,EAAE,iBAAiB;CACpB,CAAC,CAAC;AAiEZ;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAUzD,qGAAqG;AACrG,MAAM,UAAU,kBAAkB,CAGhC,MAAoC;IACpC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
export { type BlockIndex, type BlockMeta, type BodyOf, blockMeta, type IndexEntry, indexEntry, META_VERSION, pageNoIndex, seoNoIndex, } from "../v8/blockMeta.ts";
|
|
33
33
|
export { isRevisionId, REVISION_ID_RE } from "../v8/revisionId.ts";
|
|
34
34
|
export { blockVersion, CanonicalJsonError, CONTENT_HASH_FORMAT, canonicalJson, computeContentRevision, sha256Hex, } from "./canonical.ts";
|
|
35
|
-
export { CHANNEL_MESSAGE, type ChannelLoadErrorMessage, type ChannelLoadedMessage, type ChannelLoadMessage, type ChannelReadyMessage, DEFAULT_STUDIO_ORIGIN, DEFAULT_STUDIO_ORIGINS, defineStudioModule, type ModuleMessage, type PageChannelMessage, type StudioChannelContext, type StudioChannelMessage, type StudioChannelModule, } from "./channel.ts";
|
|
35
|
+
export { CHANNEL_MESSAGE, type ChannelLoadErrorMessage, type ChannelLoadedMessage, type ChannelLoadMessage, type ChannelReadyMessage, DEFAULT_STUDIO_ORIGIN, DEFAULT_STUDIO_ORIGINS, defineStudioModule, type ModuleMessage, type PageChannelMessage, STUDIO_PAGE_REFRESH, type StudioChannelContext, type StudioChannelMessage, type StudioChannelModule, type StudioPageRefresh, } from "./channel.ts";
|
|
36
36
|
export { assertSupportedEndpoint, type BatchCall, type BatchOutcome, type ContentClient, type ContentClientOptions, createContentClient, } from "./client.ts";
|
|
37
37
|
export * from "./errors.ts";
|
|
38
38
|
export * from "./keys.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,MAAM,EACX,SAAS,EACT,KAAK,UAAU,EACf,UAAU,EACV,YAAY,EACZ,WAAW,EACX,UAAU,GACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,sBAAsB,EACtB,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EACf,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,MAAM,EACX,SAAS,EACT,KAAK,UAAU,EACf,UAAU,EACV,YAAY,EACZ,WAAW,EACX,UAAU,GACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,sBAAsB,EACtB,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EACf,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,GACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,uBAAuB,EACvB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
package/dist/protocol/index.js
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
export { blockMeta, indexEntry, META_VERSION, pageNoIndex, seoNoIndex, } from "../v8/blockMeta.js";
|
|
33
33
|
export { isRevisionId, REVISION_ID_RE } from "../v8/revisionId.js";
|
|
34
34
|
export { blockVersion, CanonicalJsonError, CONTENT_HASH_FORMAT, canonicalJson, computeContentRevision, sha256Hex, } from "./canonical.js";
|
|
35
|
-
export { CHANNEL_MESSAGE, DEFAULT_STUDIO_ORIGIN, DEFAULT_STUDIO_ORIGINS, defineStudioModule, } from "./channel.js";
|
|
35
|
+
export { CHANNEL_MESSAGE, DEFAULT_STUDIO_ORIGIN, DEFAULT_STUDIO_ORIGINS, defineStudioModule, STUDIO_PAGE_REFRESH, } from "./channel.js";
|
|
36
36
|
export { assertSupportedEndpoint, createContentClient, } from "./client.js";
|
|
37
37
|
export * from "./errors.js";
|
|
38
38
|
export * from "./keys.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAIL,SAAS,EAET,UAAU,EACV,YAAY,EACZ,WAAW,EACX,UAAU,GACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,sBAAsB,EACtB,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAKf,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAIL,SAAS,EAET,UAAU,EACV,YAAY,EACZ,WAAW,EACX,UAAU,GACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,sBAAsB,EACtB,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAKf,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAGlB,mBAAmB,GAKpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,uBAAuB,EAKvB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -37,9 +37,11 @@ layout from being cached.
|
|
|
37
37
|
|
|
38
38
|
## What it does
|
|
39
39
|
|
|
40
|
-
- **The
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
- **The shortcut script** listens for the "." shortcut, only outside a frame.
|
|
41
|
+
It answers no message: v8 only, v7's framed handler (scroll-to-section,
|
|
42
|
+
rerender) is gone, so no script on the page compares the window with `top`
|
|
43
|
+
or `parent`, and a test runner that rewrites "frame-busting" code (Cypress)
|
|
44
|
+
serves the page as is.
|
|
43
45
|
- **The Studio channel** runs on every page, production included (about
|
|
44
46
|
0.7 kB gzipped). Framed by a trusted origin, it posts `{ type: "deco:ready" }`
|
|
45
47
|
and imports a module only when the answer `{ type: "deco:load", url }`
|
|
@@ -50,7 +50,7 @@ What else it mounts:
|
|
|
50
50
|
after hydration. Work that must follow hydration waits for it.
|
|
51
51
|
- `NavigationProgress` and `StableOutlet` ([`router-and-navigation.md`](./router-and-navigation.md)).
|
|
52
52
|
- An inline script that publishes the request's draft and CDN segment token to `window`.
|
|
53
|
-
-
|
|
53
|
+
- The "." edit shortcut, and `StudioChannel` and `DraftBadge` from `@decocms/blocks/preview` (below).
|
|
54
54
|
|
|
55
55
|
## The head
|
|
56
56
|
|
|
@@ -76,18 +76,18 @@ import { DecoPreview } from "@decocms/tanstack/react";
|
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
`DecoPreview` takes `site`, `editShortcut`, `nonce` and `studioOrigins`. It renders the draft
|
|
79
|
-
script,
|
|
80
|
-
without the badge. You then own `<HeadContent />`, `<Scripts />`, `lang`, the events bus and the
|
|
79
|
+
script, the "." shortcut, `StudioChannel` and `DraftBadge`. You then own `<HeadContent />`, `<Scripts />`, `lang`, the events bus and the
|
|
81
80
|
progress bar.
|
|
82
81
|
|
|
83
82
|
## Studio inside the page
|
|
84
83
|
|
|
85
|
-
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
- **The "." shortcut**: outside Studio's frame, "." opens the current page in Studio's editor: the
|
|
85
|
+
page whose route returns `pathTemplate` (and optionally `pageId`) in its loader data, else Studio
|
|
86
|
+
picks it from the URL. In a frame it does nothing (v8 only: no v7 `scrollToComponent` /
|
|
87
|
+
`editor::rerender` handler).
|
|
88
88
|
- **`StudioChannel`**: on every page, production included, about 0.7 kB gzipped. When a trusted
|
|
89
89
|
Studio origin frames the page, it loads Studio's editor modules from that origin. Otherwise it
|
|
90
|
-
does nothing.
|
|
90
|
+
does nothing. It is the only way Studio's editor reaches the page.
|
|
91
91
|
- **`DraftBadge`**: shown on a draft page outside Studio's frame. A draft link that can't be read
|
|
92
92
|
anymore shows a notice and the release.
|
|
93
93
|
|
|
@@ -98,8 +98,7 @@ from `@decocms/tanstack`). Each entry must be an exact `http(s)` origin; anythin
|
|
|
98
98
|
The worker puts the same list into the CSP. If you set `studioOrigins` on `DecoDocument`, set the
|
|
99
99
|
same list on `createDecoWorker`; `DECO_STUDIO_ORIGIN` sets both.
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
`data-manifest-key` equals the id Studio sends, else the element with that `id`. How to render
|
|
101
|
+
Studio's editor modules find the page's sections by their `data-manifest-key`. How to render
|
|
103
102
|
sections: `deco-site-authoring`.
|
|
104
103
|
|
|
105
104
|
## Security headers
|
package/src/protocol/channel.ts
CHANGED
|
@@ -118,6 +118,24 @@ export type StudioChannelModule<
|
|
|
118
118
|
Out extends ModuleMessage = ModuleMessage,
|
|
119
119
|
> = (context: StudioChannelContext<In, Out>) => void | Promise<void>;
|
|
120
120
|
|
|
121
|
+
/**
|
|
122
|
+
* The `window` property a binding sets when its framework can show a save by
|
|
123
|
+
* re-rendering the page in place (Next.js: `router.refresh()`): a
|
|
124
|
+
* {@link StudioPageRefresh}. Studio's HTML swap calls it instead of replacing
|
|
125
|
+
* the document, whose new scripts never run, so the page's client components
|
|
126
|
+
* would stop at their server markup (a footer revealed on scroll, a carousel).
|
|
127
|
+
* A page without it gets the document swap.
|
|
128
|
+
*/
|
|
129
|
+
export const STUDIO_PAGE_REFRESH = "__decoStudioRefresh";
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Shows `url` (absolute, on the page's own origin: the page's URL, or a new one
|
|
133
|
+
* whose draft pointer moved) from the server without reloading, keeping the
|
|
134
|
+
* page's client state; resolves once the new content is on screen, rejects
|
|
135
|
+
* when it can't show it (Studio then reloads the frame).
|
|
136
|
+
*/
|
|
137
|
+
export type StudioPageRefresh = (url: string) => Promise<void>;
|
|
138
|
+
|
|
121
139
|
/** Types a module's default export: `export default defineStudioModule<In, Out>((channel) => …)`. */
|
|
122
140
|
export function defineStudioModule<
|
|
123
141
|
In extends ModuleMessage = ModuleMessage,
|
package/src/protocol/index.ts
CHANGED
|
@@ -61,9 +61,11 @@ export {
|
|
|
61
61
|
defineStudioModule,
|
|
62
62
|
type ModuleMessage,
|
|
63
63
|
type PageChannelMessage,
|
|
64
|
+
STUDIO_PAGE_REFRESH,
|
|
64
65
|
type StudioChannelContext,
|
|
65
66
|
type StudioChannelMessage,
|
|
66
67
|
type StudioChannelModule,
|
|
68
|
+
type StudioPageRefresh,
|
|
67
69
|
} from "./channel.ts";
|
|
68
70
|
export {
|
|
69
71
|
assertSupportedEndpoint,
|