ticbuild 1.0.22 → 1.0.23
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/README.md +1057 -199
- package/dist/backend/ImportedResourceTypes.d.ts +22 -10
- package/dist/backend/ImportedResourceTypes.d.ts.map +1 -1
- package/dist/backend/ImportedResourceTypes.js +42 -13
- package/dist/backend/ImportedResourceTypes.js.map +1 -1
- package/dist/backend/assembly.d.ts +11 -0
- package/dist/backend/assembly.d.ts.map +1 -0
- package/dist/backend/assembly.js +150 -0
- package/dist/backend/assembly.js.map +1 -0
- package/dist/backend/assetBanking.test.d.ts +2 -0
- package/dist/backend/assetBanking.test.d.ts.map +1 -0
- package/dist/backend/assetBanking.test.js +242 -0
- package/dist/backend/assetBanking.test.js.map +1 -0
- package/dist/backend/codeBanking.test.js +7 -5
- package/dist/backend/codeBanking.test.js.map +1 -1
- package/dist/backend/codeSnippetProcessor.d.ts +78 -0
- package/dist/backend/codeSnippetProcessor.d.ts.map +1 -0
- package/dist/backend/codeSnippetProcessor.js +241 -0
- package/dist/backend/codeSnippetProcessor.js.map +1 -0
- package/dist/backend/codeSnippetProcessor.test.d.ts +2 -0
- package/dist/backend/codeSnippetProcessor.test.d.ts.map +1 -0
- package/dist/backend/codeSnippetProcessor.test.js +221 -0
- package/dist/backend/codeSnippetProcessor.test.js.map +1 -0
- package/dist/backend/importReference.d.ts +4 -0
- package/dist/backend/importReference.d.ts.map +1 -0
- package/dist/backend/importReference.js +43 -0
- package/dist/backend/importReference.js.map +1 -0
- package/dist/backend/importResources.d.ts +3 -1
- package/dist/backend/importResources.d.ts.map +1 -1
- package/dist/backend/importResources.js +124 -36
- package/dist/backend/importResources.js.map +1 -1
- package/dist/backend/importResources.test.d.ts +2 -0
- package/dist/backend/importResources.test.d.ts.map +1 -0
- package/dist/backend/importResources.test.js +87 -0
- package/dist/backend/importResources.test.js.map +1 -0
- package/dist/backend/importSources.d.ts +51 -0
- package/dist/backend/importSources.d.ts.map +1 -0
- package/dist/backend/importSources.js +261 -0
- package/dist/backend/importSources.js.map +1 -0
- package/dist/backend/importSources.test.d.ts +2 -0
- package/dist/backend/importSources.test.d.ts.map +1 -0
- package/dist/backend/importSources.test.js +271 -0
- package/dist/backend/importSources.test.js.map +1 -0
- package/dist/backend/importUtils.d.ts +5 -10
- package/dist/backend/importUtils.d.ts.map +1 -1
- package/dist/backend/importUtils.js +13 -48
- package/dist/backend/importUtils.js.map +1 -1
- package/dist/backend/importers/CodeDeclarationAnalysis.d.ts +37 -0
- package/dist/backend/importers/CodeDeclarationAnalysis.d.ts.map +1 -0
- package/dist/backend/importers/CodeDeclarationAnalysis.js +288 -0
- package/dist/backend/importers/CodeDeclarationAnalysis.js.map +1 -0
- package/dist/backend/importers/CodeResource.d.ts +90 -0
- package/dist/backend/importers/CodeResource.d.ts.map +1 -0
- package/dist/backend/importers/CodeResource.js +480 -0
- package/dist/backend/importers/CodeResource.js.map +1 -0
- package/dist/backend/importers/CodeResource.test.d.ts +2 -0
- package/dist/backend/importers/CodeResource.test.d.ts.map +1 -0
- package/dist/backend/importers/CodeResource.test.js +106 -0
- package/dist/backend/importers/CodeResource.test.js.map +1 -0
- package/dist/backend/importers/LuaAssetTypeScriptModules.d.ts +38 -0
- package/dist/backend/importers/LuaAssetTypeScriptModules.d.ts.map +1 -0
- package/dist/backend/importers/LuaAssetTypeScriptModules.js +437 -0
- package/dist/backend/importers/LuaAssetTypeScriptModules.js.map +1 -0
- package/dist/backend/importers/LuaCodeImporter.d.ts +9 -49
- package/dist/backend/importers/LuaCodeImporter.d.ts.map +1 -1
- package/dist/backend/importers/LuaCodeImporter.js +28 -255
- package/dist/backend/importers/LuaCodeImporter.js.map +1 -1
- package/dist/backend/importers/LuaCodeImporter.test.js +89 -46
- package/dist/backend/importers/LuaCodeImporter.test.js.map +1 -1
- package/dist/backend/importers/LuaTypeCatalog.d.ts +26 -0
- package/dist/backend/importers/LuaTypeCatalog.d.ts.map +1 -0
- package/dist/backend/importers/LuaTypeCatalog.js +185 -0
- package/dist/backend/importers/LuaTypeCatalog.js.map +1 -0
- package/dist/backend/importers/ManifestCodeTypeScriptModules.d.ts +10 -0
- package/dist/backend/importers/ManifestCodeTypeScriptModules.d.ts.map +1 -0
- package/dist/backend/importers/ManifestCodeTypeScriptModules.js +31 -0
- package/dist/backend/importers/ManifestCodeTypeScriptModules.js.map +1 -0
- package/dist/backend/importers/TypeScriptBuildConstants.d.ts +6 -0
- package/dist/backend/importers/TypeScriptBuildConstants.d.ts.map +1 -0
- package/dist/backend/importers/TypeScriptBuildConstants.js +79 -0
- package/dist/backend/importers/TypeScriptBuildConstants.js.map +1 -0
- package/dist/backend/importers/TypeScriptCodeImporter.d.ts +26 -0
- package/dist/backend/importers/TypeScriptCodeImporter.d.ts.map +1 -0
- package/dist/backend/importers/TypeScriptCodeImporter.js +57 -0
- package/dist/backend/importers/TypeScriptCodeImporter.js.map +1 -0
- package/dist/backend/importers/TypeScriptCodeImporter.test.d.ts +2 -0
- package/dist/backend/importers/TypeScriptCodeImporter.test.d.ts.map +1 -0
- package/dist/backend/importers/TypeScriptCodeImporter.test.js +1795 -0
- package/dist/backend/importers/TypeScriptCodeImporter.test.js.map +1 -0
- package/dist/backend/importers/TypeScriptConstantPlugin.d.ts +8 -0
- package/dist/backend/importers/TypeScriptConstantPlugin.d.ts.map +1 -0
- package/dist/backend/importers/TypeScriptConstantPlugin.js +412 -0
- package/dist/backend/importers/TypeScriptConstantPlugin.js.map +1 -0
- package/dist/backend/importers/TypeScriptDeclarationSources.d.ts +19 -0
- package/dist/backend/importers/TypeScriptDeclarationSources.d.ts.map +1 -0
- package/dist/backend/importers/TypeScriptDeclarationSources.js +119 -0
- package/dist/backend/importers/TypeScriptDeclarationSources.js.map +1 -0
- package/dist/backend/importers/TypeScriptDeclarationSyntax.d.ts +8 -0
- package/dist/backend/importers/TypeScriptDeclarationSyntax.d.ts.map +1 -0
- package/dist/backend/importers/TypeScriptDeclarationSyntax.js +29 -0
- package/dist/backend/importers/TypeScriptDeclarationSyntax.js.map +1 -0
- package/dist/backend/importers/TypeScriptLuaDeclarations.d.ts +23 -0
- package/dist/backend/importers/TypeScriptLuaDeclarations.d.ts.map +1 -0
- package/dist/backend/importers/TypeScriptLuaDeclarations.js +553 -0
- package/dist/backend/importers/TypeScriptLuaDeclarations.js.map +1 -0
- package/dist/backend/importers/TypeScriptLuaDeclarations.test.d.ts +2 -0
- package/dist/backend/importers/TypeScriptLuaDeclarations.test.d.ts.map +1 -0
- package/dist/backend/importers/TypeScriptLuaDeclarations.test.js +29 -0
- package/dist/backend/importers/TypeScriptLuaDeclarations.test.js.map +1 -0
- package/dist/backend/importers/TypeScriptManifestModules.d.ts +36 -0
- package/dist/backend/importers/TypeScriptManifestModules.d.ts.map +1 -0
- package/dist/backend/importers/TypeScriptManifestModules.js +347 -0
- package/dist/backend/importers/TypeScriptManifestModules.js.map +1 -0
- package/dist/backend/importers/TypeScriptNamedTypes.d.ts +22 -0
- package/dist/backend/importers/TypeScriptNamedTypes.d.ts.map +1 -0
- package/dist/backend/importers/TypeScriptNamedTypes.js +193 -0
- package/dist/backend/importers/TypeScriptNamedTypes.js.map +1 -0
- package/dist/backend/importers/TypeScriptProgram.d.ts +24 -0
- package/dist/backend/importers/TypeScriptProgram.d.ts.map +1 -0
- package/dist/backend/importers/TypeScriptProgram.js +141 -0
- package/dist/backend/importers/TypeScriptProgram.js.map +1 -0
- package/dist/backend/importers/TypeScriptStaticLinker.d.ts +17 -0
- package/dist/backend/importers/TypeScriptStaticLinker.d.ts.map +1 -0
- package/dist/backend/importers/TypeScriptStaticLinker.js +702 -0
- package/dist/backend/importers/TypeScriptStaticLinker.js.map +1 -0
- package/dist/backend/importers/TypeScriptTranspilationOptions.d.ts +3 -0
- package/dist/backend/importers/TypeScriptTranspilationOptions.d.ts.map +1 -0
- package/dist/backend/importers/TypeScriptTranspilationOptions.js +82 -0
- package/dist/backend/importers/TypeScriptTranspilationOptions.js.map +1 -0
- package/dist/backend/importers/TypeScriptTranspiler.d.ts +13 -0
- package/dist/backend/importers/TypeScriptTranspiler.d.ts.map +1 -0
- package/dist/backend/importers/TypeScriptTranspiler.js +241 -0
- package/dist/backend/importers/TypeScriptTranspiler.js.map +1 -0
- package/dist/backend/importers/binaryResourceImporter.d.ts +5 -14
- package/dist/backend/importers/binaryResourceImporter.d.ts.map +1 -1
- package/dist/backend/importers/binaryResourceImporter.js +6 -34
- package/dist/backend/importers/binaryResourceImporter.js.map +1 -1
- package/dist/backend/importers/textResourceImporter.d.ts +5 -15
- package/dist/backend/importers/textResourceImporter.d.ts.map +1 -1
- package/dist/backend/importers/textResourceImporter.js +6 -36
- package/dist/backend/importers/textResourceImporter.js.map +1 -1
- package/dist/backend/importers/tic80CartImporter.d.ts +12 -15
- package/dist/backend/importers/tic80CartImporter.d.ts.map +1 -1
- package/dist/backend/importers/tic80CartImporter.js +49 -84
- package/dist/backend/importers/tic80CartImporter.js.map +1 -1
- package/dist/backend/importers/tsconfigUtils.d.ts +10 -0
- package/dist/backend/importers/tsconfigUtils.d.ts.map +1 -0
- package/dist/backend/importers/tsconfigUtils.js +152 -0
- package/dist/backend/importers/tsconfigUtils.js.map +1 -0
- package/dist/backend/luaEncode.d.ts +4 -4
- package/dist/backend/luaEncode.d.ts.map +1 -1
- package/dist/backend/luaEncode.js +39 -39
- package/dist/backend/luaEncode.js.map +1 -1
- package/dist/backend/luaEncode.test.js +68 -0
- package/dist/backend/luaEncode.test.js.map +1 -1
- package/dist/backend/luaPreprocessor.d.ts +18 -1
- package/dist/backend/luaPreprocessor.d.ts.map +1 -1
- package/dist/backend/luaPreprocessor.js +581 -232
- package/dist/backend/luaPreprocessor.js.map +1 -1
- package/dist/backend/luaPreprocessor.test.js +293 -12
- package/dist/backend/luaPreprocessor.test.js.map +1 -1
- package/dist/backend/luaPreprocessorSyntax.d.ts +25 -0
- package/dist/backend/luaPreprocessorSyntax.d.ts.map +1 -0
- package/dist/backend/luaPreprocessorSyntax.js +74 -0
- package/dist/backend/luaPreprocessorSyntax.js.map +1 -0
- package/dist/backend/luaPreprocessorSyntax.test.d.ts +2 -0
- package/dist/backend/luaPreprocessorSyntax.test.d.ts.map +1 -0
- package/dist/backend/luaPreprocessorSyntax.test.js +30 -0
- package/dist/backend/luaPreprocessorSyntax.test.js.map +1 -0
- package/dist/backend/manifestLoader.test.js +174 -1
- package/dist/backend/manifestLoader.test.js.map +1 -1
- package/dist/backend/manifestTypes.d.ts +127 -65
- package/dist/backend/manifestTypes.d.ts.map +1 -1
- package/dist/backend/manifestTypes.js +3 -0
- package/dist/backend/manifestTypes.js.map +1 -1
- package/dist/backend/preprocessorDefines.d.ts +4 -0
- package/dist/backend/preprocessorDefines.d.ts.map +1 -0
- package/dist/backend/preprocessorDefines.js +15 -0
- package/dist/backend/preprocessorDefines.js.map +1 -0
- package/dist/backend/project.d.ts +8 -2
- package/dist/backend/project.d.ts.map +1 -1
- package/dist/backend/project.js +159 -115
- package/dist/backend/project.js.map +1 -1
- package/dist/backend/project.test.d.ts +2 -0
- package/dist/backend/project.test.d.ts.map +1 -0
- package/dist/backend/project.test.js +196 -0
- package/dist/backend/project.test.js.map +1 -0
- package/dist/backend/projectCore.d.ts +6 -4
- package/dist/backend/projectCore.d.ts.map +1 -1
- package/dist/backend/projectCore.js +36 -44
- package/dist/backend/projectCore.js.map +1 -1
- package/dist/backend/projectCore.test.d.ts +2 -0
- package/dist/backend/projectCore.test.d.ts.map +1 -0
- package/dist/backend/projectCore.test.js +12 -0
- package/dist/backend/projectCore.test.js.map +1 -0
- package/dist/backend/projectEnvironment.d.ts +8 -0
- package/dist/backend/projectEnvironment.d.ts.map +1 -0
- package/dist/backend/projectEnvironment.js +70 -0
- package/dist/backend/projectEnvironment.js.map +1 -0
- package/dist/backend/projectEnvironment.test.d.ts +2 -0
- package/dist/backend/projectEnvironment.test.d.ts.map +1 -0
- package/dist/backend/projectEnvironment.test.js +90 -0
- package/dist/backend/projectEnvironment.test.js.map +1 -0
- package/dist/backend/projectFiles.d.ts +32 -0
- package/dist/backend/projectFiles.d.ts.map +1 -0
- package/dist/backend/projectFiles.js +148 -0
- package/dist/backend/projectFiles.js.map +1 -0
- package/dist/backend/projectFiles.test.d.ts +2 -0
- package/dist/backend/projectFiles.test.d.ts.map +1 -0
- package/dist/backend/projectFiles.test.js +136 -0
- package/dist/backend/projectFiles.test.js.map +1 -0
- package/dist/backend/sourceMap.d.ts +40 -3
- package/dist/backend/sourceMap.d.ts.map +1 -1
- package/dist/backend/sourceMap.js +333 -64
- package/dist/backend/sourceMap.js.map +1 -1
- package/dist/backend/sourceMap.test.js +81 -0
- package/dist/backend/sourceMap.test.js.map +1 -1
- package/dist/backend/sourceMapLookup.d.ts +36 -0
- package/dist/backend/sourceMapLookup.d.ts.map +1 -0
- package/dist/backend/sourceMapLookup.js +170 -0
- package/dist/backend/sourceMapLookup.js.map +1 -0
- package/dist/backend/sourceMapLookup.test.d.ts +2 -0
- package/dist/backend/sourceMapLookup.test.d.ts.map +1 -0
- package/dist/backend/sourceMapLookup.test.js +132 -0
- package/dist/backend/sourceMapLookup.test.js.map +1 -0
- package/dist/backend/sourceMapV3.d.ts +8 -0
- package/dist/backend/sourceMapV3.d.ts.map +1 -0
- package/dist/backend/sourceMapV3.js +212 -0
- package/dist/backend/sourceMapV3.js.map +1 -0
- package/dist/backend/sourceMapV3.test.d.ts +2 -0
- package/dist/backend/sourceMapV3.test.d.ts.map +1 -0
- package/dist/backend/sourceMapV3.test.js +109 -0
- package/dist/backend/sourceMapV3.test.js.map +1 -0
- package/dist/backend/symbolIndex.d.ts +2 -12
- package/dist/backend/symbolIndex.d.ts.map +1 -1
- package/dist/backend/symbolIndex.js +18 -107
- package/dist/backend/symbolIndex.js.map +1 -1
- package/dist/backend/symbolIndex.test.js +6 -1
- package/dist/backend/symbolIndex.test.js.map +1 -1
- package/dist/backend/tic80Controller/customController.d.ts +7 -1
- package/dist/backend/tic80Controller/customController.d.ts.map +1 -1
- package/dist/backend/tic80Controller/customController.js +25 -11
- package/dist/backend/tic80Controller/customController.js.map +1 -1
- package/dist/backend/tic80Controller/customController.test.js +17 -4
- package/dist/backend/tic80Controller/customController.test.js.map +1 -1
- package/dist/backend/tic80Controller/remotingClient.d.ts.map +1 -1
- package/dist/backend/tic80Controller/remotingClient.js +2 -1
- package/dist/backend/tic80Controller/remotingClient.js.map +1 -1
- package/dist/backend/tic80Controller/remotingProtocol.d.ts +2 -0
- package/dist/backend/tic80Controller/remotingProtocol.d.ts.map +1 -1
- package/dist/backend/tic80Controller/remotingProtocol.js +19 -0
- package/dist/backend/tic80Controller/remotingProtocol.js.map +1 -1
- package/dist/backend/tic80Controller/remotingProtocol.test.js +16 -0
- package/dist/backend/tic80Controller/remotingProtocol.test.js.map +1 -1
- package/dist/backend/tic80Controller/scriptErrorProtocol.d.ts +41 -0
- package/dist/backend/tic80Controller/scriptErrorProtocol.d.ts.map +1 -0
- package/dist/backend/tic80Controller/scriptErrorProtocol.js +98 -0
- package/dist/backend/tic80Controller/scriptErrorProtocol.js.map +1 -0
- package/dist/backend/tic80Controller/scriptErrorProtocol.test.d.ts +2 -0
- package/dist/backend/tic80Controller/scriptErrorProtocol.test.d.ts.map +1 -0
- package/dist/backend/tic80Controller/scriptErrorProtocol.test.js +78 -0
- package/dist/backend/tic80Controller/scriptErrorProtocol.test.js.map +1 -0
- package/dist/backend/tic80Controller/tic80Controller.d.ts +7 -0
- package/dist/backend/tic80Controller/tic80Controller.d.ts.map +1 -1
- package/dist/backend/tic80Controller/vanillaController.d.ts +3 -5
- package/dist/backend/tic80Controller/vanillaController.d.ts.map +1 -1
- package/dist/backend/tic80Controller/vanillaController.js +19 -18
- package/dist/backend/tic80Controller/vanillaController.js.map +1 -1
- package/dist/backend/tic80Controller/vanillaController.test.d.ts +2 -0
- package/dist/backend/tic80Controller/vanillaController.test.d.ts.map +1 -0
- package/dist/backend/tic80Controller/vanillaController.test.js +36 -0
- package/dist/backend/tic80Controller/vanillaController.test.js.map +1 -0
- package/dist/backend/tic80Resolver.d.ts +2 -0
- package/dist/backend/tic80Resolver.d.ts.map +1 -1
- package/dist/backend/tic80Resolver.js +15 -47
- package/dist/backend/tic80Resolver.js.map +1 -1
- package/dist/backend/tic80Resolver.test.d.ts +2 -0
- package/dist/backend/tic80Resolver.test.d.ts.map +1 -0
- package/dist/backend/tic80Resolver.test.js +34 -0
- package/dist/backend/tic80Resolver.test.js.map +1 -0
- package/dist/benchmarks/luaMinifiers.d.ts +50 -0
- package/dist/benchmarks/luaMinifiers.d.ts.map +1 -0
- package/dist/benchmarks/luaMinifiers.js +219 -0
- package/dist/benchmarks/luaMinifiers.js.map +1 -0
- package/dist/benchmarks/luaMinifiers.test.d.ts +2 -0
- package/dist/benchmarks/luaMinifiers.test.d.ts.map +1 -0
- package/dist/benchmarks/luaMinifiers.test.js +68 -0
- package/dist/benchmarks/luaMinifiers.test.js.map +1 -0
- package/dist/buildInfo.d.ts +7 -4
- package/dist/buildInfo.d.ts.map +1 -1
- package/dist/buildInfo.js +7 -4
- package/dist/buildInfo.js.map +1 -1
- package/dist/frontend/build.d.ts.map +1 -1
- package/dist/frontend/build.js +3 -5
- package/dist/frontend/build.js.map +1 -1
- package/dist/frontend/buildReporter.d.ts +10 -2
- package/dist/frontend/buildReporter.d.ts.map +1 -1
- package/dist/frontend/buildReporter.js +4 -1
- package/dist/frontend/buildReporter.js.map +1 -1
- package/dist/frontend/buildReporter.test.js +51 -2
- package/dist/frontend/buildReporter.test.js.map +1 -1
- package/dist/frontend/cartUsage.d.ts +20 -0
- package/dist/frontend/cartUsage.d.ts.map +1 -0
- package/dist/frontend/cartUsage.js +103 -0
- package/dist/frontend/cartUsage.js.map +1 -0
- package/dist/frontend/codeBankPlacement.test.d.ts +2 -0
- package/dist/frontend/codeBankPlacement.test.d.ts.map +1 -0
- package/dist/frontend/codeBankPlacement.test.js +89 -0
- package/dist/frontend/codeBankPlacement.test.js.map +1 -0
- package/dist/frontend/codeBankWarnings.test.js +1 -0
- package/dist/frontend/codeBankWarnings.test.js.map +1 -1
- package/dist/frontend/core.d.ts +7 -2
- package/dist/frontend/core.d.ts.map +1 -1
- package/dist/frontend/core.js +301 -300
- package/dist/frontend/core.js.map +1 -1
- package/dist/frontend/init.d.ts +1 -0
- package/dist/frontend/init.d.ts.map +1 -1
- package/dist/frontend/init.js +34 -11
- package/dist/frontend/init.js.map +1 -1
- package/dist/frontend/init.test.d.ts +2 -0
- package/dist/frontend/init.test.d.ts.map +1 -0
- package/dist/frontend/init.test.js +190 -0
- package/dist/frontend/init.test.js.map +1 -0
- package/dist/frontend/inspect.d.ts +2 -0
- package/dist/frontend/inspect.d.ts.map +1 -0
- package/dist/frontend/inspect.js +62 -0
- package/dist/frontend/inspect.js.map +1 -0
- package/dist/frontend/inspect.test.d.ts +2 -0
- package/dist/frontend/inspect.test.d.ts.map +1 -0
- package/dist/frontend/inspect.test.js +126 -0
- package/dist/frontend/inspect.test.js.map +1 -0
- package/dist/frontend/luaCodeArtifacts.test.js +39 -1
- package/dist/frontend/luaCodeArtifacts.test.js.map +1 -1
- package/dist/frontend/packageInstaller.d.ts +2 -0
- package/dist/frontend/packageInstaller.d.ts.map +1 -0
- package/dist/frontend/packageInstaller.js +59 -0
- package/dist/frontend/packageInstaller.js.map +1 -0
- package/dist/frontend/parseOptions.d.ts +4 -1
- package/dist/frontend/parseOptions.d.ts.map +1 -1
- package/dist/frontend/parseOptions.js +13 -8
- package/dist/frontend/parseOptions.js.map +1 -1
- package/dist/frontend/parseOptions.test.d.ts +2 -0
- package/dist/frontend/parseOptions.test.d.ts.map +1 -0
- package/dist/frontend/parseOptions.test.js +65 -0
- package/dist/frontend/parseOptions.test.js.map +1 -0
- package/dist/frontend/projectFiles.d.ts +4 -0
- package/dist/frontend/projectFiles.d.ts.map +1 -0
- package/dist/frontend/projectFiles.js +95 -0
- package/dist/frontend/projectFiles.js.map +1 -0
- package/dist/frontend/projectFiles.test.d.ts +2 -0
- package/dist/frontend/projectFiles.test.d.ts.map +1 -0
- package/dist/frontend/projectFiles.test.js +106 -0
- package/dist/frontend/projectFiles.test.js.map +1 -0
- package/dist/frontend/run.d.ts.map +1 -1
- package/dist/frontend/run.js +3 -1
- package/dist/frontend/run.js.map +1 -1
- package/dist/frontend/scriptErrorPresentation.d.ts +9 -0
- package/dist/frontend/scriptErrorPresentation.d.ts.map +1 -0
- package/dist/frontend/scriptErrorPresentation.js +76 -0
- package/dist/frontend/scriptErrorPresentation.js.map +1 -0
- package/dist/frontend/scriptErrorPresentation.test.d.ts +2 -0
- package/dist/frontend/scriptErrorPresentation.test.d.ts.map +1 -0
- package/dist/frontend/scriptErrorPresentation.test.js +137 -0
- package/dist/frontend/scriptErrorPresentation.test.js.map +1 -0
- package/dist/frontend/scriptErrorSourceMapper.d.ts +15 -0
- package/dist/frontend/scriptErrorSourceMapper.d.ts.map +1 -0
- package/dist/frontend/scriptErrorSourceMapper.js +177 -0
- package/dist/frontend/scriptErrorSourceMapper.js.map +1 -0
- package/dist/frontend/scriptErrorSourceMapper.test.d.ts +2 -0
- package/dist/frontend/scriptErrorSourceMapper.test.d.ts.map +1 -0
- package/dist/frontend/scriptErrorSourceMapper.test.js +189 -0
- package/dist/frontend/scriptErrorSourceMapper.test.js.map +1 -0
- package/dist/frontend/terminal.d.ts +28 -2
- package/dist/frontend/terminal.d.ts.map +1 -1
- package/dist/frontend/terminal.js +465 -25
- package/dist/frontend/terminal.js.map +1 -1
- package/dist/frontend/terminal.test.js +563 -0
- package/dist/frontend/terminal.test.js.map +1 -1
- package/dist/frontend/typescriptExample.test.d.ts +2 -0
- package/dist/frontend/typescriptExample.test.d.ts.map +1 -0
- package/dist/frontend/typescriptExample.test.js +92 -0
- package/dist/frontend/typescriptExample.test.js.map +1 -0
- package/dist/frontend/watch.d.ts.map +1 -1
- package/dist/frontend/watch.js +160 -39
- package/dist/frontend/watch.js.map +1 -1
- package/dist/frontend/watch.test.js +3 -1
- package/dist/frontend/watch.test.js.map +1 -1
- package/dist/index.js +61 -20
- package/dist/index.js.map +1 -1
- package/dist/obj/build.jsonl +5 -0
- package/dist/obj/build.log +11 -5
- package/dist/obj/build.trace.json +89 -0
- package/dist/obj/resolvedManifest.ticbuild.jsonc +4 -3
- package/dist/obj/variables.json +2 -2
- package/dist/projectFileInventory.d.ts +40 -0
- package/dist/projectFileInventory.d.ts.map +1 -0
- package/dist/projectFileInventory.js +36 -0
- package/dist/projectFileInventory.js.map +1 -0
- package/dist/utils/console.d.ts +1 -1
- package/dist/utils/console.d.ts.map +1 -1
- package/dist/utils/console.js +1 -1
- package/dist/utils/console.js.map +1 -1
- package/dist/utils/encoding/base64.d.ts +3 -0
- package/dist/utils/encoding/base64.d.ts.map +1 -0
- package/dist/utils/encoding/base64.js +51 -0
- package/dist/utils/encoding/base64.js.map +1 -0
- package/dist/utils/encoding/codecRegistry.d.ts +69 -12
- package/dist/utils/encoding/codecRegistry.d.ts.map +1 -1
- package/dist/utils/encoding/codecRegistry.js +6 -0
- package/dist/utils/encoding/codecRegistry.js.map +1 -1
- package/dist/utils/encoding/hex.d.ts.map +1 -1
- package/dist/utils/encoding/hex.js +3 -0
- package/dist/utils/encoding/hex.js.map +1 -1
- package/dist/utils/encoding/lz.d.ts +25 -5
- package/dist/utils/encoding/lz.d.ts.map +1 -1
- package/dist/utils/encoding/lz.js +160 -48
- package/dist/utils/encoding/lz.js.map +1 -1
- package/dist/utils/encoding/lz.test.d.ts +2 -0
- package/dist/utils/encoding/lz.test.d.ts.map +1 -0
- package/dist/utils/encoding/lz.test.js +95 -0
- package/dist/utils/encoding/lz.test.js.map +1 -0
- package/dist/utils/encoding/payloadOutput.d.ts +4 -0
- package/dist/utils/encoding/payloadOutput.d.ts.map +1 -0
- package/dist/utils/encoding/payloadOutput.js +12 -0
- package/dist/utils/encoding/payloadOutput.js.map +1 -0
- package/dist/utils/encoding/payloadOutput.test.d.ts +2 -0
- package/dist/utils/encoding/payloadOutput.test.d.ts.map +1 -0
- package/dist/utils/encoding/payloadOutput.test.js +21 -0
- package/dist/utils/encoding/payloadOutput.test.js.map +1 -0
- package/dist/utils/encoding/payloadTextEncoding.d.ts +6 -0
- package/dist/utils/encoding/payloadTextEncoding.d.ts.map +1 -0
- package/dist/utils/encoding/payloadTextEncoding.js +39 -0
- package/dist/utils/encoding/payloadTextEncoding.js.map +1 -0
- package/dist/utils/encoding/payloadTextEncoding.test.d.ts +2 -0
- package/dist/utils/encoding/payloadTextEncoding.test.d.ts.map +1 -0
- package/dist/utils/encoding/payloadTextEncoding.test.js +31 -0
- package/dist/utils/encoding/payloadTextEncoding.test.js.map +1 -0
- package/dist/utils/errorHandling.d.ts +1 -0
- package/dist/utils/errorHandling.d.ts.map +1 -1
- package/dist/utils/errorHandling.js +4 -0
- package/dist/utils/errorHandling.js.map +1 -1
- package/dist/utils/errorHandling.test.d.ts +2 -0
- package/dist/utils/errorHandling.test.d.ts.map +1 -0
- package/dist/utils/errorHandling.test.js +17 -0
- package/dist/utils/errorHandling.test.js.map +1 -0
- package/dist/utils/fileSystem.d.ts +3 -1
- package/dist/utils/fileSystem.d.ts.map +1 -1
- package/dist/utils/fileSystem.js +16 -16
- package/dist/utils/fileSystem.js.map +1 -1
- package/dist/utils/help.d.ts +2 -1
- package/dist/utils/help.d.ts.map +1 -1
- package/dist/utils/help.js +8 -3
- package/dist/utils/help.js.map +1 -1
- package/dist/utils/lua/LuaCATS.d.ts +31 -0
- package/dist/utils/lua/LuaCATS.d.ts.map +1 -0
- package/dist/utils/lua/LuaCATS.js +159 -0
- package/dist/utils/lua/LuaCATS.js.map +1 -0
- package/dist/utils/lua/LuaCATS_declarations.d.ts +22 -0
- package/dist/utils/lua/LuaCATS_declarations.d.ts.map +1 -0
- package/dist/utils/lua/LuaCATS_declarations.js +107 -0
- package/dist/utils/lua/LuaCATS_declarations.js.map +1 -0
- package/dist/utils/lua/LuaCATS_declarations.test.d.ts +2 -0
- package/dist/utils/lua/LuaCATS_declarations.test.d.ts.map +1 -0
- package/dist/utils/lua/LuaCATS_declarations.test.js +38 -0
- package/dist/utils/lua/LuaCATS_declarations.test.js.map +1 -0
- package/dist/utils/lua/LuaCATS_types.d.ts +52 -0
- package/dist/utils/lua/LuaCATS_types.d.ts.map +1 -0
- package/dist/utils/lua/LuaCATS_types.js +202 -0
- package/dist/utils/lua/LuaCATS_types.js.map +1 -0
- package/dist/utils/lua/LuaCATS_types.test.d.ts +2 -0
- package/dist/utils/lua/LuaCATS_types.test.d.ts.map +1 -0
- package/dist/utils/lua/LuaCATS_types.test.js +38 -0
- package/dist/utils/lua/LuaCATS_types.test.js.map +1 -0
- package/dist/utils/lua/lua_alias_expressions.d.ts +2 -0
- package/dist/utils/lua/lua_alias_expressions.d.ts.map +1 -1
- package/dist/utils/lua/lua_alias_expressions.js +12 -1
- package/dist/utils/lua/lua_alias_expressions.js.map +1 -1
- package/dist/utils/lua/lua_alias_literals.d.ts +2 -0
- package/dist/utils/lua/lua_alias_literals.d.ts.map +1 -1
- package/dist/utils/lua/lua_alias_literals.js +12 -1
- package/dist/utils/lua/lua_alias_literals.js.map +1 -1
- package/dist/utils/lua/lua_alias_shared.d.ts +0 -1
- package/dist/utils/lua/lua_alias_shared.d.ts.map +1 -1
- package/dist/utils/lua/lua_alias_shared.js +60 -56
- package/dist/utils/lua/lua_alias_shared.js.map +1 -1
- package/dist/utils/lua/lua_ast.d.ts +0 -1
- package/dist/utils/lua/lua_ast.d.ts.map +1 -1
- package/dist/utils/lua/lua_ast.js +0 -6
- package/dist/utils/lua/lua_ast.js.map +1 -1
- package/dist/utils/lua/lua_ast_printer.d.ts +55 -0
- package/dist/utils/lua/lua_ast_printer.d.ts.map +1 -0
- package/dist/utils/lua/lua_ast_printer.js +1043 -0
- package/dist/utils/lua/lua_ast_printer.js.map +1 -0
- package/dist/utils/lua/lua_ast_provenance.d.ts +13 -0
- package/dist/utils/lua/lua_ast_provenance.d.ts.map +1 -0
- package/dist/utils/lua/lua_ast_provenance.js +67 -0
- package/dist/utils/lua/lua_ast_provenance.js.map +1 -0
- package/dist/utils/lua/lua_ast_rewrite.d.ts +20 -0
- package/dist/utils/lua/lua_ast_rewrite.d.ts.map +1 -0
- package/dist/utils/lua/lua_ast_rewrite.js +198 -0
- package/dist/utils/lua/lua_ast_rewrite.js.map +1 -0
- package/dist/utils/lua/lua_binding_optimizations.test.d.ts +2 -0
- package/dist/utils/lua/lua_binding_optimizations.test.d.ts.map +1 -0
- package/dist/utils/lua/lua_binding_optimizations.test.js +247 -0
- package/dist/utils/lua/lua_binding_optimizations.test.js.map +1 -0
- package/dist/utils/lua/lua_canonicalization_rules.test.d.ts +2 -0
- package/dist/utils/lua/lua_canonicalization_rules.test.d.ts.map +1 -0
- package/dist/utils/lua/lua_canonicalization_rules.test.js +194 -0
- package/dist/utils/lua/lua_canonicalization_rules.test.js.map +1 -0
- package/dist/utils/lua/lua_constant_literals.d.ts +7 -0
- package/dist/utils/lua/lua_constant_literals.d.ts.map +1 -0
- package/dist/utils/lua/lua_constant_literals.js +39 -0
- package/dist/utils/lua/lua_constant_literals.js.map +1 -0
- package/dist/utils/lua/lua_control_flow_invert_negated_if.d.ts +3 -0
- package/dist/utils/lua/lua_control_flow_invert_negated_if.d.ts.map +1 -0
- package/dist/utils/lua/lua_control_flow_invert_negated_if.js +37 -0
- package/dist/utils/lua/lua_control_flow_invert_negated_if.js.map +1 -0
- package/dist/utils/lua/lua_control_flow_remove_false_while.d.ts +3 -0
- package/dist/utils/lua/lua_control_flow_remove_false_while.d.ts.map +1 -0
- package/dist/utils/lua/lua_control_flow_remove_false_while.js +26 -0
- package/dist/utils/lua/lua_control_flow_remove_false_while.js.map +1 -0
- package/dist/utils/lua/lua_control_flow_resolve_constant_if.d.ts +3 -0
- package/dist/utils/lua/lua_control_flow_resolve_constant_if.d.ts.map +1 -0
- package/dist/utils/lua/lua_control_flow_resolve_constant_if.js +83 -0
- package/dist/utils/lua/lua_control_flow_resolve_constant_if.js.map +1 -0
- package/dist/utils/lua/lua_debug.d.ts +16 -0
- package/dist/utils/lua/lua_debug.d.ts.map +1 -0
- package/dist/utils/lua/lua_debug.js +42 -0
- package/dist/utils/lua/lua_debug.js.map +1 -0
- package/dist/utils/lua/lua_debug.test.d.ts +2 -0
- package/dist/utils/lua/lua_debug.test.d.ts.map +1 -0
- package/dist/utils/lua/lua_debug.test.js +24 -0
- package/dist/utils/lua/lua_debug.test.js.map +1 -0
- package/dist/utils/lua/lua_doc.d.ts +15 -0
- package/dist/utils/lua/lua_doc.d.ts.map +1 -1
- package/dist/utils/lua/lua_doc.js +96 -0
- package/dist/utils/lua/lua_doc.js.map +1 -1
- package/dist/utils/lua/lua_doc_types.d.ts +36 -0
- package/dist/utils/lua/lua_doc_types.d.ts.map +1 -0
- package/dist/utils/lua/lua_doc_types.js +122 -0
- package/dist/utils/lua/lua_doc_types.js.map +1 -0
- package/dist/utils/lua/lua_doc_types.test.d.ts +2 -0
- package/dist/utils/lua/lua_doc_types.test.d.ts.map +1 -0
- package/dist/utils/lua/lua_doc_types.test.js +33 -0
- package/dist/utils/lua/lua_doc_types.test.js.map +1 -0
- package/dist/utils/lua/lua_expression_effects.d.ts +3 -0
- package/dist/utils/lua/lua_expression_effects.d.ts.map +1 -0
- package/dist/utils/lua/lua_expression_effects.js +33 -0
- package/dist/utils/lua/lua_expression_effects.js.map +1 -0
- package/dist/utils/lua/lua_fundamentals.d.ts +4 -0
- package/dist/utils/lua/lua_fundamentals.d.ts.map +1 -1
- package/dist/utils/lua/lua_fundamentals.js +35 -3
- package/dist/utils/lua/lua_fundamentals.js.map +1 -1
- package/dist/utils/lua/lua_inline_immutable_aliases.d.ts +3 -0
- package/dist/utils/lua/lua_inline_immutable_aliases.d.ts.map +1 -0
- package/dist/utils/lua/lua_inline_immutable_aliases.js +124 -0
- package/dist/utils/lua/lua_inline_immutable_aliases.js.map +1 -0
- package/dist/utils/lua/lua_inline_immutable_scalars.d.ts +3 -0
- package/dist/utils/lua/lua_inline_immutable_scalars.d.ts.map +1 -0
- package/dist/utils/lua/lua_inline_immutable_scalars.js +230 -0
- package/dist/utils/lua/lua_inline_immutable_scalars.js.map +1 -0
- package/dist/utils/lua/lua_inline_single_use_expressions.d.ts +3 -0
- package/dist/utils/lua/lua_inline_single_use_expressions.d.ts.map +1 -0
- package/dist/utils/lua/lua_inline_single_use_expressions.js +105 -0
- package/dist/utils/lua/lua_inline_single_use_expressions.js.map +1 -0
- package/dist/utils/lua/lua_lexical_bindings.d.ts +25 -0
- package/dist/utils/lua/lua_lexical_bindings.d.ts.map +1 -0
- package/dist/utils/lua/lua_lexical_bindings.js +233 -0
- package/dist/utils/lua/lua_lexical_bindings.js.map +1 -0
- package/dist/utils/lua/lua_local_budget.test.js +12 -1
- package/dist/utils/lua/lua_local_budget.test.js.map +1 -1
- package/dist/utils/lua/lua_optimizer.d.ts +10 -0
- package/dist/utils/lua/lua_optimizer.d.ts.map +1 -0
- package/dist/utils/lua/lua_optimizer.js +128 -0
- package/dist/utils/lua/lua_optimizer.js.map +1 -0
- package/dist/utils/lua/lua_optimizer.test.d.ts +2 -0
- package/dist/utils/lua/lua_optimizer.test.d.ts.map +1 -0
- package/dist/utils/lua/lua_optimizer.test.js +262 -0
- package/dist/utils/lua/lua_optimizer.test.js.map +1 -0
- package/dist/utils/lua/lua_optimizer_fingerprint.d.ts +3 -0
- package/dist/utils/lua/lua_optimizer_fingerprint.d.ts.map +1 -0
- package/dist/utils/lua/lua_optimizer_fingerprint.js +50 -0
- package/dist/utils/lua/lua_optimizer_fingerprint.js.map +1 -0
- package/dist/utils/lua/lua_optimizer_rules.d.ts +3 -0
- package/dist/utils/lua/lua_optimizer_rules.d.ts.map +1 -0
- package/dist/utils/lua/lua_optimizer_rules.js +57 -0
- package/dist/utils/lua/lua_optimizer_rules.js.map +1 -0
- package/dist/utils/lua/lua_optimizer_types.d.ts +55 -0
- package/dist/utils/lua/lua_optimizer_types.d.ts.map +1 -0
- package/dist/utils/lua/lua_optimizer_types.js +31 -0
- package/dist/utils/lua/lua_optimizer_types.js.map +1 -0
- package/dist/utils/lua/lua_pack_locals.d.ts +2 -0
- package/dist/utils/lua/lua_pack_locals.d.ts.map +1 -1
- package/dist/utils/lua/lua_pack_locals.js +58 -14
- package/dist/utils/lua/lua_pack_locals.js.map +1 -1
- package/dist/utils/lua/lua_print_trace.d.ts +4 -0
- package/dist/utils/lua/lua_print_trace.d.ts.map +1 -0
- package/dist/utils/lua/lua_print_trace.js +166 -0
- package/dist/utils/lua/lua_print_trace.js.map +1 -0
- package/dist/utils/lua/lua_printer.d.ts +11 -0
- package/dist/utils/lua/lua_printer.d.ts.map +1 -0
- package/dist/utils/lua/lua_printer.js +105 -0
- package/dist/utils/lua/lua_printer.js.map +1 -0
- package/dist/utils/lua/lua_printer_lexemes.d.ts +22 -0
- package/dist/utils/lua/lua_printer_lexemes.d.ts.map +1 -0
- package/dist/utils/lua/lua_printer_lexemes.js +111 -0
- package/dist/utils/lua/lua_printer_lexemes.js.map +1 -0
- package/dist/utils/lua/lua_printer_tight2.d.ts +2 -0
- package/dist/utils/lua/lua_printer_tight2.d.ts.map +1 -0
- package/dist/utils/lua/lua_printer_tight2.js +64 -0
- package/dist/utils/lua/lua_printer_tight2.js.map +1 -0
- package/dist/utils/lua/lua_printer_traceable.d.ts +2 -0
- package/dist/utils/lua/lua_printer_traceable.d.ts.map +1 -0
- package/dist/utils/lua/lua_printer_traceable.js +107 -0
- package/dist/utils/lua/lua_printer_traceable.js.map +1 -0
- package/dist/utils/lua/lua_printer_types.d.ts +7 -0
- package/dist/utils/lua/lua_printer_types.d.ts.map +1 -0
- package/dist/utils/lua/lua_printer_types.js +3 -0
- package/dist/utils/lua/lua_printer_types.js.map +1 -0
- package/dist/utils/lua/lua_processor.d.ts +15 -72
- package/dist/utils/lua/lua_processor.d.ts.map +1 -1
- package/dist/utils/lua/lua_processor.js +177 -1205
- package/dist/utils/lua/lua_processor.js.map +1 -1
- package/dist/utils/lua/lua_processor.test.js +450 -101
- package/dist/utils/lua/lua_processor.test.js.map +1 -1
- package/dist/utils/lua/lua_remove_dead_stores.d.ts +3 -0
- package/dist/utils/lua/lua_remove_dead_stores.d.ts.map +1 -0
- package/dist/utils/lua/lua_remove_dead_stores.js +108 -0
- package/dist/utils/lua/lua_remove_dead_stores.js.map +1 -0
- package/dist/utils/lua/lua_remove_self_assignments.d.ts +3 -0
- package/dist/utils/lua/lua_remove_self_assignments.d.ts.map +1 -0
- package/dist/utils/lua/lua_remove_self_assignments.js +40 -0
- package/dist/utils/lua/lua_remove_self_assignments.js.map +1 -0
- package/dist/utils/lua/lua_remove_unused_for_variables.d.ts +3 -0
- package/dist/utils/lua/lua_remove_unused_for_variables.d.ts.map +1 -0
- package/dist/utils/lua/lua_remove_unused_for_variables.js +40 -0
- package/dist/utils/lua/lua_remove_unused_for_variables.js.map +1 -0
- package/dist/utils/lua/lua_remove_unused_functions.d.ts +2 -0
- package/dist/utils/lua/lua_remove_unused_functions.d.ts.map +1 -1
- package/dist/utils/lua/lua_remove_unused_functions.js +29 -6
- package/dist/utils/lua/lua_remove_unused_functions.js.map +1 -1
- package/dist/utils/lua/lua_remove_unused_locals.d.ts +2 -0
- package/dist/utils/lua/lua_remove_unused_locals.d.ts.map +1 -1
- package/dist/utils/lua/lua_remove_unused_locals.js +72 -289
- package/dist/utils/lua/lua_remove_unused_locals.js.map +1 -1
- package/dist/utils/lua/lua_remove_unused_parameters.d.ts +3 -0
- package/dist/utils/lua/lua_remove_unused_parameters.d.ts.map +1 -0
- package/dist/utils/lua/lua_remove_unused_parameters.js +124 -0
- package/dist/utils/lua/lua_remove_unused_parameters.js.map +1 -0
- package/dist/utils/lua/lua_rename_allowed_globals.d.ts +3 -0
- package/dist/utils/lua/lua_rename_allowed_globals.d.ts.map +1 -1
- package/dist/utils/lua/lua_rename_allowed_globals.js +78 -41
- package/dist/utils/lua/lua_rename_allowed_globals.js.map +1 -1
- package/dist/utils/lua/lua_rename_allowed_table_keys.d.ts +2 -0
- package/dist/utils/lua/lua_rename_allowed_table_keys.d.ts.map +1 -1
- package/dist/utils/lua/lua_rename_allowed_table_keys.js +57 -20
- package/dist/utils/lua/lua_rename_allowed_table_keys.js.map +1 -1
- package/dist/utils/lua/lua_rename_table_fields.d.ts +2 -0
- package/dist/utils/lua/lua_rename_table_fields.d.ts.map +1 -1
- package/dist/utils/lua/lua_rename_table_fields.js +15 -2
- package/dist/utils/lua/lua_rename_table_fields.js.map +1 -1
- package/dist/utils/lua/lua_renamer.d.ts +2 -0
- package/dist/utils/lua/lua_renamer.d.ts.map +1 -1
- package/dist/utils/lua/lua_renamer.js +146 -157
- package/dist/utils/lua/lua_renamer.js.map +1 -1
- package/dist/utils/lua/lua_scalar_simplification.test.d.ts +2 -0
- package/dist/utils/lua/lua_scalar_simplification.test.d.ts.map +1 -0
- package/dist/utils/lua/lua_scalar_simplification.test.js +293 -0
- package/dist/utils/lua/lua_scalar_simplification.test.js.map +1 -0
- package/dist/utils/lua/lua_scope_name_reuse.test.d.ts +2 -0
- package/dist/utils/lua/lua_scope_name_reuse.test.d.ts.map +1 -0
- package/dist/utils/lua/lua_scope_name_reuse.test.js +159 -0
- package/dist/utils/lua/lua_scope_name_reuse.test.js.map +1 -0
- package/dist/utils/lua/lua_simplify.d.ts +2 -0
- package/dist/utils/lua/lua_simplify.d.ts.map +1 -1
- package/dist/utils/lua/lua_simplify.js +236 -500
- package/dist/utils/lua/lua_simplify.js.map +1 -1
- package/dist/utils/lua/lua_source_mapping.test.d.ts +2 -0
- package/dist/utils/lua/lua_source_mapping.test.d.ts.map +1 -0
- package/dist/utils/lua/lua_source_mapping.test.js +182 -0
- package/dist/utils/lua/lua_source_mapping.test.js.map +1 -0
- package/dist/utils/lua/lua_string_literal.test.d.ts +2 -0
- package/dist/utils/lua/lua_string_literal.test.d.ts.map +1 -0
- package/dist/utils/lua/lua_string_literal.test.js +70 -0
- package/dist/utils/lua/lua_string_literal.test.js.map +1 -0
- package/dist/utils/lua/lua_strip_comments.d.ts +3 -0
- package/dist/utils/lua/lua_strip_comments.d.ts.map +1 -0
- package/dist/utils/lua/lua_strip_comments.js +15 -0
- package/dist/utils/lua/lua_strip_comments.js.map +1 -0
- package/dist/utils/lua/lua_symbol_collision.test.d.ts +2 -0
- package/dist/utils/lua/lua_symbol_collision.test.d.ts.map +1 -0
- package/dist/utils/lua/lua_symbol_collision.test.js +55 -0
- package/dist/utils/lua/lua_symbol_collision.test.js.map +1 -0
- package/dist/utils/lua/lua_symbols.d.ts +19 -0
- package/dist/utils/lua/lua_symbols.d.ts.map +1 -0
- package/dist/utils/lua/lua_symbols.js +258 -0
- package/dist/utils/lua/lua_symbols.js.map +1 -0
- package/dist/utils/lua/lua_symbols.test.d.ts +2 -0
- package/dist/utils/lua/lua_symbols.test.d.ts.map +1 -0
- package/dist/utils/lua/lua_symbols.test.js +75 -0
- package/dist/utils/lua/lua_symbols.test.js.map +1 -0
- package/dist/utils/lua/lua_syntax_bare_table_key.d.ts +3 -0
- package/dist/utils/lua/lua_syntax_bare_table_key.d.ts.map +1 -0
- package/dist/utils/lua/lua_syntax_bare_table_key.js +55 -0
- package/dist/utils/lua/lua_syntax_bare_table_key.js.map +1 -0
- package/dist/utils/lua/lua_syntax_member_access.d.ts +3 -0
- package/dist/utils/lua/lua_syntax_member_access.d.ts.map +1 -0
- package/dist/utils/lua/lua_syntax_member_access.js +40 -0
- package/dist/utils/lua/lua_syntax_member_access.js.map +1 -0
- package/dist/utils/lua/lua_syntax_omit_local_nil.d.ts +3 -0
- package/dist/utils/lua/lua_syntax_omit_local_nil.d.ts.map +1 -0
- package/dist/utils/lua/lua_syntax_omit_local_nil.js +32 -0
- package/dist/utils/lua/lua_syntax_omit_local_nil.js.map +1 -0
- package/dist/utils/lua/lua_syntax_remove_redundant_do.d.ts +3 -0
- package/dist/utils/lua/lua_syntax_remove_redundant_do.d.ts.map +1 -0
- package/dist/utils/lua/lua_syntax_remove_redundant_do.js +50 -0
- package/dist/utils/lua/lua_syntax_remove_redundant_do.js.map +1 -0
- package/dist/utils/lua/lua_transform_map.d.ts +36 -0
- package/dist/utils/lua/lua_transform_map.d.ts.map +1 -0
- package/dist/utils/lua/lua_transform_map.js +205 -0
- package/dist/utils/lua/lua_transform_map.js.map +1 -0
- package/dist/utils/lua/lua_utils.d.ts +2 -4
- package/dist/utils/lua/lua_utils.d.ts.map +1 -1
- package/dist/utils/lua/lua_utils.js +100 -37
- package/dist/utils/lua/lua_utils.js.map +1 -1
- package/dist/utils/templates.d.ts +1 -0
- package/dist/utils/templates.d.ts.map +1 -1
- package/dist/utils/templates.js +4 -0
- package/dist/utils/templates.js.map +1 -1
- package/dist/utils/tic80/cartLoader.d.ts.map +1 -1
- package/dist/utils/tic80/cartLoader.js +7 -5
- package/dist/utils/tic80/cartLoader.js.map +1 -1
- package/dist/utils/tic80/cartLoader.test.d.ts +2 -0
- package/dist/utils/tic80/cartLoader.test.d.ts.map +1 -0
- package/dist/utils/tic80/cartLoader.test.js +100 -0
- package/dist/utils/tic80/cartLoader.test.js.map +1 -0
- package/dist/utils/tic80/cartWriter.d.ts +2 -2
- package/dist/utils/tic80/cartWriter.d.ts.map +1 -1
- package/dist/utils/tic80/cartWriter.js +22 -17
- package/dist/utils/tic80/cartWriter.js.map +1 -1
- package/dist/utils/tic80/launch.d.ts +1 -1
- package/dist/utils/tic80/launch.d.ts.map +1 -1
- package/dist/utils/tic80/launch.js +2 -1
- package/dist/utils/tic80/launch.js.map +1 -1
- package/dist/utils/tic80/tic80.d.ts +52 -50
- package/dist/utils/tic80/tic80.d.ts.map +1 -1
- package/dist/utils/tic80/tic80.js +11 -7
- package/dist/utils/tic80/tic80.js.map +1 -1
- package/dist/utils/traceProfiler.d.ts +86 -0
- package/dist/utils/traceProfiler.d.ts.map +1 -0
- package/dist/utils/traceProfiler.js +241 -0
- package/dist/utils/traceProfiler.js.map +1 -0
- package/dist/utils/traceProfiler.test.d.ts +2 -0
- package/dist/utils/traceProfiler.test.d.ts.map +1 -0
- package/dist/utils/traceProfiler.test.js +236 -0
- package/dist/utils/traceProfiler.test.js.map +1 -0
- package/dist/utils/utils.d.ts +5 -0
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +35 -0
- package/dist/utils/utils.js.map +1 -1
- package/dist/utils/windowPosition.d.ts.map +1 -1
- package/dist/utils/windowPosition.js +2 -1
- package/dist/utils/windowPosition.js.map +1 -1
- package/package.json +31 -4
- package/scripts/benchmark-lua-minifiers.js +221 -0
- package/scripts/benchmark-lz-configs.js +247 -0
- package/scripts/gen-build-info.js +6 -0
- package/templates/TIC-80-ticbuild/tic80.exe +0 -0
- package/templates/declarations/tic80.d.ts +233 -0
- package/templates/env.template +11 -0
- package/templates/gitignore.template +7 -3
- package/templates/help/build.txt +2 -0
- package/templates/help/init.txt +3 -1
- package/templates/help/inspect.txt +14 -0
- package/templates/help/main.txt +3 -1
- package/templates/help/project.txt +27 -0
- package/templates/help/run.txt +4 -3
- package/templates/help/terminal.txt +32 -18
- package/templates/help/watch.txt +19 -5
- package/templates/minimal/project.ticbuild.jsonc +2 -1
- package/templates/piggybossa/project.ticbuild.jsonc +2 -1
- package/templates/pointsphere/project.ticbuild.jsonc +9 -15
- package/templates/pointsphere/src/palette.lua +5 -3
- package/templates/typescript/.luarc.json +5 -0
- package/templates/typescript/.vscode/extensions.json +3 -0
- package/templates/typescript/eslint.config.mjs +28 -0
- package/templates/typescript/package.json +22 -0
- package/templates/typescript/project.ticbuild.jsonc +28 -0
- package/templates/typescript/src/main.ts +6 -0
- package/templates/typescript/tsconfig.json +10 -0
- package/templates/vscode_extensions.template.json +3 -0
- package/templates/vscode_settings.template.json +3 -0
- package/ticbuild.schema.json +274 -110
- package/dist/backend/ImportedResource.d.ts +0 -11
- package/dist/backend/ImportedResource.d.ts.map +0 -1
- package/dist/backend/ImportedResource.js +0 -53
- package/dist/backend/ImportedResource.js.map +0 -1
- package/dist/backend/importers/luaImporter.d.ts +0 -1
- package/dist/backend/importers/luaImporter.d.ts.map +0 -1
- package/dist/backend/importers/luaImporter.js +0 -3
- package/dist/backend/importers/luaImporter.js.map +0 -1
- package/dist/backend/loadAllImports.d.ts +0 -1
- package/dist/backend/loadAllImports.d.ts.map +0 -1
- package/dist/backend/loadAllImports.js +0 -3
- package/dist/backend/loadAllImports.js.map +0 -1
- package/dist/backend/tic80Controller/externalController.d.ts +0 -18
- package/dist/backend/tic80Controller/externalController.d.ts.map +0 -1
- package/dist/backend/tic80Controller/externalController.js +0 -68
- package/dist/backend/tic80Controller/externalController.js.map +0 -1
- package/dist/backend/tic80Controller/internalController.d.ts +0 -13
- package/dist/backend/tic80Controller/internalController.d.ts.map +0 -1
- package/dist/backend/tic80Controller/internalController.js +0 -44
- package/dist/backend/tic80Controller/internalController.js.map +0 -1
- package/dist/frontend/manifestSchemaSync.test.d.ts +0 -2
- package/dist/frontend/manifestSchemaSync.test.d.ts.map +0 -1
- package/dist/frontend/manifestSchemaSync.test.js +0 -127
- package/dist/frontend/manifestSchemaSync.test.js.map +0 -1
- package/dist/frontend/repl.d.ts +0 -7
- package/dist/frontend/repl.d.ts.map +0 -1
- package/dist/frontend/repl.js +0 -271
- package/dist/frontend/repl.js.map +0 -1
- package/dist/utils/lua/luaUtils.d.ts +0 -1
- package/dist/utils/lua/luaUtils.d.ts.map +0 -1
- package/dist/utils/lua/luaUtils.js +0 -3
- package/dist/utils/lua/luaUtils.js.map +0 -1
- package/templates/help/repl.txt +0 -46
|
@@ -33,61 +33,113 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.preprocessTypeScriptDeclarationDirectives = preprocessTypeScriptDeclarationDirectives;
|
|
36
37
|
exports.preprocessLuaCode = preprocessLuaCode;
|
|
38
|
+
const luaparse = __importStar(require("luaparse"));
|
|
37
39
|
const path = __importStar(require("node:path"));
|
|
38
40
|
const fileSystem_1 = require("../utils/fileSystem");
|
|
39
41
|
const lua_fundamentals_1 = require("../utils/lua/lua_fundamentals");
|
|
40
42
|
const lua_utils_1 = require("../utils/lua/lua_utils");
|
|
41
43
|
const cartLoader_1 = require("../utils/tic80/cartLoader");
|
|
42
|
-
const
|
|
44
|
+
const importReference_1 = require("./importReference");
|
|
45
|
+
const tic80CartImporter_1 = require("./importers/tic80CartImporter");
|
|
43
46
|
const manifestTypes_1 = require("./manifestTypes");
|
|
44
47
|
const lua_processor_1 = require("../utils/lua/lua_processor");
|
|
45
|
-
const
|
|
48
|
+
const LuaCATS_1 = require("../utils/lua/LuaCATS");
|
|
46
49
|
const cons = __importStar(require("../utils/console"));
|
|
50
|
+
const errorHandling_1 = require("../utils/errorHandling");
|
|
47
51
|
const sourceMap_1 = require("./sourceMap");
|
|
48
52
|
const luaEncode_1 = require("./luaEncode");
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
const importSources_1 = require("./importSources");
|
|
54
|
+
const traceProfiler_1 = require("../utils/traceProfiler");
|
|
55
|
+
const preprocessorDefines_1 = require("./preprocessorDefines");
|
|
56
|
+
const luaPreprocessorSyntax_1 = require("./luaPreprocessorSyntax");
|
|
57
|
+
/** Resolve active includes from TypeScript directive comments before Lua exists. */
|
|
58
|
+
async function preprocessTypeScriptDeclarationDirectives(project, source, filePath, options) {
|
|
59
|
+
const directives = (0, luaPreprocessorSyntax_1.extractTypeScriptDeclarationDirectives)(source);
|
|
60
|
+
if (directives.trim())
|
|
61
|
+
await preprocessLuaCode(project, directives, filePath, options);
|
|
62
|
+
}
|
|
63
|
+
async function preprocessLuaCode(project, source, filePath, options = {}) {
|
|
64
|
+
const manifestDefines = (0, preprocessorDefines_1.getResolvedPreprocessorDefines)(project);
|
|
65
|
+
const fallbackImportSources = new Map();
|
|
66
|
+
const resolveImportSource = options.resolveImportSource ?? (async (importName) => {
|
|
67
|
+
const importDef = project.manifest.imports.find((candidate) => candidate.name === importName);
|
|
68
|
+
if (!importDef) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
let source = fallbackImportSources.get(importName);
|
|
72
|
+
if (!source) {
|
|
73
|
+
source = (0, importSources_1.materializeImportSource)(project, importDef);
|
|
74
|
+
fallbackImportSources.set(importName, source);
|
|
75
|
+
}
|
|
76
|
+
return await source;
|
|
77
|
+
});
|
|
51
78
|
const state = {
|
|
52
79
|
defines: new Map(Object.entries(manifestDefines)),
|
|
53
80
|
dependencies: new Set(),
|
|
54
81
|
pragmaOnceKeys: new Set(),
|
|
55
82
|
includeStack: [],
|
|
56
|
-
macros: new Map(),
|
|
57
83
|
macroSymbols: [],
|
|
58
84
|
minifyAllowedGlobalNames: [],
|
|
85
|
+
minifyGlobalNamesToKeep: [],
|
|
86
|
+
resolveCodeImport: options.resolveCodeImport,
|
|
87
|
+
resolveImportSource,
|
|
88
|
+
diagnostics: {
|
|
89
|
+
sourcesProcessed: 0,
|
|
90
|
+
sourceCharacters: 0,
|
|
91
|
+
includeDirectives: 0,
|
|
92
|
+
fileIncludes: 0,
|
|
93
|
+
codeImportIncludes: 0,
|
|
94
|
+
cartridgeCodeIncludes: 0,
|
|
95
|
+
pragmaOnceSkips: 0,
|
|
96
|
+
},
|
|
59
97
|
};
|
|
60
98
|
const includeKey = makeIncludeKey(filePath, {});
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
const
|
|
99
|
+
const inputSourceMap = options.sourceMap ?? (0, sourceMap_1.createIdentitySourceMap)(source, filePath);
|
|
100
|
+
(0, sourceMap_1.assertSourceMapMatchesSource)(inputSourceMap, source);
|
|
101
|
+
const rawResult = await (0, traceProfiler_1.profileAsync)(options.profileScope, "Resolve Lua includes and directives", {
|
|
102
|
+
category: "Lua preprocessing",
|
|
103
|
+
args: { inputCharacters: source.length },
|
|
104
|
+
}, async (scope) => {
|
|
105
|
+
const result = await processSource(project, source, inputSourceMap, filePath, includeKey, state, {});
|
|
106
|
+
scope?.setArgs({
|
|
107
|
+
outputCharacters: result.code.length,
|
|
108
|
+
sourceMapSegments: result.map.getSegments().length,
|
|
109
|
+
macroDefinitions: result.macroDefinitions.length,
|
|
110
|
+
...state.diagnostics,
|
|
111
|
+
});
|
|
112
|
+
return result;
|
|
113
|
+
});
|
|
114
|
+
const expandedResult = expandMacros(rawResult, filePath, options.profileScope);
|
|
115
|
+
const finalResult = await expandPreprocessorCalls(project, expandedResult, filePath, state, options.quietParseFailures ?? false, options.profileScope);
|
|
116
|
+
const sourceMap = (0, traceProfiler_1.profileSync)(options.profileScope, "Finalize Lua source map", {
|
|
117
|
+
category: "Lua preprocessing",
|
|
118
|
+
args: {
|
|
119
|
+
outputCharacters: finalResult.code.length,
|
|
120
|
+
sourceMapSegments: finalResult.map.getSegments().length,
|
|
121
|
+
},
|
|
122
|
+
}, () => finalResult.map.toSourceMap(finalResult.code));
|
|
64
123
|
return {
|
|
65
124
|
code: finalResult.code,
|
|
66
125
|
dependencies: Array.from(state.dependencies.values()),
|
|
67
|
-
sourceMap
|
|
126
|
+
sourceMap,
|
|
68
127
|
preprocessorSymbols: state.macroSymbols,
|
|
69
128
|
minifyAllowedGlobalNames: Array.from(new Set(state.minifyAllowedGlobalNames)),
|
|
129
|
+
minifyGlobalNamesToKeep: Array.from(new Set(state.minifyGlobalNamesToKeep)),
|
|
70
130
|
};
|
|
71
131
|
}
|
|
72
|
-
function
|
|
73
|
-
const defines = project.manifest.preprocessor?.defines;
|
|
74
|
-
if (!defines) {
|
|
75
|
-
return {};
|
|
76
|
-
}
|
|
77
|
-
const resolved = {};
|
|
78
|
-
for (const [key, value] of Object.entries(defines)) {
|
|
79
|
-
resolved[key] = typeof value === "string" ? project.substituteVariables(value) : value;
|
|
80
|
-
}
|
|
81
|
-
return resolved;
|
|
82
|
-
}
|
|
83
|
-
async function processSource(project, source, filePath, includeKey, state, inputOverrides, trackDependency = true) {
|
|
132
|
+
async function processSource(project, source, inputSourceMap, filePath, includeKey, state, inputOverrides, trackDependency = true) {
|
|
84
133
|
if (state.pragmaOnceKeys.has(includeKey)) {
|
|
85
|
-
|
|
134
|
+
state.diagnostics.pragmaOnceSkips++;
|
|
135
|
+
return { code: "", map: new sourceMap_1.SourceMapBuilder(), macroDefinitions: [] };
|
|
86
136
|
}
|
|
87
137
|
if (state.includeStack.includes(includeKey)) {
|
|
88
138
|
const cycle = [...state.includeStack, includeKey].join(" -> ");
|
|
89
139
|
throw new Error(`Lua preprocessor include cycle detected: ${cycle}`);
|
|
90
140
|
}
|
|
141
|
+
state.diagnostics.sourcesProcessed++;
|
|
142
|
+
state.diagnostics.sourceCharacters += source.length;
|
|
91
143
|
state.includeStack.push(includeKey);
|
|
92
144
|
if (trackDependency) {
|
|
93
145
|
state.dependencies.add(filePath);
|
|
@@ -101,9 +153,10 @@ async function processSource(project, source, filePath, includeKey, state, input
|
|
|
101
153
|
}
|
|
102
154
|
const conditionalStack = [];
|
|
103
155
|
const builder = new sourceMap_1.SourceMapBuilder();
|
|
156
|
+
const macroDefinitions = [];
|
|
104
157
|
let output = "";
|
|
105
158
|
let lastEmittedOrigin = null;
|
|
106
|
-
let
|
|
159
|
+
let pendingMinifyRename = null;
|
|
107
160
|
// helper to check if current line is in active conditional block
|
|
108
161
|
const isActive = () => {
|
|
109
162
|
if (conditionalStack.length === 0) {
|
|
@@ -117,71 +170,77 @@ async function processSource(project, source, filePath, includeKey, state, input
|
|
|
117
170
|
const lineInfo = lines[i];
|
|
118
171
|
const line = lineInfo.text;
|
|
119
172
|
const lineNumber = i + 1;
|
|
120
|
-
const
|
|
173
|
+
const authoredLineLocation = (0, sourceMap_1.mapPreprocessedOffsetToLineColumn)(inputSourceMap, lineInfo.startOffset, "right");
|
|
174
|
+
const authoredFilePath = authoredLineLocation?.file ?? filePath;
|
|
175
|
+
const authoredLineNumber = authoredLineLocation?.line ?? lineNumber;
|
|
176
|
+
const directiveMatch = (0, luaPreprocessorSyntax_1.parseLuaPreprocessorDirective)(line);
|
|
121
177
|
if (!directiveMatch) {
|
|
122
178
|
if (isActive()) {
|
|
123
|
-
if (
|
|
124
|
-
const targetName =
|
|
179
|
+
if (pendingMinifyRename && !isIgnorableMinifyTargetLine(line)) {
|
|
180
|
+
const targetName = parseMinifyRenameTarget(line);
|
|
125
181
|
if (!targetName) {
|
|
126
|
-
throw new Error(formatError(
|
|
182
|
+
throw new Error(formatError(pendingMinifyRename.filePath, pendingMinifyRename.lineNumber, minifyTargetError(pendingMinifyRename.option)));
|
|
127
183
|
}
|
|
128
|
-
|
|
129
|
-
|
|
184
|
+
if (pendingMinifyRename.option === "allow_rename") {
|
|
185
|
+
state.minifyAllowedGlobalNames.push(targetName);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
state.minifyGlobalNamesToKeep.push(targetName);
|
|
189
|
+
}
|
|
190
|
+
pendingMinifyRename = null;
|
|
130
191
|
}
|
|
131
192
|
if (output.length > 0) {
|
|
132
193
|
output += "\n";
|
|
133
|
-
const newlineOrigin = lastEmittedOrigin ??
|
|
134
|
-
builder.
|
|
194
|
+
const newlineOrigin = lastEmittedOrigin ?? (0, sourceMap_1.mapPreprocessedOffset)(inputSourceMap, lineInfo.startOffset, "right");
|
|
195
|
+
builder.appendGenerated("\n", newlineOrigin);
|
|
135
196
|
}
|
|
136
197
|
output += line;
|
|
137
|
-
builder.
|
|
138
|
-
lastEmittedOrigin =
|
|
198
|
+
builder.appendMappedSlice(line, inputSourceMap, lineInfo.startOffset);
|
|
199
|
+
lastEmittedOrigin = (0, sourceMap_1.mapPreprocessedOffset)(inputSourceMap, lineInfo.endOffset, "left");
|
|
139
200
|
}
|
|
140
201
|
continue;
|
|
141
202
|
}
|
|
142
|
-
const directive = directiveMatch
|
|
143
|
-
const rest = directiveMatch[2] || "";
|
|
203
|
+
const { name: directive, arguments: rest } = directiveMatch;
|
|
144
204
|
switch (directive) {
|
|
145
205
|
case "macro": {
|
|
146
|
-
const macroHeader = parseMacroHeader(rest,
|
|
206
|
+
const macroHeader = parseMacroHeader(rest, authoredFilePath, authoredLineNumber);
|
|
147
207
|
const nameOffset = findMacroNameOffset(line, lineInfo.startOffset, macroHeader.name);
|
|
148
|
-
const
|
|
208
|
+
const nameOrigin = (0, sourceMap_1.mapPreprocessedOffset)(inputSourceMap, nameOffset, "right");
|
|
209
|
+
const docLines = (0, LuaCATS_1.collectDocCommentAbove)(lineTexts, i);
|
|
149
210
|
if (macroHeader.inlineBody !== undefined) {
|
|
150
211
|
if (isActive()) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
sourceFile: filePath,
|
|
156
|
-
lineNumber,
|
|
212
|
+
const definition = createMacroDefinition(macroHeader, macroHeader.inlineBody, authoredFilePath, authoredLineNumber);
|
|
213
|
+
macroDefinitions.push({
|
|
214
|
+
offset: output.length,
|
|
215
|
+
definition,
|
|
157
216
|
});
|
|
158
217
|
state.macroSymbols.push({
|
|
159
218
|
name: macroHeader.name,
|
|
160
219
|
kind: "macro",
|
|
161
|
-
|
|
162
|
-
|
|
220
|
+
invocationStyle: macroHeader.invocationStyle,
|
|
221
|
+
sourceFile: nameOrigin?.file ?? authoredFilePath,
|
|
222
|
+
offset: nameOrigin?.offset ?? nameOffset,
|
|
163
223
|
params: macroHeader.params,
|
|
164
224
|
docLines,
|
|
165
225
|
});
|
|
166
226
|
}
|
|
167
227
|
break;
|
|
168
228
|
}
|
|
169
|
-
const bodyResult = readMacroBody(lineTexts, i + 1,
|
|
229
|
+
const bodyResult = readMacroBody(lineTexts, i + 1, authoredFilePath, authoredLineNumber);
|
|
170
230
|
i = bodyResult.endIndex;
|
|
171
231
|
if (isActive()) {
|
|
172
232
|
const strippedBody = stripLuaCommentsPreserveNewlines(bodyResult.body);
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
sourceFile: filePath,
|
|
178
|
-
lineNumber,
|
|
233
|
+
const definition = createMacroDefinition(macroHeader, strippedBody, authoredFilePath, authoredLineNumber);
|
|
234
|
+
macroDefinitions.push({
|
|
235
|
+
offset: output.length,
|
|
236
|
+
definition,
|
|
179
237
|
});
|
|
180
238
|
state.macroSymbols.push({
|
|
181
239
|
name: macroHeader.name,
|
|
182
240
|
kind: "macro",
|
|
183
|
-
|
|
184
|
-
|
|
241
|
+
invocationStyle: macroHeader.invocationStyle,
|
|
242
|
+
sourceFile: nameOrigin?.file ?? authoredFilePath,
|
|
243
|
+
offset: nameOrigin?.offset ?? nameOffset,
|
|
185
244
|
params: macroHeader.params,
|
|
186
245
|
docLines,
|
|
187
246
|
});
|
|
@@ -189,20 +248,24 @@ async function processSource(project, source, filePath, includeKey, state, input
|
|
|
189
248
|
break;
|
|
190
249
|
}
|
|
191
250
|
case "endmacro": {
|
|
192
|
-
throw new Error(formatError(
|
|
251
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, `--#endmacro without matching --#macro`));
|
|
193
252
|
}
|
|
194
253
|
case "minify": {
|
|
195
254
|
if (!isActive()) {
|
|
196
255
|
break;
|
|
197
256
|
}
|
|
198
257
|
const minifyOption = stripTrailingLineComment(rest).trim();
|
|
199
|
-
if (minifyOption !== "allow_rename") {
|
|
200
|
-
throw new Error(formatError(
|
|
258
|
+
if (minifyOption !== "allow_rename" && minifyOption !== "no_rename") {
|
|
259
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, `Unsupported --#minify option: ${minifyOption}`));
|
|
201
260
|
}
|
|
202
|
-
if (
|
|
203
|
-
throw new Error(formatError(
|
|
261
|
+
if (pendingMinifyRename) {
|
|
262
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, `--#minify ${pendingMinifyRename.option} cannot be repeated before a target declaration`));
|
|
204
263
|
}
|
|
205
|
-
|
|
264
|
+
pendingMinifyRename = {
|
|
265
|
+
option: minifyOption,
|
|
266
|
+
filePath: authoredFilePath,
|
|
267
|
+
lineNumber: authoredLineNumber,
|
|
268
|
+
};
|
|
206
269
|
break;
|
|
207
270
|
}
|
|
208
271
|
case "define": {
|
|
@@ -211,7 +274,7 @@ async function processSource(project, source, filePath, includeKey, state, input
|
|
|
211
274
|
}
|
|
212
275
|
const defineMatch = rest.match(/^([A-Za-z_][A-Za-z0-9_]*)(?:\s+(.*))?$/);
|
|
213
276
|
if (!defineMatch) {
|
|
214
|
-
throw new Error(formatError(
|
|
277
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, `Invalid --#define syntax: ${line}`));
|
|
215
278
|
}
|
|
216
279
|
const name = defineMatch[1];
|
|
217
280
|
const expr = defineMatch[2];
|
|
@@ -219,7 +282,7 @@ async function processSource(project, source, filePath, includeKey, state, input
|
|
|
219
282
|
localDefines.set(name, true);
|
|
220
283
|
}
|
|
221
284
|
else {
|
|
222
|
-
const value = evaluateExpression(parseExpression(expr,
|
|
285
|
+
const value = evaluateExpression(parseExpression(expr, authoredFilePath, authoredLineNumber), localDefines, authoredFilePath, authoredLineNumber);
|
|
223
286
|
localDefines.set(name, value);
|
|
224
287
|
}
|
|
225
288
|
break;
|
|
@@ -230,7 +293,7 @@ async function processSource(project, source, filePath, includeKey, state, input
|
|
|
230
293
|
}
|
|
231
294
|
const undefMatch = rest.match(/^([A-Za-z_][A-Za-z0-9_]*)$/);
|
|
232
295
|
if (!undefMatch) {
|
|
233
|
-
throw new Error(formatError(
|
|
296
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, `Invalid --#undef syntax: ${line}`));
|
|
234
297
|
}
|
|
235
298
|
localDefines.delete(undefMatch[1]);
|
|
236
299
|
break;
|
|
@@ -240,9 +303,9 @@ async function processSource(project, source, filePath, includeKey, state, input
|
|
|
240
303
|
let conditionMet = false;
|
|
241
304
|
if (parentActive) {
|
|
242
305
|
if (!rest || rest.trim() === "") {
|
|
243
|
-
throw new Error(formatError(
|
|
306
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, `Missing expression in --#if`));
|
|
244
307
|
}
|
|
245
|
-
const exprValue = evaluateExpression(parseExpression(rest,
|
|
308
|
+
const exprValue = evaluateExpression(parseExpression(rest, authoredFilePath, authoredLineNumber), localDefines, authoredFilePath, authoredLineNumber);
|
|
246
309
|
conditionMet = isTruthy(exprValue);
|
|
247
310
|
}
|
|
248
311
|
conditionalStack.push({
|
|
@@ -259,7 +322,7 @@ async function processSource(project, source, filePath, includeKey, state, input
|
|
|
259
322
|
if (parentActive) {
|
|
260
323
|
const ifdefMatch = rest.trim().match(/^([A-Za-z_][A-Za-z0-9_]*)$/);
|
|
261
324
|
if (!ifdefMatch) {
|
|
262
|
-
throw new Error(formatError(
|
|
325
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, `Invalid --#ifdef syntax: ${line}`));
|
|
263
326
|
}
|
|
264
327
|
conditionMet = localDefines.has(ifdefMatch[1]);
|
|
265
328
|
}
|
|
@@ -277,7 +340,7 @@ async function processSource(project, source, filePath, includeKey, state, input
|
|
|
277
340
|
if (parentActive) {
|
|
278
341
|
const ifndefMatch = rest.trim().match(/^([A-Za-z_][A-Za-z0-9_]*)$/);
|
|
279
342
|
if (!ifndefMatch) {
|
|
280
|
-
throw new Error(formatError(
|
|
343
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, `Invalid --#ifndef syntax: ${line}`));
|
|
281
344
|
}
|
|
282
345
|
conditionMet = !localDefines.has(ifndefMatch[1]);
|
|
283
346
|
}
|
|
@@ -291,11 +354,11 @@ async function processSource(project, source, filePath, includeKey, state, input
|
|
|
291
354
|
}
|
|
292
355
|
case "else": {
|
|
293
356
|
if (conditionalStack.length === 0) {
|
|
294
|
-
throw new Error(formatError(
|
|
357
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, `--#else without matching --#if`));
|
|
295
358
|
}
|
|
296
359
|
const top = conditionalStack[conditionalStack.length - 1];
|
|
297
360
|
if (top.hasElse) {
|
|
298
|
-
throw new Error(formatError(
|
|
361
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, `Duplicate --#else for same --#if`));
|
|
299
362
|
}
|
|
300
363
|
top.hasElse = true;
|
|
301
364
|
top.active = top.parentActive && !top.conditionMet;
|
|
@@ -303,7 +366,7 @@ async function processSource(project, source, filePath, includeKey, state, input
|
|
|
303
366
|
}
|
|
304
367
|
case "endif": {
|
|
305
368
|
if (conditionalStack.length === 0) {
|
|
306
|
-
throw new Error(formatError(
|
|
369
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, `--#endif without matching --#if`));
|
|
307
370
|
}
|
|
308
371
|
conditionalStack.pop();
|
|
309
372
|
break;
|
|
@@ -314,13 +377,13 @@ async function processSource(project, source, filePath, includeKey, state, input
|
|
|
314
377
|
}
|
|
315
378
|
const pragmaMatch = rest.trim().match(/^(\w+)$/);
|
|
316
379
|
if (!pragmaMatch) {
|
|
317
|
-
throw new Error(formatError(
|
|
380
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, `Invalid --#pragma syntax: ${line}`));
|
|
318
381
|
}
|
|
319
382
|
if (pragmaMatch[1] === "once") {
|
|
320
383
|
state.pragmaOnceKeys.add(includeKey);
|
|
321
384
|
}
|
|
322
385
|
else {
|
|
323
|
-
throw new Error(formatError(
|
|
386
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, `Unknown pragma: ${pragmaMatch[1]}`));
|
|
324
387
|
}
|
|
325
388
|
break;
|
|
326
389
|
}
|
|
@@ -328,20 +391,23 @@ async function processSource(project, source, filePath, includeKey, state, input
|
|
|
328
391
|
if (!isActive()) {
|
|
329
392
|
break;
|
|
330
393
|
}
|
|
394
|
+
state.diagnostics.includeDirectives++;
|
|
331
395
|
const includeMatch = rest.trim().match(/^"([^"]+)"(.*)$/);
|
|
332
396
|
if (!includeMatch) {
|
|
333
|
-
throw new Error(formatError(
|
|
397
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, `Invalid --#include syntax: ${line}`));
|
|
334
398
|
}
|
|
335
399
|
const includeTarget = includeMatch[1];
|
|
336
400
|
const remainder = includeMatch[2] || "";
|
|
337
|
-
const overrides = parseWithOverrides(remainder, localDefines,
|
|
338
|
-
const included = await resolveInclude(project, includeTarget,
|
|
401
|
+
const overrides = parseWithOverrides(remainder, localDefines, authoredFilePath, authoredLineNumber);
|
|
402
|
+
const included = await resolveInclude(project, includeTarget, authoredFilePath, overrides, state, authoredLineNumber);
|
|
403
|
+
let includedOffset = output.length;
|
|
339
404
|
if (included.code) {
|
|
340
405
|
if (output.length > 0) {
|
|
341
406
|
output += "\n";
|
|
342
|
-
const newlineOrigin = lastEmittedOrigin ?? { file:
|
|
343
|
-
builder.
|
|
407
|
+
const newlineOrigin = lastEmittedOrigin ?? { file: authoredFilePath, offset: authoredLineLocation?.offset ?? 0 };
|
|
408
|
+
builder.appendGenerated("\n", newlineOrigin);
|
|
344
409
|
}
|
|
410
|
+
includedOffset = output.length;
|
|
345
411
|
output += included.code;
|
|
346
412
|
builder.appendMap(included.map);
|
|
347
413
|
const endOrigin = included.map.mapOffset(included.code.length);
|
|
@@ -349,6 +415,12 @@ async function processSource(project, source, filePath, includeKey, state, input
|
|
|
349
415
|
lastEmittedOrigin = endOrigin;
|
|
350
416
|
}
|
|
351
417
|
}
|
|
418
|
+
for (const event of included.macroDefinitions) {
|
|
419
|
+
macroDefinitions.push({
|
|
420
|
+
offset: includedOffset + event.offset,
|
|
421
|
+
definition: event.definition,
|
|
422
|
+
});
|
|
423
|
+
}
|
|
352
424
|
break;
|
|
353
425
|
}
|
|
354
426
|
case "error": {
|
|
@@ -357,9 +429,9 @@ async function processSource(project, source, filePath, includeKey, state, input
|
|
|
357
429
|
}
|
|
358
430
|
const message = rest.trim();
|
|
359
431
|
if (!message) {
|
|
360
|
-
throw new Error(formatError(
|
|
432
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, `--#error encountered`));
|
|
361
433
|
}
|
|
362
|
-
throw new Error(formatError(
|
|
434
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, message));
|
|
363
435
|
}
|
|
364
436
|
case "warning": {
|
|
365
437
|
if (!isActive()) {
|
|
@@ -367,24 +439,24 @@ async function processSource(project, source, filePath, includeKey, state, input
|
|
|
367
439
|
}
|
|
368
440
|
const message = rest.trim();
|
|
369
441
|
if (!message) {
|
|
370
|
-
cons.warning(formatError(
|
|
442
|
+
cons.warning(formatError(authoredFilePath, authoredLineNumber, `--#warning encountered`));
|
|
371
443
|
break;
|
|
372
444
|
}
|
|
373
|
-
cons.warning(formatError(
|
|
445
|
+
cons.warning(formatError(authoredFilePath, authoredLineNumber, message));
|
|
374
446
|
break;
|
|
375
447
|
}
|
|
376
448
|
default:
|
|
377
|
-
throw new Error(formatError(
|
|
449
|
+
throw new Error(formatError(authoredFilePath, authoredLineNumber, `Unknown directive: --#${directive}`));
|
|
378
450
|
}
|
|
379
451
|
}
|
|
380
452
|
if (conditionalStack.length > 0) {
|
|
381
453
|
throw new Error(formatError(filePath, lines.length, `Unclosed --#if block`));
|
|
382
454
|
}
|
|
383
|
-
if (
|
|
384
|
-
throw new Error(formatError(
|
|
455
|
+
if (pendingMinifyRename) {
|
|
456
|
+
throw new Error(formatError(pendingMinifyRename.filePath, pendingMinifyRename.lineNumber, minifyTargetError(pendingMinifyRename.option)));
|
|
385
457
|
}
|
|
386
458
|
state.includeStack.pop();
|
|
387
|
-
return { code: output, map: builder };
|
|
459
|
+
return { code: output, map: builder, macroDefinitions };
|
|
388
460
|
}
|
|
389
461
|
function isIgnorableMinifyTargetLine(line) {
|
|
390
462
|
const trimmed = line.trim();
|
|
@@ -393,7 +465,10 @@ function isIgnorableMinifyTargetLine(line) {
|
|
|
393
465
|
function stripTrailingLineComment(text) {
|
|
394
466
|
return text.replace(/\s*--.*$/, "");
|
|
395
467
|
}
|
|
396
|
-
function
|
|
468
|
+
function minifyTargetError(option) {
|
|
469
|
+
return `--#minify ${option} must be followed by a simple global function or assignment`;
|
|
470
|
+
}
|
|
471
|
+
function parseMinifyRenameTarget(line) {
|
|
397
472
|
const functionMatch = line.match(/^\s*function\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/);
|
|
398
473
|
if (functionMatch) {
|
|
399
474
|
return functionMatch[1];
|
|
@@ -408,6 +483,7 @@ async function resolveInclude(project, includeTarget, fromFile, overrides, state
|
|
|
408
483
|
if (includeTarget.startsWith("import:")) {
|
|
409
484
|
return await resolveImportInclude(project, includeTarget, overrides, state, lineNumber);
|
|
410
485
|
}
|
|
486
|
+
state.diagnostics.fileIncludes++;
|
|
411
487
|
const substituted = project.substituteVariables(includeTarget);
|
|
412
488
|
let resolvedPath;
|
|
413
489
|
const localFound = (0, fileSystem_1.resolveFileWithSearchPaths)(substituted, path.dirname(fromFile));
|
|
@@ -419,77 +495,69 @@ async function resolveInclude(project, includeTarget, fromFile, overrides, state
|
|
|
419
495
|
resolvedPath = project.resolveIncludePath(substituted);
|
|
420
496
|
}
|
|
421
497
|
catch (error) {
|
|
422
|
-
const message =
|
|
498
|
+
const message = (0, errorHandling_1.getErrorMessage)(error);
|
|
423
499
|
throw new Error(formatError(fromFile, lineNumber, message));
|
|
424
500
|
}
|
|
425
501
|
}
|
|
426
502
|
const includeKey = makeIncludeKey(resolvedPath, overrides);
|
|
427
503
|
if (state.pragmaOnceKeys.has(includeKey)) {
|
|
428
|
-
|
|
504
|
+
state.diagnostics.pragmaOnceSkips++;
|
|
505
|
+
return { code: "", map: new sourceMap_1.SourceMapBuilder(), macroDefinitions: [] };
|
|
429
506
|
}
|
|
430
507
|
const source = await (0, fileSystem_1.readTextFileAsync)(resolvedPath);
|
|
431
|
-
const included = await processSource(project, source, resolvedPath, includeKey, state, overrides);
|
|
508
|
+
const included = await processSource(project, source, (0, sourceMap_1.createIdentitySourceMap)(source, resolvedPath), resolvedPath, includeKey, state, overrides);
|
|
432
509
|
return ensureTrailingNewline(included, resolvedPath);
|
|
433
510
|
}
|
|
434
511
|
async function resolveImportInclude(project, includeTarget, overrides, state, lineNumber) {
|
|
435
|
-
const ref = (0,
|
|
436
|
-
const importName = ref.
|
|
437
|
-
const chunkSpec = ref.chunkSpec;
|
|
512
|
+
const ref = (0, importReference_1.parseImportReference)(includeTarget);
|
|
513
|
+
const importName = ref.import;
|
|
438
514
|
const importDef = project.manifest.imports.find((imp) => imp.name === importName);
|
|
439
515
|
if (!importDef) {
|
|
440
516
|
throw new Error(formatError("<include>", lineNumber, `Import not found: ${importName}`));
|
|
441
517
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
518
|
+
const generatedLua = await state.resolveCodeImport?.(importName);
|
|
519
|
+
if (generatedLua) {
|
|
520
|
+
state.diagnostics.codeImportIncludes++;
|
|
521
|
+
if (ref.chunks !== undefined || ref.bank !== undefined) {
|
|
522
|
+
throw new Error(formatError(generatedLua.sourcePath, lineNumber, "generated code imports do not support chunk or bank selectors"));
|
|
523
|
+
}
|
|
524
|
+
for (const dependency of generatedLua.dependencies ?? []) {
|
|
525
|
+
state.dependencies.add(dependency.path);
|
|
526
|
+
}
|
|
527
|
+
const includeKey = makeIncludeKey(generatedLua.sourcePath, overrides);
|
|
445
528
|
if (state.pragmaOnceKeys.has(includeKey)) {
|
|
446
|
-
|
|
529
|
+
state.diagnostics.pragmaOnceSkips++;
|
|
530
|
+
return { code: "", map: new sourceMap_1.SourceMapBuilder(), macroDefinitions: [] };
|
|
447
531
|
}
|
|
448
|
-
const
|
|
449
|
-
|
|
450
|
-
return ensureTrailingNewline(included, resolvedPath);
|
|
532
|
+
const included = await processSource(project, generatedLua.source, generatedLua.sourceMap, generatedLua.sourcePath, includeKey, state, overrides, !(generatedLua.generatedOutputs ?? []).some((outputPath) => (0, fileSystem_1.isSameFileLocation)(outputPath, generatedLua.sourcePath)));
|
|
533
|
+
return ensureTrailingNewline(included, generatedLua.sourcePath);
|
|
451
534
|
}
|
|
452
535
|
if (importDef.kind === manifestTypes_1.kImportKind.key.Tic80Cartridge) {
|
|
453
|
-
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
const availableChunks = importDef.chunks && importDef.chunks.length > 0
|
|
458
|
-
? importDef.chunks
|
|
459
|
-
: Array.from(new Set(cart.chunks.map((chunk) => chunk.chunkType)));
|
|
460
|
-
const hasCode = availableChunks.includes("CODE") || availableChunks.includes("CODE_COMPRESSED");
|
|
461
|
-
if (!hasCode) {
|
|
462
|
-
throw new Error(formatError(resolvedPath, lineNumber, `No CODE or CODE_COMPRESSED chunk found in cart: ${importName}`));
|
|
463
|
-
}
|
|
464
|
-
let selectedChunk = availableChunks.includes("CODE") ? "CODE" : "CODE_COMPRESSED";
|
|
465
|
-
if (chunkSpec) {
|
|
466
|
-
if (chunkSpec !== "CODE" && chunkSpec !== "CODE_COMPRESSED") {
|
|
467
|
-
throw new Error(formatError(resolvedPath, lineNumber, `Only CODE or CODE_COMPRESSED chunk is supported for include`));
|
|
468
|
-
}
|
|
469
|
-
selectedChunk = chunkSpec;
|
|
470
|
-
if (!availableChunks.includes(selectedChunk)) {
|
|
471
|
-
throw new Error(formatError(resolvedPath, lineNumber, `Requested chunk ${selectedChunk} not available in import`));
|
|
472
|
-
}
|
|
536
|
+
state.diagnostics.cartridgeCodeIncludes++;
|
|
537
|
+
const importSource = await state.resolveImportSource(importName);
|
|
538
|
+
if (!importSource) {
|
|
539
|
+
throw new Error(formatError("<include>", lineNumber, `Import source not found: ${importName}`));
|
|
473
540
|
}
|
|
474
|
-
|
|
475
|
-
|
|
541
|
+
const resource = await (0, tic80CartImporter_1.importTic80Cart)(project, importDef, importSource);
|
|
542
|
+
for (const dependency of resource.getDependencyList()) {
|
|
543
|
+
state.dependencies.add(dependency.path);
|
|
476
544
|
}
|
|
477
|
-
|
|
478
|
-
let
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
545
|
+
let source;
|
|
546
|
+
let sourceName;
|
|
547
|
+
try {
|
|
548
|
+
const { chunkType, bank, data } = resource.selectSingleChunk(ref);
|
|
549
|
+
// if you really want to #include a non-CODE chunk, you need to explicitly specify the chunk
|
|
550
|
+
if (ref.chunks === undefined && chunkType !== "CODE" && chunkType !== "CODE_COMPRESSED") {
|
|
551
|
+
throw new Error("Specify a chunk type to include a data chunk as Lua source");
|
|
552
|
+
}
|
|
553
|
+
source = new TextDecoder("utf-8").decode(chunkType === "CODE_COMPRESSED" ? (0, cartLoader_1.decompressCodeBytes)(data) : data);
|
|
554
|
+
sourceName = `import:${importName}:${chunkType}:${bank}`;
|
|
485
555
|
}
|
|
486
|
-
|
|
487
|
-
throw new Error(formatError(
|
|
556
|
+
catch (error) {
|
|
557
|
+
throw new Error(formatError(resource.cartPath, lineNumber, (0, errorHandling_1.getErrorMessage)(error)));
|
|
488
558
|
}
|
|
489
|
-
const
|
|
490
|
-
|
|
491
|
-
const included = await processSource(project, source, `${includeTarget}:${selectedChunk}`, includeKey, state, overrides, false);
|
|
492
|
-
return ensureTrailingNewline(included, `${includeTarget}:${selectedChunk}`);
|
|
559
|
+
const included = await processSource(project, source, (0, sourceMap_1.createIdentitySourceMap)(source, sourceName), sourceName, makeIncludeKey(sourceName, overrides), state, overrides, false);
|
|
560
|
+
return ensureTrailingNewline(included, sourceName);
|
|
493
561
|
}
|
|
494
562
|
throw new Error(formatError("<include>", lineNumber, `Unsupported import kind: ${importDef.kind}`));
|
|
495
563
|
}
|
|
@@ -677,7 +745,7 @@ function ensureTrailingNewline(result, filePath) {
|
|
|
677
745
|
const map = new sourceMap_1.SourceMapBuilder();
|
|
678
746
|
map.appendMap(result.map);
|
|
679
747
|
map.appendGenerated("\n", origin);
|
|
680
|
-
return { code: result.code + "\n", map };
|
|
748
|
+
return { code: result.code + "\n", map, macroDefinitions: result.macroDefinitions };
|
|
681
749
|
}
|
|
682
750
|
function readLongBracketOpen(text, index) {
|
|
683
751
|
if (text[index] !== "[") {
|
|
@@ -818,6 +886,7 @@ function parseMacroHeader(rest, filePath, lineNumber) {
|
|
|
818
886
|
throw new Error(formatError(filePath, lineNumber, `Invalid --#macro syntax: ${rest}`));
|
|
819
887
|
}
|
|
820
888
|
const name = headerMatch[1];
|
|
889
|
+
const invocationStyle = headerMatch[2] === undefined ? "object" : "function";
|
|
821
890
|
const paramList = headerMatch[3];
|
|
822
891
|
const inlineBody = headerMatch[4];
|
|
823
892
|
const params = paramList
|
|
@@ -829,21 +898,75 @@ function parseMacroHeader(rest, filePath, lineNumber) {
|
|
|
829
898
|
const sanitizedInlineBody = inlineBody !== undefined ? stripLuaCommentsPreserveNewlines(inlineBody).trim() : undefined;
|
|
830
899
|
return {
|
|
831
900
|
name,
|
|
901
|
+
invocationStyle,
|
|
832
902
|
params,
|
|
833
903
|
inlineBody: sanitizedInlineBody,
|
|
834
904
|
};
|
|
835
905
|
}
|
|
906
|
+
function createMacroDefinition(header, body, sourceFile, lineNumber) {
|
|
907
|
+
const parsedBody = parseMacroBody(body, sourceFile, lineNumber);
|
|
908
|
+
if (header.invocationStyle === "object" && parsedBody.kind !== "expression") {
|
|
909
|
+
throw new Error(formatError(sourceFile, lineNumber, `Object-like macro ${header.name} must have exactly one Lua expression`));
|
|
910
|
+
}
|
|
911
|
+
return {
|
|
912
|
+
name: header.name,
|
|
913
|
+
invocationStyle: header.invocationStyle,
|
|
914
|
+
params: header.params,
|
|
915
|
+
body,
|
|
916
|
+
bodyKind: parsedBody.kind,
|
|
917
|
+
bodyAst: parsedBody.ast,
|
|
918
|
+
bodyRangeOffset: parsedBody.rangeOffset,
|
|
919
|
+
sourceFile,
|
|
920
|
+
lineNumber,
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
function parseMacroBody(body, filePath, lineNumber) {
|
|
924
|
+
if (body.trim().length === 0) {
|
|
925
|
+
return { kind: "empty", ast: null, rangeOffset: 0 };
|
|
926
|
+
}
|
|
927
|
+
const expressionPrefix = "return ";
|
|
928
|
+
try {
|
|
929
|
+
const expressionChunk = parseLuaChunkWithRanges(expressionPrefix + body);
|
|
930
|
+
if (expressionChunk.body.length === 1
|
|
931
|
+
&& expressionChunk.body[0].type === "ReturnStatement"
|
|
932
|
+
&& expressionChunk.body[0].arguments.length === 1) {
|
|
933
|
+
return {
|
|
934
|
+
kind: "expression",
|
|
935
|
+
ast: expressionChunk.body[0].arguments[0],
|
|
936
|
+
rangeOffset: expressionPrefix.length,
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
catch {
|
|
941
|
+
// A statement list is the other supported non-empty body form.
|
|
942
|
+
}
|
|
943
|
+
try {
|
|
944
|
+
return { kind: "statements", ast: parseLuaChunkWithRanges(body), rangeOffset: 0 };
|
|
945
|
+
}
|
|
946
|
+
catch (error) {
|
|
947
|
+
const message = (0, errorHandling_1.getErrorMessage)(error);
|
|
948
|
+
throw new Error(formatError(filePath, lineNumber, `Failed to parse macro body: ${message}`));
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
function parseLuaChunkWithRanges(code) {
|
|
952
|
+
return luaparse.parse(code, {
|
|
953
|
+
luaVersion: "5.3",
|
|
954
|
+
comments: true,
|
|
955
|
+
locations: true,
|
|
956
|
+
ranges: true,
|
|
957
|
+
});
|
|
958
|
+
}
|
|
836
959
|
function readMacroBody(lines, startIndex, filePath, lineNumber) {
|
|
837
960
|
const bodyLines = [];
|
|
838
961
|
for (let i = startIndex; i < lines.length; i++) {
|
|
839
962
|
const line = lines[i];
|
|
840
963
|
// check for --#endmacro
|
|
841
|
-
const match =
|
|
964
|
+
const match = (0, luaPreprocessorSyntax_1.parseLuaPreprocessorDirective)(line);
|
|
842
965
|
if (match) {
|
|
843
|
-
if (match
|
|
966
|
+
if (match.name === "endmacro") {
|
|
844
967
|
return { body: bodyLines.join("\n"), endIndex: i };
|
|
845
968
|
}
|
|
846
|
-
if (match
|
|
969
|
+
if (match.name === "macro") {
|
|
847
970
|
throw new Error(formatError(filePath, lineNumber, `Nested --#macro is not supported`));
|
|
848
971
|
}
|
|
849
972
|
}
|
|
@@ -851,66 +974,182 @@ function readMacroBody(lines, startIndex, filePath, lineNumber) {
|
|
|
851
974
|
}
|
|
852
975
|
throw new Error(formatError(filePath, lineNumber, `Unclosed --#macro block`));
|
|
853
976
|
}
|
|
854
|
-
function expandMacros(
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
977
|
+
function expandMacros(result, filePath, parentScope) {
|
|
978
|
+
return (0, traceProfiler_1.profileSync)(parentScope, "Expand Lua macros", {
|
|
979
|
+
category: "Lua preprocessing",
|
|
980
|
+
args: {
|
|
981
|
+
inputCharacters: result.code.length,
|
|
982
|
+
inputSourceMapSegments: result.map.getSegments().length,
|
|
983
|
+
macroDefinitions: result.macroDefinitions.length,
|
|
984
|
+
},
|
|
985
|
+
}, (scope) => {
|
|
986
|
+
if (result.macroDefinitions.length === 0) {
|
|
987
|
+
scope?.setArgs({ passesAttempted: 0, expansionPasses: 0, replacements: 0 });
|
|
988
|
+
return result;
|
|
864
989
|
}
|
|
865
|
-
current =
|
|
866
|
-
|
|
867
|
-
|
|
990
|
+
let current = result;
|
|
991
|
+
let passesAttempted = 0;
|
|
992
|
+
let expansionPasses = 0;
|
|
993
|
+
let replacementCount = 0;
|
|
994
|
+
const maxPasses = 25;
|
|
995
|
+
for (let pass = 0; pass < maxPasses; pass++) {
|
|
996
|
+
const passResult = (0, traceProfiler_1.profileSync)(scope, "Lua macro expansion pass", {
|
|
997
|
+
category: "Lua preprocessing",
|
|
998
|
+
args: {
|
|
999
|
+
pass: pass + 1,
|
|
1000
|
+
inputCharacters: current.code.length,
|
|
1001
|
+
inputSourceMapSegments: current.map.getSegments().length,
|
|
1002
|
+
},
|
|
1003
|
+
}, (passScope) => {
|
|
1004
|
+
const expanded = applyMacroPass(current, filePath, passScope);
|
|
1005
|
+
passScope?.setArgs({
|
|
1006
|
+
changed: expanded.changed,
|
|
1007
|
+
replacements: expanded.replacementCount,
|
|
1008
|
+
outputCharacters: expanded.code.length,
|
|
1009
|
+
outputSourceMapSegments: expanded.map.getSegments().length,
|
|
1010
|
+
});
|
|
1011
|
+
return expanded;
|
|
1012
|
+
});
|
|
1013
|
+
passesAttempted++;
|
|
1014
|
+
replacementCount += passResult.replacementCount;
|
|
1015
|
+
if (!passResult.changed) {
|
|
1016
|
+
scope?.setArgs({
|
|
1017
|
+
passesAttempted,
|
|
1018
|
+
expansionPasses,
|
|
1019
|
+
replacements: replacementCount,
|
|
1020
|
+
outputCharacters: current.code.length,
|
|
1021
|
+
outputSourceMapSegments: current.map.getSegments().length,
|
|
1022
|
+
});
|
|
1023
|
+
return current;
|
|
1024
|
+
}
|
|
1025
|
+
expansionPasses++;
|
|
1026
|
+
current = {
|
|
1027
|
+
code: passResult.code,
|
|
1028
|
+
map: passResult.map,
|
|
1029
|
+
macroDefinitions: passResult.macroDefinitions,
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
scope?.setArgs({
|
|
1033
|
+
passesAttempted,
|
|
1034
|
+
expansionPasses,
|
|
1035
|
+
replacements: replacementCount,
|
|
1036
|
+
outputCharacters: current.code.length,
|
|
1037
|
+
outputSourceMapSegments: current.map.getSegments().length,
|
|
1038
|
+
});
|
|
1039
|
+
throw new Error(formatError(filePath, 1, `Macro expansion exceeded ${maxPasses} passes (possible recursion)`));
|
|
1040
|
+
});
|
|
868
1041
|
}
|
|
869
|
-
function applyMacroPass(
|
|
870
|
-
const chunk = (0,
|
|
1042
|
+
function applyMacroPass(result, filePath, parentScope) {
|
|
1043
|
+
const chunk = (0, traceProfiler_1.profileSync)(parentScope, "Parse Lua for macro expansion", {
|
|
1044
|
+
category: "Lua preprocessing",
|
|
1045
|
+
args: { inputCharacters: result.code.length },
|
|
1046
|
+
}, () => parseLuaForMacroExpansion(result.code, filePath));
|
|
871
1047
|
const replacements = [];
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
1048
|
+
let identifierNodes = 0;
|
|
1049
|
+
let callExpressionNodes = 0;
|
|
1050
|
+
let definitionLookups = 0;
|
|
1051
|
+
const filtered = (0, traceProfiler_1.profileSync)(parentScope, "Find Lua macro expansions", {
|
|
1052
|
+
category: "Lua preprocessing",
|
|
1053
|
+
args: { macroDefinitions: result.macroDefinitions.length },
|
|
1054
|
+
}, (scope) => {
|
|
1055
|
+
walkLuaAst(chunk, (node, parent) => {
|
|
1056
|
+
if (node.type === "Identifier") {
|
|
1057
|
+
identifierNodes++;
|
|
1058
|
+
if (isIdentifierKeyPosition(node, parent)) {
|
|
1059
|
+
return;
|
|
1060
|
+
}
|
|
1061
|
+
const range = getRange(node, filePath);
|
|
1062
|
+
definitionLookups++;
|
|
1063
|
+
const macroDef = findMacroDefinitionAtOffset(result.macroDefinitions, node.name, range[0]);
|
|
1064
|
+
if (!macroDef || macroDef.invocationStyle !== "object") {
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
replacements.push({
|
|
1068
|
+
start: range[0],
|
|
1069
|
+
end: range[1],
|
|
1070
|
+
text: expandMacroBody(macroDef, []),
|
|
1071
|
+
});
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
1074
|
+
if (node.type !== "CallExpression") {
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
callExpressionNodes++;
|
|
1078
|
+
const callNode = node;
|
|
1079
|
+
if (callNode.base.type !== "Identifier") {
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
const range = getRange(callNode, filePath);
|
|
1083
|
+
definitionLookups++;
|
|
1084
|
+
const macroDef = findMacroDefinitionAtOffset(result.macroDefinitions, callNode.base.name, range[0]);
|
|
1085
|
+
if (!macroDef || macroDef.invocationStyle !== "function") {
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
const lineNumber = getLineNumber(callNode, 1);
|
|
1089
|
+
if (macroDef.bodyKind !== "expression" && parent?.type !== "CallStatement") {
|
|
1090
|
+
const bodyLabel = macroDef.bodyKind === "empty" ? "Empty" : "Statement-list";
|
|
1091
|
+
throw new Error(formatError(filePath, lineNumber, `${bodyLabel} macro ${macroDef.name} can only be used as a standalone call statement`));
|
|
1092
|
+
}
|
|
1093
|
+
const args = callNode.arguments || [];
|
|
1094
|
+
if (args.length !== macroDef.params.length) {
|
|
1095
|
+
throw new Error(formatError(filePath, lineNumber, `Macro ${macroDef.name} expects ${macroDef.params.length} args but got ${args.length}`));
|
|
1096
|
+
}
|
|
1097
|
+
const argTexts = args.map((arg) => stripLuaCommentsPreserveNewlines(sliceRange(result.code, getRange(arg, filePath))));
|
|
1098
|
+
const expanded = expandMacroBody(macroDef, argTexts);
|
|
1099
|
+
replacements.push({ start: range[0], end: range[1], text: expanded });
|
|
1100
|
+
});
|
|
1101
|
+
const sortedByStart = [...replacements].sort((a, b) => a.start - b.start || b.end - a.end);
|
|
1102
|
+
// filter out nested replacements; only keep outermost
|
|
1103
|
+
// this prevents overlapping edits
|
|
1104
|
+
const nonOverlapping = [];
|
|
1105
|
+
let currentOuter = null;
|
|
1106
|
+
for (const rep of sortedByStart) {
|
|
1107
|
+
if (currentOuter && rep.start >= currentOuter.start && rep.end <= currentOuter.end) {
|
|
1108
|
+
continue;
|
|
1109
|
+
}
|
|
1110
|
+
nonOverlapping.push(rep);
|
|
1111
|
+
currentOuter = rep;
|
|
889
1112
|
}
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
1113
|
+
scope?.setArgs({
|
|
1114
|
+
identifierNodes,
|
|
1115
|
+
callExpressionNodes,
|
|
1116
|
+
definitionLookups,
|
|
1117
|
+
replacementsFound: replacements.length,
|
|
1118
|
+
replacementsApplied: nonOverlapping.length,
|
|
1119
|
+
});
|
|
1120
|
+
return nonOverlapping;
|
|
893
1121
|
});
|
|
894
|
-
if (
|
|
895
|
-
return {
|
|
896
|
-
}
|
|
897
|
-
const sortedByStart = [...replacements].sort((a, b) => a.start - b.start || b.end - a.end);
|
|
898
|
-
// filter out nested replacements; only keep outermost
|
|
899
|
-
// this prevents overlapping edits
|
|
900
|
-
const filtered = [];
|
|
901
|
-
let currentOuter = null;
|
|
902
|
-
for (const rep of sortedByStart) {
|
|
903
|
-
if (currentOuter && rep.start >= currentOuter.start && rep.end <= currentOuter.end) {
|
|
904
|
-
continue;
|
|
905
|
-
}
|
|
906
|
-
filtered.push(rep);
|
|
907
|
-
currentOuter = rep;
|
|
1122
|
+
if (filtered.length === 0) {
|
|
1123
|
+
return { ...result, changed: false, replacementCount: 0 };
|
|
908
1124
|
}
|
|
909
1125
|
const sorted = filtered.sort((a, b) => b.start - a.start);
|
|
910
|
-
const updated = applyReplacementsWithMap(result, sorted, filePath);
|
|
911
|
-
return {
|
|
1126
|
+
const updated = applyReplacementsWithMap(result, sorted, filePath, parentScope);
|
|
1127
|
+
return { ...updated, changed: true, replacementCount: sorted.length };
|
|
1128
|
+
}
|
|
1129
|
+
function parseLuaForMacroExpansion(code, filePath) {
|
|
1130
|
+
try {
|
|
1131
|
+
return parseLuaChunkWithRanges(code);
|
|
1132
|
+
}
|
|
1133
|
+
catch (error) {
|
|
1134
|
+
const errorWithLine = error;
|
|
1135
|
+
const lineNumber = typeof errorWithLine.line === "number" ? errorWithLine.line : 1;
|
|
1136
|
+
const message = (0, errorHandling_1.getErrorMessage)(error);
|
|
1137
|
+
throw new Error(formatError(filePath, lineNumber, `Failed to parse Lua while expanding macros: ${message}`));
|
|
1138
|
+
}
|
|
912
1139
|
}
|
|
913
|
-
function
|
|
1140
|
+
function findMacroDefinitionAtOffset(events, name, invocationOffset) {
|
|
1141
|
+
let found;
|
|
1142
|
+
for (const event of events) {
|
|
1143
|
+
if (event.offset > invocationOffset) {
|
|
1144
|
+
break;
|
|
1145
|
+
}
|
|
1146
|
+
if (event.definition.name === name) {
|
|
1147
|
+
found = event.definition;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
return found;
|
|
1151
|
+
}
|
|
1152
|
+
function expandMacroBody(macro, argTexts) {
|
|
914
1153
|
const wrappedBody = wrapMacroBody(macro.body);
|
|
915
1154
|
if (wrappedBody.length === 0) {
|
|
916
1155
|
// empty macro bodies should be explicitly supported for things like ASSERT or NOP-like macros.
|
|
@@ -919,10 +1158,11 @@ function expandMacroBody(project, macro, argTexts, filePath, lineNumber) {
|
|
|
919
1158
|
if (macro.params.length === 0) {
|
|
920
1159
|
return wrappedBody;
|
|
921
1160
|
}
|
|
922
|
-
|
|
923
|
-
|
|
1161
|
+
if (!macro.bodyAst) {
|
|
1162
|
+
throw new Error(formatError(macro.sourceFile, macro.lineNumber, `Macro ${macro.name} has no parsed body`));
|
|
1163
|
+
}
|
|
924
1164
|
const replacements = [];
|
|
925
|
-
walkLuaAst(
|
|
1165
|
+
walkLuaAst(macro.bodyAst, (node, parent) => {
|
|
926
1166
|
if (node.type !== "Identifier") {
|
|
927
1167
|
return;
|
|
928
1168
|
}
|
|
@@ -935,8 +1175,8 @@ function expandMacroBody(project, macro, argTexts, filePath, lineNumber) {
|
|
|
935
1175
|
}
|
|
936
1176
|
const range = getRange(node, macro.sourceFile);
|
|
937
1177
|
replacements.push({
|
|
938
|
-
start: range[0] -
|
|
939
|
-
end: range[1] -
|
|
1178
|
+
start: range[0] - macro.bodyRangeOffset,
|
|
1179
|
+
end: range[1] - macro.bodyRangeOffset,
|
|
940
1180
|
// #14 we don't need overly aggressive parens, but here's where you'd put it if you wanted to (also see other #14 instances)
|
|
941
1181
|
text: `${argTexts[index]}`,
|
|
942
1182
|
});
|
|
@@ -959,10 +1199,26 @@ function wrapMacroBody(body) {
|
|
|
959
1199
|
// #14 we don't need overly aggressive parens, but here's where you'd put it if you wanted to (also see other #14 instances)
|
|
960
1200
|
return `${trimmed}`;
|
|
961
1201
|
}
|
|
962
|
-
async function expandPreprocessorCalls(project, result, filePath, state) {
|
|
963
|
-
|
|
1202
|
+
async function expandPreprocessorCalls(project, result, filePath, state, quietParseFailures, parentScope) {
|
|
1203
|
+
return (0, traceProfiler_1.profileAsync)(parentScope, "Expand Lua preprocessor calls", {
|
|
1204
|
+
category: "Lua preprocessing",
|
|
1205
|
+
args: {
|
|
1206
|
+
inputCharacters: result.code.length,
|
|
1207
|
+
inputSourceMapSegments: result.map.getSegments().length,
|
|
1208
|
+
},
|
|
1209
|
+
}, (scope) => expandPreprocessorCallsCore(project, result, filePath, state, quietParseFailures, scope));
|
|
1210
|
+
}
|
|
1211
|
+
async function expandPreprocessorCallsCore(project, result, filePath, state, quietParseFailures, parentScope) {
|
|
1212
|
+
const chunk = (0, traceProfiler_1.profileSync)(parentScope, "Parse Lua for preprocessor calls", {
|
|
1213
|
+
category: "Lua preprocessing",
|
|
1214
|
+
args: { inputCharacters: result.code.length },
|
|
1215
|
+
}, () => (quietParseFailures ? (0, lua_processor_1.parseLuaQuiet)(result.code) : (0, lua_processor_1.parseLua)(result.code)));
|
|
964
1216
|
const replacements = [];
|
|
965
1217
|
const tasks = [];
|
|
1218
|
+
let callExpressionNodes = 0;
|
|
1219
|
+
let expandCalls = 0;
|
|
1220
|
+
let importCalls = 0;
|
|
1221
|
+
let encodeCalls = 0;
|
|
966
1222
|
const addReplacement = (node, text) => {
|
|
967
1223
|
const range = getRange(node, filePath);
|
|
968
1224
|
replacements.push({ start: range[0], end: range[1], text });
|
|
@@ -1004,16 +1260,18 @@ async function expandPreprocessorCalls(project, result, filePath, state) {
|
|
|
1004
1260
|
}
|
|
1005
1261
|
return importDef;
|
|
1006
1262
|
};
|
|
1007
|
-
|
|
1263
|
+
const visitCall = (node) => {
|
|
1008
1264
|
if (node.type !== "CallExpression") {
|
|
1009
1265
|
return;
|
|
1010
1266
|
}
|
|
1267
|
+
callExpressionNodes++;
|
|
1011
1268
|
const callNode = node;
|
|
1012
1269
|
if (callNode.base.type !== "Identifier") {
|
|
1013
1270
|
return;
|
|
1014
1271
|
}
|
|
1015
1272
|
const fnName = callNode.base.name;
|
|
1016
1273
|
if (fnName === "__EXPAND") {
|
|
1274
|
+
expandCalls++;
|
|
1017
1275
|
tasks.push((async () => {
|
|
1018
1276
|
const lineNumber = getLineNumber(callNode, 1);
|
|
1019
1277
|
if (callNode.arguments.length !== 1) {
|
|
@@ -1027,6 +1285,7 @@ async function expandPreprocessorCalls(project, result, filePath, state) {
|
|
|
1027
1285
|
return;
|
|
1028
1286
|
}
|
|
1029
1287
|
if (fnName === "__IMPORT") {
|
|
1288
|
+
importCalls++;
|
|
1030
1289
|
tasks.push((async () => {
|
|
1031
1290
|
const lineNumber = getLineNumber(callNode, 1);
|
|
1032
1291
|
if (callNode.arguments.length !== 2) {
|
|
@@ -1038,12 +1297,16 @@ async function expandPreprocessorCalls(project, result, filePath, state) {
|
|
|
1038
1297
|
if (!importSpec.startsWith("import:")) {
|
|
1039
1298
|
throw new Error(formatError(filePath, lineNumber, `__IMPORT requires an import reference`));
|
|
1040
1299
|
}
|
|
1041
|
-
const ref = (0,
|
|
1042
|
-
const importDef = resolveImportDefinition(ref.
|
|
1300
|
+
const ref = (0, importReference_1.parseImportReference)(importSpec);
|
|
1301
|
+
const importDef = resolveImportDefinition(ref.import, lineNumber);
|
|
1043
1302
|
const pipelineSpec = project.substituteVariables(pipelineArg.value);
|
|
1044
1303
|
const split = (0, luaEncode_1.splitPipelineSpec)(pipelineSpec, true, filePath, lineNumber, formatError);
|
|
1045
1304
|
const resolvedSourceSpec = (0, luaEncode_1.normalizeEmptySpec)(project.substituteVariables(split.sourceSpecRaw || ""));
|
|
1046
|
-
const
|
|
1305
|
+
const importSource = await state.resolveImportSource(ref.import);
|
|
1306
|
+
if (!importSource) {
|
|
1307
|
+
throw new Error(formatError(filePath, lineNumber, `Import source not found: ${ref.import}`));
|
|
1308
|
+
}
|
|
1309
|
+
const bytes = await (0, luaEncode_1.resolveImportBytes)(project, importDef, importSource, resolvedSourceSpec, ref, (dep) => state.dependencies.add(dep), filePath, lineNumber, formatError);
|
|
1047
1310
|
const destSpec = project.substituteVariables(split.destSpecRaw);
|
|
1048
1311
|
const output = (0, luaEncode_1.encodeBytesWithDestSpec)(bytes, destSpec, filePath, lineNumber, formatError);
|
|
1049
1312
|
addReplacement(callNode, output);
|
|
@@ -1051,6 +1314,7 @@ async function expandPreprocessorCalls(project, result, filePath, state) {
|
|
|
1051
1314
|
return;
|
|
1052
1315
|
}
|
|
1053
1316
|
if (fnName === "__ENCODE") {
|
|
1317
|
+
encodeCalls++;
|
|
1054
1318
|
tasks.push((async () => {
|
|
1055
1319
|
const lineNumber = getLineNumber(callNode, 1);
|
|
1056
1320
|
if (callNode.arguments.length !== 2) {
|
|
@@ -1072,25 +1336,131 @@ async function expandPreprocessorCalls(project, result, filePath, state) {
|
|
|
1072
1336
|
addReplacement(callNode, output);
|
|
1073
1337
|
})());
|
|
1074
1338
|
}
|
|
1339
|
+
};
|
|
1340
|
+
(0, traceProfiler_1.profileSync)(parentScope, "Find Lua preprocessor calls", { category: "Lua preprocessing" }, (scope) => {
|
|
1341
|
+
walkLuaAst(chunk, visitCall);
|
|
1342
|
+
scope?.setArgs({
|
|
1343
|
+
callExpressionNodes,
|
|
1344
|
+
preprocessorCalls: expandCalls + importCalls + encodeCalls,
|
|
1345
|
+
expandCalls,
|
|
1346
|
+
importCalls,
|
|
1347
|
+
encodeCalls,
|
|
1348
|
+
});
|
|
1075
1349
|
});
|
|
1076
1350
|
if (tasks.length === 0) {
|
|
1351
|
+
parentScope?.setArgs({
|
|
1352
|
+
callExpressionNodes,
|
|
1353
|
+
preprocessorCalls: 0,
|
|
1354
|
+
expandCalls: 0,
|
|
1355
|
+
importCalls: 0,
|
|
1356
|
+
encodeCalls: 0,
|
|
1357
|
+
replacements: 0,
|
|
1358
|
+
outputCharacters: result.code.length,
|
|
1359
|
+
outputSourceMapSegments: result.map.getSegments().length,
|
|
1360
|
+
});
|
|
1077
1361
|
return result;
|
|
1078
1362
|
}
|
|
1079
|
-
await
|
|
1363
|
+
await (0, traceProfiler_1.profileAsync)(parentScope, "Complete Lua preprocessor calls", {
|
|
1364
|
+
category: "Lua preprocessing",
|
|
1365
|
+
args: { preprocessorCalls: tasks.length },
|
|
1366
|
+
}, async (scope) => {
|
|
1367
|
+
await Promise.all(tasks);
|
|
1368
|
+
scope?.setArgs({ replacements: replacements.length });
|
|
1369
|
+
});
|
|
1080
1370
|
if (replacements.length === 0) {
|
|
1371
|
+
parentScope?.setArgs({
|
|
1372
|
+
callExpressionNodes,
|
|
1373
|
+
preprocessorCalls: expandCalls + importCalls + encodeCalls,
|
|
1374
|
+
expandCalls,
|
|
1375
|
+
importCalls,
|
|
1376
|
+
encodeCalls,
|
|
1377
|
+
replacements: 0,
|
|
1378
|
+
outputCharacters: result.code.length,
|
|
1379
|
+
outputSourceMapSegments: result.map.getSegments().length,
|
|
1380
|
+
});
|
|
1081
1381
|
return result;
|
|
1082
1382
|
}
|
|
1083
1383
|
const sorted = replacements.sort((a, b) => b.start - a.start);
|
|
1084
|
-
|
|
1384
|
+
const updated = applyReplacementsWithMap(result, sorted, filePath, parentScope);
|
|
1385
|
+
parentScope?.setArgs({
|
|
1386
|
+
callExpressionNodes,
|
|
1387
|
+
preprocessorCalls: expandCalls + importCalls + encodeCalls,
|
|
1388
|
+
expandCalls,
|
|
1389
|
+
importCalls,
|
|
1390
|
+
encodeCalls,
|
|
1391
|
+
replacements: replacements.length,
|
|
1392
|
+
outputCharacters: updated.code.length,
|
|
1393
|
+
outputSourceMapSegments: updated.map.getSegments().length,
|
|
1394
|
+
});
|
|
1395
|
+
return updated;
|
|
1085
1396
|
}
|
|
1086
|
-
function applyReplacementsWithMap(result, replacements, filePath) {
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1397
|
+
function applyReplacementsWithMap(result, replacements, filePath, parentScope) {
|
|
1398
|
+
return (0, traceProfiler_1.profileSync)(parentScope, "Apply Lua replacements", {
|
|
1399
|
+
category: "Lua preprocessing",
|
|
1400
|
+
args: {
|
|
1401
|
+
replacements: replacements.length,
|
|
1402
|
+
inputCharacters: result.code.length,
|
|
1403
|
+
inputSourceMapSegments: result.map.getSegments().length,
|
|
1404
|
+
macroDefinitions: result.macroDefinitions.length,
|
|
1405
|
+
replacedCharacters: replacements.reduce((total, rep) => total + rep.end - rep.start, 0),
|
|
1406
|
+
insertedCharacters: replacements.reduce((total, rep) => total + rep.text.length, 0),
|
|
1407
|
+
},
|
|
1408
|
+
}, (scope) => {
|
|
1409
|
+
// original implementation was inefficient:
|
|
1410
|
+
// for each replacement,
|
|
1411
|
+
// {
|
|
1412
|
+
// perform the replacement via (slice begin + text + slice end)
|
|
1413
|
+
// update the source map via mapOffset and result.map.spliceRange()
|
|
1414
|
+
// -> spliceRange visits every segment to update offsets
|
|
1415
|
+
// so every segment is just getting pushed and pushed over and over again.
|
|
1416
|
+
// more efficient to build a map of all replacements, and apply in one sweep.
|
|
1417
|
+
// }
|
|
1418
|
+
const ascending = [...replacements].sort((a, b) => a.start - b.start || a.end - b.end);
|
|
1419
|
+
// build list of origins
|
|
1420
|
+
const mappedReplacements = ascending.map((replacement) => ({
|
|
1421
|
+
start: replacement.start,
|
|
1422
|
+
end: replacement.end,
|
|
1423
|
+
newLength: replacement.text.length,
|
|
1424
|
+
origin: result.map.mapOffset(replacement.start, "right") ?? { file: filePath, offset: 0 },
|
|
1425
|
+
}));
|
|
1426
|
+
// apply replacements in one go, building the output string in a stream of chunks
|
|
1427
|
+
const outputParts = [];
|
|
1428
|
+
let sourceCursor = 0;
|
|
1429
|
+
for (const replacement of ascending) {
|
|
1430
|
+
outputParts.push(result.code.slice(sourceCursor, replacement.start), replacement.text);
|
|
1431
|
+
sourceCursor = replacement.end;
|
|
1432
|
+
}
|
|
1433
|
+
outputParts.push(result.code.slice(sourceCursor));
|
|
1434
|
+
const out = outputParts.join("");
|
|
1435
|
+
// update the map also in one go using all the mapped replacements
|
|
1436
|
+
result.map.spliceRanges(mappedReplacements);
|
|
1437
|
+
// update macro definition offsets based on the replacements
|
|
1438
|
+
const descending = [...ascending].reverse();
|
|
1439
|
+
const macroDefinitions = result.macroDefinitions.map((event) => {
|
|
1440
|
+
let offset = event.offset;
|
|
1441
|
+
for (const replacement of descending) {
|
|
1442
|
+
offset = mapOffsetThroughReplacement(offset, replacement.start, replacement.end, replacement.text.length);
|
|
1443
|
+
}
|
|
1444
|
+
return {
|
|
1445
|
+
offset,
|
|
1446
|
+
definition: event.definition,
|
|
1447
|
+
};
|
|
1448
|
+
});
|
|
1449
|
+
scope?.setArgs({
|
|
1450
|
+
outputCharacters: out.length,
|
|
1451
|
+
outputSourceMapSegments: result.map.getSegments().length,
|
|
1452
|
+
});
|
|
1453
|
+
return { code: out, map: result.map, macroDefinitions };
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
function mapOffsetThroughReplacement(offset, start, end, replacementLength) {
|
|
1457
|
+
if (offset <= start) {
|
|
1458
|
+
return offset;
|
|
1459
|
+
}
|
|
1460
|
+
if (offset >= end) {
|
|
1461
|
+
return offset + replacementLength - (end - start);
|
|
1092
1462
|
}
|
|
1093
|
-
return
|
|
1463
|
+
return start + replacementLength;
|
|
1094
1464
|
}
|
|
1095
1465
|
function splitLinesWithOffsets(source) {
|
|
1096
1466
|
const lines = [];
|
|
@@ -1128,23 +1498,6 @@ function findMacroNameOffset(line, lineStartOffset, name) {
|
|
|
1128
1498
|
}
|
|
1129
1499
|
return lineStartOffset + index;
|
|
1130
1500
|
}
|
|
1131
|
-
function parseExpressionWithRanges(body, filePath, lineNumber) {
|
|
1132
|
-
try {
|
|
1133
|
-
const chunk = (0, lua_processor_1.parseLua)(`return ${body}`);
|
|
1134
|
-
if (chunk.body.length === 0 || chunk.body[0].type !== "ReturnStatement") {
|
|
1135
|
-
throw new Error("Invalid expression");
|
|
1136
|
-
}
|
|
1137
|
-
const returnStmt = chunk.body[0];
|
|
1138
|
-
if (returnStmt.arguments.length !== 1) {
|
|
1139
|
-
throw new Error("Expected single expression");
|
|
1140
|
-
}
|
|
1141
|
-
return returnStmt.arguments[0];
|
|
1142
|
-
}
|
|
1143
|
-
catch (error) {
|
|
1144
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1145
|
-
throw new Error(formatError(filePath, lineNumber, `Failed to parse macro body: ${message}`));
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
1501
|
function getRange(node, filePath) {
|
|
1149
1502
|
const withRange = node;
|
|
1150
1503
|
if (!withRange.range) {
|
|
@@ -1191,10 +1544,6 @@ function isIdentifierKeyPosition(node, parent) {
|
|
|
1191
1544
|
const tableKey = parent;
|
|
1192
1545
|
return tableKey.key === node;
|
|
1193
1546
|
}
|
|
1194
|
-
if (parent.type === "TableKey") {
|
|
1195
|
-
const tableKey = parent;
|
|
1196
|
-
return tableKey.key === node;
|
|
1197
|
-
}
|
|
1198
1547
|
if (parent.type === "MemberExpression") {
|
|
1199
1548
|
const member = parent;
|
|
1200
1549
|
return member.identifier === node;
|