@octane-xplat/build 0.0.1 → 0.20.0

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 (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -2
  3. package/dist/add-worker.js +66 -0
  4. package/dist/build-worker.js +276 -0
  5. package/dist/compatibility-check.js +153 -0
  6. package/dist/compatibility-data/compatibility.js +106 -0
  7. package/dist/compatibility-data/compatibility.json +305 -0
  8. package/dist/compatibility.js +229 -0
  9. package/dist/css-layers.js +63 -0
  10. package/dist/css-platform.js +230 -0
  11. package/dist/css-platform.types.d.ts +11 -0
  12. package/dist/dev-inspector.web.js +125 -0
  13. package/dist/dev-log-client.web.js +79 -0
  14. package/dist/dev-log-server.js +13 -0
  15. package/dist/doctor-checks.js +317 -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 +37 -0
  22. package/dist/linux/config.js +43 -0
  23. package/dist/linux/host/bridge-selftest.linux.js +255 -0
  24. package/dist/linux/host/gjs-host.js +1412 -0
  25. package/dist/linux/package.js +176 -0
  26. package/dist/linux-gtk/vite.d.ts +23 -0
  27. package/dist/linux-gtk/vite.js +194 -0
  28. package/dist/macos/config.js +141 -0
  29. package/dist/macos/doctor-checks.js +58 -0
  30. package/dist/macos/executables.js +39 -0
  31. package/dist/macos/jsc-host/runtime.js +134 -0
  32. package/dist/macos/native.js +287 -0
  33. package/dist/macos/runtime-package.js +30 -0
  34. package/dist/macos/tab-item.js +62 -0
  35. package/dist/macos/vite.d.ts +21 -0
  36. package/dist/macos/vite.js +111 -0
  37. package/dist/markdown.js +11 -0
  38. package/dist/mason-engine.js +20 -0
  39. package/dist/mcp/contracts/actions.js +133 -0
  40. package/dist/mcp/dev-bridge.js +363 -0
  41. package/dist/mcp/dev-socket.js +161 -0
  42. package/dist/mcp/dev-stack.js +134 -0
  43. package/dist/mcp/inspection/dom.web.js +46 -0
  44. package/dist/native-regex.js +123 -0
  45. package/dist/package-manager.js +106 -0
  46. package/dist/package-root.js +48 -0
  47. package/dist/patches.js +356 -0
  48. package/dist/route-config.js +53 -0
  49. package/dist/route-data.js +42 -0
  50. package/dist/route-generator.js +514 -0
  51. package/dist/route-path.js +29 -0
  52. package/dist/route-source.js +67 -0
  53. package/dist/targets.js +38 -0
  54. package/dist/tsconfig-envs.js +287 -0
  55. package/dist/tsrx-leaf.js +57 -0
  56. package/dist/typecheck-globals/macos.d.ts +21 -0
  57. package/dist/typecheck-globals/native.d.ts +26 -0
  58. package/dist/ui/src/markdown/markdown-ast.js +33 -0
  59. package/dist/ui/src/markdown/markdown-character-references.js +79 -0
  60. package/dist/ui/src/markdown/markdown-parse.js +1930 -0
  61. package/dist/ui/src/markdown/markdown-plugins.js +564 -0
  62. package/dist/ui/src/markdown/markdown-url.js +17 -0
  63. package/dist/updates-worker.js +34 -0
  64. package/dist/upgrade-worker.js +63 -0
  65. package/dist/vite.d.ts +85 -0
  66. package/dist/vite.js +628 -0
  67. package/dist/workshop-worker.js +181 -0
  68. package/package.json +71 -9
@@ -0,0 +1,43 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { isAbsolute, join, relative, resolve } from "node:path";
3
+ // ../cli/src/linux/config.ts
4
+ function inspectLinuxPackageConfig(appRoot) {
5
+ const manifest = JSON.parse(readFileSync(join(appRoot, "package.json"), "utf8"));
6
+ const target = manifest.xplat?.targets?.linux ?? {};
7
+ const settings = target.package ?? {};
8
+ const issues = [];
9
+ const runtime = target.runtime;
10
+ if (runtime !== "webkitgtk" && runtime !== "gtk") issues.push("linux.runtime must be webkitgtk or gtk");
11
+ const { applicationId, productName, executableName } = settings;
12
+ const version = settings.version ?? manifest.version;
13
+ const scheme = target.host?.scheme ?? "xplat";
14
+ if (typeof applicationId !== "string" || applicationId.length > 255 || !/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_-]*){2,}$/.test(applicationId)) issues.push("linux.package.applicationId must be a reverse-DNS application ID");
15
+ if (typeof productName !== "string" || !productName.trim() || [...productName].some((character) => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127)) issues.push("linux.package.productName must be a nonempty single-line name");
16
+ if (typeof executableName !== "string" || ["host", "bundle"].includes(executableName) || !/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(executableName)) issues.push("linux.package.executableName must contain only letters, digits, underscores, or hyphens");
17
+ if (typeof version !== "string" || !/^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][A-Za-z0-9.-]+)?$/.test(version)) issues.push("linux.package.version (or package version) must be a semantic version");
18
+ if ((runtime === "webkitgtk" || target.host?.scheme !== void 0) && (typeof scheme !== "string" || !/^[a-z][a-z0-9+.-]*$/.test(scheme) || [
19
+ "http",
20
+ "https",
21
+ "file",
22
+ "data",
23
+ "javascript"
24
+ ].includes(scheme))) issues.push("linux.host.scheme must be a custom lowercase URI scheme");
25
+ const config = settings.viteConfig ?? (runtime === "gtk" ? "vite.gtk.config.ts" : "vite.linux.config.ts");
26
+ let viteConfig;
27
+ if (typeof config !== "string" || isAbsolute(config) || relative(resolve(appRoot), resolve(appRoot, config)).startsWith("..")) issues.push("linux.package.viteConfig must be a relative path inside the app");
28
+ else {
29
+ viteConfig = resolve(appRoot, config);
30
+ if (!existsSync(viteConfig)) issues.push(`Linux Vite config not found: ${config}`);
31
+ }
32
+ return {
33
+ issues,
34
+ runtime,
35
+ applicationId,
36
+ productName,
37
+ executableName,
38
+ version,
39
+ scheme,
40
+ viteConfig
41
+ };
42
+ }
43
+ export { inspectLinuxPackageConfig };
@@ -0,0 +1,255 @@
1
+ // bridge-selftest.linux.js — evaluated inside the webview by the host after
2
+ // load (both WKHost.swift and gjs-host.js read this file). Round-trips every
3
+ // bridge service and reports via the xplatLog message handler, which the
4
+ // host prints to stdout. Also drops a <pre> into the DOM for eyeballing.
5
+ ;(async () => {
6
+ const log = (m) => webkit.messageHandlers.xplatLog.postMessage(m)
7
+ const call = (service, method, args) => window.__xplatBridge.call(service, method, args)
8
+
9
+ const legacyCall = (service, method, args) =>
10
+ new Promise((res, rej) => {
11
+ const id = 90000 + Math.floor(Math.random() * 9000)
12
+ const orig = window.__xplatBridge.resolve.bind(window.__xplatBridge)
13
+ const origRej = window.__xplatBridge.reject.bind(window.__xplatBridge)
14
+
15
+ window.__xplatBridge.resolve = (i, v) => {
16
+ window.__xplatBridge.resolve = orig
17
+ if (i === id) {
18
+ res(v)
19
+ } else {
20
+ orig(i, v)
21
+ }
22
+ }
23
+
24
+ window.__xplatBridge.reject = (i, m) => {
25
+ window.__xplatBridge.reject = origRej
26
+ if (i === id) {
27
+ rej(new Error(m))
28
+ } else {
29
+ origRej(i, m)
30
+ }
31
+ }
32
+
33
+ webkit.messageHandlers.xplat.postMessage(JSON.stringify({ id, service, method, args }))
34
+ })
35
+
36
+ const out = []
37
+ const failed = []
38
+ let deepLink = null
39
+
40
+ window.__xplatBridge.on('deep-links', 'open', (url) => {
41
+ deepLink = url
42
+ })
43
+
44
+ const run = async (name, fn, expected) => {
45
+ try {
46
+ const value = await fn()
47
+
48
+ if (
49
+ (expected !== undefined && value !== expected) ||
50
+ value === false ||
51
+ value === null ||
52
+ value === 'unsupported'
53
+ ) {
54
+ throw new Error('unexpected result: ' + JSON.stringify(value))
55
+ }
56
+
57
+ const result = name + '=' + JSON.stringify(value)
58
+
59
+ out.push(result)
60
+ log('SELFTEST_STEP ' + result)
61
+ } catch (e) {
62
+ failed.push(name)
63
+
64
+ const result = name + '!=>' + e.message
65
+
66
+ out.push(result)
67
+ log('SELFTEST_STEP ' + result)
68
+ }
69
+ }
70
+
71
+ log('SELFTEST_STARTED')
72
+ await run('capabilities', async () => {
73
+ const caps = await window.__xplatBridge.capabilities()
74
+ const expected = {
75
+ app: ['getInfo', 'getState', 'getWindowSize', 'consumeInitialUrl'],
76
+ clipboard: ['read', 'write'],
77
+ files: ['pick', 'readText', 'writeText'],
78
+ notifications: ['ensure', 'notify'],
79
+ secureStorage: ['get', 'set', 'remove'],
80
+ appearance: ['get'],
81
+ windows: ['open', 'close', 'setTitle'],
82
+ system: ['openUrl', 'openPath'],
83
+ storage: ['get', 'set', 'remove'],
84
+ }
85
+
86
+ // The camera service is implemented by the Linux GJS host; when a host
87
+ // reports it, the declared methods must be complete.
88
+ if (caps.camera) {
89
+ expected.camera = [
90
+ 'permissionStatus',
91
+ 'requestPermission',
92
+ 'movieDirectory',
93
+ 'reserveMoviePath',
94
+ 'writeMovieFile',
95
+ 'movieFileInfo',
96
+ 'readMovieFile',
97
+ 'deleteMovieFile',
98
+ ]
99
+ }
100
+
101
+ return Object.entries(expected).every(([service, methods]) =>
102
+ methods.every((method) => caps[service]?.includes(method)),
103
+ )
104
+ })
105
+
106
+ await run('deepLinks.open', async () => {
107
+ await new Promise((resolve) => setTimeout(resolve, 1800))
108
+ return deepLink === 'xplat://self-test/deep-link'
109
+ })
110
+
111
+ await run('legacy.clipboard.write', () => legacyCall('clipboard', 'write', ['legacy-ok']))
112
+ await run('app.getInfo', async () => (await call('app', 'getInfo', [])).supported)
113
+ await run('app.getState', async () =>
114
+ ['active', 'inactive', 'background'].includes(await call('app', 'getState', [])),
115
+ )
116
+
117
+ await run('app.getWindowSize', async () => {
118
+ const size = await call('app', 'getWindowSize', [])
119
+
120
+ return size.width > 0 && size.height > 0
121
+ })
122
+
123
+ await run(
124
+ 'app.consumeInitialUrl',
125
+ async () => (await call('app', 'consumeInitialUrl', [])) ?? 'none',
126
+ )
127
+
128
+ await run('clipboard.write', () => call('clipboard', 'write', ['harness-ok']))
129
+ await run('clipboard.read', () => call('clipboard', 'read', []), 'harness-ok')
130
+ await run('storage.set', async () => {
131
+ await call('storage', 'set', ['k', 'storage-value'])
132
+ return true
133
+ })
134
+
135
+ await run('storage.get', () => call('storage', 'get', ['k']), 'storage-value')
136
+ await run('storage.remove', async () => {
137
+ await call('storage', 'remove', ['k'])
138
+ return true
139
+ })
140
+
141
+ await run('secureStorage.set', () => call('secureStorage', 'set', ['k', 'v']))
142
+ await run('secureStorage.get', () => call('secureStorage', 'get', ['k']), 'v')
143
+ await run('notifications.ensure', () => call('notifications', 'ensure', []))
144
+ await run('notifications.notify', () => call('notifications', 'notify', ['title', 'body']))
145
+ await run('appearance.get', () => call('appearance', 'get', []))
146
+ await run('files.readText', () => call('files', 'readText', ['file:///etc/hosts']))
147
+
148
+ // camera movie storage: reserve, write, info, read-back, delete — the
149
+ // shared desktop contract also served by the macOS WKWebView host.
150
+ // Only runs on hosts that advertise the service (Linux today).
151
+ const capsForCamera = await window.__xplatBridge.capabilities()
152
+
153
+ if (capsForCamera.camera?.includes('writeMovieFile')) {
154
+ await run('camera.permissionStatus', async () => {
155
+ const { status } = await call('camera', 'permissionStatus', [{ kind: 'camera' }])
156
+
157
+ return ['notDetermined', 'granted', 'denied', 'restricted', 'unknown'].includes(status)
158
+ })
159
+
160
+ let movieFileUrl = null
161
+
162
+ await run('camera.writeMovieFile', async () => {
163
+ const { reservation } = await call('camera', 'reserveMoviePath', [{ container: 'mp4' }])
164
+
165
+ const { file } = await call('camera', 'writeMovieFile', [
166
+ { fileUrl: reservation.fileUrl, base64: btoa('movie-bytes') },
167
+ ])
168
+
169
+ if (!file?.uri?.startsWith('file://')) {
170
+ throw new Error('unexpected write result: ' + JSON.stringify(file))
171
+ }
172
+
173
+ movieFileUrl = file.uri
174
+ return file.uri
175
+ })
176
+
177
+ await run('camera.movieFileInfo', async () => {
178
+ const { info } = await call('camera', 'movieFileInfo', [{ fileUrl: movieFileUrl }])
179
+
180
+ return info?.exists && info.size === 11
181
+ })
182
+
183
+ await run('camera.readMovieFile', async () => {
184
+ const { base64 } = await call('camera', 'readMovieFile', [{ fileUrl: movieFileUrl }])
185
+
186
+ return atob(base64) === 'movie-bytes'
187
+ })
188
+
189
+ await run('camera.noOverwrite', async () => {
190
+ const { file } = await call('camera', 'writeMovieFile', [
191
+ { fileUrl: movieFileUrl, base64: btoa('x') },
192
+ ])
193
+
194
+ return file === null
195
+ })
196
+
197
+ await run('camera.privateRoot', async () => {
198
+ const { info } = await call('camera', 'movieFileInfo', [{ fileUrl: 'file:///etc/passwd' }])
199
+
200
+ return info === null
201
+ })
202
+
203
+ await run('camera.deleteMovieFile', async () => {
204
+ await call('camera', 'deleteMovieFile', [{ fileUrl: movieFileUrl }])
205
+ return !(await call('camera', 'movieFileInfo', [{ fileUrl: movieFileUrl }])).info.exists
206
+ })
207
+ }
208
+
209
+ // windows.open → real window+webview; windows.close → host emits
210
+ // windows.closed back to the opener.
211
+ const wid = 'selftest-win'
212
+ let gotClosed = false
213
+
214
+ window.__xplatBridge.on('windows', 'closed', (w) => {
215
+ if (w === wid) {
216
+ gotClosed = true
217
+ }
218
+ })
219
+
220
+ await run('windows.open', () =>
221
+ call('windows', 'open', [{ id: wid, url: '/', title: 'secondary' }]),
222
+ )
223
+
224
+ await new Promise((r) => setTimeout(r, 800))
225
+ await run('windows.close', () => call('windows', 'close', [wid]))
226
+ await new Promise((r) => setTimeout(r, 500))
227
+ await run('windows.closedEvent', async () => gotClosed)
228
+ await run('missing.clipboardMethod', async () => {
229
+ try {
230
+ await call('clipboard', 'nope', [])
231
+ return false
232
+ } catch (e) {
233
+ return e.message === 'host has no clipboard.nope'
234
+ }
235
+ })
236
+
237
+ await run('bootstrap.initialUrl', () => window.__xplatHostSnapshot?.initialUrl ?? 'none')
238
+ await run('missing.method', async () => {
239
+ try {
240
+ await call('nope', 'nope', [])
241
+ return false
242
+ } catch (e) {
243
+ return e.message === 'host has no nope.nope'
244
+ }
245
+ })
246
+
247
+ log('SELFTEST ' + out.join(' | '))
248
+
249
+ const d = document.createElement('pre')
250
+
251
+ d.id = 'bridge-selftest'
252
+ d.textContent = out.join('\n')
253
+ document.body.prepend(d)
254
+ log('SELFTEST_RESULT ' + JSON.stringify({ checks: out.length, failed }))
255
+ })()