@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.
Files changed (106) hide show
  1. package/dist/{advice-config-BLXjqjGN.mjs → advice-config-DXSIo0sg.mjs} +49 -38
  2. package/dist/advice.d.mts +8 -8
  3. package/dist/advice.mjs +2 -2
  4. package/dist/base-window-BxBZ2md_.mjs +143 -0
  5. package/dist/build-config-Dzg2frpk.d.mts +215 -0
  6. package/dist/build-config-pWdmLnrk.mjs +53 -0
  7. package/dist/{build-electron-C3Beey84.mjs → build-electron-Dsbb1EMl.mjs} +308 -120
  8. package/dist/{build-source-BvC4bPqH.mjs → build-source-d1J3shV8.mjs} +62 -27
  9. package/dist/chunk-DsiFFCwN.mjs +16 -0
  10. package/dist/cli/bin.mjs +7 -7
  11. package/dist/cli/build.d.mts +2 -2
  12. package/dist/cli/build.mjs +2 -3
  13. package/dist/cli/resolve-config.mjs +3 -2
  14. package/dist/{cli-F0B4dvSg.mjs → cli-kL6mPgBE.mjs} +4 -4
  15. package/dist/{config-BlRXeUXx.mjs → config-BK78JDRI.mjs} +1 -1
  16. package/dist/config.d.mts +3 -2
  17. package/dist/config.mjs +3 -3
  18. package/dist/{db-Cd5ETuPG.mjs → db-Bc292RYo.mjs} +2 -2
  19. package/dist/db.d.mts +1 -1
  20. package/dist/db.mjs +2 -2
  21. package/dist/dev-B2emj0HZ.mjs +301 -0
  22. package/dist/env-bootstrap.d.mts +1 -1
  23. package/dist/env-bootstrap.mjs +52 -1
  24. package/dist/events.d.mts +19 -0
  25. package/dist/events.mjs +1 -0
  26. package/dist/host-version-BIrF8tX7.mjs +65 -0
  27. package/dist/index-w5QyDjuf.d.mts +780 -0
  28. package/dist/index.d.mts +5 -6
  29. package/dist/index.mjs +5 -5
  30. package/dist/installing-preload.cjs +60 -0
  31. package/dist/launcher.mjs +2615 -122
  32. package/dist/{link-BJmsKgPa.mjs → link-glX89NV5.mjs} +215 -89
  33. package/dist/{load-config-BG2tPIfF.mjs → load-config-C4Oe2qZO.mjs} +22 -3
  34. package/dist/loaders/zenbu.d.mts +1 -0
  35. package/dist/loaders/zenbu.mjs +108 -86
  36. package/dist/{monorepo-DCruz9Jx.mjs → monorepo-Dct-kkbQ.mjs} +3 -0
  37. package/dist/node-loader.mjs +1 -1
  38. package/dist/{publish-source-34Hn9zb0.mjs → publish-source-Dq2c0iOw.mjs} +2 -2
  39. package/dist/react.d.mts +56 -7
  40. package/dist/react.mjs +118 -7
  41. package/dist/registry-CMp8FYgS.d.mts +47 -0
  42. package/dist/registry-generated.d.mts +26 -0
  43. package/dist/registry-generated.mjs +1 -0
  44. package/dist/registry.d.mts +2 -2
  45. package/dist/{reloader-DJoCB0bC.mjs → reloader-B22UiNA2.mjs} +7 -7
  46. package/dist/{renderer-host-ztaSIOGx.mjs → renderer-host-DD16MXhI.mjs} +178 -57
  47. package/dist/{rpc-CsgWnlZx.mjs → rpc-C4_NQmpT.mjs} +11 -8
  48. package/dist/rpc.d.mts +1 -1
  49. package/dist/rpc.mjs +1 -1
  50. package/dist/runtime-BQWntcOb.d.mts +218 -0
  51. package/dist/runtime.d.mts +2 -2
  52. package/dist/runtime.mjs +578 -2
  53. package/dist/{schema-DvT61x2_.d.mts → schema-CjrMVk36.d.mts} +3 -3
  54. package/dist/schema.d.mts +1 -1
  55. package/dist/schema.mjs +27 -1
  56. package/dist/{server-DB3Eki_G.mjs → server-CZLMF8Dj.mjs} +6 -6
  57. package/dist/services/default.d.mts +3 -3
  58. package/dist/services/default.mjs +14 -13
  59. package/dist/services/index.d.mts +2 -276
  60. package/dist/services/index.mjs +8 -7
  61. package/dist/setup-gate.d.mts +1 -1
  62. package/dist/setup-gate.mjs +341 -1
  63. package/dist/{transform-DJH3vN4b.mjs → transform-BzrwkEdf.mjs} +23 -917
  64. package/dist/{transport-BMSzG2-F.mjs → transport-F2hv_OEm.mjs} +1 -1
  65. package/dist/updater-DCkz9M1c.mjs +1008 -0
  66. package/dist/{vite-plugins-t4MlFcz3.mjs → vite-plugins-tt6KAtyE.mjs} +27 -26
  67. package/dist/vite.d.mts +3 -3
  68. package/dist/vite.mjs +1 -1
  69. package/dist/{window-DUvMTons.mjs → window-YFKvAM0l.mjs} +36 -19
  70. package/dist/{write-9dRFczGJ.mjs → write-DgIRjo23.mjs} +1 -1
  71. package/package.json +18 -5
  72. package/dist/advice-config-D6K_a7e9.mjs +0 -2
  73. package/dist/base-window-D8CpxMU3.mjs +0 -94
  74. package/dist/base-window-OXg2KSyP.mjs +0 -2
  75. package/dist/build-config-BwnnfrN-.mjs +0 -23
  76. package/dist/chunk-Dm34NbLt.mjs +0 -6
  77. package/dist/config-Ch1FreWU.mjs +0 -2
  78. package/dist/db-Bz_CDIWg.mjs +0 -2
  79. package/dist/dev-DLutFPyo.mjs +0 -85
  80. package/dist/env-bootstrap-rj7I-59x.mjs +0 -53
  81. package/dist/http-B36qtsm0.mjs +0 -2
  82. package/dist/load-config-CQG4297M.mjs +0 -2
  83. package/dist/registry-CioEYLI5.d.mts +0 -61
  84. package/dist/reloader-FeHKV2jd.mjs +0 -2
  85. package/dist/renderer-host-BQpS0ZM2.mjs +0 -2
  86. package/dist/rpc-D_s7-WZe.mjs +0 -2
  87. package/dist/runtime-C95iyVn6.mjs +0 -461
  88. package/dist/runtime-CsiDppGF.d.mts +0 -149
  89. package/dist/schema-dGK6qkfR.mjs +0 -28
  90. package/dist/server-CgzQOPSW.mjs +0 -2
  91. package/dist/setup-gate-D8XfYY52.mjs +0 -140
  92. package/dist/transforms-DVoy8dCu.mjs +0 -47
  93. package/dist/transforms-EVd5Fgyk.d.mts +0 -136
  94. package/dist/view-registry-2zePxTEg.mjs +0 -2
  95. package/dist/window-S3TlTXlK.mjs +0 -2
  96. /package/dist/{env-bootstrap-uCKbw2q8.d.mts → env-bootstrap-rTs8KR3-.d.mts} +0 -0
  97. /package/dist/{index-CE0iPntP.d.mts → index-C-ALz_SH.d.mts} +0 -0
  98. /package/dist/{index-CKKoxA9V.d.mts → index-ClXLQ1fw.d.mts} +0 -0
  99. /package/dist/{index-UK58xuoR.d.mts → index-DeDxePAa.d.mts} +0 -0
  100. /package/dist/{log-CyKv8hQg.mjs → log-6rzaCV0I.mjs} +0 -0
  101. /package/dist/{mirror-sync-EiWvdzTJ.mjs → mirror-sync-pYU6f3-c.mjs} +0 -0
  102. /package/dist/{node-CvZnTx53.mjs → node-BhfLKYCi.mjs} +0 -0
  103. /package/dist/{schema-CIg4GzHQ.mjs → schema-Ca7SxXgS.mjs} +0 -0
  104. /package/dist/{setup-gate-D62nX5lk.d.mts → setup-gate-BQq0QgZH.d.mts} +0 -0
  105. /package/dist/{src-pELM4_iH.mjs → src-Cven45mq.mjs} +0 -0
  106. /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 };
@@ -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 };