@zenbujs/core 0.0.2 → 0.0.4
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/LICENSE +11 -0
- package/dist/{advice-config-CjgkEf2E.mjs → advice-config-BLXjqjGN.mjs} +21 -13
- package/dist/advice-config-D6K_a7e9.mjs +2 -0
- package/dist/advice.mjs +1 -1
- package/dist/{base-window-BUt8pwbw.mjs → base-window-D8CpxMU3.mjs} +2 -2
- package/dist/base-window-OXg2KSyP.mjs +2 -0
- package/dist/{build-config-pbv0w4oN.mjs → build-config-BwnnfrN-.mjs} +8 -2
- package/dist/{build-electron-BzHa_hRi.mjs → build-electron-C3Beey84.mjs} +12 -6
- package/dist/{build-source-CnTfQBGK.mjs → build-source-BvC4bPqH.mjs} +13 -8
- 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 +36 -0
- package/dist/{cli-BLbQQIVB.mjs → cli-F0B4dvSg.mjs} +3 -3
- package/dist/config-Ch1FreWU.mjs +2 -0
- package/dist/config.d.mts +2 -0
- package/dist/config.mjs +3 -0
- package/dist/db-Bz_CDIWg.mjs +2 -0
- package/dist/{db-BXadETOb.mjs → db-Cd5ETuPG.mjs} +47 -41
- package/dist/db.d.mts +1 -1
- package/dist/env-bootstrap.d.mts +1 -1
- package/dist/http-B36qtsm0.mjs +2 -0
- package/dist/index-CKKoxA9V.d.mts +1 -0
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +2 -2
- package/dist/{link-VOoGs-pY.mjs → link-BJmsKgPa.mjs} +87 -120
- package/dist/load-config-BG2tPIfF.mjs +126 -0
- package/dist/load-config-CQG4297M.mjs +2 -0
- package/dist/loaders/zenbu.d.mts +16 -0
- package/dist/loaders/zenbu.mjs +151 -62
- package/dist/{monorepo-CQeQBIpa.mjs → monorepo-DCruz9Jx.mjs} +2 -2
- package/dist/{publish-source-BJdpDAFH.mjs → publish-source-34Hn9zb0.mjs} +12 -6
- package/dist/react.d.mts +3 -3
- package/dist/{registry-Dh_e7HU1.d.mts → registry-CioEYLI5.d.mts} +1 -1
- package/dist/registry.d.mts +1 -1
- package/dist/{reloader-lLAJ3lqg.mjs → reloader-DJoCB0bC.mjs} +2 -2
- package/dist/reloader-FeHKV2jd.mjs +2 -0
- package/dist/renderer-host-BQpS0ZM2.mjs +2 -0
- package/dist/{renderer-host-Bg8QdeeH.mjs → renderer-host-ztaSIOGx.mjs} +71 -205
- package/dist/{rpc-BwwQK6hD.mjs → rpc-CsgWnlZx.mjs} +2 -2
- package/dist/rpc-D_s7-WZe.mjs +2 -0
- package/dist/rpc.d.mts +1 -1
- package/dist/{runtime-DUFKDIe4.mjs → runtime-C95iyVn6.mjs} +53 -1
- package/dist/{runtime-CjqDr8Yf.d.mts → runtime-CsiDppGF.d.mts} +41 -1
- package/dist/runtime.d.mts +2 -2
- package/dist/runtime.mjs +2 -2
- package/dist/{schema-DMoSkwUx.d.mts → schema-DvT61x2_.d.mts} +1 -1
- package/dist/schema.d.mts +1 -1
- package/dist/server-CgzQOPSW.mjs +2 -0
- package/dist/{server-BXwZEQ-n.mjs → server-DB3Eki_G.mjs} +1 -1
- package/dist/services/default.mjs +10 -10
- package/dist/services/index.d.mts +3 -3
- package/dist/services/index.mjs +6 -6
- package/dist/{setup-gate-BcoqWu8S.mjs → setup-gate-D8XfYY52.mjs} +35 -5
- package/dist/setup-gate.d.mts +1 -1
- package/dist/setup-gate.mjs +1 -1
- package/dist/transforms-DVoy8dCu.mjs +47 -0
- package/dist/transforms-EVd5Fgyk.d.mts +136 -0
- package/dist/view-registry-2zePxTEg.mjs +2 -0
- package/dist/{vite-plugins-Bh3SCOw-.mjs → vite-plugins-t4MlFcz3.mjs} +4 -18
- package/dist/vite.mjs +1 -1
- package/dist/{window-CmmpCVX6.mjs → window-DUvMTons.mjs} +3 -3
- package/dist/window-S3TlTXlK.mjs +2 -0
- package/package.json +19 -18
- package/dist/advice-config-Cy133IQP.mjs +0 -2
- package/dist/base-window-DEIAk618.mjs +0 -2
- package/dist/config-LK73dJmO.mjs +0 -2
- package/dist/db-ByKPbnP6.mjs +0 -2
- 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/server-DjrZUbbu.mjs +0 -2
- 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/{config-CdVrW85P.mjs → config-BlRXeUXx.mjs} +0 -0
- package/dist/{dev-BU_llQh1.mjs → dev-DLutFPyo.mjs} +0 -0
- package/dist/{env-bootstrap-BtVME-CU.d.mts → env-bootstrap-uCKbw2q8.d.mts} +0 -0
- package/dist/{index-Bhlbyrn7.d.mts → index-CE0iPntP.d.mts} +0 -0
- package/dist/{index-CPZ5d6Hl.d.mts → index-UK58xuoR.d.mts} +0 -0
- package/dist/{mirror-sync-BN59kMCG.mjs → mirror-sync-EiWvdzTJ.mjs} +1 -1
- /package/dist/{node-D4M19_mV.mjs → node-CvZnTx53.mjs} +0 -0
- /package/dist/{setup-gate-BqOzm7zp.d.mts → setup-gate-D62nX5lk.d.mts} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
All Rights Reserved
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zenbu Labs Inc.
|
|
4
|
+
|
|
5
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
6
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
7
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
8
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
9
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
10
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
11
|
+
THE SOFTWARE.
|
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import fs from "node:fs";
|
|
1
|
+
import { a as getPlugins, u as runtime } from "./runtime-C95iyVn6.mjs";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import { fileURLToPath } from "node:url";
|
|
5
4
|
//#region src/services/advice-config.ts
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* Find the plugin whose `dir` contains the file at `metaUrl`. The runtime
|
|
7
|
+
* plugin registry (populated by the loader-emitted barrel) is the source
|
|
8
|
+
* of truth; this no longer walks the filesystem looking for
|
|
9
|
+
* `zenbu.plugin.json`. Returns the plugin's dir, used as the anchor for
|
|
10
|
+
* `registerContentScript` / `registerAdvice` relative-path resolution.
|
|
10
11
|
*
|
|
11
|
-
* Throws
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* Throws if no plugin matches, because a silent fallback to `process.cwd()`
|
|
13
|
+
* would attach a content script to a nonsensical location and you'd debug
|
|
14
|
+
* it by staring at empty iframes.
|
|
14
15
|
*/
|
|
15
16
|
function findPluginRoot(metaUrl) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const file = fileURLToPath(metaUrl);
|
|
18
|
+
let bestMatch = null;
|
|
19
|
+
for (const plugin of getPlugins()) {
|
|
20
|
+
const rel = path.relative(plugin.dir, file);
|
|
21
|
+
if (rel.startsWith("..") || path.isAbsolute(rel)) continue;
|
|
22
|
+
const depth = plugin.dir.split(path.sep).length;
|
|
23
|
+
if (!bestMatch || depth > bestMatch.depth) bestMatch = {
|
|
24
|
+
dir: plugin.dir,
|
|
25
|
+
depth
|
|
26
|
+
};
|
|
20
27
|
}
|
|
21
|
-
|
|
28
|
+
if (bestMatch) return bestMatch.dir;
|
|
29
|
+
throw new Error(`Could not find owning plugin for ${metaUrl}. Pass an absolute path, or call this from a file inside a Zenbu plugin.`);
|
|
22
30
|
}
|
|
23
31
|
/**
|
|
24
32
|
* Accepts either an absolute path (used as-is) or a path relative to the
|
package/dist/advice.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as getContentScripts, i as getAllScopes, n as getAllAdviceScopes, o as registerAdvice, r as getAllContentScriptPaths, s as registerContentScript, t as getAdvice } from "./advice-config-
|
|
1
|
+
import { a as getContentScripts, i as getAllScopes, n as getAllAdviceScopes, o as registerAdvice, r as getAllContentScriptPaths, s as registerContentScript, t as getAdvice } from "./advice-config-BLXjqjGN.mjs";
|
|
2
2
|
export { getAdvice, getAllAdviceScopes, getAllContentScriptPaths, getAllScopes, getContentScripts, registerAdvice, registerContentScript };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as Service, u as runtime } from "./runtime-C95iyVn6.mjs";
|
|
2
2
|
import { t as createLogger } from "./log-CyKv8hQg.mjs";
|
|
3
|
-
import { r as DbService } from "./renderer-host-
|
|
3
|
+
import { r as DbService } from "./renderer-host-ztaSIOGx.mjs";
|
|
4
4
|
import { nanoid } from "nanoid";
|
|
5
5
|
import { BaseWindow } from "electron";
|
|
6
6
|
//#region src/services/base-window.ts
|
|
@@ -5,7 +5,7 @@ function defineBuildConfig(config) {
|
|
|
5
5
|
function resolveBuildConfig(config) {
|
|
6
6
|
return {
|
|
7
7
|
source: config.source ?? ".",
|
|
8
|
-
out: config.out ?? ".zenbu/build/
|
|
8
|
+
out: config.out ?? ".zenbu/build/source",
|
|
9
9
|
include: config.include,
|
|
10
10
|
ignore: config.ignore ?? [],
|
|
11
11
|
transforms: config.transforms ?? [],
|
|
@@ -13,5 +13,11 @@ function resolveBuildConfig(config) {
|
|
|
13
13
|
bundle: config.bundle
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
+
function definePlugin(plugin) {
|
|
17
|
+
return plugin;
|
|
18
|
+
}
|
|
19
|
+
function defineConfig(config) {
|
|
20
|
+
return config;
|
|
21
|
+
}
|
|
16
22
|
//#endregion
|
|
17
|
-
export { resolveBuildConfig as n, defineBuildConfig as t };
|
|
23
|
+
export { resolveBuildConfig as i, defineConfig as n, definePlugin as r, defineBuildConfig as t };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { n as
|
|
1
|
+
import { n as loadConfig } from "./load-config-BG2tPIfF.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { execFile, execFileSync, spawn } from "node:child_process";
|
|
7
8
|
import crypto from "node:crypto";
|
|
8
9
|
import fsp from "node:fs/promises";
|
|
9
|
-
import { execFile, execFileSync, spawn } from "node:child_process";
|
|
10
10
|
import https from "node:https";
|
|
11
11
|
import { promisify } from "node:util";
|
|
12
12
|
//#region src/cli/lib/toolchain.ts
|
|
@@ -205,8 +205,13 @@ const ELECTRON_BUILDER_CONFIG_NAMES = [
|
|
|
205
205
|
];
|
|
206
206
|
function resolveProjectDir() {
|
|
207
207
|
const cwd = process.cwd();
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
for (const name of [
|
|
209
|
+
"zenbu.config.ts",
|
|
210
|
+
"zenbu.config.mts",
|
|
211
|
+
"zenbu.config.js",
|
|
212
|
+
"zenbu.config.mjs"
|
|
213
|
+
]) if (fs.existsSync(path.join(cwd, name))) return cwd;
|
|
214
|
+
console.error("zen build:electron: no zenbu.config.ts found in current directory");
|
|
210
215
|
process.exit(1);
|
|
211
216
|
}
|
|
212
217
|
/**
|
|
@@ -389,9 +394,10 @@ async function copyFile(src, dest) {
|
|
|
389
394
|
async function runBuildElectron(argv) {
|
|
390
395
|
const projectDir = resolveProjectDir();
|
|
391
396
|
const flags = parseFlags(argv);
|
|
392
|
-
const
|
|
397
|
+
const { resolved } = await loadConfig(projectDir);
|
|
398
|
+
const config = resolved.build;
|
|
393
399
|
const mirrorTarget = config.mirror?.target;
|
|
394
|
-
if (!mirrorTarget) throw new Error("zen build:electron: `mirror.target` is required in zenbu.
|
|
400
|
+
if (!mirrorTarget) throw new Error("zen build:electron: `build.mirror.target` is required in zenbu.config.ts. Set build: defineBuildConfig({ mirror: { target: \"<owner>/<repo>\", branch: \"main\" }, ... }) and run `zen publish:source init` before building.");
|
|
395
401
|
const mirrorBranch = config.mirror?.branch ?? "main";
|
|
396
402
|
const mirrorUrl = expandMirrorUrl(mirrorTarget);
|
|
397
403
|
const projectPkg = readJson(path.join(projectDir, "package.json"));
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { t as hashDir } from "./mirror-sync-
|
|
1
|
+
import { n as loadConfig } from "./load-config-BG2tPIfF.mjs";
|
|
2
|
+
import { t as hashDir } from "./mirror-sync-EiWvdzTJ.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/build-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 build:source: no zenbu.config.ts found in current directory");
|
|
12
17
|
process.exit(1);
|
|
13
18
|
}
|
|
14
19
|
function resolveSourceHead(projectDir) {
|
|
@@ -77,13 +82,13 @@ async function applyTransforms(input, transforms) {
|
|
|
77
82
|
async function runBuildSource(argv) {
|
|
78
83
|
const projectDir = resolveProjectDir();
|
|
79
84
|
const flags = parseFlags(argv);
|
|
80
|
-
const
|
|
81
|
-
const config =
|
|
85
|
+
const { resolved } = await loadConfig(projectDir);
|
|
86
|
+
const config = { ...resolved.build };
|
|
82
87
|
if (flags.out) config.out = flags.out;
|
|
83
88
|
const sourceDir = path.resolve(projectDir, config.source);
|
|
84
89
|
const outDir = path.resolve(projectDir, config.out);
|
|
85
90
|
console.log(`\n zen build:source`);
|
|
86
|
-
console.log(` config: ${path.relative(projectDir, configPath) || configPath}`);
|
|
91
|
+
console.log(` config: ${path.relative(projectDir, resolved.configPath) || resolved.configPath}`);
|
|
87
92
|
console.log(` source: ${path.relative(projectDir, sourceDir) || "."}`);
|
|
88
93
|
console.log(` out: ${path.relative(projectDir, outDir) || "."}`);
|
|
89
94
|
await fsp.rm(outDir, {
|
package/dist/cli/bin.mjs
CHANGED
|
@@ -14,19 +14,16 @@ zen — Zenbu CLI
|
|
|
14
14
|
|
|
15
15
|
Usage:
|
|
16
16
|
zen dev Run the local app in Electron with HMR
|
|
17
|
-
zen build:source Transform user TS into
|
|
18
|
-
tree (default: .zenbu/build/
|
|
19
|
-
zen build:electron [-- <eb args>] Stage
|
|
17
|
+
zen build:source Transform user TS into the staged
|
|
18
|
+
source tree (default: .zenbu/build/source)
|
|
19
|
+
zen build:electron [-- <eb args>] Stage launcher + bundled bun/pnpm,
|
|
20
20
|
then invoke electron-builder against
|
|
21
21
|
the project's electron-builder config.
|
|
22
22
|
Pass-through args after \`--\` go to
|
|
23
23
|
electron-builder (e.g. \`-- --publish always\`).
|
|
24
24
|
zen publish:source [init|push] Push staged source to the mirror repo
|
|
25
|
-
zen link Regenerate registry types
|
|
26
|
-
|
|
27
|
-
Hooks:
|
|
28
|
-
--config <zenbu.build.ts> Override the build config path
|
|
29
|
-
--no-source Skip running build:source (use stale seed)
|
|
25
|
+
zen link Regenerate registry types from
|
|
26
|
+
zenbu.config.ts
|
|
30
27
|
`);
|
|
31
28
|
}
|
|
32
29
|
async function main() {
|
|
@@ -44,37 +41,37 @@ async function main() {
|
|
|
44
41
|
const rest = argv.slice(1);
|
|
45
42
|
switch (first) {
|
|
46
43
|
case "dev": {
|
|
47
|
-
const { runDev } = await import("../dev-
|
|
44
|
+
const { runDev } = await import("../dev-DLutFPyo.mjs");
|
|
48
45
|
await runDev(rest);
|
|
49
46
|
return;
|
|
50
47
|
}
|
|
51
48
|
case "build:source": {
|
|
52
|
-
const { runBuildSource } = await import("../build-source-
|
|
49
|
+
const { runBuildSource } = await import("../build-source-BvC4bPqH.mjs");
|
|
53
50
|
await runBuildSource(rest);
|
|
54
51
|
return;
|
|
55
52
|
}
|
|
56
53
|
case "build:electron": {
|
|
57
|
-
const { runBuildElectron } = await import("../build-electron-
|
|
54
|
+
const { runBuildElectron } = await import("../build-electron-C3Beey84.mjs");
|
|
58
55
|
await runBuildElectron(rest);
|
|
59
56
|
return;
|
|
60
57
|
}
|
|
61
58
|
case "publish:source": {
|
|
62
|
-
const { runPublishSource } = await import("../publish-source-
|
|
59
|
+
const { runPublishSource } = await import("../publish-source-34Hn9zb0.mjs");
|
|
63
60
|
await runPublishSource(rest);
|
|
64
61
|
return;
|
|
65
62
|
}
|
|
66
63
|
case "link": {
|
|
67
|
-
const { runLink } = await import("../link-
|
|
64
|
+
const { runLink } = await import("../link-BJmsKgPa.mjs");
|
|
68
65
|
await runLink(rest);
|
|
69
66
|
return;
|
|
70
67
|
}
|
|
71
68
|
case "monorepo": {
|
|
72
|
-
const { runMonorepo } = await import("../monorepo-
|
|
69
|
+
const { runMonorepo } = await import("../monorepo-DCruz9Jx.mjs");
|
|
73
70
|
await runMonorepo(rest);
|
|
74
71
|
return;
|
|
75
72
|
}
|
|
76
73
|
case "db": {
|
|
77
|
-
const { runDb } = await import("../db-
|
|
74
|
+
const { runDb } = await import("../db-Cd5ETuPG.mjs");
|
|
78
75
|
await runDb(rest);
|
|
79
76
|
return;
|
|
80
77
|
}
|
package/dist/cli/build.d.mts
CHANGED
|
@@ -1,53 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
interface TransformInput {
|
|
3
|
-
path: string;
|
|
4
|
-
code: string;
|
|
5
|
-
}
|
|
6
|
-
interface TransformOutput {
|
|
7
|
-
code?: string;
|
|
8
|
-
drop?: boolean;
|
|
9
|
-
}
|
|
10
|
-
type Transform = (file: TransformInput) => TransformOutput | null | undefined | void;
|
|
11
|
-
interface MirrorConfig {
|
|
12
|
-
target: string;
|
|
13
|
-
branch?: string;
|
|
14
|
-
}
|
|
15
|
-
interface BundleConfig {
|
|
16
|
-
seed?: boolean;
|
|
17
|
-
extraResources?: string[];
|
|
18
|
-
}
|
|
19
|
-
interface BuildConfig {
|
|
20
|
-
source?: string;
|
|
21
|
-
out?: string;
|
|
22
|
-
include: string[];
|
|
23
|
-
ignore?: string[];
|
|
24
|
-
transforms?: Transform[];
|
|
25
|
-
mirror?: MirrorConfig;
|
|
26
|
-
bundle?: BundleConfig;
|
|
27
|
-
}
|
|
28
|
-
declare function defineBuildConfig(config: BuildConfig): BuildConfig;
|
|
29
|
-
type ResolvedBuildConfig = Required<Omit<BuildConfig, "mirror" | "bundle">> & {
|
|
30
|
-
mirror?: MirrorConfig;
|
|
31
|
-
bundle?: BundleConfig;
|
|
32
|
-
};
|
|
33
|
-
declare function resolveBuildConfig(config: BuildConfig): ResolvedBuildConfig;
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/cli/lib/transforms.d.ts
|
|
36
|
-
/**
|
|
37
|
-
* Marker-based feature-flag stripping. Removes lines between
|
|
38
|
-
* // @zenbu:strip-if FLAG (strip when FLAG is truthy)
|
|
39
|
-
* // @zenbu:strip-if !FLAG (strip when FLAG is falsy)
|
|
40
|
-
* ...
|
|
41
|
-
* // @zenbu:end
|
|
42
|
-
*
|
|
43
|
-
* Pure string/line ops — no AST, no compiler dep.
|
|
44
|
-
*/
|
|
45
|
-
declare function stripIfDisabled(flags: Record<string, boolean>): Transform;
|
|
46
|
-
/**
|
|
47
|
-
* Drop files whose path matches the given pattern (relative path from the
|
|
48
|
-
* source root, posix slashes). Also covered by `ignore` globs in the config;
|
|
49
|
-
* use this when a regex is more convenient than a glob.
|
|
50
|
-
*/
|
|
51
|
-
declare function dropFiles(pattern: RegExp | ((path: string) => boolean)): Transform;
|
|
52
|
-
//#endregion
|
|
1
|
+
import { _ as resolveBuildConfig, c as ResolvedBuildConfig, d as Transform, f as TransformInput, i as BundleConfig, m as defineBuildConfig, n as stripIfDisabled, o as MirrorConfig, p as TransformOutput, r as BuildConfig, t as dropFiles } from "../transforms-EVd5Fgyk.mjs";
|
|
53
2
|
export { type BuildConfig, type BundleConfig, type MirrorConfig, type ResolvedBuildConfig, type Transform, type TransformInput, type TransformOutput, defineBuildConfig, dropFiles, resolveBuildConfig, stripIfDisabled };
|
package/dist/cli/build.mjs
CHANGED
|
@@ -1,48 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const STRIP_START = /^\s*\/\/\s*@zenbu:strip-if\s+(!?)([A-Za-z_][A-Za-z0-9_]*)\s*$/;
|
|
4
|
-
const STRIP_END = /^\s*\/\/\s*@zenbu:end\s*$/;
|
|
5
|
-
/**
|
|
6
|
-
* Marker-based feature-flag stripping. Removes lines between
|
|
7
|
-
* // @zenbu:strip-if FLAG (strip when FLAG is truthy)
|
|
8
|
-
* // @zenbu:strip-if !FLAG (strip when FLAG is falsy)
|
|
9
|
-
* ...
|
|
10
|
-
* // @zenbu:end
|
|
11
|
-
*
|
|
12
|
-
* Pure string/line ops — no AST, no compiler dep.
|
|
13
|
-
*/
|
|
14
|
-
function stripIfDisabled(flags) {
|
|
15
|
-
return (file) => {
|
|
16
|
-
const lines = file.code.split("\n");
|
|
17
|
-
const out = [];
|
|
18
|
-
let stripDepth = 0;
|
|
19
|
-
for (const line of lines) {
|
|
20
|
-
const startMatch = STRIP_START.exec(line);
|
|
21
|
-
if (startMatch) {
|
|
22
|
-
const negated = startMatch[1] === "!";
|
|
23
|
-
const flagValue = flags[startMatch[2]] ?? false;
|
|
24
|
-
if ((negated ? !flagValue : flagValue) || stripDepth > 0) stripDepth += 1;
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
if (STRIP_END.test(line)) {
|
|
28
|
-
if (stripDepth > 0) stripDepth -= 1;
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
if (stripDepth === 0) out.push(line);
|
|
32
|
-
}
|
|
33
|
-
return { code: out.join("\n") };
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Drop files whose path matches the given pattern (relative path from the
|
|
38
|
-
* source root, posix slashes). Also covered by `ignore` globs in the config;
|
|
39
|
-
* use this when a regex is more convenient than a glob.
|
|
40
|
-
*/
|
|
41
|
-
function dropFiles(pattern) {
|
|
42
|
-
const test = typeof pattern === "function" ? pattern : (p) => pattern.test(p);
|
|
43
|
-
return (file) => {
|
|
44
|
-
if (test(file.path)) return { drop: true };
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
1
|
+
import { i as resolveBuildConfig, t as defineBuildConfig } from "../build-config-BwnnfrN-.mjs";
|
|
2
|
+
import { n as stripIfDisabled, t as dropFiles } from "../transforms-DVoy8dCu.mjs";
|
|
48
3
|
export { defineBuildConfig, dropFiles, resolveBuildConfig, stripIfDisabled };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { n as loadConfig } from "../load-config-BG2tPIfF.mjs";
|
|
3
|
+
import { register } from "tsx/esm/api";
|
|
4
|
+
//#region src/cli/resolve-config.ts
|
|
5
|
+
async function main() {
|
|
6
|
+
register();
|
|
7
|
+
const projectDir = process.argv[2];
|
|
8
|
+
if (!projectDir) {
|
|
9
|
+
process.stderr.write("usage: resolve-config <projectDir>\n");
|
|
10
|
+
process.exit(2);
|
|
11
|
+
}
|
|
12
|
+
const { resolved, pluginSourceFiles } = await loadConfig(projectDir);
|
|
13
|
+
const payload = {
|
|
14
|
+
plugins: resolved.plugins.map((p) => ({
|
|
15
|
+
name: p.name,
|
|
16
|
+
dir: p.dir,
|
|
17
|
+
services: p.services,
|
|
18
|
+
schemaPath: p.schemaPath,
|
|
19
|
+
migrationsPath: p.migrationsPath,
|
|
20
|
+
preloadPath: p.preloadPath,
|
|
21
|
+
eventsPath: p.eventsPath,
|
|
22
|
+
icons: p.icons
|
|
23
|
+
})),
|
|
24
|
+
appEntrypoint: resolved.uiEntrypointPath
|
|
25
|
+
};
|
|
26
|
+
process.stdout.write(JSON.stringify({
|
|
27
|
+
payload,
|
|
28
|
+
pluginSourceFiles
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
main().catch((err) => {
|
|
32
|
+
process.stderr.write(`[zenbu resolve-config] ${err instanceof Error ? err.stack ?? err.message : String(err)}\n`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
});
|
|
35
|
+
//#endregion
|
|
36
|
+
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { o as getZodDefault, t as NO_DEFAULT } from "./schema-CIg4GzHQ.mjs";
|
|
2
2
|
import { _ as handleErrnoException, d as readJsonFile, f as readJsonlFile, g as layer$7, l as paths, n as makeRootCache, t as handleWrite, v as FileSystem, y as BadArgument } from "./write-9dRFczGJ.mjs";
|
|
3
|
-
import { i as loadSchema } from "./config-
|
|
3
|
+
import { i as loadSchema } from "./config-BlRXeUXx.mjs";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import * as NodePath from "node:path";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import * as NodeUrl from "node:url";
|
|
8
|
+
import * as ChildProcess from "node:child_process";
|
|
8
9
|
import { createHash, randomUUID } from "node:crypto";
|
|
9
10
|
import * as Effect from "effect/Effect";
|
|
10
11
|
import * as Ref from "effect/Ref";
|
|
@@ -25,7 +26,6 @@ import * as Schema from "effect/Schema";
|
|
|
25
26
|
import "effect/Fiber";
|
|
26
27
|
import * as Exit from "effect/Exit";
|
|
27
28
|
import * as Cause from "effect/Cause";
|
|
28
|
-
import * as ChildProcess from "node:child_process";
|
|
29
29
|
import * as Arr from "effect/Array";
|
|
30
30
|
import * as ConfigError from "effect/ConfigError";
|
|
31
31
|
import * as Console from "effect/Console";
|
|
@@ -8030,7 +8030,7 @@ async function run(argv) {
|
|
|
8030
8030
|
process.exit(args.help ? 0 : 1);
|
|
8031
8031
|
}
|
|
8032
8032
|
if (args.command === "generate") {
|
|
8033
|
-
const { findConfigFile, loadConfig } = await import("./config-
|
|
8033
|
+
const { findConfigFile, loadConfig } = await import("./config-Ch1FreWU.mjs");
|
|
8034
8034
|
const resolved = await loadConfig(args.config ?? findConfigFile(process.cwd()));
|
|
8035
8035
|
await generateMigration({
|
|
8036
8036
|
schemaPath: resolved.schemaPath,
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as Config, c as ResolvedBuildConfig, d as Transform, f as TransformInput, g as definePlugin, h as defineConfig, i as BundleConfig, l as ResolvedConfig, m as defineBuildConfig, n as stripIfDisabled, o as MirrorConfig, p as TransformOutput, r as BuildConfig, s as Plugin, t as dropFiles, u as ResolvedPlugin } from "./transforms-EVd5Fgyk.mjs";
|
|
2
|
+
export { type BuildConfig, type BundleConfig, type Config, type MirrorConfig, type Plugin, type ResolvedBuildConfig, type ResolvedConfig, type ResolvedPlugin, type Transform, type TransformInput, type TransformOutput, defineBuildConfig, defineConfig, definePlugin, dropFiles, stripIfDisabled };
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { n as defineConfig, r as definePlugin, t as defineBuildConfig } from "./build-config-BwnnfrN-.mjs";
|
|
2
|
+
import { n as stripIfDisabled, t as dropFiles } from "./transforms-DVoy8dCu.mjs";
|
|
3
|
+
export { defineBuildConfig, defineConfig, definePlugin, dropFiles, stripIfDisabled };
|
|
@@ -247,11 +247,10 @@ Usage:
|
|
|
247
247
|
zen db remove [<path>] Drop a path from the registry (interactive when omitted)
|
|
248
248
|
zen db generate [...] Diff a schema against the last snapshot and
|
|
249
249
|
write a new migration. Default: walks up from
|
|
250
|
-
cwd to the
|
|
251
|
-
|
|
252
|
-
--manifest <path> override manifest path
|
|
250
|
+
cwd to the host's zenbu.config.ts, then picks
|
|
251
|
+
the plugin whose dir contains cwd. Flags:
|
|
253
252
|
--schema <path> schema file (bypasses
|
|
254
|
-
|
|
253
|
+
plugin discovery; must
|
|
255
254
|
be paired with --migrations)
|
|
256
255
|
--migrations <path> migrations output dir
|
|
257
256
|
(paired with --schema)
|
|
@@ -429,15 +428,20 @@ async function runDb(argv) {
|
|
|
429
428
|
* for any future internal section without growing privileged flags
|
|
430
429
|
* into the CLI.
|
|
431
430
|
*
|
|
432
|
-
* Resolution
|
|
433
|
-
*
|
|
434
|
-
*
|
|
431
|
+
* Resolution: direct mode (--schema + --migrations) bypasses everything;
|
|
432
|
+
* otherwise the cwd is matched against the plugins declared in the host
|
|
433
|
+
* project's `zenbu.config.ts`, picking the plugin whose `dir` contains the
|
|
434
|
+
* cwd. Mixing direct + plugin discovery is an error.
|
|
435
435
|
*/
|
|
436
|
-
function
|
|
436
|
+
function findProjectDir(from) {
|
|
437
437
|
let dir = path.resolve(from);
|
|
438
438
|
while (true) {
|
|
439
|
-
const
|
|
440
|
-
|
|
439
|
+
for (const name of [
|
|
440
|
+
"zenbu.config.ts",
|
|
441
|
+
"zenbu.config.mts",
|
|
442
|
+
"zenbu.config.js",
|
|
443
|
+
"zenbu.config.mjs"
|
|
444
|
+
]) if (fs.existsSync(path.join(dir, name))) return dir;
|
|
441
445
|
const parent = path.dirname(dir);
|
|
442
446
|
if (parent === dir) return null;
|
|
443
447
|
dir = parent;
|
|
@@ -445,7 +449,6 @@ function findManifest(from) {
|
|
|
445
449
|
}
|
|
446
450
|
function parseGenerateArgs(argv) {
|
|
447
451
|
const out = {
|
|
448
|
-
manifest: null,
|
|
449
452
|
schema: null,
|
|
450
453
|
migrationsOut: null,
|
|
451
454
|
custom: false,
|
|
@@ -453,9 +456,7 @@ function parseGenerateArgs(argv) {
|
|
|
453
456
|
};
|
|
454
457
|
for (let i = 0; i < argv.length; i++) {
|
|
455
458
|
const arg = argv[i];
|
|
456
|
-
if (arg === "--
|
|
457
|
-
else if (arg.startsWith("--manifest=")) out.manifest = arg.slice(11);
|
|
458
|
-
else if (arg === "--schema" && i + 1 < argv.length) out.schema = argv[++i];
|
|
459
|
+
if (arg === "--schema" && i + 1 < argv.length) out.schema = argv[++i];
|
|
459
460
|
else if (arg.startsWith("--schema=")) out.schema = arg.slice(9);
|
|
460
461
|
else if (arg === "--migrations" && i + 1 < argv.length) out.migrationsOut = argv[++i];
|
|
461
462
|
else if (arg.startsWith("--migrations=")) out.migrationsOut = arg.slice(13);
|
|
@@ -468,16 +469,12 @@ function parseGenerateArgs(argv) {
|
|
|
468
469
|
}
|
|
469
470
|
async function runGenerate(argv) {
|
|
470
471
|
const flags = parseGenerateArgs(argv);
|
|
471
|
-
const { generateMigration } = await import("./cli-
|
|
472
|
+
const { generateMigration } = await import("./cli-F0B4dvSg.mjs");
|
|
472
473
|
if (flags.schema || flags.migrationsOut) {
|
|
473
474
|
if (!flags.schema || !flags.migrationsOut) {
|
|
474
475
|
console.error("zen db generate: --schema and --migrations must be passed together.");
|
|
475
476
|
process.exit(1);
|
|
476
477
|
}
|
|
477
|
-
if (flags.manifest) {
|
|
478
|
-
console.error("zen db generate: --manifest is incompatible with --schema/--migrations; pick one input mode.");
|
|
479
|
-
process.exit(1);
|
|
480
|
-
}
|
|
481
478
|
const schemaPath = resolve(process.cwd(), flags.schema);
|
|
482
479
|
const outPath = resolve(process.cwd(), flags.migrationsOut);
|
|
483
480
|
console.log(`Schema: ${schemaPath}`);
|
|
@@ -491,37 +488,46 @@ async function runGenerate(argv) {
|
|
|
491
488
|
});
|
|
492
489
|
return;
|
|
493
490
|
}
|
|
494
|
-
const
|
|
495
|
-
if (!
|
|
496
|
-
console.error("zen db generate: no zenbu.
|
|
497
|
-
console.error(" Run from inside
|
|
498
|
-
console.error("
|
|
491
|
+
const projectDir = findProjectDir(process.cwd());
|
|
492
|
+
if (!projectDir) {
|
|
493
|
+
console.error("zen db generate: no zenbu.config.ts found in cwd or any parent.");
|
|
494
|
+
console.error(" Run from inside a Zenbu project, or use");
|
|
495
|
+
console.error(" --schema <path> --migrations <path> directly.");
|
|
499
496
|
process.exit(1);
|
|
500
497
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
498
|
+
const { loadConfig } = await import("./load-config-CQG4297M.mjs");
|
|
499
|
+
const { resolved } = await loadConfig(projectDir);
|
|
500
|
+
const cwd = path.resolve(process.cwd());
|
|
501
|
+
let bestMatch = null;
|
|
502
|
+
for (const plugin of resolved.plugins) {
|
|
503
|
+
const rel = path.relative(plugin.dir, cwd);
|
|
504
|
+
if (rel.startsWith("..") || path.isAbsolute(rel)) continue;
|
|
505
|
+
const depth = plugin.dir.split(path.sep).length;
|
|
506
|
+
if (!bestMatch || depth > bestMatch.depth) bestMatch = {
|
|
507
|
+
dir: plugin.dir,
|
|
508
|
+
depth,
|
|
509
|
+
plugin
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
if (!bestMatch) {
|
|
513
|
+
console.error(`zen db generate: cwd ${cwd} is not inside any plugin declared in ${path.relative(projectDir, resolved.configPath)}.`);
|
|
506
514
|
process.exit(1);
|
|
507
515
|
}
|
|
508
|
-
|
|
509
|
-
|
|
516
|
+
const plugin = bestMatch.plugin;
|
|
517
|
+
if (!plugin.schemaPath) {
|
|
518
|
+
console.error(`zen db generate: plugin "${plugin.name}" is missing a \`schema\` field in its definePlugin({...}).`);
|
|
510
519
|
process.exit(1);
|
|
511
520
|
}
|
|
512
|
-
if (!
|
|
513
|
-
console.error(`zen db generate: ${
|
|
514
|
-
console.error(` (the directory the generator writes migrations into).`);
|
|
521
|
+
if (!plugin.migrationsPath) {
|
|
522
|
+
console.error(`zen db generate: plugin "${plugin.name}" is missing a \`migrations\` field in its definePlugin({...}) (the directory the generator writes migrations into).`);
|
|
515
523
|
process.exit(1);
|
|
516
524
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
console.log(`Plugin: ${manifest.name ?? path.basename(baseDir)}`);
|
|
521
|
-
console.log(`Manifest: ${manifestPath}`);
|
|
525
|
+
console.log(`Plugin: ${plugin.name}`);
|
|
526
|
+
console.log(`Schema: ${plugin.schemaPath}`);
|
|
527
|
+
console.log(`Output: ${plugin.migrationsPath}`);
|
|
522
528
|
await generateMigration({
|
|
523
|
-
schemaPath,
|
|
524
|
-
outPath,
|
|
529
|
+
schemaPath: plugin.schemaPath,
|
|
530
|
+
outPath: plugin.migrationsPath,
|
|
525
531
|
name: flags.name,
|
|
526
532
|
custom: flags.custom,
|
|
527
533
|
amend: flags.amend
|
package/dist/db.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as createSchema, _ as InferSchema$1, a as dbStringify, b as blob, f as CollectionRefBrand$1, g as InferRoot$1, i as dbParse, n as connectReplica, o as ClientProxy, p as CollectionRefValue$1, s as CollectionNode$1, v as Schema$1, x as collection, y as SchemaShape$1 } from "./index-
|
|
1
|
+
import { S as createSchema, _ as InferSchema$1, a as dbStringify, b as blob, f as CollectionRefBrand$1, g as InferRoot$1, i as dbParse, n as connectReplica, o as ClientProxy, p as CollectionRefValue$1, s as CollectionNode$1, v as Schema$1, x as collection, y as SchemaShape$1 } from "./index-UK58xuoR.mjs";
|
|
2
2
|
import { z as z$1 } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/db.d.ts
|
package/dist/env-bootstrap.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as bootstrapEnv } from "./env-bootstrap-
|
|
1
|
+
import { t as bootstrapEnv } from "./env-bootstrap-uCKbw2q8.mjs";
|
|
2
2
|
export { bootstrapEnv };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as bootstrapEnv } from "./env-bootstrap-
|
|
2
|
-
import { t as setupGate } from "./setup-gate-
|
|
3
|
-
import {
|
|
4
|
-
import { n as SchemaRoot, o as schema, t as CoreSchema } from "./schema-
|
|
5
|
-
import { i as CoreServiceRouter, n as CoreEvents, r as CorePreloads, t as CoreDbSections } from "./registry-
|
|
1
|
+
import { t as bootstrapEnv } from "./env-bootstrap-uCKbw2q8.mjs";
|
|
2
|
+
import { t as setupGate } from "./setup-gate-D62nX5lk.mjs";
|
|
3
|
+
import { c as optional, f as runtime, i as ServiceRuntime, p as serviceWithDeps, r as Service, t as CleanupReason } from "./runtime-CsiDppGF.mjs";
|
|
4
|
+
import { n as SchemaRoot, o as schema, t as CoreSchema } from "./schema-DvT61x2_.mjs";
|
|
5
|
+
import { i as CoreServiceRouter, n as CoreEvents, r as CorePreloads, t as CoreDbSections } from "./registry-CioEYLI5.mjs";
|
|
6
6
|
export { CleanupReason, CoreDbSections, CoreEvents, CorePreloads, CoreSchema, SchemaRoot as CoreSchemaRoot, CoreServiceRouter, Service, ServiceRuntime, bootstrapEnv, schema as coreSchema, optional, runtime, serviceWithDeps, setupGate };
|