@zenbujs/core 0.0.9 → 0.0.12
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-BiYhyeTz.d.mts +41 -0
- package/dist/advice.d.mts +2 -36
- package/dist/advice.mjs +2 -2
- package/dist/{base-window-BxBZ2md_.mjs → base-window-4P-fVvC_.mjs} +37 -26
- package/dist/{build-config-Dzg2frpk.d.mts → build-config-GF0XzR_Y.d.mts} +42 -18
- package/dist/{build-config-pWdmLnrk.mjs → build-config-HMMqpXI1.mjs} +0 -8
- package/dist/{build-electron-Dsbb1EMl.mjs → build-electron-Di_FE62r.mjs} +10 -6
- package/dist/{build-source-d1J3shV8.mjs → build-source-BIaWpaxE.mjs} +2 -2
- package/dist/cli/bin.mjs +7 -7
- package/dist/cli/build.d.mts +1 -1
- package/dist/cli/build.mjs +1 -1
- package/dist/cli/resolve-config.mjs +6 -1
- package/dist/{cli-kL6mPgBE.mjs → cli-5jFDJWM4.mjs} +4 -4
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +2 -2
- package/dist/{db-Bc292RYo.mjs → db-MkOccvBS.mjs} +2 -2
- package/dist/db.d.mts +3 -2
- package/dist/db.mjs +2 -10
- package/dist/{dev-B2emj0HZ.mjs → dev-BSDyzO4j.mjs} +3 -9
- package/dist/env-bootstrap.d.mts +1 -1
- package/dist/events.d.mts +0 -9
- package/dist/{host-version-BIrF8tX7.mjs → host-version-Cog_odmD.mjs} +4 -3
- package/dist/{index-CVF768Xs.d.mts → index-C0mXKol5.d.mts} +188 -143
- package/dist/{index-DeDxePAa.d.mts → index-FaexRVl_.d.mts} +13 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2 -2
- package/dist/launcher.mjs +64 -6
- package/dist/link-Bt3LB_NW.mjs +586 -0
- package/dist/{load-config-C4Oe2qZO.mjs → load-config-C2XloBaQ.mjs} +68 -5
- package/dist/node-loader.mjs +1 -1
- package/dist/{publish-source-Dq2c0iOw.mjs → publish-source-v93eB9kA.mjs} +6 -2
- package/dist/react.d.mts +6 -6
- package/dist/react.mjs +4 -4
- package/dist/registry-generated.d.mts +19 -14
- package/dist/registry-saQDMUhT.d.mts +13 -0
- package/dist/registry.d.mts +1 -1
- package/dist/{reloader-B22UiNA2.mjs → reloader-CFzxYa67.mjs} +3 -3
- package/dist/{renderer-host-DD16MXhI.mjs → renderer-host-Cw38dSDe.mjs} +35 -24
- package/dist/{rpc-C4_NQmpT.mjs → rpc-Dg9zwZ33.mjs} +4 -4
- package/dist/rpc.d.mts +1 -1
- package/dist/rpc.mjs +1 -1
- package/dist/runtime-DYUONc3S.mjs +861 -0
- package/dist/{runtime-BQWntcOb.d.mts → runtime-fnPDZFYM.d.mts} +100 -3
- package/dist/runtime.d.mts +2 -2
- package/dist/runtime.mjs +2 -578
- package/dist/{schema-CjrMVk36.d.mts → schema-brYpUjYO.d.mts} +13 -25
- package/dist/schema.d.mts +2 -2
- package/dist/schema.mjs +9 -2
- package/dist/{server-CZLMF8Dj.mjs → server-BJ2ZC2z2.mjs} +2 -2
- package/dist/services/default.d.mts +1 -5
- package/dist/services/default.mjs +12 -16
- package/dist/services/index.d.mts +1 -1
- package/dist/services/index.mjs +7 -7
- package/dist/setup-gate.d.mts +1 -1
- package/dist/setup-gate.mjs +20 -12
- package/dist/{transport-F2hv_OEm.mjs → transport-Bqlv9pmJ.mjs} +1 -1
- package/dist/updater-Bs1Jtem6.mjs +480 -0
- package/dist/{vite-plugins-tt6KAtyE.mjs → vite-plugins-Df-cfldF.mjs} +2 -49
- package/dist/vite.d.mts +0 -5
- package/dist/vite.mjs +1 -1
- package/dist/{window-YFKvAM0l.mjs → window-DgB70qeZ.mjs} +113 -22
- package/dist/{write-DgIRjo23.mjs → write-7IfKa_nq.mjs} +1 -1
- package/dist/zenbu-bg-parse-CIyPkJOY.mjs +46 -0
- package/package.json +19 -18
- package/LICENSE +0 -11
- package/dist/advice-config-DXSIo0sg.mjs +0 -154
- package/dist/link-glX89NV5.mjs +0 -673
- package/dist/registry-CMp8FYgS.d.mts +0 -47
- package/dist/updater-BtB_Ki1r.mjs +0 -1011
- /package/dist/{config-BK78JDRI.mjs → config-DfciRzDu.mjs} +0 -0
- /package/dist/{env-bootstrap-rTs8KR3-.d.mts → env-bootstrap-UBug-4Kw.d.mts} +0 -0
- /package/dist/{index-C-ALz_SH.d.mts → index-CSMHYi3u.d.mts} +0 -0
- /package/dist/{index-ClXLQ1fw.d.mts → index-DJOHDG5e.d.mts} +0 -0
- /package/dist/{log-6rzaCV0I.mjs → log-BkRqDwwB.mjs} +0 -0
- /package/dist/{mirror-sync-pYU6f3-c.mjs → mirror-sync-snqh9kEp.mjs} +0 -0
- /package/dist/{monorepo-Dct-kkbQ.mjs → monorepo-CBzK3l2i.mjs} +0 -0
- /package/dist/{node-BhfLKYCi.mjs → node-BuHlEsE4.mjs} +0 -0
- /package/dist/{schema-Ca7SxXgS.mjs → schema-C6k0SroY.mjs} +0 -0
- /package/dist/{setup-gate-BQq0QgZH.d.mts → setup-gate-DkysEZQO.d.mts} +0 -0
- /package/dist/{src-Cven45mq.mjs → src-BpZAt9zL.mjs} +0 -0
- /package/dist/{trace-BaVg0rnY.mjs → trace-BVcQSD59.mjs} +0 -0
- /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-
|
|
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
|
|
208
|
+
export { load_config_exports as a, loadPluginManifest as i, loadConfig as n, loadPluginFromPath as r, findConfigPath as t };
|
package/dist/node-loader.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as require_lib, t as zenbuAdviceTransform } from "./transform-
|
|
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 {
|
|
2
|
-
import { n as init, r as push } from "./mirror-sync-
|
|
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
|
|
2
|
-
import { n as EventProxy, r as RouterProxy } from "./index-
|
|
3
|
-
import { i as ZenbuRegister, n as ResolvedEvents, r as ResolvedServiceRouter, t as ResolvedDbRoot } from "./registry-
|
|
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.
|
|
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-
|
|
2
|
-
import { t as connectRpc } from "./src-
|
|
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.
|
|
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 {
|
|
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-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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:
|
|
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 };
|
package/dist/registry.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as ZenbuRegister, n as ResolvedEvents, r as ResolvedServiceRouter, t as ResolvedDbRoot } from "./registry-
|
|
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 {
|
|
3
|
-
import { t as createLogger } from "./log-
|
|
4
|
-
import { a as zenbuVitePlugins } from "./vite-plugins-
|
|
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 {
|
|
3
|
-
import { o as getZodDefault } from "./schema-
|
|
4
|
-
import
|
|
5
|
-
import { t as createLogger } from "./log-
|
|
6
|
-
import { t as ServerService } from "./server-
|
|
7
|
-
import { i as INTERNAL_DIR, r as DB_CONFIG_JSON, t as ReloaderService } from "./reloader-
|
|
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-
|
|
9
|
-
import { t as traceKyju } from "./trace-
|
|
10
|
-
import { a as createClient, i as dbStringify, n as createRouter, o as createEffectClient, r as dbParse, s as createReplica } from "./transport-
|
|
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
|
|
380
|
-
const sectionData = client.readRoot()?.
|
|
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
|
-
|
|
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
|
|
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
|
|
391
|
+
for (const op of addBlobOps) await client[name]?.[op.key]?.create?.(new Uint8Array(0));
|
|
393
392
|
if (migration.afterMigrate) {
|
|
394
|
-
const sectionClient = client
|
|
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,
|
|
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-
|
|
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(
|
|
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(
|
|
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.
|
|
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(
|
|
1487
|
-
|
|
1488
|
-
|
|
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 {
|
|
3
|
-
import { t as createLogger } from "./log-
|
|
4
|
-
import { s as HttpService } from "./renderer-host-
|
|
5
|
-
import { n as createRpcRouter, r as createServer } from "./src-
|
|
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-
|
|
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-
|
|
1
|
+
import { t as connectRpc } from "./src-BpZAt9zL.mjs";
|
|
2
2
|
export { connectRpc };
|