lc-test3 1.1.10 → 1.1.11

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 (2) hide show
  1. package/p.js +751 -556
  2. package/package.json +1 -1
package/p.js CHANGED
@@ -1,556 +1,751 @@
1
- [ASTCache] Parse miss (SWC) - /src/pages/Login/index.js (1.90ms)
2
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/Home.js (1.10ms)
3
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/TaskPending.js (1.90ms)
4
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/TaskCompleted.js (1.70ms)
5
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/CirculatePending.js (1.60ms)
6
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/CirculateCompleted.js (1.70ms)
7
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/MyProcess.js (1.60ms)
8
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/SyncProcess.js (2.30ms)
9
- swc-parser.ts:666 [SWC] ����ʧ�ܣ����˵� Babel:
10
- x Unexpected token `Page`. Expected jsx identifier
11
- ,-[5:1]
12
-  5 | * interfaceName: �����¼�б��ӿ�
13
-  6 | * interface: /los/${appName}.pageImportApply
14
-  7 | * RESOURCESTREE-END
15
-  8 | */<Page data-dnd="%2Fsrc%2Fpages%2FImportRecord.js:Page:pagebd90" onMount={() => {$function.importRecord.fetchRecord();}} access={{ relatedInterfaces: [{ label: "�����¼�б��ӿ�", value: "/los/${appName}.pageImportApply" }] }}>
16
- :  ^^^^
17
-  9 |
18
- 10 |
19
- `----
20
-
21
-
22
- Caused by:
23
- 0: failed to parse code
24
- 1: Syntax Error
25
- parseWithSWC @ swc-parser.ts:666
26
- parseCode @ ast-cache.ts:740
27
- parseSync @ ast-cache.ts:933
28
- code2astWithCache @ ast-cache.ts:1277
29
- code2astCached @ parse.ts:112
30
- get @ light-module.ts:91
31
- get @ light-module.ts:107
32
- trackDerivedFunction @ mobx.esm.js:1842
33
- computeValue_ @ mobx.esm.js:1636
34
- trackAndCompute @ mobx.esm.js:1613
35
- get @ mobx.esm.js:1582
36
- getObservablePropValue_ @ mobx.esm.js:4744
37
- get @ mobx.esm.js:5243
38
- hasModelDiff @ workspace.ts:3262
39
- (anonymous) @ useFolder.tsx:71
40
- makeFileTree @ useFolder.tsx:64
41
- useFolder @ useFolder.tsx:303
42
- (anonymous) @ index.tsx:65
43
- (anonymous) @ observer.js:44
44
- (anonymous) @ useObserver.js:80
45
- trackDerivedFunction @ mobx.esm.js:1842
46
- track @ mobx.esm.js:2360
47
- useObserver @ useObserver.js:78
48
- (anonymous) @ observer.js:44
49
- renderWithHooks @ react-dom.development.js:15015
50
- updateFunctionComponent @ react-dom.development.js:17386
51
- updateSimpleMemoComponent @ react-dom.development.js:17245
52
- beginWork @ react-dom.development.js:19170
53
- beginWork$1 @ react-dom.development.js:23970
54
- performUnitOfWork @ react-dom.development.js:22809
55
- workLoopSync @ react-dom.development.js:22737
56
- renderRootSync @ react-dom.development.js:22700
57
- performSyncWorkOnRoot @ react-dom.development.js:22323
58
- (anonymous) @ react-dom.development.js:11357
59
- unstable_runWithPriority @ react.development.js:2764
60
- runWithPriority$1 @ react-dom.development.js:11306
61
- flushSyncCallbackQueueImpl @ react-dom.development.js:11352
62
- flushSyncCallbackQueue @ react-dom.development.js:11339
63
- discreteUpdates$1 @ react-dom.development.js:22450
64
- discreteUpdates @ react-dom.development.js:3753
65
- dispatchDiscreteEvent @ react-dom.development.js:5919
66
- light-module.ts:99 SyntaxError: Unexpected token (50:732) (at index.js:363:1)
67
- at constructor (index.js:363:1)
68
- at JSXParserMixin.raise (index.js:6609:1)
69
- at JSXParserMixin.unexpected (index.js:6629:1)
70
- at JSXParserMixin.parseExprAtom (index.js:11378:1)
71
- at JSXParserMixin.parseExprAtom (index.js:4776:1)
72
- at JSXParserMixin.parseExprSubscripts (index.js:11012:1)
73
- at JSXParserMixin.parseUpdate (index.js:10997:1)
74
- at JSXParserMixin.parseMaybeUnary (index.js:10977:1)
75
- at JSXParserMixin.parseMaybeUnaryOrPrivate (index.js:10830:1)
76
- at JSXParserMixin.parseExprOps (index.js:10835:1)
77
- at JSXParserMixin.parseMaybeConditional (index.js:10812:1)
78
- at JSXParserMixin.parseMaybeAssign (index.js:10765:1)
79
- at index.js:10734:1
80
- at JSXParserMixin.allowInAnd (index.js:12361:1)
81
- at JSXParserMixin.parseMaybeAssignAllowIn (index.js:10734:1)
82
- at JSXParserMixin.parseObjectProperty (index.js:11885:1)
83
- at JSXParserMixin.parseObjPropValue (index.js:11913:1)
84
- at JSXParserMixin.parsePropertyDefinition (index.js:11850:1)
85
- at JSXParserMixin.parseObjectLike (index.js:11765:1)
86
- at JSXParserMixin.parseExprAtom (index.js:11270:1)
87
- at JSXParserMixin.parseExprAtom (index.js:4776:1)
88
- at JSXParserMixin.parseExprSubscripts (index.js:11012:1)
89
- at JSXParserMixin.parseUpdate (index.js:10997:1)
90
- at JSXParserMixin.parseMaybeUnary (index.js:10977:1)
91
- at JSXParserMixin.parseMaybeUnaryOrPrivate (index.js:10830:1)
92
- at JSXParserMixin.parseExprOps (index.js:10835:1)
93
- at JSXParserMixin.parseMaybeConditional (index.js:10812:1)
94
- at JSXParserMixin.parseMaybeAssign (index.js:10765:1)
95
- at index.js:10734:1
96
- at JSXParserMixin.allowInAnd (index.js:12361:1)
97
- at JSXParserMixin.parseMaybeAssignAllowIn (index.js:10734:1)
98
- at JSXParserMixin.parseParenAndDistinguishExpression (index.js:11608:1)
99
- at JSXParserMixin.parseExprAtom (index.js:11262:1)
100
- at JSXParserMixin.parseExprAtom (index.js:4776:1)
101
- at JSXParserMixin.parseExprSubscripts (index.js:11012:1)
102
- at JSXParserMixin.parseUpdate (index.js:10997:1)
103
- at JSXParserMixin.parseMaybeUnary (index.js:10977:1)
104
- at JSXParserMixin.parseMaybeUnaryOrPrivate (index.js:10830:1)
105
- at JSXParserMixin.parseExprOps (index.js:10835:1)
106
- at JSXParserMixin.parseMaybeConditional (index.js:10812:1)
107
- at JSXParserMixin.parseMaybeAssign (index.js:10765:1)
108
- at index.js:10734:1
109
- at JSXParserMixin.allowInAnd (index.js:12361:1)
110
- at JSXParserMixin.parseMaybeAssignAllowIn (index.js:10734:1)
111
- at JSXParserMixin.parseObjectProperty (index.js:11885:1)
112
- at JSXParserMixin.parseObjPropValue (index.js:11913:1)
113
- at JSXParserMixin.parsePropertyDefinition (index.js:11850:1)
114
- at JSXParserMixin.parseObjectLike (index.js:11765:1)
115
- at JSXParserMixin.parseExprAtom (index.js:11270:1)
116
- at JSXParserMixin.parseExprAtom (index.js:4776:1)
117
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/PositionMgt.js (7.80ms)
118
- swc-parser.ts:666 [SWC] ����ʧ�ܣ����˵� Babel:
119
- x Unexpected token `Page`. Expected jsx identifier
120
- ,-[8:1]
121
-  8 | * interfaceName: ��ѯ��Ա�ӿ�
122
-  9 | * interface: /los/${appName}.listUser
123
- 10 | * RESOURCESTREE-END
124
- 11 | */<Page data-dnd="%2Fsrc%2Fpages%2FDepartmentMgt.js:Page:pagec977" onMount={() => {$function.department?.getDepartmentTree?.();$function.department.getDepartmentListUser();}} access={{ relatedInterfaces: [{ label: "��ȡ�������ӿ�", value: "/los/${appName}.listDepartmentTree" }, { label: "��ѯ��Ա�ӿ�", value: "/los/${appName}.listUser" }] }} className="deptMgt-page">
125
- :  ^^^^
126
- 12 |
127
- 13 |
128
- `----
129
-
130
-
131
- Caused by:
132
- 0: failed to parse code
133
- 1: Syntax Error
134
- parseWithSWC @ swc-parser.ts:666
135
- parseCode @ ast-cache.ts:740
136
- parseSync @ ast-cache.ts:933
137
- code2astWithCache @ ast-cache.ts:1277
138
- code2astCached @ parse.ts:112
139
- get @ light-module.ts:91
140
- get @ light-module.ts:107
141
- trackDerivedFunction @ mobx.esm.js:1842
142
- computeValue_ @ mobx.esm.js:1636
143
- trackAndCompute @ mobx.esm.js:1613
144
- get @ mobx.esm.js:1582
145
- getObservablePropValue_ @ mobx.esm.js:4744
146
- get @ mobx.esm.js:5243
147
- hasModelDiff @ workspace.ts:3262
148
- (anonymous) @ useFolder.tsx:71
149
- makeFileTree @ useFolder.tsx:64
150
- useFolder @ useFolder.tsx:303
151
- (anonymous) @ index.tsx:65
152
- (anonymous) @ observer.js:44
153
- (anonymous) @ useObserver.js:80
154
- trackDerivedFunction @ mobx.esm.js:1842
155
- track @ mobx.esm.js:2360
156
- useObserver @ useObserver.js:78
157
- (anonymous) @ observer.js:44
158
- renderWithHooks @ react-dom.development.js:15015
159
- updateFunctionComponent @ react-dom.development.js:17386
160
- updateSimpleMemoComponent @ react-dom.development.js:17245
161
- beginWork @ react-dom.development.js:19170
162
- beginWork$1 @ react-dom.development.js:23970
163
- performUnitOfWork @ react-dom.development.js:22809
164
- workLoopSync @ react-dom.development.js:22737
165
- renderRootSync @ react-dom.development.js:22700
166
- performSyncWorkOnRoot @ react-dom.development.js:22323
167
- (anonymous) @ react-dom.development.js:11357
168
- unstable_runWithPriority @ react.development.js:2764
169
- runWithPriority$1 @ react-dom.development.js:11306
170
- flushSyncCallbackQueueImpl @ react-dom.development.js:11352
171
- flushSyncCallbackQueue @ react-dom.development.js:11339
172
- discreteUpdates$1 @ react-dom.development.js:22450
173
- discreteUpdates @ react-dom.development.js:3753
174
- dispatchDiscreteEvent @ react-dom.development.js:5919
175
- light-module.ts:99 SyntaxError: Unexpected token (23:233) (at index.js:363:1)
176
- at constructor (index.js:363:1)
177
- at JSXParserMixin.raise (index.js:6609:1)
178
- at JSXParserMixin.unexpected (index.js:6629:1)
179
- at JSXParserMixin.parseExprAtom (index.js:11378:1)
180
- at JSXParserMixin.parseExprAtom (index.js:4776:1)
181
- at JSXParserMixin.parseExprSubscripts (index.js:11012:1)
182
- at JSXParserMixin.parseUpdate (index.js:10997:1)
183
- at JSXParserMixin.parseMaybeUnary (index.js:10977:1)
184
- at JSXParserMixin.parseMaybeUnaryOrPrivate (index.js:10830:1)
185
- at JSXParserMixin.parseExprOps (index.js:10835:1)
186
- at JSXParserMixin.parseMaybeConditional (index.js:10812:1)
187
- at JSXParserMixin.parseMaybeAssign (index.js:10765:1)
188
- at index.js:10734:1
189
- at JSXParserMixin.allowInAnd (index.js:12361:1)
190
- at JSXParserMixin.parseMaybeAssignAllowIn (index.js:10734:1)
191
- at JSXParserMixin.parseObjectProperty (index.js:11885:1)
192
- at JSXParserMixin.parseObjPropValue (index.js:11913:1)
193
- at JSXParserMixin.parsePropertyDefinition (index.js:11850:1)
194
- at JSXParserMixin.parseObjectLike (index.js:11765:1)
195
- at JSXParserMixin.parseExprAtom (index.js:11270:1)
196
- at JSXParserMixin.parseExprAtom (index.js:4776:1)
197
- at JSXParserMixin.parseExprSubscripts (index.js:11012:1)
198
- at JSXParserMixin.parseUpdate (index.js:10997:1)
199
- at JSXParserMixin.parseMaybeUnary (index.js:10977:1)
200
- at JSXParserMixin.parseMaybeUnaryOrPrivate (index.js:10830:1)
201
- at JSXParserMixin.parseExprOps (index.js:10835:1)
202
- at JSXParserMixin.parseMaybeConditional (index.js:10812:1)
203
- at JSXParserMixin.parseMaybeAssign (index.js:10765:1)
204
- at index.js:10734:1
205
- at JSXParserMixin.allowInAnd (index.js:12361:1)
206
- at JSXParserMixin.parseMaybeAssignAllowIn (index.js:10734:1)
207
- at JSXParserMixin.parseParenAndDistinguishExpression (index.js:11608:1)
208
- at JSXParserMixin.parseExprAtom (index.js:11262:1)
209
- at JSXParserMixin.parseExprAtom (index.js:4776:1)
210
- at JSXParserMixin.parseExprSubscripts (index.js:11012:1)
211
- at JSXParserMixin.parseUpdate (index.js:10997:1)
212
- at JSXParserMixin.parseMaybeUnary (index.js:10977:1)
213
- at JSXParserMixin.parseMaybeUnaryOrPrivate (index.js:10830:1)
214
- at JSXParserMixin.parseExprOps (index.js:10835:1)
215
- at JSXParserMixin.parseMaybeConditional (index.js:10812:1)
216
- at JSXParserMixin.parseMaybeAssign (index.js:10765:1)
217
- at JSXParserMixin.parseExpressionBase (index.js:10718:1)
218
- at index.js:10714:1
219
- at JSXParserMixin.allowInAnd (index.js:12361:1)
220
- at JSXParserMixin.parseExpression (index.js:10714:1)
221
- at JSXParserMixin.jsxParseExpressionContainer (index.js:4644:1)
222
- at JSXParserMixin.jsxParseAttributeValue (index.js:4616:1)
223
- at JSXParserMixin.jsxParseAttribute (index.js:4665:1)
224
- at JSXParserMixin.jsxParseOpeningElementAfterName (index.js:4679:1)
225
- at JSXParserMixin.jsxParseOpeningElementAt (index.js:4674:1)
226
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/UserMgt.js (2.40ms)
227
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/ResourceMgt.js (0.90ms)
228
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/createItem.js (4.40ms)
229
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/traceTask.js (4.50ms)
230
- swc-parser.ts:666 [SWC] ����ʧ�ܣ����˵� Babel:
231
- x Unexpected token `}`. Expected yield, an identifier, [ or {
232
- ,-[1:1]
233
- 1 | import React from "react";import { definePage } from "@loview/lowcode-react-boot";import { Page } from "@loview/lowcode-react-antd";import WorkFlowProcessConfigPage from "../components/WorkFlowProcessTrace/index.js";class App extends React.Component {render() {const { match: } = this.props;const id = match.params?.id;return (/**
234
- :  ^
235
- 2 | * RESOURCESTREE-START
236
- 3 | * interfaces:
237
- 4 | * -
238
- `----
239
-
240
-
241
- Caused by:
242
- 0: failed to parse code
243
- 1: Syntax Error
244
- parseWithSWC @ swc-parser.ts:666
245
- parseCode @ ast-cache.ts:740
246
- parseSync @ ast-cache.ts:933
247
- code2astWithCache @ ast-cache.ts:1277
248
- code2astCached @ parse.ts:112
249
- get @ light-module.ts:91
250
- get @ light-module.ts:107
251
- trackDerivedFunction @ mobx.esm.js:1842
252
- computeValue_ @ mobx.esm.js:1636
253
- trackAndCompute @ mobx.esm.js:1613
254
- get @ mobx.esm.js:1582
255
- getObservablePropValue_ @ mobx.esm.js:4744
256
- get @ mobx.esm.js:5243
257
- hasModelDiff @ workspace.ts:3262
258
- (anonymous) @ useFolder.tsx:71
259
- makeFileTree @ useFolder.tsx:64
260
- useFolder @ useFolder.tsx:303
261
- (anonymous) @ index.tsx:65
262
- (anonymous) @ observer.js:44
263
- (anonymous) @ useObserver.js:80
264
- trackDerivedFunction @ mobx.esm.js:1842
265
- track @ mobx.esm.js:2360
266
- useObserver @ useObserver.js:78
267
- (anonymous) @ observer.js:44
268
- renderWithHooks @ react-dom.development.js:15015
269
- updateFunctionComponent @ react-dom.development.js:17386
270
- updateSimpleMemoComponent @ react-dom.development.js:17245
271
- beginWork @ react-dom.development.js:19170
272
- beginWork$1 @ react-dom.development.js:23970
273
- performUnitOfWork @ react-dom.development.js:22809
274
- workLoopSync @ react-dom.development.js:22737
275
- renderRootSync @ react-dom.development.js:22700
276
- performSyncWorkOnRoot @ react-dom.development.js:22323
277
- (anonymous) @ react-dom.development.js:11357
278
- unstable_runWithPriority @ react.development.js:2764
279
- runWithPriority$1 @ react-dom.development.js:11306
280
- flushSyncCallbackQueueImpl @ react-dom.development.js:11352
281
- flushSyncCallbackQueue @ react-dom.development.js:11339
282
- discreteUpdates$1 @ react-dom.development.js:22450
283
- discreteUpdates @ react-dom.development.js:3753
284
- dispatchDiscreteEvent @ react-dom.development.js:5919
285
- light-module.ts:99 SyntaxError: Unexpected token (1:276) (at index.js:363:1)
286
- at constructor (index.js:363:1)
287
- at JSXParserMixin.raise (index.js:6609:1)
288
- at JSXParserMixin.unexpected (index.js:6629:1)
289
- at JSXParserMixin.parseIdentifierName (index.js:12138:1)
290
- at JSXParserMixin.parseIdentifier (index.js:12116:1)
291
- at JSXParserMixin.parseBindingAtom (index.js:7345:1)
292
- at JSXParserMixin.parseMaybeDefault (index.js:7428:1)
293
- at JSXParserMixin.parseObjectProperty (index.js:11885:1)
294
- at JSXParserMixin.parseObjPropValue (index.js:11913:1)
295
- at JSXParserMixin.parseBindingProperty (index.js:7409:1)
296
- at JSXParserMixin.parseObjectLike (index.js:11763:1)
297
- at JSXParserMixin.parseBindingAtom (index.js:7343:1)
298
- at JSXParserMixin.parseVarId (index.js:13321:1)
299
- at JSXParserMixin.parseVar (index.js:13302:1)
300
- at JSXParserMixin.parseVarStatement (index.js:13149:1)
301
- at JSXParserMixin.parseStatementContent (index.js:12770:1)
302
- at JSXParserMixin.parseStatementLike (index.js:12685:1)
303
- at JSXParserMixin.parseStatementListItem (index.js:12665:1)
304
- at JSXParserMixin.parseBlockOrModuleBlockBody (index.js:13235:1)
305
- at JSXParserMixin.parseBlockBody (index.js:13228:1)
306
- at JSXParserMixin.parseBlock (index.js:13216:1)
307
- at JSXParserMixin.parseFunctionBody (index.js:12035:1)
308
- at JSXParserMixin.parseFunctionBodyAndFinish (index.js:12021:1)
309
- at JSXParserMixin.parseMethod (index.js:11979:1)
310
- at JSXParserMixin.pushClassMethod (index.js:13642:1)
311
- at JSXParserMixin.parseClassMemberWithIsStatic (index.js:13530:1)
312
- at JSXParserMixin.parseClassMember (index.js:13478:1)
313
- at index.js:13432:1
314
- at JSXParserMixin.withSmartMixTopicForbiddingContext (index.js:12338:1)
315
- at JSXParserMixin.parseClassBody (index.js:13414:1)
316
- at JSXParserMixin.parseClass (index.js:13389:1)
317
- at JSXParserMixin.parseStatementContent (index.js:12712:1)
318
- at JSXParserMixin.parseStatementLike (index.js:12685:1)
319
- at JSXParserMixin.parseModuleItem (index.js:12662:1)
320
- at JSXParserMixin.parseBlockOrModuleBlockBody (index.js:13235:1)
321
- at JSXParserMixin.parseBlockBody (index.js:13228:1)
322
- at JSXParserMixin.parseProgram (index.js:12541:1)
323
- at JSXParserMixin.parseTopLevel (index.js:12531:1)
324
- at JSXParserMixin.parse (index.js:14410:1)
325
- at parse (index.js:14444:1)
326
- at parseWithSWC (swc-parser.ts:668:1)
327
- at ASTCache.parseCode (ast-cache.ts:740:1)
328
- at ASTCache.parseSync (ast-cache.ts:933:1)
329
- at code2astWithCache (ast-cache.ts:1277:1)
330
- at code2astCached (parse.ts:112:1)
331
- at LowCodeLightModule.get (light-module.ts:91:1)
332
- at LowCodeLightModule.get (light-module.ts:107:1)
333
- at trackDerivedFunction (mobx.esm.js:1842:1)
334
- at ComputedValue.computeValue_ (mobx.esm.js:1636:1)
335
- at ComputedValue.trackAndCompute (mobx.esm.js:1613:1)
336
- swc-parser.ts:666 [SWC] ����ʧ�ܣ����˵� Babel:
337
- x Unexpected token `,`. Expected yield, an identifier, [ or {
338
- ,-[1:1]
339
- 1 | import React from "react";import { definePage } from "@loview/lowcode-react-boot";import { getParamsFromRoute } from "../utils";import { Page, Button, Row, Section, Space, Table, Block } from "@loview/lowcode-react-antd";import Modal390 from "./ImportDetailModals/modal390.js";import Modal922 from "./ImportDetailModals/modal922.js";import Modal178 from "./ImportDetailModals/modal178.js";import Modal210 from "./ImportDetailModals/modal210.js";import Modal889 from "./ImportDetailModals/modal889.js";class App extends React.Component {render() {const { location: , match: } = this.props;const id = match.params?.id;const searchParams = getParamsFromRoute(location.search);const readonly = searchParams?.readonly === "true";return (/**
340
- :  ^
341
- 2 | * RESOURCESTREE-START
342
- 3 | * interfaces:
343
- 4 | * -
344
- `----
345
-
346
-
347
- Caused by:
348
- 0: failed to parse code
349
- 1: Syntax Error
350
- parseWithSWC @ swc-parser.ts:666
351
- parseCode @ ast-cache.ts:740
352
- parseSync @ ast-cache.ts:933
353
- code2astWithCache @ ast-cache.ts:1277
354
- code2astCached @ parse.ts:112
355
- get @ light-module.ts:91
356
- get @ light-module.ts:107
357
- trackDerivedFunction @ mobx.esm.js:1842
358
- computeValue_ @ mobx.esm.js:1636
359
- trackAndCompute @ mobx.esm.js:1613
360
- get @ mobx.esm.js:1582
361
- getObservablePropValue_ @ mobx.esm.js:4744
362
- get @ mobx.esm.js:5243
363
- hasModelDiff @ workspace.ts:3262
364
- (anonymous) @ useFolder.tsx:71
365
- makeFileTree @ useFolder.tsx:64
366
- useFolder @ useFolder.tsx:303
367
- (anonymous) @ index.tsx:65
368
- (anonymous) @ observer.js:44
369
- (anonymous) @ useObserver.js:80
370
- trackDerivedFunction @ mobx.esm.js:1842
371
- track @ mobx.esm.js:2360
372
- useObserver @ useObserver.js:78
373
- (anonymous) @ observer.js:44
374
- renderWithHooks @ react-dom.development.js:15015
375
- updateFunctionComponent @ react-dom.development.js:17386
376
- updateSimpleMemoComponent @ react-dom.development.js:17245
377
- beginWork @ react-dom.development.js:19170
378
- beginWork$1 @ react-dom.development.js:23970
379
- performUnitOfWork @ react-dom.development.js:22809
380
- workLoopSync @ react-dom.development.js:22737
381
- renderRootSync @ react-dom.development.js:22700
382
- performSyncWorkOnRoot @ react-dom.development.js:22323
383
- (anonymous) @ react-dom.development.js:11357
384
- unstable_runWithPriority @ react.development.js:2764
385
- runWithPriority$1 @ react-dom.development.js:11306
386
- flushSyncCallbackQueueImpl @ react-dom.development.js:11352
387
- flushSyncCallbackQueue @ react-dom.development.js:11339
388
- discreteUpdates$1 @ react-dom.development.js:22450
389
- discreteUpdates @ react-dom.development.js:3753
390
- dispatchDiscreteEvent @ react-dom.development.js:5919
391
- light-module.ts:99 SyntaxError: Unexpected token (1:564) (at index.js:363:1)
392
- at constructor (index.js:363:1)
393
- at JSXParserMixin.raise (index.js:6609:1)
394
- at JSXParserMixin.unexpected (index.js:6629:1)
395
- at JSXParserMixin.parseIdentifierName (index.js:12138:1)
396
- at JSXParserMixin.parseIdentifier (index.js:12116:1)
397
- at JSXParserMixin.parseBindingAtom (index.js:7345:1)
398
- at JSXParserMixin.parseMaybeDefault (index.js:7428:1)
399
- at JSXParserMixin.parseObjectProperty (index.js:11885:1)
400
- at JSXParserMixin.parseObjPropValue (index.js:11913:1)
401
- at JSXParserMixin.parseBindingProperty (index.js:7409:1)
402
- at JSXParserMixin.parseObjectLike (index.js:11763:1)
403
- at JSXParserMixin.parseBindingAtom (index.js:7343:1)
404
- at JSXParserMixin.parseVarId (index.js:13321:1)
405
- at JSXParserMixin.parseVar (index.js:13302:1)
406
- at JSXParserMixin.parseVarStatement (index.js:13149:1)
407
- at JSXParserMixin.parseStatementContent (index.js:12770:1)
408
- at JSXParserMixin.parseStatementLike (index.js:12685:1)
409
- at JSXParserMixin.parseStatementListItem (index.js:12665:1)
410
- at JSXParserMixin.parseBlockOrModuleBlockBody (index.js:13235:1)
411
- at JSXParserMixin.parseBlockBody (index.js:13228:1)
412
- at JSXParserMixin.parseBlock (index.js:13216:1)
413
- at JSXParserMixin.parseFunctionBody (index.js:12035:1)
414
- at JSXParserMixin.parseFunctionBodyAndFinish (index.js:12021:1)
415
- at JSXParserMixin.parseMethod (index.js:11979:1)
416
- at JSXParserMixin.pushClassMethod (index.js:13642:1)
417
- at JSXParserMixin.parseClassMemberWithIsStatic (index.js:13530:1)
418
- at JSXParserMixin.parseClassMember (index.js:13478:1)
419
- at index.js:13432:1
420
- at JSXParserMixin.withSmartMixTopicForbiddingContext (index.js:12338:1)
421
- at JSXParserMixin.parseClassBody (index.js:13414:1)
422
- at JSXParserMixin.parseClass (index.js:13389:1)
423
- at JSXParserMixin.parseStatementContent (index.js:12712:1)
424
- at JSXParserMixin.parseStatementLike (index.js:12685:1)
425
- at JSXParserMixin.parseModuleItem (index.js:12662:1)
426
- at JSXParserMixin.parseBlockOrModuleBlockBody (index.js:13235:1)
427
- at JSXParserMixin.parseBlockBody (index.js:13228:1)
428
- at JSXParserMixin.parseProgram (index.js:12541:1)
429
- at JSXParserMixin.parseTopLevel (index.js:12531:1)
430
- at JSXParserMixin.parse (index.js:14410:1)
431
- at parse (index.js:14444:1)
432
- at parseWithSWC (swc-parser.ts:668:1)
433
- at ASTCache.parseCode (ast-cache.ts:740:1)
434
- at ASTCache.parseSync (ast-cache.ts:933:1)
435
- at code2astWithCache (ast-cache.ts:1277:1)
436
- at code2astCached (parse.ts:112:1)
437
- at LowCodeLightModule.get (light-module.ts:91:1)
438
- at LowCodeLightModule.get (light-module.ts:107:1)
439
- at trackDerivedFunction (mobx.esm.js:1842:1)
440
- at ComputedValue.computeValue_ (mobx.esm.js:1636:1)
441
- at ComputedValue.trackAndCompute (mobx.esm.js:1613:1)
442
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/UpdatePwd.js (0.80ms)
443
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/getTechItem.js (8.10ms)
444
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/createDemo.js (1.40ms)
445
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/createTechRequirement.js (3.90ms)
446
- swc-parser.ts:666 [SWC] ����ʧ�ܣ����˵� Babel:
447
- x Unexpected token `Page`. Expected jsx identifier
448
- ,-[1:1]
449
- 1 | import React from "react";import { definePage } from "@loview/lowcode-react-boot";import { Page, QueryPage, Section, Row, Col, FForm, FFormItem, FFormFooter, FReset, FSubmit, Space, Button, Table, Descriptions } from "@loview/lowcode-react-antd";import ReadModal from "./techReqDemoModals/ReadModal.js";import CreateModal from "./techReqDemoModals/CreateModal.js";import UpdateModal from "./techReqDemoModals/UpdateModal.js";class App extends React.Component {render() {return (<Page data-dnd="%2Fsrc%2Fpages%2FtechReqDemo.js:Page:page5567">
450
- :  ^^^^
451
- 2 |
452
- 3 | <div data-dnd="%2Fsrc%2Fpages%2FtechReqDemo.js:div:techRequirementd428" data-meta="TechRequirement" tid="techRequirementd428" data-name="TechRequirement" data-tag="MetaContext">
453
- `----
454
-
455
-
456
- Caused by:
457
- 0: failed to parse code
458
- 1: Syntax Error
459
- parseWithSWC @ swc-parser.ts:666
460
- parseCode @ ast-cache.ts:740
461
- parseSync @ ast-cache.ts:933
462
- code2astWithCache @ ast-cache.ts:1277
463
- code2astCached @ parse.ts:112
464
- get @ light-module.ts:91
465
- get @ light-module.ts:107
466
- trackDerivedFunction @ mobx.esm.js:1842
467
- computeValue_ @ mobx.esm.js:1636
468
- trackAndCompute @ mobx.esm.js:1613
469
- get @ mobx.esm.js:1582
470
- getObservablePropValue_ @ mobx.esm.js:4744
471
- get @ mobx.esm.js:5243
472
- hasDiff @ workspace.ts:3245
473
- (anonymous) @ useFolder.tsx:71
474
- makeFileTree @ useFolder.tsx:64
475
- useFolder @ useFolder.tsx:303
476
- (anonymous) @ index.tsx:65
477
- (anonymous) @ observer.js:44
478
- (anonymous) @ useObserver.js:80
479
- trackDerivedFunction @ mobx.esm.js:1842
480
- track @ mobx.esm.js:2360
481
- useObserver @ useObserver.js:78
482
- (anonymous) @ observer.js:44
483
- renderWithHooks @ react-dom.development.js:15015
484
- updateFunctionComponent @ react-dom.development.js:17386
485
- updateSimpleMemoComponent @ react-dom.development.js:17245
486
- beginWork @ react-dom.development.js:19170
487
- beginWork$1 @ react-dom.development.js:23970
488
- performUnitOfWork @ react-dom.development.js:22809
489
- workLoopSync @ react-dom.development.js:22737
490
- renderRootSync @ react-dom.development.js:22700
491
- performSyncWorkOnRoot @ react-dom.development.js:22323
492
- (anonymous) @ react-dom.development.js:11357
493
- unstable_runWithPriority @ react.development.js:2764
494
- runWithPriority$1 @ react-dom.development.js:11306
495
- flushSyncCallbackQueueImpl @ react-dom.development.js:11352
496
- flushSyncCallbackQueue @ react-dom.development.js:11339
497
- discreteUpdates$1 @ react-dom.development.js:22450
498
- discreteUpdates @ react-dom.development.js:3753
499
- dispatchDiscreteEvent @ react-dom.development.js:5919
500
- light-module.ts:99 SyntaxError: Unexpected token (289:4498) (at index.js:363:1)
501
- at constructor (index.js:363:1)
502
- at JSXParserMixin.raise (index.js:6609:1)
503
- at JSXParserMixin.unexpected (index.js:6629:1)
504
- at JSXParserMixin.parseExprAtom (index.js:11378:1)
505
- at JSXParserMixin.parseExprAtom (index.js:4776:1)
506
- at JSXParserMixin.parseExprSubscripts (index.js:11012:1)
507
- at JSXParserMixin.parseUpdate (index.js:10997:1)
508
- at JSXParserMixin.parseMaybeUnary (index.js:10977:1)
509
- at JSXParserMixin.parseMaybeUnaryOrPrivate (index.js:10830:1)
510
- at JSXParserMixin.parseExprOps (index.js:10835:1)
511
- at JSXParserMixin.parseMaybeConditional (index.js:10812:1)
512
- at JSXParserMixin.parseMaybeAssign (index.js:10765:1)
513
- at index.js:10734:1
514
- at JSXParserMixin.allowInAnd (index.js:12361:1)
515
- at JSXParserMixin.parseMaybeAssignAllowIn (index.js:10734:1)
516
- at JSXParserMixin.parseObjectProperty (index.js:11885:1)
517
- at JSXParserMixin.parseObjPropValue (index.js:11913:1)
518
- at JSXParserMixin.parsePropertyDefinition (index.js:11850:1)
519
- at JSXParserMixin.parseObjectLike (index.js:11765:1)
520
- at JSXParserMixin.parseExprAtom (index.js:11270:1)
521
- at JSXParserMixin.parseExprAtom (index.js:4776:1)
522
- at JSXParserMixin.parseExprSubscripts (index.js:11012:1)
523
- at JSXParserMixin.parseUpdate (index.js:10997:1)
524
- at JSXParserMixin.parseMaybeUnary (index.js:10977:1)
525
- at JSXParserMixin.parseMaybeUnaryOrPrivate (index.js:10830:1)
526
- at JSXParserMixin.parseExprOps (index.js:10835:1)
527
- at JSXParserMixin.parseMaybeConditional (index.js:10812:1)
528
- at JSXParserMixin.parseMaybeAssign (index.js:10765:1)
529
- at index.js:10734:1
530
- at JSXParserMixin.allowInAnd (index.js:12361:1)
531
- at JSXParserMixin.parseMaybeAssignAllowIn (index.js:10734:1)
532
- at JSXParserMixin.parseParenAndDistinguishExpression (index.js:11608:1)
533
- at JSXParserMixin.parseExprAtom (index.js:11262:1)
534
- at JSXParserMixin.parseExprAtom (index.js:4776:1)
535
- at JSXParserMixin.parseExprSubscripts (index.js:11012:1)
536
- at JSXParserMixin.parseUpdate (index.js:10997:1)
537
- at JSXParserMixin.parseMaybeUnary (index.js:10977:1)
538
- at JSXParserMixin.parseMaybeUnaryOrPrivate (index.js:10830:1)
539
- at JSXParserMixin.parseExprOps (index.js:10835:1)
540
- at JSXParserMixin.parseMaybeConditional (index.js:10812:1)
541
- at JSXParserMixin.parseMaybeAssign (index.js:10765:1)
542
- at index.js:10734:1
543
- at JSXParserMixin.allowInAnd (index.js:12361:1)
544
- at JSXParserMixin.parseMaybeAssignAllowIn (index.js:10734:1)
545
- at JSXParserMixin.parseObjectProperty (index.js:11885:1)
546
- at JSXParserMixin.parseObjPropValue (index.js:11913:1)
547
- at JSXParserMixin.parsePropertyDefinition (index.js:11850:1)
548
- at JSXParserMixin.parseObjectLike (index.js:11765:1)
549
- at JSXParserMixin.parseExprAtom (index.js:11270:1)
550
- at JSXParserMixin.parseExprAtom (index.js:4776:1)
551
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/techReqCreateDemo.js (5.50ms)
552
- ast-cache.ts:944 [ASTCache] Parse miss (SWC) - /src/pages/techReqDetail.js (1.30ms)
553
- sandbox.tsx:193 [useSandbox] Setting eventHandlers to sandboxProps, count: 13
554
- index.tsx:92 [CodeSandbox] eventHandlers comparison: {changed: false, prevKeys: Array(13), nextKeys: Array(13), iframeReady: true}
555
- sandbox.tsx:193 [useSandbox] Setting eventHandlers to sandboxProps, count: 13
556
- index.tsx:92 [CodeSandbox] eventHandlers comparison: {changed: false, prevKeys: Array(13), nextKeys: Array(13), iframeReady: true}
1
+ /**
2
+ * SWC ��������װ
3
+ *
4
+ * SWC ���� Rust ��д�ij��� JavaScript/TypeScript ������
5
+ * �� Babel �� 20-70 ��
6
+ *
7
+ * ��ģ���ṩ��
8
+ * 1. SWC WASM ��ʼ��
9
+ * 2. SWC AST �� Babel AST ��ת��
10
+ * 3. ���˵� Babel �ļ��ݻ���
11
+ */
12
+
13
+ import * as t from '@babel/types';
14
+ import { parse as babelParse, ParserOptions } from '@babel/parser';
15
+
16
+ // SWC WASM �
17
+ let swcModule: typeof import('@swc/wasm-web') | null = null;
18
+ let swcInitPromise: Promise<void> | null = null;
19
+ let swcAvailable = false;
20
+
21
+ // Babel �������ã������ã�
22
+ const babelParserConfig: ParserOptions = {
23
+ sourceType: 'module',
24
+ plugins: [
25
+ 'jsx',
26
+ 'doExpressions',
27
+ 'objectRestSpread',
28
+ 'decorators-legacy',
29
+ 'classProperties',
30
+ 'asyncGenerators',
31
+ 'functionBind',
32
+ 'dynamicImport',
33
+ 'optionalChaining',
34
+ ],
35
+ };
36
+
37
+ // SWC ��������
38
+ const swcParserConfig = {
39
+ syntax: 'typescript' as const,
40
+ tsx: true,
41
+ decorators: true,
42
+ dynamicImport: true,
43
+ };
44
+
45
+ const permissionCommentInJSXPattern = /\/\*\*[\s\S]*?RESOURCESTREE-START[\s\S]*?RESOURCESTREE-END[\s\S]*?\*\/(?=\s*<)/g;
46
+
47
+ function sanitizePermissionCommentsForJSX(code: string) {
48
+ return code.replace(permissionCommentInJSXPattern, (comment) => {
49
+ const inner = comment
50
+ .replace(/^\/\*\*?/, '')
51
+ .replace(/\*\/$/, '');
52
+ return `{/*${inner}*/}`;
53
+ });
54
+ }
55
+
56
+ // ����ͳ��
57
+ const swcStats = {
58
+ swcParseCount: 0,
59
+ swcTotalTime: 0,
60
+ babelFallbackCount: 0,
61
+ babelTotalTime: 0,
62
+ conversionCount: 0,
63
+ conversionTotalTime: 0,
64
+ };
65
+
66
+ /**
67
+ * ��ʼ�� SWC WASM ģ��
68
+ */
69
+ export async function initSWC(): Promise<boolean> {
70
+ if (swcAvailable) return true;
71
+ if (swcInitPromise) {
72
+ await swcInitPromise;
73
+ return swcAvailable;
74
+ }
75
+
76
+ swcInitPromise = (async () => {
77
+ try {
78
+ // ��̬���� SWC WASM
79
+ const swc = await import('@swc/wasm-web');
80
+
81
+ // ��ʼ�� WASM����Ҫ���� .wasm �ļ���
82
+ await swc.default();
83
+
84
+ swcModule = swc;
85
+ swcAvailable = true;
86
+ console.log('%c[SWC] ? WASM ģ���ʼ���ɹ�', 'color: #4CAF50; font-weight: bold;');
87
+ } catch (error) {
88
+ console.warn('[SWC] ?? WASM ģ�����ʧ�ܣ���ʹ�� Babel ��Ϊ����:', error);
89
+ swcAvailable = false;
90
+ }
91
+ })();
92
+
93
+ await swcInitPromise;
94
+ return swcAvailable;
95
+ }
96
+
97
+ /**
98
+ * ��� SWC �Ƿ����
99
+ */
100
+ export function isSWCAvailable(): boolean {
101
+ return swcAvailable;
102
+ }
103
+
104
+ /**
105
+ * SWC AST �ڵ�����ӳ�䵽 Babel ����
106
+ */
107
+ const SWC_TO_BABEL_TYPE: Record<string, string> = {
108
+ 'Module': 'File',
109
+ 'Script': 'File',
110
+ 'ImportDeclaration': 'ImportDeclaration',
111
+ 'ExportDeclaration': 'ExportDeclaration',
112
+ 'ExportDefaultDeclaration': 'ExportDefaultDeclaration',
113
+ 'ExportDefaultExpression': 'ExportDefaultDeclaration',
114
+ 'ExportNamedDeclaration': 'ExportNamedDeclaration',
115
+ 'ExportAllDeclaration': 'ExportAllDeclaration',
116
+ 'VariableDeclaration': 'VariableDeclaration',
117
+ 'VariableDeclarator': 'VariableDeclarator',
118
+ 'FunctionDeclaration': 'FunctionDeclaration',
119
+ 'FunctionExpression': 'FunctionExpression',
120
+ 'ArrowFunctionExpression': 'ArrowFunctionExpression',
121
+ 'ClassDeclaration': 'ClassDeclaration',
122
+ 'ClassExpression': 'ClassExpression',
123
+ 'ClassMethod': 'ClassMethod',
124
+ 'ClassPrivateMethod': 'ClassPrivateMethod',
125
+ 'ClassProperty': 'ClassProperty',
126
+ 'ClassPrivateProperty': 'ClassPrivateProperty',
127
+ 'Constructor': 'ClassMethod',
128
+ 'PrivateName': 'PrivateName',
129
+ 'Identifier': 'Identifier',
130
+ 'StringLiteral': 'StringLiteral',
131
+ 'NumericLiteral': 'NumericLiteral',
132
+ 'BooleanLiteral': 'BooleanLiteral',
133
+ 'NullLiteral': 'NullLiteral',
134
+ 'RegExpLiteral': 'RegExpLiteral',
135
+ 'TemplateLiteral': 'TemplateLiteral',
136
+ 'ArrayExpression': 'ArrayExpression',
137
+ 'ObjectExpression': 'ObjectExpression',
138
+ 'CallExpression': 'CallExpression',
139
+ 'MemberExpression': 'MemberExpression',
140
+ 'BinaryExpression': 'BinaryExpression',
141
+ 'UnaryExpression': 'UnaryExpression',
142
+ 'ConditionalExpression': 'ConditionalExpression',
143
+ 'AssignmentExpression': 'AssignmentExpression',
144
+ 'LogicalExpression': 'LogicalExpression',
145
+ 'SequenceExpression': 'SequenceExpression',
146
+ 'NewExpression': 'NewExpression',
147
+ 'ThisExpression': 'ThisExpression',
148
+ 'SpreadElement': 'SpreadElement',
149
+ 'RestElement': 'RestElement',
150
+ 'ObjectPattern': 'ObjectPattern',
151
+ 'ArrayPattern': 'ArrayPattern',
152
+ 'AssignmentPattern': 'AssignmentPattern',
153
+ 'BlockStatement': 'BlockStatement',
154
+ 'ReturnStatement': 'ReturnStatement',
155
+ 'IfStatement': 'IfStatement',
156
+ 'SwitchStatement': 'SwitchStatement',
157
+ 'SwitchCase': 'SwitchCase',
158
+ 'ForStatement': 'ForStatement',
159
+ 'ForInStatement': 'ForInStatement',
160
+ 'ForOfStatement': 'ForOfStatement',
161
+ 'WhileStatement': 'WhileStatement',
162
+ 'DoWhileStatement': 'DoWhileStatement',
163
+ 'TryStatement': 'TryStatement',
164
+ 'CatchClause': 'CatchClause',
165
+ 'ThrowStatement': 'ThrowStatement',
166
+ 'BreakStatement': 'BreakStatement',
167
+ 'ContinueStatement': 'ContinueStatement',
168
+ 'ExpressionStatement': 'ExpressionStatement',
169
+ 'EmptyStatement': 'EmptyStatement',
170
+ 'DebuggerStatement': 'DebuggerStatement',
171
+ 'LabeledStatement': 'LabeledStatement',
172
+ 'WithStatement': 'WithStatement',
173
+ // JSX
174
+ 'JSXElement': 'JSXElement',
175
+ 'JSXFragment': 'JSXFragment',
176
+ 'JSXOpeningElement': 'JSXOpeningElement',
177
+ 'JSXClosingElement': 'JSXClosingElement',
178
+ 'JSXOpeningFragment': 'JSXOpeningFragment',
179
+ 'JSXClosingFragment': 'JSXClosingFragment',
180
+ 'JSXAttribute': 'JSXAttribute',
181
+ 'JSXSpreadAttribute': 'JSXSpreadAttribute',
182
+ 'JSXExpressionContainer': 'JSXExpressionContainer',
183
+ 'JSXText': 'JSXText',
184
+ 'JSXIdentifier': 'JSXIdentifier',
185
+ 'JSXMemberExpression': 'JSXMemberExpression',
186
+ 'JSXNamespacedName': 'JSXNamespacedName',
187
+ 'JSXEmptyExpression': 'JSXEmptyExpression',
188
+ // ����
189
+ 'AwaitExpression': 'AwaitExpression',
190
+ 'YieldExpression': 'YieldExpression',
191
+ 'TaggedTemplateExpression': 'TaggedTemplateExpression',
192
+ 'TemplateElement': 'TemplateElement',
193
+ 'OptionalMemberExpression': 'OptionalMemberExpression',
194
+ 'OptionalCallExpression': 'OptionalCallExpression',
195
+ 'ParenthesisExpression': 'ParenthesizedExpression',
196
+ // Property ������Ҫ���⴦��
197
+ 'KeyValueProperty': 'ObjectProperty',
198
+ 'AssignmentProperty': 'ObjectProperty',
199
+ 'GetterProperty': 'ObjectMethod',
200
+ 'SetterProperty': 'ObjectMethod',
201
+ 'MethodProperty': 'ObjectMethod',
202
+ 'SpreadProperty': 'SpreadElement',
203
+ 'ShorthandProperty': 'ObjectProperty',
204
+ // Import/Export specifiers
205
+ 'ImportDefaultSpecifier': 'ImportDefaultSpecifier',
206
+ 'ImportSpecifier': 'ImportSpecifier',
207
+ 'ImportNamespaceSpecifier': 'ImportNamespaceSpecifier',
208
+ 'ExportSpecifier': 'ExportSpecifier',
209
+ 'ExportDefaultSpecifier': 'ExportDefaultSpecifier',
210
+ 'ExportNamespaceSpecifier': 'ExportNamespaceSpecifier',
211
+ 'Computed': 'Computed',
212
+ 'SuperPropExpression': 'MemberExpression',
213
+ 'AssignmentPatternProperty': 'ObjectProperty',
214
+ };
215
+
216
+ /**
217
+ * �淶�����������б�
218
+ */
219
+ function normalizeParams(params: any): any[] {
220
+ if (Array.isArray(params)) {
221
+ return params.map((p) => p?.pat || p);
222
+ }
223
+ if (params && Array.isArray(params.params)) {
224
+ return params.params.map((p: any) => p?.pat || p);
225
+ }
226
+ return [];
227
+ }
228
+
229
+ /**
230
+ * �淶����Ա���ԣ����� MemberExpression.property Ϊ MemberExpression ��������ʧ��
231
+ */
232
+ function normalizeMemberProperty(prop: any, computedFlag?: boolean): { property: any; computed: boolean } {
233
+ if (!prop) {
234
+ return { property: prop, computed: Boolean(computedFlag) };
235
+ }
236
+
237
+ if (prop.type === 'Computed') {
238
+ return { property: convertSWCNode(prop.expression), computed: true };
239
+ }
240
+
241
+ const converted = convertSWCNode(prop);
242
+ const needsComputed = converted?.type === 'MemberExpression';
243
+ return { property: converted, computed: Boolean(computedFlag) || needsComputed };
244
+ }
245
+
246
+ /**
247
+ * �ݹ�ת�� SWC AST �ڵ㵽 Babel AST ��ʽ
248
+ */
249
+ function convertSWCNode(node: any): any {
250
+ if (!node || typeof node !== 'object') {
251
+ return node;
252
+ }
253
+
254
+ // ��������
255
+ if (Array.isArray(node)) {
256
+ return node.map(convertSWCNode);
257
+ }
258
+
259
+ // ��ȡ�ڵ�����
260
+ const swcType = node.type;
261
+ if (!swcType) {
262
+ // ���� SWC ExprOrSpread �ṹ��{ spread: null|{...}, expression: {...} }
263
+ if ('expression' in node && 'spread' in node) {
264
+ if (node.spread) {
265
+ return {
266
+ type: 'SpreadElement',
267
+ argument: convertSWCNode(node.expression),
268
+ };
269
+ }
270
+ return convertSWCNode(node.expression);
271
+ }
272
+ // ������ AST �ڵ�Ķ���
273
+ const result: any = {};
274
+ for (const key of Object.keys(node)) {
275
+ result[key] = convertSWCNode(node[key]);
276
+ }
277
+ return result;
278
+ }
279
+
280
+ // ӳ������
281
+ const babelType = SWC_TO_BABEL_TYPE[swcType] || swcType;
282
+
283
+ // �����½ڵ�
284
+ const babelNode: any = {
285
+ type: babelType,
286
+ };
287
+
288
+ // �����������
289
+ switch (swcType) {
290
+ case 'SuperPropExpression':
291
+ const superProp = normalizeMemberProperty(node.property, node.computed);
292
+ return {
293
+ type: 'MemberExpression',
294
+ object: { type: 'Super' },
295
+ property: superProp.property,
296
+ computed: superProp.computed,
297
+ };
298
+
299
+ case 'AssignmentPatternProperty':
300
+ return {
301
+ type: 'ObjectProperty',
302
+ key: convertSWCNode(node.key),
303
+ value: convertSWCNode(node.value),
304
+ computed: node.key?.type === 'Computed' || node.computed || false,
305
+ shorthand: false,
306
+ };
307
+ case 'SuperPropExpression':
308
+ return {
309
+ type: 'MemberExpression',
310
+ object: { type: 'Super' },
311
+ property: convertSWCNode(node.property),
312
+ computed: node.property?.type === 'Computed' || node.computed || false,
313
+ };
314
+
315
+ case 'AssignmentPatternProperty':
316
+ return {
317
+ type: 'ObjectProperty',
318
+ key: convertSWCNode(node.key),
319
+ value: convertSWCNode(node.value),
320
+ computed: node.key?.type === 'Computed' || node.computed || false,
321
+ shorthand: false,
322
+ };
323
+ case 'Computed':
324
+ // SWC computed property wrapper
325
+ return convertSWCNode(node.expression);
326
+ case 'Program':
327
+ return {
328
+ type: 'Program',
329
+ sourceType: node.sourceType || 'module',
330
+ body: convertSWCNode(node.body || node.stmts || []),
331
+ directives: [],
332
+ };
333
+ case 'Module':
334
+ case 'Script':
335
+ // ת��Ϊ Babel �� File �ṹ
336
+ return {
337
+ type: 'File',
338
+ program: {
339
+ type: 'Program',
340
+ sourceType: 'module',
341
+ body: convertSWCNode(node.body || node.stmts || []),
342
+ directives: [],
343
+ },
344
+ };
345
+
346
+ case 'ExportDefaultExpression':
347
+ return {
348
+ type: 'ExportDefaultDeclaration',
349
+ declaration: convertSWCNode(node.expression || node.expr || node.decl),
350
+ };
351
+
352
+ case 'StringLiteral':
353
+ babelNode.value = node.value;
354
+ babelNode.raw = node.raw;
355
+ break;
356
+
357
+ case 'TemplateLiteral':
358
+ babelNode.expressions = convertSWCNode(node.expressions || node.exprs || []);
359
+ babelNode.quasis = convertSWCNode(node.quasis || []);
360
+ if (!babelNode.quasis || babelNode.quasis.length === 0) {
361
+ babelNode.quasis = [
362
+ {
363
+ type: 'TemplateElement',
364
+ value: { raw: '', cooked: '' },
365
+ tail: true,
366
+ },
367
+ ];
368
+ }
369
+ if (Array.isArray(babelNode.quasis) && Array.isArray(babelNode.expressions)) {
370
+ if (babelNode.quasis.length === babelNode.expressions.length) {
371
+ babelNode.quasis.push({
372
+ type: 'TemplateElement',
373
+ value: { raw: '', cooked: '' },
374
+ tail: true,
375
+ });
376
+ }
377
+ const last = babelNode.quasis[babelNode.quasis.length - 1];
378
+ if (last) last.tail = true;
379
+ }
380
+ break;
381
+
382
+ case 'NumericLiteral':
383
+ babelNode.value = node.value;
384
+ babelNode.raw = String(node.value);
385
+ break;
386
+
387
+ case 'BooleanLiteral':
388
+ babelNode.value = node.value;
389
+ break;
390
+
391
+ case 'Identifier':
392
+ babelNode.name = node.value;
393
+ break;
394
+
395
+ case 'PrivateName':
396
+ return {
397
+ type: 'PrivateName',
398
+ id: convertSWCNode(node.id || { type: 'Identifier', value: node.name }),
399
+ };
400
+
401
+ case 'KeyValueProperty':
402
+ case 'ShorthandProperty':
403
+ babelNode.type = 'ObjectProperty';
404
+ const keyNode = node.key;
405
+ const isComputedKey = keyNode?.type === 'Computed';
406
+ const normalizedKey = normalizeMemberProperty(isComputedKey ? keyNode.expression : keyNode, node.computed);
407
+ babelNode.key = normalizedKey.property;
408
+ babelNode.value = convertSWCNode(node.value);
409
+ babelNode.computed = normalizedKey.computed || isComputedKey || node.computed || false;
410
+ babelNode.shorthand = swcType === 'ShorthandProperty';
411
+ babelNode.method = false;
412
+ break;
413
+
414
+ case 'GetterProperty':
415
+ case 'SetterProperty':
416
+ case 'MethodProperty':
417
+ babelNode.type = 'ObjectMethod';
418
+ const objMethodKey = node.key;
419
+ const objMethodComputed = objMethodKey?.type === 'Computed';
420
+ const normalizedObjMethodKey = normalizeMemberProperty(objMethodComputed ? objMethodKey.expression : objMethodKey, node.computed);
421
+ babelNode.key = normalizedObjMethodKey.property;
422
+ babelNode.kind = swcType === 'GetterProperty' ? 'get' :
423
+ swcType === 'SetterProperty' ? 'set' : 'method';
424
+ babelNode.params = convertSWCNode(normalizeParams(node.params));
425
+ babelNode.body = convertSWCNode(node.body);
426
+ babelNode.computed = normalizedObjMethodKey.computed || objMethodComputed || node.computed || false;
427
+ babelNode.generator = node.generator || false;
428
+ babelNode.async = node.async || false;
429
+ break;
430
+
431
+ case 'ImportDeclaration':
432
+ babelNode.source = convertSWCNode(node.source);
433
+ babelNode.specifiers = convertSWCNode(node.specifiers || []);
434
+ babelNode.importKind = node.typeOnly ? 'type' : 'value';
435
+ break;
436
+ case 'BlockStatement':
437
+ babelNode.body = convertSWCNode(node.body || node.stmts || []);
438
+ break;
439
+
440
+ case 'ReturnStatement':
441
+ babelNode.argument = convertSWCNode(node.argument ?? node.value ?? node.expr ?? null);
442
+ break;
443
+
444
+ case 'ExpressionStatement':
445
+ babelNode.expression = convertSWCNode(node.expression ?? node.expr);
446
+ break;
447
+
448
+ case 'ImportSpecifier':
449
+ babelNode.imported = convertSWCNode(node.imported || node.local);
450
+ babelNode.local = convertSWCNode(node.local);
451
+ break;
452
+
453
+ case 'ImportDefaultSpecifier':
454
+ babelNode.local = convertSWCNode(node.local);
455
+ break;
456
+
457
+ case 'ImportNamespaceSpecifier':
458
+ babelNode.local = convertSWCNode(node.local);
459
+ break;
460
+
461
+ case 'ExportNamedDeclaration':
462
+ babelNode.declaration = convertSWCNode(node.declaration);
463
+ babelNode.specifiers = convertSWCNode(node.specifiers || []);
464
+ babelNode.source = convertSWCNode(node.source);
465
+ break;
466
+
467
+ case 'ExportDefaultDeclaration':
468
+ babelNode.declaration = convertSWCNode(node.decl || node.declaration);
469
+ break;
470
+
471
+ case 'VariableDeclaration':
472
+ babelNode.kind = node.kind;
473
+ babelNode.declarations = convertSWCNode(node.declarations);
474
+ break;
475
+
476
+ case 'VariableDeclarator':
477
+ babelNode.id = convertSWCNode(node.id);
478
+ babelNode.init = convertSWCNode(node.init);
479
+ break;
480
+
481
+ case 'FunctionDeclaration':
482
+ case 'FunctionExpression':
483
+ babelNode.id = convertSWCNode(node.identifier);
484
+ babelNode.params = convertSWCNode(normalizeParams(node.params));
485
+ babelNode.body = convertSWCNode(node.body);
486
+ babelNode.generator = node.generator || false;
487
+ babelNode.async = node.async || false;
488
+ break;
489
+
490
+ case 'ArrowFunctionExpression':
491
+ babelNode.params = convertSWCNode(normalizeParams(node.params));
492
+ babelNode.body = convertSWCNode(node.body);
493
+ babelNode.async = node.async || false;
494
+ babelNode.expression = node.body?.type !== 'BlockStatement';
495
+ break;
496
+
497
+ case 'ClassDeclaration':
498
+ case 'ClassExpression':
499
+ babelNode.id = convertSWCNode(node.identifier || node.id);
500
+ babelNode.superClass = convertSWCNode(node.superClass);
501
+ babelNode.decorators = convertSWCNode(node.decorators || []);
502
+ babelNode.body = {
503
+ type: 'ClassBody',
504
+ body: convertSWCNode(node.body?.body || node.body || []),
505
+ };
506
+ break;
507
+
508
+ case 'ClassMethod':
509
+ case 'ClassPrivateMethod':
510
+ case 'Constructor':
511
+ const classMethodKey = node.key;
512
+ const classMethodComputed = classMethodKey?.type === 'Computed';
513
+ const normalizedClassMethodKey = normalizeMemberProperty(classMethodComputed ? classMethodKey.expression : classMethodKey, node.computed);
514
+ babelNode.key = normalizedClassMethodKey.property;
515
+ babelNode.kind = swcType === 'Constructor' ? 'constructor' : (node.kind || 'method');
516
+ babelNode.params = convertSWCNode(normalizeParams(node.function?.params || node.params));
517
+ babelNode.body = convertSWCNode(node.function?.body || node.body);
518
+ babelNode.computed = normalizedClassMethodKey.computed || classMethodComputed || node.computed || false;
519
+ babelNode.static = node.isStatic || node.static || false;
520
+ babelNode.async = node.function?.isAsync || node.async || false;
521
+ babelNode.generator = node.function?.isGenerator || node.generator || false;
522
+ break;
523
+
524
+ case 'ClassProperty':
525
+ case 'ClassPrivateProperty':
526
+ const classPropKey = node.key;
527
+ const classPropComputed = classPropKey?.type === 'Computed';
528
+ const normalizedClassPropKey = normalizeMemberProperty(classPropComputed ? classPropKey.expression : classPropKey, node.computed);
529
+ babelNode.key = normalizedClassPropKey.property;
530
+ babelNode.value = convertSWCNode(node.value);
531
+ babelNode.computed = normalizedClassPropKey.computed || classPropComputed || node.computed || false;
532
+ babelNode.static = node.isStatic || node.static || false;
533
+ break;
534
+
535
+ case 'CallExpression':
536
+ babelNode.callee = convertSWCNode(node.callee);
537
+ babelNode.arguments = convertSWCNode(node.arguments || []);
538
+ break;
539
+
540
+ case 'OptionalChainingExpression': {
541
+ const base = node.base || node.expression || node.expr || node.argument;
542
+ const converted = convertSWCNode(base);
543
+
544
+ if (converted && (converted.type === 'MemberExpression' || converted.type === 'OptionalMemberExpression')) {
545
+ converted.type = 'OptionalMemberExpression';
546
+ converted.optional = true;
547
+ }
548
+
549
+ if (converted && (converted.type === 'CallExpression' || converted.type === 'OptionalCallExpression')) {
550
+ converted.type = 'OptionalCallExpression';
551
+ converted.optional = true;
552
+ }
553
+
554
+ return converted;
555
+ }
556
+
557
+ case 'MemberExpression':
558
+ babelNode.object = convertSWCNode(node.object);
559
+ const memberProp = normalizeMemberProperty(node.property, node.computed);
560
+ babelNode.property = memberProp.property;
561
+ babelNode.computed = memberProp.computed;
562
+ babelNode.optional = node.optional || false;
563
+ break;
564
+ case 'NewExpression':
565
+ babelNode.callee = convertSWCNode(node.callee);
566
+ babelNode.arguments = convertSWCNode(node.arguments || []);
567
+ break;
568
+ case 'OptionalCallExpression':
569
+ babelNode.callee = convertSWCNode(node.callee);
570
+ babelNode.arguments = convertSWCNode(node.arguments || []);
571
+ babelNode.optional = true;
572
+ break;
573
+
574
+ case 'JSXElement':
575
+ babelNode.openingElement = convertSWCNode(node.opening);
576
+ babelNode.closingElement = convertSWCNode(node.closing);
577
+ babelNode.children = convertSWCNode(node.children || []);
578
+ babelNode.selfClosing = !node.closing;
579
+ break;
580
+
581
+ case 'JSXOpeningElement':
582
+ babelNode.name = convertSWCNode(node.name);
583
+ babelNode.attributes = convertSWCNode(node.attributes || []);
584
+ babelNode.selfClosing = node.selfClosing || false;
585
+ break;
586
+
587
+ case 'JSXClosingElement':
588
+ babelNode.name = convertSWCNode(node.name);
589
+ break;
590
+
591
+ case 'JSXAttribute':
592
+ babelNode.name = convertSWCNode(node.name);
593
+ babelNode.value = convertSWCNode(node.value);
594
+ break;
595
+
596
+ case 'JSXIdentifier':
597
+ babelNode.name = node.value;
598
+ break;
599
+
600
+ case 'JSXText':
601
+ babelNode.value = node.value;
602
+ babelNode.raw = node.raw || node.value;
603
+ break;
604
+
605
+ case 'TemplateElement':
606
+ return {
607
+ type: 'TemplateElement',
608
+ value: {
609
+ raw: node.raw ?? node.value?.raw ?? node.cooked ?? '',
610
+ cooked: node.cooked ?? node.value?.cooked ?? node.raw ?? '',
611
+ },
612
+ tail: node.tail ?? false,
613
+ };
614
+
615
+ case 'JSXExpressionContainer':
616
+ babelNode.expression = convertSWCNode(node.expression);
617
+ break;
618
+
619
+ case 'JSXFragment':
620
+ babelNode.openingFragment = { type: 'JSXOpeningFragment' };
621
+ babelNode.closingFragment = { type: 'JSXClosingFragment' };
622
+ babelNode.children = convertSWCNode(node.children || []);
623
+ break;
624
+
625
+ default:
626
+ // ͨ�ô������ݹ�ת����������
627
+ for (const key of Object.keys(node)) {
628
+ if (key === 'type' || key === 'span' || key === 'ctxt') continue;
629
+ babelNode[key] = convertSWCNode(node[key]);
630
+ }
631
+ }
632
+
633
+ return babelNode;
634
+ }
635
+
636
+ /**
637
+ * �� SWC AST ת��Ϊ Babel ���ݸ�ʽ
638
+ */
639
+ export function convertSWCToBabel(swcAst: any): t.File {
640
+ const startTime = performance.now();
641
+ const result = convertSWCNode(swcAst) as t.File;
642
+ const duration = performance.now() - startTime;
643
+
644
+ swcStats.conversionCount++;
645
+ swcStats.conversionTotalTime += duration;
646
+
647
+ return result;
648
+ }
649
+
650
+ /**
651
+ * ʹ�� SWC ��������
652
+ * ��� SWC �����ã����˵� Babel
653
+ */
654
+ export function parseWithSWC(code: string): t.File {
655
+ const safeCode = sanitizePermissionCommentsForJSX(code);
656
+ if (!swcAvailable || !swcModule) {
657
+ // ���˵� Babel
658
+ const startTime = performance.now();
659
+ const ast = babelParse(safeCode, babelParserConfig);
660
+ swcStats.babelFallbackCount++;
661
+ swcStats.babelTotalTime += performance.now() - startTime;
662
+ return ast;
663
+ }
664
+
665
+ try {
666
+ // ʹ�� SWC ����
667
+ const startTime = performance.now();
668
+ const swcAst = swcModule.parseSync(safeCode, swcParserConfig);
669
+ const parseTime = performance.now() - startTime;
670
+
671
+ swcStats.swcParseCount++;
672
+ swcStats.swcTotalTime += parseTime;
673
+
674
+ // ת��Ϊ Babel ��ʽ
675
+ return convertSWCToBabel(swcAst);
676
+ } catch (error) {
677
+ // ����ʧ�ܣ����˵� Babel
678
+ console.warn('[SWC] ����ʧ�ܣ����˵� Babel:', error);
679
+ const startTime = performance.now();
680
+ const ast = babelParse(safeCode, babelParserConfig);
681
+ swcStats.babelFallbackCount++;
682
+ swcStats.babelTotalTime += performance.now() - startTime;
683
+ return ast;
684
+ }
685
+ }
686
+
687
+ /**
688
+ * �첽ʹ�� SWC ��������
689
+ */
690
+ export async function parseWithSWCAsync(code: string): Promise<t.File> {
691
+ // ȷ�� SWC �ѳ�ʼ��
692
+ await initSWC();
693
+ return parseWithSWC(code);
694
+ }
695
+
696
+ /**
697
+ * ��ȡ SWC ����ͳ��
698
+ */
699
+ export function getSWCStats() {
700
+ return {
701
+ ...swcStats,
702
+ swcAvailable,
703
+ swcAverageParseTime: swcStats.swcParseCount > 0
704
+ ? swcStats.swcTotalTime / swcStats.swcParseCount
705
+ : 0,
706
+ babelAverageTime: swcStats.babelFallbackCount > 0
707
+ ? swcStats.babelTotalTime / swcStats.babelFallbackCount
708
+ : 0,
709
+ conversionAverageTime: swcStats.conversionCount > 0
710
+ ? swcStats.conversionTotalTime / swcStats.conversionCount
711
+ : 0,
712
+ speedup: swcStats.babelFallbackCount > 0 && swcStats.swcParseCount > 0
713
+ ? (swcStats.babelTotalTime / swcStats.babelFallbackCount) /
714
+ ((swcStats.swcTotalTime + swcStats.conversionTotalTime) / swcStats.swcParseCount)
715
+ : 0,
716
+ };
717
+ }
718
+
719
+ /**
720
+ * ��ӡ SWC ���ܱ���
721
+ */
722
+ export function printSWCReport(): void {
723
+ const stats = getSWCStats();
724
+
725
+ console.log('%c=== SWC Parser Report ===', 'color: #FF5722; font-weight: bold;');
726
+ console.log(`SWC ����: ${stats.swcAvailable ? '?' : '?'}`);
727
+ console.log(`%cSWC ��������: ${stats.swcParseCount}`, 'color: #4CAF50;');
728
+ console.log(`%cSWC �ܺ�ʱ: ${stats.swcTotalTime.toFixed(2)}ms`, 'color: #4CAF50;');
729
+ console.log(`%cSWC ƽ����ʱ: ${stats.swcAverageParseTime.toFixed(2)}ms`, 'color: #4CAF50;');
730
+ console.log(`%cBabel ���˴���: ${stats.babelFallbackCount}`, 'color: #FF9800;');
731
+ console.log(`%cBabel �ܺ�ʱ: ${stats.babelTotalTime.toFixed(2)}ms`, 'color: #FF9800;');
732
+ console.log(`%cBabel ƽ����ʱ: ${stats.babelAverageTime.toFixed(2)}ms`, 'color: #FF9800;');
733
+ console.log(`AST ת������: ${stats.conversionCount}`);
734
+ console.log(`AST ת��ƽ����ʱ: ${stats.conversionAverageTime.toFixed(2)}ms`);
735
+ if (stats.speedup > 0) {
736
+ console.log(`%c���ٱ�: ${stats.speedup.toFixed(1)}x`, 'color: #E91E63; font-weight: bold;');
737
+ }
738
+ console.log('%c=========================', 'color: #FF5722; font-weight: bold;');
739
+ }
740
+
741
+ // ��¶��ȫ�֣��������
742
+ if (typeof window !== 'undefined') {
743
+ (window as any).__SWC_PARSER__ = {
744
+ initSWC,
745
+ isSWCAvailable,
746
+ parseWithSWC,
747
+ parseWithSWCAsync,
748
+ getSWCStats,
749
+ printSWCReport,
750
+ };
751
+ }