From a3e801853a51e64449cba371ad736b0ae038621e Mon Sep 17 00:00:00 2001 From: Documentation Manager Bot <64863757+conmaster2112@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:49:27 +0200 Subject: [PATCH] quick fix for main.js --- jsconfig.json | 3 +- src/flags/ts-declarations/test.js | 39 ----- src/generate_types.js | 258 ------------------------------ src/main.js | 4 - 4 files changed, 2 insertions(+), 302 deletions(-) delete mode 100644 src/flags/ts-declarations/test.js delete mode 100644 src/generate_types.js diff --git a/jsconfig.json b/jsconfig.json index 84ffcc6..5f8c761 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -7,5 +7,6 @@ "resolveJsonModule": true, "strict": true, "moduleResolution": "node", - } + }, + "exclude": ["bin/**/*"] } \ No newline at end of file diff --git a/src/flags/ts-declarations/test.js b/src/flags/ts-declarations/test.js deleted file mode 100644 index 144a49c..0000000 --- a/src/flags/ts-declarations/test.js +++ /dev/null @@ -1,39 +0,0 @@ -import { createWriteStream, readFileSync } from "node:fs"; -import { basename, resolve, } from "node:path"; -import { Printer } from "./printers.js"; - -export async function MainEntry(){ - - const path = `D:/Resources/Programming/Github/bds-docs/bin/bds/docs/script_modules/@minecraft/server-gametest_2.0.0-alpha.json`; - const data = Printer(JSON.parse(readFileSync(resolve(import.meta.dirname, path)).toString())); - - const stream = createWriteStream("./" + basename(path, ".json") + ".d.ts", {autoClose: true}); - - for(const chunk of data) { - process.stdout.write(chunk); - await new Promise((res,rej)=>stream.write(chunk,(s)=>s?rej(s):res(s))); - } - console.log(); - stream.end(); - - -/* - const p = createPrinter({ removeComments: true}); - - const m = ScriptModuleLoader(); - const src =createSourceFile("output.d.ts", "", ScriptTarget.ES2022); - - - const nodes = m.factoryBuild(new Context(m)); - - - //console.log(p.printNode(EmitHint.Unspecified, new EnumScriptMetadataKind("Test").factoryBuild(new Context(m)), src)); - - let test = ""; - - for(const node of nodes){ - test += p.printNode(EmitHint.Unspecified, node, src).replaceAll(/\n(\s+|)/g,"") + "\r\n"; - } - - writeFileSync("./test.d.ts", test);*/ -} \ No newline at end of file diff --git a/src/generate_types.js b/src/generate_types.js deleted file mode 100644 index c8b007f..0000000 --- a/src/generate_types.js +++ /dev/null @@ -1,258 +0,0 @@ -import { factory, SyntaxKind } from "typescript"; - -/** - * @param {string} alias - * @param {string} moduleName - */ -export function CreateImportModuleDependency(alias, moduleName){ - return factory.createImportDeclaration( - undefined, - factory.createImportClause( - false, - undefined, - factory.createNamespaceImport(factory.createIdentifier(alias)) - ), - factory.createStringLiteral(moduleName), - undefined - ); -} -/** - * - * @param {SyntaxKind.PublicKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PrivateKeyword} kind - * @param {...import("typescript").ParameterDeclaration} parameters - */ -export function CreateConsrcutor(kind, ...parameters){ - return factory.createConstructorDeclaration( - [factory.createToken(kind)], - [], - undefined - ); -} -factory.createKeywordTypeNode(SyntaxKind.VoidKeyword); - -factory.createFunctionDeclaration( - [factory.createToken(ts.SyntaxKind.ExportKeyword)], - undefined, - factory.createIdentifier("Method"), - undefined, - [factory.createParameterDeclaration( - undefined, - undefined, - factory.createIdentifier("method"), - undefined, - factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword), - undefined - )], - factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword), - undefined - ) - factory.createInterfaceDeclaration( - [factory.createToken(ts.SyntaxKind.ExportKeyword)], - factory.createIdentifier("Interface"), - undefined, - undefined, - [ - factory.createMethodSignature( - undefined, - factory.createIdentifier("sendMessage"), - undefined, - undefined, - [], - factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword) - ), - factory.createPropertySignature( - undefined, - factory.createIdentifier("bob"), - undefined, - factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword) - ) - ] - )factory.createClassDeclaration( - [factory.createToken(ts.SyntaxKind.ExportKeyword)], - factory.createIdentifier("Player"), - undefined, - undefined, - [ - factory.createConstructorDeclaration( - [factory.createToken(ts.SyntaxKind.PublicKeyword)], - [factory.createParameterDeclaration( - undefined, - undefined, - factory.createIdentifier("method"), - undefined, - factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), - undefined - )], - undefined - ), - factory.createMethodDeclaration( - [factory.createToken(ts.SyntaxKind.PublicKeyword)], - undefined, - factory.createIdentifier("sendMessage"), - undefined, - undefined, - [factory.createParameterDeclaration( - undefined, - undefined, - factory.createIdentifier("method"), - undefined, - factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), - undefined - )], - factory.createTypeReferenceNode( - factory.createQualifiedName( - factory.createIdentifier("_ss"), - factory.createIdentifier("Test") - ), - undefined - ), - undefined - ), - factory.createPropertyDeclaration( - [ - factory.createToken(ts.SyntaxKind.PublicKeyword), - factory.createToken(ts.SyntaxKind.ReadonlyKeyword) - ], - factory.createIdentifier("nameTag"), - undefined, - factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), - undefined - ) - ] - ) - factory.createMethodSignature( - undefined, - factory.createIdentifier("sendMessage"), - undefined, - undefined, - [], - factory.createTypeReferenceNode( - factory.createIdentifier("Generator"), - [ - factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword), - factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword) - ] - ) - ) - factory.createMethodSignature( - undefined, - factory.createIdentifier("sendMessage"), - undefined, - undefined, - [], - factory.createTypeReferenceNode( - factory.createIdentifier("Promise"), - [factory.createUnionTypeNode([ - factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword), - factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword) - ])] - ) - ) - factory.createMethodSignature( - undefined, - factory.createIdentifier("sendMessage"), - undefined, - undefined, - [], - factory.createArrayTypeNode(factory.createParenthesizedType(factory.createUnionTypeNode([ - factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword), - factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword) - ]))) - ) - factory.createMethodSignature( - undefined, - factory.createIdentifier("sendMessage"), - undefined, - undefined, - [], - factory.createParenthesizedType(factory.createFunctionTypeNode( - undefined, - [factory.createParameterDeclaration( - undefined, - undefined, - factory.createIdentifier("m"), - undefined, - factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), - undefined - )], - factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword) - )) - ) - factory.createMethodSignature( - undefined, - factory.createIdentifier("sendMessage"), - undefined, - [ - factory.createTypeParameterDeclaration( - undefined, - factory.createIdentifier("T"), - factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword), - factory.createLiteralTypeNode(factory.createNumericLiteral("5")) - ), - factory.createTypeParameterDeclaration( - undefined, - factory.createIdentifier("S"), - undefined, - undefined - ) - ], - [], - factory.createParenthesizedType(factory.createFunctionTypeNode( - undefined, - [factory.createParameterDeclaration( - undefined, - undefined, - factory.createIdentifier("m"), - undefined, - factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), - undefined - )], - factory.createTypeReferenceNode( - factory.createIdentifier("T"), - undefined - ) - )) - ) - factory.createEnumDeclaration( - [factory.createToken(ts.SyntaxKind.ExportKeyword)], - factory.createIdentifier("MethodLike"), - [factory.createEnumMember( - factory.createIdentifier("test"), - factory.createNumericLiteral("5") - )] - ) - factory.createEnumDeclaration( - [factory.createToken(ts.SyntaxKind.ExportKeyword)], - factory.createIdentifier("MethodLike"), - [factory.createEnumMember( - factory.createIdentifier("test"), - undefined - )] - ) -factory.createVariableStatement( - [factory.createToken(ts.SyntaxKind.ExportKeyword)], - factory.createVariableDeclarationList( - [factory.createVariableDeclaration( - factory.createIdentifier("world"), - undefined, - factory.createTypeReferenceNode( - factory.createIdentifier("World"), - undefined - ), - undefined - )], - ts.NodeFlags.Const | ts.NodeFlags.Constant | ts.NodeFlags.Constant - ) - ) -factory.createVariableStatement( - [factory.createToken(ts.SyntaxKind.ExportKeyword)], - factory.createVariableDeclarationList( - [factory.createVariableDeclaration( - factory.createIdentifier("TickPerSecond"), - undefined, - undefined, - factory.createNumericLiteral("20") - )], - ts.NodeFlags.Const | ts.NodeFlags.Constant | ts.NodeFlags.Constant - ) - ) \ No newline at end of file diff --git a/src/main.js b/src/main.js index afa7e25..96c882a 100644 --- a/src/main.js +++ b/src/main.js @@ -5,7 +5,6 @@ import { writeFile } from "node:fs/promises"; import { SaveWorkspaceContent } from "./content_saver.js"; import { resolve } from "node:path"; import { GENERATOR_FLAGS } from "./flags/index.js"; -import { MainEntry } from "./flags/ts-declarations/test.js"; let performanceTime = Date.now(); // Calling Main EntryPont Main() @@ -23,9 +22,6 @@ Main() * @returns {Promise} */ async function Main(){ - - await MainEntry(); - return 0; // Fetch Current BDS Versions const versions = await FetchBDSVersions().catch(console.error); if(!versions) {