@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.
Files changed (163) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/index.js +127 -2
  3. package/dist/internal/protocol/operation.d.ts +2 -0
  4. package/dist/internal/protocol/render.d.ts +3 -30
  5. package/dist/internal/protocol.d.ts +1 -1
  6. package/dist/next-app-router.js +1 -140
  7. package/dist/preview-runtime.d.ts +249 -303
  8. package/dist/runtime-sync.d.ts +8 -8
  9. package/dist/runtime.d.ts +1 -127
  10. package/dist/site-edit-instrumentation.d.ts +1 -1
  11. package/dist/source-watcher.js +1 -150
  12. package/dist/types.d.ts +12 -14
  13. package/dist/webpack-loader.cjs +50 -588
  14. package/package.json +2 -2
  15. package/dist/execute-integration/execute-fixture-harness.d.ts +0 -25
  16. package/dist/execute-integration/execute-fixture-harness.js +0 -37
  17. package/dist/internal/ast/diagnostics/index.d.ts +0 -5
  18. package/dist/internal/ast/diagnostics/index.js +0 -25
  19. package/dist/internal/ast/history/index.d.ts +0 -15
  20. package/dist/internal/ast/history/index.js +0 -62
  21. package/dist/internal/ast/index.d.ts +0 -8
  22. package/dist/internal/ast/index.js +0 -5
  23. package/dist/internal/ast/locators/index.d.ts +0 -1
  24. package/dist/internal/ast/locators/index.js +0 -1
  25. package/dist/internal/ast/locators/resolve-locator.d.ts +0 -16
  26. package/dist/internal/ast/locators/resolve-locator.js +0 -920
  27. package/dist/internal/ast/parser/SourceParser.d.ts +0 -30
  28. package/dist/internal/ast/parser/SourceParser.js +0 -49
  29. package/dist/internal/ast/parser/index.d.ts +0 -21
  30. package/dist/internal/ast/parser/index.js +0 -64
  31. package/dist/internal/ast/primitives/conditional/conditional-primitives.d.ts +0 -18
  32. package/dist/internal/ast/primitives/conditional/conditional-primitives.js +0 -237
  33. package/dist/internal/ast/primitives/conditional/index.d.ts +0 -1
  34. package/dist/internal/ast/primitives/conditional/index.js +0 -1
  35. package/dist/internal/ast/primitives/imports/add-import.d.ts +0 -18
  36. package/dist/internal/ast/primitives/imports/add-import.js +0 -111
  37. package/dist/internal/ast/primitives/imports/index.d.ts +0 -2
  38. package/dist/internal/ast/primitives/imports/index.js +0 -2
  39. package/dist/internal/ast/primitives/imports/remove-import.d.ts +0 -15
  40. package/dist/internal/ast/primitives/imports/remove-import.js +0 -72
  41. package/dist/internal/ast/primitives/index.d.ts +0 -10
  42. package/dist/internal/ast/primitives/index.js +0 -10
  43. package/dist/internal/ast/primitives/jsx/index.d.ts +0 -4
  44. package/dist/internal/ast/primitives/jsx/index.js +0 -4
  45. package/dist/internal/ast/primitives/jsx/insert-child.d.ts +0 -11
  46. package/dist/internal/ast/primitives/jsx/insert-child.js +0 -69
  47. package/dist/internal/ast/primitives/jsx/move-node.d.ts +0 -9
  48. package/dist/internal/ast/primitives/jsx/move-node.js +0 -76
  49. package/dist/internal/ast/primitives/jsx/remove-node.d.ts +0 -7
  50. package/dist/internal/ast/primitives/jsx/remove-node.js +0 -36
  51. package/dist/internal/ast/primitives/jsx/update-text.d.ts +0 -8
  52. package/dist/internal/ast/primitives/jsx/update-text.js +0 -81
  53. package/dist/internal/ast/primitives/next/index.d.ts +0 -1
  54. package/dist/internal/ast/primitives/next/index.js +0 -1
  55. package/dist/internal/ast/primitives/next/next-primitives.d.ts +0 -43
  56. package/dist/internal/ast/primitives/next/next-primitives.js +0 -211
  57. package/dist/internal/ast/primitives/shared.d.ts +0 -60
  58. package/dist/internal/ast/primitives/shared.js +0 -176
  59. package/dist/internal/ast/primitives/style/class-expression.d.ts +0 -23
  60. package/dist/internal/ast/primitives/style/class-expression.js +0 -174
  61. package/dist/internal/ast/primitives/style/index.d.ts +0 -1
  62. package/dist/internal/ast/primitives/style/index.js +0 -1
  63. package/dist/internal/ast/primitives/style/style-primitives.d.ts +0 -49
  64. package/dist/internal/ast/primitives/style/style-primitives.js +0 -555
  65. package/dist/internal/ast/primitives/values/index.d.ts +0 -1
  66. package/dist/internal/ast/primitives/values/index.js +0 -1
  67. package/dist/internal/ast/primitives/values/value-primitives.d.ts +0 -42
  68. package/dist/internal/ast/primitives/values/value-primitives.js +0 -158
  69. package/dist/internal/ast/printer/SourcePrinter.d.ts +0 -21
  70. package/dist/internal/ast/printer/SourcePrinter.js +0 -76
  71. package/dist/internal/ast/printer/index.d.ts +0 -6
  72. package/dist/internal/ast/printer/index.js +0 -126
  73. package/dist/internal/ast/types.d.ts +0 -190
  74. package/dist/internal/ast/types.js +0 -1
  75. package/dist/internal/capability/capability-resolver.d.ts +0 -16
  76. package/dist/internal/capability/capability-resolver.js +0 -127
  77. package/dist/internal/classname-source.d.ts +0 -24
  78. package/dist/internal/classname-source.js +0 -220
  79. package/dist/internal/contracts/IEditEngineRuntime.d.ts +0 -18
  80. package/dist/internal/contracts/IEditEngineRuntime.js +0 -1
  81. package/dist/internal/domain/EditDiagnostic.d.ts +0 -38
  82. package/dist/internal/domain/EditDiagnostic.js +0 -43
  83. package/dist/internal/events/event-bus.d.ts +0 -14
  84. package/dist/internal/events/event-bus.js +0 -21
  85. package/dist/internal/graph/graph-builder.d.ts +0 -12
  86. package/dist/internal/graph/graph-builder.js +0 -1371
  87. package/dist/internal/graph/import-resolver.d.ts +0 -31
  88. package/dist/internal/graph/import-resolver.js +0 -109
  89. package/dist/internal/graph/project-graph-builder.d.ts +0 -32
  90. package/dist/internal/graph/project-graph-builder.js +0 -133
  91. package/dist/internal/graph/types.d.ts +0 -114
  92. package/dist/internal/graph/types.js +0 -6
  93. package/dist/internal/history/undo-redo.d.ts +0 -28
  94. package/dist/internal/history/undo-redo.js +0 -42
  95. package/dist/internal/index.d.ts +0 -2
  96. package/dist/internal/index.js +0 -1
  97. package/dist/internal/planner/planner.d.ts +0 -104
  98. package/dist/internal/planner/planner.js +0 -2533
  99. package/dist/internal/planner/types.d.ts +0 -275
  100. package/dist/internal/planner/types.js +0 -6
  101. package/dist/internal/protocol/boundary.js +0 -3
  102. package/dist/internal/protocol/capability.js +0 -8
  103. package/dist/internal/protocol/error.js +0 -38
  104. package/dist/internal/protocol/event.js +0 -3
  105. package/dist/internal/protocol/identity.js +0 -30
  106. package/dist/internal/protocol/operation.js +0 -8
  107. package/dist/internal/protocol/render.js +0 -3
  108. package/dist/internal/protocol.js +0 -2
  109. package/dist/internal/provenance/binding-graph.d.ts +0 -39
  110. package/dist/internal/provenance/binding-graph.js +0 -184
  111. package/dist/internal/provenance/capability-policy.d.ts +0 -15
  112. package/dist/internal/provenance/capability-policy.js +0 -96
  113. package/dist/internal/provenance/data-source-classifier.d.ts +0 -14
  114. package/dist/internal/provenance/data-source-classifier.js +0 -281
  115. package/dist/internal/provenance/resolve-text-provenance.d.ts +0 -45
  116. package/dist/internal/provenance/resolve-text-provenance.js +0 -3090
  117. package/dist/internal/provenance/types.d.ts +0 -89
  118. package/dist/internal/provenance/types.js +0 -1
  119. package/dist/internal/render/component-semantic.d.ts +0 -11
  120. package/dist/internal/render/component-semantic.js +0 -141
  121. package/dist/internal/render/content-model.d.ts +0 -3
  122. package/dist/internal/render/content-model.js +0 -89
  123. package/dist/internal/render/media-model.d.ts +0 -3
  124. package/dist/internal/render/media-model.js +0 -45
  125. package/dist/internal/render/provenance-types.d.ts +0 -33
  126. package/dist/internal/render/provenance-types.js +0 -1
  127. package/dist/internal/render/render-projection.d.ts +0 -24
  128. package/dist/internal/render/render-projection.js +0 -281
  129. package/dist/internal/render/tailwind-style-model.d.ts +0 -19
  130. package/dist/internal/render/tailwind-style-model.js +0 -1187
  131. package/dist/internal/runtime/EditEngineRuntime.d.ts +0 -25
  132. package/dist/internal/runtime/EditEngineRuntime.js +0 -89
  133. package/dist/internal/runtime/EditEngineRuntimeSnapshot.d.ts +0 -31
  134. package/dist/internal/runtime/EditEngineRuntimeSnapshot.js +0 -15
  135. package/dist/internal/runtime/InternalEditEngine.d.ts +0 -44
  136. package/dist/internal/runtime/InternalEditEngine.js +0 -1391
  137. package/dist/internal/runtime.d.ts +0 -3
  138. package/dist/internal/runtime.js +0 -1
  139. package/dist/internal/topology/topology.d.ts +0 -6
  140. package/dist/internal/topology/topology.js +0 -98
  141. package/dist/internal/topology/types.d.ts +0 -35
  142. package/dist/internal/topology/types.js +0 -5
  143. package/dist/internal/types.d.ts +0 -1
  144. package/dist/internal/types.js +0 -1
  145. package/dist/internal/writeback/in-memory-fs.d.ts +0 -7
  146. package/dist/internal/writeback/in-memory-fs.js +0 -44
  147. package/dist/internal/writeback/types.d.ts +0 -45
  148. package/dist/internal/writeback/types.js +0 -7
  149. package/dist/internal/writeback/writeback-service.d.ts +0 -7
  150. package/dist/internal/writeback/writeback-service.js +0 -568
  151. package/dist/internal-adapter.d.ts +0 -18
  152. package/dist/internal-adapter.js +0 -350
  153. package/dist/next-app-router-fs.js +0 -64
  154. package/dist/preview-runtime.js +0 -102
  155. package/dist/public-file-system.js +0 -1
  156. package/dist/runtime-sync.js +0 -321
  157. package/dist/runtime.js +0 -134
  158. package/dist/site-edit-instrumentation.js +0 -322
  159. package/dist/snapshot-file-system.d.ts +0 -19
  160. package/dist/snapshot-file-system.js +0 -49
  161. package/dist/source-writeback-test-harness.d.ts +0 -244
  162. package/dist/source-writeback-test-harness.js +0 -119
  163. package/dist/types.js +0 -1
@@ -1,89 +0,0 @@
1
- import type { ValueLocator, ValuePathSegment, ValueRootSelector } from "../ast/types.js";
2
- import type { NodePath } from "@babel/traverse";
3
- import type * as t from "@babel/types";
4
- import type { RenderSourceGraph } from "../graph/types.js";
5
- export type ExternalSourceKind = "api-field" | "cms-field" | "i18n-message" | "config-entry";
6
- export type ExternalAdapterCapability = "write-text" | "insert-child" | "remove-node" | "move-node";
7
- export interface ExternalSourceDescriptor {
8
- sourceType: ExternalSourceKind;
9
- sourceId: string;
10
- adapterId?: string;
11
- }
12
- export interface ExternalAdapterRegistration {
13
- sourceType: ExternalSourceKind;
14
- adapterId?: string;
15
- capabilities?: ExternalAdapterCapability[];
16
- }
17
- export interface ExternalSourceMatch {
18
- sourceType: ExternalSourceKind;
19
- sourceId: string;
20
- file: string;
21
- displayPath: string;
22
- adapterId?: string;
23
- }
24
- export interface ExternalSourceResolverContext {
25
- currentFile: string;
26
- expressionPath: NodePath<t.Expression>;
27
- readFile: (file: string) => Promise<string>;
28
- exists: (file: string) => Promise<boolean>;
29
- graph?: RenderSourceGraph;
30
- }
31
- export interface ExternalSourceResolution {
32
- match: ExternalSourceMatch;
33
- editMode?: "readonly";
34
- diagnostics?: ProvenanceDiagnostic[];
35
- }
36
- export type ExternalSourceResolverResult = ExternalSourceMatch | ExternalSourceResolution;
37
- export interface ExternalSourceResolver {
38
- helperNames?: string[];
39
- resolve(params: ExternalSourceResolverContext): Promise<ExternalSourceResolverResult | null> | ExternalSourceResolverResult | null;
40
- }
41
- export interface FunctionCallContract {
42
- helperName: string;
43
- purity: "pure" | "side-effect";
44
- sourceArgIndex?: number;
45
- }
46
- export type ResolvedTextWriteTarget = {
47
- kind: "value-binding";
48
- file: string;
49
- locator: ValueLocator | null;
50
- root?: ValueRootSelector;
51
- path?: ValuePathSegment[];
52
- displayExpression: string;
53
- sourceKind: "literal" | "binding" | "imported-binding" | "repeat-template";
54
- collectionIndexMap?: number[];
55
- collectionPathMap?: ValuePathSegment[][];
56
- } | {
57
- kind: "external-entry";
58
- file: string;
59
- sourceType: ExternalSourceKind;
60
- sourceId: string;
61
- adapterId?: string;
62
- displayExpression: string;
63
- };
64
- export interface SemanticSource {
65
- kind: "jsx-literal" | "component-prop" | "binding" | "imported-binding" | "object-field" | "array-item" | "repeat-template" | "conditional-branch" | ExternalSourceKind;
66
- file: string;
67
- locator: ValueLocator | null;
68
- root?: ValueRootSelector;
69
- path?: ValuePathSegment[];
70
- displayPath: string;
71
- externalSource?: ExternalSourceDescriptor;
72
- }
73
- export interface ProvenanceHop {
74
- kind: "jsx-literal" | "component-prop" | "binding" | "imported-binding" | "object-field" | "array-item" | "repeat-template" | "conditional-branch" | ExternalSourceKind;
75
- file: string;
76
- displayName: string;
77
- canEditHere: boolean;
78
- }
79
- export interface ProvenanceDiagnostic {
80
- code: "unsupported-expression" | "dynamic-key" | "conditional-branch-unresolved" | "component-prop-unresolved" | "ambiguous-prop-binding" | "external-source-readonly" | "missing-adapter";
81
- message: string;
82
- }
83
- export interface ProvenanceResolution {
84
- finalSource: SemanticSource | null;
85
- chain: ProvenanceHop[];
86
- confidence: "exact" | "safe-derived" | "partial" | "unknown";
87
- editMode: "direct" | "proxy" | "upstream" | "readonly" | "unsupported";
88
- diagnostics: ProvenanceDiagnostic[];
89
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- import type { ComponentSemanticDescriptor } from "../protocol.js";
2
- import type { ElementNode, RenderSourceGraph } from "../graph/types.js";
3
- import type { ProvenanceResolution } from "./provenance-types.js";
4
- interface BuildComponentSemanticDescriptorParams {
5
- key: string;
6
- element: ElementNode;
7
- graph: RenderSourceGraph;
8
- provenances: Map<number, ProvenanceResolution | null>;
9
- }
10
- export declare function buildComponentSemanticDescriptor(params: BuildComponentSemanticDescriptorParams): ComponentSemanticDescriptor;
11
- export {};
@@ -1,141 +0,0 @@
1
- export function buildComponentSemanticDescriptor(params) {
2
- const { key, element, graph, provenances } = params;
3
- const instanceElement = resolveInstanceElement(key, element, graph);
4
- const componentName = instanceElement?.tag ??
5
- (isComponentTag(element.tag) ? element.tag : element.componentName);
6
- const instanceKey = instanceElement?.identity.key ??
7
- resolveComponentCallerKey(element, graph) ??
8
- key;
9
- const variantKeys = resolveVariantKeys(instanceElement);
10
- const slotKeys = resolveSlotKeys(key, element, graph, provenances, instanceElement);
11
- const editableStrategy = resolveEditableStrategy(key, element, graph, provenances, instanceKey);
12
- return {
13
- componentName,
14
- instanceKey,
15
- templateOwner: resolveTemplateOwner(instanceElement ?? element, componentName),
16
- ...(variantKeys.length > 0 ? { variantKeys } : {}),
17
- ...(slotKeys.length > 0 ? { slotKeys } : {}),
18
- editableStrategy,
19
- impactScope: resolveImpactScope(editableStrategy),
20
- alternativeStrategies: resolveAlternativeStrategies(editableStrategy),
21
- };
22
- }
23
- function resolveEditableStrategy(key, element, graph, provenances, instanceKey) {
24
- for (const provenance of provenances.values()) {
25
- if (provenance?.editMode === "upstream") {
26
- return "upstream";
27
- }
28
- }
29
- if (findNearestComponentAncestor(key, graph)) {
30
- return "instance";
31
- }
32
- if (!isComponentTag(element.tag) &&
33
- element.sourceFile !== graph.routeId &&
34
- instanceKey !== key) {
35
- return "template";
36
- }
37
- return "instance";
38
- }
39
- function resolveComponentCallerKey(element, graph) {
40
- if (isComponentTag(element.tag)) {
41
- return element.identity.key;
42
- }
43
- const callers = [...graph.elements.values()].filter((candidate) => candidate.importedFrom === element.sourceFile &&
44
- matchesComponentExport(candidate, element.componentName));
45
- if (callers.length !== 1) {
46
- return null;
47
- }
48
- return callers[0].identity.key;
49
- }
50
- function resolveInstanceElement(key, element, graph) {
51
- if (isComponentTag(element.tag)) {
52
- return element;
53
- }
54
- const parentComponent = findNearestComponentAncestor(key, graph);
55
- if (parentComponent) {
56
- return parentComponent;
57
- }
58
- const callerKey = resolveComponentCallerKey(element, graph);
59
- return callerKey ? (graph.elements.get(callerKey) ?? null) : null;
60
- }
61
- function matchesComponentExport(candidate, componentName) {
62
- return (candidate.exportName === componentName ||
63
- candidate.tag === componentName ||
64
- candidate.exportName === "default");
65
- }
66
- function resolveTemplateOwner(element, componentName) {
67
- if (isComponentTag(element.tag) && element.importedFrom) {
68
- return `${element.importedFrom}#${componentName}`;
69
- }
70
- return `${element.sourceFile}#${componentName}`;
71
- }
72
- function resolveVariantKeys(instanceElement) {
73
- if (!instanceElement?.attributes) {
74
- return [];
75
- }
76
- const variantNames = new Set(["variant", "size", "tone"]);
77
- return instanceElement.attributes
78
- .filter((attribute) => variantNames.has(attribute.name))
79
- .map((attribute) => attribute.name);
80
- }
81
- function resolveSlotKeys(key, element, graph, provenances, instanceElement) {
82
- const slotKeys = new Set();
83
- const parentComponent = findNearestComponentAncestor(key, graph);
84
- if (parentComponent &&
85
- instanceElement?.identity.key === parentComponent.identity.key) {
86
- slotKeys.add("children");
87
- }
88
- for (const provenance of provenances.values()) {
89
- const propHop = provenance?.chain.find((hop) => hop.kind === "component-prop");
90
- if (!propHop) {
91
- continue;
92
- }
93
- const propName = propHop.displayName.split(".").pop();
94
- if (propName) {
95
- slotKeys.add(propName);
96
- }
97
- }
98
- if (slotKeys.size === 0 &&
99
- isComponentTag(element.tag) &&
100
- element.childKeys.length > 0) {
101
- slotKeys.add("children");
102
- }
103
- return [...slotKeys];
104
- }
105
- function findNearestComponentAncestor(key, graph) {
106
- let currentKey = graph.elements.get(key)?.parentKey ?? null;
107
- while (currentKey) {
108
- const current = graph.elements.get(currentKey);
109
- if (!current) {
110
- break;
111
- }
112
- if (isComponentTag(current.tag)) {
113
- return current;
114
- }
115
- currentKey = current.parentKey;
116
- }
117
- return null;
118
- }
119
- function isComponentTag(tag) {
120
- return /^[A-Z]/.test(tag);
121
- }
122
- function resolveImpactScope(editableStrategy) {
123
- switch (editableStrategy) {
124
- case "template":
125
- return "component-template";
126
- case "upstream":
127
- return "upstream-source";
128
- default:
129
- return "current-instance";
130
- }
131
- }
132
- function resolveAlternativeStrategies(editableStrategy) {
133
- switch (editableStrategy) {
134
- case "template":
135
- return ["instance"];
136
- case "upstream":
137
- return ["template"];
138
- default:
139
- return ["template"];
140
- }
141
- }
@@ -1,3 +0,0 @@
1
- import type { ContentModelView } from "../protocol.js";
2
- import type { ElementNode } from "../graph/types.js";
3
- export declare function buildContentModel(element: ElementNode): ContentModelView | undefined;
@@ -1,89 +0,0 @@
1
- const RICH_TEXT_FIELD_NAMES = new Set([
2
- "markdown",
3
- "body",
4
- "content",
5
- "value",
6
- "document",
7
- ]);
8
- const CONTENT_OPERATIONS = [
9
- "replace-rich-text-content",
10
- "insert-rich-text-block",
11
- "remove-rich-text-block",
12
- ];
13
- export function buildContentModel(element) {
14
- if (!isComponentTag(element.tag) || !element.attributes) {
15
- return undefined;
16
- }
17
- for (const attribute of element.attributes) {
18
- if (!RICH_TEXT_FIELD_NAMES.has(attribute.name)) {
19
- continue;
20
- }
21
- if (isMarkdownField(attribute)) {
22
- return {
23
- kind: "markdown",
24
- field: attribute.name,
25
- schema: "markdown",
26
- valuePath: attribute.source?.expression,
27
- operationBoundary: CONTENT_OPERATIONS,
28
- };
29
- }
30
- const richTextSchema = detectRichTextSchema(attribute.resolvedValue);
31
- if (richTextSchema === "prosemirror-doc" ||
32
- richTextSchema === "node-array") {
33
- return {
34
- kind: "rich-text-json",
35
- field: attribute.name,
36
- valuePath: attribute.source?.expression,
37
- schema: richTextSchema,
38
- operationBoundary: CONTENT_OPERATIONS,
39
- };
40
- }
41
- if (richTextSchema === "unsupported-json-tree") {
42
- return {
43
- kind: "rich-text-json",
44
- field: attribute.name,
45
- valuePath: attribute.source?.expression,
46
- schema: "unsupported-json-tree",
47
- operationBoundary: [],
48
- diagnostics: [
49
- {
50
- code: "unsupported-schema",
51
- field: attribute.name,
52
- message: 'Only top-level node arrays and { type: "doc", content: [] } rich-text JSON are editable in stage D',
53
- },
54
- ],
55
- };
56
- }
57
- }
58
- return undefined;
59
- }
60
- function detectRichTextSchema(value) {
61
- if (!value) {
62
- return undefined;
63
- }
64
- if (Array.isArray(value) && value.every((item) => isObjectRecord(item))) {
65
- return "node-array";
66
- }
67
- if (!isObjectRecord(value)) {
68
- return undefined;
69
- }
70
- if (value.type === "doc" && Array.isArray(value.content)) {
71
- return "prosemirror-doc";
72
- }
73
- if (Array.isArray(value.content) || Array.isArray(value.children)) {
74
- return "unsupported-json-tree";
75
- }
76
- return undefined;
77
- }
78
- function isObjectRecord(value) {
79
- return !Array.isArray(value) && typeof value === "object" && value !== null;
80
- }
81
- function isMarkdownField(attribute) {
82
- if (attribute.name === "markdown") {
83
- return true;
84
- }
85
- return false;
86
- }
87
- function isComponentTag(tag) {
88
- return /^[A-Z]/.test(tag);
89
- }
@@ -1,3 +0,0 @@
1
- import type { MediaModelView } from "../protocol.js";
2
- import type { ElementNode } from "../graph/types.js";
3
- export declare function buildMediaModel(element: ElementNode): MediaModelView | undefined;
@@ -1,45 +0,0 @@
1
- const MEDIA_FIELDS = [
2
- "src",
3
- "alt",
4
- "poster",
5
- "caption",
6
- "width",
7
- "height",
8
- ];
9
- export function buildMediaModel(element) {
10
- const attributes = element.attributes?.filter((attribute) => MEDIA_FIELDS.includes(attribute.name)) ?? [];
11
- if (attributes.length === 0) {
12
- return undefined;
13
- }
14
- const fields = attributes.map((attribute) => attribute.name);
15
- const valuePaths = Object.fromEntries(attributes
16
- .filter((attribute) => attribute.source?.expression)
17
- .map((attribute) => [attribute.name, attribute.source.expression]));
18
- const sourceType = resolveMediaSourceType(attributes.map((attribute) => attribute.value));
19
- return {
20
- kind: resolveMediaKind(element.tag, fields),
21
- sourceType,
22
- fields,
23
- editableFields: [...fields],
24
- operationBoundary: ["set-media-field"],
25
- ...(Object.keys(valuePaths).length > 0 ? { valuePaths } : {}),
26
- };
27
- }
28
- function resolveMediaKind(tag, fields) {
29
- if (tag === "img") {
30
- return "image";
31
- }
32
- if (tag === "video" || fields.includes("poster")) {
33
- return "video";
34
- }
35
- return "media";
36
- }
37
- function resolveMediaSourceType(values) {
38
- if (values.some((value) => value.startsWith("cms:"))) {
39
- return "cms-media-field";
40
- }
41
- if (values.some((value) => /^(\.?\/|\/)/.test(value))) {
42
- return "local-file-reference";
43
- }
44
- return "asset-id";
45
- }
@@ -1,33 +0,0 @@
1
- import type { ValueLocator, ValuePathSegment, ValueRootSelector } from "../ast/index.js";
2
- export type ExternalSourceKind = "api-field" | "cms-field" | "i18n-message" | "config-entry";
3
- export interface ExternalSourceDescriptor {
4
- sourceType: ExternalSourceKind;
5
- sourceId: string;
6
- adapterId?: string;
7
- }
8
- export interface SemanticSource {
9
- kind: "jsx-literal" | "component-prop" | "binding" | "imported-binding" | "object-field" | "array-item" | "repeat-template" | "conditional-branch" | ExternalSourceKind;
10
- file: string;
11
- locator: ValueLocator | null;
12
- root?: ValueRootSelector;
13
- path?: ValuePathSegment[];
14
- displayPath: string;
15
- externalSource?: ExternalSourceDescriptor;
16
- }
17
- export interface ProvenanceHop {
18
- kind: "jsx-literal" | "component-prop" | "binding" | "imported-binding" | "object-field" | "array-item" | "repeat-template" | "conditional-branch" | ExternalSourceKind;
19
- file: string;
20
- displayName: string;
21
- canEditHere: boolean;
22
- }
23
- export interface ProvenanceDiagnostic {
24
- code: "unsupported-expression" | "dynamic-key" | "conditional-branch-unresolved" | "component-prop-unresolved" | "ambiguous-prop-binding" | "external-source-readonly" | "missing-adapter";
25
- message: string;
26
- }
27
- export interface ProvenanceResolution {
28
- finalSource: SemanticSource | null;
29
- chain: ProvenanceHop[];
30
- confidence: "exact" | "safe-derived" | "partial" | "unknown";
31
- editMode: "direct" | "proxy" | "upstream" | "readonly" | "unsupported";
32
- diagnostics: ProvenanceDiagnostic[];
33
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,24 +0,0 @@
1
- import type { ComponentSemanticDescriptor, ContentModelView, MediaModelView, StyleModelView, StyleSourceView, ConditionalDetailView, RenderDocument, RenderObjectDetail, TextSourceView, WriteTargetView, NodeCapabilitySnapshot } from "../protocol.js";
2
- import type { RenderSourceGraph } from "../graph/types.js";
3
- import type { EditableTopology } from "../topology/types.js";
4
- import type { ProvenanceResolution } from "./provenance-types.js";
5
- /**
6
- * 投影 RenderDocument —— 从 graph + topology + capabilities 构建。
7
- */
8
- export declare function projectRenderDocument(graph: RenderSourceGraph, _topology: EditableTopology, capabilities: Map<string, NodeCapabilitySnapshot>, options?: {
9
- canUpdateTextByKey?: ReadonlyMap<string, boolean>;
10
- }): RenderDocument;
11
- /**
12
- * 投影 RenderObjectDetail —— 按需加载单个节点的详细信息。
13
- */
14
- export declare function projectRenderObjectDetail(key: string, graph: RenderSourceGraph, topology: EditableTopology, capabilities: Map<string, NodeCapabilitySnapshot>, textSources: Map<number, TextSourceView | null>, writeTarget: WriteTargetView, provenances?: Map<number, ProvenanceResolution | null>, conditional?: ConditionalDetailView, componentSemantic?: ComponentSemanticDescriptor, contentModel?: ContentModelView, mediaModel?: MediaModelView, styleSource?: StyleSourceView, styleModel?: StyleModelView): RenderObjectDetail;
15
- export interface DetailTextSegmentProjection {
16
- editable: boolean;
17
- source: TextSourceView | null;
18
- }
19
- /**
20
- * 选择 detail 的写回目标。
21
- * 只有可编辑 segment 解析到 value target 时,才升级为 value-binding。
22
- * 否则保持 jsx-node,并保留上游传入的 file / isProxy 元数据。
23
- */
24
- export declare function projectDetailWriteTarget(topWriteTarget: WriteTargetView, segments: DetailTextSegmentProjection[]): WriteTargetView;