@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,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js ESM Loader for Process TypeScript and Proto files
|
|
3
|
+
*
|
|
4
|
+
* This loader hooks into Node.js module loading to:
|
|
5
|
+
* 1. Compile process files (*.process.ts or files importing @justscale/core/process)
|
|
6
|
+
* 2. Transform .proto imports to JavaScript
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* node --import @justscale/typescript/register --import tsx ./app.ts
|
|
10
|
+
*/
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import { dirname, basename, relative } from 'node:path';
|
|
13
|
+
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
14
|
+
import { PtsCompiler } from './incremental.js';
|
|
15
|
+
import '../plugins/index.js';
|
|
16
|
+
import { getPlugins } from '../plugins/types.js';
|
|
17
|
+
// Singleton compiler instance
|
|
18
|
+
let compiler = null;
|
|
19
|
+
// Per-plugin resolver singletons (index matches getPlugins())
|
|
20
|
+
let pluginResolvers = null;
|
|
21
|
+
// Project root cache: computed once from cwd at first compile.
|
|
22
|
+
let projectRoot = null;
|
|
23
|
+
function getProjectRoot() {
|
|
24
|
+
if (!projectRoot)
|
|
25
|
+
projectRoot = findProjectRoot(process.cwd());
|
|
26
|
+
return projectRoot;
|
|
27
|
+
}
|
|
28
|
+
function getCompiler() {
|
|
29
|
+
if (!compiler) {
|
|
30
|
+
compiler = new PtsCompiler({
|
|
31
|
+
rootDir: getProjectRoot(),
|
|
32
|
+
verbose: process.env.PTS_VERBOSE === '1',
|
|
33
|
+
sourceMap: process.env.PTS_SOURCEMAP !== '0',
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return compiler;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Verify a file path is inside the project root after symlink resolution.
|
|
40
|
+
* Used to prevent the loader from compiling a process file that escaped
|
|
41
|
+
* via symlink or absolute-path import — those should fall through to tsx
|
|
42
|
+
* (treated as plain TypeScript) rather than getting our process-runtime
|
|
43
|
+
* codegen and access to internal opcodes.
|
|
44
|
+
*
|
|
45
|
+
* Conservative: returns true only when the realpath is provably inside
|
|
46
|
+
* the root. Returns false on stat errors so suspicious paths fall through
|
|
47
|
+
* to the safer code path.
|
|
48
|
+
*/
|
|
49
|
+
function isInsideProjectRoot(filePath) {
|
|
50
|
+
return _isInsideRoot(filePath, getProjectRoot());
|
|
51
|
+
}
|
|
52
|
+
/** Exported for unit tests; takes an explicit root rather than using cwd. */
|
|
53
|
+
export function _isInsideRoot(filePath, root) {
|
|
54
|
+
let real;
|
|
55
|
+
let realRoot;
|
|
56
|
+
try {
|
|
57
|
+
real = realpathSync(filePath);
|
|
58
|
+
// Realpath the root too — on macOS, tmpdir() returns /var/folders/...
|
|
59
|
+
// which realpaths to /private/var/folders/..., and a comparison
|
|
60
|
+
// without normalizing both ends would produce a false negative for
|
|
61
|
+
// legitimately-in-root files.
|
|
62
|
+
realRoot = realpathSync(root);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
const rel = relative(realRoot, real);
|
|
68
|
+
// Empty rel means the file IS the root (impossible for files but be
|
|
69
|
+
// explicit). Any rel starting with `..` means we walked OUT of root.
|
|
70
|
+
if (rel === '' || rel.startsWith('..'))
|
|
71
|
+
return false;
|
|
72
|
+
// Defense against `subdir/../escape` style paths that happen to resolve
|
|
73
|
+
// back inside but contain literal `..` segments — relative() normalizes,
|
|
74
|
+
// but be paranoid against future bugs.
|
|
75
|
+
return !rel.split(/[/\\]/).includes('..');
|
|
76
|
+
}
|
|
77
|
+
function getPluginResolvers() {
|
|
78
|
+
if (!pluginResolvers) {
|
|
79
|
+
const baseDir = process.cwd();
|
|
80
|
+
pluginResolvers = getPlugins().map(plugin => plugin.createResolver({ baseDir, sourceMapMode: 'inline' }));
|
|
81
|
+
}
|
|
82
|
+
return pluginResolvers;
|
|
83
|
+
}
|
|
84
|
+
function findProjectRoot(startDir) {
|
|
85
|
+
let dir = startDir;
|
|
86
|
+
while (dir !== dirname(dir)) {
|
|
87
|
+
if (existsSync(dir + '/package.json')) {
|
|
88
|
+
return dir;
|
|
89
|
+
}
|
|
90
|
+
dir = dirname(dir);
|
|
91
|
+
}
|
|
92
|
+
return startDir;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Check if a file is a process file that needs special compilation.
|
|
96
|
+
* A file is a process file if:
|
|
97
|
+
* - It matches *.process.ts naming convention
|
|
98
|
+
* - It imports from '@justscale/core/process' and contains createProcess
|
|
99
|
+
*/
|
|
100
|
+
function isProcessFile(filePath, source) {
|
|
101
|
+
const fileName = basename(filePath);
|
|
102
|
+
// Quick check: *.process.ts naming convention
|
|
103
|
+
if (fileName.includes('.process.')) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
// Read source if not provided
|
|
107
|
+
if (!source) {
|
|
108
|
+
try {
|
|
109
|
+
source = readFileSync(filePath, 'utf-8');
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Check for @justscale/core/process import AND createProcess usage
|
|
116
|
+
if (source.includes('@justscale/core/process') && source.includes('createProcess')) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Resolve hook - handles format imports (.proto, .capnp, .graphql/.gql).
|
|
123
|
+
* Tells Node.js where to find these files and marks them as ESM modules.
|
|
124
|
+
*/
|
|
125
|
+
export async function resolve(specifier, context, nextResolve) {
|
|
126
|
+
const plugins = getPlugins();
|
|
127
|
+
const isFormatImport = plugins.some(p => p.extensions.some(ext => specifier.endsWith(ext)));
|
|
128
|
+
if (isFormatImport) {
|
|
129
|
+
if (specifier.startsWith('.') && context.parentURL) {
|
|
130
|
+
return {
|
|
131
|
+
url: new URL(specifier, context.parentURL).href,
|
|
132
|
+
format: 'module',
|
|
133
|
+
shortCircuit: true,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
url: new URL(specifier, 'file://').href,
|
|
138
|
+
format: 'module',
|
|
139
|
+
shortCircuit: true,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return nextResolve(specifier, context);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Load hook - intercepts .ts files and compiles process files specially.
|
|
146
|
+
* Also handles .proto files for direct proto imports.
|
|
147
|
+
* Non-process .ts files are forwarded to the next loader (tsx).
|
|
148
|
+
*/
|
|
149
|
+
export async function load(url, context, nextLoad) {
|
|
150
|
+
// Skip node_modules and declaration files
|
|
151
|
+
if (url.includes('node_modules') || url.endsWith('.d.ts')) {
|
|
152
|
+
return nextLoad(url, context);
|
|
153
|
+
}
|
|
154
|
+
// Handle format-specific files (.proto, .capnp, .graphql, .gql)
|
|
155
|
+
const plugins = getPlugins();
|
|
156
|
+
const resolvers = getPluginResolvers();
|
|
157
|
+
for (let i = 0; i < plugins.length; i++) {
|
|
158
|
+
const plugin = plugins[i];
|
|
159
|
+
const isMatch = plugin.extensions.some(ext => url.endsWith(ext));
|
|
160
|
+
if (isMatch) {
|
|
161
|
+
const filePath = fileURLToPath(url);
|
|
162
|
+
const resolver = resolvers[i];
|
|
163
|
+
const info = resolver.resolveModule(filePath, filePath);
|
|
164
|
+
if (!info) {
|
|
165
|
+
throw new Error(`[${plugin.name}-loader] Failed to resolve: ${filePath}`);
|
|
166
|
+
}
|
|
167
|
+
if (info.errors.length > 0) {
|
|
168
|
+
const errorMessages = info.errors
|
|
169
|
+
.filter(e => e.severity === 'error')
|
|
170
|
+
.map(e => ` ${e.message}`)
|
|
171
|
+
.join('\n');
|
|
172
|
+
if (errorMessages) {
|
|
173
|
+
console.error(`[${plugin.name}-loader] Errors in ${filePath}:\n${errorMessages}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (process.env.PTS_VERBOSE === '1') {
|
|
177
|
+
console.log(`[${plugin.name}-loader] Compiled: ${filePath}`);
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
format: 'module',
|
|
181
|
+
source: info.runtime,
|
|
182
|
+
shortCircuit: true,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// Handle both .ts and .js extensions (ESM imports use .js even for .ts files)
|
|
187
|
+
let filePath;
|
|
188
|
+
if (url.endsWith('.ts')) {
|
|
189
|
+
filePath = fileURLToPath(url);
|
|
190
|
+
}
|
|
191
|
+
else if (url.endsWith('.js')) {
|
|
192
|
+
// Try to resolve .js to .ts file
|
|
193
|
+
const jsPath = fileURLToPath(url);
|
|
194
|
+
const tsPath = jsPath.replace(/\.js$/, '.ts');
|
|
195
|
+
if (existsSync(tsPath)) {
|
|
196
|
+
filePath = tsPath;
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
return nextLoad(url, context);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
return nextLoad(url, context);
|
|
204
|
+
}
|
|
205
|
+
// Check if this is a process file
|
|
206
|
+
if (!isProcessFile(filePath)) {
|
|
207
|
+
// Not a process file - let tsx handle it
|
|
208
|
+
return nextLoad(url, context);
|
|
209
|
+
}
|
|
210
|
+
// Project-root scoping: a process file that resolves (via symlink or
|
|
211
|
+
// absolute import) to outside the project must NOT be compiled with
|
|
212
|
+
// our transformer. The transformer assumes the source is trusted
|
|
213
|
+
// project code — running it on a hostile path would emit the file's
|
|
214
|
+
// contents into our process-runtime codegen path. Fall through to tsx
|
|
215
|
+
// for plain-TS handling instead.
|
|
216
|
+
if (!isInsideProjectRoot(filePath)) {
|
|
217
|
+
if (process.env.PTS_VERBOSE === '1') {
|
|
218
|
+
console.warn(`[process-loader] Refusing to compile out-of-root path as process: ${filePath}`);
|
|
219
|
+
}
|
|
220
|
+
return nextLoad(url, context);
|
|
221
|
+
}
|
|
222
|
+
// It's a process file - compile with our transformer
|
|
223
|
+
const ptsCompiler = getCompiler();
|
|
224
|
+
try {
|
|
225
|
+
const result = ptsCompiler.compile(filePath);
|
|
226
|
+
if (process.env.PTS_VERBOSE === '1') {
|
|
227
|
+
console.log(`[process-loader] ${result.cached ? 'Cached' : 'Compiled'}: ${filePath}`);
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
format: 'module',
|
|
231
|
+
source: result.code,
|
|
232
|
+
shortCircuit: true,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
console.error(`[process-loader] Failed to compile ${filePath}:`, error);
|
|
237
|
+
throw error;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Initialize hook - called when the loader is registered.
|
|
242
|
+
*/
|
|
243
|
+
export async function initialize(data) {
|
|
244
|
+
if (data?.verbose) {
|
|
245
|
+
process.env.PTS_VERBOSE = '1';
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/loader/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAuB,MAAM,qBAAqB,CAAC;AAEtE,8BAA8B;AAC9B,IAAI,QAAQ,GAAuB,IAAI,CAAC;AACxC,8DAA8D;AAC9D,IAAI,eAAe,GAA4B,IAAI,CAAC;AACpD,+DAA+D;AAC/D,IAAI,WAAW,GAAkB,IAAI,CAAC;AAEtC,SAAS,cAAc;IACrB,IAAI,CAAC,WAAW;QAAE,WAAW,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAC/D,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,SAAS,WAAW;IAClB,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,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AC;QACH,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE7C,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,GAAG,EAAE,CAAC;YACpC,OAAO,CAAC,GAAG,CAAC,oBAAoB,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC,CAAC;QACxF,CAAC;QAED,OAAO;YACL,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE,MAAM,CAAC,IAAI;YACnB,YAAY,EAAE,IAAI;SACnB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,sCAAsC,QAAQ,GAAG,EAAE,KAAK,CAAC,CAAC;QACxE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAA4B;IAC3D,IAAI,IAAI,EAAE,OAAO,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC;IAChC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PTS Loader Registration
|
|
3
|
+
*
|
|
4
|
+
* This module registers the PTS loader with Node.js.
|
|
5
|
+
* Use with --import flag:
|
|
6
|
+
*
|
|
7
|
+
* node --import @justscale/compiler/register ./app.ts
|
|
8
|
+
*
|
|
9
|
+
* Or with tsx:
|
|
10
|
+
*
|
|
11
|
+
* node --import @justscale/compiler/register --import tsx ./app.ts
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=register.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/loader/register.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PTS Loader Registration
|
|
3
|
+
*
|
|
4
|
+
* This module registers the PTS loader with Node.js.
|
|
5
|
+
* Use with --import flag:
|
|
6
|
+
*
|
|
7
|
+
* node --import @justscale/compiler/register ./app.ts
|
|
8
|
+
*
|
|
9
|
+
* Or with tsx:
|
|
10
|
+
*
|
|
11
|
+
* node --import @justscale/compiler/register --import tsx ./app.ts
|
|
12
|
+
*/
|
|
13
|
+
import { register } from 'node:module';
|
|
14
|
+
// Register the PTS loader
|
|
15
|
+
// The loader will be called before tsx (if also registered)
|
|
16
|
+
register('./loader.js', import.meta.url);
|
|
17
|
+
if (process.env.PTS_VERBOSE === '1') {
|
|
18
|
+
console.log('[pts] Loader registered');
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/loader/register.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,0BAA0B;AAC1B,4DAA4D;AAC5D,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEzC,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,GAAG,EAAE,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public-release version of the plugin barrel.
|
|
3
|
+
*
|
|
4
|
+
* Registers nothing. Swapping index.ts for this file (and excluding dist/plugins/
|
|
5
|
+
* from package.json#files) produces a published @justscale/typescript package
|
|
6
|
+
* that compiles durable processes and DI without protobuf/capnp/graphql support.
|
|
7
|
+
*
|
|
8
|
+
* To apply the patch:
|
|
9
|
+
* cp src/plugins/index.public.ts src/plugins/index.ts
|
|
10
|
+
* # then update package.json#files to exclude "dist/plugins"
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public-release version of the plugin barrel.
|
|
3
|
+
*
|
|
4
|
+
* Registers nothing. Swapping index.ts for this file (and excluding dist/plugins/
|
|
5
|
+
* from package.json#files) produces a published @justscale/typescript package
|
|
6
|
+
* that compiles durable processes and DI without protobuf/capnp/graphql support.
|
|
7
|
+
*
|
|
8
|
+
* To apply the patch:
|
|
9
|
+
* cp src/plugins/index.public.ts src/plugins/index.ts
|
|
10
|
+
* # then update package.json#files to exclude "dist/plugins"
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public-release version of the plugin barrel.
|
|
3
|
+
*
|
|
4
|
+
* Registers nothing. Swapping index.ts for this file (and excluding dist/plugins/
|
|
5
|
+
* from package.json#files) produces a published @justscale/typescript package
|
|
6
|
+
* that compiles durable processes and DI without protobuf/capnp/graphql support.
|
|
7
|
+
*
|
|
8
|
+
* To apply the patch:
|
|
9
|
+
* cp src/plugins/index.public.ts src/plugins/index.ts
|
|
10
|
+
* # then update package.json#files to exclude "dist/plugins"
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=index.public.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.public.d.ts","sourceRoot":"","sources":["../../src/plugins/index.public.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public-release version of the plugin barrel.
|
|
3
|
+
*
|
|
4
|
+
* Registers nothing. Swapping index.ts for this file (and excluding dist/plugins/
|
|
5
|
+
* from package.json#files) produces a published @justscale/typescript package
|
|
6
|
+
* that compiles durable processes and DI without protobuf/capnp/graphql support.
|
|
7
|
+
*
|
|
8
|
+
* To apply the patch:
|
|
9
|
+
* cp src/plugins/index.public.ts src/plugins/index.ts
|
|
10
|
+
* # then update package.json#files to exclude "dist/plugins"
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=index.public.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.public.js","sourceRoot":"","sources":["../../src/plugins/index.public.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compiler plugin interface for native-file-format integrations.
|
|
3
|
+
*
|
|
4
|
+
* Each format (protobuf, capnp, graphql) registers a plugin that wires its
|
|
5
|
+
* resolver, compiler host, and transformer into the ptsc/loader/language-service
|
|
6
|
+
* pipeline without being hardcoded in those entrypoints.
|
|
7
|
+
*
|
|
8
|
+
* The registry lives here; entrypoints import './plugins' (the barrel) to
|
|
9
|
+
* trigger registration, then call getPlugins() to iterate.
|
|
10
|
+
*
|
|
11
|
+
* Public-release patch: swap src/plugins/index.ts for an empty barrel.
|
|
12
|
+
* The dist/plugins/ folder is excluded from the published package.json#files.
|
|
13
|
+
*/
|
|
14
|
+
import type ts from 'typescript';
|
|
15
|
+
/**
|
|
16
|
+
* Common shape returned by every format resolver.
|
|
17
|
+
*
|
|
18
|
+
* - sourceMap: proto + capnp provide this; graphql does not (optional).
|
|
19
|
+
* - errors: all formats provide { message, severity, source }; proto/capnp call
|
|
20
|
+
* them CompileError with a slightly different shape, but all have .message and
|
|
21
|
+
* .severity so the optional-fields path works without disrupting existing code.
|
|
22
|
+
*/
|
|
23
|
+
export interface ModuleInfo {
|
|
24
|
+
/** Virtual .d.ts path */
|
|
25
|
+
declarationPath: string;
|
|
26
|
+
/** Virtual .js path */
|
|
27
|
+
runtimePath: string;
|
|
28
|
+
/** Generated TypeScript declaration */
|
|
29
|
+
declaration: string;
|
|
30
|
+
/** Generated JavaScript runtime */
|
|
31
|
+
runtime: string;
|
|
32
|
+
/** Source map JSON — present for proto/capnp, absent for graphql (v1: optional) */
|
|
33
|
+
sourceMap?: string;
|
|
34
|
+
/** Compilation errors */
|
|
35
|
+
errors: Array<{
|
|
36
|
+
message: string;
|
|
37
|
+
severity: string;
|
|
38
|
+
source?: string;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
export interface FormatResolver {
|
|
42
|
+
isImport(specifier: string): boolean;
|
|
43
|
+
resolveModule(specifier: string, containingFile: string): ModuleInfo | undefined;
|
|
44
|
+
}
|
|
45
|
+
export interface CompilerPlugin {
|
|
46
|
+
name: string;
|
|
47
|
+
/** File extensions handled, e.g. ['.proto'] */
|
|
48
|
+
extensions: string[];
|
|
49
|
+
/**
|
|
50
|
+
* Create a resolver instance for this format.
|
|
51
|
+
* The resolver is stateful (cache) so the plugin factory is called once per
|
|
52
|
+
* compile run and the returned resolver is threaded through host + transformer.
|
|
53
|
+
*/
|
|
54
|
+
createResolver(options: {
|
|
55
|
+
baseDir: string;
|
|
56
|
+
sourceMapMode?: 'external' | 'inline';
|
|
57
|
+
}): FormatResolver;
|
|
58
|
+
/**
|
|
59
|
+
* Wrap an existing compiler host to intercept virtual .d.ts reads for this format.
|
|
60
|
+
*/
|
|
61
|
+
createAwareCompilerHost(options: ts.CompilerOptions, resolver: FormatResolver, existingHost?: ts.CompilerHost): ts.CompilerHost;
|
|
62
|
+
/**
|
|
63
|
+
* Create a TypeScript transformer that rewrites format imports and collects diagnostics.
|
|
64
|
+
*/
|
|
65
|
+
createTransformer(program: ts.Program, resolver: FormatResolver, diagnosticsCollector: ts.Diagnostic[]): ts.TransformerFactory<ts.SourceFile>;
|
|
66
|
+
/**
|
|
67
|
+
* Get files emitted by the transformer for this format (to be written to outDir).
|
|
68
|
+
* Returns a Map<outputPath, content>.
|
|
69
|
+
*/
|
|
70
|
+
getEmittedFiles(resolver: FormatResolver): Map<string, string>;
|
|
71
|
+
/**
|
|
72
|
+
* Clear the emitted-files map before a fresh emit.
|
|
73
|
+
*/
|
|
74
|
+
clearEmittedFiles(resolver: FormatResolver): void;
|
|
75
|
+
/**
|
|
76
|
+
* For the language-service: return format-specific diagnostics for a single import.
|
|
77
|
+
* Receives the raw info returned by resolveModule.
|
|
78
|
+
*/
|
|
79
|
+
getDiagnosticsForImport(info: ModuleInfo, importPath: string, sourceFile: ts.SourceFile, ts: typeof import('typescript')): ts.Diagnostic[];
|
|
80
|
+
}
|
|
81
|
+
export declare function register(plugin: CompilerPlugin): void;
|
|
82
|
+
export declare function getPlugins(): readonly CompilerPlugin[];
|
|
83
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAMjC;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB,yBAAyB;IACzB,eAAe,EAAE,MAAM,CAAA;IACvB,uBAAuB;IACvB,WAAW,EAAE,MAAM,CAAA;IACnB,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAA;IACnB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,mFAAmF;IACnF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,yBAAyB;IACzB,MAAM,EAAE,KAA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Y,CAAC,GAC9B,EAAE,CAAC,UAAU,EAAE,CAAA;CACnB;AAQD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAErD;AAED,wBAAgB,UAAU,IAAI,SAAS,cAAc,EAAE,CAEtD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compiler plugin interface for native-file-format integrations.
|
|
3
|
+
*
|
|
4
|
+
* Each format (protobuf, capnp, graphql) registers a plugin that wires its
|
|
5
|
+
* resolver, compiler host, and transformer into the ptsc/loader/language-service
|
|
6
|
+
* pipeline without being hardcoded in those entrypoints.
|
|
7
|
+
*
|
|
8
|
+
* The registry lives here; entrypoints import './plugins' (the barrel) to
|
|
9
|
+
* trigger registration, then call getPlugins() to iterate.
|
|
10
|
+
*
|
|
11
|
+
* Public-release patch: swap src/plugins/index.ts for an empty barrel.
|
|
12
|
+
* The dist/plugins/ folder is excluded from the published package.json#files.
|
|
13
|
+
*/
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Registry
|
|
16
|
+
// ============================================================================
|
|
17
|
+
const plugins = [];
|
|
18
|
+
export function register(plugin) {
|
|
19
|
+
plugins.push(plugin);
|
|
20
|
+
}
|
|
21
|
+
export function getPlugins() {
|
|
22
|
+
return plugins;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAiGH,+EAA+E;AAC/E,WAAW;AACX,+EAA+E;AAE/E,MAAM,OAAO,GAAqB,EAAE,CAAC;AAErC,MAAM,UAAU,QAAQ,CAAC,MAAsB;IAC7C,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript Server integration for JustScale
|
|
3
|
+
*
|
|
4
|
+
* This module provides integration with the TypeScript Language Server
|
|
5
|
+
* for IDE support. It can be used in several ways:
|
|
6
|
+
*
|
|
7
|
+
* 1. Direct plugin: Add to tsconfig.json plugins array
|
|
8
|
+
* 2. Global plugin: Use ptscserver wrapper
|
|
9
|
+
* 3. VS Code extension: Use the recommended VS Code settings
|
|
10
|
+
*/
|
|
11
|
+
export { default as plugin } from '../language-service/index.js';
|
|
12
|
+
/**
|
|
13
|
+
* Configuration for the JustScale TypeScript server
|
|
14
|
+
*/
|
|
15
|
+
export interface ServerConfig {
|
|
16
|
+
/**
|
|
17
|
+
* Enable verbose logging
|
|
18
|
+
*/
|
|
19
|
+
verbose?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Path to the TypeScript installation to use
|
|
22
|
+
*/
|
|
23
|
+
typescriptPath?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Additional plugin paths to probe
|
|
26
|
+
*/
|
|
27
|
+
pluginPaths?: string[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Start the TypeScript Language Server with JustScale plugin enabled
|
|
31
|
+
*/
|
|
32
|
+
export declare function startLanguageServer(config?: ServerConfig): Promise<void>;
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BlF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript Server integration for JustScale
|
|
3
|
+
*
|
|
4
|
+
* This module provides integration with the TypeScript Language Server
|
|
5
|
+
* for IDE support. It can be used in several ways:
|
|
6
|
+
*
|
|
7
|
+
* 1. Direct plugin: Add to tsconfig.json plugins array
|
|
8
|
+
* 2. Global plugin: Use ptscserver wrapper
|
|
9
|
+
* 3. VS Code extension: Use the recommended VS Code settings
|
|
10
|
+
*/
|
|
11
|
+
export { default as plugin } from '../language-service/index.js';
|
|
12
|
+
/**
|
|
13
|
+
* Start the TypeScript Language Server with JustScale plugin enabled
|
|
14
|
+
*/
|
|
15
|
+
export async function startLanguageServer(config = {}) {
|
|
16
|
+
// Dynamic import to avoid bundling issues
|
|
17
|
+
const { spawn } = await import('node:child_process');
|
|
18
|
+
const { resolve } = await import('node:path');
|
|
19
|
+
const tsserverPath = config.typescriptPath
|
|
20
|
+
? resolve(config.typescriptPath, 'lib/tsserver.js')
|
|
21
|
+
: 'tsserver';
|
|
22
|
+
const args = [
|
|
23
|
+
'--globalPlugins',
|
|
24
|
+
'@justscale/typescript/language-service',
|
|
25
|
+
];
|
|
26
|
+
if (config.pluginPaths) {
|
|
27
|
+
args.push('--pluginProbeLocations', config.pluginPaths.join(','));
|
|
28
|
+
}
|
|
29
|
+
const tsserver = spawn(process.execPath, [tsserverPath, ...args], {
|
|
30
|
+
stdio: 'inherit',
|
|
31
|
+
});
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
tsserver.on('exit', (code) => {
|
|
34
|
+
if (code === 0)
|
|
35
|
+
resolve();
|
|
36
|
+
else
|
|
37
|
+
reject(new Error(`tsserver exited with code ${code}`));
|
|
38
|
+
});
|
|
39
|
+
tsserver.on('error', reject);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
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,CAAC;QACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* ptscserver - Process TypeScript Language Server
|
|
4
|
+
*
|
|
5
|
+
* Drop-in replacement for tsserver that automatically loads the JustScale
|
|
6
|
+
* language service plugin. This enables IDE integration without requiring
|
|
7
|
+
* manual plugin configuration in tsconfig.json.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* ptscserver [tsserver options]
|
|
11
|
+
*
|
|
12
|
+
* This is equivalent to running tsserver with the @justscale/typescript/language-service
|
|
13
|
+
* plugin globally enabled.
|
|
14
|
+
*
|
|
15
|
+
* VS Code Integration:
|
|
16
|
+
* In .vscode/settings.json:
|
|
17
|
+
* {
|
|
18
|
+
* "typescript.tsdk": "node_modules/typescript/lib",
|
|
19
|
+
* "typescript.tsserver.pluginPaths": ["node_modules/@justscale/typescript"]
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* Or use this wrapper directly:
|
|
23
|
+
* {
|
|
24
|
+
* "typescript.tsserver.path": "node_modules/@justscale/typescript/dist/server/tsserver.js"
|
|
25
|
+
* }
|
|
26
|
+
*/
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=tsserver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsserver.d.ts","sourceRoot":"","sources":["../../src/server/tsserver.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG"}
|