@trojanbox-vcp-test/site-edit-engine 0.1.0 → 0.2.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/index.d.ts +3 -0
- package/dist/index.js +127 -2
- package/dist/internal/protocol/operation.d.ts +2 -0
- package/dist/internal/protocol/render.d.ts +3 -30
- package/dist/internal/protocol.d.ts +1 -1
- package/dist/next-app-router.js +1 -140
- package/dist/preview-runtime.d.ts +249 -303
- package/dist/runtime-sync.d.ts +8 -8
- package/dist/runtime.d.ts +1 -127
- package/dist/site-edit-instrumentation.d.ts +1 -1
- package/dist/source-watcher.js +1 -150
- package/dist/types.d.ts +12 -14
- package/dist/webpack-loader.cjs +50 -588
- package/package.json +2 -2
- package/dist/execute-integration/execute-fixture-harness.d.ts +0 -25
- package/dist/execute-integration/execute-fixture-harness.js +0 -37
- package/dist/internal/ast/diagnostics/index.d.ts +0 -5
- package/dist/internal/ast/diagnostics/index.js +0 -25
- package/dist/internal/ast/history/index.d.ts +0 -15
- package/dist/internal/ast/history/index.js +0 -62
- package/dist/internal/ast/index.d.ts +0 -8
- package/dist/internal/ast/index.js +0 -5
- package/dist/internal/ast/locators/index.d.ts +0 -1
- package/dist/internal/ast/locators/index.js +0 -1
- package/dist/internal/ast/locators/resolve-locator.d.ts +0 -16
- package/dist/internal/ast/locators/resolve-locator.js +0 -920
- package/dist/internal/ast/parser/SourceParser.d.ts +0 -30
- package/dist/internal/ast/parser/SourceParser.js +0 -49
- package/dist/internal/ast/parser/index.d.ts +0 -21
- package/dist/internal/ast/parser/index.js +0 -64
- package/dist/internal/ast/primitives/conditional/conditional-primitives.d.ts +0 -18
- package/dist/internal/ast/primitives/conditional/conditional-primitives.js +0 -237
- package/dist/internal/ast/primitives/conditional/index.d.ts +0 -1
- package/dist/internal/ast/primitives/conditional/index.js +0 -1
- package/dist/internal/ast/primitives/imports/add-import.d.ts +0 -18
- package/dist/internal/ast/primitives/imports/add-import.js +0 -111
- package/dist/internal/ast/primitives/imports/index.d.ts +0 -2
- package/dist/internal/ast/primitives/imports/index.js +0 -2
- package/dist/internal/ast/primitives/imports/remove-import.d.ts +0 -15
- package/dist/internal/ast/primitives/imports/remove-import.js +0 -72
- package/dist/internal/ast/primitives/index.d.ts +0 -10
- package/dist/internal/ast/primitives/index.js +0 -10
- package/dist/internal/ast/primitives/jsx/index.d.ts +0 -4
- package/dist/internal/ast/primitives/jsx/index.js +0 -4
- package/dist/internal/ast/primitives/jsx/insert-child.d.ts +0 -11
- package/dist/internal/ast/primitives/jsx/insert-child.js +0 -69
- package/dist/internal/ast/primitives/jsx/move-node.d.ts +0 -9
- package/dist/internal/ast/primitives/jsx/move-node.js +0 -76
- package/dist/internal/ast/primitives/jsx/remove-node.d.ts +0 -7
- package/dist/internal/ast/primitives/jsx/remove-node.js +0 -36
- package/dist/internal/ast/primitives/jsx/update-text.d.ts +0 -8
- package/dist/internal/ast/primitives/jsx/update-text.js +0 -81
- package/dist/internal/ast/primitives/next/index.d.ts +0 -1
- package/dist/internal/ast/primitives/next/index.js +0 -1
- package/dist/internal/ast/primitives/next/next-primitives.d.ts +0 -43
- package/dist/internal/ast/primitives/next/next-primitives.js +0 -211
- package/dist/internal/ast/primitives/shared.d.ts +0 -60
- package/dist/internal/ast/primitives/shared.js +0 -176
- package/dist/internal/ast/primitives/style/class-expression.d.ts +0 -23
- package/dist/internal/ast/primitives/style/class-expression.js +0 -174
- package/dist/internal/ast/primitives/style/index.d.ts +0 -1
- package/dist/internal/ast/primitives/style/index.js +0 -1
- package/dist/internal/ast/primitives/style/style-primitives.d.ts +0 -49
- package/dist/internal/ast/primitives/style/style-primitives.js +0 -555
- package/dist/internal/ast/primitives/values/index.d.ts +0 -1
- package/dist/internal/ast/primitives/values/index.js +0 -1
- package/dist/internal/ast/primitives/values/value-primitives.d.ts +0 -42
- package/dist/internal/ast/primitives/values/value-primitives.js +0 -158
- package/dist/internal/ast/printer/SourcePrinter.d.ts +0 -21
- package/dist/internal/ast/printer/SourcePrinter.js +0 -76
- package/dist/internal/ast/printer/index.d.ts +0 -6
- package/dist/internal/ast/printer/index.js +0 -126
- package/dist/internal/ast/types.d.ts +0 -190
- package/dist/internal/ast/types.js +0 -1
- package/dist/internal/capability/capability-resolver.d.ts +0 -16
- package/dist/internal/capability/capability-resolver.js +0 -127
- package/dist/internal/classname-source.d.ts +0 -24
- package/dist/internal/classname-source.js +0 -220
- package/dist/internal/contracts/IEditEngineRuntime.d.ts +0 -18
- package/dist/internal/contracts/IEditEngineRuntime.js +0 -1
- package/dist/internal/domain/EditDiagnostic.d.ts +0 -38
- package/dist/internal/domain/EditDiagnostic.js +0 -43
- package/dist/internal/events/event-bus.d.ts +0 -14
- package/dist/internal/events/event-bus.js +0 -21
- package/dist/internal/graph/graph-builder.d.ts +0 -12
- package/dist/internal/graph/graph-builder.js +0 -1371
- package/dist/internal/graph/import-resolver.d.ts +0 -31
- package/dist/internal/graph/import-resolver.js +0 -109
- package/dist/internal/graph/project-graph-builder.d.ts +0 -32
- package/dist/internal/graph/project-graph-builder.js +0 -133
- package/dist/internal/graph/types.d.ts +0 -114
- package/dist/internal/graph/types.js +0 -6
- package/dist/internal/history/undo-redo.d.ts +0 -28
- package/dist/internal/history/undo-redo.js +0 -42
- package/dist/internal/index.d.ts +0 -2
- package/dist/internal/index.js +0 -1
- package/dist/internal/planner/planner.d.ts +0 -104
- package/dist/internal/planner/planner.js +0 -2533
- package/dist/internal/planner/types.d.ts +0 -275
- package/dist/internal/planner/types.js +0 -6
- package/dist/internal/protocol/boundary.js +0 -3
- package/dist/internal/protocol/capability.js +0 -8
- package/dist/internal/protocol/error.js +0 -38
- package/dist/internal/protocol/event.js +0 -3
- package/dist/internal/protocol/identity.js +0 -30
- package/dist/internal/protocol/operation.js +0 -8
- package/dist/internal/protocol/render.js +0 -3
- package/dist/internal/protocol.js +0 -2
- package/dist/internal/provenance/binding-graph.d.ts +0 -39
- package/dist/internal/provenance/binding-graph.js +0 -184
- package/dist/internal/provenance/capability-policy.d.ts +0 -15
- package/dist/internal/provenance/capability-policy.js +0 -96
- package/dist/internal/provenance/data-source-classifier.d.ts +0 -14
- package/dist/internal/provenance/data-source-classifier.js +0 -281
- package/dist/internal/provenance/resolve-text-provenance.d.ts +0 -45
- package/dist/internal/provenance/resolve-text-provenance.js +0 -3090
- package/dist/internal/provenance/types.d.ts +0 -89
- package/dist/internal/provenance/types.js +0 -1
- package/dist/internal/render/component-semantic.d.ts +0 -11
- package/dist/internal/render/component-semantic.js +0 -141
- package/dist/internal/render/content-model.d.ts +0 -3
- package/dist/internal/render/content-model.js +0 -89
- package/dist/internal/render/media-model.d.ts +0 -3
- package/dist/internal/render/media-model.js +0 -45
- package/dist/internal/render/provenance-types.d.ts +0 -33
- package/dist/internal/render/provenance-types.js +0 -1
- package/dist/internal/render/render-projection.d.ts +0 -24
- package/dist/internal/render/render-projection.js +0 -281
- package/dist/internal/render/tailwind-style-model.d.ts +0 -19
- package/dist/internal/render/tailwind-style-model.js +0 -1187
- package/dist/internal/runtime/EditEngineRuntime.d.ts +0 -25
- package/dist/internal/runtime/EditEngineRuntime.js +0 -89
- package/dist/internal/runtime/EditEngineRuntimeSnapshot.d.ts +0 -31
- package/dist/internal/runtime/EditEngineRuntimeSnapshot.js +0 -15
- package/dist/internal/runtime/InternalEditEngine.d.ts +0 -44
- package/dist/internal/runtime/InternalEditEngine.js +0 -1391
- package/dist/internal/runtime.d.ts +0 -3
- package/dist/internal/runtime.js +0 -1
- package/dist/internal/topology/topology.d.ts +0 -6
- package/dist/internal/topology/topology.js +0 -98
- package/dist/internal/topology/types.d.ts +0 -35
- package/dist/internal/topology/types.js +0 -5
- package/dist/internal/types.d.ts +0 -1
- package/dist/internal/types.js +0 -1
- package/dist/internal/writeback/in-memory-fs.d.ts +0 -7
- package/dist/internal/writeback/in-memory-fs.js +0 -44
- package/dist/internal/writeback/types.d.ts +0 -45
- package/dist/internal/writeback/types.js +0 -7
- package/dist/internal/writeback/writeback-service.d.ts +0 -7
- package/dist/internal/writeback/writeback-service.js +0 -568
- package/dist/internal-adapter.d.ts +0 -18
- package/dist/internal-adapter.js +0 -350
- package/dist/next-app-router-fs.js +0 -64
- package/dist/preview-runtime.js +0 -102
- package/dist/public-file-system.js +0 -1
- package/dist/runtime-sync.js +0 -321
- package/dist/runtime.js +0 -134
- package/dist/site-edit-instrumentation.js +0 -322
- package/dist/snapshot-file-system.d.ts +0 -19
- package/dist/snapshot-file-system.js +0 -49
- package/dist/source-writeback-test-harness.d.ts +0 -244
- package/dist/source-writeback-test-harness.js +0 -119
- package/dist/types.js +0 -1
package/dist/internal-adapter.js
DELETED
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
const STRUCTURAL_KEY_MAP = new Map([
|
|
2
|
-
["routeId", "routeId"],
|
|
3
|
-
["documentVersion", "documentVersion"],
|
|
4
|
-
["segmentIndex", "segmentIndex"],
|
|
5
|
-
["preserveBindings", "preserveBindings"],
|
|
6
|
-
["exportName", "exportName"],
|
|
7
|
-
["anchorKey", "anchorKey"],
|
|
8
|
-
["parentKey", "parentKey"],
|
|
9
|
-
["slotName", "slotName"],
|
|
10
|
-
["toIndex", "toIndex"],
|
|
11
|
-
["fromIndex", "fromIndex"],
|
|
12
|
-
["nextExpression", "nextExpression"],
|
|
13
|
-
["nextToken", "nextToken"],
|
|
14
|
-
]);
|
|
15
|
-
const OPAQUE_VALUE_KEYS = new Set(["value", "block", "properties", "props"]);
|
|
16
|
-
export function toInternalOperationRequest(request) {
|
|
17
|
-
return {
|
|
18
|
-
id: request.id,
|
|
19
|
-
routeId: request.routeId,
|
|
20
|
-
kind: request.kind,
|
|
21
|
-
target: toInternalTarget(request.target),
|
|
22
|
-
documentVersion: request.documentVersion,
|
|
23
|
-
params: renameStructuralKeys(request.params),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export function toSiteEditOperationResult(result) {
|
|
27
|
-
return {
|
|
28
|
-
requestId: result.requestId,
|
|
29
|
-
kind: result.kind,
|
|
30
|
-
target: toSiteEditTarget(result.target),
|
|
31
|
-
ok: result.ok,
|
|
32
|
-
resultVersion: result.resultVersion,
|
|
33
|
-
error: result.error,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export function toSiteEditRenderDocument(document, context) {
|
|
37
|
-
return {
|
|
38
|
-
siteId: context.siteId,
|
|
39
|
-
snapshotId: context.snapshotId,
|
|
40
|
-
routeId: document.routeId,
|
|
41
|
-
version: document.version,
|
|
42
|
-
rootKeys: document.rootKeys,
|
|
43
|
-
entries: document.entries.map((entry) => ({
|
|
44
|
-
key: entry.key,
|
|
45
|
-
tag: entry.tag,
|
|
46
|
-
label: entry.label,
|
|
47
|
-
parentKey: entry.parentKey,
|
|
48
|
-
childKeys: entry.childKeys,
|
|
49
|
-
operationSummary: {
|
|
50
|
-
canUpdateText: entry.operationSummary.canUpdateText,
|
|
51
|
-
canInsertChild: entry.operationSummary.canInsertChild,
|
|
52
|
-
canMove: entry.operationSummary.canMove,
|
|
53
|
-
canRemove: entry.operationSummary.canRemove,
|
|
54
|
-
},
|
|
55
|
-
})),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
export function toSiteEditObjectSummary(detail) {
|
|
59
|
-
return {
|
|
60
|
-
key: detail.key,
|
|
61
|
-
tag: detail.tag,
|
|
62
|
-
label: detail.label,
|
|
63
|
-
capabilities: {
|
|
64
|
-
constraints: detail.capabilities.constraints,
|
|
65
|
-
},
|
|
66
|
-
isOpaque: detail.isOpaque,
|
|
67
|
-
provenanceChain: detail.provenanceChain
|
|
68
|
-
? {
|
|
69
|
-
editMode: detail.provenanceChain.editMode,
|
|
70
|
-
diagnostics: detail.provenanceChain.diagnostics,
|
|
71
|
-
}
|
|
72
|
-
: undefined,
|
|
73
|
-
ancestors: detail.ancestors,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
export function toSiteEditObjectEditContext(detail) {
|
|
77
|
-
return {
|
|
78
|
-
key: detail.key,
|
|
79
|
-
componentName: detail.componentName,
|
|
80
|
-
sourceFile: detail.sourceFile,
|
|
81
|
-
capabilities: toSiteEditCapability(detail.capabilities),
|
|
82
|
-
writeTarget: {
|
|
83
|
-
kind: detail.writeTarget.kind,
|
|
84
|
-
file: detail.writeTarget.file,
|
|
85
|
-
componentName: detail.writeTarget.componentName,
|
|
86
|
-
isProxy: detail.writeTarget.isProxy,
|
|
87
|
-
},
|
|
88
|
-
effectiveWriteTarget: detail.effectiveWriteTarget
|
|
89
|
-
? {
|
|
90
|
-
kind: detail.effectiveWriteTarget.kind,
|
|
91
|
-
file: detail.effectiveWriteTarget.file,
|
|
92
|
-
isProxy: detail.effectiveWriteTarget.isProxy,
|
|
93
|
-
displayPath: detail.effectiveWriteTarget.displayPath,
|
|
94
|
-
sourceType: detail.effectiveWriteTarget.sourceType,
|
|
95
|
-
sourceId: detail.effectiveWriteTarget.sourceId,
|
|
96
|
-
}
|
|
97
|
-
: undefined,
|
|
98
|
-
provenanceChain: toSiteEditProvenanceChain(detail),
|
|
99
|
-
componentSemantic: asRecord(detail.componentSemantic),
|
|
100
|
-
textSegments: detail.textSegments.map((segment) => ({
|
|
101
|
-
index: segment.index,
|
|
102
|
-
value: segment.value,
|
|
103
|
-
editable: segment.editable,
|
|
104
|
-
source: segment.source
|
|
105
|
-
? {
|
|
106
|
-
kind: segment.source.kind,
|
|
107
|
-
file: segment.source.file,
|
|
108
|
-
expression: segment.source.expression,
|
|
109
|
-
bindingName: segment.source.bindingName,
|
|
110
|
-
path: segment.source.path,
|
|
111
|
-
}
|
|
112
|
-
: null,
|
|
113
|
-
})),
|
|
114
|
-
boundaryKind: detail.boundaryKind,
|
|
115
|
-
children: detail.children,
|
|
116
|
-
siblings: detail.siblings,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
export function toSiteEditObjectStyleDetail(detail) {
|
|
120
|
-
return {
|
|
121
|
-
key: detail.key,
|
|
122
|
-
styleSource: detail.styleSource,
|
|
123
|
-
styleModel: detail.styleModel
|
|
124
|
-
? {
|
|
125
|
-
kind: detail.styleModel.kind,
|
|
126
|
-
properties: detail.styleModel.properties.map((property) => ({
|
|
127
|
-
property: property.property,
|
|
128
|
-
value: property.value,
|
|
129
|
-
resolvedValue: property.resolvedValue,
|
|
130
|
-
...(property.breakpoint ? { breakpoint: property.breakpoint } : {}),
|
|
131
|
-
...(property.state ? { state: property.state } : {}),
|
|
132
|
-
...(property.variants?.length
|
|
133
|
-
? { variants: property.variants }
|
|
134
|
-
: {}),
|
|
135
|
-
...(property.options?.length ? { options: property.options } : {}),
|
|
136
|
-
editable: property.editable,
|
|
137
|
-
...(property.diagnostics?.length
|
|
138
|
-
? { diagnostics: property.diagnostics }
|
|
139
|
-
: {}),
|
|
140
|
-
operationBoundary: property.operationBoundary,
|
|
141
|
-
})),
|
|
142
|
-
}
|
|
143
|
-
: undefined,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
export function toSiteEditObjectContentDetail(detail) {
|
|
147
|
-
return {
|
|
148
|
-
key: detail.key,
|
|
149
|
-
contentModel: asRecord(detail.contentModel),
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
export function toSiteEditObjectMediaDetail(detail) {
|
|
153
|
-
return {
|
|
154
|
-
key: detail.key,
|
|
155
|
-
mediaModel: asRecord(detail.mediaModel),
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
export function toSiteEditObjectDetail(detail) {
|
|
159
|
-
const styleDetail = toSiteEditObjectStyleDetail(detail);
|
|
160
|
-
return {
|
|
161
|
-
key: detail.key,
|
|
162
|
-
tag: detail.tag,
|
|
163
|
-
componentName: detail.componentName,
|
|
164
|
-
sourceFile: detail.sourceFile,
|
|
165
|
-
label: detail.label,
|
|
166
|
-
capabilities: toSiteEditCapability(detail.capabilities),
|
|
167
|
-
writeTarget: {
|
|
168
|
-
kind: detail.writeTarget.kind,
|
|
169
|
-
file: detail.writeTarget.file,
|
|
170
|
-
componentName: detail.writeTarget.componentName,
|
|
171
|
-
isProxy: detail.writeTarget.isProxy,
|
|
172
|
-
},
|
|
173
|
-
effectiveWriteTarget: detail.effectiveWriteTarget
|
|
174
|
-
? {
|
|
175
|
-
kind: detail.effectiveWriteTarget.kind,
|
|
176
|
-
file: detail.effectiveWriteTarget.file,
|
|
177
|
-
isProxy: detail.effectiveWriteTarget.isProxy,
|
|
178
|
-
displayPath: detail.effectiveWriteTarget.displayPath,
|
|
179
|
-
sourceType: detail.effectiveWriteTarget.sourceType,
|
|
180
|
-
sourceId: detail.effectiveWriteTarget.sourceId,
|
|
181
|
-
}
|
|
182
|
-
: undefined,
|
|
183
|
-
provenanceChain: toSiteEditProvenanceChain(detail),
|
|
184
|
-
componentSemantic: asRecord(detail.componentSemantic),
|
|
185
|
-
contentModel: asRecord(detail.contentModel),
|
|
186
|
-
mediaModel: asRecord(detail.mediaModel),
|
|
187
|
-
styleSource: styleDetail.styleSource,
|
|
188
|
-
styleModel: styleDetail.styleModel,
|
|
189
|
-
conditional: asRecord(detail.conditional),
|
|
190
|
-
textSegments: detail.textSegments.map((segment) => ({
|
|
191
|
-
index: segment.index,
|
|
192
|
-
value: segment.value,
|
|
193
|
-
editable: segment.editable,
|
|
194
|
-
source: segment.source
|
|
195
|
-
? {
|
|
196
|
-
kind: segment.source.kind,
|
|
197
|
-
file: segment.source.file,
|
|
198
|
-
expression: segment.source.expression,
|
|
199
|
-
bindingName: segment.source.bindingName,
|
|
200
|
-
path: segment.source.path,
|
|
201
|
-
}
|
|
202
|
-
: null,
|
|
203
|
-
})),
|
|
204
|
-
boundaryKind: detail.boundaryKind,
|
|
205
|
-
isOpaque: detail.isOpaque,
|
|
206
|
-
ancestors: detail.ancestors,
|
|
207
|
-
children: detail.children,
|
|
208
|
-
siblings: detail.siblings,
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
export function toSiteEditEvent(event, context) {
|
|
212
|
-
const at = new Date().toISOString();
|
|
213
|
-
if (event.type === "document-changed") {
|
|
214
|
-
return {
|
|
215
|
-
type: "site-edit.document.changed",
|
|
216
|
-
siteId: context.siteId,
|
|
217
|
-
snapshotId: context.snapshotId,
|
|
218
|
-
routeId: event.routeId,
|
|
219
|
-
version: event.version,
|
|
220
|
-
at,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
if (event.type === "operation-completed") {
|
|
224
|
-
return {
|
|
225
|
-
type: "site-edit.operation.completed",
|
|
226
|
-
siteId: context.siteId,
|
|
227
|
-
result: toSiteEditOperationResult(event.result),
|
|
228
|
-
at,
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
if (event.type === "operation-failed") {
|
|
232
|
-
return {
|
|
233
|
-
type: "site-edit.operation.failed",
|
|
234
|
-
siteId: context.siteId,
|
|
235
|
-
requestId: event.requestId,
|
|
236
|
-
error: event.error,
|
|
237
|
-
at,
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
if (event.type === "capability-changed") {
|
|
241
|
-
return {
|
|
242
|
-
type: "site-edit.capability.changed",
|
|
243
|
-
siteId: context.siteId,
|
|
244
|
-
routeId: "",
|
|
245
|
-
keys: event.keys,
|
|
246
|
-
at,
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
return null;
|
|
250
|
-
}
|
|
251
|
-
function toInternalTarget(target) {
|
|
252
|
-
if (target.kind === "route") {
|
|
253
|
-
return { kind: "route", routeId: target.routeId };
|
|
254
|
-
}
|
|
255
|
-
return target;
|
|
256
|
-
}
|
|
257
|
-
function toSiteEditTarget(target) {
|
|
258
|
-
if (target.kind === "route") {
|
|
259
|
-
return { kind: "route", routeId: target.routeId };
|
|
260
|
-
}
|
|
261
|
-
return target;
|
|
262
|
-
}
|
|
263
|
-
function toSiteEditCapability(capability) {
|
|
264
|
-
return {
|
|
265
|
-
key: capability.key,
|
|
266
|
-
canUpdateText: capability.canUpdateText,
|
|
267
|
-
canInsertChild: capability.canInsertChild,
|
|
268
|
-
canMove: capability.canMove,
|
|
269
|
-
canRemove: capability.canRemove,
|
|
270
|
-
editModes: capability.editModes
|
|
271
|
-
? {
|
|
272
|
-
updateText: capability.editModes.updateText
|
|
273
|
-
? {
|
|
274
|
-
mode: capability.editModes.updateText.mode,
|
|
275
|
-
reasonCode: capability.editModes.updateText.reasonCode,
|
|
276
|
-
}
|
|
277
|
-
: undefined,
|
|
278
|
-
insertChild: capability.editModes.insertChild
|
|
279
|
-
? {
|
|
280
|
-
mode: capability.editModes.insertChild.mode,
|
|
281
|
-
reasonCode: capability.editModes.insertChild.reasonCode,
|
|
282
|
-
}
|
|
283
|
-
: undefined,
|
|
284
|
-
move: capability.editModes.move
|
|
285
|
-
? {
|
|
286
|
-
mode: capability.editModes.move.mode,
|
|
287
|
-
reasonCode: capability.editModes.move.reasonCode,
|
|
288
|
-
}
|
|
289
|
-
: undefined,
|
|
290
|
-
remove: capability.editModes.remove
|
|
291
|
-
? {
|
|
292
|
-
mode: capability.editModes.remove.mode,
|
|
293
|
-
reasonCode: capability.editModes.remove.reasonCode,
|
|
294
|
-
}
|
|
295
|
-
: undefined,
|
|
296
|
-
}
|
|
297
|
-
: undefined,
|
|
298
|
-
constraints: capability.constraints,
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
function toSiteEditProvenanceChain(detail) {
|
|
302
|
-
return detail.provenanceChain
|
|
303
|
-
? {
|
|
304
|
-
finalSource: detail.provenanceChain.finalSource
|
|
305
|
-
? {
|
|
306
|
-
kind: detail.provenanceChain.finalSource.kind,
|
|
307
|
-
file: detail.provenanceChain.finalSource.file,
|
|
308
|
-
displayPath: detail.provenanceChain.finalSource.displayPath,
|
|
309
|
-
externalSource: detail.provenanceChain.finalSource.externalSource
|
|
310
|
-
? {
|
|
311
|
-
sourceType: detail.provenanceChain.finalSource.externalSource
|
|
312
|
-
.sourceType,
|
|
313
|
-
sourceId: detail.provenanceChain.finalSource.externalSource
|
|
314
|
-
.sourceId,
|
|
315
|
-
adapterId: detail.provenanceChain.finalSource.externalSource
|
|
316
|
-
.adapterId,
|
|
317
|
-
}
|
|
318
|
-
: undefined,
|
|
319
|
-
}
|
|
320
|
-
: null,
|
|
321
|
-
chain: detail.provenanceChain.chain.map((hop) => ({
|
|
322
|
-
kind: hop.kind,
|
|
323
|
-
file: hop.file,
|
|
324
|
-
displayName: hop.displayName,
|
|
325
|
-
canEditHere: hop.canEditHere,
|
|
326
|
-
})),
|
|
327
|
-
confidence: detail.provenanceChain.confidence,
|
|
328
|
-
editMode: detail.provenanceChain.editMode,
|
|
329
|
-
diagnostics: detail.provenanceChain.diagnostics,
|
|
330
|
-
}
|
|
331
|
-
: undefined;
|
|
332
|
-
}
|
|
333
|
-
function renameStructuralKeys(value) {
|
|
334
|
-
if (Array.isArray(value)) {
|
|
335
|
-
return value.map((item) => renameStructuralKeys(item));
|
|
336
|
-
}
|
|
337
|
-
if (!value || typeof value !== "object") {
|
|
338
|
-
return value;
|
|
339
|
-
}
|
|
340
|
-
return Object.fromEntries(Object.entries(value).map(([key, nestedValue]) => {
|
|
341
|
-
const nextKey = STRUCTURAL_KEY_MAP.get(key) ?? key;
|
|
342
|
-
const nextValue = OPAQUE_VALUE_KEYS.has(key)
|
|
343
|
-
? nestedValue
|
|
344
|
-
: renameStructuralKeys(nestedValue);
|
|
345
|
-
return [nextKey, nextValue];
|
|
346
|
-
}));
|
|
347
|
-
}
|
|
348
|
-
function asRecord(value) {
|
|
349
|
-
return value ? value : undefined;
|
|
350
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
const pageFilePattern = /^page\.(?:tsx|ts|jsx|js|mjs|cjs)$/;
|
|
4
|
-
export function scanNextAppRouterRoutes(projectRoot) {
|
|
5
|
-
const appRoot = resolveAppRoot(projectRoot);
|
|
6
|
-
if (!appRoot) {
|
|
7
|
-
return [];
|
|
8
|
-
}
|
|
9
|
-
return collectPageFiles(appRoot)
|
|
10
|
-
.map((file) => ({
|
|
11
|
-
routeId: toRouteId(appRoot, file),
|
|
12
|
-
entryFile: toPosixPath(path.relative(projectRoot, file)),
|
|
13
|
-
}))
|
|
14
|
-
.sort((left, right) => left.routeId.localeCompare(right.routeId));
|
|
15
|
-
}
|
|
16
|
-
function resolveAppRoot(projectRoot) {
|
|
17
|
-
for (const candidate of ["app", "src/app"]) {
|
|
18
|
-
const absolutePath = path.join(projectRoot, candidate);
|
|
19
|
-
if (fs.existsSync(absolutePath) &&
|
|
20
|
-
fs.statSync(absolutePath).isDirectory()) {
|
|
21
|
-
return absolutePath;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
function collectPageFiles(directory) {
|
|
27
|
-
const files = [];
|
|
28
|
-
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
29
|
-
const absolutePath = path.join(directory, entry.name);
|
|
30
|
-
if (entry.isDirectory()) {
|
|
31
|
-
if (entry.name === "node_modules" ||
|
|
32
|
-
entry.name.startsWith(".") ||
|
|
33
|
-
entry.name.startsWith("_") ||
|
|
34
|
-
entry.name.startsWith("@")) {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
files.push(...collectPageFiles(absolutePath));
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
if (entry.isFile() && pageFilePattern.test(entry.name)) {
|
|
41
|
-
files.push(absolutePath);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return files;
|
|
45
|
-
}
|
|
46
|
-
function toRouteId(appRoot, pageFile) {
|
|
47
|
-
const relativeDirectory = toPosixPath(path.relative(appRoot, path.dirname(pageFile)));
|
|
48
|
-
const segments = relativeDirectory
|
|
49
|
-
? relativeDirectory.split("/").filter((segment) => isRouteSegment(segment))
|
|
50
|
-
: [];
|
|
51
|
-
return segments.length === 0 ? "/" : `/${segments.join("/")}`;
|
|
52
|
-
}
|
|
53
|
-
function isRouteSegment(segment) {
|
|
54
|
-
return (Boolean(segment) &&
|
|
55
|
-
!segment.startsWith("@") &&
|
|
56
|
-
!segment.startsWith("_") &&
|
|
57
|
-
!isRouteGroup(segment));
|
|
58
|
-
}
|
|
59
|
-
function isRouteGroup(segment) {
|
|
60
|
-
return segment.startsWith("(") && segment.endsWith(")");
|
|
61
|
-
}
|
|
62
|
-
function toPosixPath(value) {
|
|
63
|
-
return value.replace(/\\/g, "/");
|
|
64
|
-
}
|
package/dist/preview-runtime.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { toInternalOperationRequest, toSiteEditEvent, toSiteEditObjectContentDetail, toSiteEditObjectDetail, toSiteEditObjectEditContext, toSiteEditObjectMediaDetail, toSiteEditObjectStyleDetail, toSiteEditObjectSummary, toSiteEditOperationResult, toSiteEditRenderDocument, } from "./internal-adapter.js";
|
|
2
|
-
import { createEditEngineRuntime } from "./internal/runtime.js";
|
|
3
|
-
export class PreviewFileSystemSiteEditEngineRuntime {
|
|
4
|
-
constructor(options) {
|
|
5
|
-
this.options = options;
|
|
6
|
-
this.listeners = new Set();
|
|
7
|
-
this.engine = createEditEngineRuntime({
|
|
8
|
-
projectRoot: options.projectRoot,
|
|
9
|
-
fileSystem: options.fileSystem,
|
|
10
|
-
routes: options.routes.map((route) => ({
|
|
11
|
-
routeId: route.routeId,
|
|
12
|
-
entryFile: route.entryFile,
|
|
13
|
-
})),
|
|
14
|
-
onEvent: (event) => {
|
|
15
|
-
const siteEditEvent = toSiteEditEvent(event, {
|
|
16
|
-
siteId: options.siteId,
|
|
17
|
-
snapshotId: options.snapshotId,
|
|
18
|
-
});
|
|
19
|
-
if (siteEditEvent) {
|
|
20
|
-
options.onEvent?.(siteEditEvent);
|
|
21
|
-
for (const listener of this.listeners) {
|
|
22
|
-
listener(siteEditEvent);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
dev: options.dev,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
get status() {
|
|
30
|
-
return this.engine.status;
|
|
31
|
-
}
|
|
32
|
-
registerRoute(routeId, entryFile) {
|
|
33
|
-
this.engine.registerRoute(routeId, entryFile);
|
|
34
|
-
}
|
|
35
|
-
async setActiveRoute(routeId) {
|
|
36
|
-
await this.engine.setActiveRoute(routeId);
|
|
37
|
-
}
|
|
38
|
-
getDocument(routeId) {
|
|
39
|
-
return toSiteEditRenderDocument(this.engine.getDocument(routeId), {
|
|
40
|
-
siteId: this.options.siteId,
|
|
41
|
-
snapshotId: this.options.snapshotId,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
getObjectCapabilities(key, routeId) {
|
|
45
|
-
const detail = toSiteEditObjectDetail(this.engine.getRenderDetail(key, routeId));
|
|
46
|
-
return {
|
|
47
|
-
key: detail.key,
|
|
48
|
-
canUpdateText: detail.capabilities.canUpdateText,
|
|
49
|
-
canInsertChild: detail.capabilities.canInsertChild,
|
|
50
|
-
canMove: detail.capabilities.canMove,
|
|
51
|
-
canRemove: detail.capabilities.canRemove,
|
|
52
|
-
boundaryKind: detail.boundaryKind,
|
|
53
|
-
isOpaque: detail.isOpaque,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
getObjectSummary(key, routeId) {
|
|
57
|
-
return toSiteEditObjectSummary(this.engine.getRenderDetail(key, routeId));
|
|
58
|
-
}
|
|
59
|
-
getObjectEditContext(key, routeId) {
|
|
60
|
-
return toSiteEditObjectEditContext(this.engine.getRenderDetail(key, routeId));
|
|
61
|
-
}
|
|
62
|
-
getObjectStyleDetail(key, routeId) {
|
|
63
|
-
return toSiteEditObjectStyleDetail(this.engine.getRenderDetail(key, routeId));
|
|
64
|
-
}
|
|
65
|
-
getObjectContentDetail(key, routeId) {
|
|
66
|
-
return toSiteEditObjectContentDetail(this.engine.getRenderDetail(key, routeId));
|
|
67
|
-
}
|
|
68
|
-
getObjectMediaDetail(key, routeId) {
|
|
69
|
-
return toSiteEditObjectMediaDetail(this.engine.getRenderDetail(key, routeId));
|
|
70
|
-
}
|
|
71
|
-
getClassNameSource(key, routeId) {
|
|
72
|
-
return this.engine.getClassNameSource(key, routeId);
|
|
73
|
-
}
|
|
74
|
-
setClassNameSource(request) {
|
|
75
|
-
return this.engine.setClassNameSource(request);
|
|
76
|
-
}
|
|
77
|
-
async executeOperation(request) {
|
|
78
|
-
return toSiteEditOperationResult(await this.engine.execute(toInternalOperationRequest(request)));
|
|
79
|
-
}
|
|
80
|
-
async undo() {
|
|
81
|
-
return toSiteEditOperationResult(await this.engine.undo());
|
|
82
|
-
}
|
|
83
|
-
async redo() {
|
|
84
|
-
return toSiteEditOperationResult(await this.engine.redo());
|
|
85
|
-
}
|
|
86
|
-
notifyFileChanged(file) {
|
|
87
|
-
this.engine.notifyFileChanged(file);
|
|
88
|
-
}
|
|
89
|
-
subscribe(listener) {
|
|
90
|
-
this.listeners.add(listener);
|
|
91
|
-
return () => {
|
|
92
|
-
this.listeners.delete(listener);
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
dispose() {
|
|
96
|
-
this.listeners.clear();
|
|
97
|
-
this.engine.dispose();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
export function createPreviewSiteEditEngineRuntime(options) {
|
|
101
|
-
return new PreviewFileSystemSiteEditEngineRuntime(options);
|
|
102
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|