@octane-xplat/build 0.0.0-nightly.gf55b7b9
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 +276 -0
- package/dist/compatibility-check.js +153 -0
- package/dist/compatibility-data/compatibility.js +106 -0
- package/dist/compatibility-data/compatibility.json +305 -0
- package/dist/compatibility.js +229 -0
- package/dist/css-layers.js +63 -0
- package/dist/css-platform.js +230 -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/doctor-checks.js +317 -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 +37 -0
- package/dist/linux/config.js +43 -0
- package/dist/linux/host/bridge-selftest.linux.js +255 -0
- package/dist/linux/host/gjs-host.js +1412 -0
- package/dist/linux/package.js +176 -0
- package/dist/linux-gtk/vite.d.ts +23 -0
- package/dist/linux-gtk/vite.js +194 -0
- package/dist/macos/config.js +141 -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 +287 -0
- package/dist/macos/runtime-package.js +30 -0
- package/dist/macos/tab-item.js +62 -0
- package/dist/macos/vite.d.ts +21 -0
- package/dist/macos/vite.js +111 -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 +161 -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 +38 -0
- package/dist/tsconfig-envs.js +287 -0
- package/dist/tsrx-leaf.js +57 -0
- package/dist/typecheck-globals/macos.d.ts +21 -0
- package/dist/typecheck-globals/native.d.ts +26 -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.d.ts +85 -0
- package/dist/vite.js +628 -0
- package/dist/workshop-worker.js +181 -0
- package/package.json +73 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { srcUrl } from "../env.js";
|
|
2
|
+
import { inspectLinuxPackageConfig } from "./config.js";
|
|
3
|
+
import { chmodSync, cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import { dirname, join, resolve } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { execFileSync } from "node:child_process";
|
|
8
|
+
// ../cli/src/linux/package.ts
|
|
9
|
+
var defaultHostRoot = fileURLToPath(srcUrl(import.meta.url, "host/"));
|
|
10
|
+
var quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
11
|
+
var desktopString = (value) => value.replaceAll("\\", "\\\\").replaceAll(" ", "\\t");
|
|
12
|
+
/** The one ESM file `gjs -m` executes. xplatLinuxGtk emits `app.js` by
|
|
13
|
+
* default; accept any single top-level bundle so an app may rename it. */
|
|
14
|
+
var findGtkBundle = (appDir) => {
|
|
15
|
+
if (existsSync(join(appDir, "app.js"))) return "app.js";
|
|
16
|
+
const entries = readdirSync(appDir).filter((entry) => /\.(js|mjs)$/.test(entry));
|
|
17
|
+
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.");
|
|
18
|
+
return entries[0];
|
|
19
|
+
};
|
|
20
|
+
/** GTK4/GJS runtime: a single-file ESM bundle plus an executable `gjs -m`
|
|
21
|
+
* launcher. GJS produces no binary, so the relocatable app directory and
|
|
22
|
+
* tar archive are the distributable artifacts. No host script, desktop
|
|
23
|
+
* entry, or installer ships yet — the runtime is not qualified on a real
|
|
24
|
+
* Linux host, and URI handling/window services do not exist in the GTK
|
|
25
|
+
* host. Those pieces land with runtime qualification. */
|
|
26
|
+
function buildGtkApp(config, vite, appRoot, appDir) {
|
|
27
|
+
execFileSync(process.execPath, [
|
|
28
|
+
vite,
|
|
29
|
+
"build",
|
|
30
|
+
"--config",
|
|
31
|
+
config.viteConfig,
|
|
32
|
+
"--outDir",
|
|
33
|
+
appDir
|
|
34
|
+
], {
|
|
35
|
+
cwd: appRoot,
|
|
36
|
+
stdio: "inherit"
|
|
37
|
+
});
|
|
38
|
+
const bundle = findGtkBundle(appDir);
|
|
39
|
+
writeFileSync(join(appDir, config.executableName), `#!/bin/sh
|
|
40
|
+
set -eu
|
|
41
|
+
APP_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
42
|
+
command -v gjs >/dev/null 2>&1 || { echo 'Install GJS and GTK4; see README.txt.' >&2; exit 1; }
|
|
43
|
+
exec gjs -m "$APP_DIR/${bundle}" "$@"
|
|
44
|
+
`);
|
|
45
|
+
chmodSync(join(appDir, config.executableName), 493);
|
|
46
|
+
writeFileSync(join(appDir, "app.json"), JSON.stringify({
|
|
47
|
+
applicationId: config.applicationId,
|
|
48
|
+
productName: config.productName,
|
|
49
|
+
version: config.version
|
|
50
|
+
}, null, 2) + "\n");
|
|
51
|
+
writeFileSync(join(appDir, "README.txt"), `${config.productName} ${config.version}\nRun ./${config.executableName} from any directory; it executes the bundled app with gjs -m.\nRequires GJS and GTK4 introspection data plus a graphical session.\nUbuntu 24.04: sudo apt install gjs gir1.2-gtk-4.0\nThere is no desktop entry or installer yet — copy the directory where you want it.\n`);
|
|
52
|
+
}
|
|
53
|
+
/** Build a relocatable GJS/WebKitGTK app and tar archive from a Linux target. */
|
|
54
|
+
async function packageLinux(appRoot, { stagingRoot, publish = true, hostRoot = defaultHostRoot } = {}) {
|
|
55
|
+
const config = inspectLinuxPackageConfig(appRoot);
|
|
56
|
+
if (config.issues.length) throw new Error(config.issues.join("\n"));
|
|
57
|
+
const require = createRequire(join(resolve(appRoot), "package.json"));
|
|
58
|
+
let vite;
|
|
59
|
+
try {
|
|
60
|
+
const manifest = require.resolve("vite/package.json");
|
|
61
|
+
vite = join(dirname(manifest), JSON.parse(readFileSync(manifest, "utf8")).bin.vite);
|
|
62
|
+
} catch {
|
|
63
|
+
throw new Error("Declare vite in this app and run bun install before building Linux.");
|
|
64
|
+
}
|
|
65
|
+
const output = join(appRoot, "dist", "linux");
|
|
66
|
+
mkdirSync(output, { recursive: true });
|
|
67
|
+
const staging = stagingRoot ?? mkdtempSync(join(output, ".package-"));
|
|
68
|
+
let preserveStaging = false;
|
|
69
|
+
const appDir = join(staging, config.executableName);
|
|
70
|
+
const archiveName = `${config.executableName}-${config.version}.tar.gz`;
|
|
71
|
+
try {
|
|
72
|
+
mkdirSync(appDir);
|
|
73
|
+
if (config.runtime === "gtk") buildGtkApp(config, vite, appRoot, appDir);
|
|
74
|
+
else {
|
|
75
|
+
execFileSync(process.execPath, [
|
|
76
|
+
vite,
|
|
77
|
+
"build",
|
|
78
|
+
"--config",
|
|
79
|
+
config.viteConfig,
|
|
80
|
+
"--base",
|
|
81
|
+
"/",
|
|
82
|
+
"--outDir",
|
|
83
|
+
join(appDir, "bundle")
|
|
84
|
+
], {
|
|
85
|
+
cwd: appRoot,
|
|
86
|
+
stdio: "inherit"
|
|
87
|
+
});
|
|
88
|
+
if (!existsSync(join(appDir, "bundle", "index.html"))) throw new Error("Linux packaging requires a static Vite frontend with index.html (not SSR or library output).");
|
|
89
|
+
cpSync(hostRoot, join(appDir, "host"), { recursive: true });
|
|
90
|
+
writeFileSync(join(appDir, "app.json"), JSON.stringify({
|
|
91
|
+
applicationId: config.applicationId,
|
|
92
|
+
productName: config.productName,
|
|
93
|
+
scheme: config.scheme
|
|
94
|
+
}, null, 2) + "\n");
|
|
95
|
+
writeFileSync(join(appDir, config.executableName), `#!/bin/sh
|
|
96
|
+
set -eu
|
|
97
|
+
APP_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
98
|
+
command -v gjs >/dev/null 2>&1 || { echo 'Install GJS, GTK4, libadwaita, WebKitGTK 6.0 and libsecret; see README.txt.' >&2; exit 1; }
|
|
99
|
+
exec gjs "$APP_DIR/host/gjs-host.js" --bundle "$APP_DIR/bundle" "$@"
|
|
100
|
+
`);
|
|
101
|
+
chmodSync(join(appDir, config.executableName), 493);
|
|
102
|
+
writeFileSync(join(appDir, `${config.applicationId}.desktop`), `[Desktop Entry]
|
|
103
|
+
Type=Application
|
|
104
|
+
Name=${desktopString(config.productName)}
|
|
105
|
+
Exec=${config.executableName} %u
|
|
106
|
+
Icon=application-x-executable
|
|
107
|
+
Terminal=false
|
|
108
|
+
Categories=Utility;
|
|
109
|
+
MimeType=x-scheme-handler/${config.scheme};
|
|
110
|
+
StartupWMClass=${config.applicationId}
|
|
111
|
+
DBusActivatable=false
|
|
112
|
+
`);
|
|
113
|
+
writeFileSync(join(appDir, "install.sh"), `#!/bin/sh
|
|
114
|
+
set -eu
|
|
115
|
+
APP_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
116
|
+
DATA_DIR="\${XDG_DATA_HOME:-$HOME/.local/share}"
|
|
117
|
+
DEST="$DATA_DIR/${config.applicationId}"
|
|
118
|
+
mkdir -p "$DEST" "$DATA_DIR/applications"
|
|
119
|
+
if [ "$APP_DIR" != "$DEST" ]; then cp -R "$APP_DIR/." "$DEST/"; fi
|
|
120
|
+
python3 - "$DEST" "$DATA_DIR/applications/${config.applicationId}.desktop" <<'PY'
|
|
121
|
+
import pathlib, sys
|
|
122
|
+
root = pathlib.Path(sys.argv[1])
|
|
123
|
+
entry = (root / ${quote(`${config.applicationId}.desktop`)}).read_text()
|
|
124
|
+
# Desktop Exec quoting has two layers: string escapes, then argument escapes.
|
|
125
|
+
executable = str(root / ${quote(config.executableName)})
|
|
126
|
+
executable = executable.replace('\\\\', '\\\\\\\\\\\\\\\\').replace('"', '\\\\\\\\"').replace('\\x60', '\\\\\\\\x60').replace('$', '\\\\\\\\$').replace('%', '%%')
|
|
127
|
+
entry = entry.replace(${quote(`Exec=${config.executableName} %u`)}, 'Exec="' + executable + '" %u')
|
|
128
|
+
pathlib.Path(sys.argv[2]).write_text(entry)
|
|
129
|
+
PY
|
|
130
|
+
command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database "$DATA_DIR/applications" || true
|
|
131
|
+
printf 'Installed to %s\\n' "$DEST"
|
|
132
|
+
`);
|
|
133
|
+
chmodSync(join(appDir, "install.sh"), 493);
|
|
134
|
+
writeFileSync(join(appDir, "README.txt"), `${config.productName} ${config.version}\nRun ./${config.executableName} from any directory, or ./install.sh to copy into XDG_DATA_HOME and install the desktop entry.\nRequires Python 3 for installation; GJS, GTK4 (4.10+), libadwaita, WebKitGTK 6.0, libsecret, a graphical session, and D-Bus for execution.\nUbuntu 24.04: sudo apt install gjs gir1.2-gtk-4.0 gir1.2-adw-1 gir1.2-webkit-6.0 gir1.2-secret-1 python3 desktop-file-utils xdg-utils\nSecret storage needs an unlocked Secret Service keyring. Notifications need a desktop notification service.\nRegister incoming links with: xdg-mime default ${config.applicationId}.desktop x-scheme-handler/${config.scheme}\nRemove the installed application directory and ${config.applicationId}.desktop from XDG_DATA_HOME/applications to uninstall.\n`);
|
|
135
|
+
}
|
|
136
|
+
execFileSync("tar", [
|
|
137
|
+
"-czf",
|
|
138
|
+
join(staging, archiveName),
|
|
139
|
+
"-C",
|
|
140
|
+
staging,
|
|
141
|
+
config.executableName
|
|
142
|
+
], { stdio: "inherit" });
|
|
143
|
+
if (!publish) {
|
|
144
|
+
preserveStaging = true;
|
|
145
|
+
return {
|
|
146
|
+
version: 1,
|
|
147
|
+
runtime: config.runtime,
|
|
148
|
+
executableName: config.executableName,
|
|
149
|
+
packageVersion: config.version,
|
|
150
|
+
appDir,
|
|
151
|
+
archive: join(staging, archiveName)
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const destination = join(output, config.executableName);
|
|
155
|
+
const backup = join(staging, "previous");
|
|
156
|
+
if (existsSync(destination)) renameSync(destination, backup);
|
|
157
|
+
try {
|
|
158
|
+
renameSync(appDir, destination);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
if (existsSync(backup)) renameSync(backup, destination);
|
|
161
|
+
throw error;
|
|
162
|
+
}
|
|
163
|
+
renameSync(join(staging, archiveName), join(output, archiveName));
|
|
164
|
+
console.log(`[linux-package] ${destination}\n[linux-package] ${join(output, archiveName)}`);
|
|
165
|
+
return {
|
|
166
|
+
appDir: destination,
|
|
167
|
+
archive: join(output, archiveName)
|
|
168
|
+
};
|
|
169
|
+
} finally {
|
|
170
|
+
if (!preserveStaging) rmSync(staging, {
|
|
171
|
+
recursive: true,
|
|
172
|
+
force: true
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
export { packageLinux };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { UserConfig } from 'vite'
|
|
2
|
+
|
|
3
|
+
export interface XplatLinuxGtkOptions {
|
|
4
|
+
/** App directory used to resolve its toolchain and renderer. Defaults to cwd. */
|
|
5
|
+
root?: string
|
|
6
|
+
/** Enable Octane's universal component HMR. Defaults to false. */
|
|
7
|
+
hmr?: boolean
|
|
8
|
+
/** Override the application entry; defaults to src/main.ts. */
|
|
9
|
+
entry?: string
|
|
10
|
+
outDir?: string
|
|
11
|
+
/** Output file name (without extension); defaults to 'app'. */
|
|
12
|
+
fileName?: string
|
|
13
|
+
/** Sources the Octane compiler must not transform. */
|
|
14
|
+
exclude?: string[]
|
|
15
|
+
/** Override renderer rules; defaults to all reachable TSX/TSRX source. */
|
|
16
|
+
rules?: unknown[]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Configure the experimental GTK4/GJS renderer using the app's installed toolchain. */
|
|
20
|
+
export function xplatLinuxGtk(
|
|
21
|
+
env: { mode: string } | string,
|
|
22
|
+
options?: XplatLinuxGtkOptions,
|
|
23
|
+
): Promise<UserConfig>
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { xplatCss } from "../css-platform.js";
|
|
2
|
+
import { xplatBoundary, xplatNodeEnvDefine } from "../vite.js";
|
|
3
|
+
import { xplatInlineStylesheets } from "../inline-stylesheets.js";
|
|
4
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
import { join, resolve } from "node:path";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
// ../cli/src/linux-gtk/vite.ts
|
|
9
|
+
var renderer = "@octane-xplat/linux-gtk";
|
|
10
|
+
/** Slot-compiled modules can emit the same `withSlot`/`hookSlots`
|
|
11
|
+
* import binding in two import statements of a single module (octane's
|
|
12
|
+
* universal compiler dedupes `hookSlots` intra-file but not `withSlot` —
|
|
13
|
+
* e.g. `Button.tsrx`; plain `.ts` hook helpers emit duplicate `hookSlots`
|
|
14
|
+
* under generated `_$hookSlots$` locals too). Rolldown only dedupes
|
|
15
|
+
* bindings across modules, so the duplicate survives to a `_$withSlot`
|
|
16
|
+
* redeclaration error in the merged chunk. Keep the first binding per
|
|
17
|
+
* export and fold later local names into it. Different specifiers are a
|
|
18
|
+
* real conflict — bail. */
|
|
19
|
+
function xplatGtkSlotDedupe() {
|
|
20
|
+
return {
|
|
21
|
+
name: "xplat-gtk-slot-dedupe",
|
|
22
|
+
transform(code, id) {
|
|
23
|
+
if (!/\.(tsrx|tsx|ts|mts|js|mjs)$/.test(id)) return;
|
|
24
|
+
if (!code.includes("withSlot as _") && !code.includes("hookSlots as _")) return;
|
|
25
|
+
const firstLocal = /* @__PURE__ */ new Map();
|
|
26
|
+
const firstSpec = /* @__PURE__ */ new Map();
|
|
27
|
+
const fold = /* @__PURE__ */ new Map();
|
|
28
|
+
let changed = false;
|
|
29
|
+
let out = code.replace(/import\s*\{([^}]*)\}\s*from\s*['"]([^'"]+)['"];?/g, (stmt, names, spec) => {
|
|
30
|
+
const kept = [];
|
|
31
|
+
for (const raw of names.split(",")) {
|
|
32
|
+
const part = raw.trim();
|
|
33
|
+
const m = part.match(/^(withSlot|hookSlots) as (_\$[A-Za-z0-9_$]+)$/);
|
|
34
|
+
if (!m) {
|
|
35
|
+
if (part) kept.push(part);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const [, kind, local] = m;
|
|
39
|
+
const prev = firstSpec.get(kind);
|
|
40
|
+
if (prev !== void 0 && prev !== spec) throw new Error(`xplat-gtk-slot-dedupe: ${kind} imported from '${prev}' and '${spec}' in ${id}`);
|
|
41
|
+
if (firstLocal.has(kind)) {
|
|
42
|
+
if (local !== firstLocal.get(kind)) fold.set(local, firstLocal.get(kind));
|
|
43
|
+
changed = true;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
firstLocal.set(kind, local);
|
|
47
|
+
firstSpec.set(kind, spec);
|
|
48
|
+
kept.push(part);
|
|
49
|
+
}
|
|
50
|
+
if (!kept.length) {
|
|
51
|
+
changed = true;
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
return `import { ${kept.join(", ")} } from '${spec}';`;
|
|
55
|
+
});
|
|
56
|
+
for (const [from, to] of fold) {
|
|
57
|
+
const rx = new RegExp(from.replace(/\$/g, "\\$") + "(?![\\w$])", "g");
|
|
58
|
+
if (rx.test(out)) {
|
|
59
|
+
changed = true;
|
|
60
|
+
out = out.replace(rx, to);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return changed ? { code: out } : void 0;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** GTK4/GJS compiler and bundle setup; the consuming app owns the toolchain.
|
|
68
|
+
* Produces a single ESM file `gjs -m` executes — the Octane universal
|
|
69
|
+
* runtime and the app's components are bundled; `gi://` introspection
|
|
70
|
+
* imports stay external because the GI libraries are the platform. */
|
|
71
|
+
/** Shared sources import siblings with explicit extensions so Node can
|
|
72
|
+
* type-strip them — but the extension pins the native-default leaf and
|
|
73
|
+
* skips platform resolution. A GTK bundle redirects to the .gtk sibling
|
|
74
|
+
* when one exists, restoring what extension probing did when the same
|
|
75
|
+
* imports were extensionless. */
|
|
76
|
+
function xplatGtkLeafResolve() {
|
|
77
|
+
return {
|
|
78
|
+
name: "xplat-gtk-leaf-resolve",
|
|
79
|
+
resolveId: {
|
|
80
|
+
order: "pre",
|
|
81
|
+
handler(source, importer) {
|
|
82
|
+
if (!importer || !/^\.{1,2}\//.test(source)) return null;
|
|
83
|
+
const match = source.match(/\.(tsrx|tsx|ts|mts|mjs|jsx|js)$/);
|
|
84
|
+
if (!match || source.includes(".gtk.") || source.includes(".d.")) return null;
|
|
85
|
+
const stem = source.slice(0, -match[0].length);
|
|
86
|
+
if (stem.endsWith(".gtk")) return null;
|
|
87
|
+
const candidate = join(importer, "..", stem + ".gtk" + match[0]);
|
|
88
|
+
return existsSync(candidate) ? candidate : null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
async function xplatLinuxGtk(env, options = {}) {
|
|
94
|
+
const mode = typeof env === "string" ? env : env.mode;
|
|
95
|
+
const root = resolve(options.root ?? process.cwd());
|
|
96
|
+
const appRequire = createRequire(join(root, "package.json"));
|
|
97
|
+
const { octane } = await import(pathToFileURL(realpathSync(appRequire.resolve("@octanejs/vite-plugin"))).href);
|
|
98
|
+
const resolveApp = (name) => realpathSync(appRequire.resolve(name));
|
|
99
|
+
const rendererEntry = resolveApp(renderer);
|
|
100
|
+
const universalNative = realpathSync(appRequire.resolve("octane/universal/native"));
|
|
101
|
+
return {
|
|
102
|
+
root,
|
|
103
|
+
define: xplatNodeEnvDefine(mode),
|
|
104
|
+
plugins: [
|
|
105
|
+
xplatGtkLeafResolve(),
|
|
106
|
+
xplatGtkSlotDedupe(),
|
|
107
|
+
xplatCss("gtk"),
|
|
108
|
+
xplatInlineStylesheets(),
|
|
109
|
+
xplatBoundary("gtk"),
|
|
110
|
+
octane({
|
|
111
|
+
hmr: options.hmr ?? false,
|
|
112
|
+
exclude: options.exclude,
|
|
113
|
+
renderers: {
|
|
114
|
+
default: "gtk",
|
|
115
|
+
registry: { gtk: {
|
|
116
|
+
module: renderer,
|
|
117
|
+
target: "universal",
|
|
118
|
+
server: "unsupported",
|
|
119
|
+
text: "host",
|
|
120
|
+
intrinsics: "@octane-xplat/jsx"
|
|
121
|
+
} },
|
|
122
|
+
rules: options.rules ?? [{
|
|
123
|
+
include: "**/*.{tsx,tsrx}",
|
|
124
|
+
renderer: "gtk"
|
|
125
|
+
}]
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
],
|
|
129
|
+
build: {
|
|
130
|
+
cssCodeSplit: true,
|
|
131
|
+
outDir: options.outDir ?? "dist",
|
|
132
|
+
emptyOutDir: true,
|
|
133
|
+
lib: {
|
|
134
|
+
entry: options.entry ?? "src/main.ts",
|
|
135
|
+
formats: ["es"],
|
|
136
|
+
fileName: options.fileName ?? "app"
|
|
137
|
+
},
|
|
138
|
+
rollupOptions: {
|
|
139
|
+
external: (id) => id.startsWith("gi://"),
|
|
140
|
+
output: { inlineDynamicImports: true }
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
resolve: {
|
|
144
|
+
conditions: ["gtk", "native"],
|
|
145
|
+
dedupe: ["octane"],
|
|
146
|
+
alias: [
|
|
147
|
+
{
|
|
148
|
+
find: /^octane$/,
|
|
149
|
+
replacement: universalNative
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
find: /^octane\/universal\/native$/,
|
|
153
|
+
replacement: universalNative
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
find: /^@nativescript-community\/octane$/,
|
|
157
|
+
replacement: rendererEntry
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
find: /^@octane-xplat\/linux-gtk$/,
|
|
161
|
+
replacement: rendererEntry
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
find: /(^|.*\/)escape-props$/,
|
|
165
|
+
replacement: resolveApp(`${renderer}/compat/escape-props`)
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
find: /^@nativescript\/core$/,
|
|
169
|
+
replacement: resolveApp(`${renderer}/compat/native-core`)
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
find: /^@nativescript\/core\/animation-frame$/,
|
|
173
|
+
replacement: resolveApp(`${renderer}/compat/native-core`)
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
extensions: [
|
|
177
|
+
".gtk.tsrx",
|
|
178
|
+
".tsrx",
|
|
179
|
+
".gtk.tsx",
|
|
180
|
+
".tsx",
|
|
181
|
+
".gtk.ts",
|
|
182
|
+
".gtk.mts",
|
|
183
|
+
".gtk.mjs",
|
|
184
|
+
".mjs",
|
|
185
|
+
".mts",
|
|
186
|
+
".ts",
|
|
187
|
+
".jsx",
|
|
188
|
+
".js",
|
|
189
|
+
".json"
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
export { xplatGtkLeafResolve, xplatGtkSlotDedupe, xplatLinuxGtk };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { minimumJscHostSystemVersion } from "./jsc-host/runtime.js";
|
|
2
|
+
import { existsSync, statSync } from "node:fs";
|
|
3
|
+
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
4
|
+
// ../cli/src/macos/config.ts
|
|
5
|
+
var requiredPackageFields = [
|
|
6
|
+
"productName",
|
|
7
|
+
"bundleIdentifier",
|
|
8
|
+
"executableName",
|
|
9
|
+
"version",
|
|
10
|
+
"minimumSystemVersion"
|
|
11
|
+
];
|
|
12
|
+
var macOSRenderers = /* @__PURE__ */ new Set(["appkit", "webview"]);
|
|
13
|
+
function rendererOf(value, issues, prefix) {
|
|
14
|
+
const renderer = value ?? "appkit";
|
|
15
|
+
if (!macOSRenderers.has(renderer)) {
|
|
16
|
+
issues.push(`${prefix}.renderer must be "appkit" or "webview"`);
|
|
17
|
+
return "appkit";
|
|
18
|
+
}
|
|
19
|
+
return renderer;
|
|
20
|
+
}
|
|
21
|
+
function resolveBuildPaths(appRoot, settings, issues, prefix, renderer, stage) {
|
|
22
|
+
const webview = renderer === "webview";
|
|
23
|
+
const names = webview ? [
|
|
24
|
+
"webViteConfig",
|
|
25
|
+
"hostViteConfig",
|
|
26
|
+
"hostBundleFile",
|
|
27
|
+
...stage === "package" ? ["webOutDir"] : []
|
|
28
|
+
] : ["viteConfig", "bundleFile"];
|
|
29
|
+
const paths = {};
|
|
30
|
+
for (const key of names) {
|
|
31
|
+
if (typeof settings[key] !== "string" || !settings[key].trim()) {
|
|
32
|
+
issues.push(`missing ${prefix}.${key}`);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
paths[key] = resolveProjectPath(appRoot, settings[key], `${prefix.slice(20)} ${key}`, issues, { mustExist: key.endsWith("Config") });
|
|
36
|
+
}
|
|
37
|
+
const bundleKey = webview ? "hostBundleFile" : "bundleFile";
|
|
38
|
+
if (typeof settings[bundleKey] === "string" && !settings[bundleKey].endsWith(".cjs")) issues.push(`macOS ${bundleKey} must point to a CommonJS .cjs bundle`);
|
|
39
|
+
return paths;
|
|
40
|
+
}
|
|
41
|
+
var macOSVersionPattern = /^\d+(?:\.\d+){1,2}$/;
|
|
42
|
+
function compareVersions(left, right) {
|
|
43
|
+
const leftParts = left.split(".").map(Number);
|
|
44
|
+
const rightParts = right.split(".").map(Number);
|
|
45
|
+
for (let index = 0; index < Math.max(leftParts.length, rightParts.length); index++) {
|
|
46
|
+
const difference = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
|
|
47
|
+
if (difference !== 0) return difference;
|
|
48
|
+
}
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
function resolveProjectPath(root, value, label, issues, { mustExist = false } = {}) {
|
|
52
|
+
if (typeof value !== "string" || !value.trim() || isAbsolute(value)) {
|
|
53
|
+
issues.push(`${label} must be a path relative to the app root`);
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const path = resolve(root, value);
|
|
57
|
+
const fromRoot = relative(root, path);
|
|
58
|
+
if (fromRoot === ".." || fromRoot.startsWith(`..${sep}`) || isAbsolute(fromRoot)) {
|
|
59
|
+
issues.push(`${label} must stay inside the app root`);
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (mustExist && !existsSync(path)) {
|
|
63
|
+
issues.push(`${label} does not exist: ${value}`);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return path;
|
|
67
|
+
}
|
|
68
|
+
/** Validate the macOS packaging contract shared by `xplat build` and `doctor`. */
|
|
69
|
+
function inspectMacOSPackageConfig(appRoot, value, selectedRenderer) {
|
|
70
|
+
const issues = [];
|
|
71
|
+
const settings = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
72
|
+
if (settings !== value) issues.push("xplat.targets.macos.package must be an object");
|
|
73
|
+
for (const key of requiredPackageFields) if (typeof settings[key] !== "string" || !settings[key].trim()) issues.push(`missing xplat.targets.macos.package.${key}`);
|
|
74
|
+
const renderer = rendererOf(selectedRenderer, issues, "xplat.targets.macos");
|
|
75
|
+
if (settings.bundleIdentifier && !/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/.test(settings.bundleIdentifier)) issues.push(`invalid macOS bundle identifier: ${settings.bundleIdentifier}`);
|
|
76
|
+
if (settings.executableName && !/^[A-Za-z0-9][A-Za-z0-9._ -]*$/.test(settings.executableName)) issues.push(`invalid macOS executable name: ${settings.executableName}`);
|
|
77
|
+
if (settings.version && !/^\d+(?:\.\d+){1,2}$/.test(settings.version)) issues.push(`invalid macOS bundle version: ${settings.version}`);
|
|
78
|
+
if (settings.minimumSystemVersion && !macOSVersionPattern.test(settings.minimumSystemVersion)) issues.push(`invalid macOS minimum system version: ${settings.minimumSystemVersion}`);
|
|
79
|
+
if (typeof settings.minimumSystemVersion === "string" && macOSVersionPattern.test(settings.minimumSystemVersion) && compareVersions(settings.minimumSystemVersion, "13.5") < 0) issues.push(`macOS minimum system version must be at least ${minimumJscHostSystemVersion} for the JavaScriptCore host`);
|
|
80
|
+
const buildPaths = resolveBuildPaths(appRoot, settings, issues, "xplat.targets.macos.package", renderer, "package");
|
|
81
|
+
const iconPath = settings.icon === void 0 ? null : resolveProjectPath(appRoot, settings.icon, "macOS icon", issues, { mustExist: true });
|
|
82
|
+
if (iconPath) try {
|
|
83
|
+
if (!statSync(iconPath).isFile()) issues.push("macOS icon must point to a file");
|
|
84
|
+
} catch {
|
|
85
|
+
issues.push("macOS icon could not be inspected");
|
|
86
|
+
}
|
|
87
|
+
if (typeof settings.icon === "string" && settings.icon && !settings.icon.toLowerCase().endsWith(".icns")) issues.push("macOS icon must point to an .icns file");
|
|
88
|
+
const entitlementsPath = settings.entitlements === void 0 ? null : resolveProjectPath(appRoot, settings.entitlements, "macOS entitlements", issues, { mustExist: true });
|
|
89
|
+
if (settings.infoPlist !== void 0) {
|
|
90
|
+
if (!settings.infoPlist || typeof settings.infoPlist !== "object" || Array.isArray(settings.infoPlist)) issues.push("xplat.targets.macos.package.infoPlist must be an object");
|
|
91
|
+
else for (const [key, value] of Object.entries(settings.infoPlist)) {
|
|
92
|
+
if (!/^[A-Za-z0-9._() -]+$/.test(key)) {
|
|
93
|
+
issues.push(`invalid macOS Info.plist key: ${key}`);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const kind = typeof value;
|
|
97
|
+
if (kind !== "string" && kind !== "boolean" && kind !== "number") issues.push(`xplat.targets.macos.package.infoPlist.${key} must be a string, number, or boolean`);
|
|
98
|
+
else if (kind === "number" && !Number.isInteger(value)) issues.push(`xplat.targets.macos.package.infoPlist.${key} must be an integer`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
settings,
|
|
103
|
+
renderer,
|
|
104
|
+
...buildPaths,
|
|
105
|
+
iconPath,
|
|
106
|
+
entitlementsPath,
|
|
107
|
+
issues
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** Validate the CLI-owned CommonJS dev runner configuration. */
|
|
111
|
+
function inspectMacOSDevConfig(appRoot, value, selectedRenderer) {
|
|
112
|
+
const issues = [];
|
|
113
|
+
const settings = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
114
|
+
if (settings !== value) issues.push("xplat.targets.macos.dev must be an object");
|
|
115
|
+
const renderer = rendererOf(selectedRenderer, issues, "xplat.targets.macos");
|
|
116
|
+
if (renderer === "webview") return {
|
|
117
|
+
...resolveBuildPaths(appRoot, settings, issues, "xplat.targets.macos.dev", renderer, "dev"),
|
|
118
|
+
issues
|
|
119
|
+
};
|
|
120
|
+
const paths = {};
|
|
121
|
+
for (const key of [
|
|
122
|
+
"viteConfig",
|
|
123
|
+
"bundleFile",
|
|
124
|
+
"shellViteConfig",
|
|
125
|
+
"shellBundleFile"
|
|
126
|
+
]) {
|
|
127
|
+
if (settings[key] === void 0 && key.startsWith("shell")) continue;
|
|
128
|
+
if (typeof settings[key] !== "string" || !settings[key].trim()) {
|
|
129
|
+
issues.push(`missing xplat.targets.macos.dev.${key}`);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
paths[key] = resolveProjectPath(appRoot, settings[key], `macOS dev ${key}`, issues, { mustExist: key.endsWith("Config") });
|
|
133
|
+
if (key.endsWith("File") && !settings[key].endsWith(".cjs")) issues.push(`macOS dev ${key} must end in .cjs`);
|
|
134
|
+
}
|
|
135
|
+
if (Boolean(settings.shellViteConfig) !== Boolean(settings.shellBundleFile)) issues.push("macOS dev shellViteConfig and shellBundleFile must be specified together");
|
|
136
|
+
return {
|
|
137
|
+
...paths,
|
|
138
|
+
issues
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
export { inspectMacOSDevConfig, inspectMacOSPackageConfig };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { runDoctorTool } from "../doctor-tool.js";
|
|
2
|
+
import { inspectMacOSDevConfig, inspectMacOSPackageConfig } from "./config.js";
|
|
3
|
+
import { inspectMacOSNative } from "./native.js";
|
|
4
|
+
import { inspectJscHost } from "./jsc-host/runtime.js";
|
|
5
|
+
import { inspectMacOSRuntimePackage, macOSRuntimePackageName } from "./runtime-package.js";
|
|
6
|
+
// ../cli/src/macos/doctor-checks.ts
|
|
7
|
+
/** Tool and payload observations only; no app launch or native compilation. */
|
|
8
|
+
async function inspectMacOSDoctor(cwd, manifest, hostPackage = "@octane-xplat/cli") {
|
|
9
|
+
const rows = [];
|
|
10
|
+
const row = (name, ok, detail, hint) => rows.push({
|
|
11
|
+
name,
|
|
12
|
+
ok,
|
|
13
|
+
detail,
|
|
14
|
+
hint
|
|
15
|
+
});
|
|
16
|
+
const target = manifest.xplat?.targets?.macos ?? {};
|
|
17
|
+
const packageConfig = target.package ?? {};
|
|
18
|
+
const runtimeVersion = manifest.dependencies?.["@nativescript/macos-node-api"] ?? manifest.devDependencies?.["@nativescript/macos-node-api"];
|
|
19
|
+
const runtimeInspection = inspectMacOSRuntimePackage(cwd);
|
|
20
|
+
let runtimeHint;
|
|
21
|
+
if (typeof runtimeVersion !== "string") runtimeHint = `declare ${macOSRuntimePackageName} in dependencies`;
|
|
22
|
+
else if (!runtimeInspection.packageManifest) runtimeHint = `declared ${runtimeVersion}, but its installed package.json is missing or unreadable; run bun install`;
|
|
23
|
+
else if (runtimeInspection.missingPaths.length) runtimeHint = `installed ${runtimeInspection.packageManifest.version ?? runtimeVersion} is missing required files: ${runtimeInspection.missingPaths.join(", ")}; install a compatible ${macOSRuntimePackageName} release`;
|
|
24
|
+
const scripts = manifest.scripts ?? {};
|
|
25
|
+
const macHost = process.platform === "darwin";
|
|
26
|
+
const signingIdentity = process.env.MACOS_SIGNING_IDENTITY;
|
|
27
|
+
const notaryProfile = process.env.MACOS_NOTARY_PROFILE;
|
|
28
|
+
const packageInspection = inspectMacOSPackageConfig(cwd, target.package, target.renderer);
|
|
29
|
+
const packageIssues = [...packageInspection.issues];
|
|
30
|
+
if (signingIdentity && !packageInspection.entitlementsPath) packageIssues.push("set xplat.targets.macos.package.entitlements when signing");
|
|
31
|
+
row("macOS host", macHost, process.platform, target.renderer === "webview" ? "run WKWebView with the JavaScriptCore + NativeScript host on macOS" : "run AppKit Node-API development and packaging on macOS");
|
|
32
|
+
row("macOS architecture", process.arch === "arm64" || process.arch === "x64", process.arch === "x64" ? "x86_64" : process.arch, "the packaged runtime targets macOS arm64 and x86_64 (universal)");
|
|
33
|
+
row("macOS dev script", target.dev ? inspectMacOSDevConfig(cwd, target.dev, target.renderer).issues.length === 0 : typeof scripts.dev === "string", target.dev ? inspectMacOSDevConfig(cwd, target.dev, target.renderer).issues.join("; ") || (target.renderer === "webview" ? "CLI-owned WKWebView + JavaScriptCore runner" : "CLI-owned AppKit Node-API runner") : scripts.dev ? "present" : "missing", "declare xplat.targets.macos.dev (required for native leaves), or scripts.dev for an existing JS-only runner");
|
|
34
|
+
row("macOS package config", packageIssues.length === 0, packageIssues.length ? packageIssues.join("; ") : packageConfig.bundleIdentifier, "declare xplat.targets.macos.package metadata and valid Vite/entitlements paths");
|
|
35
|
+
row("macOS NativeScript declarations", runtimeHint === void 0, runtimeInspection.packageManifest?.version ?? runtimeVersion ?? "not declared", runtimeHint);
|
|
36
|
+
const jscHost = inspectJscHost();
|
|
37
|
+
row("macOS JavaScriptCore package host", jscHost.issues.length === 0, jscHost.issues.length ? jscHost.issues.join("; ") : "pinned universal host and addon verified", `reinstall ${hostPackage} or rebuild its pinned macOS host artifacts`);
|
|
38
|
+
try {
|
|
39
|
+
const native = await inspectMacOSNative(cwd);
|
|
40
|
+
row("macOS native leaf toolchain", true, native.leaves.length ? `${native.leaves.length} leaves; SDK ${native.toolchain.sdk}; ${native.toolchain.libclang}` : "no native leaves; no compilation tools needed");
|
|
41
|
+
if (native.leaves.length) row("macOS native dev runner", Boolean(target.dev), target.dev ? "configured" : "missing", "declare xplat.targets.macos.dev so native changes rebuild and restart the host");
|
|
42
|
+
} catch (error) {
|
|
43
|
+
row("macOS native leaf toolchain", false, String(error), "fix the named package inputs, install/select Xcode and Command Line Tools, and install Zig only for Zig leaves");
|
|
44
|
+
}
|
|
45
|
+
if (macHost) {
|
|
46
|
+
const codesign = runDoctorTool("codesign", ["--verify", "/usr/bin/codesign"]);
|
|
47
|
+
const hdiutil = runDoctorTool("hdiutil", ["help"]);
|
|
48
|
+
row("codesign", codesign.ok, codesign.out || "available", "ensure /usr/bin/codesign is available");
|
|
49
|
+
row("hdiutil", hdiutil.ok, hdiutil.out || "available", "install macOS command-line tools");
|
|
50
|
+
}
|
|
51
|
+
if (notaryProfile) {
|
|
52
|
+
const notarytool = runDoctorTool("xcrun", ["notarytool", "--version"]);
|
|
53
|
+
row("macOS notarization signing", !!signingIdentity, signingIdentity ? "Developer ID configured" : "not configured", "set MACOS_SIGNING_IDENTITY when MACOS_NOTARY_PROFILE is set");
|
|
54
|
+
row("xcrun notarytool", notarytool.ok, notarytool.out || "unavailable", "install Xcode Command Line Tools");
|
|
55
|
+
}
|
|
56
|
+
return rows;
|
|
57
|
+
}
|
|
58
|
+
export { inspectMacOSDoctor };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { prebuiltRoot } from "./jsc-host/runtime.js";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import { chmod, mkdir, mkdtemp, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
6
|
+
// ../cli/src/macos/executables.ts
|
|
7
|
+
var hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
8
|
+
async function macOSExecutable(appRoot, relativePath) {
|
|
9
|
+
const expected = JSON.parse(readFileSync(join(prebuiltRoot, "manifest.json"), "utf8")).sha256[relativePath];
|
|
10
|
+
const bytes = await readFile(join(prebuiltRoot, relativePath));
|
|
11
|
+
if (!expected || hash(bytes) !== expected) throw new Error(`macOS executable checksum differs: ${relativePath}`);
|
|
12
|
+
const cache = join(appRoot, "node_modules/.cache/xplat/macos-tools");
|
|
13
|
+
const directory = join(cache, expected);
|
|
14
|
+
const executable = join(directory, "tool");
|
|
15
|
+
try {
|
|
16
|
+
if (hash(await readFile(executable)) === expected) {
|
|
17
|
+
await chmod(executable, 493);
|
|
18
|
+
return executable;
|
|
19
|
+
}
|
|
20
|
+
} catch {}
|
|
21
|
+
await mkdir(cache, { recursive: true });
|
|
22
|
+
const staging = await mkdtemp(join(cache, ".tool-"));
|
|
23
|
+
try {
|
|
24
|
+
await writeFile(join(staging, "tool"), bytes, { mode: 493 });
|
|
25
|
+
try {
|
|
26
|
+
await rename(staging, directory);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
if (error.code !== "EEXIST" && error.code !== "ENOTEMPTY") throw error;
|
|
29
|
+
if (hash(await readFile(executable)) !== expected) throw new Error(`Corrupt macOS executable cache: ${directory}; remove it and retry`);
|
|
30
|
+
}
|
|
31
|
+
return executable;
|
|
32
|
+
} finally {
|
|
33
|
+
await rm(staging, {
|
|
34
|
+
recursive: true,
|
|
35
|
+
force: true
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export { macOSExecutable };
|