@zenbujs/core 0.0.4 → 0.0.8
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/dist/{advice-config-BLXjqjGN.mjs → advice-config-DXSIo0sg.mjs} +49 -38
- package/dist/advice.d.mts +8 -8
- package/dist/advice.mjs +2 -2
- package/dist/base-window-BxBZ2md_.mjs +143 -0
- package/dist/build-config-Dzg2frpk.d.mts +215 -0
- package/dist/build-config-pWdmLnrk.mjs +53 -0
- package/dist/{build-electron-C3Beey84.mjs → build-electron-Dsbb1EMl.mjs} +308 -120
- package/dist/{build-source-BvC4bPqH.mjs → build-source-d1J3shV8.mjs} +62 -27
- package/dist/chunk-DsiFFCwN.mjs +16 -0
- package/dist/cli/bin.mjs +7 -7
- package/dist/cli/build.d.mts +2 -2
- package/dist/cli/build.mjs +2 -3
- package/dist/cli/resolve-config.mjs +3 -2
- package/dist/{cli-F0B4dvSg.mjs → cli-kL6mPgBE.mjs} +4 -4
- package/dist/{config-BlRXeUXx.mjs → config-BK78JDRI.mjs} +1 -1
- package/dist/config.d.mts +3 -2
- package/dist/config.mjs +3 -3
- package/dist/{db-Cd5ETuPG.mjs → db-Bc292RYo.mjs} +2 -2
- package/dist/db.d.mts +1 -1
- package/dist/db.mjs +2 -2
- package/dist/dev-B2emj0HZ.mjs +301 -0
- package/dist/env-bootstrap.d.mts +1 -1
- package/dist/env-bootstrap.mjs +52 -1
- package/dist/events.d.mts +19 -0
- package/dist/events.mjs +1 -0
- package/dist/host-version-BIrF8tX7.mjs +65 -0
- package/dist/index-w5QyDjuf.d.mts +780 -0
- package/dist/index.d.mts +5 -6
- package/dist/index.mjs +5 -5
- package/dist/installing-preload.cjs +60 -0
- package/dist/launcher.mjs +2615 -122
- package/dist/{link-BJmsKgPa.mjs → link-glX89NV5.mjs} +215 -89
- package/dist/{load-config-BG2tPIfF.mjs → load-config-C4Oe2qZO.mjs} +22 -3
- package/dist/loaders/zenbu.d.mts +1 -0
- package/dist/loaders/zenbu.mjs +108 -86
- package/dist/{monorepo-DCruz9Jx.mjs → monorepo-Dct-kkbQ.mjs} +3 -0
- package/dist/node-loader.mjs +1 -1
- package/dist/{publish-source-34Hn9zb0.mjs → publish-source-Dq2c0iOw.mjs} +2 -2
- package/dist/react.d.mts +56 -7
- package/dist/react.mjs +118 -7
- package/dist/registry-CMp8FYgS.d.mts +47 -0
- package/dist/registry-generated.d.mts +26 -0
- package/dist/registry-generated.mjs +1 -0
- package/dist/registry.d.mts +2 -2
- package/dist/{reloader-DJoCB0bC.mjs → reloader-B22UiNA2.mjs} +7 -7
- package/dist/{renderer-host-ztaSIOGx.mjs → renderer-host-DD16MXhI.mjs} +178 -57
- package/dist/{rpc-CsgWnlZx.mjs → rpc-C4_NQmpT.mjs} +11 -8
- package/dist/rpc.d.mts +1 -1
- package/dist/rpc.mjs +1 -1
- package/dist/runtime-BQWntcOb.d.mts +218 -0
- package/dist/runtime.d.mts +2 -2
- package/dist/runtime.mjs +578 -2
- package/dist/{schema-DvT61x2_.d.mts → schema-CjrMVk36.d.mts} +3 -3
- package/dist/schema.d.mts +1 -1
- package/dist/schema.mjs +27 -1
- package/dist/{server-DB3Eki_G.mjs → server-CZLMF8Dj.mjs} +6 -6
- package/dist/services/default.d.mts +3 -3
- package/dist/services/default.mjs +14 -13
- package/dist/services/index.d.mts +2 -276
- package/dist/services/index.mjs +8 -7
- package/dist/setup-gate.d.mts +1 -1
- package/dist/setup-gate.mjs +341 -1
- package/dist/{transform-DJH3vN4b.mjs → transform-BzrwkEdf.mjs} +23 -917
- package/dist/{transport-BMSzG2-F.mjs → transport-F2hv_OEm.mjs} +1 -1
- package/dist/updater-DCkz9M1c.mjs +1008 -0
- package/dist/{vite-plugins-t4MlFcz3.mjs → vite-plugins-tt6KAtyE.mjs} +27 -26
- package/dist/vite.d.mts +3 -3
- package/dist/vite.mjs +1 -1
- package/dist/{window-DUvMTons.mjs → window-YFKvAM0l.mjs} +36 -19
- package/dist/{write-9dRFczGJ.mjs → write-DgIRjo23.mjs} +1 -1
- package/package.json +18 -5
- package/dist/advice-config-D6K_a7e9.mjs +0 -2
- package/dist/base-window-D8CpxMU3.mjs +0 -94
- package/dist/base-window-OXg2KSyP.mjs +0 -2
- package/dist/build-config-BwnnfrN-.mjs +0 -23
- package/dist/chunk-Dm34NbLt.mjs +0 -6
- package/dist/config-Ch1FreWU.mjs +0 -2
- package/dist/db-Bz_CDIWg.mjs +0 -2
- package/dist/dev-DLutFPyo.mjs +0 -85
- package/dist/env-bootstrap-rj7I-59x.mjs +0 -53
- package/dist/http-B36qtsm0.mjs +0 -2
- package/dist/load-config-CQG4297M.mjs +0 -2
- package/dist/registry-CioEYLI5.d.mts +0 -61
- package/dist/reloader-FeHKV2jd.mjs +0 -2
- package/dist/renderer-host-BQpS0ZM2.mjs +0 -2
- package/dist/rpc-D_s7-WZe.mjs +0 -2
- package/dist/runtime-C95iyVn6.mjs +0 -461
- package/dist/runtime-CsiDppGF.d.mts +0 -149
- package/dist/schema-dGK6qkfR.mjs +0 -28
- package/dist/server-CgzQOPSW.mjs +0 -2
- package/dist/setup-gate-D8XfYY52.mjs +0 -140
- package/dist/transforms-DVoy8dCu.mjs +0 -47
- package/dist/transforms-EVd5Fgyk.d.mts +0 -136
- package/dist/view-registry-2zePxTEg.mjs +0 -2
- package/dist/window-S3TlTXlK.mjs +0 -2
- /package/dist/{env-bootstrap-uCKbw2q8.d.mts → env-bootstrap-rTs8KR3-.d.mts} +0 -0
- /package/dist/{index-CE0iPntP.d.mts → index-C-ALz_SH.d.mts} +0 -0
- /package/dist/{index-CKKoxA9V.d.mts → index-ClXLQ1fw.d.mts} +0 -0
- /package/dist/{index-UK58xuoR.d.mts → index-DeDxePAa.d.mts} +0 -0
- /package/dist/{log-CyKv8hQg.mjs → log-6rzaCV0I.mjs} +0 -0
- /package/dist/{mirror-sync-EiWvdzTJ.mjs → mirror-sync-pYU6f3-c.mjs} +0 -0
- /package/dist/{node-CvZnTx53.mjs → node-BhfLKYCi.mjs} +0 -0
- /package/dist/{schema-CIg4GzHQ.mjs → schema-Ca7SxXgS.mjs} +0 -0
- /package/dist/{setup-gate-D62nX5lk.d.mts → setup-gate-BQq0QgZH.d.mts} +0 -0
- /package/dist/{src-pELM4_iH.mjs → src-Cven45mq.mjs} +0 -0
- /package/dist/{trace-DCB7qFzT.mjs → trace-BaVg0rnY.mjs} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/events.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Core's own events file. Mirrors the contract every plugin follows
|
|
4
|
+
* (`events: "./path/to/events.ts"` in zenbu.config / zenbu.plugin),
|
|
5
|
+
* exporting a single `Events` type that the link generator scans into
|
|
6
|
+
* the registry's `CoreEvents`.
|
|
7
|
+
*
|
|
8
|
+
* Each top-level key is a namespace; `rpc.emit.<namespace>.<event>(payload)`
|
|
9
|
+
* inside a service emits with the matching payload type.
|
|
10
|
+
*/
|
|
11
|
+
type Events = {
|
|
12
|
+
advice: {
|
|
13
|
+
reload: {
|
|
14
|
+
type: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { Events };
|
package/dist/events.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
//#region src/shared/host-version.ts
|
|
4
|
+
/**
|
|
5
|
+
* Single source of truth for reading the .app's "host version" — the
|
|
6
|
+
* concrete semver string the developer authored on
|
|
7
|
+
* `defineBuildConfig({ hostVersion: "..." })` and that
|
|
8
|
+
* `zen build:electron` baked into `<bundle>/host.json`.
|
|
9
|
+
*
|
|
10
|
+
* Imported by both:
|
|
11
|
+
* - `packages/core/src/launcher.ts` (tsdown inlines this into
|
|
12
|
+
* `dist/launcher.mjs`; the launcher cannot `import "@zenbujs/core"`)
|
|
13
|
+
* - `packages/core/src/services/updater.ts` (resolved through normal
|
|
14
|
+
* `@zenbujs/core/...` resolution at runtime)
|
|
15
|
+
*
|
|
16
|
+
* The file lives at the bundle root (`<APP_PATH>/host.json`, where
|
|
17
|
+
* `APP_PATH = app.getAppPath()`), separate from `app-config.json` so
|
|
18
|
+
* its single purpose stays obvious.
|
|
19
|
+
*/
|
|
20
|
+
const HOST_VERSION_FILENAME = "host.json";
|
|
21
|
+
/**
|
|
22
|
+
* Read `<appPath>/host.json` and return its `version` field. Throws an
|
|
23
|
+
* informative error if the file is missing, unreadable, malformed, or
|
|
24
|
+
* the `version` field is missing/empty. Callers in dev mode should
|
|
25
|
+
* check for the file's existence first (or use `tryReadHostVersion`).
|
|
26
|
+
*/
|
|
27
|
+
function readHostVersion(appPath) {
|
|
28
|
+
const filePath = path.join(appPath, HOST_VERSION_FILENAME);
|
|
29
|
+
let raw;
|
|
30
|
+
try {
|
|
31
|
+
raw = fs.readFileSync(filePath, "utf8");
|
|
32
|
+
} catch (err) {
|
|
33
|
+
const e = err;
|
|
34
|
+
if (e.code === "ENOENT") throw new Error(`[host-version] missing ${filePath}. Was this .app built with a recent \`zen build:electron\`? The build step is responsible for writing host.json.`);
|
|
35
|
+
throw new Error(`[host-version] failed to read ${filePath}: ${e.message ?? String(e)}`);
|
|
36
|
+
}
|
|
37
|
+
let parsed;
|
|
38
|
+
try {
|
|
39
|
+
parsed = JSON.parse(raw);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
throw new Error(`[host-version] ${filePath} is not valid JSON: ${err.message}`);
|
|
42
|
+
}
|
|
43
|
+
if (typeof parsed !== "object" || parsed === null || typeof parsed.version !== "string" || parsed.version.trim().length === 0) throw new Error(`[host-version] ${filePath} is missing a non-empty \`version\` string.`);
|
|
44
|
+
return {
|
|
45
|
+
version: parsed.version.trim(),
|
|
46
|
+
path: filePath
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Non-throwing variant. Returns `null` when the file is absent or invalid. */
|
|
50
|
+
function tryReadHostVersion(appPath) {
|
|
51
|
+
try {
|
|
52
|
+
return readHostVersion(appPath);
|
|
53
|
+
} catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** Inverse of `readHostVersion` — used by `zen build:electron`. */
|
|
58
|
+
function writeHostVersion(appPath, version) {
|
|
59
|
+
const filePath = path.join(appPath, HOST_VERSION_FILENAME);
|
|
60
|
+
const body = { version };
|
|
61
|
+
fs.writeFileSync(filePath, JSON.stringify(body, null, 2) + "\n");
|
|
62
|
+
return filePath;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { tryReadHostVersion as n, writeHostVersion as r, HOST_VERSION_FILENAME as t };
|