@lcap/nasl 3.8.0-beta.6 → 3.8.0-beta.7
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/.mocharc.js +1 -0
- package/out/common/BaseNode.d.ts +19 -3
- package/out/common/BaseNode.js +85 -7
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AbstractInterface__.js.map +1 -1
- package/out/concepts/Annotation__.js +1 -1
- package/out/concepts/Annotation__.js.map +1 -1
- package/out/concepts/App__.d.ts +3 -0
- package/out/concepts/App__.js +964 -4
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.js +3 -3
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/BatchAssignment__.d.ts +1 -1
- package/out/concepts/BatchAssignment__.js +2 -2
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +3 -4
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +3 -4
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BusinessComponent__.d.ts +2 -0
- package/out/concepts/BusinessComponent__.js +48 -0
- package/out/concepts/BusinessComponent__.js.map +1 -1
- package/out/concepts/BusinessLogic__.d.ts +1 -0
- package/out/concepts/BusinessLogic__.js +10 -0
- package/out/concepts/BusinessLogic__.js.map +1 -1
- package/out/concepts/CallEvent__.d.ts +2 -0
- package/out/concepts/CallEvent__.js +75 -0
- package/out/concepts/CallEvent__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +1 -0
- package/out/concepts/CallInterface__.js +26 -15
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +4 -0
- package/out/concepts/CallLogic__.js +59 -3
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +3 -3
- package/out/concepts/Entity__.js +4 -0
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Event__.d.ts +2 -0
- package/out/concepts/Event__.js +30 -0
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/FrontendType__.d.ts +2 -0
- package/out/concepts/FrontendType__.js +32 -0
- package/out/concepts/FrontendType__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +2 -0
- package/out/concepts/Frontend__.js +48 -0
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/IfStatement__.js +6 -6
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.d.ts +1 -0
- package/out/concepts/InterfaceParam__.js +23 -4
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +2 -1
- package/out/concepts/Interface__.js +29 -5
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.d.ts +1 -0
- package/out/concepts/JSBlock__.js +6 -0
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/LogicDeclaration__.d.ts +1 -0
- package/out/concepts/LogicDeclaration__.js +58 -7
- package/out/concepts/LogicDeclaration__.js.map +1 -1
- package/out/concepts/Logic__.js +32 -22
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.js +1 -2
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.js +3 -18
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +1 -1
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +2 -0
- package/out/concepts/Module__.js +64 -0
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +1 -1
- package/out/concepts/NewComposite__.js +2 -2
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/Paginate__.d.ts +1 -0
- package/out/concepts/Paginate__.js +15 -7
- package/out/concepts/Paginate__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js +2 -2
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +3 -4
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +1 -0
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +2 -0
- package/out/concepts/ViewElement__.js +8 -5
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -0
- package/out/concepts/View__.js +55 -1
- package/out/concepts/View__.js.map +1 -1
- package/out/generator/genBundleFiles.js +14 -11
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genHash.d.ts +2 -2
- package/out/generator/genHash.js +30 -30
- package/out/generator/genHash.js.map +1 -1
- package/out/generator/permission.d.ts +8 -1
- package/out/generator/permission.js +321 -23
- package/out/generator/permission.js.map +1 -1
- package/out/generator/release-body/body.js +18 -4
- package/out/generator/release-body/body.js.map +1 -1
- package/out/generator/release-body/data.js +6 -2
- package/out/generator/release-body/data.js.map +1 -1
- package/out/generator/release-body/utils.js +3 -3
- package/out/generator/release-body/utils.js.map +1 -1
- package/out/generator/release-body/validation.js +2 -2
- package/out/generator/release-body/validation.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js.map +1 -1
- package/out/natural/genNaturalTS.d.ts +2 -2
- package/out/natural/genNaturalTS.js +7 -7
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/getContext/index.d.ts +1 -1
- package/out/natural/getContext/index.js +15 -9
- package/out/natural/getContext/index.js.map +1 -1
- package/out/natural/transformTS2UI.js +30 -11
- package/out/natural/transformTS2UI.js.map +1 -1
- package/out/natural/transformTSCode.js +30 -11
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/entity2LogicNamespace.d.ts +2 -2
- package/out/server/entity2LogicNamespace.js +321 -310
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js +25 -0
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/naslServer.d.ts +1 -1
- package/out/server/naslServer.js +23 -16
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +12 -0
- package/out/server/translator.js.map +1 -1
- package/out/templator/genCreateBlock.js +3 -3
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +2 -2
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +4 -4
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +1 -1
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +3 -3
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.js +1 -1
- package/out/templator/utils.js.map +1 -1
- package/package.json +5 -5
- package/src/common/BaseNode.ts +91 -11
- package/src/concepts/AbstractInterface__.ts +1 -0
- package/src/concepts/Annotation__.ts +1 -1
- package/src/concepts/App__.ts +104 -4
- package/src/concepts/Argument__.ts +3 -3
- package/src/concepts/BatchAssignment__.ts +2 -2
- package/src/concepts/BindAttribute__.ts +3 -4
- package/src/concepts/BindDirective__.ts +3 -4
- package/src/concepts/BusinessComponent__.ts +54 -1
- package/src/concepts/BusinessLogic__.ts +10 -1
- package/src/concepts/CallEvent__.ts +66 -0
- package/src/concepts/CallInterface__.ts +21 -9
- package/src/concepts/CallLogic__.ts +59 -3
- package/src/concepts/Entity__.ts +7 -1
- package/src/concepts/Event__.ts +32 -0
- package/src/concepts/FrontendType__.ts +34 -1
- package/src/concepts/Frontend__.ts +51 -0
- package/src/concepts/IfStatement__.ts +6 -6
- package/src/concepts/InterfaceParam__.ts +23 -4
- package/src/concepts/Interface__.ts +29 -5
- package/src/concepts/JSBlock__.ts +5 -0
- package/src/concepts/LogicDeclaration__.ts +65 -7
- package/src/concepts/Logic__.ts +34 -25
- package/src/concepts/MatchCase__.ts +1 -2
- package/src/concepts/Match__.ts +3 -21
- package/src/concepts/MemberExpression__.ts +1 -1
- package/src/concepts/Module__.ts +75 -0
- package/src/concepts/NewComposite__.ts +2 -2
- package/src/concepts/Paginate__.ts +14 -7
- package/src/concepts/QueryFromExpression__.ts +2 -2
- package/src/concepts/StringLiteral__.ts +3 -4
- package/src/concepts/TypeAnnotation__.ts +1 -0
- package/src/concepts/ViewElement__.ts +9 -5
- package/src/concepts/View__.ts +56 -1
- package/src/generator/genBundleFiles.ts +14 -11
- package/src/generator/genHash.ts +32 -6
- package/src/generator/permission.ts +333 -23
- package/src/generator/release-body/body.ts +24 -5
- package/src/generator/release-body/data.ts +7 -2
- package/src/generator/release-body/utils.ts +3 -3
- package/src/generator/release-body/validation.ts +1 -1
- package/src/index.ts +13 -1
- package/src/natural/genNaturalTS.ts +9 -7
- package/src/natural/getContext/index.ts +17 -11
- package/src/natural/transformTS2UI.ts +28 -11
- package/src/natural/transformTSCode.ts +28 -11
- package/src/server/entity2LogicNamespace.ts +13 -1
- package/src/server/extendBaseNode.ts +31 -0
- package/src/server/naslServer.ts +32 -23
- package/src/server/translator.ts +15 -0
- package/src/templator/genCreateBlock.ts +4 -4
- package/src/templator/genCurdEditMultipleKeyBlock.ts +2 -2
- package/src/templator/genCurdMultipleKeyBlock.ts +7 -7
- package/src/templator/genEditTableBlock.ts +4 -4
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genGridViewBlock.ts +2 -2
- package/src/templator/genSelectBlock.ts +3 -3
- package/src/templator/genTableBlock.ts +2 -2
- package/src/templator/genUpdateBlock.ts +6 -6
- package/src/templator/utils.ts +1 -1
- package/test/concepts/string-literal/__snapshots__/toVue.spec.ts.snap +1 -1
- package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +6 -2
|
@@ -80,6 +80,8 @@ function genArgumentMemberExpression(arr: string[]) {
|
|
|
80
80
|
}
|
|
81
81
|
export interface ElementToVueOptions {
|
|
82
82
|
filterAttr?: Array<string>;
|
|
83
|
+
/** 生成器镜像的导出流程 */
|
|
84
|
+
isGeneratorExport?: boolean;
|
|
83
85
|
isExport?: boolean;
|
|
84
86
|
isRelease?: boolean;
|
|
85
87
|
isRoot?: boolean;
|
|
@@ -287,7 +289,7 @@ function transAstNodeToNaslNode(astNode: any, namespace?: string): any {
|
|
|
287
289
|
function transAstNodeToNaslTypeNode(astNode: any, namespace?: string): any {
|
|
288
290
|
let node = null;
|
|
289
291
|
// 单独特殊处理枚举因为他不是MemberExpression,而是Identifier_
|
|
290
|
-
if (astNode?.value?.startsWith('__enumTypeAnnotation_')) {
|
|
292
|
+
if (astNode?.value?.startsWith?.('__enumTypeAnnotation_')) {
|
|
291
293
|
const valueArr = astNode.value.replace('__enumTypeAnnotation_', '')?.split('.');
|
|
292
294
|
const name = valueArr.pop();
|
|
293
295
|
const namespace = valueArr.join('.');
|
|
@@ -1634,7 +1636,7 @@ export class ViewElement extends Annotatable {
|
|
|
1634
1636
|
let levelIndex = parentLevel || 0;
|
|
1635
1637
|
code += `${self.name}: () => {\n`;
|
|
1636
1638
|
|
|
1637
|
-
const
|
|
1639
|
+
const getPropInitialValue = (name: string) => {
|
|
1638
1640
|
let v = 'new nasl.core.BooleanFalse()';
|
|
1639
1641
|
const attr = self.bindAttrs?.find((attr) => attr.name === name);
|
|
1640
1642
|
if (['static', 'string'].includes(attr?.type)) {
|
|
@@ -1783,18 +1785,19 @@ export class ViewElement extends Annotatable {
|
|
|
1783
1785
|
// 分页
|
|
1784
1786
|
let pageableDefaultValue: string;
|
|
1785
1787
|
if (hasDataSource && P && !T1) {
|
|
1786
|
-
pageableDefaultValue =
|
|
1788
|
+
pageableDefaultValue = getPropInitialValue('pageable');
|
|
1787
1789
|
code += `let __pageable = ${pageableDefaultValue};\n`;
|
|
1788
1790
|
}
|
|
1789
1791
|
// 多选
|
|
1790
1792
|
let multipleDefaultValue: string;
|
|
1791
1793
|
if (hasDataSource && M && !T1) {
|
|
1792
|
-
|
|
1794
|
+
const name = config?.allNodesAPI?.[self.tag]?.props?.find((prop) => ['M'].includes(prop.tsType))?.name;
|
|
1795
|
+
multipleDefaultValue = getPropInitialValue(name || 'multiple');
|
|
1793
1796
|
code += `let __multiple = ${multipleDefaultValue};\n`;
|
|
1794
1797
|
}
|
|
1795
1798
|
if (hasDataSource && V && !T1) {
|
|
1796
1799
|
code += `// @ts-ignore
|
|
1797
|
-
let __value: typeof __multiple extends nasl.core.BooleanTrue ?
|
|
1800
|
+
let __value: typeof __multiple extends nasl.core.BooleanTrue ? nasl.collection.List<${valueType}> : ${valueType};\n`;
|
|
1798
1801
|
code += `// @ts-ignore
|
|
1799
1802
|
let __V: ${valueType};\n`;
|
|
1800
1803
|
}
|
|
@@ -2914,6 +2917,7 @@ export class ViewElement extends Annotatable {
|
|
|
2914
2917
|
return `:${name}="${value.replace(/"/g, "'")}"`;
|
|
2915
2918
|
}
|
|
2916
2919
|
} catch (e) {
|
|
2920
|
+
if (apiOfAttr && apiOfAttr.type && !apiOfAttr.type.includes('string')) return '';
|
|
2917
2921
|
if (apiOfAttr && apiOfAttr.tsType && !apiOfAttr.tsType.includes('nasl.core.String')) return '';
|
|
2918
2922
|
}
|
|
2919
2923
|
value = value
|
package/src/concepts/View__.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
withSourceMapGenerator,
|
|
16
16
|
withGenerator,
|
|
17
17
|
TranslatorGenerator,
|
|
18
|
+
createDecoratorCode,
|
|
18
19
|
} from '../translator';
|
|
19
20
|
import translator from '../bak/translator';
|
|
20
21
|
import { ElementToVueOptions } from './ViewElement__';
|
|
@@ -2559,11 +2560,11 @@ export class View extends Annotatable {
|
|
|
2559
2560
|
code += variable.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
2560
2561
|
code += ';\n';
|
|
2561
2562
|
});
|
|
2563
|
+
if (this.variables.length) code += '\n';
|
|
2562
2564
|
|
|
2563
2565
|
if (callback) {
|
|
2564
2566
|
code += callback.call(this, state);
|
|
2565
2567
|
} else {
|
|
2566
|
-
code += '\n';
|
|
2567
2568
|
code += this.elements[0].toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 }));
|
|
2568
2569
|
}
|
|
2569
2570
|
|
|
@@ -2573,6 +2574,60 @@ export class View extends Annotatable {
|
|
|
2573
2574
|
return code;
|
|
2574
2575
|
}
|
|
2575
2576
|
|
|
2577
|
+
@withSourceMap()
|
|
2578
|
+
toTextualNASL(state = createCompilerState(), callback?: (this: View, state: TranslatorState) => string): string {
|
|
2579
|
+
const viewName = state.rename ?? this.tsName;
|
|
2580
|
+
let code = '';
|
|
2581
|
+
code += createDecoratorCode(state, this, ['pageTemplateId', 'uuid', 'title', 'crumb', 'auth', 'authDescription', 'isIndex']);
|
|
2582
|
+
|
|
2583
|
+
if (state.declaration) {
|
|
2584
|
+
code += `declare view ${viewName}`;
|
|
2585
|
+
// 有参数长度
|
|
2586
|
+
code += '(';
|
|
2587
|
+
this.params.forEach((param, index) => {
|
|
2588
|
+
code += param.toTextualNASL(shiftState(state, code, { tabSize: 0 }));
|
|
2589
|
+
if (index !== this.params.length - 1) code += ', ';
|
|
2590
|
+
});
|
|
2591
|
+
code += ') {';
|
|
2592
|
+
if (state.convertChildren && this.children?.length) {
|
|
2593
|
+
this.children.forEach((child) => {
|
|
2594
|
+
code += child.toTextualNASL(shiftState(state, code, { tabSize: state?.tabSize || 0 + 1 }), callback);
|
|
2595
|
+
code += '\n';
|
|
2596
|
+
});
|
|
2597
|
+
}
|
|
2598
|
+
code += '}';
|
|
2599
|
+
} else {
|
|
2600
|
+
code += `view ${viewName}`;
|
|
2601
|
+
|
|
2602
|
+
// 有参数长度
|
|
2603
|
+
code += '(';
|
|
2604
|
+
this.params.forEach((param, index) => {
|
|
2605
|
+
code += param.toTextualNASL(shiftState(state, code, { inline: true }));
|
|
2606
|
+
if (index !== this.params.length - 1) code += ', ';
|
|
2607
|
+
});
|
|
2608
|
+
code += ')';
|
|
2609
|
+
|
|
2610
|
+
code += ' {\n';
|
|
2611
|
+
|
|
2612
|
+
this.variables.forEach((variable) => {
|
|
2613
|
+
code += `${indent(state.tabSize + 1)}let `;
|
|
2614
|
+
code += variable.toTextualNASL(shiftState(state, code, { inline: true }));
|
|
2615
|
+
code += ';\n';
|
|
2616
|
+
});
|
|
2617
|
+
if (this.variables.length) code += '\n';
|
|
2618
|
+
|
|
2619
|
+
if (callback) {
|
|
2620
|
+
code += callback.call(this, state);
|
|
2621
|
+
} else {
|
|
2622
|
+
code += this.elements[0].toTextualNASL(shiftState(state, code, { tabSize: state.tabSize + 1 }));
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
code += `\n${indent(state.tabSize)}}\n`;
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
return code;
|
|
2629
|
+
}
|
|
2630
|
+
|
|
2576
2631
|
*toEmbeddedTSFile(): EmbeddedTSFileGenerator {
|
|
2577
2632
|
let code = `namespace ${this.getTsNamespace()} {\n`;
|
|
2578
2633
|
const state = createCompilerState(code, {
|
|
@@ -176,7 +176,6 @@ function genRouteFiles(routes: Route[], defaultRoute: string,config?: any) {
|
|
|
176
176
|
// 生成路由文件列表
|
|
177
177
|
const routeFiles: any[] = [];
|
|
178
178
|
function routeToFile(route: Route) {
|
|
179
|
-
console.log(route, 'route');
|
|
180
179
|
if (route?.component?.script) {
|
|
181
180
|
const content = genExportComponetCode(route.component);
|
|
182
181
|
const lazyPath = getCompletePath(null, content, config);
|
|
@@ -236,6 +235,7 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
236
235
|
try {
|
|
237
236
|
config?.debug && genBreakpoints(app);
|
|
238
237
|
app.curDeployEnv = config.env
|
|
238
|
+
console.time('toVueOptions');
|
|
239
239
|
|
|
240
240
|
utils.traverse(
|
|
241
241
|
(current) => {
|
|
@@ -252,6 +252,7 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
252
252
|
} as View,
|
|
253
253
|
}
|
|
254
254
|
);
|
|
255
|
+
console.timeEnd('toVueOptions');
|
|
255
256
|
|
|
256
257
|
businessComponents.forEach((businessComponent) => {
|
|
257
258
|
const frontendI18nEnabled = frontend?.i18nInfo?.enabled
|
|
@@ -543,8 +544,16 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
543
544
|
} else if(window.parent.isGlobalScaleTop) {
|
|
544
545
|
// 点击跳转到外部页面时,通知顶层页面
|
|
545
546
|
document.body.addEventListener('click', (e) => {
|
|
546
|
-
if(e.target.href)
|
|
547
|
-
|
|
547
|
+
if(!e.target.href) return;
|
|
548
|
+
if(typeof e.target.href !== 'string') return;
|
|
549
|
+
if(e.target.tagName !== 'A') return;
|
|
550
|
+
try {
|
|
551
|
+
const url = new URL(e.target.href);
|
|
552
|
+
if(url.host !== location.host){
|
|
553
|
+
parent.location.href = e.target.href;
|
|
554
|
+
}
|
|
555
|
+
} catch(err) {
|
|
556
|
+
console.error(err);
|
|
548
557
|
}
|
|
549
558
|
});
|
|
550
559
|
}
|
|
@@ -618,8 +627,8 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
618
627
|
}
|
|
619
628
|
return response.text();
|
|
620
629
|
}).then(function(scriptText) {
|
|
621
|
-
var func = new Function(scriptText);
|
|
622
|
-
var result = func();
|
|
630
|
+
var func = new Function('importComponent', scriptText);
|
|
631
|
+
var result = func(window.importComponent);
|
|
623
632
|
return result;
|
|
624
633
|
})
|
|
625
634
|
.catch(error => {
|
|
@@ -879,9 +888,7 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
879
888
|
|
|
880
889
|
|
|
881
890
|
|
|
882
|
-
console.time('genHash')
|
|
883
891
|
let bundleMinPath = completePath + getCompletePath(getBundleFileName(), content, config);
|
|
884
|
-
console.timeEnd('genHash');
|
|
885
892
|
|
|
886
893
|
const otherJsList = (frontend as any)?.appletsConfig?.enable ? ['//res.wx.qq.com/open/js/jweixin-1.3.2.js'] : [];
|
|
887
894
|
|
|
@@ -1056,7 +1063,6 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
|
|
|
1056
1063
|
output.content = replaceContentFilePath(output.content || '');
|
|
1057
1064
|
})
|
|
1058
1065
|
}
|
|
1059
|
-
console.log('outputs', outputs)
|
|
1060
1066
|
return outputs;
|
|
1061
1067
|
}
|
|
1062
1068
|
|
|
@@ -1143,7 +1149,6 @@ export function getOneFiles(options: { view: View; action: string; cacheRouterDa
|
|
|
1143
1149
|
}
|
|
1144
1150
|
currentView = currentView.parentNode;
|
|
1145
1151
|
}
|
|
1146
|
-
console.log(currentRoute);
|
|
1147
1152
|
|
|
1148
1153
|
function addOrUpdateRoute(routes: Route[], newRoute: Route) {
|
|
1149
1154
|
const existingRoute = routes.find((route) => route.path === newRoute.path);
|
|
@@ -1181,7 +1186,6 @@ export function getOneFiles(options: { view: View; action: string; cacheRouterDa
|
|
|
1181
1186
|
} else {
|
|
1182
1187
|
addOrUpdateRoute(cacheRouters, currentRoute);
|
|
1183
1188
|
}
|
|
1184
|
-
console.log(cacheRouters, 111);
|
|
1185
1189
|
const routerFiles = genRouteFiles(cacheRouters, null);
|
|
1186
1190
|
const completePath = `${cacheRouterData.baseUrl}${frontend.basePath || ''}/`;
|
|
1187
1191
|
const outputs = routerFiles;
|
|
@@ -1195,6 +1199,5 @@ export function getOneFiles(options: { view: View; action: string; cacheRouterDa
|
|
|
1195
1199
|
item.ideVersion = cacheRouterData.ideVersion;
|
|
1196
1200
|
}
|
|
1197
1201
|
});
|
|
1198
|
-
console.log('outputs: ', outputs);
|
|
1199
1202
|
return outputs;
|
|
1200
1203
|
}
|
package/src/generator/genHash.ts
CHANGED
|
@@ -1,13 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
// cyrb53 (c) 2018 bryc (github.com/bryc). License: Public domain. Attribution appreciated.
|
|
2
|
+
// A fast and simple 64-bit (or 53-bit) string hash function with decent collision resistance.
|
|
3
|
+
// Largely inspired by MurmurHash2/3, but with a focus on speed/simplicity.
|
|
4
|
+
// See https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript/52171480#52171480
|
|
5
|
+
// https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js
|
|
6
|
+
const cyrb64 = (str : string, seed = 0) => {
|
|
7
|
+
let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
|
|
8
|
+
for(let i = 0, ch; i < str.length; i++) {
|
|
9
|
+
ch = str.charCodeAt(i);
|
|
10
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
11
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
12
|
+
}
|
|
13
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);
|
|
14
|
+
h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
15
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);
|
|
16
|
+
h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
17
|
+
// For a single 53-bit numeric return value we could return
|
|
18
|
+
// 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
|
19
|
+
// but we instead return the full 64-bit value:
|
|
20
|
+
return [h2>>>0, h1>>>0];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// An improved, *insecure* 64-bit hash that's short, fast, and has no dependencies.
|
|
24
|
+
// Output is always 14 characters.
|
|
25
|
+
const cyrb64Hash = (str : string, seed = 0) => {
|
|
26
|
+
const [h2, h1] = cyrb64(str, seed);
|
|
27
|
+
return h2.toString(36).padStart(7, '0') + h1.toString(36).padStart(7, '0');
|
|
28
|
+
}
|
|
29
|
+
|
|
2
30
|
|
|
3
31
|
/**
|
|
4
32
|
*
|
|
5
33
|
* @param 文件内容 content
|
|
6
|
-
* @returns
|
|
34
|
+
* @returns cyrb64 弱 hash,取前 8 位
|
|
7
35
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return hash.slice(0, 8);
|
|
11
|
-
}
|
|
36
|
+
|
|
37
|
+
export const genHash = (str : string) => cyrb64Hash(str, 0).slice(0, 8);
|
|
12
38
|
|
|
13
39
|
export default genHash;
|