@vcp-dev/site-edit-bridge 0.3.14

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.
@@ -0,0 +1,337 @@
1
+ import type { SiteEditCommandSuccess, SiteEditEvent, SiteEditObjectEditContext, SiteEditObjectSummary, SiteEditGetClassNameSourceCommandResult, SiteEditOperationCommandResult, SiteEditOperationRequest, SiteEditRenderDocument } from "@vcp-dev/contracts";
2
+ export declare const VCP_WINDOW_MESSAGE_SOURCE = "vcp-window-message";
3
+ export declare const VCP_WINDOW_MESSAGE_VERSION = 1;
4
+ export type VcpWindowMessageEnvelope<TNamespace extends string = string, TChannel extends string = string, TBody = unknown> = {
5
+ source: typeof VCP_WINDOW_MESSAGE_SOURCE;
6
+ version: typeof VCP_WINDOW_MESSAGE_VERSION;
7
+ namespace: TNamespace;
8
+ channel: TChannel;
9
+ sessionKey?: string;
10
+ body: TBody;
11
+ };
12
+ export declare function createVcpWindowMessageEnvelope<TNamespace extends string, TChannel extends string, TBody>(input: {
13
+ namespace: TNamespace;
14
+ channel: TChannel;
15
+ body: TBody;
16
+ sessionKey?: string;
17
+ }): VcpWindowMessageEnvelope<TNamespace, TChannel, TBody>;
18
+ export declare function isVcpWindowMessageEnvelope(value: unknown): value is VcpWindowMessageEnvelope;
19
+ export declare const SITE_EDIT_WINDOW_MESSAGE_NAMESPACE = "site-edit";
20
+ export declare const SITE_EDIT_FRAME_RUNTIME_CHANNEL = "frame-runtime";
21
+ export type SiteEditFrameRuntimeRef = {
22
+ key: string;
23
+ instanceIndex?: number;
24
+ instanceCount?: number;
25
+ textSegmentIndex?: number;
26
+ };
27
+ export type SiteEditFrameRuntimeStarted = {
28
+ ref: SiteEditFrameRuntimeRef;
29
+ };
30
+ export type SiteEditFrameRuntimeHitDetailLevel = "summary" | "full";
31
+ export type SiteEditFrameRuntimeScrollMetrics = {
32
+ scrollX: number;
33
+ scrollY: number;
34
+ scrollWidth: number;
35
+ scrollHeight: number;
36
+ viewportWidth: number;
37
+ viewportHeight: number;
38
+ };
39
+ export type SiteEditFrameRuntimePointerEventKind = "pointer-down" | "pointer-move" | "pointer-up" | "pointer-cancel" | "pointer-click" | "pointer-double-click";
40
+ export type SiteEditFrameRuntimeNodePatch = {
41
+ attributes?: Record<string, string | null>;
42
+ className?: string;
43
+ style?: Record<string, string | number | null | undefined>;
44
+ };
45
+ export type SiteEditFrameRuntimeNodePatchPreviewMeta = {
46
+ sessionId: string;
47
+ revision: number;
48
+ responseDetail?: "none" | "summary" | "full";
49
+ };
50
+ export type SiteEditFrameRuntimeNodePatchAck = {
51
+ applied: boolean;
52
+ appliedRevision?: number;
53
+ stale?: boolean;
54
+ duplicate?: boolean;
55
+ latestRevision?: number;
56
+ };
57
+ /**
58
+ * Theme try-on override applied in the preview frame without writing files.
59
+ * A second set replaces the previous override entirely.
60
+ */
61
+ export type SiteEditFrameRuntimeThemeOverride = {
62
+ /** CSS custom properties applied to the document element; non `--` keys are ignored. */
63
+ variables: Record<string, string>;
64
+ /** Stylesheet hrefs injected as `link[data-vcp-theme-preview]` elements, deduped by href. */
65
+ stylesheets?: string[];
66
+ };
67
+ export type SiteEditFrameRuntimeDropRelation = "before" | "after" | "append" | "prepend" | "none";
68
+ export type SiteEditFrameRuntimeDropRejectionReason = "no-editable-hit" | "no-accepting-parent" | "self-or-descendant" | "operation-boundary-blocked";
69
+ export type SiteEditFrameRuntimeDropTarget = {
70
+ anchorHit: SiteEditFrameRuntimeHit | null;
71
+ targetParentHit: SiteEditFrameRuntimeHit | null;
72
+ relation: SiteEditFrameRuntimeDropRelation;
73
+ indicatorOrientation?: "horizontal" | "vertical";
74
+ indicatorBounds?: {
75
+ top: number;
76
+ left: number;
77
+ width: number;
78
+ height: number;
79
+ };
80
+ rejectionReason?: SiteEditFrameRuntimeDropRejectionReason;
81
+ };
82
+ export type SiteEditFrameRuntimeRequestBody = {
83
+ type: "request";
84
+ id: string;
85
+ kind: "hit-test-at-point" | "start-text-edit-at-point";
86
+ payload: {
87
+ x: number;
88
+ y: number;
89
+ detailLevel?: SiteEditFrameRuntimeHitDetailLevel;
90
+ };
91
+ } | {
92
+ type: "request";
93
+ id: string;
94
+ kind: "get-scroll-metrics";
95
+ payload: Record<string, never>;
96
+ } | {
97
+ type: "request";
98
+ id: string;
99
+ kind: "scroll-to";
100
+ payload: {
101
+ x: number;
102
+ y: number;
103
+ };
104
+ } | {
105
+ type: "request";
106
+ id: string;
107
+ kind: "scroll-by";
108
+ payload: {
109
+ deltaX: number;
110
+ deltaY: number;
111
+ };
112
+ } | {
113
+ type: "request";
114
+ id: string;
115
+ kind: "set-interaction-mode";
116
+ payload: {
117
+ enabled: boolean;
118
+ };
119
+ } | {
120
+ type: "request";
121
+ id: string;
122
+ kind: "set-theme-override";
123
+ payload: SiteEditFrameRuntimeThemeOverride;
124
+ } | {
125
+ type: "request";
126
+ id: string;
127
+ kind: "clear-theme-override";
128
+ payload: Record<string, never>;
129
+ } | {
130
+ type: "request";
131
+ id: string;
132
+ kind: "get-theme-variables";
133
+ payload: {
134
+ names: string[];
135
+ };
136
+ } | {
137
+ type: "request";
138
+ id: string;
139
+ kind: "compute-drop-target-at-point";
140
+ payload: {
141
+ x: number;
142
+ y: number;
143
+ dragKind: "insert" | "move";
144
+ movingRef?: SiteEditFrameRuntimeRef;
145
+ };
146
+ } | {
147
+ type: "request";
148
+ id: string;
149
+ kind: "observe-node-bounds" | "clear-node-bounds-observer";
150
+ payload: {
151
+ ref?: SiteEditFrameRuntimeRef;
152
+ };
153
+ } | {
154
+ type: "request";
155
+ id: string;
156
+ kind: "apply-node-patch";
157
+ payload: {
158
+ ref: SiteEditFrameRuntimeRef;
159
+ patch: SiteEditFrameRuntimeNodePatch;
160
+ preview?: SiteEditFrameRuntimeNodePatchPreviewMeta;
161
+ };
162
+ } | {
163
+ type: "request";
164
+ id: string;
165
+ kind: "get-hit-by-ref" | "get-path-by-ref";
166
+ payload: {
167
+ ref: SiteEditFrameRuntimeRef;
168
+ };
169
+ } | {
170
+ type: "request";
171
+ id: string;
172
+ kind: "bridge-get-document" | "bridge-ensure-document-version";
173
+ payload: {
174
+ routeId: string;
175
+ minVersion?: number;
176
+ };
177
+ } | {
178
+ type: "request";
179
+ id: string;
180
+ kind: "bridge-get-object-summary" | "bridge-get-object-edit-context" | "bridge-get-class-name-source";
181
+ payload: {
182
+ key: string;
183
+ routeId?: string;
184
+ };
185
+ } | {
186
+ type: "request";
187
+ id: string;
188
+ kind: "bridge-execute";
189
+ payload: {
190
+ request: SiteEditOperationRequest;
191
+ };
192
+ } | {
193
+ type: "request";
194
+ id: string;
195
+ kind: "bridge-undo" | "bridge-redo";
196
+ payload: Record<string, never>;
197
+ } | {
198
+ type: "request";
199
+ id: string;
200
+ kind: "bridge-subscribe" | "bridge-unsubscribe";
201
+ payload: {
202
+ subscriptionId: string;
203
+ };
204
+ };
205
+ export type SiteEditFrameRuntimeSpacing = {
206
+ marginTop: number;
207
+ marginRight: number;
208
+ marginBottom: number;
209
+ marginLeft: number;
210
+ paddingTop: number;
211
+ paddingRight: number;
212
+ paddingBottom: number;
213
+ paddingLeft: number;
214
+ borderTopWidth: number;
215
+ borderRightWidth: number;
216
+ borderBottomWidth: number;
217
+ borderLeftWidth: number;
218
+ columnGap: number;
219
+ rowGap: number;
220
+ };
221
+ export type SiteEditFrameRuntimeRect = {
222
+ top: number;
223
+ left: number;
224
+ width: number;
225
+ height: number;
226
+ };
227
+ export type SiteEditFrameRuntimeHit = {
228
+ ref: SiteEditFrameRuntimeRef;
229
+ key: string;
230
+ detailLevel: SiteEditFrameRuntimeHitDetailLevel;
231
+ tagName: string;
232
+ sourceKind?: string;
233
+ componentName?: string;
234
+ sourceFile?: string;
235
+ parentKey?: string;
236
+ textPreview?: string;
237
+ dataset?: Record<string, string>;
238
+ attributes?: Record<string, string>;
239
+ runtimeFlags: {
240
+ selectable: boolean;
241
+ movable: boolean;
242
+ removable: boolean;
243
+ textEditable: boolean;
244
+ container: boolean;
245
+ };
246
+ layout?: {
247
+ display: string;
248
+ flexDirection?: string;
249
+ gridAutoFlow?: string;
250
+ indicatorOrientation: "horizontal" | "vertical";
251
+ };
252
+ rect: SiteEditFrameRuntimeRect;
253
+ childRects?: SiteEditFrameRuntimeRect[];
254
+ spacing?: SiteEditFrameRuntimeSpacing;
255
+ };
256
+ export type SiteEditFrameRuntimeResponseBody = {
257
+ type: "response";
258
+ id: string;
259
+ ok: boolean;
260
+ result?: SiteEditFrameRuntimeStarted | SiteEditFrameRuntimeHit | SiteEditFrameRuntimeNodePatchAck | SiteEditFrameRuntimeHit[] | SiteEditFrameRuntimeDropTarget | SiteEditFrameRuntimeScrollMetrics | SiteEditCommandSuccess<SiteEditRenderDocument> | SiteEditCommandSuccess<SiteEditObjectSummary> | SiteEditCommandSuccess<SiteEditObjectEditContext> | SiteEditGetClassNameSourceCommandResult | SiteEditOperationCommandResult | (SiteEditFrameRuntimeScrollMetrics & {
261
+ scrolled: true;
262
+ }) | {
263
+ interactionEnabled: boolean;
264
+ } | {
265
+ themeOverrideApplied: true;
266
+ } | {
267
+ themeOverrideCleared: true;
268
+ } | Record<string, string> | {
269
+ subscribed: true;
270
+ } | {
271
+ unsubscribed: true;
272
+ } | {
273
+ observing: true;
274
+ } | {
275
+ cleared: true;
276
+ };
277
+ error?: string;
278
+ };
279
+ export type SiteEditFrameRuntimeEventBody = {
280
+ type: "event";
281
+ kind: "text-edit-commit" | "text-edit-cancel" | "text-edit-exit" | "text-edit-input";
282
+ payload: {
283
+ ref: SiteEditFrameRuntimeRef;
284
+ value?: string;
285
+ hit?: SiteEditFrameRuntimeHit;
286
+ };
287
+ } | {
288
+ type: "event";
289
+ kind: "node-bounds-change";
290
+ payload: {
291
+ hit: SiteEditFrameRuntimeHit;
292
+ };
293
+ } | {
294
+ type: "event";
295
+ kind: "bridge-event";
296
+ payload: {
297
+ subscriptionId: string;
298
+ event: SiteEditEvent;
299
+ };
300
+ } | {
301
+ type: "event";
302
+ kind: SiteEditFrameRuntimePointerEventKind;
303
+ payload: {
304
+ clientX: number;
305
+ clientY: number;
306
+ buttons?: number;
307
+ hit: SiteEditFrameRuntimeHit | null;
308
+ };
309
+ } | {
310
+ type: "event";
311
+ kind: "route-ready";
312
+ payload: {
313
+ routeId: string;
314
+ version?: number;
315
+ };
316
+ } | {
317
+ type: "event";
318
+ kind: "scroll";
319
+ payload: {
320
+ metrics: SiteEditFrameRuntimeScrollMetrics;
321
+ };
322
+ };
323
+ export type SiteEditFrameRuntimeBody = SiteEditFrameRuntimeRequestBody | SiteEditFrameRuntimeResponseBody | SiteEditFrameRuntimeEventBody;
324
+ export type SiteEditFrameRuntimeMessage = VcpWindowMessageEnvelope<typeof SITE_EDIT_WINDOW_MESSAGE_NAMESPACE, typeof SITE_EDIT_FRAME_RUNTIME_CHANNEL, SiteEditFrameRuntimeBody>;
325
+ export type SiteEditFrameRuntimeRequestMessage = SiteEditFrameRuntimeMessage & {
326
+ body: SiteEditFrameRuntimeRequestBody;
327
+ };
328
+ export type SiteEditFrameRuntimeResponseMessage = SiteEditFrameRuntimeMessage & {
329
+ body: SiteEditFrameRuntimeResponseBody;
330
+ };
331
+ export type SiteEditFrameRuntimeEventMessage = SiteEditFrameRuntimeMessage & {
332
+ body: SiteEditFrameRuntimeEventBody;
333
+ };
334
+ export declare function createSiteEditFrameRuntimeMessage(body: SiteEditFrameRuntimeBody, options?: {
335
+ sessionKey?: string;
336
+ }): SiteEditFrameRuntimeMessage;
337
+ export declare function isSiteEditFrameRuntimeMessage(value: unknown): value is SiteEditFrameRuntimeMessage;
@@ -0,0 +1 @@
1
+ var s="vcp-window-message",i=1;function r(e){return{source:s,version:1,namespace:e.namespace,channel:e.channel,...e.sessionKey?{sessionKey:e.sessionKey}:{},body:e.body}}function c(e){if(typeof e!="object"||e===null)return!1;let n=e;return n.source===s&&n.version===1&&typeof n.namespace=="string"&&typeof n.channel=="string"&&"body"in n}var o="site-edit",t="frame-runtime";function E(e,n={}){return r({namespace:o,channel:t,sessionKey:n.sessionKey,body:e})}function a(e){return!c(e)||e.namespace!==o||e.channel!==t?!1:typeof e.body?.type=="string"}export{t as SITE_EDIT_FRAME_RUNTIME_CHANNEL,o as SITE_EDIT_WINDOW_MESSAGE_NAMESPACE,s as VCP_WINDOW_MESSAGE_SOURCE,i as VCP_WINDOW_MESSAGE_VERSION,E as createSiteEditFrameRuntimeMessage,r as createVcpWindowMessageEnvelope,a as isSiteEditFrameRuntimeMessage,c as isVcpWindowMessageEnvelope};
package/package.json ADDED
@@ -0,0 +1,87 @@
1
+ {
2
+ "name": "@vcp-dev/site-edit-bridge",
3
+ "version": "0.3.14",
4
+ "type": "module",
5
+ "license": "UNLICENSED",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://gitlab.cedemo.cn/vibe-coding-platform/vcp.git"
9
+ },
10
+ "homepage": "https://gitlab.cedemo.cn/vibe-coding-platform/vcp",
11
+ "bugs": {
12
+ "url": "https://gitlab.cedemo.cn/vibe-coding-platform/vcp/-/issues"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "main": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "bin": {
20
+ "vcp-site-edit-next-dev-server": "dist/start-next-dev-server.js"
21
+ },
22
+ "exports": {
23
+ ".": {
24
+ "development": "./src/index.ts",
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.js"
27
+ },
28
+ "./client": {
29
+ "development": "./src/client.ts",
30
+ "types": "./dist/client.d.ts",
31
+ "default": "./dist/client.js"
32
+ },
33
+ "./auto-bootstrap": {
34
+ "development": "./src/auto-bootstrap.ts",
35
+ "types": "./dist/auto-bootstrap.d.ts",
36
+ "default": "./dist/auto-bootstrap.js"
37
+ },
38
+ "./document-codec": {
39
+ "development": "./src/document-codec.ts",
40
+ "types": "./dist/document-codec.d.ts",
41
+ "default": "./dist/document-codec.js"
42
+ },
43
+ "./designer-trace": {
44
+ "development": "./src/designer-trace.ts",
45
+ "types": "./dist/designer-trace.d.ts",
46
+ "default": "./dist/designer-trace.js"
47
+ },
48
+ "./window-message": {
49
+ "development": "./src/window-message.ts",
50
+ "types": "./dist/window-message.d.ts",
51
+ "default": "./dist/window-message.js"
52
+ },
53
+ "./server": {
54
+ "development": "./src/server.ts",
55
+ "types": "./dist/server.d.ts",
56
+ "default": "./dist/server.js"
57
+ },
58
+ "./next-dev-server": {
59
+ "development": "./src/next-dev-server.ts",
60
+ "types": "./dist/next-dev-server.d.ts",
61
+ "default": "./dist/next-dev-server.js"
62
+ }
63
+ },
64
+ "files": [
65
+ "dist",
66
+ "README.md"
67
+ ],
68
+ "engines": {
69
+ "node": ">=24.0.0"
70
+ },
71
+ "scripts": {
72
+ "build": "pnpm --dir ../contracts build && pnpm --dir ../site-edit-engine build && node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.build.json",
73
+ "test": "vitest run --root ../.. packages/site-edit-bridge/src",
74
+ "typecheck": "tsc -p tsconfig.json --noEmit"
75
+ },
76
+ "dependencies": {
77
+ "@vcp-dev/contracts": "0.3.14",
78
+ "@vcp-dev/site-edit-engine": "0.3.14",
79
+ "@types/ws": "^8.18.1",
80
+ "ws": "^8.20.1"
81
+ },
82
+ "devDependencies": {
83
+ "@types/node": "^24.0.0",
84
+ "typescript": "^5.8.0",
85
+ "vitest": "^3.2.0"
86
+ }
87
+ }