diff --git a/Configuration.js b/Configuration.js index 03854d07..0f793d4b 100644 --- a/Configuration.js +++ b/Configuration.js @@ -2,22 +2,26 @@ * @module Option * */ -export default (await import("./Target/Function/Merge.js")).default((await import("@playform/pipe/Target/Variable/Option.js")).default, { - Action: { - Wrote: async (On) => { - try { - return (await import("./Target/Function/Output.js")).default(On.Buffer.toString()); - } - catch (_Error) { - console.log(_Error); - return On.Buffer; - } - }, - Failed: async (Input, _Error) => { - console.log(_Error); - return ""; - }, - }, - Path: new Map([["./Example/Input", "./Example/Output"]]), - File: "**/*.ts", -}); +export default (await import("./Target/Function/Merge.js")).default( + (await import("@playform/pipe/Target/Variable/Option.js")).default, + { + Action: { + Wrote: async (On) => { + try { + return ( + await import("./Target/Function/Output.js") + ).default(On.Buffer.toString()); + } catch (_Error) { + console.log(_Error); + return On.Buffer; + } + }, + Failed: async (Input, _Error) => { + console.log(_Error); + return ""; + }, + }, + Path: new Map([["./Example/Input", "./Example/Output"]]), + File: "**/*.ts", + }, +); diff --git a/Example/Output/Authentication.ts b/Example/Output/Authentication.ts index cbf8275c..fb53bb83 100644 --- a/Example/Output/Authentication.ts +++ b/Example/Output/Authentication.ts @@ -3,27 +3,33 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ class AuthenticationDataRenderer { - render(manifest: IExtensionManifest): IRenderedData { - const authentication = manifest.contributes?.authentication || []; - if (!authentication.length) { - return { data: { headers: [], rows: [] }, dispose: () => { } }; - } - const headers = [ - localize("authenticationlabel", "Label"), - localize("authenticationid", "ID"), - ]; - const rows: IRowData[][] = authentication - .sort((a, b) => a.label.localeCompare(b.label)) - .map((auth) => { - return [auth.label, auth.id]; - }); - return { data: { headers: [ - localize("authenticationlabel", "Label"), - localize("authenticationid", "ID"), - ], rows: authentication - .sort((a, b) => a.label.localeCompare(b.label)) - .map((auth) => { - return [auth.label, auth.id]; - }) }, dispose: () => { } }; - } + render(manifest: IExtensionManifest): IRenderedData { + const authentication = manifest.contributes?.authentication || []; + if (!authentication.length) { + return { data: { headers: [], rows: [] }, dispose: () => {} }; + } + const headers = [ + localize("authenticationlabel", "Label"), + localize("authenticationid", "ID"), + ]; + const rows: IRowData[][] = authentication + .sort((a, b) => a.label.localeCompare(b.label)) + .map((auth) => { + return [auth.label, auth.id]; + }); + return { + data: { + headers: [ + localize("authenticationlabel", "Label"), + localize("authenticationid", "ID"), + ], + rows: authentication + .sort((a, b) => a.label.localeCompare(b.label)) + .map((auth) => { + return [auth.label, auth.id]; + }), + }, + dispose: () => {}, + }; + } } diff --git a/Example/Output/Decorator.ts b/Example/Output/Decorator.ts index dc1133b4..9742cd59 100644 --- a/Example/Output/Decorator.ts +++ b/Example/Output/Decorator.ts @@ -1,8 +1,8 @@ class Example { - @observable - x = 5; - @computed - get doubled() { - return this.x * 2; - } + @observable + x = 5; + @computed + get doubled() { + return this.x * 2; + } } diff --git a/Example/Output/Namespace.ts b/Example/Output/Namespace.ts index 590e72cf..713a8b6b 100644 --- a/Example/Output/Namespace.ts +++ b/Example/Output/Namespace.ts @@ -1,7 +1,4 @@ namespace MyNamespace { - export const x = 5; - ; - export const z = (5 - + 3) - * 2; + export const x = 5; + export const z = (5 + 3) * 2; } diff --git a/Example/Output/Predefined.ts b/Example/Output/Predefined.ts index a1d265e1..62364add 100644 --- a/Example/Output/Predefined.ts +++ b/Example/Output/Predefined.ts @@ -5,12 +5,17 @@ *--------------------------------------------------------------------------------------------*/ import * as fs from "fs"; import * as path from "path"; + const root = path.dirname(path.dirname(__dirname)); -; -; -; const platform = process.platform; const arch = process.arch; -; -; -console.log(path.join(path.dirname(path.dirname(__dirname)), ".build", "node", `v${/^target="(.*)"$/m.exec(fs.readFileSync(path.join(path.dirname(path.dirname(__dirname)), "remote", ".npmrc"), "utf8"))![1]}`, `${platform}-${arch}`, platform === "win32" ? "node.exe" : "node")); +console.log( + path.join( + path.dirname(path.dirname(__dirname)), + ".build", + "node", + `v${/^target="(.*)"$/m.exec(fs.readFileSync(path.join(path.dirname(path.dirname(__dirname)), "remote", ".npmrc"), "utf8"))![1]}`, + `${platform}-${arch}`, + platform === "win32" ? "node.exe" : "node", + ), +); diff --git a/Source/Function/Output/Transformer/Visit.ts b/Source/Function/Output/Transformer/Visit.ts index 64cad26e..64c49c1e 100644 --- a/Source/Function/Output/Transformer/Visit.ts +++ b/Source/Function/Output/Transformer/Visit.ts @@ -63,7 +63,7 @@ interface ValidationResult { readonly warning?: TransformWarning; } -const enum ErrorCode { +enum ErrorCode { MAX_DEPTH_EXCEEDED = "MAX_DEPTH_EXCEEDED", MAX_VISITS_EXCEEDED = "MAX_VISITS_EXCEEDED", MAX_ITERATIONS_EXCEEDED = "MAX_ITERATIONS_EXCEEDED", @@ -75,7 +75,7 @@ const enum ErrorCode { SELF_REFERENCE = "SELF_REFERENCE", } -const enum WarningCode { +enum WarningCode { POTENTIAL_SIDE_EFFECT = "POTENTIAL_SIDE_EFFECT", UNUSED_DECLARATION = "UNUSED_DECLARATION", COMPLEX_INITIALIZATION = "COMPLEX_INITIALIZATION", diff --git a/Source/Function/Output/Visit.ts b/Source/Function/Output/Visit.ts index 8c6e7a92..cdcb2a19 100644 --- a/Source/Function/Output/Visit.ts +++ b/Source/Function/Output/Visit.ts @@ -49,15 +49,14 @@ export const Fn = ((...[Usage, Initializer]) => let True = false; const Visit = (node: Node) => { - if (ts.isIdentifier(node)) { - if ( - node.text === NameNode && - !ts.isTemplateExpression(node.parent) && - !ts.isTemplateSpan(node.parent) && - !ts.isPropertyAccessExpression(node.parent) - ) { - True = true; - } + if ( + ts.isIdentifier(node) && + node.text === NameNode && + !ts.isTemplateExpression(node.parent) && + !ts.isTemplateSpan(node.parent) && + !ts.isPropertyAccessExpression(node.parent) + ) { + True = true; } ts.forEachChild(node, Visit); diff --git a/Target/Class/Eliminate.js b/Target/Class/Eliminate.js index effc6df4..83f79bf7 100644 --- a/Target/Class/Eliminate.js +++ b/Target/Class/Eliminate.js @@ -1,2 +1,2 @@ #!/usr/bin/env node -var i=new(await import("commander")).Command().name("Eliminate").version("0.0.3").description("\u2198\uFE0F\u2001Eliminate\u2001\u2014").argument("-E, --Eliminate ","\u{1F4DC}\u2001Eliminate configuration file\u2001\u2014").action((await import("../Function/Eliminate.js")).default).parse();export{i as default}; +var i=new(await import("commander")).Command().name("Eliminate").version("0.0.4").description("\u2198\uFE0F\u2001Eliminate\u2001\u2014").argument("-E, --Eliminate ","\u{1F4DC}\u2001Eliminate configuration file\u2001\u2014").action((await import("../Function/Eliminate.js")).default).parse();export{i as default}; diff --git a/Target/Function/Output.d.ts b/Target/Function/Output.d.ts index 919e8239..3f67bf4e 100644 --- a/Target/Function/Output.d.ts +++ b/Target/Function/Output.d.ts @@ -504,7 +504,7 @@ export declare const ts: { createAbstractBuilder(rootNames: readonly string[] | undefined, options: import("typescript").CompilerOptions | undefined, host?: import("typescript").CompilerHost, oldProgram?: import("typescript").BuilderProgram, configFileParsingDiagnostics?: readonly import("typescript").Diagnostic[], projectReferences?: readonly import("typescript").ProjectReference[]): import("typescript").BuilderProgram; readBuilderProgram(compilerOptions: import("typescript").CompilerOptions, host: import("typescript").ReadBuildProgramHost): import("typescript").EmitAndSemanticDiagnosticsBuilderProgram | undefined; createIncrementalCompilerHost(options: import("typescript").CompilerOptions, system?: import("typescript").System): import("typescript").CompilerHost; - createIncrementalProgram({ rootNames, options, configFileParsingDiagnostics, projectReferences, host, createProgram, }: import("typescript").IncrementalProgramOptions): T; + createIncrementalProgram({ rootNames, options, configFileParsingDiagnostics, projectReferences, host, createProgram }: import("typescript").IncrementalProgramOptions): T; createWatchCompilerHost(configFileName: string, optionsToExtend: import("typescript").CompilerOptions | undefined, system: import("typescript").System, createProgram?: import("typescript").CreateProgram, reportDiagnostic?: import("typescript").DiagnosticReporter, reportWatchStatus?: import("typescript").WatchStatusReporter, watchOptionsToExtend?: import("typescript").WatchOptions, extraFileExtensions?: readonly import("typescript").FileExtensionInfo[]): import("typescript").WatchCompilerHostOfConfigFile; createWatchCompilerHost(rootFiles: string[], options: import("typescript").CompilerOptions, system: import("typescript").System, createProgram?: import("typescript").CreateProgram, reportDiagnostic?: import("typescript").DiagnosticReporter, reportWatchStatus?: import("typescript").WatchStatusReporter, projectReferences?: readonly import("typescript").ProjectReference[], watchOptions?: import("typescript").WatchOptions): import("typescript").WatchCompilerHostOfFilesAndCompilerOptions; createWatchProgram(host: import("typescript").WatchCompilerHostOfFilesAndCompilerOptions): import("typescript").WatchOfFilesAndCompilerOptions; diff --git a/Target/Function/Output/Visit.js b/Target/Function/Output/Visit.js index 10b67b92..0f3c44a6 100644 --- a/Target/Function/Output/Visit.js +++ b/Target/Function/Output/Visit.js @@ -1 +1 @@ -const l=(...[n,s])=>(...[e])=>{const f=new Set,o=`${t.SyntaxKind[e.kind]}-${e.pos}-${e.end}`;if(f.has(o)){console.warn("Warning: Circular reference detected",{TypeNode:t.SyntaxKind[e.kind],Position:e.pos,Text:e.getText?.()});return}if(f.add(o),t.forEachChild(e,l(n,s)),n.size>=1e3||s.size>=1e3){console.warn("Warning: Maximum map size reached",{UsageLength:n.size,InitializerLength:s.size});return}if(t.isVariableDeclaration(e)&&e.initializer){const i=e.name.getText();if((()=>{let c=!1;const p=r=>{t.isIdentifier(r)&&r.text===i&&!t.isTemplateExpression(r.parent)&&!t.isTemplateSpan(r.parent)&&!t.isPropertyAccessExpression(r.parent)&&(c=!0),t.forEachChild(r,p)};return p(e.initializer),c})()){console.info(`Info: Skipping self-referential initializer for: ${i}`,{TypeNode:t.SyntaxKind[e.kind],Position:e.pos,Text:e.getText?.()});return}!n.has(i)&&n.size<1e3&&n.set(i,0),s.size<1e3&&s.set(e.initializer,i)}else if(t.isIdentifier(e)){const i=e.getText();if(!t.isVariableDeclaration(e.parent)){const a=n.get(i)??0;a<1e3?n.set(i,a+1):console.warn(`Warning: Maximum usage count reached for identifier: ${i}`,{TypeNode:t.SyntaxKind[e.kind],Position:e.pos,Text:e.getText?.()})}}},{default:t}=await import("typescript");var I=l;export{l as Fn,I as default,t as ts}; +const l=(...[n,s])=>(...[e])=>{const f=new Set,c=`${t.SyntaxKind[e.kind]}-${e.pos}-${e.end}`;if(f.has(c)){console.warn("Warning: Circular reference detected",{TypeNode:t.SyntaxKind[e.kind],Position:e.pos,Text:e.getText?.()});return}if(f.add(c),t.forEachChild(e,l(n,s)),n.size>=1e3||s.size>=1e3){console.warn("Warning: Maximum map size reached",{UsageLength:n.size,InitializerLength:s.size});return}if(t.isVariableDeclaration(e)&&e.initializer){const i=e.name.getText();if((()=>{let o=!1;const p=r=>{t.isIdentifier(r)&&r.text===i&&!t.isTemplateExpression(r.parent)&&!t.isTemplateSpan(r.parent)&&!t.isPropertyAccessExpression(r.parent)&&(o=!0),t.forEachChild(r,p)};return p(e.initializer),o})()){console.info(`Info: Skipping self-referential initializer for: ${i}`,{TypeNode:t.SyntaxKind[e.kind],Position:e.pos,Text:e.getText?.()});return}!n.has(i)&&n.size<1e3&&n.set(i,0),s.size<1e3&&s.set(e.initializer,i)}else if(t.isIdentifier(e)){const i=e.getText();if(!t.isVariableDeclaration(e.parent)){const a=n.get(i)??0;a<1e3?n.set(i,a+1):console.warn(`Warning: Maximum usage count reached for identifier: ${i}`,{TypeNode:t.SyntaxKind[e.kind],Position:e.pos,Text:e.getText?.()})}}},{default:t}=await import("typescript");var I=l;export{l as Fn,I as default,t as ts};