@lcap/nasl-unified-frontend-generator 3.8.3-beta.33 → 3.8.3-beta.33-optimize
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +392 -233
- package/dist/index.d.ts +392 -233
- package/dist/index.js +317 -197
- package/dist/index.mjs +319 -199
- package/dist/playground.js +320 -200
- package/dist/playground.mjs +320 -200
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _lcap_nasl from '@lcap/nasl';
|
|
2
|
-
import { App, Frontend, LogicItem, genMetaData, FrontendVariable, TypeAnnotation, DefaultValue, Logic, BindAttribute, BindDirective, BindEvent, View, ViewElement, ValidationRule, Identifier, Return, Variable, Param, BindStyle } from '@lcap/nasl';
|
|
2
|
+
import { App, Frontend, LogicItem, genMetaData, FrontendVariable, TypeAnnotation, DefaultValue, Logic, BindAttribute, BindDirective, BindEvent, BusinessComponent, View, ViewElement, ValidationRule, Identifier, Return, Variable, Param, BaseNode, BindStyle } from '@lcap/nasl';
|
|
3
3
|
import { Container } from 'inversify';
|
|
4
4
|
import { format } from 'prettier/standalone';
|
|
5
5
|
import pino from 'pino';
|
|
@@ -39,8 +39,10 @@ interface PlatformConfig {
|
|
|
39
39
|
basePath: string;
|
|
40
40
|
sysPrefixPath: string;
|
|
41
41
|
frontendName: string;
|
|
42
|
+
isPreviewFe: boolean;
|
|
42
43
|
}
|
|
43
44
|
interface AppConfig {
|
|
45
|
+
id: string;
|
|
44
46
|
project: string;
|
|
45
47
|
domainName: string;
|
|
46
48
|
extendedConfig?: any;
|
|
@@ -55,6 +57,11 @@ interface AppConfig {
|
|
|
55
57
|
tenantType: string;
|
|
56
58
|
tenantLevel: string;
|
|
57
59
|
documentTitle: string;
|
|
60
|
+
basePath: string;
|
|
61
|
+
sysPrefixPath: string;
|
|
62
|
+
frontendName: string;
|
|
63
|
+
rootViewData: undefined;
|
|
64
|
+
appTimeZone: string | undefined;
|
|
58
65
|
}
|
|
59
66
|
interface I18nInfo {
|
|
60
67
|
enabled: boolean;
|
|
@@ -65,7 +72,7 @@ interface I18nInfo {
|
|
|
65
72
|
declare const metadataPlugin: {
|
|
66
73
|
name: string;
|
|
67
74
|
functions: {
|
|
68
|
-
makeBasePlatformConfig(app: Pick<App, 'name' | 'dnsAddr' | 'hasUserCenter' | 'hasAuth' | 'sysPrefixPath'>, frontend: Frontend, config: CommonAppConfig): BasePlatformConfig;
|
|
75
|
+
makeBasePlatformConfig(app: Pick<App, 'name' | 'dnsAddr' | 'hasUserCenter' | 'hasAuth' | 'sysPrefixPath' | 'id' | 'appTimeZone'>, frontend: Frontend, config: CommonAppConfig): BasePlatformConfig;
|
|
69
76
|
};
|
|
70
77
|
};
|
|
71
78
|
|
|
@@ -89,7 +96,8 @@ type LegacyMetaData = ReturnType<typeof genMetaData>;
|
|
|
89
96
|
* @public
|
|
90
97
|
*/
|
|
91
98
|
type NASLAppIR = {
|
|
92
|
-
views:
|
|
99
|
+
views: ViewComponentIR[];
|
|
100
|
+
bizComponents: BizComponentIR[];
|
|
93
101
|
apis: LogicIR[];
|
|
94
102
|
packages: Package[];
|
|
95
103
|
baseCtx: StateContextIR;
|
|
@@ -112,10 +120,6 @@ type Package = {
|
|
|
112
120
|
kind: 'standard' | 'extension';
|
|
113
121
|
name: string;
|
|
114
122
|
version: string;
|
|
115
|
-
/**
|
|
116
|
-
* TODO wudengke 根据实际情况确定Css
|
|
117
|
-
*/
|
|
118
|
-
hasCss?: boolean;
|
|
119
123
|
};
|
|
120
124
|
type IdentifierString = string & {
|
|
121
125
|
readonly __tag?: unique symbol;
|
|
@@ -242,10 +246,7 @@ type BindEventIR = {
|
|
|
242
246
|
*/
|
|
243
247
|
handlerName: string;
|
|
244
248
|
};
|
|
245
|
-
|
|
246
|
-
* 组件声明
|
|
247
|
-
*/
|
|
248
|
-
type ComponentIR = {
|
|
249
|
+
type BaseComponentIR = {
|
|
249
250
|
/**
|
|
250
251
|
* 组件名
|
|
251
252
|
*/
|
|
@@ -258,16 +259,41 @@ type ComponentIR = {
|
|
|
258
259
|
* 组件的元素调用
|
|
259
260
|
*/
|
|
260
261
|
elements: ComponentInstanceIR[];
|
|
262
|
+
};
|
|
263
|
+
type SubComponentIR = BaseComponentIR & {
|
|
264
|
+
kind: 'sub-component';
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* 业务组件声明
|
|
268
|
+
*/
|
|
269
|
+
type BizComponentIR = BaseComponentIR & {
|
|
270
|
+
kind: 'biz-component';
|
|
261
271
|
/**
|
|
262
|
-
*
|
|
272
|
+
* 对原始NASL View的引用
|
|
273
|
+
* @deprecated
|
|
263
274
|
*/
|
|
264
|
-
|
|
275
|
+
__raw: BusinessComponent;
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* 组件声明
|
|
279
|
+
*/
|
|
280
|
+
type ViewComponentIR = BaseComponentIR & {
|
|
281
|
+
kind: 'view';
|
|
265
282
|
/**
|
|
266
283
|
* 对原始NASL View的引用
|
|
267
284
|
* @deprecated
|
|
268
285
|
*/
|
|
269
286
|
__raw: View;
|
|
287
|
+
/**
|
|
288
|
+
* 子页面组件声明
|
|
289
|
+
* FIXME wudengke 换更好的名字。现在页面可以是组件,子页面、元素也可以是组件
|
|
290
|
+
*/
|
|
291
|
+
childComponents: ViewComponentIR[];
|
|
270
292
|
};
|
|
293
|
+
/**
|
|
294
|
+
* 组件声明
|
|
295
|
+
*/
|
|
296
|
+
type GeneralComponentIR = BizComponentIR | ViewComponentIR;
|
|
271
297
|
/**
|
|
272
298
|
* 被引用的库组件
|
|
273
299
|
*/
|
|
@@ -276,6 +302,10 @@ type ReferencedLibComponent = {
|
|
|
276
302
|
libraryName: string;
|
|
277
303
|
tag: string;
|
|
278
304
|
};
|
|
305
|
+
type ReferencedSubComponentIR = {
|
|
306
|
+
kind: SubComponentIR['kind'];
|
|
307
|
+
tag: string;
|
|
308
|
+
};
|
|
279
309
|
/**
|
|
280
310
|
* 被引用的组件
|
|
281
311
|
*
|
|
@@ -283,16 +313,16 @@ type ReferencedLibComponent = {
|
|
|
283
313
|
*
|
|
284
314
|
* @public
|
|
285
315
|
*/
|
|
286
|
-
type ReferencedComponent = ReferencedLibComponent | {
|
|
316
|
+
type ReferencedComponent = ReferencedSubComponentIR | ReferencedLibComponent | {
|
|
287
317
|
/**
|
|
288
|
-
*
|
|
318
|
+
* 业务组件
|
|
289
319
|
*/
|
|
290
|
-
kind: '
|
|
320
|
+
kind: BizComponentIR['kind'];
|
|
291
321
|
/**
|
|
292
322
|
* 组件标签名
|
|
293
323
|
*/
|
|
294
324
|
tag: string;
|
|
295
|
-
|
|
325
|
+
libraryName: string;
|
|
296
326
|
};
|
|
297
327
|
/**
|
|
298
328
|
* 对组件声明的调用
|
|
@@ -300,6 +330,10 @@ type ReferencedComponent = ReferencedLibComponent | {
|
|
|
300
330
|
* @public
|
|
301
331
|
*/
|
|
302
332
|
type ComponentInstanceIR = {
|
|
333
|
+
/**
|
|
334
|
+
* 元素名字
|
|
335
|
+
*/
|
|
336
|
+
name: string;
|
|
303
337
|
/**
|
|
304
338
|
* 持有的对组件声明的引用
|
|
305
339
|
*/
|
|
@@ -320,7 +354,10 @@ type ComponentInstanceIR = {
|
|
|
320
354
|
* 组件子元素的实例
|
|
321
355
|
*/
|
|
322
356
|
children: ComponentInstanceIR[];
|
|
323
|
-
|
|
357
|
+
/**
|
|
358
|
+
* @deprecated
|
|
359
|
+
*/
|
|
360
|
+
__raw?: ViewElement;
|
|
324
361
|
/**
|
|
325
362
|
* 插槽配置
|
|
326
363
|
*/
|
|
@@ -328,6 +365,7 @@ type ComponentInstanceIR = {
|
|
|
328
365
|
target: string | undefined;
|
|
329
366
|
scope: string | undefined;
|
|
330
367
|
};
|
|
368
|
+
kind: 'component-instance';
|
|
331
369
|
};
|
|
332
370
|
|
|
333
371
|
/**
|
|
@@ -344,7 +382,6 @@ type BaseStateIR = {
|
|
|
344
382
|
identifier: IdentifierString;
|
|
345
383
|
/**
|
|
346
384
|
* 状态的类型
|
|
347
|
-
* TODO wudengke 去掉 null!
|
|
348
385
|
*/
|
|
349
386
|
typeAnnotation: TypeAnnotationIR | null;
|
|
350
387
|
};
|
|
@@ -353,6 +390,10 @@ type LocalLogicStateIR = BaseStateIR & {
|
|
|
353
390
|
initialization: {
|
|
354
391
|
kind: 'static';
|
|
355
392
|
value: ExprIR;
|
|
393
|
+
} | {
|
|
394
|
+
kind: 'props';
|
|
395
|
+
defaultValue?: ExprIR;
|
|
396
|
+
__raw: ParamIR;
|
|
356
397
|
} | {
|
|
357
398
|
kind: 'url-param';
|
|
358
399
|
defaultValue?: ExprIR;
|
|
@@ -371,13 +412,22 @@ type TreeStateIR = BaseStateIR & {
|
|
|
371
412
|
kind: 'api-client';
|
|
372
413
|
};
|
|
373
414
|
};
|
|
374
|
-
type
|
|
415
|
+
type LocalIndividualStateIRComponentRef = {
|
|
375
416
|
kind: 'standalone';
|
|
376
417
|
initialization: {
|
|
377
418
|
kind: 'component-ref';
|
|
378
419
|
componentName: ComponentName;
|
|
379
420
|
};
|
|
380
421
|
};
|
|
422
|
+
type LocalVariableStateIR = {
|
|
423
|
+
kind: 'standalone';
|
|
424
|
+
initialization: {
|
|
425
|
+
kind: 'variable';
|
|
426
|
+
left: string;
|
|
427
|
+
right: string;
|
|
428
|
+
};
|
|
429
|
+
};
|
|
430
|
+
type LocalIndividualStateIR = BaseStateIR & (LocalIndividualStateIRComponentRef | LocalVariableStateIR);
|
|
381
431
|
/**
|
|
382
432
|
* 状态
|
|
383
433
|
*/
|
|
@@ -392,11 +442,20 @@ declare class StateActionIR {
|
|
|
392
442
|
* @example handleClick
|
|
393
443
|
*/
|
|
394
444
|
name: string;
|
|
395
|
-
kind: '
|
|
445
|
+
kind: 'standalone'
|
|
446
|
+
/**
|
|
447
|
+
* 页面级别的生命周期
|
|
448
|
+
*/
|
|
449
|
+
| 'view-lifecycle'
|
|
450
|
+
/**
|
|
451
|
+
* 端级别的生命周期
|
|
452
|
+
*/
|
|
453
|
+
| 'frontend-lifecycle';
|
|
396
454
|
constructor(props: StateActionIR);
|
|
397
455
|
}
|
|
456
|
+
declare function isLocalIndividualStateIRComponentRef(ir: StateIR): ir is LocalIndividualStateIR & LocalIndividualStateIRComponentRef;
|
|
398
457
|
|
|
399
|
-
type Other = Return | Variable | Param | DefaultValue;
|
|
458
|
+
type Other = Return | Variable | Param | DefaultValue | BaseNode;
|
|
400
459
|
type HasRuntimeSemantics = LogicItem | Logic | Other;
|
|
401
460
|
type javaScriptCodeGenCallBackBag = {
|
|
402
461
|
resolve?: (payload: {
|
|
@@ -409,20 +468,25 @@ type javaScriptCodeGenCallBackBag = {
|
|
|
409
468
|
string | undefined;
|
|
410
469
|
shouldInsertOptional?: boolean;
|
|
411
470
|
};
|
|
412
|
-
declare function getRuntimeStr(s: HasRuntimeSemantics, callbackBag?: javaScriptCodeGenCallBackBag): string;
|
|
413
471
|
type IdentifierResolver = (id: Identifier) => string | undefined;
|
|
414
472
|
type IdentifierNameResolver = (id: string) => string | undefined;
|
|
415
473
|
declare const javaScriptCodeGenPlugin: {
|
|
416
474
|
name: string;
|
|
417
475
|
functions: {
|
|
418
476
|
printSyntaxNode(expr: HasRuntimeSemantics, callbackBag?: Partial<javaScriptCodeGenCallBackBag>): string;
|
|
419
|
-
printParamIR(p: ParamIR): string;
|
|
420
477
|
};
|
|
421
478
|
};
|
|
479
|
+
/**
|
|
480
|
+
* JavaScript 代码生成插件
|
|
481
|
+
*
|
|
482
|
+
* @public
|
|
483
|
+
*/
|
|
484
|
+
declare class JavaScriptCodegenPlugin implements JavaScriptDomain.JavaScriptCodegen {
|
|
485
|
+
printSyntaxNode(expr: HasRuntimeSemantics, callbackBag?: Partial<javaScriptCodeGenCallBackBag>): string;
|
|
486
|
+
}
|
|
422
487
|
|
|
423
488
|
interface StateManager {
|
|
424
489
|
resolveIdentifier: IdentifierResolver;
|
|
425
|
-
resolveName: IdentifierNameResolver;
|
|
426
490
|
resolveCalleeNamespace: IdentifierNameResolver;
|
|
427
491
|
}
|
|
428
492
|
interface SyntaxNodePrinter<SyntaxNode> {
|
|
@@ -442,6 +506,8 @@ declare class StateContextIR {
|
|
|
442
506
|
* @returns
|
|
443
507
|
*/
|
|
444
508
|
static fromParent(parentCtx: StateContextIR | null): StateContextIR;
|
|
509
|
+
setParent(parentCtx: StateContextIR | null): this;
|
|
510
|
+
static create(): StateContextIR;
|
|
445
511
|
provide(state: StateIR): this;
|
|
446
512
|
provideAction(action: StateActionIR): this;
|
|
447
513
|
findStateByName(name: string): StateIR | undefined;
|
|
@@ -453,20 +519,134 @@ type DeepReadonly<T> = {
|
|
|
453
519
|
};
|
|
454
520
|
type FinalizedStateContextIR = DeepReadonly<StateContextIR>;
|
|
455
521
|
declare function paramToIR(param: Param): ParamIR;
|
|
456
|
-
declare function bindAttrToIR(b: BindAttribute | {
|
|
522
|
+
declare function bindAttrToIR(b: BindAttribute | (Omit<BindAttribute, 'type' | 'name' | 'rules'> & {
|
|
523
|
+
type: undefined;
|
|
524
|
+
name: 'rules';
|
|
525
|
+
rules: ValidationRule[];
|
|
526
|
+
}) | {
|
|
457
527
|
type: 'component';
|
|
458
528
|
component: ComponentInstanceIR;
|
|
459
529
|
scopeVariable: string | undefined;
|
|
460
530
|
name: string;
|
|
461
|
-
}): BindAttributeIR;
|
|
531
|
+
}): BindAttributeIR | undefined;
|
|
462
532
|
declare function logicToLogicIR(logic: Logic): LogicIR;
|
|
533
|
+
declare function inferChangeEventNameFromAttrName(attrName: string): string;
|
|
463
534
|
declare function bindViewElementEventToIR(b: BindEvent): BindEventIR;
|
|
464
535
|
declare function bindEventToAction(b: BindEventIR): StateActionIR;
|
|
465
536
|
declare const ApiClientIdentifier = "apiClient";
|
|
466
537
|
declare class NASLAppIRBuilderPlugin implements NASLDomain.IRBuilder {
|
|
538
|
+
private preProcessors?;
|
|
539
|
+
private postProcessors?;
|
|
540
|
+
constructor(preProcessors?: NASLDomain.IRPreProcesser[] | undefined, postProcessors?: NASLDomain.IRPostProcesser[] | undefined);
|
|
541
|
+
private selfBuildIR;
|
|
467
542
|
buildIR(app: App, frontend: Frontend, config: CommonAppConfig): NASLAppIR;
|
|
468
543
|
}
|
|
469
544
|
|
|
545
|
+
type JSXNode = string;
|
|
546
|
+
type JSXRepr = string;
|
|
547
|
+
declare function styleStringToInlineObject(staticStyle: string): Record<string, unknown>;
|
|
548
|
+
declare const jsxCodeGenPlugin: {
|
|
549
|
+
name: string;
|
|
550
|
+
functions: {
|
|
551
|
+
printTag(tagName: string): JSXRepr;
|
|
552
|
+
};
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
declare const defaultErrorMessageDict: Record<string, string | undefined>;
|
|
556
|
+
|
|
557
|
+
type PrettierOptions = NonNullable<Parameters<typeof format>[1]>;
|
|
558
|
+
declare const codeFormatPlugin: {
|
|
559
|
+
name: string;
|
|
560
|
+
functions: {
|
|
561
|
+
format(str: string, options?: PrettierOptions): Promise<string>;
|
|
562
|
+
};
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
type RouteIR = {
|
|
566
|
+
accumulativePath: string;
|
|
567
|
+
thisLevelPath: string;
|
|
568
|
+
elementMangledName?: string;
|
|
569
|
+
elementTemplate: ViewComponentIR;
|
|
570
|
+
children?: RouteIR[];
|
|
571
|
+
authConfig?: AuthConfig;
|
|
572
|
+
kind: 'normal';
|
|
573
|
+
lazy?: boolean;
|
|
574
|
+
meta: {
|
|
575
|
+
title: string;
|
|
576
|
+
crumb: string;
|
|
577
|
+
};
|
|
578
|
+
} | {
|
|
579
|
+
accumulativePath: string;
|
|
580
|
+
thisLevelPath: string;
|
|
581
|
+
redirect: string;
|
|
582
|
+
kind: 'redirect';
|
|
583
|
+
};
|
|
584
|
+
type AuthConfig = unknown;
|
|
585
|
+
declare const routesExtractionPlugin: {
|
|
586
|
+
name: string;
|
|
587
|
+
functions: {
|
|
588
|
+
extractRoute(components: ViewComponentIR[], routePrefix: string, options?: {
|
|
589
|
+
lazy?: boolean;
|
|
590
|
+
}): {
|
|
591
|
+
routes: RouteIR[];
|
|
592
|
+
authResourcePaths: string[];
|
|
593
|
+
baseResourcePaths: string[];
|
|
594
|
+
};
|
|
595
|
+
};
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* 微前端插件
|
|
600
|
+
*/
|
|
601
|
+
declare class MicroFrontendPlugin implements JavaScriptDomain.FrontendApplicationDomain.MicroFrontendManager {
|
|
602
|
+
produceScript(frontend: Frontend): string;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* 生命周期钩子插件
|
|
607
|
+
*/
|
|
608
|
+
declare class LifeCycleHooksPlugin implements GeneratorInfrastructureDomain.CodeGenerationLifecycleHooks {
|
|
609
|
+
protected fileSystemProvider: GeneratorInfrastructureDomain.FileSystemProvider;
|
|
610
|
+
constructor(fileSystemProvider: GeneratorInfrastructureDomain.FileSystemProvider);
|
|
611
|
+
afterAllFilesGenerated(): void;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* 文件系统插件
|
|
616
|
+
*/
|
|
617
|
+
declare class FileSystemPlugin implements GeneratorInfrastructureDomain.FileSystemProvider {
|
|
618
|
+
private vol;
|
|
619
|
+
read(path: string): string | undefined;
|
|
620
|
+
write(path: string, content: string): void;
|
|
621
|
+
remove(key: string): void;
|
|
622
|
+
toJSON(): Record<string, string | null>;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
declare class ReactPresetPlugin implements Generator.NASLTranspiler {
|
|
626
|
+
private irBuilder;
|
|
627
|
+
private microFrontendManager;
|
|
628
|
+
private fileSystemProvider;
|
|
629
|
+
private reactCodeGenerator;
|
|
630
|
+
constructor(irBuilder: NASLDomain.IRBuilder, microFrontendManager: JavaScriptDomain.FrontendApplicationDomain.MicroFrontendManager, fileSystemProvider: GeneratorInfrastructureDomain.FileSystemProvider, reactCodeGenerator: JavaScriptDomain.FrontendApplicationDomain.ReactDomain.ReactCodegen);
|
|
631
|
+
transpile(instruction: {
|
|
632
|
+
app: App;
|
|
633
|
+
frontend: Frontend;
|
|
634
|
+
config: CommonAppConfig;
|
|
635
|
+
baseDir: string;
|
|
636
|
+
}): Promise<OrganizedFile[]>;
|
|
637
|
+
static install(container: Container): Container;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* React Slot 插件
|
|
642
|
+
* @public
|
|
643
|
+
*/
|
|
644
|
+
declare class ReactSlotPlugin implements NASLDomain.IRPostProcesser {
|
|
645
|
+
postProcess(ir: NASLAppIR, config: CommonAppConfig): NASLAppIR;
|
|
646
|
+
static preprocessForSlots(c: ComponentInstanceIR): void;
|
|
647
|
+
static install(c: Container): Container;
|
|
648
|
+
}
|
|
649
|
+
|
|
470
650
|
type Folder = {
|
|
471
651
|
name: string;
|
|
472
652
|
};
|
|
@@ -543,7 +723,7 @@ type ReactHook = {
|
|
|
543
723
|
* @param c
|
|
544
724
|
* @returns
|
|
545
725
|
*/
|
|
546
|
-
declare function getComponentName(c:
|
|
726
|
+
declare function getComponentName(c: GeneralComponentIR | ComponentInstanceIR): string;
|
|
547
727
|
/**
|
|
548
728
|
* React 逻辑片段输出为JSX时可以控制的选项
|
|
549
729
|
*/
|
|
@@ -558,14 +738,22 @@ declare const ReactChildrenPropName = "children";
|
|
|
558
738
|
/**
|
|
559
739
|
* React 逻辑片段构造时可用的选项
|
|
560
740
|
*/
|
|
561
|
-
|
|
741
|
+
type ReactFragmentOption = Partial<Pick<ComponentInstanceIR, 'slot'>> & {
|
|
562
742
|
/**
|
|
563
743
|
* 混淆之后的名字
|
|
564
744
|
*
|
|
565
745
|
* 若不传此选项则不混淆名字
|
|
566
746
|
*/
|
|
567
747
|
mangledName?: string;
|
|
568
|
-
}
|
|
748
|
+
} & ({
|
|
749
|
+
kind?: 'view';
|
|
750
|
+
} | {
|
|
751
|
+
kind: 'biz-component';
|
|
752
|
+
/**
|
|
753
|
+
* 业务组件参数
|
|
754
|
+
*/
|
|
755
|
+
params?: Param[];
|
|
756
|
+
});
|
|
569
757
|
/**
|
|
570
758
|
* 文件片段
|
|
571
759
|
*
|
|
@@ -622,6 +810,7 @@ declare class ReactFragment implements FileFragment {
|
|
|
622
810
|
* 状态上下文
|
|
623
811
|
*/
|
|
624
812
|
private ctx;
|
|
813
|
+
private reactCodegenPlugin;
|
|
625
814
|
/**
|
|
626
815
|
* 其他控制选项
|
|
627
816
|
*/
|
|
@@ -646,7 +835,7 @@ declare class ReactFragment implements FileFragment {
|
|
|
646
835
|
/**
|
|
647
836
|
* 状态上下文
|
|
648
837
|
*/
|
|
649
|
-
ctx: StateContextIR,
|
|
838
|
+
ctx: StateContextIR, reactCodegenPlugin: ReactCodegenPlugin,
|
|
650
839
|
/**
|
|
651
840
|
* 其他控制选项
|
|
652
841
|
*/
|
|
@@ -662,12 +851,14 @@ declare class ReactFragment implements FileFragment {
|
|
|
662
851
|
* @returns 若没有指定混淆后的名字,则返回原名
|
|
663
852
|
*/
|
|
664
853
|
getMangledName(): string;
|
|
854
|
+
isIdeSlot(): boolean;
|
|
665
855
|
/**
|
|
666
856
|
* 转换为JSX
|
|
667
857
|
* @param option - 转JSX的选项
|
|
668
858
|
* @returns JSX
|
|
669
859
|
*/
|
|
670
860
|
toJsx(option?: ToJSXOption): JSXNode;
|
|
861
|
+
genUpdateParamsHooks(): void;
|
|
671
862
|
/**
|
|
672
863
|
* 转换为函数组件的变量声明
|
|
673
864
|
* @returns 函数组件的变量声明
|
|
@@ -680,16 +871,29 @@ declare class ReactFragment implements FileFragment {
|
|
|
680
871
|
/**
|
|
681
872
|
* 从组件声明生成React逻辑片段
|
|
682
873
|
* @param c - 组件声明
|
|
683
|
-
* @returns 生成的React
|
|
874
|
+
* @returns 生成的React逻辑片段。至少生成一个逻辑片段
|
|
875
|
+
*/
|
|
876
|
+
static fromComponentIR(c: GeneralComponentIR, reactCodegen: ReactCodegenPlugin): ReactFragment;
|
|
877
|
+
/**
|
|
878
|
+
* 启发式地将大组件拆分为若干个小组件
|
|
879
|
+
* @param c
|
|
880
|
+
* @param reactCodegen
|
|
881
|
+
* @returns
|
|
684
882
|
*/
|
|
685
|
-
static
|
|
883
|
+
static fromComponentIRIntoHeuristicallySplitFragments(c: GeneralComponentIR, reactCodegen: ReactCodegenPlugin, options?: {
|
|
884
|
+
/**
|
|
885
|
+
* 拆分大小
|
|
886
|
+
*/
|
|
887
|
+
sizeThreshold?: number;
|
|
888
|
+
}): {
|
|
889
|
+
main: ReactFragment;
|
|
890
|
+
subs: ReactFragment[];
|
|
891
|
+
};
|
|
686
892
|
/**
|
|
687
893
|
* 绑定事件
|
|
688
894
|
* @param b - 绑定事件的IR
|
|
689
895
|
*/
|
|
690
|
-
bindEvent(b: BindEventIR
|
|
691
|
-
handlerPrefix: string;
|
|
692
|
-
}): void;
|
|
896
|
+
bindEvent(b: BindEventIR): void;
|
|
693
897
|
/**
|
|
694
898
|
* 将属性存入当前片段的attrMap
|
|
695
899
|
*
|
|
@@ -758,158 +962,58 @@ declare class ReactFileDescription {
|
|
|
758
962
|
/**
|
|
759
963
|
* 组件声明到文件路径的映射字典
|
|
760
964
|
*/
|
|
761
|
-
type ComponentIRToPathDict = WeakMap<
|
|
762
|
-
declare const reactCodeGenPlugin: {
|
|
763
|
-
name: string;
|
|
764
|
-
functions: {
|
|
765
|
-
genReactFragment(c: ComponentInstanceIR, ctx: StateContextIR): ReactFragment;
|
|
766
|
-
/**
|
|
767
|
-
* 根据组件声明信息和文件夹信息生成React组件
|
|
768
|
-
* @param c - 组件声明信息
|
|
769
|
-
* @param folder - 文件夹信息
|
|
770
|
-
* @returns 生成的多个React文件
|
|
771
|
-
*/
|
|
772
|
-
genReactComponent(c: ComponentIR, folder?: FolderPath): ReactFileDescription[];
|
|
773
|
-
/**
|
|
774
|
-
* 递归生成React组件的文件
|
|
775
|
-
* @param c - 组件声明
|
|
776
|
-
* @param dict - 组件声明到文件路径的映射字典
|
|
777
|
-
* @param folder - 此文件所属的父文件夹
|
|
778
|
-
* @returns 生成的React文件描述列表
|
|
779
|
-
*/
|
|
780
|
-
recursivelyGenReactComponent(c: ComponentIR, dict: ComponentIRToPathDict, folder?: FolderPath): ReactFileDescription[];
|
|
781
|
-
buildRoutes(views: ComponentIR[], componentIRToPathDict: ComponentIRToPathDict): ReactFileDescription;
|
|
782
|
-
/**
|
|
783
|
-
* 构建平台配置文件
|
|
784
|
-
* @param ir - NASL应用中间表示
|
|
785
|
-
* @returns 平台配置文件描述
|
|
786
|
-
*/
|
|
787
|
-
buildPlatformConfig(ir: NASLAppIR): ReactFileDescription;
|
|
788
|
-
buildInit(ir: NASLAppIR): ReactFileDescription;
|
|
789
|
-
buildMasterCss(themeCSS: string, packages: NASLAppIR['packages']): Promise<ReactFileDescription>;
|
|
790
|
-
/**
|
|
791
|
-
* 构建前端全局变量文件
|
|
792
|
-
* @param variables - 全局变量表示的列表
|
|
793
|
-
* @param baseCtx - 状态上下文
|
|
794
|
-
* @returns React文件描述
|
|
795
|
-
*/
|
|
796
|
-
buildGlobalFrontendVariableFile(variables: NASLAppIR['configs']['globalVariables'], baseCtx: StateContextIR): Promise<ReactFileDescription>;
|
|
797
|
-
buildLibraryHook(packages: NASLAppIR['packages']): ReactFileDescription;
|
|
798
|
-
/**
|
|
799
|
-
* 生成布局后的React源代码文件
|
|
800
|
-
* @param ir - NASL应用中间表示
|
|
801
|
-
* @param baseDir - 基目录
|
|
802
|
-
* @returns 组织后的文件列表
|
|
803
|
-
*/
|
|
804
|
-
genFiles(ir: NASLAppIR, baseDir: string): Promise<OrganizedFile[]>;
|
|
805
|
-
};
|
|
806
|
-
};
|
|
807
|
-
|
|
808
|
-
type JSXNode = string;
|
|
809
|
-
type JSXRepr = string;
|
|
810
|
-
declare function styleStringToInlineObject(staticStyle: string): Record<string, unknown>;
|
|
811
|
-
declare const jsxCodeGenPlugin: {
|
|
812
|
-
name: string;
|
|
813
|
-
functions: {
|
|
814
|
-
printJSX(c: ComponentIR, option?: ToJSXOption): JSXRepr;
|
|
815
|
-
printTag(tagName: string): JSXRepr;
|
|
816
|
-
};
|
|
817
|
-
};
|
|
818
|
-
|
|
819
|
-
declare const defaultErrorMessageDict: Record<string, string | undefined>;
|
|
820
|
-
|
|
821
|
-
type PrettierOptions = NonNullable<Parameters<typeof format>[1]>;
|
|
822
|
-
declare const codeFormatPlugin: {
|
|
823
|
-
name: string;
|
|
824
|
-
functions: {
|
|
825
|
-
format(str: string, options?: PrettierOptions): Promise<string>;
|
|
826
|
-
};
|
|
827
|
-
};
|
|
828
|
-
|
|
829
|
-
type RouteIR = {
|
|
830
|
-
accumulativePath: string;
|
|
831
|
-
thisLevelPath: string;
|
|
832
|
-
elementMangledName?: string;
|
|
833
|
-
elementTemplate: ComponentIR;
|
|
834
|
-
children?: RouteIR[];
|
|
835
|
-
authConfig?: AuthConfig;
|
|
836
|
-
kind: 'normal';
|
|
837
|
-
lazy?: boolean;
|
|
838
|
-
meta: {
|
|
839
|
-
title: string;
|
|
840
|
-
crumb: string;
|
|
841
|
-
};
|
|
842
|
-
} | {
|
|
843
|
-
accumulativePath: string;
|
|
844
|
-
thisLevelPath: string;
|
|
845
|
-
redirect: string;
|
|
846
|
-
kind: 'redirect';
|
|
847
|
-
};
|
|
848
|
-
type AuthConfig = unknown;
|
|
849
|
-
declare const routesExtractionPlugin: {
|
|
850
|
-
name: string;
|
|
851
|
-
functions: {
|
|
852
|
-
extractRoute(components: ComponentIR[], routePrefix: string, options?: {
|
|
853
|
-
lazy?: boolean;
|
|
854
|
-
}): {
|
|
855
|
-
routes: RouteIR[];
|
|
856
|
-
authResourcePaths: string[];
|
|
857
|
-
baseResourcePaths: string[];
|
|
858
|
-
};
|
|
859
|
-
};
|
|
860
|
-
};
|
|
861
|
-
|
|
965
|
+
type ComponentIRToPathDict = WeakMap<GeneralComponentIR, string>;
|
|
862
966
|
/**
|
|
863
|
-
*
|
|
967
|
+
* React 代码生成插件
|
|
864
968
|
*/
|
|
865
|
-
declare class
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
969
|
+
declare class ReactCodegenPlugin implements JavaScriptDomain.FrontendApplicationDomain.ReactDomain.ReactCodegen {
|
|
970
|
+
javaScriptCodegen: JavaScriptDomain.JavaScriptCodegen;
|
|
971
|
+
reactStateManager: JavaScriptDomain.FrontendApplicationDomain.ReactDomain.ReactStateManager;
|
|
972
|
+
private projectOrganizer;
|
|
973
|
+
private reactHookProviders?;
|
|
974
|
+
constructor(javaScriptCodegen: JavaScriptDomain.JavaScriptCodegen, reactStateManager: JavaScriptDomain.FrontendApplicationDomain.ReactDomain.ReactStateManager, projectOrganizer: GeneratorInfrastructureDomain.ProjectOrganizer, reactHookProviders?: JavaScriptDomain.FrontendApplicationDomain.ReactDomain.ReactHookProvider[] | undefined);
|
|
975
|
+
genReactFragment(c: ComponentInstanceIR, ctx: StateContextIR): ReactFragment;
|
|
976
|
+
/**
|
|
977
|
+
* 根据组件声明信息和文件夹信息生成React组件
|
|
978
|
+
* @param c - 组件声明信息
|
|
979
|
+
* @param folder - 文件夹信息
|
|
980
|
+
* @returns 生成的多个React文件
|
|
981
|
+
*/
|
|
982
|
+
genReactComponent(c: GeneralComponentIR, folder?: FolderPath): ReactFileDescription[];
|
|
983
|
+
/**
|
|
984
|
+
* 递归生成React组件的文件
|
|
985
|
+
* @param c - 组件声明
|
|
986
|
+
* @param dict - 组件声明到文件路径的映射字典
|
|
987
|
+
* @param folder - 此文件所属的父文件夹
|
|
988
|
+
* @returns 生成的React文件描述列表
|
|
989
|
+
*/
|
|
990
|
+
recursivelyGenReactComponent(c: GeneralComponentIR, dict: ComponentIRToPathDict, folder?: FolderPath): ReactFileDescription[];
|
|
991
|
+
buildRoutes(views: ViewComponentIR[], componentIRToPathDict: ComponentIRToPathDict): ReactFileDescription;
|
|
992
|
+
/**
|
|
993
|
+
* 构建平台配置文件
|
|
994
|
+
* @param ir - NASL应用中间表示
|
|
995
|
+
* @returns 平台配置文件描述
|
|
996
|
+
*/
|
|
997
|
+
buildPlatformConfig(ir: NASLAppIR): ReactFileDescription;
|
|
998
|
+
buildInit(ir: NASLAppIR): ReactFileDescription;
|
|
999
|
+
buildMasterCss(themeCSS: string, packages: NASLAppIR['packages']): Promise<ReactFileDescription>;
|
|
1000
|
+
/**
|
|
1001
|
+
* 构建前端全局变量文件
|
|
1002
|
+
* @param variables - 全局变量表示的列表
|
|
1003
|
+
* @param baseCtx - 状态上下文
|
|
1004
|
+
* @returns React文件描述
|
|
1005
|
+
*/
|
|
1006
|
+
buildGlobalFrontendVariableFile(variables: NASLAppIR['configs']['globalVariables'], baseCtx: StateContextIR): Promise<ReactFileDescription>;
|
|
1007
|
+
buildLibraryHook(packages: NASLAppIR['packages']): ReactFileDescription;
|
|
1008
|
+
/**
|
|
1009
|
+
* 生成布局后的React源代码文件
|
|
1010
|
+
* @param ir - NASL应用中间表示
|
|
1011
|
+
* @param baseDir - 基目录
|
|
1012
|
+
* @returns 组织后的文件列表
|
|
1013
|
+
*/
|
|
1014
|
+
genFiles(ir: NASLAppIR, baseDir: string): Promise<OrganizedFile[]>;
|
|
900
1015
|
}
|
|
901
1016
|
|
|
902
|
-
/**
|
|
903
|
-
* React Slot 插件
|
|
904
|
-
* @public
|
|
905
|
-
*/
|
|
906
|
-
declare const reactSlotPlugin: {
|
|
907
|
-
name: string;
|
|
908
|
-
functions: {
|
|
909
|
-
preprocessForSlots(c: ComponentInstanceIR): void;
|
|
910
|
-
};
|
|
911
|
-
};
|
|
912
|
-
|
|
913
1017
|
declare const reactComponentLibHackPlugin: {
|
|
914
1018
|
name: string;
|
|
915
1019
|
functions: {
|
|
@@ -924,13 +1028,14 @@ declare const reactComponentLibHackPlugin: {
|
|
|
924
1028
|
name: string;
|
|
925
1029
|
} & {
|
|
926
1030
|
kind: 'expr';
|
|
927
|
-
}>(
|
|
1031
|
+
}>(b: T): BindAttributeIR & {
|
|
928
1032
|
kind: 'expr';
|
|
929
|
-
}
|
|
1033
|
+
};
|
|
930
1034
|
};
|
|
931
1035
|
};
|
|
932
1036
|
|
|
933
1037
|
declare const ReactRouterDefaultViewFolderName = "__views__";
|
|
1038
|
+
declare const ReactRouterDefaultBizComponentsFolderName = "__bizComponents__";
|
|
934
1039
|
declare const reactRouterPlugin: {
|
|
935
1040
|
name: string;
|
|
936
1041
|
functions: {
|
|
@@ -942,51 +1047,60 @@ declare const reactRouterPlugin: {
|
|
|
942
1047
|
};
|
|
943
1048
|
};
|
|
944
1049
|
|
|
945
|
-
|
|
1050
|
+
type TempWithCtx = (ctx: StateContextIR) => StateManager;
|
|
1051
|
+
declare class ReactHookBuilder {
|
|
1052
|
+
static emptyHook(): ReactHook;
|
|
1053
|
+
static componentRefNameToHook(refName: string): ReactHook;
|
|
1054
|
+
static variableToHook(left: string, right: string): ReactHook;
|
|
1055
|
+
static componentRefsObjectToHook(refNameList: string[]): ReactHook;
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* React 原生状态管理器
|
|
1059
|
+
*/
|
|
1060
|
+
declare class ReactStateManagerVanillaPlugin implements JavaScriptDomain.FrontendApplicationDomain.ReactDomain.ReactStateManager {
|
|
1061
|
+
reactJavaScriptCodegen: JavaScriptDomain.JavaScriptCodegen;
|
|
1062
|
+
constructor(reactJavaScriptCodegen: JavaScriptDomain.JavaScriptCodegen);
|
|
1063
|
+
makeTreeStateHooks(ctx: StateContextIR): ReactHook[];
|
|
1064
|
+
makeLocalLogicHooks(ctx: StateContextIR): ReactHook[];
|
|
1065
|
+
actionToBody(ctx: StateContextIR, action: StateActionIR, getWithCtx?: () => TempWithCtx): string;
|
|
1066
|
+
makeLocalIndividualHooks(ctx: StateContextIR, getWithCtx?: () => TempWithCtx): ReactHook[];
|
|
1067
|
+
initializationToExpr(ctx: StateContextIR, init: LocalLogicStateIR['initialization']): string | undefined;
|
|
946
1068
|
produceHooks(ctx: StateContextIR): ReactHook[];
|
|
1069
|
+
/**
|
|
1070
|
+
* @deprecated 用依赖注入的方法做
|
|
1071
|
+
*/
|
|
1072
|
+
withCtx(ctx: StateContextIR): StateManager;
|
|
1073
|
+
__resolveIdentifier(ctx: StateContextIR, id: Identifier): string | undefined;
|
|
1074
|
+
__resolveName(ctx: StateContextIR, name: string): string | undefined;
|
|
1075
|
+
__hooksDefinitions(): ReactFileDescription;
|
|
947
1076
|
}
|
|
948
|
-
declare const reactStateManagerMobxPlugin: {
|
|
949
|
-
name: string;
|
|
950
|
-
functions: {
|
|
951
|
-
/**
|
|
952
|
-
* 根据所消费的State的信息,产生支持消费的Hooks调用
|
|
953
|
-
*/
|
|
954
|
-
produceHooks(ctx: StateContextIR): ReactHook[];
|
|
955
|
-
readonly storeName: string;
|
|
956
|
-
__resolveIdentifier(ctx: StateContextIR, id: Identifier): string | undefined;
|
|
957
|
-
__resolveName(ctx: StateContextIR, name: string): string | undefined;
|
|
958
|
-
/**
|
|
959
|
-
* @deprecated 用依赖注入的方法做
|
|
960
|
-
*/
|
|
961
|
-
withCtx(ctx: StateContextIR): {
|
|
962
|
-
resolveIdentifier: (id: Identifier) => string | undefined;
|
|
963
|
-
resolveName: (name: string) => string | undefined;
|
|
964
|
-
resolveCalleeNamespace: (name: string) => string | undefined;
|
|
965
|
-
};
|
|
966
|
-
__hooksDefinitions(): ReactFileDescription;
|
|
967
|
-
};
|
|
968
|
-
};
|
|
969
1077
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1078
|
+
/**
|
|
1079
|
+
* React 原生状态管理器
|
|
1080
|
+
*/
|
|
1081
|
+
declare class ReactStateManagerMobxPlugin implements JavaScriptDomain.FrontendApplicationDomain.ReactDomain.ReactHookProvider {
|
|
1082
|
+
private reactStateManagerVanillaPlugin;
|
|
1083
|
+
constructor(reactStateManagerVanillaPlugin: ReactStateManagerVanillaPlugin);
|
|
1084
|
+
makeLocalLogicBundleHook(ctx: StateContextIR): ReactHook | undefined;
|
|
1085
|
+
makePublicBusinessLogicHook(ctx: StateContextIR): ReactHook[];
|
|
1086
|
+
/**
|
|
1087
|
+
* 根据所消费的State的信息,产生支持消费的Hooks调用
|
|
1088
|
+
*/
|
|
1089
|
+
produceHooks(ctx: StateContextIR): ReactHook[];
|
|
1090
|
+
get storeName(): string;
|
|
1091
|
+
__resolveIdentifier(ctx: StateContextIR, id: Identifier): string | undefined;
|
|
1092
|
+
__resolveName(ctx: StateContextIR, name: string): string | undefined;
|
|
1093
|
+
/**
|
|
1094
|
+
* @deprecated 用依赖注入的方法做
|
|
1095
|
+
*/
|
|
1096
|
+
withCtx(ctx: StateContextIR): {
|
|
1097
|
+
resolveIdentifier: (id: Identifier) => string | undefined;
|
|
1098
|
+
resolveName: (name: string) => string | undefined;
|
|
1099
|
+
resolveCalleeNamespace: (name: string) => string | undefined;
|
|
988
1100
|
};
|
|
989
|
-
|
|
1101
|
+
genHookDefinition(): ReactFileDescription;
|
|
1102
|
+
static install(container: Container): Container;
|
|
1103
|
+
}
|
|
990
1104
|
|
|
991
1105
|
/**
|
|
992
1106
|
*
|
|
@@ -1074,7 +1188,7 @@ declare namespace GeneratorInfrastructureDomain {
|
|
|
1074
1188
|
*/
|
|
1075
1189
|
declare namespace NASLDomain {
|
|
1076
1190
|
/**
|
|
1077
|
-
* IR
|
|
1191
|
+
* IR构建器,负责将app根据配置转换为初步的IR
|
|
1078
1192
|
*/
|
|
1079
1193
|
interface IRBuilder {
|
|
1080
1194
|
/**
|
|
@@ -1087,6 +1201,22 @@ declare namespace NASLDomain {
|
|
|
1087
1201
|
*/
|
|
1088
1202
|
buildIR(app: App, frontend: Frontend, config: CommonAppConfig): NASLAppIR;
|
|
1089
1203
|
}
|
|
1204
|
+
/**
|
|
1205
|
+
* IR前处理器,负责对IRBuilder的输入进行前处理
|
|
1206
|
+
*/
|
|
1207
|
+
interface IRPreProcesser {
|
|
1208
|
+
preProcess(app: App, frontend: Frontend, config: CommonAppConfig): {
|
|
1209
|
+
app: App;
|
|
1210
|
+
frontend: Frontend;
|
|
1211
|
+
config: CommonAppConfig;
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
/**
|
|
1215
|
+
* IR后处理器,负责对IRBuilder生产出的IR进行后处理
|
|
1216
|
+
*/
|
|
1217
|
+
interface IRPostProcesser {
|
|
1218
|
+
postProcess(ir: NASLAppIR, config: CommonAppConfig): NASLAppIR;
|
|
1219
|
+
}
|
|
1090
1220
|
/**
|
|
1091
1221
|
* 元信息抽取接口
|
|
1092
1222
|
*/
|
|
@@ -1125,7 +1255,7 @@ declare namespace JavaScriptDomain {
|
|
|
1125
1255
|
* @param c - 组件IR
|
|
1126
1256
|
* @param option - 生成选项
|
|
1127
1257
|
*/
|
|
1128
|
-
printJSX(c:
|
|
1258
|
+
printJSX(c: GeneralComponentIR, option?: ToJSXOption): string;
|
|
1129
1259
|
/**
|
|
1130
1260
|
* 打印简单自闭合标签
|
|
1131
1261
|
* @param tagName - 标签名
|
|
@@ -1165,7 +1295,7 @@ declare namespace JavaScriptDomain {
|
|
|
1165
1295
|
*
|
|
1166
1296
|
* 状态管理器,也就是状态管理上下文。主要负责提供Identifier和CalleeNamespace解析为JavaScript字符串的函数
|
|
1167
1297
|
*/
|
|
1168
|
-
interface
|
|
1298
|
+
interface SymbolResolver {
|
|
1169
1299
|
/**
|
|
1170
1300
|
* Identifier 解析函数
|
|
1171
1301
|
*/
|
|
@@ -1175,10 +1305,29 @@ declare namespace JavaScriptDomain {
|
|
|
1175
1305
|
*/
|
|
1176
1306
|
resolveCalleeNamespace: IdentifierNameResolver;
|
|
1177
1307
|
}
|
|
1308
|
+
interface StateManager {
|
|
1309
|
+
/**
|
|
1310
|
+
* @deprecated 更名
|
|
1311
|
+
* @param ctx
|
|
1312
|
+
*/
|
|
1313
|
+
withCtx(ctx: StateContextIR): SymbolResolver;
|
|
1314
|
+
}
|
|
1178
1315
|
/**
|
|
1179
1316
|
* React框架领域
|
|
1180
1317
|
*/
|
|
1181
1318
|
namespace ReactDomain {
|
|
1319
|
+
interface ReactJavaScriptCodegenHandler {
|
|
1320
|
+
/**
|
|
1321
|
+
* 从NASL表达式生成JavaScript代码
|
|
1322
|
+
* @param expr - NASL表达式语法节点
|
|
1323
|
+
* @param callbackBag - 回调函数包
|
|
1324
|
+
* @returns JavaScript代码 或者 无法生成
|
|
1325
|
+
*/
|
|
1326
|
+
printBaseNode(expr: BaseNode, callbackBag?: Partial<javaScriptCodeGenCallBackBag>): string | undefined;
|
|
1327
|
+
}
|
|
1328
|
+
interface ReactHookProvider {
|
|
1329
|
+
genHookDefinition(): ReactFileDescription;
|
|
1330
|
+
}
|
|
1182
1331
|
/**
|
|
1183
1332
|
* React状态管理接口
|
|
1184
1333
|
*/
|
|
@@ -1204,14 +1353,14 @@ declare namespace JavaScriptDomain {
|
|
|
1204
1353
|
* @param c - 组件声明
|
|
1205
1354
|
* @param folder
|
|
1206
1355
|
*/
|
|
1207
|
-
genReactComponent(c:
|
|
1356
|
+
genReactComponent(c: GeneralComponentIR, folder?: FolderPath): ReactFileDescription[];
|
|
1208
1357
|
/**
|
|
1209
1358
|
* 构建路由文件
|
|
1210
1359
|
* @param views - 组件声明表示
|
|
1211
1360
|
* @param componentIRToPathDict - 组件
|
|
1212
1361
|
* @returns 路由文件
|
|
1213
1362
|
*/
|
|
1214
|
-
buildRoutes(views:
|
|
1363
|
+
buildRoutes(views: GeneralComponentIR[], componentIRToPathDict: ComponentIRToPathDict): ReactFileDescription;
|
|
1215
1364
|
/**
|
|
1216
1365
|
* 构建主CSS入口文件
|
|
1217
1366
|
* @param packages - 包信息
|
|
@@ -1319,13 +1468,23 @@ declare function translateNASLToReactApp(
|
|
|
1319
1468
|
app: App, frontend: Frontend, config: CommonAppConfig, baseDir: string | undefined, container: Container): Promise<OrganizedFile[]>;
|
|
1320
1469
|
|
|
1321
1470
|
declare const ServiceMetaKind: {
|
|
1471
|
+
/**
|
|
1472
|
+
* @deprecated
|
|
1473
|
+
*/
|
|
1322
1474
|
StateManager: symbol;
|
|
1475
|
+
ReactStateManager: symbol;
|
|
1476
|
+
ReactHookProvider: symbol;
|
|
1323
1477
|
CodePrinter: symbol;
|
|
1478
|
+
ReactJavaScriptCodePrinter: symbol;
|
|
1479
|
+
BaseNodePrinter: symbol;
|
|
1324
1480
|
ProjectOrganizer: symbol;
|
|
1325
1481
|
MicroFrontendManager: symbol;
|
|
1326
1482
|
FrontendCodeGenerator: symbol;
|
|
1327
1483
|
IRBuilder: symbol;
|
|
1484
|
+
IRPostProcesser: symbol;
|
|
1485
|
+
IRPreProcesser: symbol;
|
|
1328
1486
|
NASLTranspiler: symbol;
|
|
1487
|
+
ReactCodegen: symbol;
|
|
1329
1488
|
CodeGenerationLifecycleHooks: symbol;
|
|
1330
1489
|
FileSystemProvider: symbol;
|
|
1331
1490
|
};
|
|
@@ -1352,4 +1511,4 @@ declare function makePlugin<Functions extends {}>({ name, functions, }: NASLPlug
|
|
|
1352
1511
|
declare function deserializeAppWhileKeepTypeAnnotation(appJSON: object): App;
|
|
1353
1512
|
declare function serializeAppWithKeepTypeAnnotation(app: App): any;
|
|
1354
1513
|
|
|
1355
|
-
export { ApiClientIdentifier, type BasePlatformConfig, type BindAttributeIR, type BindDirectiveIR, type BindEventIR, type
|
|
1514
|
+
export { ApiClientIdentifier, type BaseComponentIR, type BasePlatformConfig, type BindAttributeIR, type BindDirectiveIR, type BindEventIR, type BizComponentIR, type CommonAppConfig, type ComponentIRToPathDict, type ComponentInstanceIR, type Dict, type Expr, type ExprIR, type FileFragment, FileSystemPlugin, type FinalizedStateContextIR, type GeneralComponentIR, Generator, GeneratorInfrastructureDomain, type HasRuntimeSemantics, type IdentifierNameResolver, type IdentifierResolver, type IdentifierString, type ImportIR, type ImportIRResolver, type InputFile, type JSXNode, JavaScriptCodegenPlugin, JavaScriptDomain, type LegacyMetaData, LifeCycleHooksPlugin, type LocalIndividualStateIR, type LocalIndividualStateIRComponentRef, type LocalLogicStateIR, type LocalVariableStateIR, Logger, type LogicIR, MicroFrontendPlugin, type NASLAppIR, NASLAppIRBuilderPlugin, NASLDomain, type NASLPlugin, type OrganizedFile, type Package, type ParamIR, PlacedFile, type PlatformConfig, type PrettierOptions, ProjectOrganizerPlugin, type ProjectStructureConfig, ReactChildrenPropName, ReactCodegenPlugin, ReactFileDescription, ReactFragment, type ReactHook, ReactHookBuilder, ReactPresetPlugin, ReactRouterDefaultBizComponentsFolderName, ReactRouterDefaultViewFolderName, ReactSlotPlugin, ReactStateManagerMobxPlugin, ReactStateManagerVanillaPlugin, type ReferencedComponent, type ReferencedLibComponent, type ReferencedSubComponentIR, type RouteIR, ServiceMetaKind, StateActionIR, StateContextIR, type StateIR, type StateManager, type SubComponentIR, type SyntaxNodePrinter, type ToJSXOption, type TreeStateIR, type TypeAnnotationIR, type ViewComponentIR, VirtualProject, bindAttrToIR, bindEventToAction, bindViewElementEventToIR, codeFormatPlugin, compileAsProject, compileNASLToReactDist, defaultErrorMessageDict, deserializeAppWhileKeepTypeAnnotation, getComponentName, inferChangeEventNameFromAttrName, isLocalIndividualStateIRComponentRef, type javaScriptCodeGenCallBackBag, javaScriptCodeGenPlugin, jsxCodeGenPlugin, logicToLogicIR, makeDefaultContainer, makePlugin, metadataPlugin, paramToIR, reactComponentLibHackPlugin, reactRouterPlugin, routesExtractionPlugin, serializeAppWithKeepTypeAnnotation, styleStringToInlineObject, translateNASLToReactApp };
|