@trojanbox-vcp-test/site-edit-engine 0.1.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/README.md +85 -0
- package/dist/execute-integration/execute-fixture-harness.d.ts +25 -0
- package/dist/execute-integration/execute-fixture-harness.js +37 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/internal/ast/diagnostics/index.d.ts +5 -0
- package/dist/internal/ast/diagnostics/index.js +25 -0
- package/dist/internal/ast/history/index.d.ts +15 -0
- package/dist/internal/ast/history/index.js +62 -0
- package/dist/internal/ast/index.d.ts +8 -0
- package/dist/internal/ast/index.js +5 -0
- package/dist/internal/ast/locators/index.d.ts +1 -0
- package/dist/internal/ast/locators/index.js +1 -0
- package/dist/internal/ast/locators/resolve-locator.d.ts +16 -0
- package/dist/internal/ast/locators/resolve-locator.js +920 -0
- package/dist/internal/ast/parser/SourceParser.d.ts +30 -0
- package/dist/internal/ast/parser/SourceParser.js +49 -0
- package/dist/internal/ast/parser/index.d.ts +21 -0
- package/dist/internal/ast/parser/index.js +64 -0
- package/dist/internal/ast/primitives/conditional/conditional-primitives.d.ts +18 -0
- package/dist/internal/ast/primitives/conditional/conditional-primitives.js +237 -0
- package/dist/internal/ast/primitives/conditional/index.d.ts +1 -0
- package/dist/internal/ast/primitives/conditional/index.js +1 -0
- package/dist/internal/ast/primitives/imports/add-import.d.ts +18 -0
- package/dist/internal/ast/primitives/imports/add-import.js +111 -0
- package/dist/internal/ast/primitives/imports/index.d.ts +2 -0
- package/dist/internal/ast/primitives/imports/index.js +2 -0
- package/dist/internal/ast/primitives/imports/remove-import.d.ts +15 -0
- package/dist/internal/ast/primitives/imports/remove-import.js +72 -0
- package/dist/internal/ast/primitives/index.d.ts +10 -0
- package/dist/internal/ast/primitives/index.js +10 -0
- package/dist/internal/ast/primitives/jsx/index.d.ts +4 -0
- package/dist/internal/ast/primitives/jsx/index.js +4 -0
- package/dist/internal/ast/primitives/jsx/insert-child.d.ts +11 -0
- package/dist/internal/ast/primitives/jsx/insert-child.js +69 -0
- package/dist/internal/ast/primitives/jsx/move-node.d.ts +9 -0
- package/dist/internal/ast/primitives/jsx/move-node.js +76 -0
- package/dist/internal/ast/primitives/jsx/remove-node.d.ts +7 -0
- package/dist/internal/ast/primitives/jsx/remove-node.js +36 -0
- package/dist/internal/ast/primitives/jsx/update-text.d.ts +8 -0
- package/dist/internal/ast/primitives/jsx/update-text.js +81 -0
- package/dist/internal/ast/primitives/next/index.d.ts +1 -0
- package/dist/internal/ast/primitives/next/index.js +1 -0
- package/dist/internal/ast/primitives/next/next-primitives.d.ts +43 -0
- package/dist/internal/ast/primitives/next/next-primitives.js +211 -0
- package/dist/internal/ast/primitives/shared.d.ts +60 -0
- package/dist/internal/ast/primitives/shared.js +176 -0
- package/dist/internal/ast/primitives/style/class-expression.d.ts +23 -0
- package/dist/internal/ast/primitives/style/class-expression.js +174 -0
- package/dist/internal/ast/primitives/style/index.d.ts +1 -0
- package/dist/internal/ast/primitives/style/index.js +1 -0
- package/dist/internal/ast/primitives/style/style-primitives.d.ts +49 -0
- package/dist/internal/ast/primitives/style/style-primitives.js +555 -0
- package/dist/internal/ast/primitives/values/index.d.ts +1 -0
- package/dist/internal/ast/primitives/values/index.js +1 -0
- package/dist/internal/ast/primitives/values/value-primitives.d.ts +42 -0
- package/dist/internal/ast/primitives/values/value-primitives.js +158 -0
- package/dist/internal/ast/printer/SourcePrinter.d.ts +21 -0
- package/dist/internal/ast/printer/SourcePrinter.js +76 -0
- package/dist/internal/ast/printer/index.d.ts +6 -0
- package/dist/internal/ast/printer/index.js +126 -0
- package/dist/internal/ast/types.d.ts +190 -0
- package/dist/internal/ast/types.js +1 -0
- package/dist/internal/capability/capability-resolver.d.ts +16 -0
- package/dist/internal/capability/capability-resolver.js +127 -0
- package/dist/internal/classname-source.d.ts +24 -0
- package/dist/internal/classname-source.js +220 -0
- package/dist/internal/contracts/IEditEngineRuntime.d.ts +18 -0
- package/dist/internal/contracts/IEditEngineRuntime.js +1 -0
- package/dist/internal/domain/EditDiagnostic.d.ts +38 -0
- package/dist/internal/domain/EditDiagnostic.js +43 -0
- package/dist/internal/events/event-bus.d.ts +14 -0
- package/dist/internal/events/event-bus.js +21 -0
- package/dist/internal/graph/graph-builder.d.ts +12 -0
- package/dist/internal/graph/graph-builder.js +1371 -0
- package/dist/internal/graph/import-resolver.d.ts +31 -0
- package/dist/internal/graph/import-resolver.js +109 -0
- package/dist/internal/graph/project-graph-builder.d.ts +32 -0
- package/dist/internal/graph/project-graph-builder.js +133 -0
- package/dist/internal/graph/types.d.ts +114 -0
- package/dist/internal/graph/types.js +6 -0
- package/dist/internal/history/undo-redo.d.ts +28 -0
- package/dist/internal/history/undo-redo.js +42 -0
- package/dist/internal/index.d.ts +2 -0
- package/dist/internal/index.js +1 -0
- package/dist/internal/planner/planner.d.ts +104 -0
- package/dist/internal/planner/planner.js +2533 -0
- package/dist/internal/planner/types.d.ts +275 -0
- package/dist/internal/planner/types.js +6 -0
- package/dist/internal/protocol/boundary.d.ts +10 -0
- package/dist/internal/protocol/boundary.js +3 -0
- package/dist/internal/protocol/capability.d.ts +47 -0
- package/dist/internal/protocol/capability.js +8 -0
- package/dist/internal/protocol/error.d.ts +43 -0
- package/dist/internal/protocol/error.js +38 -0
- package/dist/internal/protocol/event.d.ts +39 -0
- package/dist/internal/protocol/event.js +3 -0
- package/dist/internal/protocol/identity.d.ts +26 -0
- package/dist/internal/protocol/identity.js +30 -0
- package/dist/internal/protocol/operation.d.ts +224 -0
- package/dist/internal/protocol/operation.js +8 -0
- package/dist/internal/protocol/render.d.ts +212 -0
- package/dist/internal/protocol/render.js +3 -0
- package/dist/internal/protocol.d.ts +9 -0
- package/dist/internal/protocol.js +2 -0
- package/dist/internal/provenance/binding-graph.d.ts +39 -0
- package/dist/internal/provenance/binding-graph.js +184 -0
- package/dist/internal/provenance/capability-policy.d.ts +15 -0
- package/dist/internal/provenance/capability-policy.js +96 -0
- package/dist/internal/provenance/data-source-classifier.d.ts +14 -0
- package/dist/internal/provenance/data-source-classifier.js +281 -0
- package/dist/internal/provenance/resolve-text-provenance.d.ts +45 -0
- package/dist/internal/provenance/resolve-text-provenance.js +3090 -0
- package/dist/internal/provenance/types.d.ts +89 -0
- package/dist/internal/provenance/types.js +1 -0
- package/dist/internal/render/component-semantic.d.ts +11 -0
- package/dist/internal/render/component-semantic.js +141 -0
- package/dist/internal/render/content-model.d.ts +3 -0
- package/dist/internal/render/content-model.js +89 -0
- package/dist/internal/render/media-model.d.ts +3 -0
- package/dist/internal/render/media-model.js +45 -0
- package/dist/internal/render/provenance-types.d.ts +33 -0
- package/dist/internal/render/provenance-types.js +1 -0
- package/dist/internal/render/render-projection.d.ts +24 -0
- package/dist/internal/render/render-projection.js +281 -0
- package/dist/internal/render/tailwind-style-model.d.ts +19 -0
- package/dist/internal/render/tailwind-style-model.js +1187 -0
- package/dist/internal/runtime/EditEngineRuntime.d.ts +25 -0
- package/dist/internal/runtime/EditEngineRuntime.js +89 -0
- package/dist/internal/runtime/EditEngineRuntimeSnapshot.d.ts +31 -0
- package/dist/internal/runtime/EditEngineRuntimeSnapshot.js +15 -0
- package/dist/internal/runtime/InternalEditEngine.d.ts +44 -0
- package/dist/internal/runtime/InternalEditEngine.js +1391 -0
- package/dist/internal/runtime.d.ts +3 -0
- package/dist/internal/runtime.js +1 -0
- package/dist/internal/topology/topology.d.ts +6 -0
- package/dist/internal/topology/topology.js +98 -0
- package/dist/internal/topology/types.d.ts +35 -0
- package/dist/internal/topology/types.js +5 -0
- package/dist/internal/types.d.ts +1 -0
- package/dist/internal/types.js +1 -0
- package/dist/internal/writeback/in-memory-fs.d.ts +7 -0
- package/dist/internal/writeback/in-memory-fs.js +44 -0
- package/dist/internal/writeback/types.d.ts +45 -0
- package/dist/internal/writeback/types.js +7 -0
- package/dist/internal/writeback/writeback-service.d.ts +7 -0
- package/dist/internal/writeback/writeback-service.js +568 -0
- package/dist/internal-adapter.d.ts +18 -0
- package/dist/internal-adapter.js +350 -0
- package/dist/next-app-router-fs.d.ts +2 -0
- package/dist/next-app-router-fs.js +64 -0
- package/dist/next-app-router.d.ts +11 -0
- package/dist/next-app-router.js +140 -0
- package/dist/preview-runtime.d.ts +394 -0
- package/dist/preview-runtime.js +102 -0
- package/dist/public-file-system.d.ts +7 -0
- package/dist/public-file-system.js +1 -0
- package/dist/runtime-sync.d.ts +95 -0
- package/dist/runtime-sync.js +321 -0
- package/dist/runtime.d.ts +340 -0
- package/dist/runtime.js +134 -0
- package/dist/site-edit-instrumentation.d.ts +19 -0
- package/dist/site-edit-instrumentation.js +322 -0
- package/dist/snapshot-file-system.d.ts +19 -0
- package/dist/snapshot-file-system.js +49 -0
- package/dist/source-watcher.d.ts +20 -0
- package/dist/source-watcher.js +150 -0
- package/dist/source-writeback-test-harness.d.ts +244 -0
- package/dist/source-writeback-test-harness.js +119 -0
- package/dist/types.d.ts +68 -0
- package/dist/types.js +1 -0
- package/dist/webpack-loader.cjs +592 -0
- package/dist/webpack-loader.d.ts +27 -0
- package/package.json +66 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import type { OperationError } from "./error.js";
|
|
2
|
+
/** caller-facing 操作类型 */
|
|
3
|
+
export type OperationType = "update-text" | "remove-node" | "insert-child" | "move-node" | "replace-rich-text-content" | "insert-rich-text-block" | "remove-rich-text-block" | "set-media-field" | "set-component-slot-content" | "set-object-field" | "insert-object-field" | "remove-object-field" | "update-array-item" | "insert-array-item" | "remove-array-item" | "move-array-item" | "replace-conditional-expression" | "set-conditional-branch-content" | "set-jsx-prop" | "remove-jsx-prop" | "set-class-name" | "add-class-token" | "remove-class-token" | "set-style-property" | "set-style-properties" | "set-css-module-class" | "set-directive" | "remove-directive" | "set-route-export" | "set-metadata-field" | "set-generate-metadata";
|
|
4
|
+
export type OperationValue = string | number | boolean | null | OperationValue[] | {
|
|
5
|
+
[key: string]: OperationValue;
|
|
6
|
+
};
|
|
7
|
+
export type OperationTarget = {
|
|
8
|
+
kind: "node";
|
|
9
|
+
key: string;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "route";
|
|
12
|
+
routeId: string;
|
|
13
|
+
};
|
|
14
|
+
export type StyleProperty = "display" | "position" | "top" | "right" | "bottom" | "left" | "zIndex" | "flexDirection" | "flexWrap" | "flexGrow" | "flexShrink" | "flexBasis" | "order" | "gridTemplateColumns" | "gridTemplateRows" | "columns" | "gridColumn" | "gridRow" | "gap" | "gapX" | "gapY" | "spaceX" | "spaceY" | "alignItems" | "justifyContent" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "width" | "height" | "minWidth" | "minHeight" | "maxWidth" | "maxHeight" | "overflow" | "fontFamily" | "fontSize" | "fontWeight" | "lineHeight" | "letterSpacing" | "textAlign" | "textTransform" | "textDecoration" | "textOverflow" | "textIndent" | "writingMode" | "whiteSpace" | "wordBreak" | "lineClamp" | "fontVariantNumeric" | "screenReaderOnly" | "color" | "backgroundColor" | "backgroundImage" | "borderStyle" | "borderWidth" | "borderRadius" | "borderColor" | "objectFit" | "objectPosition" | "aspectRatio" | "opacity" | "boxShadow" | "transform" | "transformOrigin" | "transitionProperty" | "transitionDuration" | "transitionTimingFunction" | "animation" | "pointerEvents" | "cursor" | "userSelect" | "fontStyle" | "textUnderlineOffset" | "scrollMarginTop" | "alignSelf" | "flex" | "outlineStyle" | "resize" | "ringWidth" | "ringColor" | "backdropFilter" | "overscrollBehavior" | "divideWidth" | "divideColor";
|
|
15
|
+
export type StyleStateMode = "hover" | "active" | "focus" | "disabled";
|
|
16
|
+
export type StyleBreakpoint = "sm" | "md" | "lg" | "xl" | "2xl";
|
|
17
|
+
/**
|
|
18
|
+
* 操作请求 —— 由 client 发起,发送至 engine 执行。
|
|
19
|
+
*/
|
|
20
|
+
export interface OperationRequest {
|
|
21
|
+
/** 请求唯一 ID(用于关联 result / error) */
|
|
22
|
+
id: string;
|
|
23
|
+
/** 节点级编辑时可选的 route 约束。 */
|
|
24
|
+
routeId?: string;
|
|
25
|
+
/** 操作类型 */
|
|
26
|
+
kind: OperationType;
|
|
27
|
+
/** 操作目标。节点级编辑走 node,路由入口编辑走 route。 */
|
|
28
|
+
target: OperationTarget;
|
|
29
|
+
/** 请求时的 document version,用于乐观锁冲突检测 */
|
|
30
|
+
documentVersion: number;
|
|
31
|
+
/** 操作参数,按 kind 区分 */
|
|
32
|
+
params: OperationParams;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 移动/插入目标位置。
|
|
36
|
+
*
|
|
37
|
+
* 支持四种 relation:
|
|
38
|
+
* - before / after: 以 anchorKey 为锚点的前后位置
|
|
39
|
+
* - prepend / append: 以 parentKey 为容器的首尾位置
|
|
40
|
+
*
|
|
41
|
+
* 关键:anchorKey / parentKey 可以跨组件、跨文件,
|
|
42
|
+
* 展开为多步 RewritePlan 是 engine/planner 的责任。
|
|
43
|
+
*/
|
|
44
|
+
export type MoveTarget = {
|
|
45
|
+
relation: "before" | "after";
|
|
46
|
+
anchorKey: string;
|
|
47
|
+
} | {
|
|
48
|
+
relation: "prepend" | "append";
|
|
49
|
+
parentKey: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* 可插入的 HTML 标签集合。
|
|
53
|
+
*
|
|
54
|
+
* 使用 string 联合 + 品牌扩展,允许任意合法 HTML 标签。
|
|
55
|
+
*/
|
|
56
|
+
export type InsertableTag = "div" | "span" | "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "ul" | "ol" | "li" | "a" | "button" | "img" | "input" | "section" | "article" | "header" | "footer" | "nav" | "main" | "aside" | "form" | "label" | "textarea" | "select" | "option" | "table" | "thead" | "tbody" | "tr" | "th" | "td" | (string & {});
|
|
57
|
+
/**
|
|
58
|
+
* 插入节点规格。
|
|
59
|
+
*
|
|
60
|
+
* 支持两种模式:
|
|
61
|
+
* - native-tag: 插入 HTML 原生标签(可带文本)
|
|
62
|
+
* - component-call: 插入组件调用(需要 source + exportName + optional props)
|
|
63
|
+
*
|
|
64
|
+
* 关键:不能退化成 native-tag-only,component-call 是正式能力。
|
|
65
|
+
*/
|
|
66
|
+
export type InsertNodeSpec = {
|
|
67
|
+
kind: "native-tag";
|
|
68
|
+
tag: InsertableTag;
|
|
69
|
+
text?: string;
|
|
70
|
+
} | {
|
|
71
|
+
kind: "component-call";
|
|
72
|
+
component: {
|
|
73
|
+
source: string;
|
|
74
|
+
exportName: string;
|
|
75
|
+
};
|
|
76
|
+
props?: Record<string, unknown>;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* 操作参数联合类型 —— 按 kind 区分。
|
|
80
|
+
*
|
|
81
|
+
* - update-text: 更新文本段落(segmentIndex + value)
|
|
82
|
+
* - remove-node: 移除节点(无额外参数)
|
|
83
|
+
* - insert-child: 插入子节点(node 规格 + position)
|
|
84
|
+
* - move-node: 移动节点(target 位置 + preserveBindings)
|
|
85
|
+
*/
|
|
86
|
+
export type OperationParams = {
|
|
87
|
+
kind: "update-text";
|
|
88
|
+
segmentIndex: number;
|
|
89
|
+
value: string;
|
|
90
|
+
} | {
|
|
91
|
+
kind: "remove-node";
|
|
92
|
+
} | {
|
|
93
|
+
kind: "insert-child";
|
|
94
|
+
node: InsertNodeSpec;
|
|
95
|
+
position: MoveTarget;
|
|
96
|
+
} | {
|
|
97
|
+
kind: "move-node";
|
|
98
|
+
target: MoveTarget;
|
|
99
|
+
preserveBindings?: boolean;
|
|
100
|
+
} | {
|
|
101
|
+
kind: "replace-rich-text-content";
|
|
102
|
+
field: string;
|
|
103
|
+
value: OperationValue;
|
|
104
|
+
} | {
|
|
105
|
+
kind: "insert-rich-text-block";
|
|
106
|
+
field: string;
|
|
107
|
+
index: number;
|
|
108
|
+
block: OperationValue;
|
|
109
|
+
} | {
|
|
110
|
+
kind: "remove-rich-text-block";
|
|
111
|
+
field: string;
|
|
112
|
+
index: number;
|
|
113
|
+
} | {
|
|
114
|
+
kind: "set-media-field";
|
|
115
|
+
field: "src" | "alt" | "poster" | "caption" | "width" | "height";
|
|
116
|
+
value: OperationValue;
|
|
117
|
+
} | {
|
|
118
|
+
kind: "set-component-slot-content";
|
|
119
|
+
slotName: string;
|
|
120
|
+
value: OperationValue;
|
|
121
|
+
} | {
|
|
122
|
+
kind: "set-object-field";
|
|
123
|
+
segmentIndex: number;
|
|
124
|
+
value: OperationValue;
|
|
125
|
+
} | {
|
|
126
|
+
kind: "insert-object-field";
|
|
127
|
+
segmentIndex: number;
|
|
128
|
+
field: string;
|
|
129
|
+
value: OperationValue;
|
|
130
|
+
} | {
|
|
131
|
+
kind: "remove-object-field";
|
|
132
|
+
segmentIndex: number;
|
|
133
|
+
field?: string;
|
|
134
|
+
} | {
|
|
135
|
+
kind: "update-array-item";
|
|
136
|
+
segmentIndex: number;
|
|
137
|
+
value: OperationValue;
|
|
138
|
+
index?: number;
|
|
139
|
+
} | {
|
|
140
|
+
kind: "insert-array-item";
|
|
141
|
+
segmentIndex: number;
|
|
142
|
+
index: number;
|
|
143
|
+
value: OperationValue;
|
|
144
|
+
} | {
|
|
145
|
+
kind: "remove-array-item";
|
|
146
|
+
segmentIndex: number;
|
|
147
|
+
index?: number;
|
|
148
|
+
} | {
|
|
149
|
+
kind: "move-array-item";
|
|
150
|
+
segmentIndex: number;
|
|
151
|
+
toIndex: number;
|
|
152
|
+
fromIndex?: number;
|
|
153
|
+
} | {
|
|
154
|
+
kind: "replace-conditional-expression";
|
|
155
|
+
nextExpression: string;
|
|
156
|
+
} | {
|
|
157
|
+
kind: "set-conditional-branch-content";
|
|
158
|
+
branch: "then" | "else";
|
|
159
|
+
content: {
|
|
160
|
+
jsx: string;
|
|
161
|
+
};
|
|
162
|
+
} | {
|
|
163
|
+
kind: "set-jsx-prop";
|
|
164
|
+
name: string;
|
|
165
|
+
value: OperationValue | null;
|
|
166
|
+
} | {
|
|
167
|
+
kind: "remove-jsx-prop";
|
|
168
|
+
name: string;
|
|
169
|
+
} | {
|
|
170
|
+
kind: "set-class-name";
|
|
171
|
+
value: string;
|
|
172
|
+
} | {
|
|
173
|
+
kind: "add-class-token";
|
|
174
|
+
token: string;
|
|
175
|
+
} | {
|
|
176
|
+
kind: "remove-class-token";
|
|
177
|
+
token: string;
|
|
178
|
+
} | {
|
|
179
|
+
kind: "set-style-property";
|
|
180
|
+
property: string;
|
|
181
|
+
value: OperationValue | null;
|
|
182
|
+
} | {
|
|
183
|
+
kind: "set-style-properties";
|
|
184
|
+
properties: Record<string, OperationValue | null>;
|
|
185
|
+
} | {
|
|
186
|
+
kind: "set-css-module-class";
|
|
187
|
+
from: string;
|
|
188
|
+
to: string;
|
|
189
|
+
} | {
|
|
190
|
+
kind: "set-directive";
|
|
191
|
+
value: "use client" | "use server";
|
|
192
|
+
} | {
|
|
193
|
+
kind: "remove-directive";
|
|
194
|
+
value: "use client" | "use server";
|
|
195
|
+
} | {
|
|
196
|
+
kind: "set-route-export";
|
|
197
|
+
name: string;
|
|
198
|
+
value: OperationValue;
|
|
199
|
+
} | {
|
|
200
|
+
kind: "set-metadata-field";
|
|
201
|
+
field: string;
|
|
202
|
+
value: OperationValue | null;
|
|
203
|
+
} | {
|
|
204
|
+
kind: "set-generate-metadata";
|
|
205
|
+
field: string;
|
|
206
|
+
value: OperationValue | null;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* 操作结果 —— engine 执行完成后返回。
|
|
210
|
+
*/
|
|
211
|
+
export interface OperationResult {
|
|
212
|
+
/** 对应的请求 ID */
|
|
213
|
+
requestId: string;
|
|
214
|
+
/** 操作类型 */
|
|
215
|
+
kind: OperationType;
|
|
216
|
+
/** 操作目标 */
|
|
217
|
+
target: OperationTarget;
|
|
218
|
+
/** 是否成功 */
|
|
219
|
+
ok: boolean;
|
|
220
|
+
/** 操作后的 document version */
|
|
221
|
+
resultVersion: number;
|
|
222
|
+
/** 失败时的错误信息 */
|
|
223
|
+
error?: OperationError;
|
|
224
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import type { NodeCapabilitySnapshot } from "./capability.js";
|
|
2
|
+
import type { BoundaryKind } from "./boundary.js";
|
|
3
|
+
import type { OperationType, StyleBreakpoint, StyleProperty, StyleStateMode } from "./operation.js";
|
|
4
|
+
export type ExternalSourceKind = "api-field" | "cms-field" | "i18n-message" | "config-entry";
|
|
5
|
+
export interface ExternalSourceView {
|
|
6
|
+
sourceType: ExternalSourceKind;
|
|
7
|
+
sourceId: string;
|
|
8
|
+
adapterId?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 轻量级文档树 —— 一个路由对应一棵 RenderDocument。
|
|
12
|
+
* 由 engine 从 graph 投影而来,client 用于构建大纲 / 画布。
|
|
13
|
+
*/
|
|
14
|
+
export interface RenderDocument {
|
|
15
|
+
routeId: string;
|
|
16
|
+
version: number;
|
|
17
|
+
rootKeys: string[];
|
|
18
|
+
entries: RenderEntry[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 单个渲染条目 —— 描述一个节点在树中的位置与概要能力。
|
|
22
|
+
*/
|
|
23
|
+
export interface RenderEntry {
|
|
24
|
+
key: string;
|
|
25
|
+
tag: string;
|
|
26
|
+
label: string;
|
|
27
|
+
parentKey: string | null;
|
|
28
|
+
childKeys: string[];
|
|
29
|
+
operationSummary: OperationSummary;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 能力概要 —— 标记该节点支持的四个核心操作。
|
|
33
|
+
* 用于大纲 / 画布的快速渲染,详细约束见 NodeCapabilitySnapshot。
|
|
34
|
+
*/
|
|
35
|
+
export interface OperationSummary {
|
|
36
|
+
canUpdateText: boolean;
|
|
37
|
+
canInsertChild: boolean;
|
|
38
|
+
canMove: boolean;
|
|
39
|
+
canRemove: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 选中节点的详细信息 —— 按需加载。
|
|
43
|
+
* 包含完整 capability、text segments、boundary 信息、邻接关系。
|
|
44
|
+
*/
|
|
45
|
+
export interface RenderObjectDetail {
|
|
46
|
+
key: string;
|
|
47
|
+
tag: string;
|
|
48
|
+
componentName: string;
|
|
49
|
+
sourceFile: string;
|
|
50
|
+
label: string;
|
|
51
|
+
capabilities: NodeCapabilitySnapshot;
|
|
52
|
+
writeTarget: WriteTargetView;
|
|
53
|
+
effectiveWriteTarget?: EffectiveWriteTargetView;
|
|
54
|
+
provenanceChain?: ProvenanceChainView;
|
|
55
|
+
componentSemantic?: ComponentSemanticDescriptor;
|
|
56
|
+
contentModel?: ContentModelView;
|
|
57
|
+
mediaModel?: MediaModelView;
|
|
58
|
+
styleSource?: StyleSourceView;
|
|
59
|
+
styleModel?: StyleModelView;
|
|
60
|
+
conditional?: ConditionalDetailView;
|
|
61
|
+
textSegments: TextSegmentView[];
|
|
62
|
+
boundaryKind: BoundaryKind | null;
|
|
63
|
+
isOpaque: boolean;
|
|
64
|
+
ancestors: RenderEntryRef[];
|
|
65
|
+
children: RenderEntryRef[];
|
|
66
|
+
siblings: RenderEntryRef[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 写回目标视图 —— 描述该节点的语义写回落点。
|
|
70
|
+
*/
|
|
71
|
+
export interface WriteTargetView {
|
|
72
|
+
kind: "jsx-node" | "component-proxy" | "value-binding" | "route-export";
|
|
73
|
+
file: string;
|
|
74
|
+
componentName: string;
|
|
75
|
+
isProxy: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface EffectiveWriteTargetView {
|
|
78
|
+
kind: "jsx-node" | "value-path" | "route-export" | "external-entry";
|
|
79
|
+
file?: string;
|
|
80
|
+
isProxy: boolean;
|
|
81
|
+
displayPath?: string;
|
|
82
|
+
sourceType?: ExternalSourceKind;
|
|
83
|
+
sourceId?: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 文本段落视图 —— 表示一个可编辑 / 只读的文本片段。
|
|
87
|
+
*/
|
|
88
|
+
export interface TextSegmentView {
|
|
89
|
+
index: number;
|
|
90
|
+
value: string;
|
|
91
|
+
editable: boolean;
|
|
92
|
+
source: TextSourceView | null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 文本来源视图 —— 描述文本片段来自字面量、绑定或模板。
|
|
96
|
+
*/
|
|
97
|
+
export interface TextSourceView {
|
|
98
|
+
kind: "literal" | "binding" | "imported-binding" | "repeat-template";
|
|
99
|
+
file: string;
|
|
100
|
+
expression: string;
|
|
101
|
+
bindingName?: string;
|
|
102
|
+
path?: Array<string | number>;
|
|
103
|
+
}
|
|
104
|
+
export interface ProvenanceChainView {
|
|
105
|
+
finalSource: SemanticSourceView | null;
|
|
106
|
+
chain: ProvenanceHopView[];
|
|
107
|
+
confidence: "exact" | "safe-derived" | "partial" | "unknown";
|
|
108
|
+
editMode: "direct" | "proxy" | "upstream" | "readonly" | "unsupported";
|
|
109
|
+
diagnostics: Array<{
|
|
110
|
+
code: string;
|
|
111
|
+
message: string;
|
|
112
|
+
}>;
|
|
113
|
+
}
|
|
114
|
+
export interface SemanticSourceView {
|
|
115
|
+
kind: "jsx-literal" | "component-prop" | "binding" | "imported-binding" | "object-field" | "array-item" | "repeat-template" | "conditional-branch" | ExternalSourceKind;
|
|
116
|
+
file: string;
|
|
117
|
+
displayPath: string;
|
|
118
|
+
externalSource?: ExternalSourceView;
|
|
119
|
+
}
|
|
120
|
+
export interface ProvenanceHopView {
|
|
121
|
+
kind: "jsx-literal" | "component-prop" | "binding" | "imported-binding" | "object-field" | "array-item" | "repeat-template" | "conditional-branch" | ExternalSourceKind;
|
|
122
|
+
file: string;
|
|
123
|
+
displayName: string;
|
|
124
|
+
canEditHere: boolean;
|
|
125
|
+
}
|
|
126
|
+
export interface ComponentSemanticDescriptor {
|
|
127
|
+
componentName: string;
|
|
128
|
+
instanceKey: string;
|
|
129
|
+
templateOwner?: string;
|
|
130
|
+
variantKeys?: string[];
|
|
131
|
+
slotKeys?: string[];
|
|
132
|
+
editableStrategy: "instance" | "template" | "upstream";
|
|
133
|
+
impactScope?: "current-instance" | "component-template" | "upstream-source";
|
|
134
|
+
alternativeStrategies?: Array<"instance" | "template" | "upstream">;
|
|
135
|
+
}
|
|
136
|
+
export type ContentModelOperation = Extract<OperationType, "replace-rich-text-content" | "insert-rich-text-block" | "remove-rich-text-block">;
|
|
137
|
+
export type MediaModelOperation = Extract<OperationType, "set-media-field">;
|
|
138
|
+
export type StyleModelOperation = Extract<OperationType, "set-style-property" | "set-style-properties">;
|
|
139
|
+
export interface ModelDiagnosticView {
|
|
140
|
+
code: "unsupported-schema" | "unsupported-field";
|
|
141
|
+
field?: string;
|
|
142
|
+
message: string;
|
|
143
|
+
}
|
|
144
|
+
export interface ContentModelView {
|
|
145
|
+
kind: "markdown" | "rich-text-json";
|
|
146
|
+
field: string;
|
|
147
|
+
valuePath?: string;
|
|
148
|
+
schema?: string;
|
|
149
|
+
operationBoundary: ContentModelOperation[];
|
|
150
|
+
diagnostics?: ModelDiagnosticView[];
|
|
151
|
+
}
|
|
152
|
+
export interface MediaModelView {
|
|
153
|
+
kind: "image" | "video" | "media";
|
|
154
|
+
sourceType: "asset-id" | "cms-media-field" | "local-file-reference";
|
|
155
|
+
fields: string[];
|
|
156
|
+
editableFields: Array<"src" | "alt" | "poster" | "caption" | "width" | "height">;
|
|
157
|
+
operationBoundary: MediaModelOperation[];
|
|
158
|
+
valuePaths?: Record<string, string>;
|
|
159
|
+
diagnostics?: ModelDiagnosticView[];
|
|
160
|
+
}
|
|
161
|
+
export interface StyleModelView {
|
|
162
|
+
kind: "css-style-model";
|
|
163
|
+
editable: boolean;
|
|
164
|
+
operationBoundary: StyleModelOperation[];
|
|
165
|
+
properties: StylePropertyView[];
|
|
166
|
+
sourcePath?: string;
|
|
167
|
+
diagnostics?: Array<{
|
|
168
|
+
code: "missing-class-name" | "dynamic-binding" | "non-string-binding";
|
|
169
|
+
message: string;
|
|
170
|
+
}>;
|
|
171
|
+
}
|
|
172
|
+
export interface StyleSourceView {
|
|
173
|
+
kind: "class-name-source";
|
|
174
|
+
className: string;
|
|
175
|
+
sourceKind: "missing" | "static-attribute" | "static-expression" | "dynamic-expression";
|
|
176
|
+
editable: boolean;
|
|
177
|
+
operationBoundary: StyleModelOperation[];
|
|
178
|
+
sourcePath?: string;
|
|
179
|
+
diagnostics?: Array<{
|
|
180
|
+
code: "missing-class-name" | "dynamic-binding" | "non-string-binding";
|
|
181
|
+
message: string;
|
|
182
|
+
}>;
|
|
183
|
+
}
|
|
184
|
+
export interface StylePropertyView {
|
|
185
|
+
property: StyleProperty;
|
|
186
|
+
value: string | number | boolean | null;
|
|
187
|
+
resolvedValue?: string | number | boolean | null;
|
|
188
|
+
breakpoint?: StyleBreakpoint;
|
|
189
|
+
state?: StyleStateMode;
|
|
190
|
+
variants?: string[];
|
|
191
|
+
options?: Array<string | number>;
|
|
192
|
+
editable: boolean;
|
|
193
|
+
operationBoundary?: StyleModelOperation[];
|
|
194
|
+
diagnostics?: Array<{
|
|
195
|
+
code: "unsupported-value" | "responsive-value";
|
|
196
|
+
message: string;
|
|
197
|
+
}>;
|
|
198
|
+
}
|
|
199
|
+
export interface ConditionalDetailView {
|
|
200
|
+
currentBranch: "then" | "else";
|
|
201
|
+
availableBranches: Array<"then" | "else">;
|
|
202
|
+
conditionExpression: string;
|
|
203
|
+
provenance?: ProvenanceChainView;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* 轻量级条目引用 —— 用于邻接关系列表。
|
|
207
|
+
*/
|
|
208
|
+
export interface RenderEntryRef {
|
|
209
|
+
key: string;
|
|
210
|
+
tag: string;
|
|
211
|
+
label: string;
|
|
212
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { computeSourceIdentityKey, parseSourceIdentityKey, } from "./protocol/identity.js";
|
|
2
|
+
export { OperationErrorCode } from "./protocol/error.js";
|
|
3
|
+
export type { BoundaryKind } from "./protocol/boundary.js";
|
|
4
|
+
export type { CapabilityConstraint, CapabilityModeView, ConstraintKind, NodeCapabilitySnapshot, } from "./protocol/capability.js";
|
|
5
|
+
export type { DesignerEvent } from "./protocol/event.js";
|
|
6
|
+
export type { OperationError } from "./protocol/error.js";
|
|
7
|
+
export type { SourceIdentity } from "./protocol/identity.js";
|
|
8
|
+
export type { InsertableTag, InsertNodeSpec, MoveTarget, OperationParams, OperationRequest, OperationResult, OperationTarget, OperationType, OperationValue, StyleBreakpoint, StyleProperty, StyleStateMode, } from "./protocol/operation.js";
|
|
9
|
+
export type { ComponentSemanticDescriptor, ConditionalDetailView, ContentModelView, EffectiveWriteTargetView, MediaModelView, OperationSummary, ProvenanceChainView, ProvenanceHopView, RenderDocument, RenderEntry, RenderEntryRef, RenderObjectDetail, SemanticSourceView, StyleModelOperation, StyleModelView, StyleSourceView, StylePropertyView, TextSegmentView, TextSourceView, WriteTargetView, } from "./protocol/render.js";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Binding, NodePath } from "@babel/traverse";
|
|
2
|
+
import * as t from "@babel/types";
|
|
3
|
+
import type { TextExpressionSource } from "../graph/types.js";
|
|
4
|
+
import type { ValuePathSegment } from "../ast/types.js";
|
|
5
|
+
export type BindingGraphNodeKind = "literal" | "local-binding" | "param" | "prop-default" | "alias" | "imported-binding" | "hook-state" | "async-result";
|
|
6
|
+
export type BindingGraphEdgeKind = "assigned-from" | "destructured-from" | "defaulted-from" | "passed-prop" | "imported-from" | "setter-updated-by";
|
|
7
|
+
export interface BindingGraphNode {
|
|
8
|
+
id: string;
|
|
9
|
+
kind: BindingGraphNodeKind;
|
|
10
|
+
name: string;
|
|
11
|
+
path: NodePath;
|
|
12
|
+
}
|
|
13
|
+
export interface BindingGraphEdge {
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
kind: BindingGraphEdgeKind;
|
|
17
|
+
}
|
|
18
|
+
export interface BindingGraph {
|
|
19
|
+
nodes: BindingGraphNode[];
|
|
20
|
+
edges: BindingGraphEdge[];
|
|
21
|
+
}
|
|
22
|
+
export interface PropDefaultBinding {
|
|
23
|
+
propName: string;
|
|
24
|
+
componentName: string;
|
|
25
|
+
expressionPath: NodePath<t.Expression>;
|
|
26
|
+
displayPath: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ParamPropReference {
|
|
29
|
+
propName: string;
|
|
30
|
+
remainingPath: ValuePathSegment[];
|
|
31
|
+
}
|
|
32
|
+
export interface AliasInitializer {
|
|
33
|
+
expressionPath: NodePath<t.Expression>;
|
|
34
|
+
}
|
|
35
|
+
export declare function createBindingGraph(): BindingGraph;
|
|
36
|
+
export declare function findAliasInitializer(binding: Binding): AliasInitializer | null;
|
|
37
|
+
export declare function getParamPropReference(binding: Binding, sourceInfo?: TextExpressionSource): ParamPropReference | null;
|
|
38
|
+
export declare function findPropDefaultBinding(binding: Binding, componentName: string, expectedPropName?: string): PropDefaultBinding | null;
|
|
39
|
+
export declare function findPatternBindingPath(pattern: t.PatternLike, bindingName: string, prefix?: ValuePathSegment[]): ValuePathSegment[] | null;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import * as t from "@babel/types";
|
|
2
|
+
export function createBindingGraph() {
|
|
3
|
+
return { nodes: [], edges: [] };
|
|
4
|
+
}
|
|
5
|
+
export function findAliasInitializer(binding) {
|
|
6
|
+
if (binding.path.isVariableDeclarator()) {
|
|
7
|
+
const initPath = binding.path.get("init");
|
|
8
|
+
return initPath?.isExpression() ? { expressionPath: initPath } : null;
|
|
9
|
+
}
|
|
10
|
+
if (!binding.path.isIdentifier() ||
|
|
11
|
+
!binding.path.parentPath?.isVariableDeclarator()) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const initPath = binding.path.parentPath.get("init");
|
|
15
|
+
if (!initPath?.isExpression()) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return { expressionPath: initPath };
|
|
19
|
+
}
|
|
20
|
+
export function getParamPropReference(binding, sourceInfo) {
|
|
21
|
+
if (binding.path.isObjectPattern()) {
|
|
22
|
+
return sourceInfo
|
|
23
|
+
? {
|
|
24
|
+
propName: sourceInfo.base,
|
|
25
|
+
remainingPath: sourceInfo.path,
|
|
26
|
+
}
|
|
27
|
+
: null;
|
|
28
|
+
}
|
|
29
|
+
const objectProperty = getDestructuredPropPropertyPath(binding);
|
|
30
|
+
if (objectProperty) {
|
|
31
|
+
const propName = getObjectPropertyKey(objectProperty.node);
|
|
32
|
+
if (!propName) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
propName,
|
|
37
|
+
remainingPath: sourceInfo?.path ?? [],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (binding.path.isIdentifier() &&
|
|
41
|
+
binding.path.key === 0 &&
|
|
42
|
+
Array.isArray(binding.path.container)) {
|
|
43
|
+
const [firstPath, ...restPath] = sourceInfo?.path ?? [];
|
|
44
|
+
if (!firstPath || firstPath.kind !== "property") {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
propName: firstPath.name,
|
|
49
|
+
remainingPath: restPath,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
export function findPropDefaultBinding(binding, componentName, expectedPropName) {
|
|
55
|
+
if (binding.path.isObjectPattern()) {
|
|
56
|
+
for (const property of binding.path.get("properties")) {
|
|
57
|
+
if (!property.isObjectProperty()) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const propName = getObjectPropertyKey(property.node);
|
|
61
|
+
if (!propName || (expectedPropName && propName !== expectedPropName)) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const valuePath = property.get("value");
|
|
65
|
+
if (!valuePath.isAssignmentPattern()) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const rightPath = valuePath.get("right");
|
|
69
|
+
if (!rightPath.isExpression()) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
propName,
|
|
74
|
+
componentName,
|
|
75
|
+
expressionPath: rightPath,
|
|
76
|
+
displayPath: `${componentName}.${propName}.default`,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const assignmentPath = getDefaultAssignmentPath(binding);
|
|
81
|
+
if (!assignmentPath) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const objectProperty = assignmentPath.parentPath;
|
|
85
|
+
if (!objectProperty?.isObjectProperty()) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const propName = getObjectPropertyKey(objectProperty.node);
|
|
89
|
+
if (!propName || (expectedPropName && propName !== expectedPropName)) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
const rightPath = assignmentPath.get("right");
|
|
93
|
+
if (!rightPath.isExpression()) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
propName,
|
|
98
|
+
componentName,
|
|
99
|
+
expressionPath: rightPath,
|
|
100
|
+
displayPath: `${componentName}.${propName}.default`,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export function findPatternBindingPath(pattern, bindingName, prefix = []) {
|
|
104
|
+
if (t.isIdentifier(pattern)) {
|
|
105
|
+
return pattern.name === bindingName ? prefix : null;
|
|
106
|
+
}
|
|
107
|
+
if (t.isObjectPattern(pattern)) {
|
|
108
|
+
for (const property of pattern.properties) {
|
|
109
|
+
if (t.isObjectProperty(property)) {
|
|
110
|
+
const key = getObjectPropertyKey(property);
|
|
111
|
+
if (!key) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const result = findPatternBindingPath(property.value, bindingName, [...prefix, { kind: "property", name: key }]);
|
|
115
|
+
if (result) {
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else if (t.isRestElement(property)) {
|
|
120
|
+
const result = findPatternBindingPath(property.argument, bindingName, prefix);
|
|
121
|
+
if (result) {
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (t.isArrayPattern(pattern)) {
|
|
128
|
+
for (let index = 0; index < pattern.elements.length; index += 1) {
|
|
129
|
+
const element = pattern.elements[index];
|
|
130
|
+
if (!element) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const target = t.isRestElement(element) ? element.argument : element;
|
|
134
|
+
const result = findPatternBindingPath(target, bindingName, [...prefix, { kind: "index", index }]);
|
|
135
|
+
if (result) {
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (t.isAssignmentPattern(pattern)) {
|
|
141
|
+
return findPatternBindingPath(pattern.left, bindingName, prefix);
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
function getDefaultAssignmentPath(binding) {
|
|
146
|
+
if (!binding.path.isIdentifier()) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
const parent = binding.path.parentPath;
|
|
150
|
+
if (parent?.isAssignmentPattern() && parent.node.left === binding.path.node) {
|
|
151
|
+
return parent;
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
function getDestructuredPropPropertyPath(binding) {
|
|
156
|
+
if (!binding.path.isIdentifier()) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
const directParent = binding.path.parentPath;
|
|
160
|
+
if (directParent?.isObjectProperty() &&
|
|
161
|
+
directParent.parentPath?.isObjectPattern()) {
|
|
162
|
+
return directParent;
|
|
163
|
+
}
|
|
164
|
+
const assignmentParent = directParent?.isAssignmentPattern()
|
|
165
|
+
? directParent.parentPath
|
|
166
|
+
: null;
|
|
167
|
+
if (assignmentParent?.isObjectProperty() &&
|
|
168
|
+
assignmentParent.parentPath?.isObjectPattern()) {
|
|
169
|
+
return assignmentParent;
|
|
170
|
+
}
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
function getObjectPropertyKey(property) {
|
|
174
|
+
if (property.computed) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
if (t.isIdentifier(property.key)) {
|
|
178
|
+
return property.key.name;
|
|
179
|
+
}
|
|
180
|
+
if (t.isStringLiteral(property.key)) {
|
|
181
|
+
return property.key.value;
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
}
|