@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,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, "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("; ") || "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 };
@@ -0,0 +1,134 @@
1
+ import { srcUrl } from "../../env.js";
2
+ import { readFileSync, statSync } from "node:fs";
3
+ import "node:module";
4
+ import { join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { createHash } from "node:crypto";
7
+ // ../cli/src/macos/jsc-host/runtime.ts
8
+ var hostRoot = fileURLToPath(srcUrl(import.meta.url, ""));
9
+ var prebuiltRoot = join(hostRoot, "prebuilt");
10
+ join(prebuiltRoot, "macos");
11
+ var minimumJscHostSystemVersion = "13.5";
12
+ var macOSArchitectures = ["arm64", "x86_64"];
13
+ function isFile(path) {
14
+ try {
15
+ return statSync(path).isFile();
16
+ } catch {
17
+ return false;
18
+ }
19
+ }
20
+ var machOArchNames = /* @__PURE__ */ new Map([[16777228, "arm64"], [16777223, "x86_64"]]);
21
+ /** Slice `bytes` into thin Mach-O images: itself, or each fat-arch member. */
22
+ function machOSlices(bytes) {
23
+ const magic = bytes.readUInt32BE(0);
24
+ if (magic !== 3405691582 && magic !== 3405691583) return [bytes];
25
+ const wide = magic === 3405691583;
26
+ const count = bytes.readUInt32BE(4);
27
+ const entrySize = wide ? 32 : 20;
28
+ const slices = [];
29
+ for (let index = 0; index < count; index++) {
30
+ const entry = 8 + index * entrySize;
31
+ if (entry + entrySize > bytes.length) break;
32
+ const offset = wide ? Number(bytes.readBigUInt64BE(entry + 8)) : bytes.readUInt32BE(entry + 8);
33
+ const size = wide ? Number(bytes.readBigUInt64BE(entry + 16)) : bytes.readUInt32BE(entry + 12);
34
+ slices.push(bytes.subarray(offset, offset + size));
35
+ }
36
+ return slices;
37
+ }
38
+ function inspectMachO(bytes, label, issues, minimumSystemVersion = minimumJscHostSystemVersion, architectures = macOSArchitectures) {
39
+ if (bytes.length < 32) {
40
+ issues.push(`${label} is not a Mach-O binary`);
41
+ return;
42
+ }
43
+ const found = /* @__PURE__ */ new Set();
44
+ let images = 0;
45
+ for (const slice of machOSlices(bytes)) {
46
+ if (slice.length < 32 || slice.readUInt32LE(0) !== 4277009103) continue;
47
+ images++;
48
+ const arch = machOArchNames.get(slice.readUInt32LE(4));
49
+ if (arch) found.add(arch);
50
+ inspectThinMachO(slice, arch ? `${label} (${arch})` : label, issues, minimumSystemVersion);
51
+ }
52
+ if (!images) {
53
+ issues.push(`${label} is not a Mach-O binary`);
54
+ return;
55
+ }
56
+ for (const arch of architectures) if (!found.has(arch)) issues.push(`${label} lacks an ${arch} slice`);
57
+ }
58
+ function inspectThinMachO(slice, label, issues, minimumSystemVersion) {
59
+ const commands = slice.readUInt32LE(16);
60
+ let offset = 32;
61
+ let minimumVersion;
62
+ for (let index = 0; index < commands; index++) {
63
+ if (offset + 8 > slice.length) {
64
+ issues.push(`${label} has truncated load commands`);
65
+ return;
66
+ }
67
+ const command = slice.readUInt32LE(offset);
68
+ const size = slice.readUInt32LE(offset + 4);
69
+ if (size < 8 || offset + size > slice.length) {
70
+ issues.push(`${label} has invalid load commands`);
71
+ return;
72
+ }
73
+ if (command === 50 && size >= 24) {
74
+ const version = slice.readUInt32LE(offset + 12);
75
+ minimumVersion = `${version >>> 16}.${version >>> 8 & 255}`;
76
+ }
77
+ if (command === 12 && size >= 24) {
78
+ const nameOffset = slice.readUInt32LE(offset + 8);
79
+ if (nameOffset < size) {
80
+ const name = slice.toString("utf8", offset + nameOffset, offset + size).split("\0")[0];
81
+ if (name.startsWith("@rpath/")) issues.push(`${label} requires an unpackaged library: ${name}`);
82
+ }
83
+ }
84
+ offset += size;
85
+ }
86
+ if (!minimumVersion) issues.push(`${label} does not declare a macOS deployment target`);
87
+ else {
88
+ const [major, minor] = minimumVersion.split(".").map(Number);
89
+ const [allowedMajor, allowedMinor] = minimumSystemVersion.split(".").map(Number);
90
+ if (major > allowedMajor || major === allowedMajor && minor > allowedMinor) issues.push(`${label} requires macOS ${minimumVersion}, above the declared ${minimumSystemVersion}`);
91
+ }
92
+ }
93
+ function inspectJscHost() {
94
+ const issues = [];
95
+ let manifest;
96
+ try {
97
+ manifest = JSON.parse(readFileSync(join(prebuiltRoot, "manifest.json"), "utf8"));
98
+ } catch {
99
+ return {
100
+ issues: ["JavaScriptCore host manifest is missing or invalid"],
101
+ manifest: null
102
+ };
103
+ }
104
+ for (const [relativePath, expectedHash] of Object.entries(manifest.sha256 ?? {})) {
105
+ const path = join(prebuiltRoot, relativePath);
106
+ if (!isFile(path)) {
107
+ issues.push(`JavaScriptCore host file is missing: ${relativePath}`);
108
+ continue;
109
+ }
110
+ const bytes = readFileSync(path);
111
+ if (createHash("sha256").update(bytes).digest("hex") !== expectedHash) issues.push(`JavaScriptCore host checksum mismatch: ${relativePath}`);
112
+ if (relativePath.endsWith("/host") || relativePath.endsWith("/NativeScript")) inspectMachO(bytes, relativePath, issues);
113
+ else if (relativePath.endsWith("/objc-metadata-generator")) {
114
+ const generatorIssues = [];
115
+ inspectMachO(bytes, relativePath, generatorIssues, minimumJscHostSystemVersion);
116
+ issues.push(...generatorIssues.filter((issue) => !issue.includes("unpackaged library")));
117
+ }
118
+ }
119
+ for (const relativePath of [
120
+ "macos/host",
121
+ "macos/metadata.macos.arm64.nsmd",
122
+ "macos/metadata.macos.x86_64.nsmd",
123
+ "macos/NativeScript.framework/Versions/A/NativeScript",
124
+ "macos/objc-metadata-generator"
125
+ ]) if (!manifest.sha256?.[relativePath]) issues.push(`JavaScriptCore host manifest omits ${relativePath}`);
126
+ if (!Array.isArray(manifest.architectures) || manifest.architectures.length !== macOSArchitectures.length || !macOSArchitectures.every((arch) => manifest.architectures.includes(arch))) issues.push(`JavaScriptCore host manifest architectures must be ${macOSArchitectures.join(",")}`);
127
+ if (manifest.minimumSystemVersion !== "13.5") issues.push("JavaScriptCore host deployment target differs from package configuration");
128
+ if (!isFile(join(hostRoot, "shim.js"))) issues.push("JavaScriptCore host shim is missing");
129
+ return {
130
+ issues,
131
+ manifest
132
+ };
133
+ }
134
+ export { hostRoot, inspectJscHost, inspectMachO, macOSArchitectures, minimumJscHostSystemVersion, prebuiltRoot };
@@ -0,0 +1,286 @@
1
+ import { macOSExecutable } from "./executables.js";
2
+ import { installedPackageRoot } from "../package-root.js";
3
+ import { prebuiltRoot } from "./jsc-host/runtime.js";
4
+ import fs, { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
5
+ import { basename, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import { createHash } from "node:crypto";
8
+ import { execFile } from "node:child_process";
9
+ import "node:fs/promises";
10
+ import { promisify } from "node:util";
11
+ // ../cli/src/macos/native.ts
12
+ var execute = promisify(execFile);
13
+ var hash = (value) => createHash("sha256").update(value).digest("hex");
14
+ var compilerExtensions = /* @__PURE__ */ new Set([
15
+ ".c",
16
+ ".m",
17
+ ".mm",
18
+ ".swift",
19
+ ".zig"
20
+ ]);
21
+ fileURLToPath(import.meta.url);
22
+ async function run(command, args, stage, env = process.env) {
23
+ try {
24
+ return (await execute(command, args, {
25
+ timeout: 18e4,
26
+ maxBuffer: 33554432,
27
+ env
28
+ })).stdout.trim();
29
+ } catch (error) {
30
+ const diagnostics = (error.stderr ?? error.message).split("\n").filter((line) => /error:|fatal error:|aborted|failed|dyld:/.test(line));
31
+ throw new Error(`[macos-native] ${stage}: ${command} exited ${error.code ?? error.signal ?? "unsuccessfully"}\n${(diagnostics.join("\n") || error.stderr || error.message).slice(-6e3)}`);
32
+ }
33
+ }
34
+ function inside(root, path) {
35
+ const rel = relative(root, path);
36
+ return rel === "" || !isAbsolute(rel) && rel !== ".." && !rel.startsWith(`..${sep}`);
37
+ }
38
+ function strings(value, label, fallback = []) {
39
+ if (value === void 0) return fallback;
40
+ if (!Array.isArray(value) || value.some((item) => typeof item !== "string" || !item.trim())) throw new Error(`${label} must be an array of nonempty strings`);
41
+ return value;
42
+ }
43
+ function nativeFiles(root, dir = root, seen = /* @__PURE__ */ new Set()) {
44
+ const actual = realpathSync(dir);
45
+ if (!inside(root, actual)) throw new Error(`Native input escapes platforms/macos: ${dir}`);
46
+ if (seen.has(actual)) throw new Error(`Native input contains a symlink cycle: ${dir}`);
47
+ seen.add(actual);
48
+ const files = [];
49
+ for (const entry of readdirSync(dir).sort()) {
50
+ const path = join(dir, entry);
51
+ if (!inside(root, realpathSync(path))) throw new Error(`Native input escapes platforms/macos: ${path}`);
52
+ if (statSync(path).isDirectory()) files.push(...nativeFiles(root, path, seen));
53
+ else if (statSync(path).isFile()) files.push(path);
54
+ }
55
+ seen.delete(actual);
56
+ return files;
57
+ }
58
+ function select(root, nativeRoot, patterns, label) {
59
+ if (typeof fs.globSync !== "function") throw new Error("[macos-native] Native source selection requires Node 22.17 or later");
60
+ const files = /* @__PURE__ */ new Set();
61
+ for (const pattern of patterns) {
62
+ if (isAbsolute(pattern) || pattern.split(/[\\/]/).includes("..")) throw new Error(`${label}: package-relative paths required`);
63
+ const matches = fs.globSync(pattern, { cwd: root }).sort();
64
+ if (!matches.length) throw new Error(`${label}: no files match ${pattern}`);
65
+ for (const match of matches) {
66
+ const path = realpathSync(join(root, match));
67
+ if (!inside(nativeRoot, path) || !statSync(path).isFile()) throw new Error(`${label}: input must be a file inside platforms/macos: ${match}`);
68
+ files.add(path);
69
+ }
70
+ }
71
+ return [...files].sort();
72
+ }
73
+ function resourceMap(root, nativeRoot, value, label) {
74
+ if (value === void 0) return [];
75
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label} must map app resource paths to package files`);
76
+ return Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([destination, source]) => {
77
+ if (!destination.trim() || isAbsolute(destination) || destination.split(/[\\/]/).some((part) => part === ".." || part === ".") || typeof source !== "string" || !source.trim()) throw new Error(`${label} must use safe relative app paths and package files`);
78
+ return {
79
+ destination,
80
+ source: select(root, nativeRoot, [source], label)[0]
81
+ };
82
+ });
83
+ }
84
+ function noticeFile(root, nativeRoot, value, label) {
85
+ if (value === void 0) return null;
86
+ if (typeof value !== "string" || !value.trim()) throw new Error(`${label} must be a package-relative file inside platforms/macos`);
87
+ return select(root, nativeRoot, [value], label)[0];
88
+ }
89
+ /** Resolve runtime dependencies in dependency order, including pnpm/workspace links. */
90
+ function discoverMacOSNative(appRoot) {
91
+ const packages = /* @__PURE__ */ new Map();
92
+ const visiting = /* @__PURE__ */ new Set();
93
+ const leaves = [];
94
+ const prebuilt = [];
95
+ const prebuiltFiles = /* @__PURE__ */ new Map();
96
+ function visit(root) {
97
+ root = realpathSync(root);
98
+ if (packages.has(root) || visiting.has(root)) return;
99
+ visiting.add(root);
100
+ const manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
101
+ const deps = {
102
+ ...manifest.peerDependencies,
103
+ ...manifest.dependencies,
104
+ ...manifest.optionalDependencies
105
+ };
106
+ const dependencyRoots = [];
107
+ for (const name of Object.keys(deps).sort()) {
108
+ const dep = installedPackageRoot(root, name);
109
+ if (!dep) {
110
+ if (name in (manifest.optionalDependencies ?? {}) || !(name in (manifest.dependencies ?? {}))) continue;
111
+ throw new Error(`[macos-native] ${manifest.name}: dependency ${name} is not installed; run bun install`);
112
+ }
113
+ dependencyRoots.push(dep);
114
+ visit(dep);
115
+ }
116
+ visiting.delete(root);
117
+ const nativeRoot = join(root, "platforms/macos");
118
+ const config = manifest.xplat?.macos;
119
+ let leaf;
120
+ if (config !== void 0 && (!config || typeof config !== "object" || Array.isArray(config))) throw new Error(`[macos-native] ${manifest.name}: xplat.macos must be an object`);
121
+ if (config !== void 0 || existsSync(nativeRoot)) {
122
+ if (!existsSync(nativeRoot)) throw new Error(`[macos-native] ${manifest.name}: platforms/macos is missing`);
123
+ const allowed = /* @__PURE__ */ new Set([
124
+ "sources",
125
+ "headers",
126
+ "includePaths",
127
+ "frameworks",
128
+ "libraries",
129
+ "defines",
130
+ "swiftWholeModuleOptimization",
131
+ "swiftHeaderImports",
132
+ "resources",
133
+ "notices",
134
+ "prebuiltLibraries"
135
+ ]);
136
+ for (const key of Object.keys(config ?? {})) if (!allowed.has(key)) throw new Error(`[macos-native] ${manifest.name}: unknown xplat.macos.${key}`);
137
+ const files = nativeFiles(nativeRoot);
138
+ const defaults = files.filter((path) => inside(join(nativeRoot, "src"), path) && compilerExtensions.has(extname(path)));
139
+ const sources = config?.sources === void 0 ? defaults : select(root, nativeRoot, strings(config.sources, `${manifest.name} sources`), `${manifest.name} sources`);
140
+ const prebuiltLibraries = select(root, nativeRoot, strings(config?.prebuiltLibraries, `${manifest.name} prebuiltLibraries`), `${manifest.name} prebuiltLibraries`);
141
+ for (const path of prebuiltLibraries) if (extname(path) !== ".dylib") throw new Error(`[macos-native] ${manifest.name}: prebuilt library must be a .dylib: ${path}`);
142
+ if (!sources.length && prebuiltLibraries.length) {
143
+ for (const key of Object.keys(config)) if (key !== "prebuiltLibraries" && key !== "notices") throw new Error(`[macos-native] ${manifest.name}: xplat.macos.${key} requires native sources`);
144
+ } else if (sources.length || config !== void 0) {
145
+ if (!sources.length) throw new Error(`[macos-native] ${manifest.name}: no native sources`);
146
+ for (const path of sources) if (!compilerExtensions.has(extname(path))) throw new Error(`[macos-native] ${manifest.name}: unsupported source ${path}`);
147
+ const headers = config?.headers === void 0 ? files.filter((path) => inside(join(nativeRoot, "include"), path) && extname(path) === ".h") : select(root, nativeRoot, strings(config.headers, `${manifest.name} headers`), `${manifest.name} headers`);
148
+ if (!headers.length && !sources.some((path) => extname(path) === ".swift")) throw new Error(`[macos-native] ${manifest.name}: public headers are required`);
149
+ const includePaths = strings(config?.includePaths, `${manifest.name} includePaths`).map((path) => {
150
+ const actual = realpathSync(resolve(root, path));
151
+ if (!inside(nativeRoot, actual) || !statSync(actual).isDirectory()) throw new Error(`${manifest.name}: includePaths must be directories inside platforms/macos`);
152
+ return actual;
153
+ });
154
+ const frameworks = strings(config?.frameworks, `${manifest.name} frameworks`);
155
+ const libraries = strings(config?.libraries, `${manifest.name} libraries`);
156
+ const defines = strings(config?.defines, `${manifest.name} defines`);
157
+ const swiftHeaderImports = strings(config?.swiftHeaderImports, `${manifest.name} swiftHeaderImports`);
158
+ for (const header of swiftHeaderImports) if (!/^[A-Za-z][A-Za-z0-9_]*\/[A-Za-z0-9_./-]+\.h$/.test(header) || header.split("/").includes("..")) throw new Error(`${manifest.name}: invalid Swift Objective-C header import ${header}`);
159
+ const swiftWholeModuleOptimization = config?.swiftWholeModuleOptimization ?? false;
160
+ if (typeof swiftWholeModuleOptimization !== "boolean") throw new Error(`${manifest.name}: swiftWholeModuleOptimization must be boolean`);
161
+ if (swiftHeaderImports.length && !sources.some((path) => extname(path) === ".swift")) throw new Error(`${manifest.name}: swiftHeaderImports require Swift sources`);
162
+ const resources = resourceMap(root, nativeRoot, config?.resources, `${manifest.name} resources`);
163
+ const notices = noticeFile(root, nativeRoot, config?.notices, `${manifest.name} notices`);
164
+ for (const name of [...frameworks, ...libraries]) if (!/^[A-Za-z0-9_+-]+$/.test(name)) throw new Error(`${manifest.name}: invalid system framework/library ${name}`);
165
+ for (const define of defines) if (!/^[A-Za-z_][A-Za-z0-9_]*(?:=[^\r\n]+)?$/.test(define)) throw new Error(`${manifest.name}: invalid define ${define}`);
166
+ const id = `Xplat_${(manifest.name ?? "app").replace(/[^A-Za-z0-9]/g, "_")}_${hash(root).slice(0, 8)}`;
167
+ leaf = {
168
+ root,
169
+ name: manifest.name ?? root,
170
+ id,
171
+ nativeRoot,
172
+ sources,
173
+ headers,
174
+ includePaths,
175
+ frameworks,
176
+ libraries,
177
+ defines,
178
+ swiftWholeModuleOptimization,
179
+ swiftHeaderImports,
180
+ resources,
181
+ notices,
182
+ files,
183
+ dependencyRoots
184
+ };
185
+ leaves.push(leaf);
186
+ }
187
+ if (prebuiltLibraries.length) {
188
+ const notices = leaf ? null : noticeFile(root, nativeRoot, config?.notices, `${manifest.name} notices`);
189
+ for (const path of prebuiltLibraries) {
190
+ const file = basename(path);
191
+ if (prebuiltFiles.has(file)) throw new Error(`[macos-native] Multiple packages ship prebuilt ${file}`);
192
+ prebuiltFiles.set(file, manifest.name);
193
+ prebuilt.push({
194
+ name: manifest.name,
195
+ file,
196
+ source: path,
197
+ notices
198
+ });
199
+ }
200
+ }
201
+ }
202
+ packages.set(root, {
203
+ manifest,
204
+ dependencyRoots,
205
+ leaf
206
+ });
207
+ }
208
+ visit(appRoot);
209
+ const resourceDestinations = /* @__PURE__ */ new Set();
210
+ for (const leaf of leaves) for (const { destination } of leaf.resources) {
211
+ if (resourceDestinations.has(destination)) throw new Error(`[macos-native] Multiple leaves package the same app resource: ${destination}`);
212
+ resourceDestinations.add(destination);
213
+ }
214
+ const defineValues = /* @__PURE__ */ new Map();
215
+ for (const leaf of leaves) for (const define of leaf.defines) {
216
+ const key = define.split("=")[0];
217
+ if (defineValues.has(key) && defineValues.get(key) !== define) throw new Error(`[macos-native] ${leaf.name}: conflicting definition for ${key} across native leaves`);
218
+ defineValues.set(key, define);
219
+ }
220
+ for (const leaf of leaves) {
221
+ const seen = /* @__PURE__ */ new Set([leaf.root]);
222
+ const deps = /* @__PURE__ */ new Set();
223
+ function collect(root) {
224
+ if (seen.has(root)) return;
225
+ seen.add(root);
226
+ const pkg = packages.get(root);
227
+ if (pkg.leaf) deps.add(pkg.leaf.id);
228
+ for (const dep of pkg.dependencyRoots) collect(dep);
229
+ }
230
+ for (const root of leaf.dependencyRoots) collect(root);
231
+ leaf.dependencies = leaves.filter((dep) => deps.has(dep.id)).map((dep) => dep.id);
232
+ if (leaf.dependencies.some((id) => leaves.findIndex((dep) => dep.id === id) >= leaves.indexOf(leaf))) throw new Error(`[macos-native] ${leaf.name}: native dependency cycle`);
233
+ }
234
+ const inputs = [...packages.entries()].map(([root, pkg]) => [root, pkg.manifest]);
235
+ for (const leaf of leaves) for (const path of leaf.files) inputs.push([path, hash(readFileSync(path))]);
236
+ for (const lib of prebuilt) {
237
+ inputs.push([lib.source, hash(readFileSync(lib.source))]);
238
+ if (lib.notices) inputs.push([lib.notices, hash(readFileSync(lib.notices))]);
239
+ }
240
+ return {
241
+ leaves,
242
+ prebuilt,
243
+ fingerprint: hash(JSON.stringify(inputs))
244
+ };
245
+ }
246
+ /** Validate the toolchain only when the app actually has native leaves. */
247
+ async function inspectMacOSNative(appRoot) {
248
+ const graph = discoverMacOSNative(appRoot);
249
+ if (!graph.leaves.length) return {
250
+ ...graph,
251
+ toolchain: null
252
+ };
253
+ if (process.platform !== "darwin" || process.arch !== "arm64" && process.arch !== "x64") throw new Error("[macos-native] Native leaves require a Mac running macOS arm64 or x86_64: the metadata generator loads the Command Line Tools libclang for the build host architecture");
254
+ const sdkEnv = process.env.XPLAT_MACOS_SDK;
255
+ const sdk = sdkEnv && sdkEnv.startsWith("/") ? sdkEnv : await run("xcrun", [
256
+ "--sdk",
257
+ sdkEnv || "macosx",
258
+ "--show-sdk-path"
259
+ ], "locate macOS SDK; install/select Xcode");
260
+ const clang = await run("xcrun", ["--find", "clang"], "locate Xcode compiler");
261
+ const swift = graph.leaves.some((leaf) => leaf.sources.some((path) => extname(path) === ".swift")) ? process.env.XPLAT_MACOS_SWIFTC || await run("xcrun", ["--find", "swiftc"], "locate Swift compiler") : null;
262
+ const zig = graph.leaves.some((leaf) => leaf.sources.some((path) => extname(path) === ".zig")) ? await run("zig", ["version"], "Zig sources require Zig on PATH") : null;
263
+ const manifest = JSON.parse(readFileSync(join(prebuiltRoot, "manifest.json"), "utf8"));
264
+ let generator = join(prebuiltRoot, manifest.metadataGenerator?.path ?? "missing-metadata-generator");
265
+ if (!manifest.metadataGenerator || !existsSync(generator) || hash(readFileSync(generator)) !== manifest.sha256[manifest.metadataGenerator.path]) throw new Error("[macos-native] Metadata generator missing or checksum differs; reinstall the project macOS build tooling");
266
+ generator = await macOSExecutable(appRoot, manifest.metadataGenerator.path);
267
+ const libclang = await run(generator, ["--xplat-check"], "load metadata generator; install compatible Command Line Tools libclang");
268
+ const clangVersion = await run(clang, ["--version"], "inspect compiler");
269
+ const swiftVersion = swift ? await run(swift, ["--version"], "inspect Swift compiler") : null;
270
+ return {
271
+ ...graph,
272
+ toolchain: {
273
+ sdk,
274
+ clang,
275
+ swift,
276
+ zig,
277
+ libclang,
278
+ clangVersion,
279
+ swiftVersion,
280
+ sdkSettings: hash(readFileSync(join(sdk, "SDKSettings.json"))),
281
+ generator,
282
+ generatorHash: manifest.sha256[manifest.metadataGenerator.path]
283
+ }
284
+ };
285
+ }
286
+ export { discoverMacOSNative, inspectMacOSNative };
@@ -0,0 +1,30 @@
1
+ import { installedPackageRoot } from "../package-root.js";
2
+ import { readFileSync, statSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ // ../cli/src/macos/runtime-package.ts
5
+ var macOSRuntimePackageName = "@nativescript/macos-node-api";
6
+ var requiredPackageFiles = ["index.d.ts", "LICENSE"];
7
+ function readPackageManifest(path) {
8
+ try {
9
+ const manifest = JSON.parse(readFileSync(path, "utf8"));
10
+ return manifest && typeof manifest === "object" && !Array.isArray(manifest) ? manifest : null;
11
+ } catch {
12
+ return null;
13
+ }
14
+ }
15
+ function isFile(path) {
16
+ try {
17
+ return statSync(path).isFile();
18
+ } catch {
19
+ return false;
20
+ }
21
+ }
22
+ function inspectMacOSRuntimePackage(appRoot) {
23
+ const packageRoot = installedPackageRoot(appRoot, "@nativescript/macos-node-api") ?? join(appRoot, "node_modules", ..."@nativescript/macos-node-api".split("/"));
24
+ return {
25
+ packageRoot,
26
+ packageManifest: readPackageManifest(join(packageRoot, "package.json")),
27
+ missingPaths: requiredPackageFiles.filter((path) => !isFile(join(packageRoot, path)))
28
+ };
29
+ }
30
+ export { inspectMacOSRuntimePackage, macOSRuntimePackageName };
@@ -0,0 +1,62 @@
1
+ import { parseModule } from "@tsrx/core";
2
+ // ../cli/src/macos/tab-item.ts
3
+ /** Keep native handles inside a source-tree component that owns their portals. */
4
+ function tabItemContentRoots() {
5
+ return {
6
+ name: "xplat-appkit-owned-content",
7
+ enforce: "pre",
8
+ transform(source, id) {
9
+ if (!/\.(?:tsx|tsrx)(?:\?|$)/.test(id) || /\.web\.(?:tsx|tsrx)(?:\?|$)/.test(id) || id.includes("/macos-appkit/src/portal-components.macos.tsx")) return null;
10
+ if (/@jsxImportSource\s+@octane-xplat\/jsx\/dom\b/.test(source)) return null;
11
+ if (!/tabviewitem|listview/.test(source)) return null;
12
+ const ast = parseModule(source, id.split("?")[0]);
13
+ const edits = [];
14
+ const bindings = /* @__PURE__ */ new Map();
15
+ const names = {
16
+ tabviewitem: "__PortalTabItem",
17
+ listview: "__PortalList"
18
+ };
19
+ function binding(tag) {
20
+ if (bindings.has(tag)) return bindings.get(tag);
21
+ let name = "__Xplat" + names[tag];
22
+ while (source.includes(name)) name += "_";
23
+ bindings.set(tag, name);
24
+ return name;
25
+ }
26
+ function visit(node) {
27
+ if (!node || typeof node !== "object") return;
28
+ if (node.type === "JSXElement" && node.openingElement.name.type === "JSXIdentifier") {
29
+ const tag = node.openingElement.name.name;
30
+ if (tag in names) {
31
+ const name = binding(tag);
32
+ edits.push([
33
+ node.openingElement.name.start,
34
+ node.openingElement.name.end,
35
+ name
36
+ ]);
37
+ if (node.closingElement) edits.push([
38
+ node.closingElement.name.start,
39
+ node.closingElement.name.end,
40
+ name
41
+ ]);
42
+ }
43
+ }
44
+ for (const [key, value] of Object.entries(node)) {
45
+ if (key === "metadata" || key === "loc") continue;
46
+ if (Array.isArray(value)) for (const child of value) visit(child);
47
+ else if (value && typeof value === "object") visit(value);
48
+ }
49
+ }
50
+ visit(ast);
51
+ if (!edits.length) return null;
52
+ let code = source;
53
+ for (const [start, end, replacement] of edits.sort((a, b) => b[0] - a[0])) code = code.slice(0, start) + replacement + code.slice(end);
54
+ code += `\nimport { ${[...bindings].map(([tag, name]) => `${names[tag]} as ${name}`).join(", ")} } from '@octane-xplat/macos-appkit'\n`;
55
+ return {
56
+ code,
57
+ map: null
58
+ };
59
+ }
60
+ };
61
+ }
62
+ export { tabItemContentRoots };
@@ -0,0 +1,13 @@
1
+ import type { UserConfig } from 'vite'
2
+
3
+ import type { XplatMacOSOptions } from './vite-options.js'
4
+ export type { XplatMacOSOptions } from './vite-options.js'
5
+
6
+ /** Configure NativeScript Core on AppKit using the app's installed macOS provider. */
7
+ export function macos(
8
+ env: { mode: string } | string,
9
+ options?: XplatMacOSOptions,
10
+ ): Promise<UserConfig>
11
+
12
+ /** @deprecated Use {@link macos}. */
13
+ export const xplatMacOS: typeof macos
@@ -0,0 +1,22 @@
1
+ import { createCoreMacOSConfig } from "./core-vite.js";
2
+ // ../cli/src/macos/vite.ts
3
+ /** Compile the macOS app for the NativeScript Core provider on AppKit. */
4
+ async function macos(env, options = {}) {
5
+ const rules = options.rules?.map((rule) => rule && typeof rule === "object" && "renderer" in rule && rule.renderer === "macos" ? {
6
+ ...rule,
7
+ renderer: "nativescript"
8
+ } : rule);
9
+ const { config } = await createCoreMacOSConfig(typeof env === "string" ? env : env.mode, {
10
+ ...options,
11
+ rules
12
+ });
13
+ const library = config.build?.lib;
14
+ if (options.packaged === false && library) {
15
+ library.formats = ["es"];
16
+ library.fileName = "app";
17
+ }
18
+ return config;
19
+ }
20
+ /** @deprecated Use {@link macos}. */
21
+ var xplatMacOS = macos;
22
+ export { macos, xplatMacOS };
@@ -0,0 +1,11 @@
1
+ import { parseMdDoc } from "./ui/src/markdown/markdown-parse.js";
2
+ // ../cli/src/markdown.ts
3
+ /** Bake Markdown source into a versioned `MdDoc` (v2) for route codegen.
4
+ * The JSON round-trip drops absent optional fields (`start` on an unordered
5
+ * list, `delimiter`, `spread`, …) so the embedded literal is exactly what
6
+ * `JSON.parse` hands the runtime — assertRouteDataJson rejects undefined
7
+ * fields as silently-dropped data otherwise. */
8
+ function mdToDoc(src) {
9
+ return JSON.parse(JSON.stringify(parseMdDoc(src)));
10
+ }
11
+ export { mdToDoc };