@octane-xplat/build 0.0.0-nightly.g1b95ef7
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 +5 -0
- package/dist/add-worker.js +66 -0
- package/dist/build-worker.js +287 -0
- package/dist/compatibility-check.js +155 -0
- package/dist/compatibility-data/compatibility.js +109 -0
- package/dist/compatibility-data/compatibility.json +298 -0
- package/dist/compatibility.js +240 -0
- package/dist/css-platform.js +236 -0
- package/dist/css-platform.types.d.ts +11 -0
- package/dist/dev-inspector.web.js +125 -0
- package/dist/dev-log-client.web.js +79 -0
- package/dist/dev-log-server.js +13 -0
- package/dist/devtools-worker.js +94 -0
- package/dist/doctor-checks.js +414 -0
- package/dist/doctor-tool.js +27 -0
- package/dist/env.js +3 -0
- package/dist/fmt-plan.js +149 -0
- package/dist/fonts-worker.js +31 -0
- package/dist/fonts.js +614 -0
- package/dist/inline-stylesheets.js +44 -0
- package/dist/linux/config.js +43 -0
- package/dist/linux/gtk-runtime.js +86 -0
- package/dist/linux/package.js +189 -0
- package/dist/linux-gtk/bindings.mjs +675 -0
- package/dist/linux-gtk/native-gi-projection.js +36 -0
- package/dist/linux-gtk/vite.d.ts +39 -0
- package/dist/linux-gtk/vite.js +281 -0
- package/dist/macos/config.js +136 -0
- package/dist/macos/core-ui.js +59 -0
- package/dist/macos/core-vite.js +122 -0
- package/dist/macos/doctor-checks.js +58 -0
- package/dist/macos/executables.js +39 -0
- package/dist/macos/jsc-host/runtime.js +134 -0
- package/dist/macos/native.js +286 -0
- package/dist/macos/runtime-package.js +30 -0
- package/dist/macos/tab-item.js +62 -0
- package/dist/macos/vite.d.ts +13 -0
- package/dist/macos/vite.js +22 -0
- package/dist/markdown.js +11 -0
- package/dist/mason-engine.js +20 -0
- package/dist/mcp/contracts/actions.js +133 -0
- package/dist/mcp/dev-bridge.js +363 -0
- package/dist/mcp/dev-socket.js +203 -0
- package/dist/mcp/dev-stack.js +134 -0
- package/dist/mcp/inspection/dom.web.js +46 -0
- package/dist/native-regex.js +123 -0
- package/dist/package-manager.js +106 -0
- package/dist/package-root.js +48 -0
- package/dist/patches.js +356 -0
- package/dist/route-config.js +53 -0
- package/dist/route-data.js +42 -0
- package/dist/route-generator.js +514 -0
- package/dist/route-path.js +29 -0
- package/dist/route-source.js +67 -0
- package/dist/targets.js +37 -0
- package/dist/tsconfig-envs.js +400 -0
- package/dist/tsconfig-pin.js +31 -0
- package/dist/tsrx-leaf.js +57 -0
- package/dist/typecheck-globals/macos.d.ts +21 -0
- package/dist/typecheck-globals/native.d.ts +42 -0
- package/dist/ui/src/markdown/markdown-ast.js +33 -0
- package/dist/ui/src/markdown/markdown-character-references.js +79 -0
- package/dist/ui/src/markdown/markdown-parse.js +1930 -0
- package/dist/ui/src/markdown/markdown-plugins.js +564 -0
- package/dist/ui/src/markdown/markdown-url.js +17 -0
- package/dist/updates-worker.js +34 -0
- package/dist/upgrade-worker.js +63 -0
- package/dist/vite-target.js +57 -0
- package/dist/vite.d.ts +125 -0
- package/dist/vite.js +797 -0
- package/dist/workshop-worker.js +181 -0
- package/package.json +74 -0
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { srcUrl } from "./env.js";
|
|
2
|
+
import { existsSync, globSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { parse as parse$1, printParseErrorCode } from "jsonc-parser";
|
|
7
|
+
// ../cli/src/tsconfig-envs.ts
|
|
8
|
+
var MODULE_DIR = fileURLToPath(srcUrl(import.meta.url, ""));
|
|
9
|
+
var ENV_MANIFEST = "tsconfig.envs.json";
|
|
10
|
+
/**
|
|
11
|
+
* Directory the environment generator owns at the project root. Its configs
|
|
12
|
+
* and isolation canaries are tracked, so editors discover platform programs
|
|
13
|
+
* right after dependency installation without a typecheck run first.
|
|
14
|
+
*/
|
|
15
|
+
var ENV_PROGRAM_DIR = "xplat-typecheck";
|
|
16
|
+
/**
|
|
17
|
+
* The declaration-emission suffix order: extensionless first, then every platform suffix. Imports
|
|
18
|
+
* bind the unsuffixed default; variant files still enter the program as
|
|
19
|
+
* roots so each is checked against the shared contract.
|
|
20
|
+
*/
|
|
21
|
+
var PLATFORM_MODULE_SUFFIXES = [
|
|
22
|
+
"",
|
|
23
|
+
".web",
|
|
24
|
+
".ios",
|
|
25
|
+
".android",
|
|
26
|
+
".mobile",
|
|
27
|
+
".native",
|
|
28
|
+
".macos",
|
|
29
|
+
".linux",
|
|
30
|
+
".gtk",
|
|
31
|
+
".windows"
|
|
32
|
+
];
|
|
33
|
+
/** Platform resolution and ambient runtime declarations for checking and consumers. */
|
|
34
|
+
var TYPECHECK_ENVIRONMENTS = {
|
|
35
|
+
web: { compilerOptions: {
|
|
36
|
+
jsxImportSource: "@octane-xplat/jsx/dom",
|
|
37
|
+
moduleSuffixes: [".web", ""],
|
|
38
|
+
customConditions: ["web"],
|
|
39
|
+
lib: [
|
|
40
|
+
"ESNext",
|
|
41
|
+
"DOM",
|
|
42
|
+
"DOM.Iterable"
|
|
43
|
+
]
|
|
44
|
+
} },
|
|
45
|
+
native: {
|
|
46
|
+
compilerOptions: {
|
|
47
|
+
jsxImportSource: "@octane-xplat/jsx",
|
|
48
|
+
moduleSuffixes: [
|
|
49
|
+
".ios",
|
|
50
|
+
".android",
|
|
51
|
+
".mobile",
|
|
52
|
+
""
|
|
53
|
+
],
|
|
54
|
+
customConditions: ["native"],
|
|
55
|
+
lib: ["ESNext"]
|
|
56
|
+
},
|
|
57
|
+
ambient: ["typecheck-globals/native.d.ts"]
|
|
58
|
+
},
|
|
59
|
+
ios: {
|
|
60
|
+
compilerOptions: {
|
|
61
|
+
jsxImportSource: "@octane-xplat/jsx",
|
|
62
|
+
moduleSuffixes: [
|
|
63
|
+
".ios",
|
|
64
|
+
".mobile",
|
|
65
|
+
".native",
|
|
66
|
+
""
|
|
67
|
+
],
|
|
68
|
+
customConditions: ["ios", "native"],
|
|
69
|
+
lib: ["ESNext"]
|
|
70
|
+
},
|
|
71
|
+
ambient: ["typecheck-globals/native.d.ts"]
|
|
72
|
+
},
|
|
73
|
+
android: {
|
|
74
|
+
compilerOptions: {
|
|
75
|
+
jsxImportSource: "@octane-xplat/jsx",
|
|
76
|
+
moduleSuffixes: [
|
|
77
|
+
".android",
|
|
78
|
+
".mobile",
|
|
79
|
+
".native",
|
|
80
|
+
""
|
|
81
|
+
],
|
|
82
|
+
customConditions: ["android", "native"],
|
|
83
|
+
lib: ["ESNext"]
|
|
84
|
+
},
|
|
85
|
+
ambient: ["typecheck-globals/native.d.ts"]
|
|
86
|
+
},
|
|
87
|
+
macos: {
|
|
88
|
+
compilerOptions: {
|
|
89
|
+
jsxImportSource: "@octane-xplat/jsx",
|
|
90
|
+
moduleSuffixes: [".macos", ""],
|
|
91
|
+
customConditions: ["macos"],
|
|
92
|
+
lib: ["ESNext"]
|
|
93
|
+
},
|
|
94
|
+
ambient: [
|
|
95
|
+
"typecheck-globals/macos.d.ts",
|
|
96
|
+
"pkg:@octane-xplat/macos-appkit/src/host-globals.d.ts",
|
|
97
|
+
"../../macos-appkit/src/host-globals.d.ts"
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
gtk: {
|
|
101
|
+
compilerOptions: {
|
|
102
|
+
jsxImportSource: "@octane-xplat/jsx",
|
|
103
|
+
moduleSuffixes: [".gtk", ""],
|
|
104
|
+
customConditions: ["gtk", "native"],
|
|
105
|
+
lib: ["ESNext"]
|
|
106
|
+
},
|
|
107
|
+
ambient: ["pkg:@octane-xplat/linux-gtk/dist/host-globals.d.ts", "../../linux-gtk-renderer/src/host-globals.d.ts"]
|
|
108
|
+
},
|
|
109
|
+
windows: {
|
|
110
|
+
compilerOptions: {
|
|
111
|
+
jsxImportSource: "@octane-xplat/jsx",
|
|
112
|
+
moduleSuffixes: [
|
|
113
|
+
".windows",
|
|
114
|
+
".native",
|
|
115
|
+
""
|
|
116
|
+
],
|
|
117
|
+
customConditions: ["windows", "native"],
|
|
118
|
+
lib: ["ESNext"]
|
|
119
|
+
},
|
|
120
|
+
ambient: ["typecheck-globals/native.d.ts"]
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
/** Which environment a platform file suffix belongs to. */
|
|
124
|
+
var SUFFIX_ENV = {
|
|
125
|
+
web: "web",
|
|
126
|
+
ios: "native",
|
|
127
|
+
android: "native",
|
|
128
|
+
mobile: "native",
|
|
129
|
+
native: "native",
|
|
130
|
+
macos: "macos",
|
|
131
|
+
windows: "windows",
|
|
132
|
+
linux: "gtk",
|
|
133
|
+
gtk: "gtk"
|
|
134
|
+
};
|
|
135
|
+
/** Strip // and block comments plus trailing commas so authored tsconfig-style files parse. */
|
|
136
|
+
function parseJsonc(text, path) {
|
|
137
|
+
const errors = [];
|
|
138
|
+
const value = parse$1(text, errors, { allowTrailingComma: true });
|
|
139
|
+
if (errors.length) {
|
|
140
|
+
const error = errors[0];
|
|
141
|
+
throw new Error(`${path}: invalid JSON — ${printParseErrorCode(error.error)} at offset ${error.offset}`);
|
|
142
|
+
}
|
|
143
|
+
return value;
|
|
144
|
+
}
|
|
145
|
+
function loadEnvManifest(dir) {
|
|
146
|
+
const path = join(dir, ENV_MANIFEST);
|
|
147
|
+
if (!existsSync(path)) return null;
|
|
148
|
+
const manifest = parseJsonc(readFileSync(path, "utf8"), path);
|
|
149
|
+
if (!manifest || typeof manifest !== "object" || Array.isArray(manifest)) throw new Error(`${path}: expected a JSON object`);
|
|
150
|
+
const envs = manifest.environments;
|
|
151
|
+
if (!envs || typeof envs !== "object" || Array.isArray(envs) || !Object.keys(envs).length) throw new Error(`${path}: expected a non-empty "environments" object`);
|
|
152
|
+
return {
|
|
153
|
+
path,
|
|
154
|
+
manifest
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
var SOURCE_EXT = /\.(?:ts|tsx|mts|cts|tsrx|js|jsx|mjs|cjs)$/;
|
|
158
|
+
function expandGlobs(dir, patterns, label, { required = true, sourcesOnly = true } = {}) {
|
|
159
|
+
const files = /* @__PURE__ */ new Set();
|
|
160
|
+
for (const pattern of patterns ?? []) {
|
|
161
|
+
let matched;
|
|
162
|
+
try {
|
|
163
|
+
matched = globSync(pattern, { cwd: dir });
|
|
164
|
+
} catch (e) {
|
|
165
|
+
throw new Error(`${label}: bad pattern "${pattern}" — ${e.message}`);
|
|
166
|
+
}
|
|
167
|
+
const keep = sourcesOnly ? matched.filter((rel) => SOURCE_EXT.test(rel)) : matched;
|
|
168
|
+
if (required && !keep.length) throw new Error(`${label}: pattern "${pattern}" matched no source files`);
|
|
169
|
+
for (const rel of keep) files.add(resolve(dir, rel));
|
|
170
|
+
}
|
|
171
|
+
return files;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Resolve one environment entry to its concrete root files.
|
|
175
|
+
* entry = { files?: [...], include?: [...], exclude?: [...] } — paths are
|
|
176
|
+
* relative to the manifest directory; include/exclude are glob patterns.
|
|
177
|
+
*/
|
|
178
|
+
function resolveEnvFiles(dir, entry, label) {
|
|
179
|
+
const files = expandGlobs(dir, entry.include, label);
|
|
180
|
+
for (const file of entry.files ?? []) {
|
|
181
|
+
const abs = resolve(dir, file);
|
|
182
|
+
if (!existsSync(abs)) throw new Error(`${label}: file "${file}" does not exist`);
|
|
183
|
+
files.add(abs);
|
|
184
|
+
}
|
|
185
|
+
const excluded = expandGlobs(dir, entry.exclude, label, {
|
|
186
|
+
required: false,
|
|
187
|
+
sourcesOnly: false
|
|
188
|
+
});
|
|
189
|
+
for (const file of files) for (const abs of excluded) if (file === abs || file.startsWith(`${abs}/`)) {
|
|
190
|
+
files.delete(file);
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
if (!files.size) throw new Error(`${label}: resolved no files — an empty program would pass vacuously`);
|
|
194
|
+
return [...files].sort();
|
|
195
|
+
}
|
|
196
|
+
/** Map a `src/index[.<suffix>].*` barrel to the environment that must claim it. */
|
|
197
|
+
function barrelEnv(rel) {
|
|
198
|
+
const match = /^src\/index(?:\.([A-Za-z]+))?\.(?:ts|tsx|mts|cts|tsrx)$/.exec(rel);
|
|
199
|
+
if (!match) return null;
|
|
200
|
+
const suffix = match[1];
|
|
201
|
+
if (!suffix) return "any";
|
|
202
|
+
return SUFFIX_ENV[suffix] ?? null;
|
|
203
|
+
}
|
|
204
|
+
var arraysEqual = (a, b) => Array.isArray(a) && a.length === b.length && a.every((v, i) => v === b[i]);
|
|
205
|
+
/** Platform tags on source files, including declarations and tests. */
|
|
206
|
+
function sourcePlatform(file) {
|
|
207
|
+
return /\.(web|ios|android|mobile|native|macos|windows|linux|gtk)(?=\.)/.exec(file)?.[1];
|
|
208
|
+
}
|
|
209
|
+
function applicable(file, env) {
|
|
210
|
+
const tag = sourcePlatform(file);
|
|
211
|
+
if (!tag) return true;
|
|
212
|
+
if (tag === "mobile") return env === "ios" || env === "android";
|
|
213
|
+
if (tag === "native") return [
|
|
214
|
+
"ios",
|
|
215
|
+
"android",
|
|
216
|
+
"windows"
|
|
217
|
+
].includes(env);
|
|
218
|
+
return tag === env || env === "gtk" && tag === "linux";
|
|
219
|
+
}
|
|
220
|
+
function platformTypes(types, env, dir) {
|
|
221
|
+
const require = createRequire(join(dir, "package.json"));
|
|
222
|
+
const sdkPath = (name) => {
|
|
223
|
+
const local = join(dir, "node_modules", name);
|
|
224
|
+
if (existsSync(local)) return local;
|
|
225
|
+
try {
|
|
226
|
+
return require.resolve(name);
|
|
227
|
+
} catch {
|
|
228
|
+
try {
|
|
229
|
+
const owner = require.resolve("@nativescript/types/package.json");
|
|
230
|
+
return createRequire(owner).resolve(name);
|
|
231
|
+
} catch {
|
|
232
|
+
return name;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
return types.flatMap((name) => name === "@nativescript/types" || name === `@nativescript/types-${env}` ? ["ios", "android"].includes(env) ? [sdkPath("@nativescript/types/globals.d.ts"), sdkPath(`@nativescript/types-${env}/index.d.ts`)] : [] : [name]);
|
|
237
|
+
}
|
|
238
|
+
function validateOptions(options, label) {
|
|
239
|
+
if (options !== void 0 && (!options || typeof options !== "object" || Array.isArray(options))) throw new Error(`${label}: compilerOptions must be an object`);
|
|
240
|
+
for (const key of ["types", "lib"]) {
|
|
241
|
+
const value = options?.[key];
|
|
242
|
+
if (value !== void 0 && (!Array.isArray(value) || value.some((item) => typeof item !== "string"))) throw new Error(`${label}: compilerOptions.${key} must be an array of strings`);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/** Expand the manifest into independent platform programs; never merge SDKs. */
|
|
246
|
+
function expandEnvPrograms(dir, { path: manifestPath, manifest }, { ambientRoot = MODULE_DIR, check = false } = {}) {
|
|
247
|
+
const errors = [];
|
|
248
|
+
const resolved = {};
|
|
249
|
+
const groups = /* @__PURE__ */ new Map();
|
|
250
|
+
validateOptions(manifest.compilerOptions, ENV_MANIFEST);
|
|
251
|
+
const top = manifest.compilerOptions ?? {};
|
|
252
|
+
for (const [env, entry] of Object.entries(manifest.environments)) {
|
|
253
|
+
if (!TYPECHECK_ENVIRONMENTS[env]) {
|
|
254
|
+
errors.push(env === "linux" ? `${ENV_MANIFEST}: environment "linux" is retired; move native Linux roots to "gtk" (GJS, no DOM)` : `${ENV_MANIFEST}: unknown environment "${env}"`);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
258
|
+
errors.push(`${ENV_MANIFEST}: environment "${env}" must be an object`);
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
validateOptions(entry.compilerOptions, `${ENV_MANIFEST} environment "${env}"`);
|
|
262
|
+
for (const key of [
|
|
263
|
+
"files",
|
|
264
|
+
"include",
|
|
265
|
+
"exclude"
|
|
266
|
+
]) if (entry[key] !== void 0 && (!Array.isArray(entry[key]) || entry[key].some((v) => typeof v !== "string"))) throw new Error(`${ENV_MANIFEST}: environment "${env}" ${key} must be an array of strings`);
|
|
267
|
+
for (const key of Object.keys(entry.compilerOptions ?? {})) if (!["types", "lib"].includes(key)) errors.push(`${ENV_MANIFEST}: environment "${env}" cannot override compilerOptions.${key}`);
|
|
268
|
+
const files = resolveEnvFiles(dir, entry, `${ENV_MANIFEST} environment "${env}"`);
|
|
269
|
+
resolved[env] = files;
|
|
270
|
+
for (const target of env === "native" ? ["ios", "android"] : [env]) {
|
|
271
|
+
if (groups.has(target)) {
|
|
272
|
+
errors.push(`${ENV_MANIFEST}: "${target}" overlaps the native environment; declare native or separate ios/android entries`);
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
const options = TYPECHECK_ENVIRONMENTS[target];
|
|
276
|
+
const libs = entry.compilerOptions?.lib ?? options.compilerOptions.lib;
|
|
277
|
+
if (target !== "web" && [...top.lib ?? [], ...libs].some((v) => /^dom(?:\.|$)/i.test(v))) errors.push(`${ENV_MANIFEST}: DOM libraries are not allowed in "${target}"; put browser libraries in the web environment`);
|
|
278
|
+
const types = platformTypes([...top.types ?? [], ...entry.compilerOptions?.types ?? []], target, dir);
|
|
279
|
+
for (const sdk of ["ios", "android"]) if (sdk !== target && types.some((t) => t.includes(`@nativescript/types-${sdk}`))) errors.push(`${ENV_MANIFEST}: ${sdk} SDK types are not allowed in "${target}"`);
|
|
280
|
+
const packageAmbient = (options.ambient ?? []).filter((entry) => entry.startsWith("pkg:")).map((entry) => join(dir, "node_modules", entry.slice(4))).filter(existsSync);
|
|
281
|
+
const packageAmbientRealPaths = new Set(packageAmbient.map((entry) => realpathSync(entry)));
|
|
282
|
+
const ambient = (options.ambient ?? []).filter((entry) => !entry.startsWith("pkg:")).map((entry) => resolve(ambientRoot, entry)).filter((entry) => existsSync(entry) && !packageAmbientRealPaths.has(realpathSync(entry)));
|
|
283
|
+
const active = files.filter((file) => applicable(file, target)).filter((file) => {
|
|
284
|
+
if (sourcePlatform(file) || file.endsWith(".d.ts")) return true;
|
|
285
|
+
const ext = /\.(tsrx|tsx|ts|mts|cts)$/.exec(file)?.[0];
|
|
286
|
+
return !ext || !options.compilerOptions.moduleSuffixes.filter(Boolean).some((suffix) => existsSync(file.slice(0, -ext.length) + suffix + ext));
|
|
287
|
+
});
|
|
288
|
+
if (!active.length) errors.push(`${ENV_MANIFEST}: "${target}" resolved no applicable source files`);
|
|
289
|
+
groups.set(target, {
|
|
290
|
+
files: [...ambient, ...active],
|
|
291
|
+
compilerOptions: {
|
|
292
|
+
...top,
|
|
293
|
+
...options.compilerOptions,
|
|
294
|
+
jsxImportSource: top.jsxImportSource ?? "@octane-xplat/jsx",
|
|
295
|
+
types: [.../* @__PURE__ */ new Set([...types, ...packageAmbient])],
|
|
296
|
+
lib: [.../* @__PURE__ */ new Set([...top.lib ?? [], ...libs])]
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
for (const rel of globSync("src/index*.{ts,tsx,mts,cts,tsrx}", { cwd: dir })) {
|
|
302
|
+
const env = barrelEnv(rel);
|
|
303
|
+
if (!env) continue;
|
|
304
|
+
if (!(env === "any" ? Object.values(resolved).flat() : env === "native" ? [
|
|
305
|
+
...resolved.native ?? [],
|
|
306
|
+
...resolved.ios ?? [],
|
|
307
|
+
...resolved.android ?? []
|
|
308
|
+
] : resolved[env] ?? []).includes(resolve(dir, rel))) errors.push(`${ENV_MANIFEST}: ${rel} is not claimed by the "${env}" environment`);
|
|
309
|
+
}
|
|
310
|
+
if (top.moduleSuffixes !== void 0 && !arraysEqual(top.moduleSuffixes, PLATFORM_MODULE_SUFFIXES)) errors.push(`${ENV_MANIFEST}: top-level moduleSuffixes is fixed; configure platform resolution through environments`);
|
|
311
|
+
if (errors.length) throw new Error(errors.join("\n"));
|
|
312
|
+
const outDir = join(dir, ENV_PROGRAM_DIR);
|
|
313
|
+
const generatedPath = (file) => {
|
|
314
|
+
const rel = relative(outDir, file);
|
|
315
|
+
if (!rel || isAbsolute(rel)) return file;
|
|
316
|
+
return rel.startsWith(".") ? rel : "./" + rel;
|
|
317
|
+
};
|
|
318
|
+
const outputs = /* @__PURE__ */ new Map();
|
|
319
|
+
const programs = [];
|
|
320
|
+
for (const [env, group] of [...groups].sort(([a], [b]) => [
|
|
321
|
+
"web",
|
|
322
|
+
"ios",
|
|
323
|
+
"android",
|
|
324
|
+
"macos",
|
|
325
|
+
"windows",
|
|
326
|
+
"gtk"
|
|
327
|
+
].indexOf(a) - [
|
|
328
|
+
"web",
|
|
329
|
+
"ios",
|
|
330
|
+
"android",
|
|
331
|
+
"macos",
|
|
332
|
+
"windows",
|
|
333
|
+
"gtk"
|
|
334
|
+
].indexOf(b))) {
|
|
335
|
+
const configPath = join(outDir, `${env}.json`);
|
|
336
|
+
const forbidden = [
|
|
337
|
+
...env === "web" ? [] : [
|
|
338
|
+
"document",
|
|
339
|
+
"window",
|
|
340
|
+
"HTMLElement"
|
|
341
|
+
],
|
|
342
|
+
...env === "ios" ? [] : ["UIView"],
|
|
343
|
+
...env === "android" ? [] : ["android.os.Build"]
|
|
344
|
+
];
|
|
345
|
+
const canary = join(outDir, `isolation-${env}.ts`);
|
|
346
|
+
outputs.set(canary, "export {}\n" + forbidden.map((name) => `// @ts-expect-error ${name} must be absent in ${env}\nvoid ${name}\n`).join(""));
|
|
347
|
+
group.files = [...group.files, canary];
|
|
348
|
+
const config = {
|
|
349
|
+
extends: generatedPath(manifestPath),
|
|
350
|
+
...group,
|
|
351
|
+
files: group.files.map(generatedPath),
|
|
352
|
+
compilerOptions: {
|
|
353
|
+
...group.compilerOptions,
|
|
354
|
+
types: group.compilerOptions.types.map((entry) => isAbsolute(entry) ? generatedPath(entry) : entry.startsWith(".") ? generatedPath(resolve(dir, entry)) : entry)
|
|
355
|
+
},
|
|
356
|
+
include: [],
|
|
357
|
+
exclude: []
|
|
358
|
+
};
|
|
359
|
+
outputs.set(configPath, JSON.stringify(config, null, " ") + "\n");
|
|
360
|
+
programs.push({
|
|
361
|
+
env,
|
|
362
|
+
configPath,
|
|
363
|
+
files: group.files
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
if (check) verifyEnvOutputs(dir, outDir, outputs, programs);
|
|
367
|
+
else writeEnvOutputs(outDir, outputs);
|
|
368
|
+
return programs;
|
|
369
|
+
}
|
|
370
|
+
/** Write the generator-owned program directory, pruning stale target files. */
|
|
371
|
+
function writeEnvOutputs(outDir, outputs) {
|
|
372
|
+
mkdirSync(outDir, { recursive: true });
|
|
373
|
+
for (const [path, text] of outputs) writeFileSync(path, text);
|
|
374
|
+
for (const entry of readdirSync(outDir, { withFileTypes: true })) if (entry.isFile() && !outputs.has(join(outDir, entry.name))) rmSync(join(outDir, entry.name));
|
|
375
|
+
}
|
|
376
|
+
/** Compare tracked programs against a fresh expansion without writing. */
|
|
377
|
+
function verifyEnvOutputs(dir, outDir, outputs, programs) {
|
|
378
|
+
const stale = [];
|
|
379
|
+
for (const [path, text] of outputs) if (!existsSync(path)) stale.push(`${relative(dir, path)} is missing`);
|
|
380
|
+
else if (readFileSync(path, "utf8") !== text) stale.push(`${relative(dir, path)} does not match the manifest expansion`);
|
|
381
|
+
if (existsSync(outDir)) {
|
|
382
|
+
for (const entry of readdirSync(outDir, { withFileTypes: true })) if (entry.isFile() && !outputs.has(join(outDir, entry.name))) stale.push(`${ENV_PROGRAM_DIR}/${entry.name} belongs to a retired target`);
|
|
383
|
+
}
|
|
384
|
+
const solution = join(dir, "tsconfig.json");
|
|
385
|
+
if (existsSync(solution)) {
|
|
386
|
+
const expected = programs.map(({ configPath }) => generatedRef(dir, configPath));
|
|
387
|
+
const config = parseJsonc(readFileSync(solution, "utf8"), solution);
|
|
388
|
+
if (Array.isArray(config?.references)) {
|
|
389
|
+
const declared = config.references.map((reference) => reference?.path).filter((path) => typeof path === "string").map((path) => path.replaceAll("\\", "/")).filter((path) => /(?:^|\/)xplat-typecheck\//.test(path)).map((path) => path.replace(/^\.\//, ""));
|
|
390
|
+
for (const ref of expected) if (!declared.includes(ref)) stale.push(`tsconfig.json does not reference ./${ref}`);
|
|
391
|
+
for (const ref of declared) if (!expected.includes(ref)) stale.push(`tsconfig.json references retired program ./${ref}`);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
if (stale.length) throw new Error(`${ENV_PROGRAM_DIR}/ programs are stale — regenerate with xplat typecheck or bun run sync:envs\n` + stale.map((line) => ` ${line}`).join("\n"));
|
|
395
|
+
}
|
|
396
|
+
/** The tracked reference a solution tsconfig records for a generated program. */
|
|
397
|
+
function generatedRef(dir, configPath) {
|
|
398
|
+
return configPath.slice(dir.length + 1).replaceAll("\\", "/");
|
|
399
|
+
}
|
|
400
|
+
export { ENV_MANIFEST, ENV_PROGRAM_DIR, PLATFORM_MODULE_SUFFIXES, TYPECHECK_ENVIRONMENTS, expandEnvPrograms, loadEnvManifest };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { parse as parse$1 } from "jsonc-parser";
|
|
4
|
+
// ../cli/src/tsconfig-pin.ts
|
|
5
|
+
/**
|
|
6
|
+
* Vite 8's oxc transform resolves each file's governing tsconfig.json and
|
|
7
|
+
* follows its project references. References-style configs point at the env
|
|
8
|
+
* programs `xplat typecheck` generates under the tracked xplat-typecheck/
|
|
9
|
+
* directory — while a reference dangles (programs never generated, pruned,
|
|
10
|
+
* or a legacy node_modules/.cache reference), every plain-source transform
|
|
11
|
+
* fails with TSCONFIG_ERROR. Return the committed env manifest beside the
|
|
12
|
+
* nearest governing tsconfig.json; ordinary discovery resumes once the
|
|
13
|
+
* programs exist.
|
|
14
|
+
*/
|
|
15
|
+
function transformTsconfig(root) {
|
|
16
|
+
let dir = resolve(root);
|
|
17
|
+
for (;;) {
|
|
18
|
+
if (existsSync(join(dir, "tsconfig.json"))) break;
|
|
19
|
+
const parent = dirname(dir);
|
|
20
|
+
if (parent === dir) return;
|
|
21
|
+
dir = parent;
|
|
22
|
+
}
|
|
23
|
+
const manifest = join(dir, "tsconfig.envs.json");
|
|
24
|
+
if (!existsSync(manifest)) return;
|
|
25
|
+
const config = parse$1(readFileSync(join(dir, "tsconfig.json"), "utf8"));
|
|
26
|
+
return (Array.isArray(config?.references) ? config.references : []).some((reference) => {
|
|
27
|
+
const path = reference?.path;
|
|
28
|
+
return typeof path === "string" && /(?:^|\/)xplat-typecheck\//.test(path.replaceAll("\\", "/")) && !existsSync(resolve(dir, path));
|
|
29
|
+
}) ? manifest : void 0;
|
|
30
|
+
}
|
|
31
|
+
export { transformTsconfig };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, isAbsolute, resolve } from "node:path";
|
|
3
|
+
import { parseModule } from "@tsrx/core";
|
|
4
|
+
// ../cli/src/tsrx-leaf.ts
|
|
5
|
+
/** Declaration contracts participate in checking, never runtime discovery. */
|
|
6
|
+
function isTsrxContract(source, file) {
|
|
7
|
+
if (source.startsWith("// Type contract only.")) return true;
|
|
8
|
+
if (!/\bdeclare\b/.test(source)) return false;
|
|
9
|
+
const { body } = parseModule(source, file);
|
|
10
|
+
const declared = /* @__PURE__ */ new Set();
|
|
11
|
+
for (const statement of body) {
|
|
12
|
+
const node = statement.declaration ?? statement;
|
|
13
|
+
if (!node.declare) continue;
|
|
14
|
+
if (node.id?.name) declared.add(node.id.name);
|
|
15
|
+
for (const item of node.declarations ?? []) if (item.id.name) declared.add(item.id.name);
|
|
16
|
+
}
|
|
17
|
+
const typeOnly = (node) => {
|
|
18
|
+
if (node.declare || node.type === "TSDeclareFunction" || node.type === "TSInterfaceDeclaration" || node.type === "TSTypeAliasDeclaration") return true;
|
|
19
|
+
if (node.type === "ImportDeclaration" || node.type === "EmptyStatement") return true;
|
|
20
|
+
if (node.type === "ExportDefaultDeclaration") return node.declaration?.type === "Identifier" && declared.has(node.declaration.name ?? "");
|
|
21
|
+
if (node.type === "ExportNamedDeclaration") {
|
|
22
|
+
if (node.exportKind === "type") return true;
|
|
23
|
+
if (node.declaration) return typeOnly(node.declaration);
|
|
24
|
+
return !node.source && (node.specifiers ?? []).every((item) => item.exportKind === "type" || declared.has(item.local?.name ?? ""));
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
};
|
|
28
|
+
return declared.size > 0 && body.every(typeOnly);
|
|
29
|
+
}
|
|
30
|
+
var suffixes = {
|
|
31
|
+
web: ["web"],
|
|
32
|
+
ios: ["ios", "mobile"],
|
|
33
|
+
visionos: ["ios", "mobile"],
|
|
34
|
+
android: ["android", "mobile"],
|
|
35
|
+
macos: ["macos"],
|
|
36
|
+
windows: ["windows"],
|
|
37
|
+
gtk: ["gtk"],
|
|
38
|
+
linux: ["linux", "web"],
|
|
39
|
+
native: []
|
|
40
|
+
};
|
|
41
|
+
/** Explicit extensions identify the source language, not the runtime platform. */
|
|
42
|
+
function resolveTsrxLeaf(source, importer, platform) {
|
|
43
|
+
if (!importer || !source.startsWith(".") && !isAbsolute(source)) return null;
|
|
44
|
+
const [file] = source.split(/[?#]/, 1);
|
|
45
|
+
if (!file.endsWith(".tsrx") || /\.(web|ios|android|mobile|macos|windows|linux|gtk)\.tsrx$/.test(file)) return null;
|
|
46
|
+
const query = source.slice(file.length);
|
|
47
|
+
const base = resolve(dirname(importer.split(/[?#]/, 1)[0].replace(/^\/@fs\//, "/")), file.slice(0, -5));
|
|
48
|
+
const fallback = `${base}.tsrx`;
|
|
49
|
+
if (importer.split(/[?#]/, 1)[0].replace(/^\/@fs\//, "/").replaceAll("\\", "/").replace(/\.(web|ios|android|mobile|macos|windows|linux|gtk)\.tsrx$/, ".tsrx") === fallback.replaceAll("\\", "/")) return existsSync(fallback) ? fallback.replaceAll("\\", "/") + query : null;
|
|
50
|
+
for (const suffix of suffixes[platform] ?? []) {
|
|
51
|
+
const candidate = `${base}.${suffix}.tsrx`;
|
|
52
|
+
if (existsSync(candidate)) return candidate.replaceAll("\\", "/") + query;
|
|
53
|
+
}
|
|
54
|
+
if (existsSync(fallback) && isTsrxContract(readFileSync(fallback, "utf8"), fallback)) throw new Error(`No ${platform} implementation for ${file}; its unsuffixed TSRX module is a declaration-only contract.`);
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
export { isTsrxContract, resolveTsrxLeaf };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Ambient JS-engine globals for the macOS AppKit environment. The packaged
|
|
2
|
+
// JSC host shim (packages/cli/src/macos/jsc-host/shim.js) installs all of
|
|
3
|
+
// these on globalThis; AppKit/ObjC bridge globals are out of scope here —
|
|
4
|
+
// leaves that use them declare their own ambient surface.
|
|
5
|
+
declare var console: {
|
|
6
|
+
log(...args: unknown[]): void
|
|
7
|
+
info(...args: unknown[]): void
|
|
8
|
+
warn(...args: unknown[]): void
|
|
9
|
+
error(...args: unknown[]): void
|
|
10
|
+
debug(...args: unknown[]): void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare function setTimeout(callback: (...args: unknown[]) => void, delay?: number): number
|
|
14
|
+
declare function clearTimeout(handle?: number): void
|
|
15
|
+
declare function setInterval(callback: (...args: unknown[]) => void, delay?: number): number
|
|
16
|
+
declare function clearInterval(handle?: number): void
|
|
17
|
+
declare function queueMicrotask(callback: () => void): void
|
|
18
|
+
|
|
19
|
+
// The macOS host embeds a real Node runtime — the broader process ambient
|
|
20
|
+
// (env index signature + cwd) lives in macos-appkit's host-globals.d.ts,
|
|
21
|
+
// which is listed alongside this file for every macos-env program.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Ambient JS-engine globals for the NativeScript environments (iOS/Android/Windows).
|
|
2
|
+
// The runtime provides all of these but @nativescript/core leaves the global
|
|
3
|
+
// declarations commented out (global-types.d.ts) — same reasoning and shape
|
|
4
|
+
// as apps/harness/types/globals.d.ts. Platform bridge globals (android,
|
|
5
|
+
// UIApplication, …) are NOT declared here: they come from the real
|
|
6
|
+
// @nativescript/types packages, which a package must declare when its checked
|
|
7
|
+
// sources use them.
|
|
8
|
+
declare var console: {
|
|
9
|
+
log(...args: unknown[]): void
|
|
10
|
+
info(...args: unknown[]): void
|
|
11
|
+
warn(...args: unknown[]): void
|
|
12
|
+
error(...args: unknown[]): void
|
|
13
|
+
debug(...args: unknown[]): void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare function setTimeout(callback: (...args: unknown[]) => void, delay?: number): number
|
|
17
|
+
declare function clearTimeout(handle?: number): void
|
|
18
|
+
declare function setInterval(callback: (...args: unknown[]) => void, delay?: number): number
|
|
19
|
+
declare function clearInterval(handle?: number): void
|
|
20
|
+
declare function queueMicrotask(callback: () => void): void
|
|
21
|
+
|
|
22
|
+
// The bundler statically replaces process.env.NODE_ENV (vite `define`); tsc
|
|
23
|
+
// still needs the name in a program with no Node types. Kept narrow: other
|
|
24
|
+
// process.env.FOO reads stay type errors because the define cannot rewrite
|
|
25
|
+
// them either.
|
|
26
|
+
declare var process: { env: { NODE_ENV?: string } }
|
|
27
|
+
|
|
28
|
+
// Installed as real globals by every NativeScript runtime (@nativescript/core
|
|
29
|
+
// text module; verified on the packaged windows host too). Declared here
|
|
30
|
+
// rather than via lib.dom, which native programs must not see. BufferSource
|
|
31
|
+
// is DOM-only, so decode takes the concrete array-buffer unions.
|
|
32
|
+
declare class TextDecoder {
|
|
33
|
+
readonly encoding: string
|
|
34
|
+
decode(input: ArrayBuffer | ArrayBufferView): string
|
|
35
|
+
toString(): string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
declare class TextEncoder {
|
|
39
|
+
readonly encoding: string
|
|
40
|
+
encode(input?: string): Uint8Array
|
|
41
|
+
toString(): string
|
|
42
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// ../ui/src/markdown/markdown-ast.ts
|
|
2
|
+
/** Kind tag of the serialized markdown document envelope. */
|
|
3
|
+
var MD_DOC_KIND = "octane-xplat/md";
|
|
4
|
+
/**
|
|
5
|
+
* Visible text of an inline run — the same projection Outline and heading
|
|
6
|
+
* labels use (`markdownAstText` upstream). Images project their alt text;
|
|
7
|
+
* citations and breaks contribute nothing; extension nodes defer to
|
|
8
|
+
* `extensionText` (their `source` text by default).
|
|
9
|
+
*/
|
|
10
|
+
function mdInlineText(nodes, extensionText = (node) => node.source ?? "") {
|
|
11
|
+
let text = "";
|
|
12
|
+
for (const node of nodes ?? []) switch (node.type) {
|
|
13
|
+
case "text":
|
|
14
|
+
case "inlineCode":
|
|
15
|
+
case "inlineMath":
|
|
16
|
+
text += node.value;
|
|
17
|
+
break;
|
|
18
|
+
case "strong":
|
|
19
|
+
case "emphasis":
|
|
20
|
+
case "delete":
|
|
21
|
+
case "link":
|
|
22
|
+
text += mdInlineText(node.children, extensionText);
|
|
23
|
+
break;
|
|
24
|
+
case "image":
|
|
25
|
+
text += node.alt;
|
|
26
|
+
break;
|
|
27
|
+
case "citation":
|
|
28
|
+
case "break": break;
|
|
29
|
+
case "extension": text += extensionText(node);
|
|
30
|
+
}
|
|
31
|
+
return text;
|
|
32
|
+
}
|
|
33
|
+
export { MD_DOC_KIND, mdInlineText };
|