@justscale/typescript 0.1.1
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/LICENSE +21 -0
- package/README.md +128 -0
- package/dist/api.d.ts +144 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +380 -0
- package/dist/api.js.map +1 -0
- package/dist/compiler/analyzer.d.ts +247 -0
- package/dist/compiler/analyzer.d.ts.map +1 -0
- package/dist/compiler/analyzer.js +3201 -0
- package/dist/compiler/analyzer.js.map +1 -0
- package/dist/compiler/cli.d.ts +12 -0
- package/dist/compiler/cli.d.ts.map +1 -0
- package/dist/compiler/cli.js +209 -0
- package/dist/compiler/cli.js.map +1 -0
- package/dist/compiler/compile.d.ts +26 -0
- package/dist/compiler/compile.d.ts.map +1 -0
- package/dist/compiler/compile.js +121 -0
- package/dist/compiler/compile.js.map +1 -0
- package/dist/compiler/errors.d.ts +336 -0
- package/dist/compiler/errors.d.ts.map +1 -0
- package/dist/compiler/errors.js +466 -0
- package/dist/compiler/errors.js.map +1 -0
- package/dist/compiler/exports-prepass.d.ts +31 -0
- package/dist/compiler/exports-prepass.d.ts.map +1 -0
- package/dist/compiler/exports-prepass.js +249 -0
- package/dist/compiler/exports-prepass.js.map +1 -0
- package/dist/compiler/hmr-change-detector.d.ts +47 -0
- package/dist/compiler/hmr-change-detector.d.ts.map +1 -0
- package/dist/compiler/hmr-change-detector.js +395 -0
- package/dist/compiler/hmr-change-detector.js.map +1 -0
- package/dist/compiler/hmr-transformer.d.ts +54 -0
- package/dist/compiler/hmr-transformer.d.ts.map +1 -0
- package/dist/compiler/hmr-transformer.js +535 -0
- package/dist/compiler/hmr-transformer.js.map +1 -0
- package/dist/compiler/index.d.ts +19 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +16 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/primitive-detector.d.ts +70 -0
- package/dist/compiler/primitive-detector.d.ts.map +1 -0
- package/dist/compiler/primitive-detector.js +338 -0
- package/dist/compiler/primitive-detector.js.map +1 -0
- package/dist/compiler/ptsc.d.ts +40 -0
- package/dist/compiler/ptsc.d.ts.map +1 -0
- package/dist/compiler/ptsc.js +462 -0
- package/dist/compiler/ptsc.js.map +1 -0
- package/dist/compiler/rewriter.d.ts +96 -0
- package/dist/compiler/rewriter.d.ts.map +1 -0
- package/dist/compiler/rewriter.js +418 -0
- package/dist/compiler/rewriter.js.map +1 -0
- package/dist/compiler/step-hash.d.ts +43 -0
- package/dist/compiler/step-hash.d.ts.map +1 -0
- package/dist/compiler/step-hash.js +83 -0
- package/dist/compiler/step-hash.js.map +1 -0
- package/dist/compiler/switch-codegen.d.ts +84 -0
- package/dist/compiler/switch-codegen.d.ts.map +1 -0
- package/dist/compiler/switch-codegen.js +1540 -0
- package/dist/compiler/switch-codegen.js.map +1 -0
- package/dist/compiler/transformer.d.ts +29 -0
- package/dist/compiler/transformer.d.ts.map +1 -0
- package/dist/compiler/transformer.js +216 -0
- package/dist/compiler/transformer.js.map +1 -0
- package/dist/config/index.d.ts +122 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +215 -0
- package/dist/config/index.js.map +1 -0
- package/dist/di-errors/formatter.d.ts +126 -0
- package/dist/di-errors/formatter.d.ts.map +1 -0
- package/dist/di-errors/formatter.js +384 -0
- package/dist/di-errors/formatter.js.map +1 -0
- package/dist/di-errors/index.d.ts +5 -0
- package/dist/di-errors/index.d.ts.map +1 -0
- package/dist/di-errors/index.js +13 -0
- package/dist/di-errors/index.js.map +1 -0
- package/dist/editor.d.ts +11 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +2 -0
- package/dist/editor.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/language-service/index.d.ts +52 -0
- package/dist/language-service/index.d.ts.map +1 -0
- package/dist/language-service/index.js +366 -0
- package/dist/language-service/index.js.map +1 -0
- package/dist/language-service/process-quick-fixes.d.ts +20 -0
- package/dist/language-service/process-quick-fixes.d.ts.map +1 -0
- package/dist/language-service/process-quick-fixes.js +114 -0
- package/dist/language-service/process-quick-fixes.js.map +1 -0
- package/dist/language-service/quick-fix-discovery.d.ts +39 -0
- package/dist/language-service/quick-fix-discovery.d.ts.map +1 -0
- package/dist/language-service/quick-fix-discovery.js +124 -0
- package/dist/language-service/quick-fix-discovery.js.map +1 -0
- package/dist/loader/incremental.d.ts +50 -0
- package/dist/loader/incremental.d.ts.map +1 -0
- package/dist/loader/incremental.js +151 -0
- package/dist/loader/incremental.js.map +1 -0
- package/dist/loader/index.d.ts +25 -0
- package/dist/loader/index.d.ts.map +1 -0
- package/dist/loader/index.js +24 -0
- package/dist/loader/index.js.map +1 -0
- package/dist/loader/loader.d.ts +52 -0
- package/dist/loader/loader.d.ts.map +1 -0
- package/dist/loader/loader.js +248 -0
- package/dist/loader/loader.js.map +1 -0
- package/dist/loader/register.d.ts +14 -0
- package/dist/loader/register.d.ts.map +1 -0
- package/dist/loader/register.js +20 -0
- package/dist/loader/register.js.map +1 -0
- package/dist/plugins/index.d.ts +13 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +13 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/index.public.d.ts +13 -0
- package/dist/plugins/index.public.d.ts.map +1 -0
- package/dist/plugins/index.public.js +13 -0
- package/dist/plugins/index.public.js.map +1 -0
- package/dist/plugins/types.d.ts +83 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +24 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/server/index.d.ts +33 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +42 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/tsserver.d.ts +28 -0
- package/dist/server/tsserver.d.ts.map +1 -0
- package/dist/server/tsserver.js +126 -0
- package/dist/server/tsserver.js.map +1 -0
- package/lib/lib.d.ts +20 -0
- package/lib/lib.decorators.d.ts +382 -0
- package/lib/lib.decorators.legacy.d.ts +20 -0
- package/lib/lib.dom.asynciterable.d.ts +18 -0
- package/lib/lib.dom.d.ts +45125 -0
- package/lib/lib.dom.iterable.d.ts +18 -0
- package/lib/lib.es2015.collection.d.ts +150 -0
- package/lib/lib.es2015.core.d.ts +595 -0
- package/lib/lib.es2015.d.ts +26 -0
- package/lib/lib.es2015.generator.d.ts +75 -0
- package/lib/lib.es2015.iterable.d.ts +603 -0
- package/lib/lib.es2015.promise.d.ts +79 -0
- package/lib/lib.es2015.proxy.d.ts +126 -0
- package/lib/lib.es2015.reflect.d.ts +142 -0
- package/lib/lib.es2015.symbol.d.ts +44 -0
- package/lib/lib.es2015.symbol.wellknown.d.ts +324 -0
- package/lib/lib.es2016.array.include.d.ts +114 -0
- package/lib/lib.es2016.d.ts +19 -0
- package/lib/lib.es2016.full.d.ts +21 -0
- package/lib/lib.es2016.intl.d.ts +29 -0
- package/lib/lib.es2017.arraybuffer.d.ts +19 -0
- package/lib/lib.es2017.d.ts +24 -0
- package/lib/lib.es2017.date.d.ts +29 -0
- package/lib/lib.es2017.full.d.ts +21 -0
- package/lib/lib.es2017.intl.d.ts +42 -0
- package/lib/lib.es2017.object.d.ts +47 -0
- package/lib/lib.es2017.sharedmemory.d.ts +133 -0
- package/lib/lib.es2017.string.d.ts +43 -0
- package/lib/lib.es2017.typedarrays.d.ts +51 -0
- package/lib/lib.es2018.asyncgenerator.d.ts +75 -0
- package/lib/lib.es2018.asynciterable.d.ts +51 -0
- package/lib/lib.es2018.d.ts +22 -0
- package/lib/lib.es2018.full.d.ts +22 -0
- package/lib/lib.es2018.intl.d.ts +81 -0
- package/lib/lib.es2018.promise.d.ts +28 -0
- package/lib/lib.es2018.regexp.d.ts +35 -0
- package/lib/lib.es2019.array.d.ts +77 -0
- package/lib/lib.es2019.d.ts +22 -0
- package/lib/lib.es2019.full.d.ts +22 -0
- package/lib/lib.es2019.intl.d.ts +21 -0
- package/lib/lib.es2019.object.d.ts +31 -0
- package/lib/lib.es2019.string.d.ts +35 -0
- package/lib/lib.es2019.symbol.d.ts +22 -0
- package/lib/lib.es2020.bigint.d.ts +763 -0
- package/lib/lib.es2020.d.ts +25 -0
- package/lib/lib.es2020.date.d.ts +40 -0
- package/lib/lib.es2020.full.d.ts +22 -0
- package/lib/lib.es2020.intl.d.ts +472 -0
- package/lib/lib.es2020.number.d.ts +26 -0
- package/lib/lib.es2020.promise.d.ts +45 -0
- package/lib/lib.es2020.sharedmemory.d.ts +97 -0
- package/lib/lib.es2020.string.d.ts +42 -0
- package/lib/lib.es2020.symbol.wellknown.d.ts +39 -0
- package/lib/lib.es2021.d.ts +21 -0
- package/lib/lib.es2021.full.d.ts +22 -0
- package/lib/lib.es2021.intl.d.ts +164 -0
- package/lib/lib.es2021.promise.d.ts +46 -0
- package/lib/lib.es2021.string.d.ts +31 -0
- package/lib/lib.es2021.weakref.d.ts +76 -0
- package/lib/lib.es2022.array.d.ts +119 -0
- package/lib/lib.es2022.d.ts +23 -0
- package/lib/lib.es2022.error.d.ts +73 -0
- package/lib/lib.es2022.full.d.ts +22 -0
- package/lib/lib.es2022.intl.d.ts +143 -0
- package/lib/lib.es2022.object.d.ts +24 -0
- package/lib/lib.es2022.regexp.d.ts +37 -0
- package/lib/lib.es2022.string.d.ts +23 -0
- package/lib/lib.es2023.array.d.ts +922 -0
- package/lib/lib.es2023.collection.d.ts +19 -0
- package/lib/lib.es2023.d.ts +20 -0
- package/lib/lib.es2023.full.d.ts +22 -0
- package/lib/lib.es2023.intl.d.ts +62 -0
- package/lib/lib.es2024.arraybuffer.d.ts +63 -0
- package/lib/lib.es2024.collection.d.ts +27 -0
- package/lib/lib.es2024.d.ts +24 -0
- package/lib/lib.es2024.full.d.ts +22 -0
- package/lib/lib.es2024.object.d.ts +27 -0
- package/lib/lib.es2024.promise.d.ts +33 -0
- package/lib/lib.es2024.regexp.d.ts +23 -0
- package/lib/lib.es2024.sharedmemory.d.ts +66 -0
- package/lib/lib.es2024.string.d.ts +27 -0
- package/lib/lib.es2025.collection.d.ts +94 -0
- package/lib/lib.es2025.d.ts +23 -0
- package/lib/lib.es2025.float16.d.ts +443 -0
- package/lib/lib.es2025.full.d.ts +22 -0
- package/lib/lib.es2025.intl.d.ts +200 -0
- package/lib/lib.es2025.iterator.d.ts +146 -0
- package/lib/lib.es2025.promise.d.ts +32 -0
- package/lib/lib.es2025.regexp.d.ts +30 -0
- package/lib/lib.es5.d.ts +4599 -0
- package/lib/lib.es6.d.ts +21 -0
- package/lib/lib.esnext.array.d.ts +33 -0
- package/lib/lib.esnext.collection.d.ts +47 -0
- package/lib/lib.esnext.d.ts +27 -0
- package/lib/lib.esnext.date.d.ts +21 -0
- package/lib/lib.esnext.decorators.d.ts +26 -0
- package/lib/lib.esnext.disposable.d.ts +191 -0
- package/lib/lib.esnext.error.d.ts +22 -0
- package/lib/lib.esnext.full.d.ts +22 -0
- package/lib/lib.esnext.intl.d.ts +107 -0
- package/lib/lib.esnext.sharedmemory.d.ts +23 -0
- package/lib/lib.esnext.temporal.d.ts +485 -0
- package/lib/lib.esnext.typedarrays.d.ts +90 -0
- package/lib/lib.scripthost.d.ts +320 -0
- package/lib/lib.webworker.asynciterable.d.ts +18 -0
- package/lib/lib.webworker.d.ts +15606 -0
- package/lib/lib.webworker.importscripts.d.ts +21 -0
- package/lib/lib.webworker.iterable.d.ts +18 -0
- package/lib/logger.js +144 -0
- package/lib/package.json +7 -0
- package/lib/tsserver.js +57 -0
- package/lib/tsserverlibrary.js +171 -0
- package/lib/typesMap.json +497 -0
- package/lib/typescript.js +373 -0
- package/package.json +115 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* ptsc - Process TypeScript Compiler
|
|
4
|
+
*
|
|
5
|
+
* Drop-in replacement for tsc that compiles JustScale durable processes.
|
|
6
|
+
* Supports all tsc command-line options and behaviors.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Full tsc CLI compatibility (all options work identically)
|
|
10
|
+
* - Process diagnostics (TSPxxxx error codes)
|
|
11
|
+
* - Transforms createProcess() calls into opcode-based execution
|
|
12
|
+
* - Supports project references with -b mode
|
|
13
|
+
* - Watch mode support
|
|
14
|
+
* - Custom justscale section in tsconfig.json
|
|
15
|
+
*
|
|
16
|
+
* Usage (exactly like tsc):
|
|
17
|
+
* ptsc # Compile using nearest tsconfig.json
|
|
18
|
+
* ptsc --noEmit # Type check only
|
|
19
|
+
* ptsc -p tsconfig.json # Use specific config
|
|
20
|
+
* ptsc -b tsconfig.build.json # Build mode with project references
|
|
21
|
+
* ptsc --watch # Watch mode
|
|
22
|
+
* ptsc --init # Initialize a new tsconfig.json
|
|
23
|
+
* ptsc --help # Show help
|
|
24
|
+
* ptsc --version # Show version
|
|
25
|
+
* ptsc file.ts # Compile a single file
|
|
26
|
+
*
|
|
27
|
+
* JustScale-specific options (via tsconfig.json):
|
|
28
|
+
* ```json
|
|
29
|
+
* {
|
|
30
|
+
* "compilerOptions": { ... },
|
|
31
|
+
* "justscale": {
|
|
32
|
+
* "processFilePattern": "*.process.ts",
|
|
33
|
+
* "strict": true,
|
|
34
|
+
* "verbose": false
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
import ts from 'typescript';
|
|
40
|
+
import { resolve, dirname, basename, join, relative, sep } from 'node:path';
|
|
41
|
+
import { writeFileSync, existsSync } from 'node:fs';
|
|
42
|
+
import { analyzeHandler } from './analyzer.js';
|
|
43
|
+
import { filterUsingExportsDiagnostics } from './errors.js';
|
|
44
|
+
import { createProcessTransformer } from './transformer.js';
|
|
45
|
+
import { extractAndInjectExportsTypes, createModifiedHost } from './exports-prepass.js';
|
|
46
|
+
import { parseConfig, defaultConfig } from '../config/index.js';
|
|
47
|
+
import '../plugins/index.js';
|
|
48
|
+
import { getPlugins } from '../plugins/types.js';
|
|
49
|
+
// Version from package.json
|
|
50
|
+
const VERSION = '0.1.0';
|
|
51
|
+
// Parse command line arguments
|
|
52
|
+
const args = process.argv.slice(2);
|
|
53
|
+
// Handle --version
|
|
54
|
+
if (args.includes('--version') || args.includes('-v')) {
|
|
55
|
+
console.log(`ptsc Version ${VERSION}`);
|
|
56
|
+
console.log(`TypeScript ${ts.version}`);
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
// Handle --help
|
|
60
|
+
if (args.includes('--help') || args.includes('-h') || args.includes('-?')) {
|
|
61
|
+
printHelp();
|
|
62
|
+
process.exit(0);
|
|
63
|
+
}
|
|
64
|
+
// Handle --init
|
|
65
|
+
if (args.includes('--init')) {
|
|
66
|
+
initConfig();
|
|
67
|
+
process.exit(0);
|
|
68
|
+
}
|
|
69
|
+
// Normalize -b/--build to --project - same compile pipeline, just a different flag name.
|
|
70
|
+
// tsc treats -b specially (incremental, project references) but our pipeline handles
|
|
71
|
+
// all of that through the standard path with proto/process transforms.
|
|
72
|
+
const buildModeIndex = args.findIndex((arg) => arg === '-b' || arg === '--build');
|
|
73
|
+
if (buildModeIndex !== -1) {
|
|
74
|
+
args[buildModeIndex] = '--project';
|
|
75
|
+
}
|
|
76
|
+
// Parse command line using TypeScript's parser
|
|
77
|
+
const parsedCommandLine = ts.parseCommandLine(args);
|
|
78
|
+
if (parsedCommandLine.errors.length > 0) {
|
|
79
|
+
console.error(ts.formatDiagnosticsWithColorAndContext(parsedCommandLine.errors, formatHost()));
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
// Find tsconfig
|
|
83
|
+
let configPath;
|
|
84
|
+
if (parsedCommandLine.options.project) {
|
|
85
|
+
configPath = resolve(parsedCommandLine.options.project);
|
|
86
|
+
}
|
|
87
|
+
else if (parsedCommandLine.fileNames.length === 0) {
|
|
88
|
+
// No files specified, look for tsconfig
|
|
89
|
+
configPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists, 'tsconfig.json');
|
|
90
|
+
}
|
|
91
|
+
// If we have a config, parse it
|
|
92
|
+
let parsedConfig;
|
|
93
|
+
let justscaleConfig = { ...defaultConfig };
|
|
94
|
+
if (configPath) {
|
|
95
|
+
if (!existsSync(configPath)) {
|
|
96
|
+
console.error(`error TS6053: File '${configPath}' not found.`);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
parsedConfig = parseConfig(configPath, parsedCommandLine.options);
|
|
100
|
+
if (parsedConfig.errors.length > 0) {
|
|
101
|
+
console.error(ts.formatDiagnosticsWithColorAndContext(parsedConfig.errors, formatHost()));
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
justscaleConfig = parsedConfig.justscale;
|
|
105
|
+
}
|
|
106
|
+
else if (parsedCommandLine.fileNames.length > 0) {
|
|
107
|
+
// Compile specific files without tsconfig
|
|
108
|
+
parsedConfig = {
|
|
109
|
+
compilerOptions: {
|
|
110
|
+
...parsedCommandLine.options,
|
|
111
|
+
// Default options for standalone compilation
|
|
112
|
+
target: parsedCommandLine.options.target ?? ts.ScriptTarget.ES2022,
|
|
113
|
+
module: parsedCommandLine.options.module ?? ts.ModuleKind.NodeNext,
|
|
114
|
+
moduleResolution: parsedCommandLine.options.moduleResolution ?? ts.ModuleResolutionKind.NodeNext,
|
|
115
|
+
},
|
|
116
|
+
fileNames: parsedCommandLine.fileNames,
|
|
117
|
+
justscale: defaultConfig,
|
|
118
|
+
configFilePath: '',
|
|
119
|
+
errors: [],
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
console.error('error: Cannot find tsconfig.json');
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
if (parsedConfig.compilerOptions.watch) {
|
|
127
|
+
runWatchMode(configPath, parsedConfig);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const exitCode = runBuild(parsedConfig, justscaleConfig);
|
|
131
|
+
process.exit(exitCode);
|
|
132
|
+
}
|
|
133
|
+
function runBuild(config, jsConfig) {
|
|
134
|
+
const verbose = jsConfig.verbose;
|
|
135
|
+
if (verbose) {
|
|
136
|
+
console.log(`Compiling ${config.fileNames.length} file(s)...`);
|
|
137
|
+
}
|
|
138
|
+
const baseDir = config.configFilePath ? dirname(config.configFilePath) : process.cwd();
|
|
139
|
+
const plugins = getPlugins();
|
|
140
|
+
// Create one resolver per plugin
|
|
141
|
+
const pluginResolvers = plugins.map(plugin => plugin.createResolver({
|
|
142
|
+
baseDir,
|
|
143
|
+
sourceMapMode: 'external',
|
|
144
|
+
}));
|
|
145
|
+
// Chain compiler hosts: each plugin wraps the previous host
|
|
146
|
+
const combinedHost = plugins.reduce((prevHost, plugin, i) => plugin.createAwareCompilerHost(config.compilerOptions, pluginResolvers[i], prevHost), undefined) ?? ts.createCompilerHost(config.compilerOptions);
|
|
147
|
+
const program1 = ts.createProgram({
|
|
148
|
+
rootNames: config.fileNames,
|
|
149
|
+
options: config.compilerOptions,
|
|
150
|
+
projectReferences: config.projectReferences,
|
|
151
|
+
host: combinedHost,
|
|
152
|
+
});
|
|
153
|
+
// Two-pass: extract `using exports` types, inject __exportsType, re-create program.
|
|
154
|
+
// TypeScript infers TExports correctly from the phantom property; oldProgram reuses unchanged files.
|
|
155
|
+
const modifiedSources = extractAndInjectExportsTypes(program1);
|
|
156
|
+
let program;
|
|
157
|
+
if (modifiedSources.size > 0) {
|
|
158
|
+
const host2 = createModifiedHost(combinedHost, modifiedSources);
|
|
159
|
+
program = ts.createProgram({
|
|
160
|
+
rootNames: config.fileNames,
|
|
161
|
+
options: config.compilerOptions,
|
|
162
|
+
projectReferences: config.projectReferences,
|
|
163
|
+
host: host2,
|
|
164
|
+
oldProgram: program1,
|
|
165
|
+
});
|
|
166
|
+
if (verbose) {
|
|
167
|
+
console.log(`[ptsc] Re-parsed ${modifiedSources.size} file(s) with injected export types`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
program = program1;
|
|
172
|
+
}
|
|
173
|
+
const pluginDiagnostics = plugins.map(() => []);
|
|
174
|
+
const diagnostics = filterUsingExportsDiagnostics([
|
|
175
|
+
...program.getConfigFileParsingDiagnostics(),
|
|
176
|
+
...program.getSyntacticDiagnostics(),
|
|
177
|
+
...program.getOptionsDiagnostics(),
|
|
178
|
+
...program.getGlobalDiagnostics(),
|
|
179
|
+
...program.getSemanticDiagnostics(),
|
|
180
|
+
]);
|
|
181
|
+
const processDiagnostics = getProcessDiagnostics(program, jsConfig);
|
|
182
|
+
const allDiagnostics = [...diagnostics, ...processDiagnostics];
|
|
183
|
+
if (allDiagnostics.length > 0) {
|
|
184
|
+
console.log(ts.formatDiagnosticsWithColorAndContext(allDiagnostics, formatHost()));
|
|
185
|
+
}
|
|
186
|
+
if (!config.compilerOptions.noEmit) {
|
|
187
|
+
// Clear emitted-file maps before fresh emit
|
|
188
|
+
plugins.forEach((plugin, i) => plugin.clearEmittedFiles(pluginResolvers[i]));
|
|
189
|
+
const pluginTransformers = plugins.map((plugin, i) => plugin.createTransformer(program, pluginResolvers[i], pluginDiagnostics[i]));
|
|
190
|
+
const emitResult = program.emit(undefined, // targetSourceFile - emit all files
|
|
191
|
+
undefined, // writeFile - use default
|
|
192
|
+
undefined, // cancellationToken
|
|
193
|
+
undefined, // emitOnlyDtsFiles
|
|
194
|
+
{
|
|
195
|
+
before: [
|
|
196
|
+
createProcessTransformer(program, { verbose: verbose ?? false }),
|
|
197
|
+
...pluginTransformers,
|
|
198
|
+
],
|
|
199
|
+
});
|
|
200
|
+
allDiagnostics.push(...emitResult.diagnostics);
|
|
201
|
+
pluginDiagnostics.forEach(diags => allDiagnostics.push(...diags));
|
|
202
|
+
const outDir = config.compilerOptions.outDir;
|
|
203
|
+
const rootDir = config.compilerOptions.rootDir;
|
|
204
|
+
// Helper to ensure directory exists
|
|
205
|
+
const mkdirp = (p) => {
|
|
206
|
+
const parent = dirname(p);
|
|
207
|
+
if (!existsSync(parent))
|
|
208
|
+
mkdirp(parent);
|
|
209
|
+
if (!existsSync(p))
|
|
210
|
+
ts.sys.createDirectory(p);
|
|
211
|
+
};
|
|
212
|
+
for (let i = 0; i < plugins.length; i++) {
|
|
213
|
+
const emittedFiles = plugins[i].getEmittedFiles(pluginResolvers[i]);
|
|
214
|
+
for (const [filePath, content] of emittedFiles) {
|
|
215
|
+
let outputPath = filePath;
|
|
216
|
+
if (outDir) {
|
|
217
|
+
if (rootDir) {
|
|
218
|
+
const relativePath = relative(rootDir, filePath);
|
|
219
|
+
outputPath = join(outDir, relativePath);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
outputPath = join(outDir, basename(filePath));
|
|
223
|
+
}
|
|
224
|
+
const canonicalOutDir = resolve(outDir);
|
|
225
|
+
const canonicalOutPath = resolve(outputPath);
|
|
226
|
+
if (canonicalOutPath !== canonicalOutDir && !canonicalOutPath.startsWith(canonicalOutDir + sep)) {
|
|
227
|
+
throw new Error(`Refusing to emit ${filePath}: resolved output ${canonicalOutPath} escapes outDir ${canonicalOutDir}`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const dir = dirname(outputPath);
|
|
231
|
+
if (!existsSync(dir))
|
|
232
|
+
mkdirp(dir);
|
|
233
|
+
ts.sys.writeFile(outputPath, content);
|
|
234
|
+
if (verbose) {
|
|
235
|
+
console.log(` Emitted: ${outputPath}`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
const pluginTransformers = plugins.map((plugin, i) => plugin.createTransformer(program, pluginResolvers[i], pluginDiagnostics[i]));
|
|
242
|
+
for (const sourceFile of program.getSourceFiles()) {
|
|
243
|
+
if (!sourceFile.isDeclarationFile) {
|
|
244
|
+
ts.transform(sourceFile, pluginTransformers);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
pluginDiagnostics.forEach(diags => allDiagnostics.push(...diags));
|
|
248
|
+
}
|
|
249
|
+
const schemaDiagnostics = pluginDiagnostics.flat();
|
|
250
|
+
if (schemaDiagnostics.length > 0) {
|
|
251
|
+
console.log(ts.formatDiagnosticsWithColorAndContext(schemaDiagnostics, formatHost()));
|
|
252
|
+
}
|
|
253
|
+
const errorCount = allDiagnostics.filter((d) => d.category === ts.DiagnosticCategory.Error).length;
|
|
254
|
+
if (errorCount > 0) {
|
|
255
|
+
console.log('');
|
|
256
|
+
console.log(`Found ${errorCount} error${errorCount > 1 ? 's' : ''}.`);
|
|
257
|
+
}
|
|
258
|
+
return errorCount > 0 ? 1 : 0;
|
|
259
|
+
}
|
|
260
|
+
function runWatchMode(configPath, config) {
|
|
261
|
+
const jsConfig = config.justscale;
|
|
262
|
+
const host = ts.createWatchCompilerHost(configPath, config.compilerOptions, ts.sys, ts.createEmitAndSemanticDiagnosticsBuilderProgram, reportDiagnostic, reportWatchStatus);
|
|
263
|
+
const originalAfterProgramCreate = host.afterProgramCreate;
|
|
264
|
+
host.afterProgramCreate = (builderProgram) => {
|
|
265
|
+
const program1 = builderProgram.getProgram();
|
|
266
|
+
const modifiedSources = extractAndInjectExportsTypes(program1);
|
|
267
|
+
let program;
|
|
268
|
+
if (modifiedSources.size > 0) {
|
|
269
|
+
const host2 = createModifiedHost(ts.createCompilerHost(config.compilerOptions), modifiedSources);
|
|
270
|
+
program = ts.createProgram({
|
|
271
|
+
rootNames: program1.getRootFileNames(),
|
|
272
|
+
options: program1.getCompilerOptions(),
|
|
273
|
+
host: host2,
|
|
274
|
+
oldProgram: program1,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
program = program1;
|
|
279
|
+
}
|
|
280
|
+
const processDiagnostics = getProcessDiagnostics(program, jsConfig);
|
|
281
|
+
for (const diag of processDiagnostics) {
|
|
282
|
+
reportDiagnostic(diag);
|
|
283
|
+
}
|
|
284
|
+
if (!config.compilerOptions.noEmit) {
|
|
285
|
+
program.emit(undefined, undefined, undefined, undefined, {
|
|
286
|
+
before: [createProcessTransformer(program, { verbose: jsConfig.verbose ?? false })],
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
if (originalAfterProgramCreate) {
|
|
290
|
+
originalAfterProgramCreate(builderProgram);
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
ts.createWatchProgram(host);
|
|
294
|
+
}
|
|
295
|
+
function getProcessDiagnostics(program, config) {
|
|
296
|
+
const diagnostics = [];
|
|
297
|
+
const typeChecker = program.getTypeChecker();
|
|
298
|
+
const processModules = config.processModules ?? defaultConfig.processModules;
|
|
299
|
+
for (const sourceFile of program.getSourceFiles()) {
|
|
300
|
+
if (sourceFile.isDeclarationFile)
|
|
301
|
+
continue;
|
|
302
|
+
if (sourceFile.fileName.includes('node_modules'))
|
|
303
|
+
continue;
|
|
304
|
+
if (!isProcessFile(sourceFile, config, processModules))
|
|
305
|
+
continue;
|
|
306
|
+
ts.forEachChild(sourceFile, function visit(node) {
|
|
307
|
+
if (ts.isCallExpression(node)) {
|
|
308
|
+
const expr = node.expression;
|
|
309
|
+
if (ts.isIdentifier(expr) && expr.text === 'createProcess') {
|
|
310
|
+
const configArg = node.arguments[0];
|
|
311
|
+
if (configArg && ts.isObjectLiteralExpression(configArg)) {
|
|
312
|
+
const handler = findHandler(configArg);
|
|
313
|
+
if (handler) {
|
|
314
|
+
const analysis = analyzeHandler(handler, typeChecker);
|
|
315
|
+
diagnostics.push(...analysis.diagnostics);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
ts.forEachChild(node, visit);
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
return diagnostics;
|
|
324
|
+
}
|
|
325
|
+
function isProcessFile(sourceFile, config, processModules) {
|
|
326
|
+
const pattern = config.processFilePattern;
|
|
327
|
+
if (pattern && sourceFile.fileName.includes(pattern.replace('*', ''))) {
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
if (sourceFile.fileName.includes('.process.'))
|
|
331
|
+
return true;
|
|
332
|
+
for (const stmt of sourceFile.statements) {
|
|
333
|
+
if (ts.isImportDeclaration(stmt)) {
|
|
334
|
+
const moduleSpecifier = stmt.moduleSpecifier;
|
|
335
|
+
if (ts.isStringLiteral(moduleSpecifier)) {
|
|
336
|
+
if (processModules.includes(moduleSpecifier.text)) {
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
function findHandler(configObj) {
|
|
345
|
+
for (const prop of configObj.properties) {
|
|
346
|
+
if (ts.isMethodDeclaration(prop)) {
|
|
347
|
+
if (ts.isIdentifier(prop.name) && prop.name.text === 'handler') {
|
|
348
|
+
return prop;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
else if (ts.isPropertyAssignment(prop)) {
|
|
352
|
+
if (ts.isIdentifier(prop.name) && prop.name.text === 'handler') {
|
|
353
|
+
if (ts.isFunctionExpression(prop.initializer) || ts.isArrowFunction(prop.initializer)) {
|
|
354
|
+
return prop.initializer;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return undefined;
|
|
360
|
+
}
|
|
361
|
+
function formatHost() {
|
|
362
|
+
return {
|
|
363
|
+
getCanonicalFileName: (path) => path,
|
|
364
|
+
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
365
|
+
getNewLine: () => ts.sys.newLine,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
function reportDiagnostic(diagnostic) {
|
|
369
|
+
console.log(ts.formatDiagnosticsWithColorAndContext([diagnostic], formatHost()));
|
|
370
|
+
}
|
|
371
|
+
function reportWatchStatus(diagnostic) {
|
|
372
|
+
console.log(ts.formatDiagnostic(diagnostic, formatHost()));
|
|
373
|
+
}
|
|
374
|
+
function printHelp() {
|
|
375
|
+
console.log(`
|
|
376
|
+
ptsc - Process TypeScript Compiler
|
|
377
|
+
Drop-in replacement for tsc with JustScale process compilation support.
|
|
378
|
+
|
|
379
|
+
Version: ${VERSION}
|
|
380
|
+
TypeScript: ${ts.version}
|
|
381
|
+
|
|
382
|
+
Usage:
|
|
383
|
+
ptsc [options] [file...]
|
|
384
|
+
|
|
385
|
+
Examples:
|
|
386
|
+
ptsc Compile using nearest tsconfig.json
|
|
387
|
+
ptsc hello.ts Compile a single file
|
|
388
|
+
ptsc --noEmit Type check only (no output)
|
|
389
|
+
ptsc -p tsconfig.json Use specific config file
|
|
390
|
+
ptsc -b tsconfig.build.json Build mode with project references
|
|
391
|
+
ptsc -w Watch mode
|
|
392
|
+
ptsc --init Initialize tsconfig.json
|
|
393
|
+
|
|
394
|
+
Common Options:
|
|
395
|
+
-w, --watch Watch input files
|
|
396
|
+
-p, --project <path> Compile the project given the path to tsconfig.json
|
|
397
|
+
-b, --build Build one or more projects and their dependencies
|
|
398
|
+
--noEmit Disable emitting files from compilation
|
|
399
|
+
--declaration Generate .d.ts declaration files
|
|
400
|
+
--outDir <path> Redirect output structure to the directory
|
|
401
|
+
--rootDir <path> Specify root directory of input files
|
|
402
|
+
--strict Enable all strict type-checking options
|
|
403
|
+
--target <version> Set ECMAScript target version
|
|
404
|
+
--module <type> Specify module code generation
|
|
405
|
+
-h, --help Show this help message
|
|
406
|
+
-v, --version Print version information
|
|
407
|
+
|
|
408
|
+
JustScale Options (in tsconfig.json):
|
|
409
|
+
{
|
|
410
|
+
"justscale": {
|
|
411
|
+
"processFilePattern": "*.process.ts", // File pattern for processes
|
|
412
|
+
"strict": true, // Strict process checking
|
|
413
|
+
"verbose": false, // Verbose output
|
|
414
|
+
"processModules": ["@justscale/core/process"]
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
Process Diagnostics (TSPxxxx):
|
|
419
|
+
TSP0001: Missing await on suspension point
|
|
420
|
+
TSP0002: Variable captured across suspension point
|
|
421
|
+
TSP0003: Invalid process handler signature
|
|
422
|
+
TSP0004: Unsupported control flow in process
|
|
423
|
+
|
|
424
|
+
For more information, see: https://justscale.sh/docs/typescript
|
|
425
|
+
`);
|
|
426
|
+
}
|
|
427
|
+
function initConfig() {
|
|
428
|
+
const configPath = resolve(process.cwd(), 'tsconfig.json');
|
|
429
|
+
if (existsSync(configPath)) {
|
|
430
|
+
console.error(`error: tsconfig.json already exists at ${configPath}`);
|
|
431
|
+
process.exit(1);
|
|
432
|
+
}
|
|
433
|
+
const config = {
|
|
434
|
+
compilerOptions: {
|
|
435
|
+
target: 'ES2022',
|
|
436
|
+
module: 'NodeNext',
|
|
437
|
+
moduleResolution: 'NodeNext',
|
|
438
|
+
strict: true,
|
|
439
|
+
esModuleInterop: true,
|
|
440
|
+
skipLibCheck: true,
|
|
441
|
+
forceConsistentCasingInFileNames: true,
|
|
442
|
+
outDir: './dist',
|
|
443
|
+
rootDir: './src',
|
|
444
|
+
declaration: true,
|
|
445
|
+
declarationMap: true,
|
|
446
|
+
sourceMap: true,
|
|
447
|
+
plugins: [
|
|
448
|
+
{ name: '@justscale/typescript/language-service' }
|
|
449
|
+
]
|
|
450
|
+
},
|
|
451
|
+
justscale: {
|
|
452
|
+
processFilePattern: '*.process.ts',
|
|
453
|
+
strict: true,
|
|
454
|
+
verbose: false
|
|
455
|
+
},
|
|
456
|
+
include: ['src/**/*'],
|
|
457
|
+
exclude: ['node_modules', 'dist']
|
|
458
|
+
};
|
|
459
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
|
|
460
|
+
console.log(`Created tsconfig.json at ${configPath}`);
|
|
461
|
+
}
|
|
462
|
+
//# sourceMappingURL=ptsc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ptsc.js","sourceRoot":"","sources":["../../src/compiler/ptsc.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ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OAAO,EAAE;gBACP,EAAE,IAAI,EAAE,wCAAwC,EAAE;aACnD;SACF;QACD,SAAS,EAAE;YACT,kBAAkB,EAAE,cAAc;YAClC,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE,KAAK;SACf;QACD,OAAO,EAAE,CAAC,UAAU,CAAC;QACrB,OAAO,EAAE,CAAC,cAAc,EAAE,MAAM,CAAC;KAClC,CAAC;IAEF,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAClE,OAAO,CAAC,GAAG,CAAC,4BAA4B,UAAU,EAAE,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @justscale/core/process - AST Rewriter
|
|
3
|
+
*
|
|
4
|
+
* Rewrites variable references in block bodies to use state.vars and services.
|
|
5
|
+
*
|
|
6
|
+
* Transforms:
|
|
7
|
+
* - Handler params (orderId) -> state.vars.orderId
|
|
8
|
+
* - Injected services (payments) -> services.payments
|
|
9
|
+
* - Local variables (payment) -> state.vars.payment
|
|
10
|
+
* - Using variables (order) -> state.vars.order (rehydrated before block)
|
|
11
|
+
*/
|
|
12
|
+
import ts from 'typescript';
|
|
13
|
+
export interface RewriterContext {
|
|
14
|
+
/** Variables from handler params: [orderId] or { order: orderId } */
|
|
15
|
+
paramVars: Set<string>;
|
|
16
|
+
/** Aliases: local name -> param name, for { user: userId } -> Map("userId" -> "user") */
|
|
17
|
+
paramAliases: Map<string, string>;
|
|
18
|
+
/** Injected service names: { payments, shipping } */
|
|
19
|
+
serviceVars: Set<string>;
|
|
20
|
+
/** Local variables created via STORE opcodes (cross-block state) */
|
|
21
|
+
localVars: Set<string>;
|
|
22
|
+
/** Using variables that need rehydration */
|
|
23
|
+
usingVars: Set<string>;
|
|
24
|
+
/** Race result variables (from const r = race()) - rewrite to __raceResult */
|
|
25
|
+
raceVars: Set<string>;
|
|
26
|
+
/** Variables declared within the current block - don't rewrite these */
|
|
27
|
+
blockLocalVars?: Set<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Step index an unlabeled `break` should jump to when encountered
|
|
30
|
+
* inside this rewrite scope. Used for race-branch case bodies, where
|
|
31
|
+
* the user wrote `break;` to exit their `switch(true) { case signal(r, …): … }`
|
|
32
|
+
* and we need the generated code to jump to the race's continuation step
|
|
33
|
+
* instead of silently breaking out of the compiled `switch(step)`.
|
|
34
|
+
*
|
|
35
|
+
* Cleared when entering user-written loops or switches (their `break`
|
|
36
|
+
* targets those constructs, not ours).
|
|
37
|
+
*/
|
|
38
|
+
breakTarget?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Step index an unlabeled `continue` should jump to when encountered
|
|
41
|
+
* inside this rewrite scope. Same problem as `break`: a naked `continue`
|
|
42
|
+
* inside an if-body of a race branch restarts `main_loop` without advancing
|
|
43
|
+
* `step`, causing the same branch body to re-execute immediately - infinite
|
|
44
|
+
* loop. Rewrite to `step = continueTarget; continue main_loop;`.
|
|
45
|
+
*
|
|
46
|
+
* For race branches inside a while loop, `continueTarget` equals `nextStep`
|
|
47
|
+
* (the continuation step). Both `break` and `continue` at the top of a race
|
|
48
|
+
* branch body lead to the same place: the step after the branch completes.
|
|
49
|
+
*/
|
|
50
|
+
continueTarget?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Rewrite a statement to use state.vars and services.
|
|
54
|
+
* Preserves source positions for accurate source maps.
|
|
55
|
+
*/
|
|
56
|
+
export declare function rewriteStatement(factory: ts.NodeFactory, stmt: ts.Statement, ctx: RewriterContext): ts.Statement;
|
|
57
|
+
/**
|
|
58
|
+
* Rewrite an expression to use state.vars and services.
|
|
59
|
+
* Preserves source positions for accurate source maps.
|
|
60
|
+
*/
|
|
61
|
+
export declare function rewriteExpression(factory: ts.NodeFactory, expr: ts.Expression, ctx: RewriterContext): ts.Expression;
|
|
62
|
+
/**
|
|
63
|
+
* Extract param variable names from handler parameters.
|
|
64
|
+
*
|
|
65
|
+
* Handles both tuple and object destructuring:
|
|
66
|
+
* handler(deps, [orderId]) -> paramVars: {orderId}, aliases: {}
|
|
67
|
+
* handler(deps, { order: orderId }) -> paramVars: {orderId}, aliases: {orderId -> order}
|
|
68
|
+
*
|
|
69
|
+
* The aliases map local names to the param names from the path.
|
|
70
|
+
* The rewriter uses aliases to access state.vars[paramName] instead of state.vars[localName].
|
|
71
|
+
*/
|
|
72
|
+
export declare function extractParamVars(handler: ts.FunctionExpression | ts.ArrowFunction | ts.MethodDeclaration): Set<string>;
|
|
73
|
+
/**
|
|
74
|
+
* Extract param aliases from object destructuring rename patterns.
|
|
75
|
+
*
|
|
76
|
+
* For `{ user: userId }`, returns Map { "userId" -> "user" }.
|
|
77
|
+
* The rewriter uses this to access `state.vars.user` when it sees `userId`.
|
|
78
|
+
*/
|
|
79
|
+
export declare function extractParamAliases(handler: ts.FunctionExpression | ts.ArrowFunction | ts.MethodDeclaration): Map<string, string>;
|
|
80
|
+
/**
|
|
81
|
+
* Extract service variable names from handler parameters.
|
|
82
|
+
*
|
|
83
|
+
* Handles: async handler({ payments, shipping }, [...])
|
|
84
|
+
*/
|
|
85
|
+
export declare function extractServiceVars(handler: ts.FunctionExpression | ts.ArrowFunction | ts.MethodDeclaration): Set<string>;
|
|
86
|
+
/**
|
|
87
|
+
* Extract all variable names declared in a list of statements.
|
|
88
|
+
* Used to identify block-local variables that shouldn't be rewritten.
|
|
89
|
+
*/
|
|
90
|
+
export declare function extractDeclaredVars(statements: ts.Statement[]): Set<string>;
|
|
91
|
+
/**
|
|
92
|
+
* Clone an expression, creating synthesized nodes that can be printed.
|
|
93
|
+
* This is necessary when the original expression comes from a different source file.
|
|
94
|
+
*/
|
|
95
|
+
export declare function cloneExpression(factory: ts.NodeFactory, expr: ts.Expression): ts.Expression;
|
|
96
|
+
//# sourceMappingURL=rewriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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