@octane-xplat/build 0.0.0-nightly.g1b95ef7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/add-worker.js +66 -0
- package/dist/build-worker.js +287 -0
- package/dist/compatibility-check.js +155 -0
- package/dist/compatibility-data/compatibility.js +109 -0
- package/dist/compatibility-data/compatibility.json +298 -0
- package/dist/compatibility.js +240 -0
- package/dist/css-platform.js +236 -0
- package/dist/css-platform.types.d.ts +11 -0
- package/dist/dev-inspector.web.js +125 -0
- package/dist/dev-log-client.web.js +79 -0
- package/dist/dev-log-server.js +13 -0
- package/dist/devtools-worker.js +94 -0
- package/dist/doctor-checks.js +414 -0
- package/dist/doctor-tool.js +27 -0
- package/dist/env.js +3 -0
- package/dist/fmt-plan.js +149 -0
- package/dist/fonts-worker.js +31 -0
- package/dist/fonts.js +614 -0
- package/dist/inline-stylesheets.js +44 -0
- package/dist/linux/config.js +43 -0
- package/dist/linux/gtk-runtime.js +86 -0
- package/dist/linux/package.js +189 -0
- package/dist/linux-gtk/bindings.mjs +675 -0
- package/dist/linux-gtk/native-gi-projection.js +36 -0
- package/dist/linux-gtk/vite.d.ts +39 -0
- package/dist/linux-gtk/vite.js +281 -0
- package/dist/macos/config.js +136 -0
- package/dist/macos/core-ui.js +59 -0
- package/dist/macos/core-vite.js +122 -0
- package/dist/macos/doctor-checks.js +58 -0
- package/dist/macos/executables.js +39 -0
- package/dist/macos/jsc-host/runtime.js +134 -0
- package/dist/macos/native.js +286 -0
- package/dist/macos/runtime-package.js +30 -0
- package/dist/macos/tab-item.js +62 -0
- package/dist/macos/vite.d.ts +13 -0
- package/dist/macos/vite.js +22 -0
- package/dist/markdown.js +11 -0
- package/dist/mason-engine.js +20 -0
- package/dist/mcp/contracts/actions.js +133 -0
- package/dist/mcp/dev-bridge.js +363 -0
- package/dist/mcp/dev-socket.js +203 -0
- package/dist/mcp/dev-stack.js +134 -0
- package/dist/mcp/inspection/dom.web.js +46 -0
- package/dist/native-regex.js +123 -0
- package/dist/package-manager.js +106 -0
- package/dist/package-root.js +48 -0
- package/dist/patches.js +356 -0
- package/dist/route-config.js +53 -0
- package/dist/route-data.js +42 -0
- package/dist/route-generator.js +514 -0
- package/dist/route-path.js +29 -0
- package/dist/route-source.js +67 -0
- package/dist/targets.js +37 -0
- package/dist/tsconfig-envs.js +400 -0
- package/dist/tsconfig-pin.js +31 -0
- package/dist/tsrx-leaf.js +57 -0
- package/dist/typecheck-globals/macos.d.ts +21 -0
- package/dist/typecheck-globals/native.d.ts +42 -0
- package/dist/ui/src/markdown/markdown-ast.js +33 -0
- package/dist/ui/src/markdown/markdown-character-references.js +79 -0
- package/dist/ui/src/markdown/markdown-parse.js +1930 -0
- package/dist/ui/src/markdown/markdown-plugins.js +564 -0
- package/dist/ui/src/markdown/markdown-url.js +17 -0
- package/dist/updates-worker.js +34 -0
- package/dist/upgrade-worker.js +63 -0
- package/dist/vite-target.js +57 -0
- package/dist/vite.d.ts +125 -0
- package/dist/vite.js +797 -0
- package/dist/workshop-worker.js +181 -0
- package/package.json +74 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
// ../cli/src/linux-gtk/native-gi-projection.ts
|
|
4
|
+
var schemaId = "\0xplat-gtk-schema";
|
|
5
|
+
var namespacePrefix = "\0xplat-gtk-gi:";
|
|
6
|
+
var gtkRuntimeBuildMarker = ".xplat-gtk-runtime";
|
|
7
|
+
function nativeGiProjection(schemaPath, verifyPackaging) {
|
|
8
|
+
const bindingsPath = resolve(import.meta.dirname, "bindings.mjs");
|
|
9
|
+
return {
|
|
10
|
+
name: "xplat-gtk-native-gi",
|
|
11
|
+
enforce: "pre",
|
|
12
|
+
resolveId(id) {
|
|
13
|
+
if (id === "virtual:gtk-schema") return schemaId;
|
|
14
|
+
if (id.startsWith("gi://")) return namespacePrefix + id.slice(5).split("?")[0];
|
|
15
|
+
},
|
|
16
|
+
load(id) {
|
|
17
|
+
if (id === schemaId) {
|
|
18
|
+
this.addWatchFile(schemaPath);
|
|
19
|
+
const schema = JSON.parse(readFileSync(schemaPath, "utf8"));
|
|
20
|
+
return `export default ${JSON.stringify(schema)};`;
|
|
21
|
+
}
|
|
22
|
+
if (id.startsWith(namespacePrefix)) {
|
|
23
|
+
const namespace = id.slice(14);
|
|
24
|
+
return `import { namespaces } from ${JSON.stringify(bindingsPath)}; export default namespaces[${JSON.stringify(namespace)}];`;
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
generateBundle() {
|
|
28
|
+
if (verifyPackaging) this.emitFile({
|
|
29
|
+
type: "asset",
|
|
30
|
+
fileName: gtkRuntimeBuildMarker,
|
|
31
|
+
source: "1\n"
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export { gtkRuntimeBuildMarker, nativeGiProjection };
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
/** GI schema from the NativeScript Linux runtime payload supplied by packaging. */
|
|
14
|
+
nativeGiSchema?: string
|
|
15
|
+
/** Sources the Octane compiler must not transform. */
|
|
16
|
+
exclude?: string[]
|
|
17
|
+
/** Override renderer rules; defaults to all reachable TSX/TSRX source. */
|
|
18
|
+
rules?: unknown[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Configure the experimental GTK4 renderer using the app's installed toolchain. */
|
|
22
|
+
export function linuxGtk(
|
|
23
|
+
env: { mode: string } | string,
|
|
24
|
+
options?: XplatLinuxGtkOptions,
|
|
25
|
+
): Promise<UserConfig>
|
|
26
|
+
|
|
27
|
+
/** @deprecated Use {@link linuxGtk}. */
|
|
28
|
+
export const xplatLinuxGtk: typeof linuxGtk
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/** Check whether the installed renderer includes the runtime for the current architecture. */
|
|
32
|
+
export function hasGtkDevelopmentRuntime(root: string): boolean
|
|
33
|
+
|
|
34
|
+
/** Stage a checked runtime next to the development shell bundle. */
|
|
35
|
+
export function stageGtkDevelopmentRuntime(
|
|
36
|
+
root: string,
|
|
37
|
+
outDir: string,
|
|
38
|
+
bundle: string,
|
|
39
|
+
): { executable: string; schema: string }
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { css } from "../css-platform.js";
|
|
2
|
+
import { boundary, nodeEnvDefine } from "../vite.js";
|
|
3
|
+
import { inlineStylesheets } from "../inline-stylesheets.js";
|
|
4
|
+
import { nativeGiProjection } from "./native-gi-projection.js";
|
|
5
|
+
import { installedGtkRuntimeRoot, stageGtkRuntime, writeGtkRuntimeLauncher } from "../linux/gtk-runtime.js";
|
|
6
|
+
import { chmodSync, existsSync, readFileSync, realpathSync } from "node:fs";
|
|
7
|
+
import { createRequire } from "node:module";
|
|
8
|
+
import { dirname, join, resolve } from "node:path";
|
|
9
|
+
import { pathToFileURL } from "node:url";
|
|
10
|
+
// ../cli/src/linux-gtk/vite.ts
|
|
11
|
+
function hostRuntime(root) {
|
|
12
|
+
const architecture = process.arch === "x64" ? "x86_64" : process.arch === "arm64" ? "aarch64" : null;
|
|
13
|
+
const payload = installedGtkRuntimeRoot(root);
|
|
14
|
+
return architecture && payload ? {
|
|
15
|
+
architecture,
|
|
16
|
+
path: join(payload, architecture)
|
|
17
|
+
} : null;
|
|
18
|
+
}
|
|
19
|
+
function hasGtkDevelopmentRuntime(root) {
|
|
20
|
+
const runtime = hostRuntime(root);
|
|
21
|
+
return Boolean(runtime && existsSync(join(runtime.path, "ns-linux")));
|
|
22
|
+
}
|
|
23
|
+
function stageGtkDevelopmentRuntime(root, outDir, bundle) {
|
|
24
|
+
const runtime = hostRuntime(root);
|
|
25
|
+
if (!runtime) throw new Error("GTK development requires the installed NativeScript Linux runtime for this host");
|
|
26
|
+
const directory = join(outDir, "runtime");
|
|
27
|
+
if (stageGtkRuntime(runtime.path, directory) !== runtime.architecture) throw new Error(`GTK development runtime must match ${runtime.architecture}`);
|
|
28
|
+
writeGtkRuntimeLauncher(outDir, "launch", bundle, runtime.architecture);
|
|
29
|
+
return {
|
|
30
|
+
executable: join(outDir, "launch"),
|
|
31
|
+
schema: join(directory, "gi.json")
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
var renderer = "@octane-xplat/linux-gtk";
|
|
35
|
+
/** Slot-compiled modules can emit the same `withSlot`/`hookSlots`
|
|
36
|
+
* import binding in two import statements of a single module (octane's
|
|
37
|
+
* universal compiler dedupes `hookSlots` intra-file but not `withSlot` —
|
|
38
|
+
* e.g. `Button.tsrx`; plain `.ts` hook helpers emit duplicate `hookSlots`
|
|
39
|
+
* under generated `_$hookSlots$` locals too). Rolldown only dedupes
|
|
40
|
+
* bindings across modules, so the duplicate survives to a `_$withSlot`
|
|
41
|
+
* redeclaration error in the merged chunk. Keep the first binding per
|
|
42
|
+
* export and fold later local names into it. Different specifiers are a
|
|
43
|
+
* real conflict — bail. */
|
|
44
|
+
function gtkSlotDedupe() {
|
|
45
|
+
return {
|
|
46
|
+
name: "xplat-gtk-slot-dedupe",
|
|
47
|
+
transform(code, id) {
|
|
48
|
+
if (!/\.(tsrx|tsx|ts|mts|js|mjs)$/.test(id)) return;
|
|
49
|
+
if (!code.includes("withSlot as _") && !code.includes("hookSlots as _")) return;
|
|
50
|
+
const firstLocal = /* @__PURE__ */ new Map();
|
|
51
|
+
const firstSpec = /* @__PURE__ */ new Map();
|
|
52
|
+
const fold = /* @__PURE__ */ new Map();
|
|
53
|
+
let changed = false;
|
|
54
|
+
let out = code.replace(/import\s*\{([^}]*)\}\s*from\s*['"]([^'"]+)['"];?/g, (stmt, names, spec) => {
|
|
55
|
+
const kept = [];
|
|
56
|
+
for (const raw of names.split(",")) {
|
|
57
|
+
const part = raw.trim();
|
|
58
|
+
const m = part.match(/^(withSlot|hookSlots) as (_\$[A-Za-z0-9_$]+)$/);
|
|
59
|
+
if (!m) {
|
|
60
|
+
if (part) kept.push(part);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const [, kind, local] = m;
|
|
64
|
+
const prev = firstSpec.get(kind);
|
|
65
|
+
if (prev !== void 0 && prev !== spec) throw new Error(`xplat-gtk-slot-dedupe: ${kind} imported from '${prev}' and '${spec}' in ${id}`);
|
|
66
|
+
if (firstLocal.has(kind)) {
|
|
67
|
+
if (local !== firstLocal.get(kind)) fold.set(local, firstLocal.get(kind));
|
|
68
|
+
changed = true;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
firstLocal.set(kind, local);
|
|
72
|
+
firstSpec.set(kind, spec);
|
|
73
|
+
kept.push(part);
|
|
74
|
+
}
|
|
75
|
+
if (!kept.length) {
|
|
76
|
+
changed = true;
|
|
77
|
+
return "";
|
|
78
|
+
}
|
|
79
|
+
return `import { ${kept.join(", ")} } from '${spec}';`;
|
|
80
|
+
});
|
|
81
|
+
for (const [from, to] of fold) {
|
|
82
|
+
const rx = new RegExp(from.replace(/\$/g, "\\$") + "(?![\\w$])", "g");
|
|
83
|
+
if (rx.test(out)) {
|
|
84
|
+
changed = true;
|
|
85
|
+
out = out.replace(rx, to);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return changed ? { code: out } : void 0;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** Shared sources import siblings with explicit extensions so Node can
|
|
93
|
+
* type-strip them — but the extension pins the native-default leaf and
|
|
94
|
+
* skips platform resolution. A GTK bundle redirects to the .gtk sibling
|
|
95
|
+
* when one exists, restoring what extension probing did when the same
|
|
96
|
+
* imports were extensionless. */
|
|
97
|
+
function gtkLeafResolve() {
|
|
98
|
+
return {
|
|
99
|
+
name: "xplat-gtk-leaf-resolve",
|
|
100
|
+
resolveId: {
|
|
101
|
+
order: "pre",
|
|
102
|
+
handler(source, importer) {
|
|
103
|
+
if (!importer || !/^\.{1,2}\//.test(source)) return null;
|
|
104
|
+
const match = source.match(/\.(tsrx|tsx|ts|mts|mjs|jsx|js)$/);
|
|
105
|
+
if (!match || source.includes(".gtk.") || source.includes(".d.")) return null;
|
|
106
|
+
const stem = source.slice(0, -match[0].length);
|
|
107
|
+
if (stem.endsWith(".gtk")) return null;
|
|
108
|
+
const candidate = join(importer, "..", stem + ".gtk" + match[0]);
|
|
109
|
+
return existsSync(candidate) ? candidate : null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
var masonArches = ["x86_64", "aarch64"];
|
|
115
|
+
var masonFiles = ["libxplatmason-gtk.so", "XplatMason-1.0.typelib"];
|
|
116
|
+
/** Emits the installed renderer package's prebuilt Mason binding into the
|
|
117
|
+
* bundle — both architectures at xplatmason/<arch>/, where the renderer's
|
|
118
|
+
* bundled-typelib lookup expects them beside app.js. A missing package or
|
|
119
|
+
* prebuilt file fails the build rather than shipping a bundle that can
|
|
120
|
+
* only throw at startup. */
|
|
121
|
+
function gtkPrebuiltMason(appRequire) {
|
|
122
|
+
return {
|
|
123
|
+
name: "xplat-gtk-prebuilt-mason",
|
|
124
|
+
buildStart() {
|
|
125
|
+
let prebuilt;
|
|
126
|
+
try {
|
|
127
|
+
prebuilt = join(dirname(realpathSync(appRequire.resolve(`${renderer}/package.json`))), "platforms/linux/prebuilt");
|
|
128
|
+
} catch (error) {
|
|
129
|
+
throw new Error(`xplat-gtk-prebuilt-mason: could not resolve ${renderer} from this app — it must be installed as a dependency (${error.message})`);
|
|
130
|
+
}
|
|
131
|
+
for (const arch of masonArches) for (const name of masonFiles) {
|
|
132
|
+
const source = join(prebuilt, arch, name);
|
|
133
|
+
if (!existsSync(source)) throw new Error(`xplat-gtk-prebuilt-mason: ${renderer} has no prebuilt file ${source} — reinstall the package or build native/xplatmason via build-prebuilt.sh`);
|
|
134
|
+
this.emitFile({
|
|
135
|
+
type: "asset",
|
|
136
|
+
fileName: `xplatmason/${arch}/${name}`,
|
|
137
|
+
source: readFileSync(source)
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
writeBundle(options) {
|
|
142
|
+
for (const arch of masonArches) chmodSync(join(options.dir ?? "dist", "xplatmason", arch, "libxplatmason-gtk.so"), 493);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
async function linuxGtk(env, options = {}) {
|
|
147
|
+
const mode = typeof env === "string" ? env : env.mode;
|
|
148
|
+
const root = resolve(options.root ?? process.cwd());
|
|
149
|
+
const appRequire = createRequire(join(root, "package.json"));
|
|
150
|
+
const resolveApp = (name) => realpathSync(appRequire.resolve(name));
|
|
151
|
+
const rendererEntry = resolveApp(renderer);
|
|
152
|
+
const providerEntry = resolveApp(`${renderer}/core-provider`);
|
|
153
|
+
const providerRequire = createRequire(providerEntry);
|
|
154
|
+
const sharedRenderer = providerRequire.resolve("@octane-xplat/nativescript-octane");
|
|
155
|
+
const [{ createNativeScriptProvider }, { nativeScriptRenderer }, { octane }] = await Promise.all([
|
|
156
|
+
import(pathToFileURL(providerEntry).href),
|
|
157
|
+
import(pathToFileURL(providerRequire.resolve("@octane-xplat/nativescript-octane/config")).href),
|
|
158
|
+
import(pathToFileURL(resolveApp("octane/compiler/vite")).href)
|
|
159
|
+
]);
|
|
160
|
+
const { config: provider } = await createNativeScriptProvider(root);
|
|
161
|
+
const rules = options.rules?.map((rule) => rule?.renderer === "gtk" ? {
|
|
162
|
+
...rule,
|
|
163
|
+
renderer: "nativescript"
|
|
164
|
+
} : rule);
|
|
165
|
+
const universalNative = realpathSync(appRequire.resolve("octane/universal/native"));
|
|
166
|
+
const packagedSchema = process.env.XPLAT_GTK_RUNTIME_SCHEMA;
|
|
167
|
+
const schema = packagedSchema || options.nativeGiSchema;
|
|
168
|
+
const schemaPath = schema && resolve(root, schema);
|
|
169
|
+
return {
|
|
170
|
+
root,
|
|
171
|
+
define: {
|
|
172
|
+
...provider.define,
|
|
173
|
+
...nodeEnvDefine(mode),
|
|
174
|
+
__DEV__: JSON.stringify(mode === "development"),
|
|
175
|
+
...schemaPath && {
|
|
176
|
+
print: "console.log",
|
|
177
|
+
printerr: "console.error",
|
|
178
|
+
"imports.system.exit": "process.exit"
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
plugins: [
|
|
182
|
+
...provider.plugins,
|
|
183
|
+
...schemaPath ? [nativeGiProjection(schemaPath, Boolean(packagedSchema))] : [],
|
|
184
|
+
gtkLeafResolve(),
|
|
185
|
+
gtkSlotDedupe(),
|
|
186
|
+
...schemaPath ? [] : [gtkPrebuiltMason(appRequire)],
|
|
187
|
+
css("gtk"),
|
|
188
|
+
inlineStylesheets(),
|
|
189
|
+
boundary("gtk"),
|
|
190
|
+
octane({
|
|
191
|
+
hmr: options.hmr ?? false,
|
|
192
|
+
exclude: options.exclude,
|
|
193
|
+
renderers: {
|
|
194
|
+
default: "nativescript",
|
|
195
|
+
registry: { nativescript: {
|
|
196
|
+
...nativeScriptRenderer,
|
|
197
|
+
intrinsics: "@octane-xplat/jsx"
|
|
198
|
+
} },
|
|
199
|
+
rules: rules ?? [{
|
|
200
|
+
include: "**/*.{tsx,tsrx}",
|
|
201
|
+
renderer: "nativescript"
|
|
202
|
+
}]
|
|
203
|
+
}
|
|
204
|
+
})
|
|
205
|
+
],
|
|
206
|
+
build: {
|
|
207
|
+
cssCodeSplit: true,
|
|
208
|
+
outDir: options.outDir ?? "dist",
|
|
209
|
+
emptyOutDir: true,
|
|
210
|
+
lib: {
|
|
211
|
+
entry: options.entry ?? "src/main.ts",
|
|
212
|
+
formats: ["es"],
|
|
213
|
+
fileName: options.fileName ?? "app"
|
|
214
|
+
},
|
|
215
|
+
rollupOptions: {
|
|
216
|
+
external: (id) => !schemaPath && id.startsWith("gi://"),
|
|
217
|
+
output: {
|
|
218
|
+
...provider.build.rollupOptions.output,
|
|
219
|
+
codeSplitting: false
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
resolve: {
|
|
224
|
+
conditions: ["gtk", "native"],
|
|
225
|
+
dedupe: ["octane"],
|
|
226
|
+
alias: [
|
|
227
|
+
...provider.resolve.alias,
|
|
228
|
+
{
|
|
229
|
+
find: /^octane$/,
|
|
230
|
+
replacement: universalNative
|
|
231
|
+
},
|
|
232
|
+
...[
|
|
233
|
+
"signals",
|
|
234
|
+
"signals/client",
|
|
235
|
+
"signals/server"
|
|
236
|
+
].map((entry) => ({
|
|
237
|
+
find: new RegExp(`^octane/${entry}$`),
|
|
238
|
+
replacement: join(dirname(universalNative), entry === "signals" ? "signals/index.js" : `${entry}.js`)
|
|
239
|
+
})),
|
|
240
|
+
{
|
|
241
|
+
find: /^octane\/universal\/native$/,
|
|
242
|
+
replacement: universalNative
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
find: /^@octane-xplat\/nativescript-octane$/,
|
|
246
|
+
replacement: sharedRenderer
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
find: /^@octane-xplat\/linux-gtk$/,
|
|
250
|
+
replacement: rendererEntry
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
find: /(^|.*\/)escape-props$/,
|
|
254
|
+
replacement: resolveApp(`${renderer}/compat/escape-props`)
|
|
255
|
+
}
|
|
256
|
+
],
|
|
257
|
+
extensions: [
|
|
258
|
+
".gtk.tsrx",
|
|
259
|
+
".tsrx",
|
|
260
|
+
".gtk.tsx",
|
|
261
|
+
".tsx",
|
|
262
|
+
".gtk.ts",
|
|
263
|
+
".gtk.mts",
|
|
264
|
+
".gtk.mjs",
|
|
265
|
+
".mjs",
|
|
266
|
+
".mts",
|
|
267
|
+
".ts",
|
|
268
|
+
".jsx",
|
|
269
|
+
".js",
|
|
270
|
+
".json"
|
|
271
|
+
]
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/** @deprecated Use {@link linuxGtk}. */
|
|
276
|
+
var xplatLinuxGtk = linuxGtk;
|
|
277
|
+
/** @deprecated Use {@link gtkSlotDedupe}. */
|
|
278
|
+
var xplatGtkSlotDedupe = gtkSlotDedupe;
|
|
279
|
+
/** @deprecated Use {@link gtkLeafResolve}. */
|
|
280
|
+
var xplatGtkLeafResolve = gtkLeafResolve;
|
|
281
|
+
export { gtkLeafResolve, gtkSlotDedupe, hasGtkDevelopmentRuntime, linuxGtk, stageGtkDevelopmentRuntime, xplatGtkLeafResolve, xplatGtkSlotDedupe, xplatLinuxGtk };
|
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
function rendererOf(value, issues, prefix) {
|
|
13
|
+
if (value !== void 0 && value !== "appkit") issues.push(`${prefix}.renderer must be "appkit"; desktop WebView hosting has been removed. Use native AppKit screens or run the app in a browser.`);
|
|
14
|
+
return "appkit";
|
|
15
|
+
}
|
|
16
|
+
function resolveBuildPaths(appRoot, settings, issues, prefix) {
|
|
17
|
+
const paths = {};
|
|
18
|
+
for (const key of [
|
|
19
|
+
"webViteConfig",
|
|
20
|
+
"hostViteConfig",
|
|
21
|
+
"hostBundleFile",
|
|
22
|
+
"webOutDir"
|
|
23
|
+
]) if (settings[key] !== void 0) issues.push(`${prefix}.${key} is no longer supported; configure native AppKit viteConfig and bundleFile`);
|
|
24
|
+
for (const key of ["viteConfig", "bundleFile"]) {
|
|
25
|
+
if (typeof settings[key] !== "string" || !settings[key].trim()) {
|
|
26
|
+
issues.push(`missing ${prefix}.${key}`);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
paths[key] = resolveProjectPath(appRoot, settings[key], `${prefix.slice(20)} ${key}`, issues, { mustExist: key.endsWith("Config") });
|
|
30
|
+
}
|
|
31
|
+
if (typeof settings.bundleFile === "string" && !settings.bundleFile.endsWith(".cjs")) issues.push("macOS bundleFile must point to a CommonJS .cjs bundle");
|
|
32
|
+
return paths;
|
|
33
|
+
}
|
|
34
|
+
var macOSVersionPattern = /^\d+(?:\.\d+){1,2}$/;
|
|
35
|
+
function compareVersions(left, right) {
|
|
36
|
+
const leftParts = left.split(".").map(Number);
|
|
37
|
+
const rightParts = right.split(".").map(Number);
|
|
38
|
+
for (let index = 0; index < Math.max(leftParts.length, rightParts.length); index++) {
|
|
39
|
+
const difference = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
|
|
40
|
+
if (difference !== 0) return difference;
|
|
41
|
+
}
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
function resolveProjectPath(root, value, label, issues, { mustExist = false } = {}) {
|
|
45
|
+
if (typeof value !== "string" || !value.trim() || isAbsolute(value)) {
|
|
46
|
+
issues.push(`${label} must be a path relative to the app root`);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const path = resolve(root, value);
|
|
50
|
+
const fromRoot = relative(root, path);
|
|
51
|
+
if (fromRoot === ".." || fromRoot.startsWith(`..${sep}`) || isAbsolute(fromRoot)) {
|
|
52
|
+
issues.push(`${label} must stay inside the app root`);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (mustExist && !existsSync(path)) {
|
|
56
|
+
issues.push(`${label} does not exist: ${value}`);
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return path;
|
|
60
|
+
}
|
|
61
|
+
/** Validate the macOS packaging contract shared by `xplat build` and `doctor`. */
|
|
62
|
+
function inspectMacOSPackageConfig(appRoot, value, selectedRenderer) {
|
|
63
|
+
const issues = [];
|
|
64
|
+
const settings = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
65
|
+
if (settings !== value) issues.push("xplat.targets.macos.package must be an object");
|
|
66
|
+
for (const key of requiredPackageFields) if (typeof settings[key] !== "string" || !settings[key].trim()) issues.push(`missing xplat.targets.macos.package.${key}`);
|
|
67
|
+
const renderer = rendererOf(selectedRenderer, issues, "xplat.targets.macos");
|
|
68
|
+
if (settings.bundleIdentifier && !/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/.test(settings.bundleIdentifier)) issues.push(`invalid macOS bundle identifier: ${settings.bundleIdentifier}`);
|
|
69
|
+
if (settings.executableName && !/^[A-Za-z0-9][A-Za-z0-9._ -]*$/.test(settings.executableName)) issues.push(`invalid macOS executable name: ${settings.executableName}`);
|
|
70
|
+
if (settings.version && !/^\d+(?:\.\d+){1,2}$/.test(settings.version)) issues.push(`invalid macOS bundle version: ${settings.version}`);
|
|
71
|
+
if (settings.minimumSystemVersion && !macOSVersionPattern.test(settings.minimumSystemVersion)) issues.push(`invalid macOS minimum system version: ${settings.minimumSystemVersion}`);
|
|
72
|
+
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`);
|
|
73
|
+
const buildPaths = resolveBuildPaths(appRoot, settings, issues, "xplat.targets.macos.package");
|
|
74
|
+
const iconPath = settings.icon === void 0 ? null : resolveProjectPath(appRoot, settings.icon, "macOS icon", issues, { mustExist: true });
|
|
75
|
+
if (iconPath) try {
|
|
76
|
+
if (!statSync(iconPath).isFile()) issues.push("macOS icon must point to a file");
|
|
77
|
+
} catch {
|
|
78
|
+
issues.push("macOS icon could not be inspected");
|
|
79
|
+
}
|
|
80
|
+
if (typeof settings.icon === "string" && settings.icon && !settings.icon.toLowerCase().endsWith(".icns")) issues.push("macOS icon must point to an .icns file");
|
|
81
|
+
const entitlementsPath = settings.entitlements === void 0 ? null : resolveProjectPath(appRoot, settings.entitlements, "macOS entitlements", issues, { mustExist: true });
|
|
82
|
+
if (settings.infoPlist !== void 0) {
|
|
83
|
+
if (!settings.infoPlist || typeof settings.infoPlist !== "object" || Array.isArray(settings.infoPlist)) issues.push("xplat.targets.macos.package.infoPlist must be an object");
|
|
84
|
+
else for (const [key, value] of Object.entries(settings.infoPlist)) {
|
|
85
|
+
if (!/^[A-Za-z0-9._() -]+$/.test(key)) {
|
|
86
|
+
issues.push(`invalid macOS Info.plist key: ${key}`);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const kind = typeof value;
|
|
90
|
+
if (kind !== "string" && kind !== "boolean" && kind !== "number") issues.push(`xplat.targets.macos.package.infoPlist.${key} must be a string, number, or boolean`);
|
|
91
|
+
else if (kind === "number" && !Number.isInteger(value)) issues.push(`xplat.targets.macos.package.infoPlist.${key} must be an integer`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
settings,
|
|
96
|
+
renderer,
|
|
97
|
+
...buildPaths,
|
|
98
|
+
iconPath,
|
|
99
|
+
entitlementsPath,
|
|
100
|
+
issues
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/** Validate the CLI-owned CommonJS dev runner configuration. */
|
|
104
|
+
function inspectMacOSDevConfig(appRoot, value, selectedRenderer) {
|
|
105
|
+
const issues = [];
|
|
106
|
+
const settings = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
107
|
+
if (settings !== value) issues.push("xplat.targets.macos.dev must be an object");
|
|
108
|
+
rendererOf(selectedRenderer, issues, "xplat.targets.macos");
|
|
109
|
+
for (const key of [
|
|
110
|
+
"webViteConfig",
|
|
111
|
+
"hostViteConfig",
|
|
112
|
+
"hostBundleFile",
|
|
113
|
+
"webOutDir"
|
|
114
|
+
]) if (settings[key] !== void 0) issues.push(`xplat.targets.macos.dev.${key} is no longer supported; configure native AppKit viteConfig and bundleFile`);
|
|
115
|
+
const paths = {};
|
|
116
|
+
for (const key of [
|
|
117
|
+
"viteConfig",
|
|
118
|
+
"bundleFile",
|
|
119
|
+
"shellViteConfig",
|
|
120
|
+
"shellBundleFile"
|
|
121
|
+
]) {
|
|
122
|
+
if (settings[key] === void 0 && key.startsWith("shell")) continue;
|
|
123
|
+
if (typeof settings[key] !== "string" || !settings[key].trim()) {
|
|
124
|
+
issues.push(`missing xplat.targets.macos.dev.${key}`);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
paths[key] = resolveProjectPath(appRoot, settings[key], `macOS dev ${key}`, issues, { mustExist: key.endsWith("Config") });
|
|
128
|
+
if (key.endsWith("File") && !settings[key].endsWith(".cjs")) issues.push(`macOS dev ${key} must end in .cjs`);
|
|
129
|
+
}
|
|
130
|
+
if (Boolean(settings.shellViteConfig) !== Boolean(settings.shellBundleFile)) issues.push("macOS dev shellViteConfig and shellBundleFile must be specified together");
|
|
131
|
+
return {
|
|
132
|
+
...paths,
|
|
133
|
+
issues
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
export { inspectMacOSDevConfig, inspectMacOSPackageConfig };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { installedPackageRoot } from "../package-root.js";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
// ../cli/src/macos/core-ui.ts
|
|
4
|
+
/** Keep UI and routing on the Core driver when AppKit hosts the bundle. */
|
|
5
|
+
function coreMacOSUI(appRoot) {
|
|
6
|
+
const uiRoot = installedPackageRoot(appRoot, "@octane-xplat/ui");
|
|
7
|
+
if (!uiRoot) return {
|
|
8
|
+
aliases: [],
|
|
9
|
+
plugins: [],
|
|
10
|
+
reusedFiles: []
|
|
11
|
+
};
|
|
12
|
+
const src = join(uiRoot, "src");
|
|
13
|
+
const index = join(src, "index-core.macos.ts");
|
|
14
|
+
const pane = join(src, "routing/RoutePane.mobile.tsrx");
|
|
15
|
+
const gestures = join(src, "gestures/host-core.macos.tsx");
|
|
16
|
+
const fullScreenPage = join(src, "components/layout/full-screen-page.mobile.ts");
|
|
17
|
+
const keyboardOverlay = join(src, "internal/keyboard/keyboard-overlay-host.mobile.ts");
|
|
18
|
+
const leaves = /* @__PURE__ */ new Map([
|
|
19
|
+
[join(src, "routing/RouteOutlet"), join(src, "routing/RouteOutlet.tsrx")],
|
|
20
|
+
[join(src, "routing/RoutePane"), pane],
|
|
21
|
+
[join(src, "components/layout/full-screen-page"), fullScreenPage],
|
|
22
|
+
[join(src, "internal/keyboard/keyboard-overlay-host"), keyboardOverlay],
|
|
23
|
+
[join(src, "components/navigation/nav-href"), join(src, "components/navigation/nav-href.ts")],
|
|
24
|
+
[join(src, "components/forms/TextInput"), join(src, "components/forms/TextInput.tsrx")],
|
|
25
|
+
[join(src, "components/forms/TextArea"), join(src, "components/forms/TextArea.tsrx")],
|
|
26
|
+
[join(src, "gestures/host"), gestures],
|
|
27
|
+
[join(src, "gestures/host.macos"), gestures],
|
|
28
|
+
[join(src, "internal/layout/styled"), join(src, "internal/layout/styled.tsrx")]
|
|
29
|
+
]);
|
|
30
|
+
return {
|
|
31
|
+
aliases: [{
|
|
32
|
+
find: /^@octane-xplat\/ui$/,
|
|
33
|
+
replacement: index
|
|
34
|
+
}, {
|
|
35
|
+
find: /^@octane-xplat\/ui\/routing$/,
|
|
36
|
+
replacement: join(src, "routing/index.ts")
|
|
37
|
+
}],
|
|
38
|
+
reusedFiles: [
|
|
39
|
+
pane,
|
|
40
|
+
fullScreenPage,
|
|
41
|
+
keyboardOverlay
|
|
42
|
+
],
|
|
43
|
+
plugins: [{
|
|
44
|
+
name: "xplat:macos-core-ui",
|
|
45
|
+
enforce: "pre",
|
|
46
|
+
resolveId: {
|
|
47
|
+
order: "pre",
|
|
48
|
+
handler(source, importer) {
|
|
49
|
+
if (!importer || !source.startsWith(".")) return;
|
|
50
|
+
const [file] = source.split(/[?#]/, 1);
|
|
51
|
+
const base = resolve(dirname(importer.split(/[?#]/, 1)[0]), file.replace(/\.(?:tsx?|tsrx)$/, ""));
|
|
52
|
+
const leaf = leaves.get(base);
|
|
53
|
+
if (leaf) return leaf + source.slice(file.length);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}]
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export { coreMacOSUI };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { css } from "../css-platform.js";
|
|
2
|
+
import { inlineStylesheets } from "../inline-stylesheets.js";
|
|
3
|
+
import { boundary, nodeEnvDefine } from "../vite.js";
|
|
4
|
+
import { nativeDevSocketPlugin } from "../mcp/dev-socket.js";
|
|
5
|
+
import { coreMacOSUI } from "./core-ui.js";
|
|
6
|
+
import { tabItemContentRoots } from "./tab-item.js";
|
|
7
|
+
import { createRequire } from "node:module";
|
|
8
|
+
import { dirname, join, resolve } from "node:path";
|
|
9
|
+
import { pathToFileURL } from "node:url";
|
|
10
|
+
// ../cli/src/macos/core-vite.ts
|
|
11
|
+
/** Assemble the Core runtime with the macOS host's normal build contracts. */
|
|
12
|
+
async function createCoreMacOSConfig(mode, options = {}) {
|
|
13
|
+
const root = resolve(options.root ?? process.cwd());
|
|
14
|
+
const packaged = options.packaged ?? true;
|
|
15
|
+
const require = createRequire(join(root, "package.json"));
|
|
16
|
+
const providerEntry = require.resolve("@octane-xplat/macos-appkit/core-provider");
|
|
17
|
+
const requireProvider = createRequire(providerEntry);
|
|
18
|
+
const [{ createNativeScriptProvider, nativeScriptDevImports }, { nativeScriptRenderer }, { octane }] = await Promise.all([
|
|
19
|
+
import(pathToFileURL(providerEntry).href),
|
|
20
|
+
import(pathToFileURL(requireProvider.resolve("@octane-xplat/nativescript-octane/config")).href),
|
|
21
|
+
import(pathToFileURL(require.resolve("octane/compiler/vite")).href)
|
|
22
|
+
]);
|
|
23
|
+
const { config: provider, coreRoot, reusedCoreFiles } = await createNativeScriptProvider(root);
|
|
24
|
+
const appKitSource = dirname(require.resolve("@octane-xplat/macos-appkit/host"));
|
|
25
|
+
const ui = coreMacOSUI(root);
|
|
26
|
+
const external = new Set(options.external);
|
|
27
|
+
if (!packaged) for (const name of [...nativeScriptDevImports, "@octane-xplat/macos-appkit"]) external.add(name);
|
|
28
|
+
const devSocket = mode === "development" ? nativeDevSocketPlugin() : null;
|
|
29
|
+
return {
|
|
30
|
+
config: {
|
|
31
|
+
root,
|
|
32
|
+
define: {
|
|
33
|
+
...provider.define,
|
|
34
|
+
...nodeEnvDefine(mode),
|
|
35
|
+
__DEV__: JSON.stringify(mode === "development"),
|
|
36
|
+
__WINDOWS__: "false"
|
|
37
|
+
},
|
|
38
|
+
plugins: [
|
|
39
|
+
...provider.plugins,
|
|
40
|
+
...ui.plugins,
|
|
41
|
+
...devSocket ? [devSocket] : [],
|
|
42
|
+
tabItemContentRoots(),
|
|
43
|
+
css("macos"),
|
|
44
|
+
inlineStylesheets("nativescript"),
|
|
45
|
+
boundary("macos", /* @__PURE__ */ new Set([...reusedCoreFiles, ...ui.reusedFiles])),
|
|
46
|
+
octane({
|
|
47
|
+
hmr: options.hmr ?? false,
|
|
48
|
+
exclude: ["types/macos", ...options.exclude ?? []],
|
|
49
|
+
renderers: {
|
|
50
|
+
registry: { nativescript: {
|
|
51
|
+
...nativeScriptRenderer,
|
|
52
|
+
intrinsics: "@octane-xplat/jsx"
|
|
53
|
+
} },
|
|
54
|
+
rules: options.rules ?? [{
|
|
55
|
+
include: "**/*.{tsx,tsrx}",
|
|
56
|
+
renderer: "nativescript"
|
|
57
|
+
}]
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
],
|
|
61
|
+
resolve: {
|
|
62
|
+
conditions: ["macos", "native"],
|
|
63
|
+
dedupe: ["octane"],
|
|
64
|
+
extensions: [
|
|
65
|
+
".macos.tsrx",
|
|
66
|
+
".tsrx",
|
|
67
|
+
".macos.tsx",
|
|
68
|
+
".tsx",
|
|
69
|
+
".macos.ts",
|
|
70
|
+
".ts",
|
|
71
|
+
".mts",
|
|
72
|
+
".jsx",
|
|
73
|
+
".js",
|
|
74
|
+
".json"
|
|
75
|
+
],
|
|
76
|
+
alias: [
|
|
77
|
+
...provider.resolve.alias,
|
|
78
|
+
...ui.aliases,
|
|
79
|
+
{
|
|
80
|
+
find: /^@octane-xplat\/macos-appkit$/,
|
|
81
|
+
replacement: join(appKitSource, "nativescript-renderer.macos.ts")
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
find: /^@octane-xplat\/macos-appkit\/host$/,
|
|
85
|
+
replacement: join(appKitSource, "nativescript-host.macos.ts")
|
|
86
|
+
},
|
|
87
|
+
...!external.has("@octane-xplat/nativescript-octane") ? [{
|
|
88
|
+
find: /^@octane-xplat\/nativescript-octane$/,
|
|
89
|
+
replacement: requireProvider.resolve("@octane-xplat/nativescript-octane")
|
|
90
|
+
}] : [],
|
|
91
|
+
{
|
|
92
|
+
find: /^octane$/,
|
|
93
|
+
replacement: "octane/universal/native"
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
build: {
|
|
98
|
+
cssCodeSplit: true,
|
|
99
|
+
outDir: options.outDir ?? (packaged ? "dist/package-build" : "dist"),
|
|
100
|
+
emptyOutDir: packaged,
|
|
101
|
+
lib: {
|
|
102
|
+
entry: options.entry ?? (packaged ? "src/main.ts" : "src/App.tsx"),
|
|
103
|
+
fileName: () => options.fileName ?? (packaged ? "main.cjs" : "app.cjs"),
|
|
104
|
+
formats: ["cjs"]
|
|
105
|
+
},
|
|
106
|
+
rollupOptions: {
|
|
107
|
+
external: [
|
|
108
|
+
"@nativescript/macos-node-api",
|
|
109
|
+
/^node:/,
|
|
110
|
+
...external
|
|
111
|
+
],
|
|
112
|
+
output: {
|
|
113
|
+
...provider.build.rollupOptions.output,
|
|
114
|
+
codeSplitting: false
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
coreRoot
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export { createCoreMacOSConfig };
|