lc-test3 1.1.10 → 1.1.12

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 +753 -556
  2. package/package.json +1 -1
package/p.js CHANGED
@@ -1,556 +1,753 @@
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 permissionCommentPattern = /\/\*\*[\s\S]*?RESOURCESTREE-START[\s\S]*?RESOURCESTREE-END[\s\S]*?\*\//g;
46
+
47
+ function sanitizePermissionCommentsForJSX(code: string) {
48
+ return code.replace(permissionCommentPattern, (comment, offset) => {
49
+ const rest = code.slice(offset + comment.length);
50
+ // SWC �� "return (/**...*/<JSX" �Ľ������ȶ���ֱ���Ƴ�������� JSX ��ʼ��ǩ��Ȩ��ע��
51
+ if (/^\s*</.test(rest)) {
52
+ return '';
53
+ }
54
+ return comment;
55
+ });
56
+ }
57
+
58
+ // ����ͳ��
59
+ const swcStats = {
60
+ swcParseCount: 0,
61
+ swcTotalTime: 0,
62
+ babelFallbackCount: 0,
63
+ babelTotalTime: 0,
64
+ conversionCount: 0,
65
+ conversionTotalTime: 0,
66
+ };
67
+
68
+ /**
69
+ * ��ʼ�� SWC WASM ģ��
70
+ */
71
+ export async function initSWC(): Promise<boolean> {
72
+ if (swcAvailable) return true;
73
+ if (swcInitPromise) {
74
+ await swcInitPromise;
75
+ return swcAvailable;
76
+ }
77
+
78
+ swcInitPromise = (async () => {
79
+ try {
80
+ // ��̬���� SWC WASM
81
+ const swc = await import('@swc/wasm-web');
82
+
83
+ // ��ʼ�� WASM����Ҫ���� .wasm �ļ���
84
+ await swc.default();
85
+
86
+ swcModule = swc;
87
+ swcAvailable = true;
88
+ console.log('%c[SWC] ? WASM ģ���ʼ���ɹ�', 'color: #4CAF50; font-weight: bold;');
89
+ } catch (error) {
90
+ console.warn('[SWC] ?? WASM ģ�����ʧ�ܣ���ʹ�� Babel ��Ϊ����:', error);
91
+ swcAvailable = false;
92
+ }
93
+ })();
94
+
95
+ await swcInitPromise;
96
+ return swcAvailable;
97
+ }
98
+
99
+ /**
100
+ * ��� SWC �Ƿ����
101
+ */
102
+ export function isSWCAvailable(): boolean {
103
+ return swcAvailable;
104
+ }
105
+
106
+ /**
107
+ * SWC AST �ڵ�����ӳ�䵽 Babel ����
108
+ */
109
+ const SWC_TO_BABEL_TYPE: Record<string, string> = {
110
+ 'Module': 'File',
111
+ 'Script': 'File',
112
+ 'ImportDeclaration': 'ImportDeclaration',
113
+ 'ExportDeclaration': 'ExportDeclaration',
114
+ 'ExportDefaultDeclaration': 'ExportDefaultDeclaration',
115
+ 'ExportDefaultExpression': 'ExportDefaultDeclaration',
116
+ 'ExportNamedDeclaration': 'ExportNamedDeclaration',
117
+ 'ExportAllDeclaration': 'ExportAllDeclaration',
118
+ 'VariableDeclaration': 'VariableDeclaration',
119
+ 'VariableDeclarator': 'VariableDeclarator',
120
+ 'FunctionDeclaration': 'FunctionDeclaration',
121
+ 'FunctionExpression': 'FunctionExpression',
122
+ 'ArrowFunctionExpression': 'ArrowFunctionExpression',
123
+ 'ClassDeclaration': 'ClassDeclaration',
124
+ 'ClassExpression': 'ClassExpression',
125
+ 'ClassMethod': 'ClassMethod',
126
+ 'ClassPrivateMethod': 'ClassPrivateMethod',
127
+ 'ClassProperty': 'ClassProperty',
128
+ 'ClassPrivateProperty': 'ClassPrivateProperty',
129
+ 'Constructor': 'ClassMethod',
130
+ 'PrivateName': 'PrivateName',
131
+ 'Identifier': 'Identifier',
132
+ 'StringLiteral': 'StringLiteral',
133
+ 'NumericLiteral': 'NumericLiteral',
134
+ 'BooleanLiteral': 'BooleanLiteral',
135
+ 'NullLiteral': 'NullLiteral',
136
+ 'RegExpLiteral': 'RegExpLiteral',
137
+ 'TemplateLiteral': 'TemplateLiteral',
138
+ 'ArrayExpression': 'ArrayExpression',
139
+ 'ObjectExpression': 'ObjectExpression',
140
+ 'CallExpression': 'CallExpression',
141
+ 'MemberExpression': 'MemberExpression',
142
+ 'BinaryExpression': 'BinaryExpression',
143
+ 'UnaryExpression': 'UnaryExpression',
144
+ 'ConditionalExpression': 'ConditionalExpression',
145
+ 'AssignmentExpression': 'AssignmentExpression',
146
+ 'LogicalExpression': 'LogicalExpression',
147
+ 'SequenceExpression': 'SequenceExpression',
148
+ 'NewExpression': 'NewExpression',
149
+ 'ThisExpression': 'ThisExpression',
150
+ 'SpreadElement': 'SpreadElement',
151
+ 'RestElement': 'RestElement',
152
+ 'ObjectPattern': 'ObjectPattern',
153
+ 'ArrayPattern': 'ArrayPattern',
154
+ 'AssignmentPattern': 'AssignmentPattern',
155
+ 'BlockStatement': 'BlockStatement',
156
+ 'ReturnStatement': 'ReturnStatement',
157
+ 'IfStatement': 'IfStatement',
158
+ 'SwitchStatement': 'SwitchStatement',
159
+ 'SwitchCase': 'SwitchCase',
160
+ 'ForStatement': 'ForStatement',
161
+ 'ForInStatement': 'ForInStatement',
162
+ 'ForOfStatement': 'ForOfStatement',
163
+ 'WhileStatement': 'WhileStatement',
164
+ 'DoWhileStatement': 'DoWhileStatement',
165
+ 'TryStatement': 'TryStatement',
166
+ 'CatchClause': 'CatchClause',
167
+ 'ThrowStatement': 'ThrowStatement',
168
+ 'BreakStatement': 'BreakStatement',
169
+ 'ContinueStatement': 'ContinueStatement',
170
+ 'ExpressionStatement': 'ExpressionStatement',
171
+ 'EmptyStatement': 'EmptyStatement',
172
+ 'DebuggerStatement': 'DebuggerStatement',
173
+ 'LabeledStatement': 'LabeledStatement',
174
+ 'WithStatement': 'WithStatement',
175
+ // JSX
176
+ 'JSXElement': 'JSXElement',
177
+ 'JSXFragment': 'JSXFragment',
178
+ 'JSXOpeningElement': 'JSXOpeningElement',
179
+ 'JSXClosingElement': 'JSXClosingElement',
180
+ 'JSXOpeningFragment': 'JSXOpeningFragment',
181
+ 'JSXClosingFragment': 'JSXClosingFragment',
182
+ 'JSXAttribute': 'JSXAttribute',
183
+ 'JSXSpreadAttribute': 'JSXSpreadAttribute',
184
+ 'JSXExpressionContainer': 'JSXExpressionContainer',
185
+ 'JSXText': 'JSXText',
186
+ 'JSXIdentifier': 'JSXIdentifier',
187
+ 'JSXMemberExpression': 'JSXMemberExpression',
188
+ 'JSXNamespacedName': 'JSXNamespacedName',
189
+ 'JSXEmptyExpression': 'JSXEmptyExpression',
190
+ // ����
191
+ 'AwaitExpression': 'AwaitExpression',
192
+ 'YieldExpression': 'YieldExpression',
193
+ 'TaggedTemplateExpression': 'TaggedTemplateExpression',
194
+ 'TemplateElement': 'TemplateElement',
195
+ 'OptionalMemberExpression': 'OptionalMemberExpression',
196
+ 'OptionalCallExpression': 'OptionalCallExpression',
197
+ 'ParenthesisExpression': 'ParenthesizedExpression',
198
+ // Property ������Ҫ���⴦��
199
+ 'KeyValueProperty': 'ObjectProperty',
200
+ 'AssignmentProperty': 'ObjectProperty',
201
+ 'GetterProperty': 'ObjectMethod',
202
+ 'SetterProperty': 'ObjectMethod',
203
+ 'MethodProperty': 'ObjectMethod',
204
+ 'SpreadProperty': 'SpreadElement',
205
+ 'ShorthandProperty': 'ObjectProperty',
206
+ // Import/Export specifiers
207
+ 'ImportDefaultSpecifier': 'ImportDefaultSpecifier',
208
+ 'ImportSpecifier': 'ImportSpecifier',
209
+ 'ImportNamespaceSpecifier': 'ImportNamespaceSpecifier',
210
+ 'ExportSpecifier': 'ExportSpecifier',
211
+ 'ExportDefaultSpecifier': 'ExportDefaultSpecifier',
212
+ 'ExportNamespaceSpecifier': 'ExportNamespaceSpecifier',
213
+ 'Computed': 'Computed',
214
+ 'SuperPropExpression': 'MemberExpression',
215
+ 'AssignmentPatternProperty': 'ObjectProperty',
216
+ };
217
+
218
+ /**
219
+ * �淶�����������б�
220
+ */
221
+ function normalizeParams(params: any): any[] {
222
+ if (Array.isArray(params)) {
223
+ return params.map((p) => p?.pat || p);
224
+ }
225
+ if (params && Array.isArray(params.params)) {
226
+ return params.params.map((p: any) => p?.pat || p);
227
+ }
228
+ return [];
229
+ }
230
+
231
+ /**
232
+ * �淶����Ա���ԣ����� MemberExpression.property Ϊ MemberExpression ��������ʧ��
233
+ */
234
+ function normalizeMemberProperty(prop: any, computedFlag?: boolean): { property: any; computed: boolean } {
235
+ if (!prop) {
236
+ return { property: prop, computed: Boolean(computedFlag) };
237
+ }
238
+
239
+ if (prop.type === 'Computed') {
240
+ return { property: convertSWCNode(prop.expression), computed: true };
241
+ }
242
+
243
+ const converted = convertSWCNode(prop);
244
+ const needsComputed = converted?.type === 'MemberExpression';
245
+ return { property: converted, computed: Boolean(computedFlag) || needsComputed };
246
+ }
247
+
248
+ /**
249
+ * �ݹ�ת�� SWC AST �ڵ㵽 Babel AST ��ʽ
250
+ */
251
+ function convertSWCNode(node: any): any {
252
+ if (!node || typeof node !== 'object') {
253
+ return node;
254
+ }
255
+
256
+ // ��������
257
+ if (Array.isArray(node)) {
258
+ return node.map(convertSWCNode);
259
+ }
260
+
261
+ // ��ȡ�ڵ�����
262
+ const swcType = node.type;
263
+ if (!swcType) {
264
+ // ���� SWC ExprOrSpread �ṹ��{ spread: null|{...}, expression: {...} }
265
+ if ('expression' in node && 'spread' in node) {
266
+ if (node.spread) {
267
+ return {
268
+ type: 'SpreadElement',
269
+ argument: convertSWCNode(node.expression),
270
+ };
271
+ }
272
+ return convertSWCNode(node.expression);
273
+ }
274
+ // ������ AST �ڵ�Ķ���
275
+ const result: any = {};
276
+ for (const key of Object.keys(node)) {
277
+ result[key] = convertSWCNode(node[key]);
278
+ }
279
+ return result;
280
+ }
281
+
282
+ // ӳ������
283
+ const babelType = SWC_TO_BABEL_TYPE[swcType] || swcType;
284
+
285
+ // �����½ڵ�
286
+ const babelNode: any = {
287
+ type: babelType,
288
+ };
289
+
290
+ // �����������
291
+ switch (swcType) {
292
+ case 'SuperPropExpression':
293
+ const superProp = normalizeMemberProperty(node.property, node.computed);
294
+ return {
295
+ type: 'MemberExpression',
296
+ object: { type: 'Super' },
297
+ property: superProp.property,
298
+ computed: superProp.computed,
299
+ };
300
+
301
+ case 'AssignmentPatternProperty':
302
+ return {
303
+ type: 'ObjectProperty',
304
+ key: convertSWCNode(node.key),
305
+ value: convertSWCNode(node.value),
306
+ computed: node.key?.type === 'Computed' || node.computed || false,
307
+ shorthand: false,
308
+ };
309
+ case 'SuperPropExpression':
310
+ return {
311
+ type: 'MemberExpression',
312
+ object: { type: 'Super' },
313
+ property: convertSWCNode(node.property),
314
+ computed: node.property?.type === 'Computed' || node.computed || false,
315
+ };
316
+
317
+ case 'AssignmentPatternProperty':
318
+ return {
319
+ type: 'ObjectProperty',
320
+ key: convertSWCNode(node.key),
321
+ value: convertSWCNode(node.value),
322
+ computed: node.key?.type === 'Computed' || node.computed || false,
323
+ shorthand: false,
324
+ };
325
+ case 'Computed':
326
+ // SWC computed property wrapper
327
+ return convertSWCNode(node.expression);
328
+ case 'Program':
329
+ return {
330
+ type: 'Program',
331
+ sourceType: node.sourceType || 'module',
332
+ body: convertSWCNode(node.body || node.stmts || []),
333
+ directives: [],
334
+ };
335
+ case 'Module':
336
+ case 'Script':
337
+ // ת��Ϊ Babel �� File �ṹ
338
+ return {
339
+ type: 'File',
340
+ program: {
341
+ type: 'Program',
342
+ sourceType: 'module',
343
+ body: convertSWCNode(node.body || node.stmts || []),
344
+ directives: [],
345
+ },
346
+ };
347
+
348
+ case 'ExportDefaultExpression':
349
+ return {
350
+ type: 'ExportDefaultDeclaration',
351
+ declaration: convertSWCNode(node.expression || node.expr || node.decl),
352
+ };
353
+
354
+ case 'StringLiteral':
355
+ babelNode.value = node.value;
356
+ babelNode.raw = node.raw;
357
+ break;
358
+
359
+ case 'TemplateLiteral':
360
+ babelNode.expressions = convertSWCNode(node.expressions || node.exprs || []);
361
+ babelNode.quasis = convertSWCNode(node.quasis || []);
362
+ if (!babelNode.quasis || babelNode.quasis.length === 0) {
363
+ babelNode.quasis = [
364
+ {
365
+ type: 'TemplateElement',
366
+ value: { raw: '', cooked: '' },
367
+ tail: true,
368
+ },
369
+ ];
370
+ }
371
+ if (Array.isArray(babelNode.quasis) && Array.isArray(babelNode.expressions)) {
372
+ if (babelNode.quasis.length === babelNode.expressions.length) {
373
+ babelNode.quasis.push({
374
+ type: 'TemplateElement',
375
+ value: { raw: '', cooked: '' },
376
+ tail: true,
377
+ });
378
+ }
379
+ const last = babelNode.quasis[babelNode.quasis.length - 1];
380
+ if (last) last.tail = true;
381
+ }
382
+ break;
383
+
384
+ case 'NumericLiteral':
385
+ babelNode.value = node.value;
386
+ babelNode.raw = String(node.value);
387
+ break;
388
+
389
+ case 'BooleanLiteral':
390
+ babelNode.value = node.value;
391
+ break;
392
+
393
+ case 'Identifier':
394
+ babelNode.name = node.value;
395
+ break;
396
+
397
+ case 'PrivateName':
398
+ return {
399
+ type: 'PrivateName',
400
+ id: convertSWCNode(node.id || { type: 'Identifier', value: node.name }),
401
+ };
402
+
403
+ case 'KeyValueProperty':
404
+ case 'ShorthandProperty':
405
+ babelNode.type = 'ObjectProperty';
406
+ const keyNode = node.key;
407
+ const isComputedKey = keyNode?.type === 'Computed';
408
+ const normalizedKey = normalizeMemberProperty(isComputedKey ? keyNode.expression : keyNode, node.computed);
409
+ babelNode.key = normalizedKey.property;
410
+ babelNode.value = convertSWCNode(node.value);
411
+ babelNode.computed = normalizedKey.computed || isComputedKey || node.computed || false;
412
+ babelNode.shorthand = swcType === 'ShorthandProperty';
413
+ babelNode.method = false;
414
+ break;
415
+
416
+ case 'GetterProperty':
417
+ case 'SetterProperty':
418
+ case 'MethodProperty':
419
+ babelNode.type = 'ObjectMethod';
420
+ const objMethodKey = node.key;
421
+ const objMethodComputed = objMethodKey?.type === 'Computed';
422
+ const normalizedObjMethodKey = normalizeMemberProperty(objMethodComputed ? objMethodKey.expression : objMethodKey, node.computed);
423
+ babelNode.key = normalizedObjMethodKey.property;
424
+ babelNode.kind = swcType === 'GetterProperty' ? 'get' :
425
+ swcType === 'SetterProperty' ? 'set' : 'method';
426
+ babelNode.params = convertSWCNode(normalizeParams(node.params));
427
+ babelNode.body = convertSWCNode(node.body);
428
+ babelNode.computed = normalizedObjMethodKey.computed || objMethodComputed || node.computed || false;
429
+ babelNode.generator = node.generator || false;
430
+ babelNode.async = node.async || false;
431
+ break;
432
+
433
+ case 'ImportDeclaration':
434
+ babelNode.source = convertSWCNode(node.source);
435
+ babelNode.specifiers = convertSWCNode(node.specifiers || []);
436
+ babelNode.importKind = node.typeOnly ? 'type' : 'value';
437
+ break;
438
+ case 'BlockStatement':
439
+ babelNode.body = convertSWCNode(node.body || node.stmts || []);
440
+ break;
441
+
442
+ case 'ReturnStatement':
443
+ babelNode.argument = convertSWCNode(node.argument ?? node.value ?? node.expr ?? null);
444
+ break;
445
+
446
+ case 'ExpressionStatement':
447
+ babelNode.expression = convertSWCNode(node.expression ?? node.expr);
448
+ break;
449
+
450
+ case 'ImportSpecifier':
451
+ babelNode.imported = convertSWCNode(node.imported || node.local);
452
+ babelNode.local = convertSWCNode(node.local);
453
+ break;
454
+
455
+ case 'ImportDefaultSpecifier':
456
+ babelNode.local = convertSWCNode(node.local);
457
+ break;
458
+
459
+ case 'ImportNamespaceSpecifier':
460
+ babelNode.local = convertSWCNode(node.local);
461
+ break;
462
+
463
+ case 'ExportNamedDeclaration':
464
+ babelNode.declaration = convertSWCNode(node.declaration);
465
+ babelNode.specifiers = convertSWCNode(node.specifiers || []);
466
+ babelNode.source = convertSWCNode(node.source);
467
+ break;
468
+
469
+ case 'ExportDefaultDeclaration':
470
+ babelNode.declaration = convertSWCNode(node.decl || node.declaration);
471
+ break;
472
+
473
+ case 'VariableDeclaration':
474
+ babelNode.kind = node.kind;
475
+ babelNode.declarations = convertSWCNode(node.declarations);
476
+ break;
477
+
478
+ case 'VariableDeclarator':
479
+ babelNode.id = convertSWCNode(node.id);
480
+ babelNode.init = convertSWCNode(node.init);
481
+ break;
482
+
483
+ case 'FunctionDeclaration':
484
+ case 'FunctionExpression':
485
+ babelNode.id = convertSWCNode(node.identifier);
486
+ babelNode.params = convertSWCNode(normalizeParams(node.params));
487
+ babelNode.body = convertSWCNode(node.body);
488
+ babelNode.generator = node.generator || false;
489
+ babelNode.async = node.async || false;
490
+ break;
491
+
492
+ case 'ArrowFunctionExpression':
493
+ babelNode.params = convertSWCNode(normalizeParams(node.params));
494
+ babelNode.body = convertSWCNode(node.body);
495
+ babelNode.async = node.async || false;
496
+ babelNode.expression = node.body?.type !== 'BlockStatement';
497
+ break;
498
+
499
+ case 'ClassDeclaration':
500
+ case 'ClassExpression':
501
+ babelNode.id = convertSWCNode(node.identifier || node.id);
502
+ babelNode.superClass = convertSWCNode(node.superClass);
503
+ babelNode.decorators = convertSWCNode(node.decorators || []);
504
+ babelNode.body = {
505
+ type: 'ClassBody',
506
+ body: convertSWCNode(node.body?.body || node.body || []),
507
+ };
508
+ break;
509
+
510
+ case 'ClassMethod':
511
+ case 'ClassPrivateMethod':
512
+ case 'Constructor':
513
+ const classMethodKey = node.key;
514
+ const classMethodComputed = classMethodKey?.type === 'Computed';
515
+ const normalizedClassMethodKey = normalizeMemberProperty(classMethodComputed ? classMethodKey.expression : classMethodKey, node.computed);
516
+ babelNode.key = normalizedClassMethodKey.property;
517
+ babelNode.kind = swcType === 'Constructor' ? 'constructor' : (node.kind || 'method');
518
+ babelNode.params = convertSWCNode(normalizeParams(node.function?.params || node.params));
519
+ babelNode.body = convertSWCNode(node.function?.body || node.body);
520
+ babelNode.computed = normalizedClassMethodKey.computed || classMethodComputed || node.computed || false;
521
+ babelNode.static = node.isStatic || node.static || false;
522
+ babelNode.async = node.function?.isAsync || node.async || false;
523
+ babelNode.generator = node.function?.isGenerator || node.generator || false;
524
+ break;
525
+
526
+ case 'ClassProperty':
527
+ case 'ClassPrivateProperty':
528
+ const classPropKey = node.key;
529
+ const classPropComputed = classPropKey?.type === 'Computed';
530
+ const normalizedClassPropKey = normalizeMemberProperty(classPropComputed ? classPropKey.expression : classPropKey, node.computed);
531
+ babelNode.key = normalizedClassPropKey.property;
532
+ babelNode.value = convertSWCNode(node.value);
533
+ babelNode.computed = normalizedClassPropKey.computed || classPropComputed || node.computed || false;
534
+ babelNode.static = node.isStatic || node.static || false;
535
+ break;
536
+
537
+ case 'CallExpression':
538
+ babelNode.callee = convertSWCNode(node.callee);
539
+ babelNode.arguments = convertSWCNode(node.arguments || []);
540
+ break;
541
+
542
+ case 'OptionalChainingExpression': {
543
+ const base = node.base || node.expression || node.expr || node.argument;
544
+ const converted = convertSWCNode(base);
545
+
546
+ if (converted && (converted.type === 'MemberExpression' || converted.type === 'OptionalMemberExpression')) {
547
+ converted.type = 'OptionalMemberExpression';
548
+ converted.optional = true;
549
+ }
550
+
551
+ if (converted && (converted.type === 'CallExpression' || converted.type === 'OptionalCallExpression')) {
552
+ converted.type = 'OptionalCallExpression';
553
+ converted.optional = true;
554
+ }
555
+
556
+ return converted;
557
+ }
558
+
559
+ case 'MemberExpression':
560
+ babelNode.object = convertSWCNode(node.object);
561
+ const memberProp = normalizeMemberProperty(node.property, node.computed);
562
+ babelNode.property = memberProp.property;
563
+ babelNode.computed = memberProp.computed;
564
+ babelNode.optional = node.optional || false;
565
+ break;
566
+ case 'NewExpression':
567
+ babelNode.callee = convertSWCNode(node.callee);
568
+ babelNode.arguments = convertSWCNode(node.arguments || []);
569
+ break;
570
+ case 'OptionalCallExpression':
571
+ babelNode.callee = convertSWCNode(node.callee);
572
+ babelNode.arguments = convertSWCNode(node.arguments || []);
573
+ babelNode.optional = true;
574
+ break;
575
+
576
+ case 'JSXElement':
577
+ babelNode.openingElement = convertSWCNode(node.opening);
578
+ babelNode.closingElement = convertSWCNode(node.closing);
579
+ babelNode.children = convertSWCNode(node.children || []);
580
+ babelNode.selfClosing = !node.closing;
581
+ break;
582
+
583
+ case 'JSXOpeningElement':
584
+ babelNode.name = convertSWCNode(node.name);
585
+ babelNode.attributes = convertSWCNode(node.attributes || []);
586
+ babelNode.selfClosing = node.selfClosing || false;
587
+ break;
588
+
589
+ case 'JSXClosingElement':
590
+ babelNode.name = convertSWCNode(node.name);
591
+ break;
592
+
593
+ case 'JSXAttribute':
594
+ babelNode.name = convertSWCNode(node.name);
595
+ babelNode.value = convertSWCNode(node.value);
596
+ break;
597
+
598
+ case 'JSXIdentifier':
599
+ babelNode.name = node.value;
600
+ break;
601
+
602
+ case 'JSXText':
603
+ babelNode.value = node.value;
604
+ babelNode.raw = node.raw || node.value;
605
+ break;
606
+
607
+ case 'TemplateElement':
608
+ return {
609
+ type: 'TemplateElement',
610
+ value: {
611
+ raw: node.raw ?? node.value?.raw ?? node.cooked ?? '',
612
+ cooked: node.cooked ?? node.value?.cooked ?? node.raw ?? '',
613
+ },
614
+ tail: node.tail ?? false,
615
+ };
616
+
617
+ case 'JSXExpressionContainer':
618
+ babelNode.expression = convertSWCNode(node.expression);
619
+ break;
620
+
621
+ case 'JSXFragment':
622
+ babelNode.openingFragment = { type: 'JSXOpeningFragment' };
623
+ babelNode.closingFragment = { type: 'JSXClosingFragment' };
624
+ babelNode.children = convertSWCNode(node.children || []);
625
+ break;
626
+
627
+ default:
628
+ // ͨ�ô������ݹ�ת����������
629
+ for (const key of Object.keys(node)) {
630
+ if (key === 'type' || key === 'span' || key === 'ctxt') continue;
631
+ babelNode[key] = convertSWCNode(node[key]);
632
+ }
633
+ }
634
+
635
+ return babelNode;
636
+ }
637
+
638
+ /**
639
+ * �� SWC AST ת��Ϊ Babel ���ݸ�ʽ
640
+ */
641
+ export function convertSWCToBabel(swcAst: any): t.File {
642
+ const startTime = performance.now();
643
+ const result = convertSWCNode(swcAst) as t.File;
644
+ const duration = performance.now() - startTime;
645
+
646
+ swcStats.conversionCount++;
647
+ swcStats.conversionTotalTime += duration;
648
+
649
+ return result;
650
+ }
651
+
652
+ /**
653
+ * ʹ�� SWC ��������
654
+ * ��� SWC �����ã����˵� Babel
655
+ */
656
+ export function parseWithSWC(code: string): t.File {
657
+ const safeCode = sanitizePermissionCommentsForJSX(code);
658
+ if (!swcAvailable || !swcModule) {
659
+ // ���˵� Babel
660
+ const startTime = performance.now();
661
+ const ast = babelParse(safeCode, babelParserConfig);
662
+ swcStats.babelFallbackCount++;
663
+ swcStats.babelTotalTime += performance.now() - startTime;
664
+ return ast;
665
+ }
666
+
667
+ try {
668
+ // ʹ�� SWC ����
669
+ const startTime = performance.now();
670
+ const swcAst = swcModule.parseSync(safeCode, swcParserConfig);
671
+ const parseTime = performance.now() - startTime;
672
+
673
+ swcStats.swcParseCount++;
674
+ swcStats.swcTotalTime += parseTime;
675
+
676
+ // ת��Ϊ Babel ��ʽ
677
+ return convertSWCToBabel(swcAst);
678
+ } catch (error) {
679
+ // ����ʧ�ܣ����˵� Babel
680
+ console.warn('[SWC] ����ʧ�ܣ����˵� Babel:', error);
681
+ const startTime = performance.now();
682
+ const ast = babelParse(safeCode, babelParserConfig);
683
+ swcStats.babelFallbackCount++;
684
+ swcStats.babelTotalTime += performance.now() - startTime;
685
+ return ast;
686
+ }
687
+ }
688
+
689
+ /**
690
+ * �첽ʹ�� SWC ��������
691
+ */
692
+ export async function parseWithSWCAsync(code: string): Promise<t.File> {
693
+ // ȷ�� SWC �ѳ�ʼ��
694
+ await initSWC();
695
+ return parseWithSWC(code);
696
+ }
697
+
698
+ /**
699
+ * ��ȡ SWC ����ͳ��
700
+ */
701
+ export function getSWCStats() {
702
+ return {
703
+ ...swcStats,
704
+ swcAvailable,
705
+ swcAverageParseTime: swcStats.swcParseCount > 0
706
+ ? swcStats.swcTotalTime / swcStats.swcParseCount
707
+ : 0,
708
+ babelAverageTime: swcStats.babelFallbackCount > 0
709
+ ? swcStats.babelTotalTime / swcStats.babelFallbackCount
710
+ : 0,
711
+ conversionAverageTime: swcStats.conversionCount > 0
712
+ ? swcStats.conversionTotalTime / swcStats.conversionCount
713
+ : 0,
714
+ speedup: swcStats.babelFallbackCount > 0 && swcStats.swcParseCount > 0
715
+ ? (swcStats.babelTotalTime / swcStats.babelFallbackCount) /
716
+ ((swcStats.swcTotalTime + swcStats.conversionTotalTime) / swcStats.swcParseCount)
717
+ : 0,
718
+ };
719
+ }
720
+
721
+ /**
722
+ * ��ӡ SWC ���ܱ���
723
+ */
724
+ export function printSWCReport(): void {
725
+ const stats = getSWCStats();
726
+
727
+ console.log('%c=== SWC Parser Report ===', 'color: #FF5722; font-weight: bold;');
728
+ console.log(`SWC ����: ${stats.swcAvailable ? '?' : '?'}`);
729
+ console.log(`%cSWC ��������: ${stats.swcParseCount}`, 'color: #4CAF50;');
730
+ console.log(`%cSWC �ܺ�ʱ: ${stats.swcTotalTime.toFixed(2)}ms`, 'color: #4CAF50;');
731
+ console.log(`%cSWC ƽ����ʱ: ${stats.swcAverageParseTime.toFixed(2)}ms`, 'color: #4CAF50;');
732
+ console.log(`%cBabel ���˴���: ${stats.babelFallbackCount}`, 'color: #FF9800;');
733
+ console.log(`%cBabel �ܺ�ʱ: ${stats.babelTotalTime.toFixed(2)}ms`, 'color: #FF9800;');
734
+ console.log(`%cBabel ƽ����ʱ: ${stats.babelAverageTime.toFixed(2)}ms`, 'color: #FF9800;');
735
+ console.log(`AST ת������: ${stats.conversionCount}`);
736
+ console.log(`AST ת��ƽ����ʱ: ${stats.conversionAverageTime.toFixed(2)}ms`);
737
+ if (stats.speedup > 0) {
738
+ console.log(`%c���ٱ�: ${stats.speedup.toFixed(1)}x`, 'color: #E91E63; font-weight: bold;');
739
+ }
740
+ console.log('%c=========================', 'color: #FF5722; font-weight: bold;');
741
+ }
742
+
743
+ // ��¶��ȫ�֣��������
744
+ if (typeof window !== 'undefined') {
745
+ (window as any).__SWC_PARSER__ = {
746
+ initSWC,
747
+ isSWCAvailable,
748
+ parseWithSWC,
749
+ parseWithSWCAsync,
750
+ getSWCStats,
751
+ printSWCReport,
752
+ };
753
+ }