@depup/base44__vite-plugin 1.0.4-depup.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 +34 -0
- package/changes.json +22 -0
- package/compat/agents.cjs +13 -0
- package/compat/base44Client.cjs +6 -0
- package/compat/entities.cjs +25 -0
- package/compat/functions.cjs +9 -0
- package/compat/integrations.cjs +9 -0
- package/dist/ErrorOverlay.d.ts +12 -0
- package/dist/ErrorOverlay.d.ts.map +1 -0
- package/dist/ErrorOverlay.js +51 -0
- package/dist/ErrorOverlay.js.map +1 -0
- package/dist/bridge.d.ts +8 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +8 -0
- package/dist/bridge.js.map +1 -0
- package/dist/capabilities/inline-edit/controller.d.ts +3 -0
- package/dist/capabilities/inline-edit/controller.d.ts.map +1 -0
- package/dist/capabilities/inline-edit/controller.js +203 -0
- package/dist/capabilities/inline-edit/controller.js.map +1 -0
- package/dist/capabilities/inline-edit/dom-utils.d.ts +7 -0
- package/dist/capabilities/inline-edit/dom-utils.d.ts.map +1 -0
- package/dist/capabilities/inline-edit/dom-utils.js +59 -0
- package/dist/capabilities/inline-edit/dom-utils.js.map +1 -0
- package/dist/capabilities/inline-edit/index.d.ts +3 -0
- package/dist/capabilities/inline-edit/index.d.ts.map +1 -0
- package/dist/capabilities/inline-edit/index.js +2 -0
- package/dist/capabilities/inline-edit/index.js.map +1 -0
- package/dist/capabilities/inline-edit/types.d.ts +29 -0
- package/dist/capabilities/inline-edit/types.d.ts.map +1 -0
- package/dist/capabilities/inline-edit/types.js +2 -0
- package/dist/capabilities/inline-edit/types.js.map +1 -0
- package/dist/consts.d.ts +11 -0
- package/dist/consts.d.ts.map +1 -0
- package/dist/consts.js +11 -0
- package/dist/consts.js.map +1 -0
- package/dist/error-overlay-plugin.d.ts +3 -0
- package/dist/error-overlay-plugin.d.ts.map +1 -0
- package/dist/error-overlay-plugin.js +15 -0
- package/dist/error-overlay-plugin.js.map +1 -0
- package/dist/html-injections-plugin.d.ts +8 -0
- package/dist/html-injections-plugin.d.ts.map +1 -0
- package/dist/html-injections-plugin.js +132 -0
- package/dist/html-injections-plugin.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +158 -0
- package/dist/index.js.map +1 -0
- package/dist/injections/layer-dropdown/consts.d.ts +20 -0
- package/dist/injections/layer-dropdown/consts.d.ts.map +1 -0
- package/dist/injections/layer-dropdown/consts.js +41 -0
- package/dist/injections/layer-dropdown/consts.js.map +1 -0
- package/dist/injections/layer-dropdown/controller.d.ts +4 -0
- package/dist/injections/layer-dropdown/controller.d.ts.map +1 -0
- package/dist/injections/layer-dropdown/controller.js +88 -0
- package/dist/injections/layer-dropdown/controller.js.map +1 -0
- package/dist/injections/layer-dropdown/dropdown-ui.d.ts +13 -0
- package/dist/injections/layer-dropdown/dropdown-ui.d.ts.map +1 -0
- package/dist/injections/layer-dropdown/dropdown-ui.js +186 -0
- package/dist/injections/layer-dropdown/dropdown-ui.js.map +1 -0
- package/dist/injections/layer-dropdown/types.d.ts +26 -0
- package/dist/injections/layer-dropdown/types.d.ts.map +1 -0
- package/dist/injections/layer-dropdown/types.js +3 -0
- package/dist/injections/layer-dropdown/types.js.map +1 -0
- package/dist/injections/layer-dropdown/utils.d.ts +25 -0
- package/dist/injections/layer-dropdown/utils.d.ts.map +1 -0
- package/dist/injections/layer-dropdown/utils.js +143 -0
- package/dist/injections/layer-dropdown/utils.js.map +1 -0
- package/dist/injections/navigation-notifier.d.ts +2 -0
- package/dist/injections/navigation-notifier.d.ts.map +1 -0
- package/dist/injections/navigation-notifier.js +34 -0
- package/dist/injections/navigation-notifier.js.map +1 -0
- package/dist/injections/sandbox-hmr-notifier.d.ts +2 -0
- package/dist/injections/sandbox-hmr-notifier.d.ts.map +1 -0
- package/dist/injections/sandbox-hmr-notifier.js +10 -0
- package/dist/injections/sandbox-hmr-notifier.js.map +1 -0
- package/dist/injections/sandbox-mount-observer.d.ts +2 -0
- package/dist/injections/sandbox-mount-observer.d.ts.map +1 -0
- package/dist/injections/sandbox-mount-observer.js +18 -0
- package/dist/injections/sandbox-mount-observer.js.map +1 -0
- package/dist/injections/unhandled-errors-handlers.d.ts +2 -0
- package/dist/injections/unhandled-errors-handlers.d.ts.map +1 -0
- package/dist/injections/unhandled-errors-handlers.js +93 -0
- package/dist/injections/unhandled-errors-handlers.js.map +1 -0
- package/dist/injections/utils.d.ts +65 -0
- package/dist/injections/utils.d.ts.map +1 -0
- package/dist/injections/utils.js +186 -0
- package/dist/injections/utils.js.map +1 -0
- package/dist/injections/visual-edit-agent.d.ts +2 -0
- package/dist/injections/visual-edit-agent.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent.js +583 -0
- package/dist/injections/visual-edit-agent.js.map +1 -0
- package/dist/jsx-processor.d.ts +17 -0
- package/dist/jsx-processor.d.ts.map +1 -0
- package/dist/jsx-processor.js +129 -0
- package/dist/jsx-processor.js.map +1 -0
- package/dist/jsx-utils.d.ts +16 -0
- package/dist/jsx-utils.d.ts.map +1 -0
- package/dist/jsx-utils.js +98 -0
- package/dist/jsx-utils.js.map +1 -0
- package/dist/processors/collection-id-processor.d.ts +20 -0
- package/dist/processors/collection-id-processor.d.ts.map +1 -0
- package/dist/processors/collection-id-processor.js +182 -0
- package/dist/processors/collection-id-processor.js.map +1 -0
- package/dist/processors/collection-item-field-processor.d.ts +39 -0
- package/dist/processors/collection-item-field-processor.d.ts.map +1 -0
- package/dist/processors/collection-item-field-processor.js +289 -0
- package/dist/processors/collection-item-field-processor.js.map +1 -0
- package/dist/processors/collection-item-id-processor.d.ts +12 -0
- package/dist/processors/collection-item-id-processor.d.ts.map +1 -0
- package/dist/processors/collection-item-id-processor.js +50 -0
- package/dist/processors/collection-item-id-processor.js.map +1 -0
- package/dist/processors/static-array-processor.d.ts +28 -0
- package/dist/processors/static-array-processor.d.ts.map +1 -0
- package/dist/processors/static-array-processor.js +173 -0
- package/dist/processors/static-array-processor.js.map +1 -0
- package/dist/processors/utils/collection-tracing-utils.d.ts +36 -0
- package/dist/processors/utils/collection-tracing-utils.d.ts.map +1 -0
- package/dist/processors/utils/collection-tracing-utils.js +390 -0
- package/dist/processors/utils/collection-tracing-utils.js.map +1 -0
- package/dist/processors/utils/shared-utils.d.ts +96 -0
- package/dist/processors/utils/shared-utils.d.ts.map +1 -0
- package/dist/processors/utils/shared-utils.js +600 -0
- package/dist/processors/utils/shared-utils.js.map +1 -0
- package/dist/statics/index.mjs +16 -0
- package/dist/statics/index.mjs.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +22 -0
- package/dist/utils.js.map +1 -0
- package/dist/visual-edit-plugin.d.ts +3 -0
- package/dist/visual-edit-plugin.d.ts.map +1 -0
- package/dist/visual-edit-plugin.js +100 -0
- package/dist/visual-edit-plugin.js.map +1 -0
- package/package.json +75 -0
- package/src/ErrorOverlay.ts +71 -0
- package/src/bridge.ts +8 -0
- package/src/capabilities/inline-edit/controller.ts +254 -0
- package/src/capabilities/inline-edit/dom-utils.ts +58 -0
- package/src/capabilities/inline-edit/index.ts +2 -0
- package/src/capabilities/inline-edit/types.ts +35 -0
- package/src/consts.ts +11 -0
- package/src/error-overlay-plugin.ts +19 -0
- package/src/html-injections-plugin.ts +166 -0
- package/src/index.ts +225 -0
- package/src/injections/layer-dropdown/LAYERS.md +258 -0
- package/src/injections/layer-dropdown/consts.ts +51 -0
- package/src/injections/layer-dropdown/controller.ts +109 -0
- package/src/injections/layer-dropdown/dropdown-ui.ts +242 -0
- package/src/injections/layer-dropdown/types.ts +30 -0
- package/src/injections/layer-dropdown/utils.ts +175 -0
- package/src/injections/navigation-notifier.ts +43 -0
- package/src/injections/sandbox-hmr-notifier.ts +8 -0
- package/src/injections/sandbox-mount-observer.ts +25 -0
- package/src/injections/unhandled-errors-handlers.ts +114 -0
- package/src/injections/utils.ts +208 -0
- package/src/injections/visual-edit-agent.ts +706 -0
- package/src/jsx-processor.ts +169 -0
- package/src/jsx-utils.ts +131 -0
- package/src/processors/collection-id-processor.ts +261 -0
- package/src/processors/collection-item-field-processor.ts +439 -0
- package/src/processors/collection-item-id-processor.ts +69 -0
- package/src/processors/static-array-processor.ts +260 -0
- package/src/processors/utils/collection-tracing-utils.ts +507 -0
- package/src/processors/utils/shared-utils.ts +785 -0
- package/src/utils.ts +27 -0
- package/src/visual-edit-plugin.md +358 -0
- package/src/visual-edit-plugin.ts +110 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import type { NodePath } from "@babel/traverse";
|
|
2
|
+
import type * as t from "@babel/types";
|
|
3
|
+
import {
|
|
4
|
+
DATA_ARR_INDEX,
|
|
5
|
+
DATA_ARR_VARIABLE_NAME,
|
|
6
|
+
DATA_ARR_FIELD,
|
|
7
|
+
} from "../consts.js";
|
|
8
|
+
import { JSXAttributeUtils, StaticValueUtils } from "./utils/shared-utils.js";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const GENERATED_INDEX_PARAM = "__arrIdx__";
|
|
12
|
+
|
|
13
|
+
interface ArrayMapInfo {
|
|
14
|
+
arrayExpression: NodePath<t.Expression>;
|
|
15
|
+
callbackParam: string;
|
|
16
|
+
indexParam: string | null;
|
|
17
|
+
arrayVariableName: string | null;
|
|
18
|
+
mapCallPath: NodePath<t.CallExpression>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class StaticArrayProcessor {
|
|
22
|
+
private attributeUtils: JSXAttributeUtils;
|
|
23
|
+
private staticValueUtils: StaticValueUtils;
|
|
24
|
+
|
|
25
|
+
constructor(private types: typeof t) {
|
|
26
|
+
this.attributeUtils = new JSXAttributeUtils(types);
|
|
27
|
+
this.staticValueUtils = new StaticValueUtils(types);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
process(path: NodePath<t.JSXOpeningElement>): void {
|
|
31
|
+
const arrayInfo = this.findParentArrayMap(path);
|
|
32
|
+
if (!arrayInfo) return;
|
|
33
|
+
|
|
34
|
+
if (!this.isStaticArray(arrayInfo.arrayExpression)) return;
|
|
35
|
+
|
|
36
|
+
const indexIdentifier = this.ensureIndexParam(arrayInfo);
|
|
37
|
+
this.addDataAttributes(path, arrayInfo, indexIdentifier);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private addDataAttributes(
|
|
41
|
+
path: NodePath<t.JSXOpeningElement>,
|
|
42
|
+
arrayInfo: ArrayMapInfo,
|
|
43
|
+
indexIdentifier: string
|
|
44
|
+
): void {
|
|
45
|
+
this.attributeUtils.addExpressionAttribute(
|
|
46
|
+
path,
|
|
47
|
+
DATA_ARR_INDEX,
|
|
48
|
+
this.types.identifier(indexIdentifier)
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
if (arrayInfo.arrayVariableName) {
|
|
52
|
+
this.attributeUtils.addStringAttribute(
|
|
53
|
+
path,
|
|
54
|
+
DATA_ARR_VARIABLE_NAME,
|
|
55
|
+
arrayInfo.arrayVariableName
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const fieldPath = this.findTextContentFieldPath(
|
|
60
|
+
path,
|
|
61
|
+
arrayInfo.callbackParam
|
|
62
|
+
);
|
|
63
|
+
if (fieldPath) {
|
|
64
|
+
this.attributeUtils.addStringAttribute(path, DATA_ARR_FIELD, fieldPath);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private findTextContentFieldPath(
|
|
69
|
+
path: NodePath<t.JSXOpeningElement>,
|
|
70
|
+
callbackParam: string
|
|
71
|
+
): string | null {
|
|
72
|
+
const parentElement = path.parentPath;
|
|
73
|
+
if (!parentElement?.isJSXElement()) return null;
|
|
74
|
+
|
|
75
|
+
for (const child of parentElement.get("children")) {
|
|
76
|
+
const fieldPath = this.extractFieldPathFromChild(child, callbackParam);
|
|
77
|
+
if (fieldPath) return fieldPath;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private extractFieldPathFromChild(
|
|
84
|
+
child: NodePath<t.JSXElement["children"][number]>,
|
|
85
|
+
callbackParam: string
|
|
86
|
+
): string | null {
|
|
87
|
+
if (!child.isJSXExpressionContainer()) return null;
|
|
88
|
+
|
|
89
|
+
const expression = child.get("expression");
|
|
90
|
+
if (!expression.isMemberExpression()) return null;
|
|
91
|
+
|
|
92
|
+
return this.extractFieldPath(expression, callbackParam);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private extractFieldPath(
|
|
96
|
+
expr: NodePath<t.MemberExpression>,
|
|
97
|
+
callbackParam: string
|
|
98
|
+
): string | null {
|
|
99
|
+
const parts = this.collectMemberExpressionParts(expr);
|
|
100
|
+
if (!parts) return null;
|
|
101
|
+
|
|
102
|
+
const { rootName, propertyNames } = parts;
|
|
103
|
+
return rootName === callbackParam ? propertyNames.join(".") : null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private collectMemberExpressionParts(
|
|
107
|
+
expr: NodePath<t.MemberExpression>
|
|
108
|
+
): { rootName: string; propertyNames: string[] } | null {
|
|
109
|
+
const propertyNames: string[] = [];
|
|
110
|
+
let current: NodePath<t.Expression> = expr;
|
|
111
|
+
|
|
112
|
+
while (current.isMemberExpression()) {
|
|
113
|
+
const property = current.get("property");
|
|
114
|
+
if (!property.isIdentifier()) return null;
|
|
115
|
+
|
|
116
|
+
propertyNames.unshift(property.node.name);
|
|
117
|
+
current = current.get("object") as NodePath<t.Expression>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!current.isIdentifier()) return null;
|
|
121
|
+
|
|
122
|
+
return { rootName: current.node.name, propertyNames };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private ensureIndexParam(arrayInfo: ArrayMapInfo): string {
|
|
126
|
+
if (arrayInfo.indexParam) {
|
|
127
|
+
return arrayInfo.indexParam;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
this.addIndexParamToCallback(arrayInfo.mapCallPath);
|
|
131
|
+
return GENERATED_INDEX_PARAM;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private addIndexParamToCallback(
|
|
135
|
+
mapCallPath: NodePath<t.CallExpression>
|
|
136
|
+
): void {
|
|
137
|
+
const callback = this.getMapCallback(mapCallPath);
|
|
138
|
+
if (!callback) return;
|
|
139
|
+
|
|
140
|
+
const params = callback.get("params");
|
|
141
|
+
if (params.length === 1) {
|
|
142
|
+
callback.node.params.push(this.types.identifier(GENERATED_INDEX_PARAM));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private getMapCallback(
|
|
147
|
+
mapCallPath: NodePath<t.CallExpression>
|
|
148
|
+
): NodePath<t.Function> | null {
|
|
149
|
+
const args = mapCallPath.get("arguments");
|
|
150
|
+
const firstArg = args[0];
|
|
151
|
+
if (firstArg && firstArg.isFunction()) {
|
|
152
|
+
return firstArg as NodePath<t.Function>;
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private findParentArrayMap(
|
|
158
|
+
path: NodePath<t.JSXOpeningElement>,
|
|
159
|
+
maxDepth: number = 5
|
|
160
|
+
): ArrayMapInfo | null {
|
|
161
|
+
let currentPath: NodePath = path;
|
|
162
|
+
let depth = 0;
|
|
163
|
+
|
|
164
|
+
while (currentPath.parentPath && depth < maxDepth) {
|
|
165
|
+
const mapInfo = this.tryExtractMapInfo(currentPath.parentPath);
|
|
166
|
+
if (mapInfo) return mapInfo;
|
|
167
|
+
|
|
168
|
+
currentPath = currentPath.parentPath;
|
|
169
|
+
depth++;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private tryExtractMapInfo(parent: NodePath): ArrayMapInfo | null {
|
|
176
|
+
if (!parent.isCallExpression()) return null;
|
|
177
|
+
if (!this.isMapCall(parent)) return null;
|
|
178
|
+
|
|
179
|
+
return this.extractArrayMapInfo(parent);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
private isMapCall(callExpr: NodePath<t.CallExpression>): boolean {
|
|
183
|
+
const callee = callExpr.get("callee");
|
|
184
|
+
if (!callee.isMemberExpression()) return false;
|
|
185
|
+
|
|
186
|
+
const property = callee.get("property");
|
|
187
|
+
return property.isIdentifier() && property.node.name === "map";
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
private extractArrayMapInfo(
|
|
191
|
+
mapCall: NodePath<t.CallExpression>
|
|
192
|
+
): ArrayMapInfo | null {
|
|
193
|
+
const callback = this.getMapCallback(mapCall);
|
|
194
|
+
if (!callback) return null;
|
|
195
|
+
|
|
196
|
+
const params = callback.get("params");
|
|
197
|
+
const firstParam = params[0];
|
|
198
|
+
if (!firstParam || !firstParam.isIdentifier()) return null;
|
|
199
|
+
|
|
200
|
+
const callee = mapCall.get("callee") as NodePath<t.MemberExpression>;
|
|
201
|
+
const arrayExpression = callee.get("object") as NodePath<t.Expression>;
|
|
202
|
+
|
|
203
|
+
return {
|
|
204
|
+
arrayExpression,
|
|
205
|
+
callbackParam: firstParam.node.name,
|
|
206
|
+
indexParam: this.extractIndexParam(params),
|
|
207
|
+
arrayVariableName: this.extractArrayVariableName(arrayExpression),
|
|
208
|
+
mapCallPath: mapCall,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
private extractIndexParam(params: NodePath<t.Node>[]): string | null {
|
|
213
|
+
const secondParam = params[1];
|
|
214
|
+
return secondParam && secondParam.isIdentifier()
|
|
215
|
+
? secondParam.node.name
|
|
216
|
+
: null;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private extractArrayVariableName(
|
|
220
|
+
arrayExpression: NodePath<t.Expression>
|
|
221
|
+
): string | null {
|
|
222
|
+
return arrayExpression.isIdentifier() ? arrayExpression.node.name : null;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private isStaticArray(arrayExpression: NodePath<t.Expression>): boolean {
|
|
226
|
+
const arrayExpr = this.resolveArrayExpression(arrayExpression);
|
|
227
|
+
return arrayExpr ? this.isStaticArrayExpression(arrayExpr) : false;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
private resolveArrayExpression(
|
|
231
|
+
expression: NodePath<t.Expression>
|
|
232
|
+
): NodePath<t.ArrayExpression> | null {
|
|
233
|
+
if (expression.isArrayExpression()) {
|
|
234
|
+
return expression;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (expression.isIdentifier()) {
|
|
238
|
+
return this.resolveIdentifierToArray(expression);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
private resolveIdentifierToArray(
|
|
245
|
+
identifier: NodePath<t.Identifier>
|
|
246
|
+
): NodePath<t.ArrayExpression> | null {
|
|
247
|
+
const binding = identifier.scope.getBinding(identifier.node.name);
|
|
248
|
+
|
|
249
|
+
if (!binding?.path.isVariableDeclarator()) return null;
|
|
250
|
+
|
|
251
|
+
const init = binding.path.get("init");
|
|
252
|
+
return init.isArrayExpression() ? init : null;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
private isStaticArrayExpression(
|
|
256
|
+
arrayExpression: NodePath<t.ArrayExpression>
|
|
257
|
+
): boolean {
|
|
258
|
+
return this.staticValueUtils.isStaticArrayExpression(arrayExpression);
|
|
259
|
+
}
|
|
260
|
+
}
|