@conloca/cms-spa 0.2.1 → 0.2.3
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/README.md +26 -0
- package/dist/spa/main.css +240 -4
- package/dist/ts/.build-inputs.json +178 -0
- package/dist/ts/App.d.ts +10 -2
- package/dist/ts/App.d.ts.map +1 -1
- package/dist/ts/App.js +20 -8
- package/dist/ts/App.js.map +1 -1
- package/dist/ts/CmsSpaApp.d.ts.map +1 -1
- package/dist/ts/CmsSpaApp.js +4 -1
- package/dist/ts/CmsSpaApp.js.map +1 -1
- package/dist/ts/components/CMSDashboard.d.ts.map +1 -1
- package/dist/ts/components/CMSDashboard.js +6 -2
- package/dist/ts/components/CMSDashboard.js.map +1 -1
- package/dist/ts/components/RouteErrorPage.d.ts +11 -0
- package/dist/ts/components/RouteErrorPage.d.ts.map +1 -0
- package/dist/ts/components/RouteErrorPage.js +44 -0
- package/dist/ts/components/RouteErrorPage.js.map +1 -0
- package/dist/ts/components/dashboard/RecentActivity.d.ts.map +1 -1
- package/dist/ts/components/dashboard/RecentActivity.js +2 -8
- package/dist/ts/components/dashboard/RecentActivity.js.map +1 -1
- package/dist/ts/components/dialogs/CreateDataDialog.js +2 -2
- package/dist/ts/components/dialogs/CreateDataDialog.js.map +1 -1
- package/dist/ts/components/dialogs/CreateFolderDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/CreateFolderDialog.js +2 -1
- package/dist/ts/components/dialogs/CreateFolderDialog.js.map +1 -1
- package/dist/ts/components/dialogs/CreatePageFlow.d.ts +13 -0
- package/dist/ts/components/dialogs/CreatePageFlow.d.ts.map +1 -0
- package/dist/ts/components/dialogs/CreatePageFlow.js +100 -0
- package/dist/ts/components/dialogs/CreatePageFlow.js.map +1 -0
- package/dist/ts/components/dialogs/DataPropertiesDialog.d.ts +1 -1
- package/dist/ts/components/dialogs/DataPropertiesDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/DataPropertiesDialog.js +2 -2
- package/dist/ts/components/dialogs/DataPropertiesDialog.js.map +1 -1
- package/dist/ts/components/dialogs/FragmentPropertiesDialog.d.ts +1 -1
- package/dist/ts/components/dialogs/FragmentPropertiesDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/FragmentPropertiesDialog.js +2 -2
- package/dist/ts/components/dialogs/FragmentPropertiesDialog.js.map +1 -1
- package/dist/ts/components/dialogs/PageMetadataDialog.d.ts +2 -12
- package/dist/ts/components/dialogs/PageMetadataDialog.d.ts.map +1 -1
- package/dist/ts/components/dialogs/PageMetadataDialog.js +3 -21
- package/dist/ts/components/dialogs/PageMetadataDialog.js.map +1 -1
- package/dist/ts/components/editor/CMSMDXEditor.d.ts.map +1 -1
- package/dist/ts/components/editor/CMSMDXEditor.js +46 -55
- package/dist/ts/components/editor/CMSMDXEditor.js.map +1 -1
- package/dist/ts/components/editor/DrawerItemOverride.d.ts +2 -0
- package/dist/ts/components/editor/DrawerItemOverride.d.ts.map +1 -1
- package/dist/ts/components/editor/DrawerItemOverride.js +4 -3
- package/dist/ts/components/editor/DrawerItemOverride.js.map +1 -1
- package/dist/ts/components/editor/PageEditor.d.ts +6 -7
- package/dist/ts/components/editor/PageEditor.d.ts.map +1 -1
- package/dist/ts/components/editor/PageEditor.js +124 -34
- package/dist/ts/components/editor/PageEditor.js.map +1 -1
- package/dist/ts/components/editor/PageEditorHeaderActions.js +1 -1
- package/dist/ts/components/editor/PageEditorHeaderActions.js.map +1 -1
- package/dist/ts/components/editor/PageEditorWrapper.d.ts.map +1 -1
- package/dist/ts/components/editor/PageEditorWrapper.js +48 -12
- package/dist/ts/components/editor/PageEditorWrapper.js.map +1 -1
- package/dist/ts/components/editor/draft-media-config.d.ts +22 -0
- package/dist/ts/components/editor/draft-media-config.d.ts.map +1 -0
- package/dist/ts/components/editor/draft-media-config.js +186 -0
- package/dist/ts/components/editor/draft-media-config.js.map +1 -0
- package/dist/ts/components/editor/preview-availability.d.ts +6 -5
- package/dist/ts/components/editor/preview-availability.d.ts.map +1 -1
- package/dist/ts/components/editor/preview-availability.js +6 -5
- package/dist/ts/components/editor/preview-availability.js.map +1 -1
- package/dist/ts/components/editors/DataEditor.d.ts +2 -2
- package/dist/ts/components/editors/DataEditor.d.ts.map +1 -1
- package/dist/ts/components/forms/HintForm.js +8 -5
- package/dist/ts/components/forms/HintForm.js.map +1 -1
- package/dist/ts/components/forms/SchemaForm.d.ts +17 -5
- package/dist/ts/components/forms/SchemaForm.d.ts.map +1 -1
- package/dist/ts/components/forms/SchemaForm.js +16 -9
- package/dist/ts/components/forms/SchemaForm.js.map +1 -1
- package/dist/ts/components/media/AssetCard.d.ts.map +1 -1
- package/dist/ts/components/media/AssetCard.js +3 -2
- package/dist/ts/components/media/AssetCard.js.map +1 -1
- package/dist/ts/components/media/AssetDetailSidebar.d.ts.map +1 -1
- package/dist/ts/components/media/AssetDetailSidebar.js +4 -2
- package/dist/ts/components/media/AssetDetailSidebar.js.map +1 -1
- package/dist/ts/components/media/FolderTreeSidebar.d.ts.map +1 -1
- package/dist/ts/components/media/FolderTreeSidebar.js +4 -1
- package/dist/ts/components/media/FolderTreeSidebar.js.map +1 -1
- package/dist/ts/components/pages/PageList.d.ts.map +1 -1
- package/dist/ts/components/pages/PageList.js +13 -99
- package/dist/ts/components/pages/PageList.js.map +1 -1
- package/dist/ts/components/sandbox/ContentSandbox.d.ts.map +1 -1
- package/dist/ts/components/sandbox/ContentSandbox.js +36 -5
- package/dist/ts/components/sandbox/ContentSandbox.js.map +1 -1
- package/dist/ts/content-form-fields.d.ts +41 -0
- package/dist/ts/content-form-fields.d.ts.map +1 -0
- package/dist/ts/content-form-fields.js +70 -0
- package/dist/ts/content-form-fields.js.map +1 -0
- package/dist/ts/content-wrapper.d.ts +65 -0
- package/dist/ts/content-wrapper.d.ts.map +1 -0
- package/dist/ts/content-wrapper.js +190 -0
- package/dist/ts/content-wrapper.js.map +1 -0
- package/dist/ts/data-schemas.d.ts +4 -3
- package/dist/ts/data-schemas.d.ts.map +1 -1
- package/dist/ts/data-schemas.js.map +1 -1
- package/dist/ts/frame/channel.d.ts +40 -0
- package/dist/ts/frame/channel.d.ts.map +1 -0
- package/dist/ts/frame/channel.js +233 -0
- package/dist/ts/frame/channel.js.map +1 -0
- package/dist/ts/frame/editor-frame.d.ts +23 -0
- package/dist/ts/frame/editor-frame.d.ts.map +1 -0
- package/dist/ts/frame/editor-frame.js +154 -0
- package/dist/ts/frame/editor-frame.js.map +1 -0
- package/dist/ts/frame/media-cache.d.ts +26 -0
- package/dist/ts/frame/media-cache.d.ts.map +1 -0
- package/dist/ts/frame/media-cache.js +123 -0
- package/dist/ts/frame/media-cache.js.map +1 -0
- package/dist/ts/frame/memory-router.d.ts +10 -0
- package/dist/ts/frame/memory-router.d.ts.map +1 -0
- package/dist/ts/frame/memory-router.js +39 -0
- package/dist/ts/frame/memory-router.js.map +1 -0
- package/dist/ts/frame/parent-hello.d.ts +11 -0
- package/dist/ts/frame/parent-hello.d.ts.map +1 -0
- package/dist/ts/frame/parent-hello.js +53 -0
- package/dist/ts/frame/parent-hello.js.map +1 -0
- package/dist/ts/frame/protocol.d.ts +201 -0
- package/dist/ts/frame/protocol.d.ts.map +1 -0
- package/dist/ts/frame/protocol.js +195 -0
- package/dist/ts/frame/protocol.js.map +1 -0
- package/dist/ts/frame/rpc-content-client.d.ts +10 -0
- package/dist/ts/frame/rpc-content-client.d.ts.map +1 -0
- package/dist/ts/frame/rpc-content-client.js +51 -0
- package/dist/ts/frame/rpc-content-client.js.map +1 -0
- package/dist/ts/frame/save-shortcut.d.ts +8 -0
- package/dist/ts/frame/save-shortcut.d.ts.map +1 -0
- package/dist/ts/frame/save-shortcut.js +26 -0
- package/dist/ts/frame/save-shortcut.js.map +1 -0
- package/dist/ts/host-schema.d.ts +73 -0
- package/dist/ts/host-schema.d.ts.map +1 -0
- package/dist/ts/host-schema.js +66 -0
- package/dist/ts/host-schema.js.map +1 -0
- package/dist/ts/host-style-probe.d.ts +32 -37
- package/dist/ts/host-style-probe.d.ts.map +1 -1
- package/dist/ts/host-style-probe.js +102 -68
- package/dist/ts/host-style-probe.js.map +1 -1
- package/dist/ts/index.d.ts +4 -2
- package/dist/ts/index.d.ts.map +1 -1
- package/dist/ts/index.js +6 -2
- package/dist/ts/index.js.map +1 -1
- package/dist/ts/main-spa.d.ts.map +1 -1
- package/dist/ts/main-spa.js +2 -1
- package/dist/ts/main-spa.js.map +1 -1
- package/dist/ts/page-schema-define.d.ts +14 -12
- package/dist/ts/page-schema-define.d.ts.map +1 -1
- package/dist/ts/page-schema-define.js +8 -5
- package/dist/ts/page-schema-define.js.map +1 -1
- package/dist/ts/prose-surface-css.d.ts +3 -5
- package/dist/ts/prose-surface-css.d.ts.map +1 -1
- package/dist/ts/prose-surface-css.js +3 -5
- package/dist/ts/prose-surface-css.js.map +1 -1
- package/dist/ts/site-styles.d.ts +4 -21
- package/dist/ts/site-styles.d.ts.map +1 -1
- package/dist/ts/site-styles.js.map +1 -1
- package/dist/ts/ui-config.d.ts +52 -1
- package/dist/ts/ui-config.d.ts.map +1 -1
- package/dist/ts/ui-config.js +4 -0
- package/dist/ts/ui-config.js.map +1 -1
- package/dist/ts/utils/asset-url.d.ts +2 -0
- package/dist/ts/utils/asset-url.d.ts.map +1 -1
- package/dist/ts/utils/asset-url.js +7 -0
- package/dist/ts/utils/asset-url.js.map +1 -1
- package/dist/ts/utils/pageMetadata.d.ts.map +1 -1
- package/dist/ts/utils/pageMetadata.js +27 -10
- package/dist/ts/utils/pageMetadata.js.map +1 -1
- package/dist/ts/utils/schema-fields.d.ts +23 -0
- package/dist/ts/utils/schema-fields.d.ts.map +1 -0
- package/dist/ts/utils/schema-fields.js +82 -0
- package/dist/ts/utils/schema-fields.js.map +1 -0
- package/package.json +56 -18
- package/src/App.tsx +35 -14
- package/src/CmsSpaApp.tsx +5 -1
- package/src/components/CMSDashboard.tsx +12 -4
- package/src/components/RouteErrorPage.tsx +75 -0
- package/src/components/dashboard/RecentActivity.tsx +3 -7
- package/src/components/dialogs/CreateDataDialog.tsx +2 -2
- package/src/components/dialogs/CreateFolderDialog.tsx +2 -1
- package/src/components/dialogs/CreatePageFlow.tsx +117 -0
- package/src/components/dialogs/DataPropertiesDialog.tsx +3 -2
- package/src/components/dialogs/FragmentPropertiesDialog.tsx +3 -2
- package/src/components/dialogs/PageMetadataDialog.tsx +5 -28
- package/src/components/editor/CMSMDXEditor.tsx +49 -69
- package/src/components/editor/DrawerItemOverride.tsx +14 -8
- package/src/components/editor/PageEditor.tsx +135 -36
- package/src/components/editor/PageEditorHeaderActions.tsx +1 -1
- package/src/components/editor/PageEditorWrapper.tsx +51 -12
- package/src/components/editor/draft-media-config.ts +197 -0
- package/src/components/editor/preview-availability.ts +6 -5
- package/src/components/editors/DataEditor.tsx +2 -2
- package/src/components/forms/HintForm.tsx +7 -5
- package/src/components/forms/SchemaForm.tsx +41 -12
- package/src/components/media/AssetCard.tsx +10 -7
- package/src/components/media/AssetDetailSidebar.tsx +6 -6
- package/src/components/media/FolderTreeSidebar.tsx +3 -1
- package/src/components/pages/PageList.tsx +17 -119
- package/src/components/sandbox/ContentSandbox.tsx +34 -5
- package/src/content-form-fields.ts +79 -0
- package/src/content-wrapper.ts +284 -0
- package/src/data-schemas.ts +4 -3
- package/src/frame/channel.ts +258 -0
- package/src/frame/editor-frame.ts +180 -0
- package/src/frame/media-cache.ts +144 -0
- package/src/frame/memory-router.ts +39 -0
- package/src/frame/parent-hello.ts +62 -0
- package/src/frame/protocol.ts +323 -0
- package/src/frame/rpc-content-client.ts +58 -0
- package/src/frame/save-shortcut.ts +25 -0
- package/src/host-schema.ts +122 -0
- package/src/host-style-probe.ts +120 -90
- package/src/index.ts +7 -2
- package/src/main-spa.tsx +2 -0
- package/src/main.css +12 -8
- package/src/page-schema-define.ts +29 -17
- package/src/prose-surface-css.ts +3 -5
- package/src/site-styles.ts +4 -22
- package/src/ui-config.ts +54 -1
- package/src/utils/asset-url.ts +8 -0
- package/src/utils/pageMetadata.ts +27 -10
- package/src/utils/schema-fields.ts +106 -0
- package/dist/ts/host-discovery.d.ts +0 -40
- package/dist/ts/host-discovery.d.ts.map +0 -1
- package/dist/ts/host-discovery.js +0 -39
- package/dist/ts/host-discovery.js.map +0 -1
- package/dist/ts/utils/zodIntrospect.d.ts +0 -19
- package/dist/ts/utils/zodIntrospect.d.ts.map +0 -1
- package/dist/ts/utils/zodIntrospect.js +0 -95
- package/dist/ts/utils/zodIntrospect.js.map +0 -1
- package/src/host-discovery.ts +0 -77
- package/src/utils/zodIntrospect.ts +0 -136
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import type { ThemePreference } from '../theme.js';
|
|
2
|
+
import type { EditorWriteRefusal, PreviewCapability } from '../ui-config.js';
|
|
3
|
+
export { EDITOR_HOST_PROTOCOL, EDITOR_HOST_PROTOCOLS, type EditorFrameFailure, type EditorHostPageData, } from '@conloca/content-api-client';
|
|
4
|
+
export { CONTENT_METHOD_CLASSIFICATION } from '../write-access.js';
|
|
5
|
+
export interface ProtocolRange {
|
|
6
|
+
min: number;
|
|
7
|
+
max: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const HELLO_TYPE = "conloca:hello";
|
|
10
|
+
/** The parent's window message; it carries exactly one port. */
|
|
11
|
+
export interface Hello {
|
|
12
|
+
type: typeof HELLO_TYPE;
|
|
13
|
+
protocols: ProtocolRange;
|
|
14
|
+
}
|
|
15
|
+
/** The page's answer to a hello, with the identity its build baked in, so the parent can compare it. */
|
|
16
|
+
export interface Accepted {
|
|
17
|
+
kind: 'accepted';
|
|
18
|
+
protocol: number;
|
|
19
|
+
repo: string | null;
|
|
20
|
+
siteId: string;
|
|
21
|
+
}
|
|
22
|
+
export interface Nack {
|
|
23
|
+
kind: 'nack';
|
|
24
|
+
code: 'origin-rejected' | 'unsupported-protocol';
|
|
25
|
+
/** The protocol the page speaks, sent with `unsupported-protocol`. */
|
|
26
|
+
page?: number;
|
|
27
|
+
}
|
|
28
|
+
/** The parent's settings, sent once after `accepted`. */
|
|
29
|
+
export interface Init {
|
|
30
|
+
kind: 'init';
|
|
31
|
+
initialPath: string;
|
|
32
|
+
readOnly: EditorWriteRefusal | null;
|
|
33
|
+
previewCapability: PreviewCapability;
|
|
34
|
+
theme: ThemePreference;
|
|
35
|
+
locales?: {
|
|
36
|
+
list: string[];
|
|
37
|
+
defaultLocale: string;
|
|
38
|
+
};
|
|
39
|
+
mediaEnabled: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface Ready {
|
|
42
|
+
kind: 'ready';
|
|
43
|
+
}
|
|
44
|
+
export interface Call {
|
|
45
|
+
kind: 'call';
|
|
46
|
+
id: number;
|
|
47
|
+
method: string;
|
|
48
|
+
args: unknown[];
|
|
49
|
+
}
|
|
50
|
+
export type Result = {
|
|
51
|
+
kind: 'result';
|
|
52
|
+
id: number;
|
|
53
|
+
ok: true;
|
|
54
|
+
value: unknown;
|
|
55
|
+
} | {
|
|
56
|
+
kind: 'result';
|
|
57
|
+
id: number;
|
|
58
|
+
ok: false;
|
|
59
|
+
error: WireError;
|
|
60
|
+
};
|
|
61
|
+
export interface FrameEvent {
|
|
62
|
+
kind: 'event';
|
|
63
|
+
name: string;
|
|
64
|
+
payload: unknown;
|
|
65
|
+
}
|
|
66
|
+
export type ControlMessage = Accepted | Nack | Init | Ready;
|
|
67
|
+
export type FrameMessage = ControlMessage | Call | Result | FrameEvent;
|
|
68
|
+
/** Codes of the errors the channel itself raises. */
|
|
69
|
+
export type RpcErrorCode = 'method_not_allowed' | 'bad_arguments' | 'rate_limited';
|
|
70
|
+
/** An error as it crosses the port; the receiving side rebuilds the matching class. */
|
|
71
|
+
export interface WireError {
|
|
72
|
+
/** `APIClientError`, `StaleWriteError`, `ContentWriteRefusedError`, `RpcError` or `Error`. */
|
|
73
|
+
name: string;
|
|
74
|
+
message: string;
|
|
75
|
+
/** `APIClientError.code`, or an {@link RpcErrorCode}. */
|
|
76
|
+
code?: string;
|
|
77
|
+
/** `APIClientError.details`. */
|
|
78
|
+
details?: unknown;
|
|
79
|
+
/** `StaleWriteError.data`. */
|
|
80
|
+
data?: unknown;
|
|
81
|
+
/** `ContentWriteRefusedError.method`. */
|
|
82
|
+
method?: string;
|
|
83
|
+
refusal?: {
|
|
84
|
+
reason: string;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** The argument of `media.load`. */
|
|
88
|
+
export interface MediaLoadInput {
|
|
89
|
+
route: 'serve' | 'draft';
|
|
90
|
+
/** Relative to the media root (`uploads/hero.png`): raw, never URL-encoded, no leading slash. */
|
|
91
|
+
path: string;
|
|
92
|
+
}
|
|
93
|
+
/** The answer to `preview.open`. */
|
|
94
|
+
export type PreviewOpenResult = {
|
|
95
|
+
ok: true;
|
|
96
|
+
} | {
|
|
97
|
+
ok: false;
|
|
98
|
+
reason: 'not-deployed';
|
|
99
|
+
message: string;
|
|
100
|
+
} | {
|
|
101
|
+
ok: false;
|
|
102
|
+
reason: 'popup-blocked';
|
|
103
|
+
};
|
|
104
|
+
/** The answer to `site.open`; a refused path rejects with `RpcError` `bad_arguments`. */
|
|
105
|
+
export type SiteOpenResult = {
|
|
106
|
+
ok: true;
|
|
107
|
+
} | {
|
|
108
|
+
ok: false;
|
|
109
|
+
reason: 'popup-blocked';
|
|
110
|
+
};
|
|
111
|
+
/** Each event name and its payload. */
|
|
112
|
+
export interface FrameEventPayloads {
|
|
113
|
+
'editor.dirty': {
|
|
114
|
+
dirty: boolean;
|
|
115
|
+
};
|
|
116
|
+
'shortcut.save': null;
|
|
117
|
+
'editor.stale': null;
|
|
118
|
+
'load.failed': {
|
|
119
|
+
stage: 'site' | 'css' | 'ui';
|
|
120
|
+
/** For logs; the parent shows its own text. */
|
|
121
|
+
message: string;
|
|
122
|
+
};
|
|
123
|
+
'route.changed': {
|
|
124
|
+
path: string;
|
|
125
|
+
replace: boolean;
|
|
126
|
+
};
|
|
127
|
+
'route.navigate': {
|
|
128
|
+
path: string;
|
|
129
|
+
};
|
|
130
|
+
'readOnly.changed': {
|
|
131
|
+
readOnly: EditorWriteRefusal | null;
|
|
132
|
+
};
|
|
133
|
+
'previewCapability.changed': {
|
|
134
|
+
previewCapability: PreviewCapability;
|
|
135
|
+
};
|
|
136
|
+
'theme.changed': {
|
|
137
|
+
theme: ThemePreference;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/** Content methods the page may call; the parent refuses every other client method. */
|
|
141
|
+
export declare const FRAME_CONTENT_METHODS: readonly ["getContent", "getLocalized", "getSitePages", "getFragments", "getData", "getDataCollections", "listAllContent", "getSitesConfig", "getPageByPathname", "getFragmentByName", "getDataByName", "isPathnameAvailable", "isDataNameAvailable", "compileMDX", "createContent", "updateLocalized", "deleteContent", "deleteLocalized", "batchUpdate", "movePage", "listAssets", "getAsset", "listFolder", "getFolderTree", "getAssetUsage", "uploadAsset", "importAssetUrl", "deleteAsset", "createFolder", "updateAssetMetadata", "moveAssets"];
|
|
142
|
+
/** Parent-side methods the page may call; `site.open` takes `{ path }`, the page pathname relative to the site base. */
|
|
143
|
+
export declare const FRAME_HOST_METHODS: readonly ['mediaBridge.getAssetScope', 'mediaBridge.getMediaIssue', 'media.load', 'preview.open', 'site.open'];
|
|
144
|
+
/**
|
|
145
|
+
* The parent calls this on the page and gets an `EditorFlushResult`. Its `message` is for logs; the parent shows its
|
|
146
|
+
* own text.
|
|
147
|
+
*/
|
|
148
|
+
export declare const EDITOR_FLUSH_METHOD = "editor.flush";
|
|
149
|
+
export type FrameMethod = (typeof FRAME_CONTENT_METHODS)[number] | (typeof FRAME_HOST_METHODS)[number];
|
|
150
|
+
/** The most arguments each method takes, as the client declares them. */
|
|
151
|
+
export declare const FRAME_METHOD_MAX_ARGS: {
|
|
152
|
+
readonly getContent: 1;
|
|
153
|
+
readonly getLocalized: 2;
|
|
154
|
+
readonly getSitePages: 2;
|
|
155
|
+
readonly getFragments: 2;
|
|
156
|
+
readonly getData: 2;
|
|
157
|
+
readonly getDataCollections: 0;
|
|
158
|
+
readonly listAllContent: 1;
|
|
159
|
+
readonly getSitesConfig: 0;
|
|
160
|
+
readonly getPageByPathname: 3;
|
|
161
|
+
readonly getFragmentByName: 3;
|
|
162
|
+
readonly getDataByName: 3;
|
|
163
|
+
readonly isPathnameAvailable: 4;
|
|
164
|
+
readonly isDataNameAvailable: 3;
|
|
165
|
+
readonly compileMDX: 1;
|
|
166
|
+
readonly createContent: 1;
|
|
167
|
+
readonly updateLocalized: 1;
|
|
168
|
+
readonly deleteContent: 2;
|
|
169
|
+
readonly deleteLocalized: 1;
|
|
170
|
+
readonly batchUpdate: 1;
|
|
171
|
+
readonly movePage: 5;
|
|
172
|
+
readonly listAssets: 0;
|
|
173
|
+
readonly getAsset: 1;
|
|
174
|
+
readonly listFolder: 1;
|
|
175
|
+
readonly getFolderTree: 0;
|
|
176
|
+
readonly getAssetUsage: 1;
|
|
177
|
+
readonly uploadAsset: 1;
|
|
178
|
+
readonly importAssetUrl: 3;
|
|
179
|
+
readonly deleteAsset: 1;
|
|
180
|
+
readonly createFolder: 1;
|
|
181
|
+
readonly updateAssetMetadata: 2;
|
|
182
|
+
readonly moveAssets: 3;
|
|
183
|
+
readonly 'mediaBridge.getAssetScope': 1;
|
|
184
|
+
readonly 'mediaBridge.getMediaIssue': 1;
|
|
185
|
+
readonly 'media.load': 1;
|
|
186
|
+
readonly 'preview.open': 1;
|
|
187
|
+
readonly 'site.open': 1;
|
|
188
|
+
};
|
|
189
|
+
/** Whether `path` is an editor route (`pathname + search`) the page may report or the parent may send. */
|
|
190
|
+
export declare function isFramePath(path: string): boolean;
|
|
191
|
+
export declare function isThemePreference(value: unknown): value is ThemePreference;
|
|
192
|
+
export declare function isPreviewCapability(value: unknown): value is PreviewCapability;
|
|
193
|
+
export declare function isWriteRefusal(value: unknown): value is EditorWriteRefusal;
|
|
194
|
+
/** Reads a control message off the port; `undefined` when `data` is not a well-formed one. */
|
|
195
|
+
export declare function readControlMessage(data: unknown): ControlMessage | undefined;
|
|
196
|
+
/**
|
|
197
|
+
* Whether the page accepts a hello from `origin`: `https://<label>.<root>` without a port, `<label>` one DNS label
|
|
198
|
+
* that is not reserved. Under a `.localhost` root, `http:` and any port are allowed too.
|
|
199
|
+
*/
|
|
200
|
+
export declare function acceptsParentOrigin(origin: string, root: string, isReserved: (label: string) => boolean): boolean;
|
|
201
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../src/frame/protocol.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE7E,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAEnE,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,UAAU,kBAAkB,CAAC;AAE1C,gEAAgE;AAChE,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,OAAO,UAAU,CAAC;IACxB,SAAS,EAAE,aAAa,CAAC;CAC1B;AAED,wGAAwG;AACxG,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,iBAAiB,GAAG,sBAAsB,CAAC;IACjD,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,yDAAyD;AACzD,MAAM,WAAW,IAAI;IACnB,IAAI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jD;AAID,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAE9E;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAE1E;AAiCD,8FAA8F;AAC9F,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAqB5E;AAID;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAejH"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
export { EDITOR_HOST_PROTOCOL, EDITOR_HOST_PROTOCOLS, } from '@conloca/content-api-client';
|
|
2
|
+
export { CONTENT_METHOD_CLASSIFICATION } from '../write-access.js';
|
|
3
|
+
export const HELLO_TYPE = 'conloca:hello';
|
|
4
|
+
/** Content methods the page may call; the parent refuses every other client method. */
|
|
5
|
+
export const FRAME_CONTENT_METHODS = [
|
|
6
|
+
'getContent',
|
|
7
|
+
'getLocalized',
|
|
8
|
+
'getSitePages',
|
|
9
|
+
'getFragments',
|
|
10
|
+
'getData',
|
|
11
|
+
'getDataCollections',
|
|
12
|
+
'listAllContent',
|
|
13
|
+
'getSitesConfig',
|
|
14
|
+
'getPageByPathname',
|
|
15
|
+
'getFragmentByName',
|
|
16
|
+
'getDataByName',
|
|
17
|
+
'isPathnameAvailable',
|
|
18
|
+
'isDataNameAvailable',
|
|
19
|
+
'compileMDX',
|
|
20
|
+
'createContent',
|
|
21
|
+
'updateLocalized',
|
|
22
|
+
'deleteContent',
|
|
23
|
+
'deleteLocalized',
|
|
24
|
+
'batchUpdate',
|
|
25
|
+
'movePage',
|
|
26
|
+
'listAssets',
|
|
27
|
+
'getAsset',
|
|
28
|
+
'listFolder',
|
|
29
|
+
'getFolderTree',
|
|
30
|
+
'getAssetUsage',
|
|
31
|
+
'uploadAsset',
|
|
32
|
+
'importAssetUrl',
|
|
33
|
+
'deleteAsset',
|
|
34
|
+
'createFolder',
|
|
35
|
+
'updateAssetMetadata',
|
|
36
|
+
'moveAssets',
|
|
37
|
+
];
|
|
38
|
+
/** Parent-side methods the page may call; `site.open` takes `{ path }`, the page pathname relative to the site base. */
|
|
39
|
+
export const FRAME_HOST_METHODS = [
|
|
40
|
+
'mediaBridge.getAssetScope',
|
|
41
|
+
'mediaBridge.getMediaIssue',
|
|
42
|
+
'media.load',
|
|
43
|
+
'preview.open',
|
|
44
|
+
'site.open',
|
|
45
|
+
];
|
|
46
|
+
/**
|
|
47
|
+
* The parent calls this on the page and gets an `EditorFlushResult`. Its `message` is for logs; the parent shows its
|
|
48
|
+
* own text.
|
|
49
|
+
*/
|
|
50
|
+
export const EDITOR_FLUSH_METHOD = 'editor.flush';
|
|
51
|
+
/** The most arguments each method takes, as the client declares them. */
|
|
52
|
+
export const FRAME_METHOD_MAX_ARGS = {
|
|
53
|
+
getContent: 1,
|
|
54
|
+
getLocalized: 2,
|
|
55
|
+
getSitePages: 2,
|
|
56
|
+
getFragments: 2,
|
|
57
|
+
getData: 2,
|
|
58
|
+
getDataCollections: 0,
|
|
59
|
+
listAllContent: 1,
|
|
60
|
+
getSitesConfig: 0,
|
|
61
|
+
getPageByPathname: 3,
|
|
62
|
+
getFragmentByName: 3,
|
|
63
|
+
getDataByName: 3,
|
|
64
|
+
isPathnameAvailable: 4,
|
|
65
|
+
isDataNameAvailable: 3,
|
|
66
|
+
compileMDX: 1,
|
|
67
|
+
createContent: 1,
|
|
68
|
+
updateLocalized: 1,
|
|
69
|
+
deleteContent: 2,
|
|
70
|
+
deleteLocalized: 1,
|
|
71
|
+
batchUpdate: 1,
|
|
72
|
+
movePage: 5,
|
|
73
|
+
listAssets: 0,
|
|
74
|
+
getAsset: 1,
|
|
75
|
+
listFolder: 1,
|
|
76
|
+
getFolderTree: 0,
|
|
77
|
+
getAssetUsage: 1,
|
|
78
|
+
uploadAsset: 1,
|
|
79
|
+
importAssetUrl: 3,
|
|
80
|
+
deleteAsset: 1,
|
|
81
|
+
createFolder: 1,
|
|
82
|
+
updateAssetMetadata: 2,
|
|
83
|
+
moveAssets: 3,
|
|
84
|
+
'mediaBridge.getAssetScope': 1,
|
|
85
|
+
'mediaBridge.getMediaIssue': 1,
|
|
86
|
+
'media.load': 1,
|
|
87
|
+
'preview.open': 1,
|
|
88
|
+
'site.open': 1,
|
|
89
|
+
};
|
|
90
|
+
const FRAME_PATH_RE = /^\/[A-Za-z0-9/_.:%-]{0,512}(\?[A-Za-z0-9_.:%=&-]{0,512})?$/;
|
|
91
|
+
const DNS_LABEL_RE = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
92
|
+
/** Whether `path` is an editor route (`pathname + search`) the page may report or the parent may send. */
|
|
93
|
+
export function isFramePath(path) {
|
|
94
|
+
return FRAME_PATH_RE.test(path) && !path.includes('//');
|
|
95
|
+
}
|
|
96
|
+
/* oxlint-disable anti-slop/no-unknown-parameters -- the guards below read what arrives on the port, untyped by nature. */
|
|
97
|
+
export function isThemePreference(value) {
|
|
98
|
+
return value === 'light' || value === 'dark' || value === 'system';
|
|
99
|
+
}
|
|
100
|
+
export function isPreviewCapability(value) {
|
|
101
|
+
return value === 'available' || value === 'unavailable' || value === 'unknown';
|
|
102
|
+
}
|
|
103
|
+
export function isWriteRefusal(value) {
|
|
104
|
+
return typeof value === 'object' && value !== null && 'reason' in value && typeof value.reason === 'string';
|
|
105
|
+
}
|
|
106
|
+
function readLocales(value) {
|
|
107
|
+
if (typeof value !== 'object' || value === null || !('list' in value) || !('defaultLocale' in value))
|
|
108
|
+
return undefined;
|
|
109
|
+
const { list, defaultLocale } = value;
|
|
110
|
+
if (!Array.isArray(list) || typeof defaultLocale !== 'string')
|
|
111
|
+
return undefined;
|
|
112
|
+
const locales = list.filter((locale) => typeof locale === 'string');
|
|
113
|
+
return locales.length === list.length ? { list: locales, defaultLocale } : undefined;
|
|
114
|
+
}
|
|
115
|
+
function readInit(data) {
|
|
116
|
+
if (typeof data !== 'object' || data === null)
|
|
117
|
+
return undefined;
|
|
118
|
+
if (!('initialPath' in data) || typeof data.initialPath !== 'string' || !isFramePath(data.initialPath)) {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
if (!('readOnly' in data) || !(data.readOnly === null || isWriteRefusal(data.readOnly)))
|
|
122
|
+
return undefined;
|
|
123
|
+
if (!('previewCapability' in data) || !isPreviewCapability(data.previewCapability))
|
|
124
|
+
return undefined;
|
|
125
|
+
if (!('theme' in data) || !isThemePreference(data.theme))
|
|
126
|
+
return undefined;
|
|
127
|
+
if (!('mediaEnabled' in data) || typeof data.mediaEnabled !== 'boolean')
|
|
128
|
+
return undefined;
|
|
129
|
+
const init = {
|
|
130
|
+
kind: 'init',
|
|
131
|
+
initialPath: data.initialPath,
|
|
132
|
+
readOnly: data.readOnly,
|
|
133
|
+
previewCapability: data.previewCapability,
|
|
134
|
+
theme: data.theme,
|
|
135
|
+
mediaEnabled: data.mediaEnabled,
|
|
136
|
+
};
|
|
137
|
+
if (!('locales' in data) || data.locales === undefined)
|
|
138
|
+
return init;
|
|
139
|
+
const locales = readLocales(data.locales);
|
|
140
|
+
return locales ? { ...init, locales } : undefined;
|
|
141
|
+
}
|
|
142
|
+
/** Reads a control message off the port; `undefined` when `data` is not a well-formed one. */
|
|
143
|
+
export function readControlMessage(data) {
|
|
144
|
+
if (typeof data !== 'object' || data === null || !('kind' in data))
|
|
145
|
+
return undefined;
|
|
146
|
+
switch (data.kind) {
|
|
147
|
+
case 'ready':
|
|
148
|
+
return { kind: 'ready' };
|
|
149
|
+
case 'init':
|
|
150
|
+
return readInit(data);
|
|
151
|
+
case 'accepted':
|
|
152
|
+
if (!('protocol' in data) || typeof data.protocol !== 'number')
|
|
153
|
+
return undefined;
|
|
154
|
+
if (!('repo' in data) || !(data.repo === null || typeof data.repo === 'string'))
|
|
155
|
+
return undefined;
|
|
156
|
+
if (!('siteId' in data) || typeof data.siteId !== 'string')
|
|
157
|
+
return undefined;
|
|
158
|
+
return { kind: 'accepted', protocol: data.protocol, repo: data.repo, siteId: data.siteId };
|
|
159
|
+
case 'nack': {
|
|
160
|
+
if (!('code' in data) || (data.code !== 'origin-rejected' && data.code !== 'unsupported-protocol'))
|
|
161
|
+
return undefined;
|
|
162
|
+
const nack = { kind: 'nack', code: data.code };
|
|
163
|
+
return 'page' in data && typeof data.page === 'number' ? { ...nack, page: data.page } : nack;
|
|
164
|
+
}
|
|
165
|
+
default:
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/* oxlint-enable anti-slop/no-unknown-parameters */
|
|
170
|
+
/**
|
|
171
|
+
* Whether the page accepts a hello from `origin`: `https://<label>.<root>` without a port, `<label>` one DNS label
|
|
172
|
+
* that is not reserved. Under a `.localhost` root, `http:` and any port are allowed too.
|
|
173
|
+
*/
|
|
174
|
+
export function acceptsParentOrigin(origin, root, isReserved) {
|
|
175
|
+
let url;
|
|
176
|
+
try {
|
|
177
|
+
url = new URL(origin);
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
const local = root.endsWith('.localhost');
|
|
183
|
+
if (url.origin !== origin)
|
|
184
|
+
return false;
|
|
185
|
+
if (url.protocol !== 'https:' && !(local && url.protocol === 'http:'))
|
|
186
|
+
return false;
|
|
187
|
+
if (url.port !== '' && !local)
|
|
188
|
+
return false;
|
|
189
|
+
const suffix = `.${root}`;
|
|
190
|
+
if (!url.hostname.endsWith(suffix))
|
|
191
|
+
return false;
|
|
192
|
+
const label = url.hostname.slice(0, -suffix.length);
|
|
193
|
+
return DNS_LABEL_RE.test(label) && !isReserved(label);
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/frame/protocol.ts"],"names":[],"mappings":"AASA,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GAGtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAOnE,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC;AA8G1C,uFAAuF;AACvF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,YAAY;IACZ,cAAc;IACd,cAAc;IACd,cAAc;IACd,SAAS;IACT,oBAAoB;IACpB,gBAAgB;IAChB,gBAAgB;IAChB,mBAAmB;IACnB,mBAAmB;IACnB,eAAe;IACf,qBAAqB;IACrB,qBAAqB;IACrB,YAAY;IACZ,eAAe;IACf,iBAAiB;IACjB,eAAe;IACf,iBAAiB;IACjB,aAAa;IACb,UAAU;IACV,YAAY;IACZ,UAAU;IACV,YAAY;IACZ,eAAe;IACf,eAAe;IACf,aAAa;IACb,gBAAgB;IAChB,aAAa;IACb,cAAc;IACd,qBAAqB;IACrB,YAAY;CAC0C,CAAC;AAEzD,wHAAwH;AACxH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,2BAA2B;IAC3B,2BAA2B;IAC3B,YAAY;IACZ,cAAc;IACd,WAAW;CACH,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAIlD,yEAAyE;AACzE,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,UAAU,EAAE,CAAC;IACb,YAAY,EAAE,CAAC;IACf,YAAY,EAAE,CAAC;IACf,YAAY,EAAE,CAAC;IACf,OAAO,EAAE,CAAC;IACV,kBAAkB,EAAE,CAAC;IACrB,cAAc,EAAE,CAAC;IACjB,cAAc,EAAE,CAAC;IACjB,iBAAiB,EAAE,CAAC;IACpB,iBAAiB,EAAE,CAAC;IACpB,aAA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AAsC;IACtG,IAAI,GAAQ,CAAC;IACb,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC1C,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IACpF,IAAI,GAAG,CAAC,IAAI,KAAK,EAAE,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAC5C,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;IAC1B,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IACjD,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACpD,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ContentAPIClient } from '@conloca/content-api-client';
|
|
2
|
+
import type { FrameChannel } from './channel.js';
|
|
3
|
+
/**
|
|
4
|
+
* The content client of an editor frame: it holds no credentials, so every content method becomes a call the
|
|
5
|
+
* parent frame runs on its own client. All methods cross, writes and reads alike; the parent decides what it refuses.
|
|
6
|
+
*/
|
|
7
|
+
export declare class RpcContentClient extends ContentAPIClient {
|
|
8
|
+
constructor(channel: Pick<FrameChannel, 'call'>);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=rpc-content-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-content-client.d.ts","sourceRoot":"","sources":["../../../src/frame/rpc-content-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAgCjD;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,gBAAgB;IACpD,YAAY,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,EAkB9C;CACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ContentAPIClient } from '@conloca/content-api-client';
|
|
2
|
+
import { clearMediaCache } from './media-cache.js';
|
|
3
|
+
import { CONTENT_METHOD_CLASSIFICATION } from './protocol.js';
|
|
4
|
+
/** Writes after which loaded media bytes may be stale. */
|
|
5
|
+
const MEDIA_WRITES = new Set([
|
|
6
|
+
'uploadAsset',
|
|
7
|
+
'importAssetUrl',
|
|
8
|
+
'deleteAsset',
|
|
9
|
+
'createFolder',
|
|
10
|
+
'updateAssetMetadata',
|
|
11
|
+
'moveAssets',
|
|
12
|
+
]);
|
|
13
|
+
/** The name/value pairs of an upload form, each File replaced by a copy held in memory. */
|
|
14
|
+
function uploadPairs(form) {
|
|
15
|
+
return Promise.all([...form.entries()].map(async ([name, value]) => typeof value === 'string'
|
|
16
|
+
? [name, value]
|
|
17
|
+
: [
|
|
18
|
+
name,
|
|
19
|
+
new File([await value.arrayBuffer()], value.name, {
|
|
20
|
+
type: value.type,
|
|
21
|
+
lastModified: value.lastModified,
|
|
22
|
+
}),
|
|
23
|
+
]));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The content client of an editor frame: it holds no credentials, so every content method becomes a call the
|
|
27
|
+
* parent frame runs on its own client. All methods cross, writes and reads alike; the parent decides what it refuses.
|
|
28
|
+
*/
|
|
29
|
+
export class RpcContentClient extends ContentAPIClient {
|
|
30
|
+
constructor(channel) {
|
|
31
|
+
super();
|
|
32
|
+
for (const method of Object.keys(CONTENT_METHOD_CLASSIFICATION)) {
|
|
33
|
+
Object.defineProperty(this, method, {
|
|
34
|
+
// oxlint-disable-next-line anti-slop/no-unknown-returns -- it replaces a typed ContentAPIClient method; callers see that method's types.
|
|
35
|
+
value: async (...args) => {
|
|
36
|
+
// FormData cannot be cloned onto a port; its name/value pairs can. A picked File is backed by a disk
|
|
37
|
+
// path only this frame's process may read, so each File crosses as an in-memory copy of its bytes.
|
|
38
|
+
const sent = method === 'uploadAsset' && args[0] instanceof FormData ? [await uploadPairs(args[0])] : args;
|
|
39
|
+
const result = await channel.call(method, sent);
|
|
40
|
+
if (MEDIA_WRITES.has(method))
|
|
41
|
+
clearMediaCache();
|
|
42
|
+
return result;
|
|
43
|
+
},
|
|
44
|
+
writable: false,
|
|
45
|
+
enumerable: false,
|
|
46
|
+
configurable: false,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=rpc-content-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-content-client.js","sourceRoot":"","sources":["../../../src/frame/rpc-content-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AAE9D,0DAA0D;AAC1D,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,aAAa;IACb,gBAAgB;IAChB,aAAa;IACb,cAAc;IACd,qBAAqB;IACrB,YAAY;CACb,CAAC,CAAC;AAEH,2FAA2F;AAC3F,SAAS,WAAW,CAAC,IAAc;IACjC,OAAO,OAAO,CAAC,GAAG,CAChB,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,CA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,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Whether a key press is Cmd/Ctrl+S. */
|
|
2
|
+
export declare function isSaveCombo(event: KeyboardEvent): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* In a parent frame, hands Cmd/Ctrl+S pressed inside the editing canvas to the editor's `window`, where the frame
|
|
5
|
+
* connection sends it to the parent. The canvas is its own document, so its key presses never reach `window`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useCanvasSaveShortcut(canvasDocument: Document | undefined): void;
|
|
8
|
+
//# sourceMappingURL=save-shortcut.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-shortcut.d.ts","sourceRoot":"","sources":["../../../src/frame/save-shortcut.ts"],"names":[],"mappings":"AAGA,yCAAyC;AACzC,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAEzD;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,QAAQ,GAAG,SAAS,GAAG,IAAI,CAYhF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { inEditorFrame } from '../ui-config.js';
|
|
3
|
+
/** Whether a key press is Cmd/Ctrl+S. */
|
|
4
|
+
export function isSaveCombo(event) {
|
|
5
|
+
return (event.metaKey || event.ctrlKey) && (event.key === 's' || event.key === 'S');
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* In a parent frame, hands Cmd/Ctrl+S pressed inside the editing canvas to the editor's `window`, where the frame
|
|
9
|
+
* connection sends it to the parent. The canvas is its own document, so its key presses never reach `window`.
|
|
10
|
+
*/
|
|
11
|
+
export function useCanvasSaveShortcut(canvasDocument) {
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!canvasDocument || !inEditorFrame())
|
|
14
|
+
return undefined;
|
|
15
|
+
const onKeyDown = (event) => {
|
|
16
|
+
if (!isSaveCombo(event))
|
|
17
|
+
return;
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
const { key, metaKey, ctrlKey } = event;
|
|
20
|
+
window.dispatchEvent(new KeyboardEvent('keydown', { key, metaKey, ctrlKey, cancelable: true }));
|
|
21
|
+
};
|
|
22
|
+
canvasDocument.addEventListener('keydown', onKeyDown);
|
|
23
|
+
return () => canvasDocument.removeEventListener('keydown', onKeyDown);
|
|
24
|
+
}, [canvasDocument]);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=save-shortcut.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-shortcut.js","sourceRoot":"","sources":["../../../src/frame/save-shortcut.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,yCAAyC;AACzC,MAAM,UAAU,WAAW,CAAC,KAAoB;IAC9C,OAAO,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;AACtF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,cAAoC;IACxE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,cAAc,IAAI,CAAC,aAAa,EAAE;YAAE,OAAO,SAAS,CAAC;QAC1D,MAAM,SAAS,GAAG,CAAC,KAAoB,EAAE,EAAE;YACzC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;gBAAE,OAAO;YAChC,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;YACxC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,SAAS,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAClG,CAAC,CAAC;QACF,cAAc,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACtD,OAAO,GAAG,EAAE,CAAC,cAAc,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACxE,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { IJsonSchemaUnit, IValidation } from '@typia/interface';
|
|
2
|
+
/**
|
|
3
|
+
* The contract a site's `pageSchemas` / `dataSchemas` entries are written in.
|
|
4
|
+
*
|
|
5
|
+
* A site's content schema is dynamic from this package's point of view — it is
|
|
6
|
+
* declared in the host's own source and only reaches the CMS at runtime — so the
|
|
7
|
+
* CMS cannot generate anything for it. The host does, with Typia, where the type
|
|
8
|
+
* lives:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import typia from 'typia';
|
|
12
|
+
*
|
|
13
|
+
* interface BlogFields {
|
|
14
|
+
* // A JSDoc comment here becomes the field's help text in the editor.
|
|
15
|
+
* excerpt?: string;
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* export const articleFields = defineHostSchema<BlogFields>({
|
|
19
|
+
* validate: typia.createValidate<BlogFields>(),
|
|
20
|
+
* metadata: typia.json.schema<BlogFields>(),
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Both members are compiler output for the same `T`: `validate` is what the
|
|
25
|
+
* build validates stored entries with (`@conloca/astro-cms`'s loader), and
|
|
26
|
+
* `metadata` is the JSON Schema the editor renders its form from. Nothing here
|
|
27
|
+
* re-describes the shape by hand, and the `T` parameter ties the two together at
|
|
28
|
+
* compile time.
|
|
29
|
+
*
|
|
30
|
+
* `typia.plain.createValidatePrune<T>()` is the Zod-`z.object()` equivalent for
|
|
31
|
+
* `validate`: on success it also drops undeclared nested keys. Plain
|
|
32
|
+
* `typia.createValidate<T>()` keeps them.
|
|
33
|
+
*/
|
|
34
|
+
export interface HostSchema<T extends object = object> {
|
|
35
|
+
/** A generated Typia validator for `T` (`typia.createValidate<T>()` or `typia.plain.createValidatePrune<T>()`). */
|
|
36
|
+
readonly validate: (input: unknown) => IValidation<T>;
|
|
37
|
+
/** Generated JSON Schema metadata for `T` (`typia.json.schema<T>()`). */
|
|
38
|
+
readonly metadata: IJsonSchemaUnit<'3.1', T>;
|
|
39
|
+
}
|
|
40
|
+
/** The value type a {@link HostSchema} validates — the `z.infer` of this contract. */
|
|
41
|
+
export type HostSchemaType<S> = S extends HostSchema<infer T> ? T : never;
|
|
42
|
+
/**
|
|
43
|
+
* Typed identity for a {@link HostSchema}. Refuses at declaration time what the
|
|
44
|
+
* editor and the loader could not use: a validator that is not a function, or
|
|
45
|
+
* metadata whose root is not an object type (content entries are records).
|
|
46
|
+
*/
|
|
47
|
+
export declare function defineHostSchema<T extends object>(schema: HostSchema<T>): HostSchema<T>;
|
|
48
|
+
/**
|
|
49
|
+
* Whether a value is a generated host schema. A site's `dataSchemas` / `pageSchemas` reach the
|
|
50
|
+
* editor at runtime from the site's own bundle, so an entry written before the generated
|
|
51
|
+
* contract (a validator-library object, a hand-written descriptor) can arrive where the types
|
|
52
|
+
* promise a {@link HostSchema}; reading its `metadata` then throws. Check before reading.
|
|
53
|
+
*/
|
|
54
|
+
export declare function isHostSchema(value: unknown): value is HostSchema;
|
|
55
|
+
/** Generated JSON Schema metadata, whatever type it was generated for. */
|
|
56
|
+
export type HostSchemaMetadata = IJsonSchemaUnit.IV3_1<unknown>;
|
|
57
|
+
type JsonSchema = HostSchemaMetadata['schema'];
|
|
58
|
+
type JsonObjectSchema = Extract<JsonSchema, {
|
|
59
|
+
type: 'object';
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* Follow a generated `$ref` to its component. Returns the schema unchanged when
|
|
63
|
+
* it is not a reference, and `null` for a reference the unit does not carry.
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolveHostJsonSchema(metadata: HostSchemaMetadata, node: JsonSchema): Exclude<JsonSchema, {
|
|
66
|
+
$ref: string;
|
|
67
|
+
}> | null;
|
|
68
|
+
/** The object schema at the root of generated metadata, or `null` when the root is not an object. */
|
|
69
|
+
export declare function rootObjectOf(metadata: HostSchemaMetadata): JsonObjectSchema | null;
|
|
70
|
+
/** The top-level field names a host schema declares, in declaration order. */
|
|
71
|
+
export declare function hostSchemaFieldNames(schema: HostSchema): string[];
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=host-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-schema.d.ts","sourceRoot":"","sources":["../../src/host-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACnD,mHAAmH;IACnH,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC;IACtD,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC9C;AAED,sFAAsF;AACtF,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAUvF;AAED;;;;;GAKG;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAiBhE;AAED,0EAA0E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