@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,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exports Pre-pass
|
|
3
|
+
*
|
|
4
|
+
* Two-pass compilation for process exports type inference.
|
|
5
|
+
*
|
|
6
|
+
* Pass 1: Create a TypeScript program, find `using exports = { ... }` declarations
|
|
7
|
+
* in process handlers, extract the type via typeChecker.getTypeAtLocation().
|
|
8
|
+
* Pass 2: Inject `__exportsType: void 0 as unknown as <ExportsType>` into the
|
|
9
|
+
* createProcess config, re-create the program. TypeScript now infers TExports
|
|
10
|
+
* correctly from the phantom property.
|
|
11
|
+
*
|
|
12
|
+
* Non-exported types referenced by the exports (e.g. local interfaces) are
|
|
13
|
+
* automatically exported so the declaration emitter can reference them.
|
|
14
|
+
*
|
|
15
|
+
* This gives us correct types everywhere: type checking, .d.ts output, IDE.
|
|
16
|
+
*/
|
|
17
|
+
import ts from 'typescript';
|
|
18
|
+
/**
|
|
19
|
+
* Extract exports types from all process files in a program and return
|
|
20
|
+
* modified source texts with `__exportsType` phantom properties injected.
|
|
21
|
+
*
|
|
22
|
+
* Returns a map from file name to modified source text.
|
|
23
|
+
* Only files that contain createProcess calls with `using exports` are included.
|
|
24
|
+
*/
|
|
25
|
+
export function extractAndInjectExportsTypes(program) {
|
|
26
|
+
const typeChecker = program.getTypeChecker();
|
|
27
|
+
const printer = ts.createPrinter();
|
|
28
|
+
const modifiedSources = new Map();
|
|
29
|
+
for (const sourceFile of program.getSourceFiles()) {
|
|
30
|
+
if (sourceFile.isDeclarationFile || sourceFile.fileName.includes('node_modules'))
|
|
31
|
+
continue;
|
|
32
|
+
const injections = findExportsInjections(sourceFile, typeChecker, printer);
|
|
33
|
+
if (injections.length === 0)
|
|
34
|
+
continue;
|
|
35
|
+
const modifiedText = applyInjections(sourceFile.text, injections);
|
|
36
|
+
modifiedSources.set(sourceFile.fileName, modifiedText);
|
|
37
|
+
}
|
|
38
|
+
return modifiedSources;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create a compiler host that serves modified source for specific files,
|
|
42
|
+
* falling back to the base host for everything else.
|
|
43
|
+
*/
|
|
44
|
+
export function createModifiedHost(baseHost, modifiedSources) {
|
|
45
|
+
return {
|
|
46
|
+
...baseHost,
|
|
47
|
+
getSourceFile: (name, languageVersionOrOptions, onError, shouldCreateNewSourceFile) => {
|
|
48
|
+
if (modifiedSources.has(name)) {
|
|
49
|
+
return ts.createSourceFile(name, modifiedSources.get(name), languageVersionOrOptions, true);
|
|
50
|
+
}
|
|
51
|
+
return baseHost.getSourceFile(name, languageVersionOrOptions, onError, shouldCreateNewSourceFile);
|
|
52
|
+
},
|
|
53
|
+
readFile: (name) => {
|
|
54
|
+
if (modifiedSources.has(name))
|
|
55
|
+
return modifiedSources.get(name);
|
|
56
|
+
return baseHost.readFile(name);
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Find all createProcess calls with `using exports` in a source file
|
|
62
|
+
* and extract the exports type for injection.
|
|
63
|
+
*/
|
|
64
|
+
function findExportsInjections(sourceFile, typeChecker, printer) {
|
|
65
|
+
const injections = [];
|
|
66
|
+
ts.forEachChild(sourceFile, function visit(node) {
|
|
67
|
+
if (ts.isCallExpression(node) &&
|
|
68
|
+
ts.isIdentifier(node.expression) &&
|
|
69
|
+
node.expression.text === 'createProcess') {
|
|
70
|
+
const configArg = node.arguments[0];
|
|
71
|
+
if (configArg && ts.isObjectLiteralExpression(configArg)) {
|
|
72
|
+
const handler = findHandler(configArg);
|
|
73
|
+
if (handler) {
|
|
74
|
+
const exportDecl = findExportsDeclaration(handler);
|
|
75
|
+
if (exportDecl) {
|
|
76
|
+
const type = typeChecker.getTypeAtLocation(exportDecl);
|
|
77
|
+
const typeNode = typeChecker.typeToTypeNode(type, exportDecl, ts.NodeBuilderFlags.NoTruncation | ts.NodeBuilderFlags.WriteArrayAsGenericType);
|
|
78
|
+
if (typeNode) {
|
|
79
|
+
const typeText = printer.printNode(ts.EmitHint.Unspecified, typeNode, sourceFile);
|
|
80
|
+
// Find non-exported types referenced by the exports type
|
|
81
|
+
// and collect their declaration positions so we can auto-export them
|
|
82
|
+
const autoExportPositions = findNonExportedTypePositions(type, typeChecker, sourceFile);
|
|
83
|
+
injections.push({ configNode: configArg, typeText, autoExportPositions });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
ts.forEachChild(node, visit);
|
|
90
|
+
});
|
|
91
|
+
return injections;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Find non-exported types referenced by the exports type and return
|
|
95
|
+
* the source positions of their declarations (where we need to add `export`).
|
|
96
|
+
*
|
|
97
|
+
* Uses a simple approach: walk the type node text produced by typeToTypeNode
|
|
98
|
+
* and look for identifiers that reference non-exported local declarations.
|
|
99
|
+
* This avoids recursive type walking which can stack overflow on circular types.
|
|
100
|
+
*/
|
|
101
|
+
function findNonExportedTypePositions(type, typeChecker, sourceFile) {
|
|
102
|
+
const positions = [];
|
|
103
|
+
const checked = new Set();
|
|
104
|
+
// Collect all named types visible in the source file
|
|
105
|
+
const localTypes = new Map();
|
|
106
|
+
for (const stmt of sourceFile.statements) {
|
|
107
|
+
if (ts.isInterfaceDeclaration(stmt) && !hasExportModifier(stmt)) {
|
|
108
|
+
localTypes.set(stmt.name.text, stmt);
|
|
109
|
+
}
|
|
110
|
+
else if (ts.isTypeAliasDeclaration(stmt) && !hasExportModifier(stmt)) {
|
|
111
|
+
localTypes.set(stmt.name.text, stmt);
|
|
112
|
+
}
|
|
113
|
+
else if (ts.isEnumDeclaration(stmt) && !hasExportModifier(stmt)) {
|
|
114
|
+
localTypes.set(stmt.name.text, stmt);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (localTypes.size === 0)
|
|
118
|
+
return [];
|
|
119
|
+
// Walk the type (breadth-first, depth-limited) to find references to local types
|
|
120
|
+
const queue = [type];
|
|
121
|
+
const visited = new Set(); // use type id to avoid revisiting
|
|
122
|
+
while (queue.length > 0 && visited.size < 100) {
|
|
123
|
+
const t = queue.shift();
|
|
124
|
+
const id = t.id;
|
|
125
|
+
if (id !== undefined && visited.has(id))
|
|
126
|
+
continue;
|
|
127
|
+
if (id !== undefined)
|
|
128
|
+
visited.add(id);
|
|
129
|
+
// Check if this type's symbol matches a local non-exported type
|
|
130
|
+
const sym = t.getSymbol() ?? t.aliasSymbol;
|
|
131
|
+
if (sym && !checked.has(sym.name) && localTypes.has(sym.name)) {
|
|
132
|
+
checked.add(sym.name);
|
|
133
|
+
const decl = localTypes.get(sym.name);
|
|
134
|
+
positions.push(decl.getStart());
|
|
135
|
+
}
|
|
136
|
+
// Enqueue type arguments
|
|
137
|
+
const typeArgs = t.typeArguments ?? t.resolvedTypeArguments;
|
|
138
|
+
if (Array.isArray(typeArgs)) {
|
|
139
|
+
for (const arg of typeArgs)
|
|
140
|
+
queue.push(arg);
|
|
141
|
+
}
|
|
142
|
+
// Enqueue union/intersection members
|
|
143
|
+
if (t.isUnion() || t.isIntersection()) {
|
|
144
|
+
for (const member of t.types)
|
|
145
|
+
queue.push(member);
|
|
146
|
+
}
|
|
147
|
+
// Enqueue property types (limited - only direct properties)
|
|
148
|
+
try {
|
|
149
|
+
for (const prop of typeChecker.getPropertiesOfType(t)) {
|
|
150
|
+
const propType = typeChecker.getTypeOfSymbol(prop);
|
|
151
|
+
queue.push(propType);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
// getPropertiesOfType can throw on some synthetic types
|
|
156
|
+
}
|
|
157
|
+
// Enqueue call signature return/param types
|
|
158
|
+
for (const sig of t.getCallSignatures()) {
|
|
159
|
+
queue.push(typeChecker.getReturnTypeOfSignature(sig));
|
|
160
|
+
for (const param of sig.getParameters()) {
|
|
161
|
+
queue.push(typeChecker.getTypeOfSymbol(param));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return [...new Set(positions)];
|
|
166
|
+
}
|
|
167
|
+
function hasExportModifier(node) {
|
|
168
|
+
return (ts.canHaveModifiers(node) && ts.getModifiers(node)?.some(m => m.kind === ts.SyntaxKind.ExportKeyword)) ?? false;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Find the handler function in a createProcess config object.
|
|
172
|
+
*/
|
|
173
|
+
function findHandler(configObj) {
|
|
174
|
+
for (const prop of configObj.properties) {
|
|
175
|
+
if (ts.isMethodDeclaration(prop) && ts.isIdentifier(prop.name) && prop.name.text === 'handler') {
|
|
176
|
+
return prop;
|
|
177
|
+
}
|
|
178
|
+
if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name) && prop.name.text === 'handler') {
|
|
179
|
+
if (ts.isFunctionExpression(prop.initializer) || ts.isArrowFunction(prop.initializer)) {
|
|
180
|
+
return prop.initializer;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Find `using exports = { ... }` in a handler body.
|
|
188
|
+
* Simple AST walk - no full analyzer needed.
|
|
189
|
+
*/
|
|
190
|
+
function findExportsDeclaration(handler) {
|
|
191
|
+
const body = handler.body;
|
|
192
|
+
if (!body || !ts.isBlock(body))
|
|
193
|
+
return undefined;
|
|
194
|
+
for (const stmt of body.statements) {
|
|
195
|
+
if (!ts.isVariableStatement(stmt))
|
|
196
|
+
continue;
|
|
197
|
+
for (const decl of stmt.declarationList.declarations) {
|
|
198
|
+
if (ts.isIdentifier(decl.name) &&
|
|
199
|
+
decl.name.text === 'exports' &&
|
|
200
|
+
decl.initializer &&
|
|
201
|
+
ts.isObjectLiteralExpression(decl.initializer)) {
|
|
202
|
+
return decl;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Apply exports type injections into source text.
|
|
210
|
+
* - Inserts `__exportsType: void 0 as unknown as <type>` into each createProcess config
|
|
211
|
+
* - Adds `export` to non-exported type declarations referenced by the exports type
|
|
212
|
+
*
|
|
213
|
+
* Uses AST node positions for precise insertion - not pattern matching.
|
|
214
|
+
*/
|
|
215
|
+
function applyInjections(sourceText, injections) {
|
|
216
|
+
// Collect all modifications: { position, text } sorted by position descending
|
|
217
|
+
const mods = [];
|
|
218
|
+
for (const { configNode, typeText, autoExportPositions } of injections) {
|
|
219
|
+
// 1. Inject __exportsType into config object
|
|
220
|
+
const closingBracePos = configNode.end - 1;
|
|
221
|
+
const lastProp = configNode.properties[configNode.properties.length - 1];
|
|
222
|
+
if (!lastProp)
|
|
223
|
+
continue;
|
|
224
|
+
const textBetween = sourceText.substring(lastProp.end, closingBracePos);
|
|
225
|
+
const hasTrailingComma = textBetween.includes(',');
|
|
226
|
+
const comma = hasTrailingComma ? '' : ',';
|
|
227
|
+
mods.push({ pos: closingBracePos, insert: `${comma} __exportsType: void 0 as unknown as ${typeText}` });
|
|
228
|
+
// 2. Add `export` to non-exported type declarations
|
|
229
|
+
for (const pos of autoExportPositions) {
|
|
230
|
+
mods.push({ pos, insert: 'export ' });
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Sort by position descending so later insertions don't shift earlier positions
|
|
234
|
+
mods.sort((a, b) => b.pos - a.pos);
|
|
235
|
+
// Deduplicate by position (same type might be referenced by multiple processes)
|
|
236
|
+
const seen = new Set();
|
|
237
|
+
const uniqueMods = mods.filter(m => {
|
|
238
|
+
if (seen.has(m.pos))
|
|
239
|
+
return false;
|
|
240
|
+
seen.add(m.pos);
|
|
241
|
+
return true;
|
|
242
|
+
});
|
|
243
|
+
let result = sourceText;
|
|
244
|
+
for (const { pos, insert } of uniqueMods) {
|
|
245
|
+
result = result.slice(0, pos) + insert + result.slice(pos);
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=exports-prepass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports-prepass.js","sourceRoot":"","sources":["../../src/compiler/exports-prepass.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAW5B;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAAmB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AAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAEnC,gFAAgF;IAChF,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;QACjC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QAClC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,IAAI,MAAM,GAAG,UAAU,CAAC;IACxB,KAAK,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;QACzC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HMR Change Detector
|
|
3
|
+
*
|
|
4
|
+
* Analyzes two versions of TypeScript source code to determine:
|
|
5
|
+
* 1. Which services changed
|
|
6
|
+
* 2. What kind of changes occurred (method-only vs structural)
|
|
7
|
+
* 3. Which specific methods changed (for method patching)
|
|
8
|
+
*
|
|
9
|
+
* This enables the dev server to choose between:
|
|
10
|
+
* - method-patch: Only method bodies changed, can do in-place patching
|
|
11
|
+
* - full-reload: Structural changes, need full service reload with state migration
|
|
12
|
+
*/
|
|
13
|
+
export interface ServiceChange {
|
|
14
|
+
/** Stable service ID (file#ClassName) */
|
|
15
|
+
serviceId: string;
|
|
16
|
+
/** Type of change detected */
|
|
17
|
+
changeType: 'method-only' | 'structural';
|
|
18
|
+
/** List of changed method names (only for method-only changes) */
|
|
19
|
+
changedMethods: string[];
|
|
20
|
+
/** Description of what changed (for debugging) */
|
|
21
|
+
reason: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ChangeDetectionResult {
|
|
24
|
+
/** Whether any services changed */
|
|
25
|
+
hasChanges: boolean;
|
|
26
|
+
/** List of changed services */
|
|
27
|
+
services: ServiceChange[];
|
|
28
|
+
/** Services that were added (new file or new class) */
|
|
29
|
+
added: string[];
|
|
30
|
+
/** Services that were removed */
|
|
31
|
+
removed: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Detect changes between two versions of a source file.
|
|
35
|
+
*
|
|
36
|
+
* @param oldSource - Previous version of the source code
|
|
37
|
+
* @param newSource - New version of the source code
|
|
38
|
+
* @param fileName - File path (for service ID generation)
|
|
39
|
+
* @param baseDir - Base directory for relative paths
|
|
40
|
+
*/
|
|
41
|
+
export declare function detectChanges(oldSource: string, newSource: string, fileName: string, baseDir?: string): ChangeDetectionResult;
|
|
42
|
+
/**
|
|
43
|
+
* Quick check if a file might contain services.
|
|
44
|
+
* Use this for early filtering in file watchers.
|
|
45
|
+
*/
|
|
46
|
+
export declare function mightContainServices(source: string): boolean;
|
|
47
|
+
//# sourceMappingURL=hmr-change-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmr-change-detector.d.ts","sourceRoot":"","sources":["../../src/compiler/hmr-change-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAA;IACjB,8BAA8B;IAC9B,UAAU,EAAE,aAAa,GAAG,YAAY,CAAA;IACxC,kEAAkE;IAClE,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,mCAAmC;IACnC,UAAU,EAAE,OAAO,CAAA;IACnB,+BAA+B;IAC/B,QAAQ,EAAE,aAAa,EAAE,CAAA;IACzB,uDAAuD;IACvD,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,iCAAiC;IACjC,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAiBD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,MAAsB,GAC9B,qBAAqB,CAwCvB;AAiaD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE5D"}
|