@zenbujs/core 0.0.3 → 0.0.5
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-CjgkEf2E.mjs → advice-config-QYB2qEd_.mjs} +32 -14
- package/dist/advice.mjs +1 -1
- package/dist/{base-window-BUt8pwbw.mjs → base-window-BbFRRhKP.mjs} +9 -4
- package/dist/{build-config-pbv0w4oN.mjs → build-config-C3a-o3_B.mjs} +8 -2
- package/dist/{build-electron-BzHa_hRi.mjs → build-electron-CNJ0dLND.mjs} +12 -6
- package/dist/{build-source-CnTfQBGK.mjs → build-source-C2puqEVr.mjs} +13 -8
- package/dist/chunk-DsiFFCwN.mjs +16 -0
- package/dist/cli/bin.mjs +12 -15
- package/dist/cli/build.d.mts +1 -52
- package/dist/cli/build.mjs +2 -47
- package/dist/cli/resolve-config.mjs +37 -0
- package/dist/{cli-BLbQQIVB.mjs → cli-C3R1LBMY.mjs} +5 -5
- package/dist/{config-CdVrW85P.mjs → config-DXRCDUxG.mjs} +1 -1
- package/dist/config.d.mts +3 -0
- package/dist/config.mjs +4 -0
- package/dist/{db-BXadETOb.mjs → db-xjvahRFJ.mjs} +47 -41
- package/dist/db.d.mts +1 -1
- package/dist/db.mjs +2 -2
- package/dist/env-bootstrap.d.mts +1 -1
- package/dist/env-bootstrap.mjs +52 -1
- package/dist/index-ClXLQ1fw.d.mts +1 -0
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +4 -4
- package/dist/{link-VOoGs-pY.mjs → link-c0_aLWQ3.mjs} +87 -120
- package/dist/load-config-xMf2wxH8.mjs +141 -0
- package/dist/loaders/zenbu.d.mts +17 -0
- package/dist/loaders/zenbu.mjs +144 -135
- package/dist/{monorepo-CQeQBIpa.mjs → monorepo-3avKJwzJ.mjs} +5 -2
- package/dist/node-loader.mjs +1 -1
- package/dist/{publish-source-BJdpDAFH.mjs → publish-source-Dill72NS.mjs} +12 -6
- package/dist/react.d.mts +3 -3
- package/dist/react.mjs +2 -2
- package/dist/{registry-Dh_e7HU1.d.mts → registry-eX6e2oql.d.mts} +1 -1
- package/dist/registry.d.mts +1 -1
- package/dist/{reloader-lLAJ3lqg.mjs → reloader-DzEO8kJr.mjs} +6 -4
- package/dist/{renderer-host-Bg8QdeeH.mjs → renderer-host-Cau9JK0v.mjs} +90 -212
- package/dist/{rpc-BwwQK6hD.mjs → rpc-JfGv-Wuw.mjs} +7 -5
- package/dist/rpc.d.mts +1 -1
- package/dist/rpc.mjs +1 -1
- package/dist/{runtime-CjqDr8Yf.d.mts → runtime-pCeVzj--.d.mts} +73 -1
- package/dist/runtime.d.mts +2 -2
- package/dist/runtime.mjs +522 -2
- package/dist/{schema-DMoSkwUx.d.mts → schema-Dl85YjXW.d.mts} +1 -1
- package/dist/schema.d.mts +1 -1
- package/dist/schema.mjs +27 -1
- package/dist/{server-BXwZEQ-n.mjs → server-y3PPbh3l.mjs} +5 -3
- package/dist/services/default.mjs +10 -10
- package/dist/services/index.d.mts +8 -4
- package/dist/services/index.mjs +6 -6
- package/dist/setup-gate.d.mts +1 -1
- package/dist/setup-gate.mjs +248 -1
- package/dist/{transform-DJH3vN4b.mjs → transform-CmFYPmt8.mjs} +1 -1
- package/dist/transforms-CuTODvDx.d.mts +145 -0
- package/dist/transforms-htxfTwsY.mjs +47 -0
- package/dist/{transport-BMSzG2-F.mjs → transport-F2hv_OEm.mjs} +1 -1
- package/dist/{vite-plugins-Bh3SCOw-.mjs → vite-plugins-Do7liKi_.mjs} +5 -19
- package/dist/vite.mjs +1 -1
- package/dist/{window-CmmpCVX6.mjs → window-o2NGUsIb.mjs} +10 -7
- package/dist/{write-9dRFczGJ.mjs → write-DgIRjo23.mjs} +1 -1
- package/package.json +11 -10
- package/dist/advice-config-Cy133IQP.mjs +0 -2
- package/dist/base-window-DEIAk618.mjs +0 -2
- package/dist/chunk-Dm34NbLt.mjs +0 -6
- package/dist/config-LK73dJmO.mjs +0 -2
- package/dist/db-ByKPbnP6.mjs +0 -2
- package/dist/env-bootstrap-rj7I-59x.mjs +0 -53
- package/dist/http-IBcLzbYu.mjs +0 -2
- package/dist/load-build-config-DozuRhAN.mjs +0 -40
- package/dist/reloader-BCkLjDhS.mjs +0 -2
- package/dist/renderer-host-DpvBPTHJ.mjs +0 -2
- package/dist/rpc-CqitnyR4.mjs +0 -2
- package/dist/runtime-DUFKDIe4.mjs +0 -409
- package/dist/schema-dGK6qkfR.mjs +0 -28
- package/dist/server-DjrZUbbu.mjs +0 -2
- package/dist/setup-gate-BcoqWu8S.mjs +0 -110
- package/dist/view-registry-BualWgAf.mjs +0 -2
- package/dist/window-CM2a9Kyc.mjs +0 -2
- package/dist/{index-FtE8MXJ_.d.mts → cli/resolve-config.d.mts} +0 -0
- package/dist/{dev-BU_llQh1.mjs → dev-Dazhu66l.mjs} +0 -0
- package/dist/{env-bootstrap-BtVME-CU.d.mts → env-bootstrap-DW2hVhSO.d.mts} +0 -0
- package/dist/{index-Bhlbyrn7.d.mts → index-C-ALz_SH.d.mts} +0 -0
- package/dist/{index-CPZ5d6Hl.d.mts → index-M_lSNBrq.d.mts} +0 -0
- package/dist/{log-CyKv8hQg.mjs → log-6rzaCV0I.mjs} +0 -0
- package/dist/{mirror-sync-BN59kMCG.mjs → mirror-sync-PDzxhf1w.mjs} +1 -1
- /package/dist/{node-D4M19_mV.mjs → node-_8xShqxr.mjs} +0 -0
- /package/dist/{schema-CIg4GzHQ.mjs → schema-Ca7SxXgS.mjs} +0 -0
- /package/dist/{setup-gate-BqOzm7zp.d.mts → setup-gate-Dcy8gGPJ.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
package/dist/loaders/zenbu.mjs
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
1
|
import fs from "node:fs";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
import { execFileSync } from "node:child_process";
|
|
5
5
|
//#region src/loaders/zenbu.ts
|
|
6
6
|
const verbose = process.env.ZENBU_VERBOSE === "1";
|
|
7
|
-
const { subscribe } = createRequire(import.meta.url)("@parcel/watcher");
|
|
8
|
-
let registerWatcherClosable = () => {};
|
|
9
|
-
try {
|
|
10
|
-
const pause = await import("@zenbujs/hmr/pause");
|
|
11
|
-
registerWatcherClosable = typeof pause.registerWatcherClosable === "function" ? pause.registerWatcherClosable : registerWatcherClosable;
|
|
12
|
-
} catch {}
|
|
13
7
|
const loaderName = "zenbu-loader";
|
|
14
8
|
let tracePort = null;
|
|
15
9
|
const stats = {
|
|
@@ -18,50 +12,34 @@ const stats = {
|
|
|
18
12
|
loadCount: 0,
|
|
19
13
|
loadMs: 0
|
|
20
14
|
};
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
let resolvedPayload = null;
|
|
16
|
+
let resolvedPluginSourceFiles = [];
|
|
17
|
+
/**
|
|
18
|
+
* Number of times we've materialized the plugin root since boot.
|
|
19
|
+
*/
|
|
20
|
+
let pluginsRootInvocations = 0;
|
|
23
21
|
function initialize(data) {
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
while (i < str.length) if (str[i] === "\"") {
|
|
45
|
-
let j = i + 1;
|
|
46
|
-
while (j < str.length) if (str[j] === "\\") j += 2;
|
|
47
|
-
else if (str[j] === "\"") {
|
|
48
|
-
j++;
|
|
49
|
-
break;
|
|
50
|
-
} else j++;
|
|
51
|
-
result += str.slice(i, j);
|
|
52
|
-
i = j;
|
|
53
|
-
} else if (str[i] === "/" && str[i + 1] === "/") {
|
|
54
|
-
i += 2;
|
|
55
|
-
while (i < str.length && str[i] !== "\n") i++;
|
|
56
|
-
} else if (str[i] === "/" && str[i + 1] === "*") {
|
|
57
|
-
i += 2;
|
|
58
|
-
while (i < str.length && !(str[i] === "*" && str[i + 1] === "/")) i++;
|
|
59
|
-
i += 2;
|
|
60
|
-
} else {
|
|
61
|
-
result += str[i];
|
|
62
|
-
i++;
|
|
22
|
+
if (data?.payload) {
|
|
23
|
+
resolvedPayload = data.payload;
|
|
24
|
+
resolvedPluginSourceFiles = data.pluginSourceFiles ?? [];
|
|
25
|
+
}
|
|
26
|
+
if (data?.tracePort) {
|
|
27
|
+
tracePort = data.tracePort;
|
|
28
|
+
tracePort.on("message", (msg) => {
|
|
29
|
+
if (msg !== "flush") return;
|
|
30
|
+
try {
|
|
31
|
+
tracePort?.postMessage({
|
|
32
|
+
name: loaderName,
|
|
33
|
+
...stats
|
|
34
|
+
});
|
|
35
|
+
} catch {}
|
|
36
|
+
stats.resolveCount = 0;
|
|
37
|
+
stats.resolveMs = 0;
|
|
38
|
+
stats.loadCount = 0;
|
|
39
|
+
stats.loadMs = 0;
|
|
40
|
+
});
|
|
41
|
+
tracePort.unref?.();
|
|
63
42
|
}
|
|
64
|
-
return JSON.parse(result.replace(/,\s*([\]}])/g, "$1"));
|
|
65
43
|
}
|
|
66
44
|
function globRegex(filePattern) {
|
|
67
45
|
return new RegExp(`^${filePattern.replace(/\./g, "\\.").replace(/\*/g, ".*")}$`);
|
|
@@ -72,94 +50,105 @@ function expandGlob(pattern) {
|
|
|
72
50
|
if (!fs.existsSync(dir)) return [];
|
|
73
51
|
return fs.readdirSync(dir).filter((file) => regex.test(file)).map((file) => path.resolve(dir, file));
|
|
74
52
|
}
|
|
75
|
-
function snapshotDir(dir, regex) {
|
|
76
|
-
if (!fs.existsSync(dir)) return /* @__PURE__ */ new Set();
|
|
77
|
-
try {
|
|
78
|
-
return new Set(fs.readdirSync(dir).filter((file) => regex.test(file)));
|
|
79
|
-
} catch {
|
|
80
|
-
return /* @__PURE__ */ new Set();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function handleDirEvent(dir, filename) {
|
|
84
|
-
for (const entry of barrels.values()) for (const glob of entry.globs) {
|
|
85
|
-
if (glob.dir !== dir) continue;
|
|
86
|
-
if (!glob.regex.test(filename)) continue;
|
|
87
|
-
const nextSnapshot = snapshotDir(dir, glob.regex);
|
|
88
|
-
if (!(nextSnapshot.size !== glob.snapshot.size || [...nextSnapshot].some((file) => !glob.snapshot.has(file)))) continue;
|
|
89
|
-
glob.snapshot = nextSnapshot;
|
|
90
|
-
try {
|
|
91
|
-
entry.hot?.invalidate?.();
|
|
92
|
-
if (verbose) console.log(`[zenbu-loader] invalidated barrel (${filename} added/removed in ${dir})`);
|
|
93
|
-
} catch (err) {
|
|
94
|
-
console.error("[zenbu-loader] invalidate failed:", err);
|
|
95
|
-
}
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function ensureDirWatcher(dir) {
|
|
100
|
-
if (dirWatchers.has(dir)) return;
|
|
101
|
-
if (!fs.existsSync(dir)) return;
|
|
102
|
-
let subscription = null;
|
|
103
|
-
let closed = false;
|
|
104
|
-
subscribe(dir, (err, events) => {
|
|
105
|
-
if (err) return;
|
|
106
|
-
for (const event of events) {
|
|
107
|
-
if (path.dirname(event.path) !== dir) continue;
|
|
108
|
-
handleDirEvent(dir, path.basename(event.path));
|
|
109
|
-
}
|
|
110
|
-
}).then((sub) => {
|
|
111
|
-
if (closed) sub.unsubscribe().catch(() => {});
|
|
112
|
-
else subscription = sub;
|
|
113
|
-
}).catch((err) => {
|
|
114
|
-
console.error(`[zenbu-loader] subscribe failed for ${dir}:`, err);
|
|
115
|
-
});
|
|
116
|
-
const closable = { close: () => {
|
|
117
|
-
closed = true;
|
|
118
|
-
if (subscription) return subscription.unsubscribe().catch(() => {});
|
|
119
|
-
} };
|
|
120
|
-
registerWatcherClosable(closable);
|
|
121
|
-
dirWatchers.set(dir, closable);
|
|
122
|
-
}
|
|
123
53
|
function buildSource(imports) {
|
|
124
54
|
return imports.map((specifier) => `import ${JSON.stringify(specifier)}\n`).join("");
|
|
125
55
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Read the resolved config from the process global. setup-gate populates
|
|
58
|
+
* this before registering our loader, so by the time `load()` is invoked
|
|
59
|
+
* the snapshot is always present.
|
|
60
|
+
*
|
|
61
|
+
* We can't `await import("zenbu.config.ts")` from inside `load()` because
|
|
62
|
+
* Node's ESM loader serializes load hooks — a dynamic import re-enters the
|
|
63
|
+
* loader chain and deadlocks. Pre-resolving in setup-gate sidesteps that.
|
|
64
|
+
*/
|
|
65
|
+
function resolveConfigViaSubprocess(projectDir) {
|
|
66
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
67
|
+
const candidates = [path.resolve(here, "..", "cli", "resolve-config.mjs"), path.resolve(here, "..", "..", "dist", "cli", "resolve-config.mjs")];
|
|
68
|
+
const resolverScript = candidates.find((c) => fs.existsSync(c));
|
|
69
|
+
if (!resolverScript) throw new Error(`[zenbu-loader] resolve-config.mjs not found (looked in: ${candidates.join(", ")})`);
|
|
70
|
+
/**
|
|
71
|
+
* this takes ~100ms and can be heavily optimized, but its a fine solution for now
|
|
72
|
+
*/
|
|
73
|
+
const env = {
|
|
74
|
+
...process.env,
|
|
75
|
+
ELECTRON_RUN_AS_NODE: "1"
|
|
76
|
+
};
|
|
77
|
+
const out = execFileSync(process.execPath, [resolverScript, projectDir], {
|
|
78
|
+
encoding: "utf8",
|
|
79
|
+
timeout: 1e3,
|
|
80
|
+
env,
|
|
81
|
+
stdio: [
|
|
82
|
+
"ignore",
|
|
83
|
+
"pipe",
|
|
84
|
+
"inherit"
|
|
85
|
+
]
|
|
86
|
+
});
|
|
87
|
+
return JSON.parse(out);
|
|
88
|
+
}
|
|
89
|
+
function getResolvedConfig(configPath) {
|
|
90
|
+
if (pluginsRootInvocations === 0) {
|
|
91
|
+
pluginsRootInvocations += 1;
|
|
92
|
+
if (!resolvedPayload) throw new Error("[zenbu-loader] zenbu config not resolved before loader registration. setup-gate must pass it via register(specifier, { data: { payload, pluginSourceFiles } }).");
|
|
93
|
+
return {
|
|
94
|
+
payload: resolvedPayload,
|
|
95
|
+
pluginSourceFiles: resolvedPluginSourceFiles
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
pluginsRootInvocations += 1;
|
|
99
|
+
const fresh = resolveConfigViaSubprocess(path.dirname(configPath));
|
|
100
|
+
resolvedPayload = fresh.payload;
|
|
101
|
+
resolvedPluginSourceFiles = fresh.pluginSourceFiles;
|
|
102
|
+
return fresh;
|
|
130
103
|
}
|
|
131
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Generate the top-level plugins barrel. The first import is the registry
|
|
106
|
+
* setup module; ESM evaluates left-to-right in import order, so by the time
|
|
107
|
+
* the plugin barrels start importing service files, `replacePlugins(...)` and
|
|
108
|
+
* `registerAppEntrypoint(...)` have already populated the runtime registry.
|
|
109
|
+
*/
|
|
110
|
+
function buildPluginsRoot(payload) {
|
|
111
|
+
const registryUrl = `zenbu:registry?data=${encodeURIComponent(JSON.stringify(payload))}`;
|
|
112
|
+
const barrelUrls = payload.plugins.map((p) => `zenbu:barrel?plugin=${encodeURIComponent(JSON.stringify(p))}`);
|
|
132
113
|
return {
|
|
133
|
-
source: `${buildSource(
|
|
134
|
-
|
|
114
|
+
source: `${buildSource([registryUrl, ...barrelUrls])}import.meta.hot?.accept()\n`,
|
|
115
|
+
barrelUrls
|
|
135
116
|
};
|
|
136
117
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Generate the registry-setup module body. Side-effect only — no exports.
|
|
120
|
+
* Imported FIRST by the plugins root so its `replacePlugins` /
|
|
121
|
+
* `registerAppEntrypoint` calls run before any plugin's service files
|
|
122
|
+
* evaluate.
|
|
123
|
+
*/
|
|
124
|
+
function buildRegistryModule(payload) {
|
|
125
|
+
return [
|
|
126
|
+
"import { replacePlugins, registerAppEntrypoint } from \"@zenbujs/core/runtime\"",
|
|
127
|
+
`replacePlugins(${JSON.stringify(payload.plugins)})`,
|
|
128
|
+
`registerAppEntrypoint(${JSON.stringify(payload.appEntrypoint)}, ${JSON.stringify(payload.splashPath)})`,
|
|
129
|
+
"import.meta.hot?.accept()"
|
|
130
|
+
].join("\n") + "\n";
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Generate a per-plugin barrel: just service-file imports anchored at the
|
|
134
|
+
* plugin's `dir`. Glob-form entries get expanded via `fs.readdirSync` and
|
|
135
|
+
* glob directories are registered with `context.hot.watch()` so dynohot
|
|
136
|
+
* reloads the generated barrel when service files are added/removed.
|
|
137
|
+
*/
|
|
138
|
+
function buildPluginBarrel(plugin) {
|
|
141
139
|
const imports = [];
|
|
142
|
-
const watchPaths = new Set([
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
const resolved = path.resolve(baseDir, entry);
|
|
140
|
+
const watchPaths = new Set([plugin.dir]);
|
|
141
|
+
for (const entry of plugin.services) {
|
|
142
|
+
const resolved = path.isAbsolute(entry) ? entry : path.resolve(plugin.dir, entry);
|
|
146
143
|
if (resolved.includes("*")) {
|
|
147
144
|
const dir = path.dirname(resolved);
|
|
148
|
-
const regex = globRegex(path.basename(resolved));
|
|
149
145
|
watchPaths.add(dir);
|
|
150
|
-
globs.push({
|
|
151
|
-
dir,
|
|
152
|
-
regex,
|
|
153
|
-
snapshot: snapshotDir(dir, regex)
|
|
154
|
-
});
|
|
155
146
|
for (const file of expandGlob(resolved)) imports.push(pathToFileURL(file).href);
|
|
156
|
-
} else
|
|
157
|
-
else imports.push(pathToFileURL(resolved).href);
|
|
147
|
+
} else imports.push(pathToFileURL(resolved).href);
|
|
158
148
|
}
|
|
159
149
|
return {
|
|
160
150
|
source: `${buildSource(imports)}import.meta.hot?.accept()\n`,
|
|
161
|
-
watchPaths
|
|
162
|
-
globs
|
|
151
|
+
watchPaths
|
|
163
152
|
};
|
|
164
153
|
}
|
|
165
154
|
const CORE_PACKAGE_ROOT_FOR_LOADER = (() => {
|
|
@@ -224,9 +213,30 @@ function loadImpl(url, context, nextLoad) {
|
|
|
224
213
|
if (url.startsWith("zenbu:plugins?")) {
|
|
225
214
|
const params = new URL(url).searchParams;
|
|
226
215
|
const configPath = decodeURIComponent(params.get("config") ?? "");
|
|
227
|
-
const {
|
|
228
|
-
|
|
229
|
-
if (
|
|
216
|
+
const { payload, pluginSourceFiles } = getResolvedConfig(configPath);
|
|
217
|
+
const { source, barrelUrls } = buildPluginsRoot(payload);
|
|
218
|
+
if (context.hot?.watch) {
|
|
219
|
+
context.hot.watch(pathToFileURL(configPath));
|
|
220
|
+
for (const file of pluginSourceFiles) context.hot.watch(pathToFileURL(file));
|
|
221
|
+
}
|
|
222
|
+
if (verbose) console.log(`[zenbu-loader] generated plugin root for ${path.basename(configPath)} (${payload.plugins.length} plugins, ${barrelUrls.length} barrels)`);
|
|
223
|
+
return {
|
|
224
|
+
format: "module",
|
|
225
|
+
source,
|
|
226
|
+
shortCircuit: true
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
if (url.startsWith("zenbu:registry?")) {
|
|
230
|
+
const params = new URL(url).searchParams;
|
|
231
|
+
const data = decodeURIComponent(params.get("data") ?? "");
|
|
232
|
+
let payload;
|
|
233
|
+
try {
|
|
234
|
+
payload = JSON.parse(data);
|
|
235
|
+
} catch (err) {
|
|
236
|
+
throw new Error(`[zenbu-loader] bad registry payload: ${err.message}`);
|
|
237
|
+
}
|
|
238
|
+
const source = buildRegistryModule(payload);
|
|
239
|
+
if (verbose) console.log(`[zenbu-loader] emitted registry module (${payload.plugins.length} plugins, entrypoint=${path.basename(payload.appEntrypoint)})`);
|
|
230
240
|
return {
|
|
231
241
|
format: "module",
|
|
232
242
|
source,
|
|
@@ -235,17 +245,16 @@ function loadImpl(url, context, nextLoad) {
|
|
|
235
245
|
}
|
|
236
246
|
if (url.startsWith("zenbu:barrel?")) {
|
|
237
247
|
const params = new URL(url).searchParams;
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
globs
|
|
245
|
-
});
|
|
246
|
-
for (const glob of globs) ensureDirWatcher(glob.dir);
|
|
248
|
+
const pluginRaw = decodeURIComponent(params.get("plugin") ?? "");
|
|
249
|
+
let plugin;
|
|
250
|
+
try {
|
|
251
|
+
plugin = JSON.parse(pluginRaw);
|
|
252
|
+
} catch (err) {
|
|
253
|
+
throw new Error(`[zenbu-loader] bad plugin payload: ${err.message}`);
|
|
247
254
|
}
|
|
248
|
-
|
|
255
|
+
const { source, watchPaths } = buildPluginBarrel(plugin);
|
|
256
|
+
if (context.hot?.watch) for (const watchPath of watchPaths) context.hot.watch(pathToFileURL(watchPath));
|
|
257
|
+
if (verbose) console.log(`[zenbu-loader] generated barrel for plugin ${plugin.name} (${source.split("\n").filter(Boolean).length} imports, ${watchPaths.size} watches)`);
|
|
249
258
|
return {
|
|
250
259
|
format: "module",
|
|
251
260
|
source,
|
|
@@ -3,12 +3,15 @@ import os from "node:os";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { execFileSync } from "node:child_process";
|
|
5
5
|
//#region src/cli/commands/monorepo.ts
|
|
6
|
+
/**
|
|
7
|
+
* todo: should only be exposed when an env var is passed
|
|
8
|
+
*/
|
|
6
9
|
const MARKER_FILE = ".zenbu-dev-link";
|
|
7
10
|
const DEFAULT_MONOREPO = path.join(os.homedir(), ".zenbu", "plugins", "zenbu");
|
|
8
11
|
function resolveProjectDir() {
|
|
9
12
|
const cwd = process.cwd();
|
|
10
|
-
if (fs.existsSync(path.join(cwd, "zenbu.
|
|
11
|
-
console.error("zen monorepo: not in a zenbu project (no zenbu.
|
|
13
|
+
if (fs.existsSync(path.join(cwd, "zenbu.config.ts")) || fs.existsSync(path.join(cwd, "zenbu")) || fs.existsSync(path.join(cwd, MARKER_FILE))) return cwd;
|
|
14
|
+
console.error("zen monorepo: not in a zenbu project (no zenbu.config.ts or zenbu/ found)");
|
|
12
15
|
process.exit(1);
|
|
13
16
|
}
|
|
14
17
|
function resolveMonorepoPath(explicit) {
|
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-CmFYPmt8.mjs";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
//#region ../advice/src/node-loader.ts
|
|
4
4
|
var import_lib = require_lib();
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as init, r as push } from "./mirror-sync-
|
|
1
|
+
import { t as loadConfig } from "./load-config-xMf2wxH8.mjs";
|
|
2
|
+
import { n as init, r as push } from "./mirror-sync-PDzxhf1w.mjs";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import fsp from "node:fs/promises";
|
|
6
5
|
import { execFileSync } from "node:child_process";
|
|
6
|
+
import fsp from "node:fs/promises";
|
|
7
7
|
//#region src/cli/commands/publish-source.ts
|
|
8
8
|
function resolveProjectDir() {
|
|
9
9
|
const cwd = process.cwd();
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
for (const name of [
|
|
11
|
+
"zenbu.config.ts",
|
|
12
|
+
"zenbu.config.mts",
|
|
13
|
+
"zenbu.config.js",
|
|
14
|
+
"zenbu.config.mjs"
|
|
15
|
+
]) if (fs.existsSync(path.join(cwd, name))) return cwd;
|
|
16
|
+
console.error("zen publish:source: no zenbu.config.ts found in current directory");
|
|
12
17
|
process.exit(1);
|
|
13
18
|
}
|
|
14
19
|
function currentSourceSha(projectDir) {
|
|
@@ -85,7 +90,8 @@ function logResult(action, result, mirrorUrl) {
|
|
|
85
90
|
async function runPublishSource(argv) {
|
|
86
91
|
const projectDir = resolveProjectDir();
|
|
87
92
|
const flags = parseFlags(argv);
|
|
88
|
-
const
|
|
93
|
+
const { resolved } = await loadConfig(projectDir);
|
|
94
|
+
const config = resolved.build;
|
|
89
95
|
const target = flags.target ?? config.mirror?.target;
|
|
90
96
|
if (!target) {
|
|
91
97
|
console.error("zen publish:source: no mirror target specified (config.mirror.target or --target)");
|
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-
|
|
2
|
-
import { c as ResolvedServiceRouter, l as ZenbuRegister, o as ResolvedDbRoot, s as ResolvedEvents } from "./registry-
|
|
3
|
-
import { n as EventProxy, r as RouterProxy } from "./index-
|
|
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-M_lSNBrq.mjs";
|
|
2
|
+
import { c as ResolvedServiceRouter, l as ZenbuRegister, o as ResolvedDbRoot, s as ResolvedEvents } from "./registry-eX6e2oql.mjs";
|
|
3
|
+
import { n as EventProxy, r as RouterProxy } from "./index-C-ALz_SH.mjs";
|
|
4
4
|
import * as _$react from "react";
|
|
5
5
|
import { ReactNode } from "react";
|
|
6
6
|
|
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-F2hv_OEm.mjs";
|
|
2
|
+
import { t as connectRpc } from "./src-Cven45mq.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() {
|
package/dist/registry.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as Events, c as ResolvedServiceRouter, i as CoreServiceRouter, l as ZenbuRegister, n as CoreEvents, o as ResolvedDbRoot, r as CorePreloads, s as ResolvedEvents, t as CoreDbSections } from "./registry-
|
|
1
|
+
import { a as Events, c as ResolvedServiceRouter, i as CoreServiceRouter, l as ZenbuRegister, n as CoreEvents, o as ResolvedDbRoot, r as CorePreloads, s as ResolvedEvents, t as CoreDbSections } from "./registry-eX6e2oql.mjs";
|
|
2
2
|
export { CoreDbSections, CoreEvents, CorePreloads, CoreServiceRouter, Events, ResolvedDbRoot, ResolvedEvents, ResolvedServiceRouter, ZenbuRegister };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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-Do7liKi_.mjs";
|
|
4
5
|
import os from "node:os";
|
|
5
6
|
import path, { resolve } from "node:path";
|
|
6
7
|
import { createHash } from "node:crypto";
|
|
@@ -15,6 +16,7 @@ const DB_CONFIG_JSON = path.join(INTERNAL_DIR, "db.json");
|
|
|
15
16
|
path.join(INTERNAL_DIR, "plugin-setup-state.json");
|
|
16
17
|
//#endregion
|
|
17
18
|
//#region src/services/reloader.ts
|
|
19
|
+
var reloader_exports = /* @__PURE__ */ __exportAll({ ReloaderService: () => ReloaderService });
|
|
18
20
|
const log = createLogger("reloader");
|
|
19
21
|
function safeCacheSegment(value) {
|
|
20
22
|
return value.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64) || "renderer";
|
|
@@ -161,4 +163,4 @@ var ReloaderService = class extends Service {
|
|
|
161
163
|
};
|
|
162
164
|
runtime.register(ReloaderService, import.meta);
|
|
163
165
|
//#endregion
|
|
164
|
-
export {
|
|
166
|
+
export { INTERNAL_DIR as i, reloader_exports as n, DB_CONFIG_JSON as r, ReloaderService as t };
|