@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.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/dist/add-worker.js +66 -0
  4. package/dist/build-worker.js +287 -0
  5. package/dist/compatibility-check.js +155 -0
  6. package/dist/compatibility-data/compatibility.js +109 -0
  7. package/dist/compatibility-data/compatibility.json +298 -0
  8. package/dist/compatibility.js +240 -0
  9. package/dist/css-platform.js +236 -0
  10. package/dist/css-platform.types.d.ts +11 -0
  11. package/dist/dev-inspector.web.js +125 -0
  12. package/dist/dev-log-client.web.js +79 -0
  13. package/dist/dev-log-server.js +13 -0
  14. package/dist/devtools-worker.js +94 -0
  15. package/dist/doctor-checks.js +414 -0
  16. package/dist/doctor-tool.js +27 -0
  17. package/dist/env.js +3 -0
  18. package/dist/fmt-plan.js +149 -0
  19. package/dist/fonts-worker.js +31 -0
  20. package/dist/fonts.js +614 -0
  21. package/dist/inline-stylesheets.js +44 -0
  22. package/dist/linux/config.js +43 -0
  23. package/dist/linux/gtk-runtime.js +86 -0
  24. package/dist/linux/package.js +189 -0
  25. package/dist/linux-gtk/bindings.mjs +675 -0
  26. package/dist/linux-gtk/native-gi-projection.js +36 -0
  27. package/dist/linux-gtk/vite.d.ts +39 -0
  28. package/dist/linux-gtk/vite.js +281 -0
  29. package/dist/macos/config.js +136 -0
  30. package/dist/macos/core-ui.js +59 -0
  31. package/dist/macos/core-vite.js +122 -0
  32. package/dist/macos/doctor-checks.js +58 -0
  33. package/dist/macos/executables.js +39 -0
  34. package/dist/macos/jsc-host/runtime.js +134 -0
  35. package/dist/macos/native.js +286 -0
  36. package/dist/macos/runtime-package.js +30 -0
  37. package/dist/macos/tab-item.js +62 -0
  38. package/dist/macos/vite.d.ts +13 -0
  39. package/dist/macos/vite.js +22 -0
  40. package/dist/markdown.js +11 -0
  41. package/dist/mason-engine.js +20 -0
  42. package/dist/mcp/contracts/actions.js +133 -0
  43. package/dist/mcp/dev-bridge.js +363 -0
  44. package/dist/mcp/dev-socket.js +203 -0
  45. package/dist/mcp/dev-stack.js +134 -0
  46. package/dist/mcp/inspection/dom.web.js +46 -0
  47. package/dist/native-regex.js +123 -0
  48. package/dist/package-manager.js +106 -0
  49. package/dist/package-root.js +48 -0
  50. package/dist/patches.js +356 -0
  51. package/dist/route-config.js +53 -0
  52. package/dist/route-data.js +42 -0
  53. package/dist/route-generator.js +514 -0
  54. package/dist/route-path.js +29 -0
  55. package/dist/route-source.js +67 -0
  56. package/dist/targets.js +37 -0
  57. package/dist/tsconfig-envs.js +400 -0
  58. package/dist/tsconfig-pin.js +31 -0
  59. package/dist/tsrx-leaf.js +57 -0
  60. package/dist/typecheck-globals/macos.d.ts +21 -0
  61. package/dist/typecheck-globals/native.d.ts +42 -0
  62. package/dist/ui/src/markdown/markdown-ast.js +33 -0
  63. package/dist/ui/src/markdown/markdown-character-references.js +79 -0
  64. package/dist/ui/src/markdown/markdown-parse.js +1930 -0
  65. package/dist/ui/src/markdown/markdown-plugins.js +564 -0
  66. package/dist/ui/src/markdown/markdown-url.js +17 -0
  67. package/dist/updates-worker.js +34 -0
  68. package/dist/upgrade-worker.js +63 -0
  69. package/dist/vite-target.js +57 -0
  70. package/dist/vite.d.ts +125 -0
  71. package/dist/vite.js +797 -0
  72. package/dist/workshop-worker.js +181 -0
  73. package/package.json +74 -0
@@ -0,0 +1,43 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { isAbsolute, join, relative, resolve } from "node:path";
3
+ // ../cli/src/linux/config.ts
4
+ function inspectLinuxPackageConfig(appRoot) {
5
+ const manifest = JSON.parse(readFileSync(join(appRoot, "package.json"), "utf8"));
6
+ const target = manifest.xplat?.targets?.linux ?? {};
7
+ const settings = target.package ?? {};
8
+ const issues = [];
9
+ const runtime = target.runtime;
10
+ if (runtime !== "gtk") issues.push("linux.runtime must be gtk; desktop WebView hosting has been removed. Use native GTK screens or run the app in a browser.");
11
+ const { applicationId, productName, executableName } = settings;
12
+ const version = settings.version ?? manifest.version;
13
+ const scheme = target.host?.scheme ?? "xplat";
14
+ if (typeof applicationId !== "string" || applicationId.length > 255 || !/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_-]*){2,}$/.test(applicationId)) issues.push("linux.package.applicationId must be a reverse-DNS application ID");
15
+ if (typeof productName !== "string" || !productName.trim() || [...productName].some((character) => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127)) issues.push("linux.package.productName must be a nonempty single-line name");
16
+ if (typeof executableName !== "string" || ["host", "bundle"].includes(executableName) || !/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(executableName)) issues.push("linux.package.executableName must contain only letters, digits, underscores, or hyphens");
17
+ if (typeof version !== "string" || !/^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][A-Za-z0-9.-]+)?$/.test(version)) issues.push("linux.package.version (or package version) must be a semantic version");
18
+ if (target.host?.scheme !== void 0 && (typeof scheme !== "string" || !/^[a-z][a-z0-9+.-]*$/.test(scheme) || [
19
+ "http",
20
+ "https",
21
+ "file",
22
+ "data",
23
+ "javascript"
24
+ ].includes(scheme))) issues.push("linux.host.scheme must be a custom lowercase URI scheme");
25
+ const config = settings.viteConfig ?? "vite.gtk.config.ts";
26
+ let viteConfig;
27
+ if (typeof config !== "string" || isAbsolute(config) || relative(resolve(appRoot), resolve(appRoot, config)).startsWith("..")) issues.push("linux.package.viteConfig must be a relative path inside the app");
28
+ else {
29
+ viteConfig = resolve(appRoot, config);
30
+ if (!existsSync(viteConfig)) issues.push(`Linux Vite config not found: ${config}`);
31
+ }
32
+ return {
33
+ issues,
34
+ runtime,
35
+ applicationId,
36
+ productName,
37
+ executableName,
38
+ version,
39
+ scheme,
40
+ viteConfig
41
+ };
42
+ }
43
+ export { inspectLinuxPackageConfig };
@@ -0,0 +1,86 @@
1
+ import { installedPackageRoot } from "../package-root.js";
2
+ import { chmodSync, lstatSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
3
+ import { dirname, join } from "node:path";
4
+ import { createHash } from "node:crypto";
5
+ // ../cli/src/linux/gtk-runtime.ts
6
+ var machines = {
7
+ aarch64: 183,
8
+ x86_64: 62
9
+ };
10
+ function installedGtkRuntimeRoot(appRoot) {
11
+ const renderer = installedPackageRoot(appRoot, "@octane-xplat/linux-gtk");
12
+ if (!renderer) return null;
13
+ const source = join(renderer, "platforms/linux/runtime");
14
+ return hasRuntimeDirectory(source) ? source : null;
15
+ }
16
+ function stageInstalledGtkRuntime(appRoot, destination) {
17
+ const source = installedGtkRuntimeRoot(appRoot);
18
+ if (!source) throw new Error("Linux GTK requires the NativeScript runtime payloads. Install a matching release of @octane-xplat/linux-gtk or stage the pinned payloads in a source checkout.");
19
+ mkdirSync(destination);
20
+ for (const architecture of ["x86_64", "aarch64"]) {
21
+ const input = join(source, architecture);
22
+ if (!hasRuntimeDirectory(input) || stageGtkRuntime(input, join(destination, architecture)) !== architecture) throw new Error(`Installed GTK runtime is missing the ${architecture} payload`);
23
+ }
24
+ if (!readFileSync(join(destination, "x86_64/gi.json")).equals(readFileSync(join(destination, "aarch64/gi.json")))) throw new Error("Installed GTK runtimes must use the same GI schema");
25
+ }
26
+ function hasRuntimeDirectory(path) {
27
+ const info = lstatSync(path, { throwIfNoEntry: false });
28
+ if (!info) return false;
29
+ if (!info.isDirectory() || realpathSync(path) !== path) throw new Error(`GTK runtime payload must be an ordinary directory: ${path}`);
30
+ return true;
31
+ }
32
+ function stageGtkRuntime(sourcePath, destination) {
33
+ const source = realpathSync(sourcePath);
34
+ const manifestPath = join(source, "manifest.json");
35
+ if (!lstatSync(manifestPath).isFile()) throw new Error("GTK runtime manifest must be a regular file");
36
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
37
+ const { architecture, files } = manifest ?? {};
38
+ if (manifest?.version !== 1 || architecture !== "aarch64" && architecture !== "x86_64" || !files || typeof files !== "object" || Array.isArray(files)) throw new Error("Invalid GTK runtime payload manifest");
39
+ const libraries = ["lib/libmason_c.so", "lib/libxplatmason-gtk.so"];
40
+ for (const name of [
41
+ "ns-linux",
42
+ "gi.json",
43
+ "icu/icudt77l.dat",
44
+ `metadata-${architecture}.bin`,
45
+ "metadata/mason.bin",
46
+ "metadata/xplatmason.bin",
47
+ "metadata/gtk-matrix.bin",
48
+ "metadata/webkit.bin",
49
+ "typings/index.d.ts",
50
+ ...libraries
51
+ ]) if (!Object.hasOwn(files, name)) throw new Error(`GTK runtime payload is missing ${name}`);
52
+ mkdirSync(destination);
53
+ for (const [name, hash] of Object.entries(files)) {
54
+ if (!name.split("/").every((part) => /^[A-Za-z0-9_!.-]+$/.test(part) && part !== "." && part !== "..") || name === "manifest.json" || typeof hash !== "string" || !/^[0-9a-f]{64}$/.test(hash)) throw new Error(`Invalid GTK runtime manifest entry: ${name}`);
55
+ const input = join(source, name);
56
+ if (!lstatSync(input).isFile() || realpathSync(input) !== input) throw new Error(`GTK runtime payload must contain a regular file: ${name}`);
57
+ const bytes = readFileSync(input);
58
+ if (!bytes.length || createHash("sha256").update(bytes).digest("hex") !== hash) throw new Error(`GTK runtime payload checksum mismatch: ${name}`);
59
+ if ((name === "ns-linux" || libraries.includes(name)) && (bytes.subarray(0, 6).toString("hex") !== "7f454c460201" || bytes.length < 20 || bytes.readUInt16LE(18) !== machines[architecture])) throw new Error(`Expected a ${architecture} Linux ELF file: ${name}`);
60
+ const output = join(destination, name);
61
+ mkdirSync(dirname(output), { recursive: true });
62
+ writeFileSync(output, bytes, { flag: "wx" });
63
+ if (name === "ns-linux") chmodSync(output, 493);
64
+ }
65
+ writeFileSync(join(destination, "manifest.json"), JSON.stringify(manifest, null, 2) + "\n", { flag: "wx" });
66
+ return architecture;
67
+ }
68
+ function writeGtkRuntimeLauncher(appDir, launcher, bundle, architecture = "x86_64") {
69
+ const bundleArg = "'" + bundle.replaceAll("'", "'\\''") + "'";
70
+ const launcherPath = join(appDir, launcher);
71
+ writeFileSync(join(appDir, "package.json"), "{\"type\":\"module\"}\n", { flag: "wx" });
72
+ writeFileSync(launcherPath, `#!/bin/sh
73
+ set -eu
74
+ APP_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
75
+ RUNTIME="$APP_DIR/runtime"
76
+ ${architecture === "universal" ? `case "$(uname -m)" in
77
+ x86_64) RUNTIME="$RUNTIME/x86_64" ;;
78
+ aarch64) RUNTIME="$RUNTIME/aarch64" ;;
79
+ *) echo "This app supports x86_64 and aarch64 Linux." >&2; exit 1 ;;
80
+ esac
81
+ ` : ""}export ICU_DATA="$RUNTIME/icu"
82
+ exec "$RUNTIME/ns-linux" "$APP_DIR"/${bundleArg} "$@"
83
+ `, { flag: "wx" });
84
+ chmodSync(launcherPath, 493);
85
+ }
86
+ export { installedGtkRuntimeRoot, stageGtkRuntime, stageInstalledGtkRuntime, writeGtkRuntimeLauncher };
@@ -0,0 +1,189 @@
1
+ import { gtkRuntimeBuildMarker } from "../linux-gtk/native-gi-projection.js";
2
+ import { inspectLinuxPackageConfig } from "./config.js";
3
+ import { stageGtkRuntime, stageInstalledGtkRuntime, writeGtkRuntimeLauncher } from "./gtk-runtime.js";
4
+ import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
5
+ import { createRequire } from "node:module";
6
+ import { dirname, join, resolve } from "node:path";
7
+ import { execFileSync } from "node:child_process";
8
+ // ../cli/src/linux/package.ts
9
+ var quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
10
+ var desktopString = (value) => value.replaceAll("\\", "\\\\").replaceAll(" ", "\\t");
11
+ /** The application ESM entry. linuxGtk emits `app.js` by
12
+ * default; accept any single top-level bundle so an app may rename it. */
13
+ var findGtkBundle = (appDir) => {
14
+ if (existsSync(join(appDir, "app.js"))) return "app.js";
15
+ const entries = readdirSync(appDir).filter((entry) => /\.(js|mjs)$/.test(entry));
16
+ if (entries.length !== 1) throw new Error("Linux GTK packaging expected exactly one ESM bundle (app.js by default); keep the Vite lib build to a single-file output.");
17
+ return entries[0];
18
+ };
19
+ /** XDG install surface for native GTK apps: a `.desktop` entry,
20
+ * `install.sh` (replaces any previous install cleanly, then writes the
21
+ * absolute Exec path), and `uninstall.sh` (removes only the installed app
22
+ * directory and desktop entry — user settings under XDG_CONFIG_HOME stay).
23
+ * GTK currently registers no URI scheme. */
24
+ function writeDesktopInstall(config, appDir, { scheme, execArgs }) {
25
+ const execLine = `Exec=${config.executableName}${execArgs}`;
26
+ writeFileSync(join(appDir, `${config.applicationId}.desktop`), `[Desktop Entry]
27
+ Type=Application
28
+ Name=${desktopString(config.productName)}
29
+ ${execLine}
30
+ Icon=application-x-executable
31
+ Terminal=false
32
+ Categories=Utility;
33
+ ${scheme ? `MimeType=x-scheme-handler/${scheme};\n` : ""}StartupWMClass=${config.applicationId}
34
+ DBusActivatable=false
35
+ `);
36
+ writeFileSync(join(appDir, "install.sh"), `#!/bin/sh
37
+ set -eu
38
+ APP_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
39
+ DATA_DIR="\${XDG_DATA_HOME:-$HOME/.local/share}"
40
+ DEST="$DATA_DIR/${config.applicationId}"
41
+ mkdir -p "$DATA_DIR/applications"
42
+ if [ "$APP_DIR" != "$DEST" ]; then
43
+ rm -rf -- "$DEST"
44
+ mkdir -p "$DEST"
45
+ cp -R "$APP_DIR/." "$DEST/"
46
+ fi
47
+ python3 - "$DEST" "$DATA_DIR/applications/${config.applicationId}.desktop" <<'PY'
48
+ import pathlib, sys
49
+ root = pathlib.Path(sys.argv[1])
50
+ entry = (root / ${quote(`${config.applicationId}.desktop`)}).read_text()
51
+ # Desktop Exec quoting has two layers: string escapes, then argument escapes.
52
+ executable = str(root / ${quote(config.executableName)})
53
+ executable = executable.replace('\\\\', '\\\\\\\\\\\\\\\\').replace('"', '\\\\\\\\"').replace('\\x60', '\\\\\\\\x60').replace('$', '\\\\\\\\$').replace('%', '%%')
54
+ entry = entry.replace(${quote(execLine)}, 'Exec="' + executable + '"${execArgs}')
55
+ pathlib.Path(sys.argv[2]).write_text(entry)
56
+ PY
57
+ command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database "$DATA_DIR/applications" || true
58
+ printf 'Installed to %s\\n' "$DEST"
59
+ `);
60
+ chmodSync(join(appDir, "install.sh"), 493);
61
+ writeFileSync(join(appDir, "uninstall.sh"), `#!/bin/sh
62
+ set -eu
63
+ DATA_DIR="\${XDG_DATA_HOME:-$HOME/.local/share}"
64
+ DEST="$DATA_DIR/${config.applicationId}"
65
+ rm -rf -- "$DEST"
66
+ rm -f -- "$DATA_DIR/applications/${config.applicationId}.desktop"
67
+ command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database "$DATA_DIR/applications" || true
68
+ printf 'Removed %s and its desktop entry.\\n' "$DEST"
69
+ printf 'Settings kept under %s\\n' "\${XDG_CONFIG_HOME:-$HOME/.config}/${config.applicationId}"
70
+ `);
71
+ chmodSync(join(appDir, "uninstall.sh"), 493);
72
+ }
73
+ /** Bundle one GTK entry and its launcher in the native-owned staging directory. */
74
+ function buildGtkApp(config, vite, appRoot, appDir, gtkRuntimeRoot) {
75
+ const payload = join(dirname(appDir), ".gtk-runtime");
76
+ let architecture;
77
+ let schemaPath;
78
+ if (gtkRuntimeRoot) {
79
+ architecture = stageGtkRuntime(gtkRuntimeRoot, payload);
80
+ schemaPath = join(payload, "gi.json");
81
+ } else {
82
+ stageInstalledGtkRuntime(appRoot, payload);
83
+ architecture = "universal";
84
+ schemaPath = join(payload, "x86_64/gi.json");
85
+ }
86
+ execFileSync(process.execPath, [
87
+ vite,
88
+ "build",
89
+ "--config",
90
+ config.viteConfig,
91
+ "--outDir",
92
+ appDir
93
+ ], {
94
+ cwd: appRoot,
95
+ stdio: "inherit",
96
+ env: {
97
+ ...process.env,
98
+ XPLAT_GTK_RUNTIME_SCHEMA: schemaPath
99
+ }
100
+ });
101
+ const bundle = findGtkBundle(appDir);
102
+ const marker = join(appDir, gtkRuntimeBuildMarker);
103
+ if (!existsSync(marker) || readFileSync(marker, "utf8") !== "1\n") throw new Error("Use the updated linuxGtk Vite preset to build with the NativeScript runtime.");
104
+ rmSync(marker);
105
+ renameSync(payload, join(appDir, "runtime"));
106
+ writeGtkRuntimeLauncher(appDir, config.executableName, bundle, architecture);
107
+ writeFileSync(join(appDir, "app.json"), JSON.stringify({
108
+ applicationId: config.applicationId,
109
+ productName: config.productName,
110
+ version: config.version
111
+ }, null, 2) + "\n");
112
+ writeDesktopInstall(config, appDir, {
113
+ scheme: null,
114
+ execArgs: ""
115
+ });
116
+ const instructions = `Run ./${config.executableName} from any directory. The bundled NativeScript runtime supports Linux ${architecture === "universal" ? "x86_64 and aarch64" : architecture}.\nOn Ubuntu 24.04, install libgtk-4-1 and libjson-glib-1.0-0 and use a graphical session.\nInstall libwebkitgtk-6.0-4 for WebView, libsoup-3.0-0 for HTTP images, and librsvg2-common for SVG images.\n`;
117
+ writeFileSync(join(appDir, "README.txt"), `${config.productName} ${config.version}\n${instructions}`);
118
+ return architecture;
119
+ }
120
+ async function packageLinux(appRoot, { stagingRoot, publish = true, gtkRuntimeRoot } = {}) {
121
+ const config = inspectLinuxPackageConfig(appRoot);
122
+ if (config.issues.length) throw new Error(config.issues.join("\n"));
123
+ const require = createRequire(join(resolve(appRoot), "package.json"));
124
+ let vite;
125
+ try {
126
+ const manifest = require.resolve("vite/package.json");
127
+ vite = join(dirname(manifest), JSON.parse(readFileSync(manifest, "utf8")).bin.vite);
128
+ } catch {
129
+ throw new Error("Declare vite in this app and run bun install before building Linux.");
130
+ }
131
+ const output = join(appRoot, "dist", "linux");
132
+ mkdirSync(output, { recursive: true });
133
+ const staging = stagingRoot ?? mkdtempSync(join(output, ".package-"));
134
+ let preserveStaging = false;
135
+ const appDir = join(staging, config.executableName);
136
+ const archiveName = `${config.executableName}-${config.version}.tar.gz`;
137
+ try {
138
+ let gtkRuntimeArchitecture;
139
+ mkdirSync(appDir);
140
+ gtkRuntimeArchitecture = buildGtkApp(config, vite, appRoot, appDir, gtkRuntimeRoot);
141
+ execFileSync("tar", [
142
+ "--no-xattrs",
143
+ "-czf",
144
+ join(staging, archiveName),
145
+ "-C",
146
+ staging,
147
+ config.executableName
148
+ ], {
149
+ stdio: "inherit",
150
+ env: {
151
+ ...process.env,
152
+ COPYFILE_DISABLE: "1"
153
+ }
154
+ });
155
+ if (!publish) {
156
+ preserveStaging = true;
157
+ return {
158
+ version: 1,
159
+ runtime: config.runtime,
160
+ gtkRuntimeArchitecture,
161
+ executableName: config.executableName,
162
+ packageVersion: config.version,
163
+ appDir,
164
+ archive: join(staging, archiveName)
165
+ };
166
+ }
167
+ const destination = join(output, config.executableName);
168
+ const backup = join(staging, "previous");
169
+ if (existsSync(destination)) renameSync(destination, backup);
170
+ try {
171
+ renameSync(appDir, destination);
172
+ } catch (error) {
173
+ if (existsSync(backup)) renameSync(backup, destination);
174
+ throw error;
175
+ }
176
+ renameSync(join(staging, archiveName), join(output, archiveName));
177
+ console.log(`[linux-package] ${destination}\n[linux-package] ${join(output, archiveName)}`);
178
+ return {
179
+ appDir: destination,
180
+ archive: join(output, archiveName)
181
+ };
182
+ } finally {
183
+ if (!preserveStaging) rmSync(staging, {
184
+ recursive: true,
185
+ force: true
186
+ });
187
+ }
188
+ }
189
+ export { packageLinux };