@zenbujs/core 0.0.9 → 0.0.13

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 (81) hide show
  1. package/dist/advice-config-BiYhyeTz.d.mts +41 -0
  2. package/dist/advice.d.mts +2 -36
  3. package/dist/advice.mjs +2 -2
  4. package/dist/{base-window-BxBZ2md_.mjs → base-window-4P-fVvC_.mjs} +37 -26
  5. package/dist/{build-config-Dzg2frpk.d.mts → build-config-GF0XzR_Y.d.mts} +42 -18
  6. package/dist/{build-config-pWdmLnrk.mjs → build-config-HMMqpXI1.mjs} +0 -8
  7. package/dist/{build-electron-Dsbb1EMl.mjs → build-electron-Di_FE62r.mjs} +10 -6
  8. package/dist/{build-source-d1J3shV8.mjs → build-source-BIaWpaxE.mjs} +2 -2
  9. package/dist/cli/bin.mjs +7 -7
  10. package/dist/cli/build.d.mts +1 -1
  11. package/dist/cli/build.mjs +1 -1
  12. package/dist/cli/resolve-config.mjs +6 -1
  13. package/dist/{cli-kL6mPgBE.mjs → cli-5jFDJWM4.mjs} +4 -4
  14. package/dist/config.d.mts +3 -3
  15. package/dist/config.mjs +2 -2
  16. package/dist/{db-Bc292RYo.mjs → db-MkOccvBS.mjs} +2 -2
  17. package/dist/db.d.mts +3 -2
  18. package/dist/db.mjs +2 -10
  19. package/dist/{dev-B2emj0HZ.mjs → dev-BSDyzO4j.mjs} +3 -9
  20. package/dist/env-bootstrap.d.mts +1 -1
  21. package/dist/events.d.mts +0 -9
  22. package/dist/{host-version-BIrF8tX7.mjs → host-version-Cog_odmD.mjs} +4 -3
  23. package/dist/{index-CVF768Xs.d.mts → index-C0mXKol5.d.mts} +188 -143
  24. package/dist/{index-DeDxePAa.d.mts → index-FaexRVl_.d.mts} +13 -1
  25. package/dist/index.d.mts +4 -4
  26. package/dist/index.mjs +2 -2
  27. package/dist/launcher.mjs +64 -6
  28. package/dist/link-Bt3LB_NW.mjs +586 -0
  29. package/dist/{load-config-C4Oe2qZO.mjs → load-config-C2XloBaQ.mjs} +68 -5
  30. package/dist/node-loader.mjs +1 -1
  31. package/dist/{publish-source-Dq2c0iOw.mjs → publish-source-v93eB9kA.mjs} +6 -2
  32. package/dist/react.d.mts +6 -6
  33. package/dist/react.mjs +4 -4
  34. package/dist/registry-generated.d.mts +19 -14
  35. package/dist/registry-saQDMUhT.d.mts +13 -0
  36. package/dist/registry.d.mts +1 -1
  37. package/dist/{reloader-B22UiNA2.mjs → reloader-CFzxYa67.mjs} +3 -3
  38. package/dist/{renderer-host-DD16MXhI.mjs → renderer-host-Cw38dSDe.mjs} +35 -24
  39. package/dist/{rpc-C4_NQmpT.mjs → rpc-Dg9zwZ33.mjs} +4 -4
  40. package/dist/rpc.d.mts +1 -1
  41. package/dist/rpc.mjs +1 -1
  42. package/dist/runtime-DYUONc3S.mjs +861 -0
  43. package/dist/{runtime-BQWntcOb.d.mts → runtime-fnPDZFYM.d.mts} +100 -3
  44. package/dist/runtime.d.mts +2 -2
  45. package/dist/runtime.mjs +2 -578
  46. package/dist/{schema-CjrMVk36.d.mts → schema-brYpUjYO.d.mts} +13 -25
  47. package/dist/schema.d.mts +2 -2
  48. package/dist/schema.mjs +9 -2
  49. package/dist/{server-CZLMF8Dj.mjs → server-BJ2ZC2z2.mjs} +2 -2
  50. package/dist/services/default.d.mts +1 -5
  51. package/dist/services/default.mjs +12 -16
  52. package/dist/services/index.d.mts +1 -1
  53. package/dist/services/index.mjs +7 -7
  54. package/dist/setup-gate.d.mts +1 -1
  55. package/dist/setup-gate.mjs +20 -12
  56. package/dist/{transport-F2hv_OEm.mjs → transport-Bqlv9pmJ.mjs} +1 -1
  57. package/dist/updater-Bs1Jtem6.mjs +480 -0
  58. package/dist/{vite-plugins-tt6KAtyE.mjs → vite-plugins-Df-cfldF.mjs} +2 -49
  59. package/dist/vite.d.mts +0 -5
  60. package/dist/vite.mjs +1 -1
  61. package/dist/{window-YFKvAM0l.mjs → window-DgB70qeZ.mjs} +113 -22
  62. package/dist/{write-DgIRjo23.mjs → write-7IfKa_nq.mjs} +1 -1
  63. package/dist/zenbu-bg-parse-CIyPkJOY.mjs +46 -0
  64. package/package.json +6 -5
  65. package/dist/advice-config-DXSIo0sg.mjs +0 -154
  66. package/dist/link-glX89NV5.mjs +0 -673
  67. package/dist/registry-CMp8FYgS.d.mts +0 -47
  68. package/dist/updater-BtB_Ki1r.mjs +0 -1011
  69. /package/dist/{config-BK78JDRI.mjs → config-DfciRzDu.mjs} +0 -0
  70. /package/dist/{env-bootstrap-rTs8KR3-.d.mts → env-bootstrap-UBug-4Kw.d.mts} +0 -0
  71. /package/dist/{index-C-ALz_SH.d.mts → index-CSMHYi3u.d.mts} +0 -0
  72. /package/dist/{index-ClXLQ1fw.d.mts → index-DJOHDG5e.d.mts} +0 -0
  73. /package/dist/{log-6rzaCV0I.mjs → log-BkRqDwwB.mjs} +0 -0
  74. /package/dist/{mirror-sync-pYU6f3-c.mjs → mirror-sync-snqh9kEp.mjs} +0 -0
  75. /package/dist/{monorepo-Dct-kkbQ.mjs → monorepo-CBzK3l2i.mjs} +0 -0
  76. /package/dist/{node-BhfLKYCi.mjs → node-BuHlEsE4.mjs} +0 -0
  77. /package/dist/{schema-Ca7SxXgS.mjs → schema-C6k0SroY.mjs} +0 -0
  78. /package/dist/{setup-gate-BQq0QgZH.d.mts → setup-gate-DkysEZQO.d.mts} +0 -0
  79. /package/dist/{src-Cven45mq.mjs → src-BpZAt9zL.mjs} +0 -0
  80. /package/dist/{trace-BaVg0rnY.mjs → trace-BVcQSD59.mjs} +0 -0
  81. /package/dist/{transform-BzrwkEdf.mjs → transform-czrcGnVV.mjs} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { n as __exportAll } from "./chunk-DsiFFCwN.mjs";
2
- import { i as resolveBuildConfig } from "./build-config-pWdmLnrk.mjs";
2
+ import { i as resolveBuildConfig } from "./build-config-HMMqpXI1.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
@@ -7,7 +7,9 @@ import { pathToFileURL } from "node:url";
7
7
  //#region src/cli/lib/load-config.ts
8
8
  var load_config_exports = /* @__PURE__ */ __exportAll({
9
9
  findConfigPath: () => findConfigPath,
10
- loadConfig: () => loadConfig
10
+ loadConfig: () => loadConfig,
11
+ loadPluginFromPath: () => loadPluginFromPath,
12
+ loadPluginManifest: () => loadPluginManifest
11
13
  });
12
14
  const localRequire = createRequire(import.meta.url);
13
15
  const CONFIG_NAMES = [
@@ -55,6 +57,22 @@ function assertPluginShape(p, source) {
55
57
  const obj = p;
56
58
  if (typeof obj.name !== "string" || obj.name.length === 0) throw new Error(`${source}: plugin missing required string \`name\`.`);
57
59
  if (!Array.isArray(obj.services)) throw new Error(`${source}: plugin \`services\` must be an array of glob strings.`);
60
+ if (obj.dependsOn !== void 0) {
61
+ if (!Array.isArray(obj.dependsOn)) throw new Error(`${source}: plugin \`dependsOn\` must be an array.`);
62
+ for (const [i, dep] of obj.dependsOn.entries()) {
63
+ if (!dep || typeof dep !== "object") throw new Error(`${source}: dependsOn[${i}] must be an object with { name, from }.`);
64
+ const d = dep;
65
+ if (typeof d.name !== "string" || d.name.length === 0) throw new Error(`${source}: dependsOn[${i}].name must be a non-empty string.`);
66
+ if (typeof d.from !== "string" || d.from.length === 0) throw new Error(`${source}: dependsOn[${i}].from must be a non-empty string.`);
67
+ }
68
+ }
69
+ }
70
+ function resolveDependsOn(plugin, dir) {
71
+ if (!plugin.dependsOn || plugin.dependsOn.length === 0) return void 0;
72
+ return plugin.dependsOn.map((d) => ({
73
+ name: d.name,
74
+ fromPath: path.isAbsolute(d.from) ? d.from : path.resolve(dir, d.from)
75
+ }));
58
76
  }
59
77
  function resolvePluginPaths(plugin, dir) {
60
78
  const abs = (rel) => path.isAbsolute(rel) ? rel : path.resolve(dir, rel);
@@ -66,7 +84,8 @@ function resolvePluginPaths(plugin, dir) {
66
84
  migrationsPath: plugin.migrations ? abs(plugin.migrations) : void 0,
67
85
  preloadPath: plugin.preload ? abs(plugin.preload) : void 0,
68
86
  eventsPath: plugin.events ? abs(plugin.events) : void 0,
69
- icons: plugin.icons
87
+ icons: plugin.icons,
88
+ dependsOn: resolveDependsOn(plugin, dir)
70
89
  };
71
90
  }
72
91
  async function resolvePluginEntry(entry, configDir) {
@@ -133,7 +152,6 @@ async function loadConfig(projectDir) {
133
152
  installingPath,
134
153
  plugins,
135
154
  build: resolveBuildConfig(config.build ?? {
136
- hostVersion: "0.0.0",
137
155
  source: ".",
138
156
  include: ["**/*"]
139
157
  })
@@ -141,5 +159,50 @@ async function loadConfig(projectDir) {
141
159
  pluginSourceFiles
142
160
  };
143
161
  }
162
+ /**
163
+ * Resolve a `dependsOn[].fromPath` to a `ResolvedPlugin`.
164
+ *
165
+ * `fromPath` may be:
166
+ * - a `zenbu.plugin.ts` (single plugin: load and return it; `name` must
167
+ * match the plugin's `name`),
168
+ * - a `zenbu.config.ts` (multi-plugin: load and pick `plugins[].name === name`).
169
+ *
170
+ * No recursion into the upstream's own `dependsOn` happens here — we only
171
+ * need the upstream's **own surface** for vendoring, never its composite.
172
+ */
173
+ async function loadPluginFromPath(args) {
174
+ const { fromPath, name } = args;
175
+ if (!fs.existsSync(fromPath)) throw new Error(`dependsOn: file ${fromPath} does not exist (looking for plugin "${name}").`);
176
+ if (!PLUGIN_FILE_RE.test(fromPath)) throw new Error(`dependsOn: \`from\` must point at a .ts/.js file, got ${path.basename(fromPath)}.`);
177
+ if (path.basename(fromPath).startsWith("zenbu.config.")) {
178
+ const config = await importFresh(fromPath);
179
+ if (!config || typeof config !== "object" || !Array.isArray(config.plugins)) throw new Error(`dependsOn: ${fromPath} is not a valid zenbu config (no \`plugins\` array).`);
180
+ const configDir = path.dirname(fromPath);
181
+ for (const entry of config.plugins) {
182
+ const { resolved } = await resolvePluginEntry(entry, configDir);
183
+ if (resolved.name === name) return resolved;
184
+ }
185
+ throw new Error(`dependsOn: ${fromPath} does not declare a plugin named "${name}".`);
186
+ }
187
+ const plugin = await importFresh(fromPath);
188
+ assertPluginShape(plugin, fromPath);
189
+ if (plugin.name !== name) throw new Error(`dependsOn: ${fromPath} exports plugin "${plugin.name}", expected "${name}".`);
190
+ return resolvePluginPaths(plugin, path.dirname(fromPath));
191
+ }
192
+ /**
193
+ * Load a standalone `zenbu.plugin.ts` (or any TS file whose default export
194
+ * is a `Plugin`) and return its `ResolvedPlugin`. Used by `zen link
195
+ * --plugin <dir>` to wire types for a plugin that has no host context yet.
196
+ *
197
+ * Unlike `loadPluginFromPath`, no `name` filter is required — the file
198
+ * must declare a single plugin.
199
+ */
200
+ async function loadPluginManifest(filePath) {
201
+ if (!fs.existsSync(filePath)) throw new Error(`zen link --plugin: ${filePath} does not exist.`);
202
+ if (!PLUGIN_FILE_RE.test(filePath)) throw new Error(`zen link --plugin: expected a .ts/.js file, got ${path.basename(filePath)}.`);
203
+ const plugin = await importFresh(filePath);
204
+ assertPluginShape(plugin, filePath);
205
+ return resolvePluginPaths(plugin, path.dirname(filePath));
206
+ }
144
207
  //#endregion
145
- export { load_config_exports as n, loadConfig as t };
208
+ export { load_config_exports as a, loadPluginManifest as i, loadConfig as n, loadPluginFromPath as r, findConfigPath as t };
@@ -1,4 +1,4 @@
1
- import { n as require_lib, t as zenbuAdviceTransform } from "./transform-BzrwkEdf.mjs";
1
+ import { n as require_lib, t as zenbuAdviceTransform } from "./transform-czrcGnVV.mjs";
2
2
  import { fileURLToPath } from "node:url";
3
3
  //#region ../advice/src/node-loader.ts
4
4
  var import_lib = require_lib();
@@ -1,10 +1,14 @@
1
- import { t as loadConfig } from "./load-config-C4Oe2qZO.mjs";
2
- import { n as init, r as push } from "./mirror-sync-pYU6f3-c.mjs";
1
+ import { n as loadConfig } from "./load-config-C2XloBaQ.mjs";
2
+ import { n as init, r as push } from "./mirror-sync-snqh9kEp.mjs";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
5
  import { execFileSync } from "node:child_process";
6
6
  import fsp from "node:fs/promises";
7
7
  //#region src/cli/commands/publish-source.ts
8
+ /**
9
+ * fixme: does not survive deletes from .zenbu, we need to
10
+ * resync from remote
11
+ */
8
12
  function resolveProjectDir() {
9
13
  const cwd = process.cwd();
10
14
  for (const name of [
package/dist/react.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { f as CollectionRefBrand, h as InferCollectionItem, n as connectReplica, o as ClientProxy, p as CollectionRefValue, u as CollectionState, y as SchemaShape } from "./index-DeDxePAa.mjs";
2
- import { n as EventProxy, r as RouterProxy } from "./index-C-ALz_SH.mjs";
3
- import { i as ZenbuRegister, n as ResolvedEvents, r as ResolvedServiceRouter, t as ResolvedDbRoot } from "./registry-CMp8FYgS.mjs";
1
+ import { b as SchemaShape, f as CollectionRefBrand, h as InferCollectionItem, n as connectReplica, o as ClientProxy, p as CollectionRefValue, u as CollectionState } from "./index-FaexRVl_.mjs";
2
+ import { n as EventProxy, r as RouterProxy } from "./index-CSMHYi3u.mjs";
3
+ import { i as ZenbuRegister, n as ResolvedEvents, r as ResolvedServiceRouter, t as ResolvedDbRoot } from "./registry-saQDMUhT.mjs";
4
4
  import * as _$react from "react";
5
5
  import { CSSProperties, ReactElement, ReactNode } from "react";
6
6
 
@@ -13,8 +13,8 @@ type CollectionResult<Item> = {
13
13
  };
14
14
  //#endregion
15
15
  //#region src/react.d.ts
16
- type AnyRpc = RouterProxy<Record<string, Record<string, (...args: any[]) => any>>>;
17
- type AnyEvents = EventProxy<Record<string, unknown>>;
16
+ type AnyRpc = RouterProxy<Record<string, Record<string, Record<string, (...args: any[]) => any>>>>;
17
+ type AnyEvents = EventProxy<Record<string, Record<string, unknown>>>;
18
18
  type AnyDbClient = ClientProxy<SchemaShape>;
19
19
  type Replica = Awaited<ReturnType<typeof connectReplica>>["replica"];
20
20
  type Connection = {
@@ -39,7 +39,7 @@ type RegisteredEvents = ResolvedEvents;
39
39
  * Subscribe to a slice of the live DB. The selector's `root` is typed via
40
40
  * `ZenbuRegister["db"]`, populated by `zen link`. No generic at the call site.
41
41
  *
42
- * const count = useDb((root) => root.plugin.app.count)
42
+ * const count = useDb((root) => root.app.count)
43
43
  */
44
44
  declare function useDb(): RegisteredDbRoot;
45
45
  declare function useDb<T>(selector: (root: RegisteredDbRoot) => T, isEqual?: (a: T, b: T) => boolean): T;
package/dist/react.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { i as dbStringify, r as dbParse, t as connectReplica } from "./transport-F2hv_OEm.mjs";
2
- import { t as connectRpc } from "./src-Cven45mq.mjs";
1
+ import { i as dbStringify, r as dbParse, t as connectReplica } from "./transport-Bqlv9pmJ.mjs";
2
+ import { t as connectRpc } from "./src-BpZAt9zL.mjs";
3
3
  import { createContext, createElement, useCallback, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
4
4
  //#region ../kyju/src/v2/react/index.ts
5
5
  function createKyjuReact() {
@@ -212,7 +212,7 @@ function ZenbuProvider({ wsUrl, fallback, errorFallback, children }) {
212
212
  const viewType = window.location.pathname.match(/^\/views\/([^/]+)\//)?.[1] ?? new URLSearchParams(window.location.search).get("type");
213
213
  let unsubReload = null;
214
214
  if (viewType) {
215
- const adviceReload = events?.advice?.reload;
215
+ const adviceReload = events?.core?.advice?.reload;
216
216
  if (adviceReload?.subscribe) unsubReload = adviceReload.subscribe((data) => {
217
217
  if (data?.type === "*" || data?.type === viewType) location.reload();
218
218
  });
@@ -326,7 +326,7 @@ function shallowJSONEqual(a, b) {
326
326
  }
327
327
  }
328
328
  function View({ type, args, visible = true, style, className, onLoad, fallback = null }) {
329
- const url = useDb((root) => root.plugin.core.lastKnownViewRegistry.find((v) => v.type === type)?.url ?? null);
329
+ const url = useDb((root) => root.core.lastKnownViewRegistry.find((v) => v.type === type)?.url ?? null);
330
330
  const iframeRef = useRef(null);
331
331
  const initialUrlRef = useRef(null);
332
332
  const lastArgsRef = useRef(null);
@@ -1,25 +1,30 @@
1
+ import { InferSchemaRoot } from "./db.mjs";
1
2
  import { Events } from "./events.mjs";
2
- import { n as SchemaRoot } from "./schema-CjrMVk36.mjs";
3
- import { c as DbService, d as ServerService, i as BaseWindowService, l as HttpService, n as WindowService, o as RendererHostService, r as RpcService, s as ViewRegistryService, t as UpdaterService, u as ReloaderService } from "./index-CVF768Xs.mjs";
3
+ import { o as schema } from "./schema-brYpUjYO.mjs";
4
+ import { c as DbService, d as ServerService, i as BaseWindowService, l as HttpService, n as WindowService, o as RendererHostService, r as RpcService, s as ViewRegistryService, t as UpdaterService, u as ReloaderService } from "./index-C0mXKol5.mjs";
4
5
 
5
6
  //#region src/registry-generated.d.ts
6
7
  type ServiceBase = "evaluate" | "shutdown" | "constructor" | "effect" | "__cleanupAllEffects" | "__effectCleanups" | "ctx";
7
8
  type ExtractRpcMethods<T> = { [K in Exclude<keyof T, ServiceBase | `_${string}`> as T[K] extends ((...args: any[]) => any) ? K : never]: T[K] };
8
9
  type CoreServiceRouter = {
9
- "base-window": ExtractRpcMethods<BaseWindowService>;
10
- db: ExtractRpcMethods<DbService>;
11
- http: ExtractRpcMethods<HttpService>;
12
- reloader: ExtractRpcMethods<ReloaderService>;
13
- "renderer-host": ExtractRpcMethods<RendererHostService>;
14
- rpc: ExtractRpcMethods<RpcService>;
15
- server: ExtractRpcMethods<ServerService>;
16
- updater: ExtractRpcMethods<UpdaterService>;
17
- "view-registry": ExtractRpcMethods<ViewRegistryService>;
18
- window: ExtractRpcMethods<WindowService>;
10
+ core: {
11
+ "base-window": ExtractRpcMethods<BaseWindowService>;
12
+ db: ExtractRpcMethods<DbService>;
13
+ http: ExtractRpcMethods<HttpService>;
14
+ reloader: ExtractRpcMethods<ReloaderService>;
15
+ "renderer-host": ExtractRpcMethods<RendererHostService>;
16
+ rpc: ExtractRpcMethods<RpcService>;
17
+ server: ExtractRpcMethods<ServerService>;
18
+ updater: ExtractRpcMethods<UpdaterService>;
19
+ "view-registry": ExtractRpcMethods<ViewRegistryService>;
20
+ window: ExtractRpcMethods<WindowService>;
21
+ };
22
+ };
23
+ type CoreEvents = {
24
+ core: Events;
19
25
  };
20
- type CoreEvents = Events;
21
26
  type CoreDbSections = {
22
- core: SchemaRoot;
27
+ core: InferSchemaRoot<typeof schema>;
23
28
  };
24
29
  type CorePreloads = {};
25
30
  //#endregion
@@ -0,0 +1,13 @@
1
+ //#region src/registry.d.ts
2
+ interface ZenbuRegister {}
3
+ type ResolvedDbRoot = ZenbuRegister extends {
4
+ db: infer T;
5
+ } ? T : {};
6
+ type ResolvedServiceRouter = ZenbuRegister extends {
7
+ rpc: infer T;
8
+ } ? T : {};
9
+ type ResolvedEvents = ZenbuRegister extends {
10
+ events: infer T;
11
+ } ? T : {};
12
+ //#endregion
13
+ export { ZenbuRegister as i, ResolvedEvents as n, ResolvedServiceRouter as r, ResolvedDbRoot as t };
@@ -1,2 +1,2 @@
1
- import { i as ZenbuRegister, n as ResolvedEvents, r as ResolvedServiceRouter, t as ResolvedDbRoot } from "./registry-CMp8FYgS.mjs";
1
+ import { i as ZenbuRegister, n as ResolvedEvents, r as ResolvedServiceRouter, t as ResolvedDbRoot } from "./registry-saQDMUhT.mjs";
2
2
  export { ResolvedDbRoot, ResolvedEvents, ResolvedServiceRouter, ZenbuRegister };
@@ -1,7 +1,7 @@
1
1
  import { n as __exportAll } from "./chunk-DsiFFCwN.mjs";
2
- import { Service, runtime } from "./runtime.mjs";
3
- import { t as createLogger } from "./log-6rzaCV0I.mjs";
4
- import { a as zenbuVitePlugins } from "./vite-plugins-tt6KAtyE.mjs";
2
+ import { f as runtime, n as Service } from "./runtime-DYUONc3S.mjs";
3
+ import { t as createLogger } from "./log-BkRqDwwB.mjs";
4
+ import { a as zenbuVitePlugins } from "./vite-plugins-Df-cfldF.mjs";
5
5
  import os from "node:os";
6
6
  import path, { resolve } from "node:path";
7
7
  import { createHash } from "node:crypto";
@@ -1,13 +1,13 @@
1
1
  import { n as __exportAll } from "./chunk-DsiFFCwN.mjs";
2
- import { Service, getAppEntrypoint, getPlugins, runtime, subscribeConfig } from "./runtime.mjs";
3
- import { o as getZodDefault } from "./schema-Ca7SxXgS.mjs";
4
- import { schema } from "./schema.mjs";
5
- import { t as createLogger } from "./log-6rzaCV0I.mjs";
6
- import { t as ServerService } from "./server-CZLMF8Dj.mjs";
7
- import { i as INTERNAL_DIR, r as DB_CONFIG_JSON, t as ReloaderService } from "./reloader-B22UiNA2.mjs";
8
- import { a as createBlob, c as makeErrorAck, g as layer$1, h as writeJsonFile, i as cleanupStaleTmpFiles, l as paths, m as validateSession, n as makeRootCache, o as createCollection, p as sendAck, r as broadcastDbUpdate, s as makeAck, t as handleWrite, u as readCollectionItemRange, v as FileSystem } from "./write-DgIRjo23.mjs";
9
- import { t as traceKyju } from "./trace-BaVg0rnY.mjs";
10
- import { a as createClient, i as dbStringify, n as createRouter, o as createEffectClient, r as dbParse, s as createReplica } from "./transport-F2hv_OEm.mjs";
2
+ import { f as runtime, i as getAppEntrypoint, n as Service, p as subscribeConfig, s as getPlugins } from "./runtime-DYUONc3S.mjs";
3
+ import { o as getZodDefault } from "./schema-C6k0SroY.mjs";
4
+ import schema from "./schema.mjs";
5
+ import { t as createLogger } from "./log-BkRqDwwB.mjs";
6
+ import { t as ServerService } from "./server-BJ2ZC2z2.mjs";
7
+ import { i as INTERNAL_DIR, r as DB_CONFIG_JSON, t as ReloaderService } from "./reloader-CFzxYa67.mjs";
8
+ import { a as createBlob, c as makeErrorAck, g as layer$1, h as writeJsonFile, i as cleanupStaleTmpFiles, l as paths, m as validateSession, n as makeRootCache, o as createCollection, p as sendAck, r as broadcastDbUpdate, s as makeAck, t as handleWrite, u as readCollectionItemRange, v as FileSystem } from "./write-7IfKa_nq.mjs";
9
+ import { t as traceKyju } from "./trace-BVcQSD59.mjs";
10
+ import { a as createClient, i as dbStringify, n as createRouter, o as createEffectClient, r as dbParse, s as createReplica } from "./transport-Bqlv9pmJ.mjs";
11
11
  import fs from "node:fs";
12
12
  import os from "node:os";
13
13
  import path from "node:path";
@@ -376,22 +376,21 @@ const sectionMigrationPlugin = (sections) => ({
376
376
  const migration = migrations[v];
377
377
  const ops = migration.operations ?? [];
378
378
  const removeOps = ops.filter((o) => o.op === "remove" && (o.kind === "collection" || o.kind === "blob"));
379
- for (const op of removeOps) await client.plugin?.[name]?.[op.key]?.delete?.();
380
- const sectionData = client.readRoot()?.plugin?.[name] ?? {};
379
+ for (const op of removeOps) await client[name]?.[op.key]?.delete?.();
380
+ const sectionData = client.readRoot()?.[name] ?? {};
381
381
  const apply = (data) => applyOperations(data, ops);
382
382
  let newSectionData;
383
383
  if (migration.migrate) newSectionData = migration.migrate(sectionData, { apply });
384
384
  else newSectionData = apply(sectionData);
385
385
  await client.update((r) => {
386
- if (!r.plugin) r.plugin = {};
387
- r.plugin[name] = newSectionData;
386
+ r[name] = newSectionData;
388
387
  });
389
388
  const addCollectionOps = ops.filter((o) => o.op === "add" && o.kind === "collection");
390
- for (const op of addCollectionOps) await client.plugin?.[name]?.[op.key]?.create?.();
389
+ for (const op of addCollectionOps) await client[name]?.[op.key]?.create?.();
391
390
  const addBlobOps = ops.filter((o) => o.op === "add" && o.kind === "blob");
392
- for (const op of addBlobOps) await client.plugin?.[name]?.[op.key]?.create?.(new Uint8Array(0));
391
+ for (const op of addBlobOps) await client[name]?.[op.key]?.create?.(new Uint8Array(0));
393
392
  if (migration.afterMigrate) {
394
- const sectionClient = client.plugin?.[name];
393
+ const sectionClient = client[name];
395
394
  await migration.afterMigrate({ client: sectionClient });
396
395
  }
397
396
  await client.update((r) => {
@@ -560,7 +559,7 @@ const initializeSectionedDbIfNeeded = (fs, config, sections) => Effect.gen(funct
560
559
  yield* fs.makeDirectory(config.dbPath, { recursive: true });
561
560
  const sectionsData = {};
562
561
  for (const section of sections) sectionsData[section.name] = yield* buildSchemaRoot(fs, config, section.schema);
563
- yield* finalizeAndWriteRoot(fs, config, { plugin: sectionsData });
562
+ yield* finalizeAndWriteRoot(fs, config, sectionsData);
564
563
  });
565
564
  const createDbEffect = (userConfig) => Effect.gen(function* () {
566
565
  const fs = yield* FileSystem;
@@ -581,6 +580,8 @@ const createDbEffect = (userConfig) => Effect.gen(function* () {
581
580
  const names = userConfig.sections.map((s) => s.name);
582
581
  const dupes = names.filter((n, i) => names.indexOf(n) !== i);
583
582
  if (dupes.length > 0) throw new Error(`Duplicate section names: ${[...new Set(dupes)].join(", ")}`);
583
+ const conflicts = names.filter((n) => n === "_plugins");
584
+ if (conflicts.length > 0) throw new Error(`Section names collide with reserved kyju keys: ${conflicts.join(", ")}`);
584
585
  yield* initializeSectionedDbIfNeeded(fs, config, userConfig.sections);
585
586
  } else if (userConfig.schema) yield* initializeDbIfNeeded(fs, config, userConfig.schema);
586
587
  }));
@@ -727,6 +728,9 @@ async function loadRegistry() {
727
728
  }
728
729
  if (!raw || typeof raw !== "object") return { ...DEFAULT_REGISTRY };
729
730
  const obj = raw;
731
+ /**
732
+ * legacy? no
733
+ */
730
734
  if (typeof obj.dbPath === "string" && obj.defaultDbPath === void 0 && obj.dbs === void 0) {
731
735
  const p = normalize(obj.dbPath);
732
736
  const upgraded = {
@@ -1016,7 +1020,7 @@ function resolveConfigPath() {
1016
1020
  * loader-emitted barrel before any service evaluates.
1017
1021
  */
1018
1022
  async function loadAppDbField(configPath) {
1019
- const { loadConfig } = await import("./load-config-C4Oe2qZO.mjs").then((n) => n.n);
1023
+ const { loadConfig } = await import("./load-config-C2XloBaQ.mjs").then((n) => n.a);
1020
1024
  const { resolved } = await loadConfig(path.dirname(configPath));
1021
1025
  return resolved.dbPath;
1022
1026
  }
@@ -1352,7 +1356,8 @@ var ViewRegistryService = class extends Service.create({
1352
1356
  }) {
1353
1357
  views = /* @__PURE__ */ new Map();
1354
1358
  manifestIcons = /* @__PURE__ */ new Map();
1355
- async register(type, root, configFile, meta) {
1359
+ async register(spec) {
1360
+ const { type, root, configFile, meta } = spec;
1356
1361
  log$1.verbose(`register("${type}", root="${root}", config="${configFile}")`);
1357
1362
  const existing = this.views.get(type);
1358
1363
  if (existing) {
@@ -1374,7 +1379,8 @@ var ViewRegistryService = class extends Service.create({
1374
1379
  log$1.verbose(`"${type}" registered at ${entry.url}`);
1375
1380
  return entry;
1376
1381
  }
1377
- registerAlias(type, reloaderId, pathPrefix, meta) {
1382
+ registerAlias(spec) {
1383
+ const { type, reloaderId, pathPrefix, meta } = spec;
1378
1384
  const existing = this.views.get(type);
1379
1385
  if (existing) return existing;
1380
1386
  const reloaderEntry = this.ctx.reloader.get(reloaderId);
@@ -1428,7 +1434,7 @@ var ViewRegistryService = class extends Service.create({
1428
1434
  meta: e.meta
1429
1435
  }));
1430
1436
  await Effect.runPromise(client.update((root) => {
1431
- root.plugin.core.lastKnownViewRegistry = snapshot;
1437
+ root.core.lastKnownViewRegistry = snapshot;
1432
1438
  })).catch((err) => {});
1433
1439
  }
1434
1440
  };
@@ -1483,9 +1489,14 @@ var RendererHostService = class extends Service.create({
1483
1489
  const entry = await this.ctx.reloader.create("app", rendererRoot, configFile);
1484
1490
  this.url = entry.url;
1485
1491
  this.port = entry.port;
1486
- this.ctx.viewRegistry.registerAlias("app", "app", "", {
1487
- kind: "app",
1488
- label: "App"
1492
+ this.ctx.viewRegistry.registerAlias({
1493
+ type: "entrypoint",
1494
+ reloaderId: "app",
1495
+ pathPrefix: "",
1496
+ meta: {
1497
+ kind: "entrypoint",
1498
+ label: "App"
1499
+ }
1489
1500
  });
1490
1501
  log.verbose(`ready at ${this.url}`);
1491
1502
  }
@@ -1,8 +1,8 @@
1
1
  import { n as __exportAll } from "./chunk-DsiFFCwN.mjs";
2
- import { Service, runtime } from "./runtime.mjs";
3
- import { t as createLogger } from "./log-6rzaCV0I.mjs";
4
- import { s as HttpService } from "./renderer-host-DD16MXhI.mjs";
5
- import { n as createRpcRouter, r as createServer } from "./src-Cven45mq.mjs";
2
+ import { f as runtime, n as Service } from "./runtime-DYUONc3S.mjs";
3
+ import { t as createLogger } from "./log-BkRqDwwB.mjs";
4
+ import { s as HttpService } from "./renderer-host-Cw38dSDe.mjs";
5
+ import { n as createRpcRouter, r as createServer } from "./src-BpZAt9zL.mjs";
6
6
  //#region src/services/rpc.ts
7
7
  var rpc_exports = /* @__PURE__ */ __exportAll({ RpcService: () => RpcService });
8
8
  const log = createLogger("rpc");
package/dist/rpc.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as EventProxy, r as RouterProxy, t as connectRpc } from "./index-C-ALz_SH.mjs";
1
+ import { n as EventProxy, r as RouterProxy, t as connectRpc } from "./index-CSMHYi3u.mjs";
2
2
  export { type EventProxy, type RouterProxy, connectRpc };
package/dist/rpc.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as connectRpc } from "./src-Cven45mq.mjs";
1
+ import { t as connectRpc } from "./src-BpZAt9zL.mjs";
2
2
  export { connectRpc };