@bleedingdev/modern-js-renderer-octane 0.0.0-stage → 3.9.3-ultramodern.10
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/bin/octane-tsc.mjs +4 -0
- package/dist/cjs/bootstrap.js +68 -0
- package/dist/cjs/client.js +421 -0
- package/dist/cjs/entry-application.js +88 -0
- package/dist/cjs/entry-client.js +95 -0
- package/dist/cjs/entry-server.js +135 -0
- package/dist/cjs/federation-context.js +72 -0
- package/dist/cjs/federation.js +205 -0
- package/dist/cjs/i18n/I18nProvider.js +59 -0
- package/dist/cjs/i18n/LocalizedLink.js +80 -0
- package/dist/cjs/i18n/context.js +41 -0
- package/dist/cjs/i18n/index.js +83 -0
- package/dist/cjs/i18n/languageSync.js +99 -0
- package/dist/cjs/i18n/types.js +18 -0
- package/dist/cjs/i18n/useI18n.js +110 -0
- package/dist/cjs/i18n-external-snapshot.js +645 -0
- package/dist/cjs/index.js +46 -0
- package/dist/cjs/manifest.js +167 -0
- package/dist/cjs/plugin/compiler.js +122 -0
- package/dist/cjs/plugin/create.js +266 -0
- package/dist/cjs/plugin/index.js +151 -0
- package/dist/cjs/plugin/profile.js +91 -0
- package/dist/cjs/plugin/source.js +56 -0
- package/dist/cjs/router-client.js +139 -0
- package/dist/cjs/router-external-snapshot.js +291 -0
- package/dist/cjs/router-handler.js +171 -0
- package/dist/cjs/router-server-cleanup.js +46 -0
- package/dist/cjs/router-server-snapshot.js +405 -0
- package/dist/cjs/router-server.js +100 -0
- package/dist/cjs/router-snapshot.js +270 -0
- package/dist/cjs/router.js +218 -0
- package/dist/cjs/routes.js +190 -0
- package/dist/cjs/server.js +245 -0
- package/dist/cjs/typecheck.js +615 -0
- package/dist/cjs/worker-federation-context.js +63 -0
- package/dist/cjs/worker-federation-contexts.js +97 -0
- package/dist/cjs/worker-federation.js +97 -0
- package/dist/esm/bootstrap.mjs +24 -0
- package/dist/esm/client.mjs +377 -0
- package/dist/esm/entry-application.mjs +44 -0
- package/dist/esm/entry-client.mjs +57 -0
- package/dist/esm/entry-server.mjs +91 -0
- package/dist/esm/federation-context.mjs +25 -0
- package/dist/esm/federation.mjs +167 -0
- package/dist/esm/i18n/I18nProvider.mjs +21 -0
- package/dist/esm/i18n/LocalizedLink.mjs +42 -0
- package/dist/esm/i18n/context.mjs +3 -0
- package/dist/esm/i18n/index.mjs +8 -0
- package/dist/esm/i18n/languageSync.mjs +61 -0
- package/dist/esm/i18n/types.mjs +0 -0
- package/dist/esm/i18n/useI18n.mjs +72 -0
- package/dist/esm/i18n-external-snapshot.mjs +576 -0
- package/dist/esm/index.mjs +8 -0
- package/dist/esm/manifest.mjs +117 -0
- package/dist/esm/router-client.mjs +98 -0
- package/dist/esm/router-external-snapshot.mjs +244 -0
- package/dist/esm/router-handler.mjs +133 -0
- package/dist/esm/router-server-cleanup.mjs +8 -0
- package/dist/esm/router-server-snapshot.mjs +367 -0
- package/dist/esm/router-server.mjs +11 -0
- package/dist/esm/router-snapshot.mjs +199 -0
- package/dist/esm/router.mjs +94 -0
- package/dist/esm/routes.mjs +134 -0
- package/dist/esm/server.mjs +204 -0
- package/dist/esm/worker-federation-context.mjs +19 -0
- package/dist/esm/worker-federation-contexts.mjs +47 -0
- package/dist/esm/worker-federation.mjs +59 -0
- package/dist/esm-node/bootstrap.mjs +24 -0
- package/dist/esm-node/manifest.mjs +117 -0
- package/dist/esm-node/plugin/compiler.mjs +67 -0
- package/dist/esm-node/plugin/create.mjs +228 -0
- package/dist/esm-node/plugin/index.mjs +103 -0
- package/dist/esm-node/plugin/profile.mjs +53 -0
- package/dist/esm-node/plugin/source.mjs +7 -0
- package/dist/esm-node/typecheck.mjs +560 -0
- package/dist/types/bootstrap.d.ts +10 -0
- package/dist/types/client.d.ts +40 -0
- package/dist/types/entry-application.d.ts +19 -0
- package/dist/types/entry-client.d.ts +10 -0
- package/dist/types/entry-server.d.ts +14 -0
- package/dist/types/federation-context.d.ts +28 -0
- package/dist/types/federation.d.ts +20 -0
- package/dist/types/i18n/I18nProvider.d.ts +8 -0
- package/dist/types/i18n/LocalizedLink.d.ts +14 -0
- package/dist/types/i18n/context.d.ts +9 -0
- package/dist/types/i18n/index.d.ts +9 -0
- package/dist/types/i18n/languageSync.d.ts +26 -0
- package/dist/types/i18n/types.d.ts +34 -0
- package/dist/types/i18n/useI18n.d.ts +21 -0
- package/dist/types/i18n-external-snapshot.d.ts +43 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/manifest.d.ts +34 -0
- package/dist/types/plugin/compiler-manifest.d.cts +10 -0
- package/dist/types/plugin/compiler.d.ts +5 -0
- package/dist/types/plugin/create.d.ts +23 -0
- package/dist/types/plugin/index.d.ts +3 -0
- package/dist/types/plugin/profile.d.ts +2 -0
- package/dist/types/plugin/source.d.ts +1 -0
- package/dist/types/plugin/svg-component-template.d.cts +6 -0
- package/dist/types/router-client.d.ts +12 -0
- package/dist/types/router-external-snapshot.d.ts +10 -0
- package/dist/types/router-handler.d.ts +13 -0
- package/dist/types/router-server-cleanup.d.ts +3 -0
- package/dist/types/router-server-snapshot.d.ts +15 -0
- package/dist/types/router-server.d.ts +11 -0
- package/dist/types/router-snapshot.d.ts +14 -0
- package/dist/types/router.d.ts +30 -0
- package/dist/types/routes.d.ts +20 -0
- package/dist/types/server.d.ts +47 -0
- package/dist/types/typecheck.d.ts +31 -0
- package/dist/types/worker-federation-context.d.ts +34 -0
- package/dist/types/worker-federation-contexts.d.ts +25 -0
- package/dist/types/worker-federation.d.ts +20 -0
- package/package.json +278 -4
- package/src/bootstrap.ts +60 -0
- package/src/client.ts +568 -0
- package/src/entry-application.ts +76 -0
- package/src/entry-client.ts +90 -0
- package/src/entry-server.ts +153 -0
- package/src/federation-context.ts +53 -0
- package/src/federation.ts +307 -0
- package/src/i18n/I18nProvider.ts +47 -0
- package/src/i18n/LocalizedLink.ts +86 -0
- package/src/i18n/context.ts +12 -0
- package/src/i18n/index.ts +31 -0
- package/src/i18n/languageSync.ts +132 -0
- package/src/i18n/types.ts +36 -0
- package/src/i18n/useI18n.ts +119 -0
- package/src/i18n-external-snapshot.ts +803 -0
- package/src/index.ts +10 -0
- package/src/manifest.ts +253 -0
- package/src/plugin/compiler-manifest.cjs +204 -0
- package/src/plugin/compiler.ts +104 -0
- package/src/plugin/create.ts +273 -0
- package/src/plugin/index.ts +107 -0
- package/src/plugin/profile.ts +50 -0
- package/src/plugin/source.ts +16 -0
- package/src/plugin/svg-component-template.cjs +17 -0
- package/src/router-client.ts +144 -0
- package/src/router-external-snapshot.ts +363 -0
- package/src/router-handler.ts +185 -0
- package/src/router-server-cleanup.ts +11 -0
- package/src/router-server-snapshot.ts +564 -0
- package/src/router-server.ts +21 -0
- package/src/router-snapshot.ts +251 -0
- package/src/router.ts +192 -0
- package/src/routes.ts +274 -0
- package/src/server.ts +340 -0
- package/src/typecheck.ts +723 -0
- package/src/worker-federation-context.ts +51 -0
- package/src/worker-federation-contexts.ts +91 -0
- package/src/worker-federation.ts +120 -0
- package/README.md +0 -3
|
@@ -0,0 +1,615 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
+
})();
|
|
27
|
+
(()=>{
|
|
28
|
+
__webpack_require__.r = (exports1)=>{
|
|
29
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
30
|
+
value: 'Module'
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
33
|
+
value: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
var __webpack_exports__ = {};
|
|
38
|
+
__webpack_require__.r(__webpack_exports__);
|
|
39
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
+
checkOctaneProject: ()=>checkOctaneProject,
|
|
41
|
+
formatOctaneDiagnostic: ()=>formatOctaneDiagnostic,
|
|
42
|
+
runOctaneTypecheck: ()=>runOctaneTypecheck
|
|
43
|
+
});
|
|
44
|
+
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
45
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
46
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
47
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
48
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
49
|
+
const language_core_namespaceObject = require("@volar/language-core");
|
|
50
|
+
const external_jsonc_parser_namespaceObject = require("jsonc-parser");
|
|
51
|
+
const volar_namespaceObject = require("octane/compiler/volar");
|
|
52
|
+
const external_typescript_namespaceObject = require("typescript");
|
|
53
|
+
const fs_namespaceObject = require("typescript/unstable/fs");
|
|
54
|
+
const sync_namespaceObject = require("typescript/unstable/sync");
|
|
55
|
+
const nativeExtension = /\.tsrx$/u;
|
|
56
|
+
const projectedExtension = /\.tsrx\.tsx$/u;
|
|
57
|
+
function typecheck_location(source, pos) {
|
|
58
|
+
const prefix = source.slice(0, pos);
|
|
59
|
+
const lines = prefix.split(/\r\n|\r|\n/u);
|
|
60
|
+
return {
|
|
61
|
+
line: lines.length,
|
|
62
|
+
column: (lines.at(-1)?.length ?? 0) + 1
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function readFile(file) {
|
|
66
|
+
try {
|
|
67
|
+
return external_node_fs_default().readFileSync(file, 'utf8');
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (error instanceof Error && 'code' in error && ('ENOENT' === error.code || 'ENOTDIR' === error.code)) return;
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function projectConfig(source, fileName, discovery, roots) {
|
|
74
|
+
const errors = [];
|
|
75
|
+
const config = (0, external_jsonc_parser_namespaceObject.parseTree)(source.replace(/^\uFEFF/u, ' '), errors, {
|
|
76
|
+
allowTrailingComma: true
|
|
77
|
+
});
|
|
78
|
+
if (errors.length || !config || 'object' !== config.type) return;
|
|
79
|
+
const edits = [];
|
|
80
|
+
const additions = [];
|
|
81
|
+
for (const field of [
|
|
82
|
+
'files',
|
|
83
|
+
'include',
|
|
84
|
+
'exclude'
|
|
85
|
+
]){
|
|
86
|
+
const array = (0, external_jsonc_parser_namespaceObject.findNodeAtLocation)(config, [
|
|
87
|
+
field
|
|
88
|
+
]);
|
|
89
|
+
if (roots) {
|
|
90
|
+
const content = JSON.stringify('files' === field ? roots : []);
|
|
91
|
+
if (array) {
|
|
92
|
+
if ('array' === array.type && (array.children ?? []).every((node)=>'string' === node.type)) edits.push({
|
|
93
|
+
offset: array.offset,
|
|
94
|
+
length: array.length,
|
|
95
|
+
content
|
|
96
|
+
});
|
|
97
|
+
} else additions.push(`${JSON.stringify(field)}:${content}`);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (array?.type === 'array') for (const node of array.children ?? []){
|
|
101
|
+
const file = (0, external_jsonc_parser_namespaceObject.getNodeValue)(node);
|
|
102
|
+
if ('string' != typeof file) continue;
|
|
103
|
+
const projected = 'files' === field || 'complete' === discovery ? nativeExtension.test(file) ? `${file}.tsx` : file : 'native' === discovery && /[.*?]/u.test(file.replaceAll('\\', '/').split('/').at(-1) ?? '') ? `${file.endsWith('/**') ? `${file}/*` : file}.tsx` : file;
|
|
104
|
+
if (projected !== file) edits.push({
|
|
105
|
+
offset: node.offset,
|
|
106
|
+
length: node.length,
|
|
107
|
+
content: JSON.stringify(projected)
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (additions.length) edits.push({
|
|
112
|
+
offset: config.offset + 1,
|
|
113
|
+
length: 0,
|
|
114
|
+
content: `${additions.join(',')}${config.children?.length ? ',' : ''}`
|
|
115
|
+
});
|
|
116
|
+
if (!edits.length) return;
|
|
117
|
+
const mappings = [];
|
|
118
|
+
let sourceOffset = 0;
|
|
119
|
+
let code = '';
|
|
120
|
+
for (const edit of edits.sort((left, right)=>left.offset - right.offset)){
|
|
121
|
+
const unchanged = source.slice(sourceOffset, edit.offset);
|
|
122
|
+
mappings.push({
|
|
123
|
+
sourceOffsets: [
|
|
124
|
+
sourceOffset
|
|
125
|
+
],
|
|
126
|
+
generatedOffsets: [
|
|
127
|
+
code.length
|
|
128
|
+
],
|
|
129
|
+
lengths: [
|
|
130
|
+
unchanged.length
|
|
131
|
+
],
|
|
132
|
+
data: {
|
|
133
|
+
verification: true
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
code += unchanged;
|
|
137
|
+
mappings.push({
|
|
138
|
+
sourceOffsets: [
|
|
139
|
+
edit.offset
|
|
140
|
+
],
|
|
141
|
+
generatedOffsets: [
|
|
142
|
+
code.length
|
|
143
|
+
],
|
|
144
|
+
lengths: [
|
|
145
|
+
edit.length
|
|
146
|
+
],
|
|
147
|
+
generatedLengths: [
|
|
148
|
+
edit.content.length
|
|
149
|
+
],
|
|
150
|
+
data: {
|
|
151
|
+
verification: true
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
code += edit.content;
|
|
155
|
+
sourceOffset = edit.offset + edit.length;
|
|
156
|
+
}
|
|
157
|
+
mappings.push({
|
|
158
|
+
sourceOffsets: [
|
|
159
|
+
sourceOffset
|
|
160
|
+
],
|
|
161
|
+
generatedOffsets: [
|
|
162
|
+
code.length
|
|
163
|
+
],
|
|
164
|
+
lengths: [
|
|
165
|
+
source.length - sourceOffset
|
|
166
|
+
],
|
|
167
|
+
data: {
|
|
168
|
+
verification: true
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
code += source.slice(sourceOffset);
|
|
172
|
+
return {
|
|
173
|
+
source,
|
|
174
|
+
fileName,
|
|
175
|
+
code,
|
|
176
|
+
map: new language_core_namespaceObject.SourceMap(mappings)
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function diagnosticText(diagnostic) {
|
|
180
|
+
return [
|
|
181
|
+
diagnostic.text,
|
|
182
|
+
...diagnostic.messageChain?.map(diagnosticText) ?? []
|
|
183
|
+
].join('\n');
|
|
184
|
+
}
|
|
185
|
+
function checkOctaneProject(options) {
|
|
186
|
+
if ('7.0.2' !== external_typescript_namespaceObject.version) throw new Error(`Octane typechecking requires TypeScript 7.0.2; found ${external_typescript_namespaceObject.version}`);
|
|
187
|
+
const cwd = external_node_path_default().resolve(options.cwd ?? process.cwd());
|
|
188
|
+
let project = external_node_path_default().resolve(cwd, options.project);
|
|
189
|
+
if (external_node_fs_default().existsSync(project) && external_node_fs_default().statSync(project).isDirectory()) project = external_node_path_default().join(project, 'tsconfig.json');
|
|
190
|
+
if (!external_node_fs_default().existsSync(project)) throw new Error(`Cannot find project ${project}`);
|
|
191
|
+
if (options.compilerOptions?.noEmit === false || options.compilerOptions?.noCheck === true || options.compilerOptions?.skipLibCheck === true || options.compilerOptions?.skipDefaultLibCheck === true) throw new Error('Octane typechecking requires noEmit, full checking, and library checking');
|
|
192
|
+
const effectiveConfig = external_node_path_default().join(external_node_path_default().dirname(project), `.octane-typecheck-${(0, external_node_crypto_namespaceObject.randomUUID)()}.json`);
|
|
193
|
+
const authoredConfig = (0, external_jsonc_parser_namespaceObject.parse)((readFile(project) ?? '').replace(/^\uFEFF/u, ' '), [], {
|
|
194
|
+
allowTrailingComma: true
|
|
195
|
+
});
|
|
196
|
+
const effectiveOptions = {
|
|
197
|
+
extends: project,
|
|
198
|
+
...Array.isArray(authoredConfig?.references) ? {
|
|
199
|
+
references: authoredConfig.references
|
|
200
|
+
} : {},
|
|
201
|
+
compilerOptions: {
|
|
202
|
+
...options.compilerOptions,
|
|
203
|
+
noEmit: true,
|
|
204
|
+
noCheck: false,
|
|
205
|
+
skipLibCheck: false,
|
|
206
|
+
skipDefaultLibCheck: false
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
const virtual = (0, fs_namespaceObject.createVirtualFileSystem)({
|
|
210
|
+
[effectiveConfig]: JSON.stringify(effectiveOptions)
|
|
211
|
+
});
|
|
212
|
+
const projections = new Map();
|
|
213
|
+
const configurations = new Map();
|
|
214
|
+
const configFiles = new Set([
|
|
215
|
+
project
|
|
216
|
+
]);
|
|
217
|
+
const referencedConfigs = new Set([
|
|
218
|
+
project
|
|
219
|
+
]);
|
|
220
|
+
const referenceRoots = new Map();
|
|
221
|
+
let discovery = 'ordinary';
|
|
222
|
+
function authoredName(file) {
|
|
223
|
+
if (!projectedExtension.test(file)) return file;
|
|
224
|
+
const authored = file.slice(0, -4);
|
|
225
|
+
if (!external_node_fs_default().existsSync(authored)) return file;
|
|
226
|
+
if (external_node_fs_default().existsSync(file)) throw new Error(`Octane projection collision: ${authored} conflicts with physical ${file}`);
|
|
227
|
+
return authored;
|
|
228
|
+
}
|
|
229
|
+
function projection(file) {
|
|
230
|
+
const fileName = authoredName(file);
|
|
231
|
+
if (fileName === file) return;
|
|
232
|
+
const known = projections.get(file);
|
|
233
|
+
if (known) return known;
|
|
234
|
+
const source = readFile(fileName);
|
|
235
|
+
if (void 0 === source) return;
|
|
236
|
+
let compiled;
|
|
237
|
+
try {
|
|
238
|
+
compiled = (0, volar_namespaceObject.compileToVolarMappings)(source, fileName, {
|
|
239
|
+
loose: true
|
|
240
|
+
});
|
|
241
|
+
} catch (error) {
|
|
242
|
+
if (!(error instanceof SyntaxError)) throw error;
|
|
243
|
+
compiled = {
|
|
244
|
+
code: 'export {};',
|
|
245
|
+
mappings: [],
|
|
246
|
+
diagnostics: [],
|
|
247
|
+
errors: [
|
|
248
|
+
{
|
|
249
|
+
name: error.name,
|
|
250
|
+
message: error.message,
|
|
251
|
+
fileName,
|
|
252
|
+
type: 'fatal',
|
|
253
|
+
...'pos' in error && 'number' == typeof error.pos ? {
|
|
254
|
+
pos: error.pos
|
|
255
|
+
} : {},
|
|
256
|
+
...'end' in error && 'number' == typeof error.end ? {
|
|
257
|
+
end: error.end
|
|
258
|
+
} : {}
|
|
259
|
+
}
|
|
260
|
+
]
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
const result = {
|
|
264
|
+
...compiled,
|
|
265
|
+
source,
|
|
266
|
+
fileName,
|
|
267
|
+
map: new language_core_namespaceObject.SourceMap(compiled.mappings)
|
|
268
|
+
};
|
|
269
|
+
projections.set(file, result);
|
|
270
|
+
virtual.writeFile?.(file, compiled.code);
|
|
271
|
+
return result;
|
|
272
|
+
}
|
|
273
|
+
const overlay = {
|
|
274
|
+
readFile (file) {
|
|
275
|
+
const content = virtual.readFile?.(file);
|
|
276
|
+
if (void 0 !== content) return content;
|
|
277
|
+
const compiled = projection(file);
|
|
278
|
+
if (compiled) return compiled.code;
|
|
279
|
+
if (file.endsWith('.json')) {
|
|
280
|
+
const source = readFile(file);
|
|
281
|
+
if (void 0 !== source) {
|
|
282
|
+
if (!configFiles.has(file) && ('complete' === discovery || 'package.json' === external_node_path_default().basename(file))) return source;
|
|
283
|
+
configFiles.add(file);
|
|
284
|
+
const configData = (0, external_jsonc_parser_namespaceObject.parse)(source.replace(/^\uFEFF/u, ' '), [], {
|
|
285
|
+
allowTrailingComma: true
|
|
286
|
+
});
|
|
287
|
+
for (const reference of referencedConfigs.has(file) && Array.isArray(configData?.references) ? configData.references : []){
|
|
288
|
+
if ('string' != typeof reference?.path) continue;
|
|
289
|
+
const target = external_node_path_default().resolve(external_node_path_default().dirname(file), reference.path);
|
|
290
|
+
const referenceFile = target.endsWith('.json') ? target : external_node_path_default().join(target, 'tsconfig.json');
|
|
291
|
+
configFiles.add(referenceFile);
|
|
292
|
+
referencedConfigs.add(referenceFile);
|
|
293
|
+
}
|
|
294
|
+
const roots = 'complete' === discovery ? referenceRoots.get(file) : void 0;
|
|
295
|
+
const config = projectConfig(source, file, discovery, roots ? [
|
|
296
|
+
...roots
|
|
297
|
+
] : void 0);
|
|
298
|
+
if (config) configurations.set(file, config);
|
|
299
|
+
else configurations.delete(file);
|
|
300
|
+
return config?.code ?? source;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
fileExists (file) {
|
|
305
|
+
if (virtual.fileExists?.(file)) return true;
|
|
306
|
+
if (authoredName(file) !== file) return true;
|
|
307
|
+
},
|
|
308
|
+
directoryExists (directory) {
|
|
309
|
+
return virtual.directoryExists?.(directory) || void 0;
|
|
310
|
+
},
|
|
311
|
+
getAccessibleEntries (directory) {
|
|
312
|
+
const files = new Set(virtual.getAccessibleEntries?.(directory)?.files);
|
|
313
|
+
const directories = new Set(virtual.getAccessibleEntries?.(directory)?.directories);
|
|
314
|
+
try {
|
|
315
|
+
for (const entry of external_node_fs_default().readdirSync(directory, {
|
|
316
|
+
withFileTypes: true
|
|
317
|
+
})){
|
|
318
|
+
let isDirectory = entry.isDirectory();
|
|
319
|
+
if (entry.isSymbolicLink()) try {
|
|
320
|
+
isDirectory = external_node_fs_default().statSync(external_node_path_default().join(directory, entry.name)).isDirectory();
|
|
321
|
+
} catch (error) {
|
|
322
|
+
if (error instanceof Error && 'code' in error && ('ENOENT' === error.code || 'ENOTDIR' === error.code)) continue;
|
|
323
|
+
throw error;
|
|
324
|
+
}
|
|
325
|
+
if (isDirectory) directories.add(entry.name);
|
|
326
|
+
else {
|
|
327
|
+
files.add(entry.name);
|
|
328
|
+
if (nativeExtension.test(entry.name)) {
|
|
329
|
+
const projected = external_node_path_default().join(directory, `${entry.name}.tsx`);
|
|
330
|
+
authoredName(projected);
|
|
331
|
+
files.add(`${entry.name}.tsx`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
} catch (error) {
|
|
336
|
+
if (!(error instanceof Error && 'code' in error && ('ENOENT' === error.code || 'ENOTDIR' === error.code))) throw error;
|
|
337
|
+
}
|
|
338
|
+
return {
|
|
339
|
+
files: [
|
|
340
|
+
...files
|
|
341
|
+
].filter((file)=>'ordinary' !== discovery || authoredName(external_node_path_default().join(directory, file)) === external_node_path_default().join(directory, file)).sort(),
|
|
342
|
+
directories: [
|
|
343
|
+
...directories
|
|
344
|
+
].sort()
|
|
345
|
+
};
|
|
346
|
+
},
|
|
347
|
+
realpath (file) {
|
|
348
|
+
const authored = authoredName(file);
|
|
349
|
+
if (authored !== file) try {
|
|
350
|
+
return `${external_node_fs_default().realpathSync(authored)}.tsx`;
|
|
351
|
+
} catch {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
return virtual.fileExists?.(file) ? file : void 0;
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
const roots = new Set();
|
|
358
|
+
for (const mode of [
|
|
359
|
+
'ordinary',
|
|
360
|
+
'native'
|
|
361
|
+
]){
|
|
362
|
+
discovery = mode;
|
|
363
|
+
const parser = new sync_namespaceObject.API({
|
|
364
|
+
cwd,
|
|
365
|
+
fs: overlay
|
|
366
|
+
});
|
|
367
|
+
try {
|
|
368
|
+
for (const file of parser.parseConfigFile(effectiveConfig).fileNames)if ('ordinary' === mode || authoredName(file) !== file) roots.add(file);
|
|
369
|
+
const parsedReferences = new Set([
|
|
370
|
+
project
|
|
371
|
+
]);
|
|
372
|
+
for (const reference of referencedConfigs){
|
|
373
|
+
if (parsedReferences.has(reference)) continue;
|
|
374
|
+
parsedReferences.add(reference);
|
|
375
|
+
const selected = referenceRoots.get(reference) ?? new Set();
|
|
376
|
+
referenceRoots.set(reference, selected);
|
|
377
|
+
for (const file of parser.parseConfigFile(reference).fileNames)if ('ordinary' === mode || authoredName(file) !== file) selected.add(file);
|
|
378
|
+
}
|
|
379
|
+
} finally{
|
|
380
|
+
parser.close();
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
discovery = 'complete';
|
|
384
|
+
virtual.writeFile?.(effectiveConfig, JSON.stringify({
|
|
385
|
+
...effectiveOptions,
|
|
386
|
+
files: [
|
|
387
|
+
...roots
|
|
388
|
+
],
|
|
389
|
+
include: [],
|
|
390
|
+
exclude: []
|
|
391
|
+
}));
|
|
392
|
+
const api = new sync_namespaceObject.API({
|
|
393
|
+
cwd,
|
|
394
|
+
fs: overlay
|
|
395
|
+
});
|
|
396
|
+
try {
|
|
397
|
+
const snapshot = api.updateSnapshot({
|
|
398
|
+
openProjects: [
|
|
399
|
+
effectiveConfig
|
|
400
|
+
],
|
|
401
|
+
openFiles: [
|
|
402
|
+
...roots
|
|
403
|
+
]
|
|
404
|
+
});
|
|
405
|
+
const program = snapshot.getProject(effectiveConfig)?.program;
|
|
406
|
+
if (!program) throw new Error(`Native TypeScript did not load project ${project}`);
|
|
407
|
+
function remap(diagnostic) {
|
|
408
|
+
const relatedInformation = diagnostic.relatedInformation?.flatMap((info)=>{
|
|
409
|
+
const mapped = remap(info);
|
|
410
|
+
return mapped ? [
|
|
411
|
+
mapped
|
|
412
|
+
] : [];
|
|
413
|
+
});
|
|
414
|
+
const text = diagnosticText(diagnostic);
|
|
415
|
+
const compiled = diagnostic.fileName ? projections.get(diagnostic.fileName) ?? configurations.get(diagnostic.fileName) : void 0;
|
|
416
|
+
let pos = diagnostic.pos;
|
|
417
|
+
let end = diagnostic.end;
|
|
418
|
+
let origin = "typescript";
|
|
419
|
+
let message = text;
|
|
420
|
+
if (compiled) {
|
|
421
|
+
const ranges = compiled.map.toSourceRange(pos, end, true, (info)=>(0, language_core_namespaceObject.shouldReportDiagnostics)(info, void 0, diagnostic.code));
|
|
422
|
+
const range = ranges.next().value;
|
|
423
|
+
if (range) [pos, end] = range;
|
|
424
|
+
else {
|
|
425
|
+
if (!compiled.map.toSourceRange(pos, end, true).next().done) return;
|
|
426
|
+
origin = 'projection';
|
|
427
|
+
message = `Cannot map native TS${diagnostic.code} at generated offsets ${pos}-${end}: ${text}`;
|
|
428
|
+
pos = 0;
|
|
429
|
+
end = 0;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
const fileName = compiled?.fileName ?? (diagnostic.fileName === effectiveConfig ? void 0 : diagnostic.fileName);
|
|
433
|
+
const source = compiled?.source ?? (fileName ? readFile(fileName) : void 0);
|
|
434
|
+
return {
|
|
435
|
+
...fileName ? {
|
|
436
|
+
fileName
|
|
437
|
+
} : {},
|
|
438
|
+
pos,
|
|
439
|
+
end,
|
|
440
|
+
...void 0 !== source ? typecheck_location(source, pos) : {},
|
|
441
|
+
code: diagnostic.code,
|
|
442
|
+
category: 'projection' === origin || 1 === diagnostic.category ? 'error' : 0 === diagnostic.category ? 'warning' : 'message',
|
|
443
|
+
text: message,
|
|
444
|
+
origin,
|
|
445
|
+
...relatedInformation?.length ? {
|
|
446
|
+
relatedInformation
|
|
447
|
+
} : {}
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
const diagnostics = [
|
|
451
|
+
...program.getConfigFileParsingDiagnostics(),
|
|
452
|
+
...program.getProgramDiagnostics(),
|
|
453
|
+
...program.getGlobalDiagnostics(),
|
|
454
|
+
...program.getSyntacticDiagnostics(),
|
|
455
|
+
...program.getBindDiagnostics(),
|
|
456
|
+
...program.getSemanticDiagnostics()
|
|
457
|
+
].flatMap((diagnostic)=>{
|
|
458
|
+
const mapped = remap(diagnostic);
|
|
459
|
+
return mapped ? [
|
|
460
|
+
mapped
|
|
461
|
+
] : [];
|
|
462
|
+
});
|
|
463
|
+
const nativeFiles = program.getSourceFileNames();
|
|
464
|
+
for (const file of nativeFiles){
|
|
465
|
+
const compiled = projections.get(file);
|
|
466
|
+
if (compiled) {
|
|
467
|
+
for (const diagnostic of compiled.diagnostics)diagnostics.push({
|
|
468
|
+
fileName: compiled.fileName,
|
|
469
|
+
pos: diagnostic.start.offset,
|
|
470
|
+
end: diagnostic.end.offset,
|
|
471
|
+
...typecheck_location(compiled.source, diagnostic.start.offset),
|
|
472
|
+
code: diagnostic.code,
|
|
473
|
+
category: 'error' === diagnostic.severity ? 'error' : 'warning' === diagnostic.severity ? 'warning' : 'message',
|
|
474
|
+
text: diagnostic.message,
|
|
475
|
+
origin: 'octane'
|
|
476
|
+
});
|
|
477
|
+
for (const error of compiled.errors){
|
|
478
|
+
const pos = error.pos ?? 0;
|
|
479
|
+
diagnostics.push({
|
|
480
|
+
fileName: compiled.fileName,
|
|
481
|
+
pos,
|
|
482
|
+
end: error.end ?? pos,
|
|
483
|
+
...typecheck_location(compiled.source, pos),
|
|
484
|
+
code: 'OCTANE_PARSE',
|
|
485
|
+
category: 'error',
|
|
486
|
+
text: error.message,
|
|
487
|
+
origin: 'octane'
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
const unique = new Map(diagnostics.map((diagnostic)=>[
|
|
493
|
+
JSON.stringify(diagnostic),
|
|
494
|
+
diagnostic
|
|
495
|
+
]));
|
|
496
|
+
return {
|
|
497
|
+
compilerVersion: external_typescript_namespaceObject.version,
|
|
498
|
+
files: [
|
|
499
|
+
...new Set(nativeFiles.map((file)=>projections.get(file)?.fileName ?? file))
|
|
500
|
+
].sort(),
|
|
501
|
+
diagnostics: [
|
|
502
|
+
...unique.values()
|
|
503
|
+
].sort((left, right)=>(left.fileName ?? '').localeCompare(right.fileName ?? '') || left.pos - right.pos || String(left.code).localeCompare(String(right.code)))
|
|
504
|
+
};
|
|
505
|
+
} finally{
|
|
506
|
+
api.close();
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
function formatOctaneDiagnostic(diagnostic, cwd = process.cwd()) {
|
|
510
|
+
const file = diagnostic.fileName ? `${external_node_path_default().relative(cwd, diagnostic.fileName)}(${diagnostic.line ?? 1},${diagnostic.column ?? 1}): ` : '';
|
|
511
|
+
const code = 'number' == typeof diagnostic.code ? `TS${diagnostic.code}` : diagnostic.code;
|
|
512
|
+
const related = diagnostic.relatedInformation?.map((info)=>` ${formatOctaneDiagnostic(info, cwd)}`).join('\n');
|
|
513
|
+
return `${file}${diagnostic.category} ${code}: ${diagnostic.text}${related ? `\n${related}` : ''}`;
|
|
514
|
+
}
|
|
515
|
+
const booleanOptions = new Set([
|
|
516
|
+
'strict',
|
|
517
|
+
'isolatedModules',
|
|
518
|
+
'verbatimModuleSyntax',
|
|
519
|
+
'allowImportingTsExtensions',
|
|
520
|
+
'allowJs',
|
|
521
|
+
'esModuleInterop',
|
|
522
|
+
'noUncheckedIndexedAccess',
|
|
523
|
+
'exactOptionalPropertyTypes',
|
|
524
|
+
'noImplicitOverride',
|
|
525
|
+
'noFallthroughCasesInSwitch',
|
|
526
|
+
'noPropertyAccessFromIndexSignature',
|
|
527
|
+
'noImplicitReturns',
|
|
528
|
+
'resolveJsonModule',
|
|
529
|
+
'strictNullChecks',
|
|
530
|
+
'strictFunctionTypes',
|
|
531
|
+
'strictBindCallApply',
|
|
532
|
+
'strictPropertyInitialization',
|
|
533
|
+
'noImplicitAny',
|
|
534
|
+
'noImplicitThis',
|
|
535
|
+
'useUnknownInCatchVariables',
|
|
536
|
+
'alwaysStrict'
|
|
537
|
+
]);
|
|
538
|
+
const stringOptions = new Set([
|
|
539
|
+
'target',
|
|
540
|
+
'module',
|
|
541
|
+
'moduleResolution',
|
|
542
|
+
'moduleDetection',
|
|
543
|
+
'jsx',
|
|
544
|
+
'jsxImportSource'
|
|
545
|
+
]);
|
|
546
|
+
function runOctaneTypecheck(argv, io = {}) {
|
|
547
|
+
const stdout = io.stdout ?? ((text)=>process.stdout.write(text));
|
|
548
|
+
const stderr = io.stderr ?? ((text)=>process.stderr.write(text));
|
|
549
|
+
try {
|
|
550
|
+
let project = 'tsconfig.json';
|
|
551
|
+
let listFiles = false;
|
|
552
|
+
const compilerOptions = {};
|
|
553
|
+
for(let index = 0; index < argv.length; index++){
|
|
554
|
+
const argument = argv[index];
|
|
555
|
+
if ('--version' === argument || '-v' === argument) {
|
|
556
|
+
stdout(`Version ${external_typescript_namespaceObject.version}\n`);
|
|
557
|
+
return 0;
|
|
558
|
+
}
|
|
559
|
+
if ('--help' === argument || '-h' === argument) {
|
|
560
|
+
stdout('octane-tsc --project <tsconfig.json> [--noEmit] [--strict]\n');
|
|
561
|
+
return 0;
|
|
562
|
+
}
|
|
563
|
+
if ('--project' === argument || '-p' === argument) {
|
|
564
|
+
const value = argv[++index];
|
|
565
|
+
if (!value || value.startsWith('-')) throw new Error('--project requires a configuration path');
|
|
566
|
+
project = value;
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
if (!argument?.startsWith('--')) throw new Error(`Unsupported Octane typecheck argument ${argument}`);
|
|
570
|
+
const name = argument.slice(2);
|
|
571
|
+
if (booleanOptions.has(name) || [
|
|
572
|
+
'noEmit',
|
|
573
|
+
'noCheck',
|
|
574
|
+
'skipLibCheck',
|
|
575
|
+
'skipDefaultLibCheck',
|
|
576
|
+
'pretty',
|
|
577
|
+
'listFiles',
|
|
578
|
+
'explainFiles'
|
|
579
|
+
].includes(name)) {
|
|
580
|
+
const explicit = argv[index + 1];
|
|
581
|
+
const value = 'true' === explicit || 'false' === explicit ? 'true' === argv[++index] : true;
|
|
582
|
+
if ('noEmit' === name && !value || ('noCheck' === name || 'skipLibCheck' === name || 'skipDefaultLibCheck' === name) && value) throw new Error(`--${name} ${value} is incompatible with full Octane typechecking`);
|
|
583
|
+
if ('listFiles' === name || 'explainFiles' === name) listFiles ||= value;
|
|
584
|
+
else if ('pretty' !== name) compilerOptions[name] = value;
|
|
585
|
+
} else if (stringOptions.has(name) || 'lib' === name || 'types' === name) {
|
|
586
|
+
const value = argv[++index];
|
|
587
|
+
if (!value || value.startsWith('-')) throw new Error(`--${name} requires a value`);
|
|
588
|
+
compilerOptions[name] = 'lib' === name || 'types' === name ? value.split(',') : value;
|
|
589
|
+
} else throw new Error(`Unsupported Octane typecheck option --${name}`);
|
|
590
|
+
}
|
|
591
|
+
const cwd = external_node_path_default().resolve(io.cwd ?? process.cwd());
|
|
592
|
+
const result = checkOctaneProject({
|
|
593
|
+
project,
|
|
594
|
+
cwd,
|
|
595
|
+
compilerOptions
|
|
596
|
+
});
|
|
597
|
+
for (const diagnostic of result.diagnostics)stdout(`${formatOctaneDiagnostic(diagnostic, cwd)}\n`);
|
|
598
|
+
if (listFiles) for (const file of result.files)stdout(`${file}\n`);
|
|
599
|
+
return result.diagnostics.some((diagnostic)=>'error' === diagnostic.category) ? 1 : 0;
|
|
600
|
+
} catch (error) {
|
|
601
|
+
stderr(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
602
|
+
return 1;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
exports.checkOctaneProject = __webpack_exports__.checkOctaneProject;
|
|
606
|
+
exports.formatOctaneDiagnostic = __webpack_exports__.formatOctaneDiagnostic;
|
|
607
|
+
exports.runOctaneTypecheck = __webpack_exports__.runOctaneTypecheck;
|
|
608
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
609
|
+
"checkOctaneProject",
|
|
610
|
+
"formatOctaneDiagnostic",
|
|
611
|
+
"runOctaneTypecheck"
|
|
612
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
613
|
+
Object.defineProperty(exports, '__esModule', {
|
|
614
|
+
value: true
|
|
615
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
WorkerFederationApplication: ()=>WorkerFederationApplication,
|
|
32
|
+
WorkerFederationContext: ()=>WorkerFederationContext,
|
|
33
|
+
WorkerFederationRoot: ()=>WorkerFederationRoot
|
|
34
|
+
});
|
|
35
|
+
const external_octane_namespaceObject = require("octane");
|
|
36
|
+
const external_federation_context_js_namespaceObject = require("./federation-context.js");
|
|
37
|
+
const WorkerFederationContext = (0, external_octane_namespaceObject.createContext)(null);
|
|
38
|
+
function WorkerFederationRoot(props) {
|
|
39
|
+
return (0, external_octane_namespaceObject.createElement)(WorkerFederationContext, {
|
|
40
|
+
value: props.scope,
|
|
41
|
+
children: props.children
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function WorkerFederationApplication(props) {
|
|
45
|
+
return (0, external_octane_namespaceObject.createElement)(WorkerFederationRoot, {
|
|
46
|
+
scope: props.scope,
|
|
47
|
+
children: props.federation ? (0, external_octane_namespaceObject.createElement)(external_federation_context_js_namespaceObject.FederationApplication, {
|
|
48
|
+
scope: props.federation,
|
|
49
|
+
application: props.application
|
|
50
|
+
}) : (0, external_octane_namespaceObject.createElement)(props.application.default, props.application.props)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
exports.WorkerFederationApplication = __webpack_exports__.WorkerFederationApplication;
|
|
54
|
+
exports.WorkerFederationContext = __webpack_exports__.WorkerFederationContext;
|
|
55
|
+
exports.WorkerFederationRoot = __webpack_exports__.WorkerFederationRoot;
|
|
56
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
57
|
+
"WorkerFederationApplication",
|
|
58
|
+
"WorkerFederationContext",
|
|
59
|
+
"WorkerFederationRoot"
|
|
60
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
61
|
+
Object.defineProperty(exports, '__esModule', {
|
|
62
|
+
value: true
|
|
63
|
+
});
|