@zenbujs/core 0.0.5 → 0.0.9

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 (72) hide show
  1. package/dist/{advice-config-QYB2qEd_.mjs → advice-config-DXSIo0sg.mjs} +40 -39
  2. package/dist/advice.d.mts +8 -8
  3. package/dist/advice.mjs +2 -2
  4. package/dist/{base-window-BbFRRhKP.mjs → base-window-BxBZ2md_.mjs} +51 -7
  5. package/dist/{transforms-CuTODvDx.d.mts → build-config-Dzg2frpk.d.mts} +98 -28
  6. package/dist/build-config-pWdmLnrk.mjs +53 -0
  7. package/dist/{build-electron-CNJ0dLND.mjs → build-electron-Dsbb1EMl.mjs} +308 -120
  8. package/dist/{build-source-C2puqEVr.mjs → build-source-d1J3shV8.mjs} +62 -27
  9. package/dist/cli/bin.mjs +7 -7
  10. package/dist/cli/build.d.mts +2 -2
  11. package/dist/cli/build.mjs +2 -3
  12. package/dist/cli/resolve-config.mjs +1 -1
  13. package/dist/{cli-C3R1LBMY.mjs → cli-kL6mPgBE.mjs} +2 -2
  14. package/dist/config.d.mts +3 -3
  15. package/dist/config.mjs +2 -3
  16. package/dist/{db-xjvahRFJ.mjs → db-Bc292RYo.mjs} +2 -2
  17. package/dist/db.d.mts +1 -1
  18. package/dist/dev-B2emj0HZ.mjs +301 -0
  19. package/dist/env-bootstrap.d.mts +1 -1
  20. package/dist/events.d.mts +19 -0
  21. package/dist/events.mjs +1 -0
  22. package/dist/host-version-BIrF8tX7.mjs +65 -0
  23. package/dist/index-CVF768Xs.d.mts +783 -0
  24. package/dist/index.d.mts +5 -6
  25. package/dist/index.mjs +2 -2
  26. package/dist/installing-preload.cjs +60 -0
  27. package/dist/launcher.mjs +2615 -122
  28. package/dist/{link-c0_aLWQ3.mjs → link-glX89NV5.mjs} +215 -89
  29. package/dist/{load-config-xMf2wxH8.mjs → load-config-C4Oe2qZO.mjs} +5 -1
  30. package/dist/loaders/zenbu.mjs +102 -0
  31. package/dist/node-loader.mjs +1 -1
  32. package/dist/{publish-source-Dill72NS.mjs → publish-source-Dq2c0iOw.mjs} +2 -2
  33. package/dist/react.d.mts +55 -6
  34. package/dist/react.mjs +116 -5
  35. package/dist/registry-CMp8FYgS.d.mts +47 -0
  36. package/dist/registry-generated.d.mts +26 -0
  37. package/dist/registry-generated.mjs +1 -0
  38. package/dist/registry.d.mts +2 -2
  39. package/dist/{reloader-DzEO8kJr.mjs → reloader-B22UiNA2.mjs} +2 -4
  40. package/dist/{renderer-host-Cau9JK0v.mjs → renderer-host-DD16MXhI.mjs} +152 -43
  41. package/dist/{rpc-JfGv-Wuw.mjs → rpc-C4_NQmpT.mjs} +5 -4
  42. package/dist/{runtime-pCeVzj--.d.mts → runtime-BQWntcOb.d.mts} +85 -48
  43. package/dist/runtime.d.mts +2 -2
  44. package/dist/runtime.mjs +139 -83
  45. package/dist/{schema-Dl85YjXW.d.mts → schema-CjrMVk36.d.mts} +3 -3
  46. package/dist/schema.d.mts +1 -1
  47. package/dist/schema.mjs +1 -1
  48. package/dist/{server-y3PPbh3l.mjs → server-CZLMF8Dj.mjs} +1 -3
  49. package/dist/services/default.d.mts +3 -3
  50. package/dist/services/default.mjs +14 -13
  51. package/dist/services/index.d.mts +2 -280
  52. package/dist/services/index.mjs +8 -7
  53. package/dist/setup-gate.d.mts +1 -1
  54. package/dist/setup-gate.mjs +123 -24
  55. package/dist/{transform-CmFYPmt8.mjs → transform-BzrwkEdf.mjs} +22 -916
  56. package/dist/updater-BtB_Ki1r.mjs +1011 -0
  57. package/dist/{vite-plugins-Do7liKi_.mjs → vite-plugins-tt6KAtyE.mjs} +26 -25
  58. package/dist/vite.d.mts +3 -3
  59. package/dist/vite.mjs +1 -1
  60. package/dist/{window-o2NGUsIb.mjs → window-YFKvAM0l.mjs} +30 -16
  61. package/package.json +17 -4
  62. package/dist/build-config-C3a-o3_B.mjs +0 -23
  63. package/dist/dev-Dazhu66l.mjs +0 -85
  64. package/dist/registry-eX6e2oql.d.mts +0 -61
  65. package/dist/transforms-htxfTwsY.mjs +0 -47
  66. /package/dist/{config-DXRCDUxG.mjs → config-BK78JDRI.mjs} +0 -0
  67. /package/dist/{env-bootstrap-DW2hVhSO.d.mts → env-bootstrap-rTs8KR3-.d.mts} +0 -0
  68. /package/dist/{index-M_lSNBrq.d.mts → index-DeDxePAa.d.mts} +0 -0
  69. /package/dist/{mirror-sync-PDzxhf1w.mjs → mirror-sync-pYU6f3-c.mjs} +0 -0
  70. /package/dist/{monorepo-3avKJwzJ.mjs → monorepo-Dct-kkbQ.mjs} +0 -0
  71. /package/dist/{node-_8xShqxr.mjs → node-BhfLKYCi.mjs} +0 -0
  72. /package/dist/{setup-gate-Dcy8gGPJ.d.mts → setup-gate-BQq0QgZH.d.mts} +0 -0
@@ -1,12 +1,12 @@
1
1
  import { getPlugins } from "./runtime.mjs";
2
- import { n as require_lib, t as zenbuAdviceTransform$1 } from "./transform-CmFYPmt8.mjs";
3
- import { a as getAllScopes, i as getAllContentScriptPaths, n as getAdvice, o as getContentScripts } from "./advice-config-QYB2qEd_.mjs";
2
+ import { n as require_lib, t as zenbuAdviceTransform$1 } from "./transform-BzrwkEdf.mjs";
3
+ import { a as getAllTypes, i as getAllContentScriptPaths, n as getAdvice, o as getContentScripts } from "./advice-config-DXSIo0sg.mjs";
4
4
  import path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  //#region ../advice/src/vite.ts
7
7
  var import_lib = require_lib();
8
8
  const defaultInclude = /\.[jt]sx?$/;
9
- const defaultExclude = /node_modules/;
9
+ const defaultExclude = /node_modules|[/\\]\.vite[/\\]deps[/\\]|[/\\]vite-cache[/\\][^/\\]+[/\\]deps[/\\]/;
10
10
  function zenbuAdvicePlugin(options = {}) {
11
11
  let resolvedRoot;
12
12
  return {
@@ -29,7 +29,8 @@ function zenbuAdvicePlugin(options = {}) {
29
29
  parserOpts: { plugins: parserPlugins },
30
30
  sourceMaps: true,
31
31
  configFile: false,
32
- babelrc: false
32
+ babelrc: false,
33
+ compact: false
33
34
  });
34
35
  if (!result?.code) return null;
35
36
  return {
@@ -142,29 +143,29 @@ function zenbuFrameworkResolve() {
142
143
  }
143
144
  };
144
145
  }
145
- function getScopeFromPath(urlPath) {
146
+ function getTypeFromPath(urlPath) {
146
147
  const m = urlPath.match(/^\/views\/([^/]+)\//);
147
148
  return m ? m[1] : null;
148
149
  }
149
150
  /**
150
- * Resolve the view scope for a request. The kernel passes `?scope=<name>`
151
+ * Resolve the view type for a request. The kernel passes `?type=<name>`
151
152
  * in the iframe URL when opening a view (see `WindowService.openView`); we
152
- * also support `/views/<scope>/...` paths for plugins that register their
153
+ * also support `/views/<type>/...` paths for plugins that register their
153
154
  * own multi-page Vite layouts.
154
155
  */
155
- function resolveScope(urlPath, originalUrl) {
156
- const fromPath = getScopeFromPath(urlPath);
156
+ function resolveType(urlPath, originalUrl) {
157
+ const fromPath = getTypeFromPath(urlPath);
157
158
  if (fromPath) return fromPath;
158
159
  if (!originalUrl) return null;
159
160
  const queryIdx = originalUrl.indexOf("?");
160
161
  if (queryIdx < 0) return null;
161
- return new URLSearchParams(originalUrl.slice(queryIdx + 1)).get("scope");
162
+ return new URLSearchParams(originalUrl.slice(queryIdx + 1)).get("type");
162
163
  }
163
164
  function parsePreludeId(id) {
164
165
  const rest = id.slice(17);
165
166
  const queryIdx = rest.indexOf("?");
166
- if (queryIdx < 0) return { scope: rest };
167
- return { scope: rest.slice(0, queryIdx) };
167
+ if (queryIdx < 0) return { type: rest };
168
+ return { type: rest.slice(0, queryIdx) };
168
169
  }
169
170
  function generateAdvicePreludeCode(entries) {
170
171
  if (entries.length === 0) return "";
@@ -195,9 +196,9 @@ function resolveAdviceRuntime() {
195
196
  }
196
197
  /**
197
198
  * Per-iframe prelude that registers all advice + content scripts for the
198
- * iframe's scope. The prelude is loaded via a `<script type="module">` tag
199
- * injected into the iframe's HTML; loading it before the app's own entry
200
- * lets advice register before the modules it patches evaluate.
199
+ * iframe's view type. The prelude is loaded via a `<script type="module">`
200
+ * tag injected into the iframe's HTML; loading it before the app's own
201
+ * entry lets advice register before the modules it patches evaluate.
201
202
  */
202
203
  function advicePreludePlugin() {
203
204
  return {
@@ -209,15 +210,15 @@ function advicePreludePlugin() {
209
210
  },
210
211
  load(id) {
211
212
  if (!id.startsWith(RESOLVED_PREFIX)) return null;
212
- const { scope } = parsePreludeId(id);
213
- let code = generateAdvicePreludeCode(getAdvice(scope));
214
- for (const scriptPath of getContentScripts(scope)) code += `import ${JSON.stringify(scriptPath)}\n`;
213
+ const { type } = parsePreludeId(id);
214
+ let code = generateAdvicePreludeCode(getAdvice(type));
215
+ for (const scriptPath of getContentScripts(type)) code += `import ${JSON.stringify(scriptPath)}\n`;
215
216
  return code || "// no advice or content scripts\n";
216
217
  },
217
218
  handleHotUpdate({ file, server }) {
218
219
  let matched = false;
219
- for (const scope of getAllScopes()) {
220
- for (const entry of getAdvice(scope)) if (file === entry.modulePath) {
220
+ for (const type of getAllTypes()) {
221
+ for (const entry of getAdvice(type)) if (file === entry.modulePath) {
221
222
  matched = true;
222
223
  break;
223
224
  }
@@ -249,16 +250,16 @@ function advicePreludePlugin() {
249
250
  });
250
251
  },
251
252
  transformIndexHtml(html, ctx) {
252
- const scope = resolveScope(ctx.path ?? "", ctx.originalUrl);
253
- if (!scope) return html;
254
- const hasAdvice = getAdvice(scope).length > 0;
255
- const hasScripts = getContentScripts(scope).length > 0;
253
+ const type = resolveType(ctx.path ?? "", ctx.originalUrl);
254
+ if (!type) return html;
255
+ const hasAdvice = getAdvice(type).length > 0;
256
+ const hasScripts = getContentScripts(type).length > 0;
256
257
  if (!hasAdvice && !hasScripts) return html;
257
258
  return [{
258
259
  tag: "script",
259
260
  attrs: {
260
261
  type: "module",
261
- src: `${PRELUDE_PREFIX}${scope}`
262
+ src: `${PRELUDE_PREFIX}${type}`
262
263
  },
263
264
  injectTo: "head"
264
265
  }];
package/dist/vite.d.mts CHANGED
@@ -38,9 +38,9 @@ declare function zenbuFrameworkResolve(): Plugin;
38
38
  declare function resolveAdviceRuntime(): Plugin;
39
39
  /**
40
40
  * Per-iframe prelude that registers all advice + content scripts for the
41
- * iframe's scope. The prelude is loaded via a `<script type="module">` tag
42
- * injected into the iframe's HTML; loading it before the app's own entry
43
- * lets advice register before the modules it patches evaluate.
41
+ * iframe's view type. The prelude is loaded via a `<script type="module">`
42
+ * tag injected into the iframe's HTML; loading it before the app's own
43
+ * entry lets advice register before the modules it patches evaluate.
44
44
  */
45
45
  declare function advicePreludePlugin(): Plugin;
46
46
  /**
package/dist/vite.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as zenbuVitePlugins, i as zenbuFrameworkResolve, n as resolveAdviceRuntime, r as zenbuAdviceTransform, t as advicePreludePlugin } from "./vite-plugins-Do7liKi_.mjs";
1
+ import { a as zenbuVitePlugins, i as zenbuFrameworkResolve, n as resolveAdviceRuntime, r as zenbuAdviceTransform, t as advicePreludePlugin } from "./vite-plugins-tt6KAtyE.mjs";
2
2
  export { advicePreludePlugin, resolveAdviceRuntime, zenbuAdviceTransform, zenbuFrameworkResolve, zenbuVitePlugins };
@@ -1,10 +1,10 @@
1
1
  import { n as __exportAll } from "./chunk-DsiFFCwN.mjs";
2
- import { runtime, serviceWithDeps } from "./runtime.mjs";
2
+ import { Service, runtime } from "./runtime.mjs";
3
3
  import { t as createLogger } from "./log-6rzaCV0I.mjs";
4
- import { r as ViewRegistryService, s as HttpService, t as RendererHostService } from "./renderer-host-Cau9JK0v.mjs";
5
- import { t as BaseWindowService } from "./base-window-BbFRRhKP.mjs";
4
+ import { r as ViewRegistryService, s as HttpService, t as RendererHostService } from "./renderer-host-DD16MXhI.mjs";
5
+ import { i as entrypointBgColor, t as BaseWindowService } from "./base-window-BxBZ2md_.mjs";
6
6
  import { URLSearchParams } from "node:url";
7
- import { WebContentsView, clipboard, dialog, shell } from "electron";
7
+ import { WebContentsView, app, clipboard, dialog, shell } from "electron";
8
8
  import electronContextMenu from "electron-context-menu";
9
9
  //#region src/services/window.ts
10
10
  var window_exports = /* @__PURE__ */ __exportAll({ WindowService: () => WindowService });
@@ -19,13 +19,15 @@ function queryString(query) {
19
19
  const encoded = params.toString();
20
20
  return encoded ? `?${encoded}` : "";
21
21
  }
22
- var WindowService = class extends serviceWithDeps({
23
- baseWindow: BaseWindowService,
24
- viewRegistry: ViewRegistryService,
25
- http: HttpService,
26
- rendererHost: RendererHostService
22
+ var WindowService = class extends Service.create({
23
+ key: "window",
24
+ deps: {
25
+ baseWindow: BaseWindowService,
26
+ viewRegistry: ViewRegistryService,
27
+ http: HttpService,
28
+ rendererHost: RendererHostService
29
+ }
27
30
  }) {
28
- static key = "window";
29
31
  mounted = /* @__PURE__ */ new Map();
30
32
  evaluate() {
31
33
  this.setup("window-view-cleanup", () => {
@@ -43,10 +45,22 @@ var WindowService = class extends serviceWithDeps({
43
45
  this.mounted.clear();
44
46
  };
45
47
  });
48
+ this.setup("activate-reopens-entrypoint", () => {
49
+ const onActivate = () => {
50
+ if (this.ctx.baseWindow.windows.size > 0) return;
51
+ this.openView({ type: "app" }).catch((err) => {
52
+ log.error("activate-reopens-entrypoint: openView failed:", err);
53
+ });
54
+ };
55
+ app.on("activate", onActivate);
56
+ return () => {
57
+ app.removeListener("activate", onActivate);
58
+ };
59
+ });
46
60
  }
47
61
  async openView(args) {
48
- const entry = this.ctx.viewRegistry.get(args.scope);
49
- if (!entry) throw new Error(`No registered view for scope "${args.scope}"`);
62
+ const entry = this.ctx.viewRegistry.get(args.type);
63
+ if (!entry) throw new Error(`No registered view for type "${args.type}"`);
50
64
  const windowId = args.windowId ?? "main";
51
65
  let win = this.ctx.baseWindow.windows.get(windowId);
52
66
  if (!win) win = this.ctx.baseWindow.createWindow({ windowId }).win;
@@ -67,7 +81,7 @@ var WindowService = class extends serviceWithDeps({
67
81
  sandbox: true,
68
82
  ...args.view?.webPreferences
69
83
  } });
70
- view.setBackgroundColor(args.view?.backgroundColor ?? "#F4F4F4");
84
+ view.setBackgroundColor(args.view?.backgroundColor ?? entrypointBgColor());
71
85
  win.contentView.addChildView(view);
72
86
  const disposeContextMenu = electronContextMenu({
73
87
  window: view,
@@ -102,18 +116,18 @@ var WindowService = class extends serviceWithDeps({
102
116
  wsPort: this.ctx.http.port,
103
117
  wsToken: this.ctx.http.authToken,
104
118
  windowId,
105
- scope: args.scope
119
+ type: args.type
106
120
  })}`;
107
121
  await view.webContents.loadURL(url);
108
122
  this.mounted.set(windowId, {
109
123
  windowId,
110
- scope: args.scope,
124
+ type: args.type,
111
125
  view,
112
126
  disposeContextMenu
113
127
  });
114
128
  if (!win.isVisible()) win.show();
115
129
  win.focus();
116
- log.verbose(`mounted "${args.scope}" in window "${windowId}"`);
130
+ log.verbose(`mounted "${args.type}" in window "${windowId}"`);
117
131
  return { windowId };
118
132
  }
119
133
  async focusWindow(windowId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenbujs/core",
3
- "version": "0.0.5",
3
+ "version": "0.0.9",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -42,6 +42,14 @@
42
42
  "types": "./dist/registry.d.mts",
43
43
  "import": "./dist/registry.mjs"
44
44
  },
45
+ "./registry-generated": {
46
+ "types": "./dist/registry-generated.d.mts",
47
+ "import": "./dist/registry-generated.mjs"
48
+ },
49
+ "./events": {
50
+ "types": "./dist/events.d.mts",
51
+ "import": "./dist/events.mjs"
52
+ },
45
53
  "./schema": {
46
54
  "types": "./dist/schema.d.mts",
47
55
  "import": "./dist/schema.mjs"
@@ -98,6 +106,7 @@
98
106
  "electron-context-menu": "^4.1.2",
99
107
  "isomorphic-git": "^1.37.6",
100
108
  "nanoid": "^5.1.6",
109
+ "semver": "^7.8.0",
101
110
  "tsx": "^4.21.0",
102
111
  "vite": "^6.0.0",
103
112
  "ws": "^8.18.0",
@@ -107,19 +116,23 @@
107
116
  "devDependencies": {
108
117
  "@types/node": "^22.0.0",
109
118
  "@types/react": "^19.0.0",
119
+ "@types/semver": "^7.7.1",
110
120
  "@types/ws": "^8.18.0",
111
121
  "electron": "^42.0.0",
112
122
  "tsdown": "^0.21.10",
113
123
  "typescript": "^5.4.5",
114
- "@zenbu/zenrpc": "0.0.0",
124
+ "vitest": "^3.2.4",
125
+ "@zenbu/advice": "0.0.0",
115
126
  "@zenbu/kyju": "0.0.0",
116
- "@zenbu/advice": "0.0.0"
127
+ "@zenbu/zenrpc": "0.0.0"
117
128
  },
118
129
  "scripts": {
119
130
  "build": "node --max-old-space-size=8192 ./node_modules/tsdown/dist/run.mjs",
131
+ "prebuild": "pnpm link:types",
120
132
  "dev": "tsdown --watch",
121
- "link:types": "node ./dist/cli/bin.mjs link --types-config ./zenbu-types.config.json --registry ./types",
133
+ "link:types": "tsx ./src/cli/bin.ts link --types-config ./zenbu-types.config.json --out ./src/registry-generated.ts --augment-out ./types/zenbu-register.ts",
122
134
  "db:generate": "node ./dist/cli/bin.mjs db generate --schema src/schema.ts --migrations ./migrations",
135
+ "test": "vitest run",
123
136
  "typecheck": "tsc --noEmit -p tsconfig.json"
124
137
  }
125
138
  }
@@ -1,23 +0,0 @@
1
- //#region src/cli/lib/build-config.ts
2
- function defineBuildConfig(config) {
3
- return config;
4
- }
5
- function resolveBuildConfig(config) {
6
- return {
7
- source: config.source ?? ".",
8
- out: config.out ?? ".zenbu/build/source",
9
- include: config.include,
10
- ignore: config.ignore ?? [],
11
- transforms: config.transforms ?? [],
12
- mirror: config.mirror,
13
- bundle: config.bundle
14
- };
15
- }
16
- function definePlugin(plugin) {
17
- return plugin;
18
- }
19
- function defineConfig(config) {
20
- return config;
21
- }
22
- //#endregion
23
- export { resolveBuildConfig as i, defineConfig as n, definePlugin as r, defineBuildConfig as t };
@@ -1,85 +0,0 @@
1
- import { existsSync, statSync } from "node:fs";
2
- import path, { resolve } from "node:path";
3
- import { spawn } from "node:child_process";
4
- //#region src/cli/commands/dev.ts
5
- /**
6
- * `zen dev` — launch the local app under Electron with the setup-gate as the
7
- * main entry. This is the entrypoint of `pnpm dev` in scaffolded apps. The
8
- * command is intentionally hookable: future versions can layer doctor checks,
9
- * environment validation, or a managed dev-server here without touching the
10
- * user's `package.json` scripts.
11
- *
12
- * Defaults to a foreground/blocking child so Ctrl+C in the terminal kills the
13
- * Electron process and `pnpm dev` exits cleanly. Pass `--detach` to spawn it
14
- * in the background instead (returns immediately, Electron lives until quit).
15
- */
16
- function parseArgs(argv) {
17
- let pathArg;
18
- let detach = false;
19
- let verbose = false;
20
- for (let i = 0; i < argv.length; i++) {
21
- const arg = argv[i];
22
- if (arg === "--detach") detach = true;
23
- else if (arg === "--verbose" || arg === "-v") verbose = true;
24
- else if (!arg.startsWith("-") && pathArg == null) pathArg = arg;
25
- else {
26
- console.error(`zen dev: unknown flag "${arg}"`);
27
- console.error(`valid: zen dev [path] [--detach] [--verbose]`);
28
- process.exit(1);
29
- }
30
- }
31
- const projectDir = pathArg ? resolve(process.cwd(), pathArg) : process.cwd();
32
- if (!existsSync(projectDir)) {
33
- console.error(`zen dev: path "${pathArg}" does not exist`);
34
- process.exit(1);
35
- }
36
- try {
37
- if (!statSync(projectDir).isDirectory()) {
38
- console.error(`zen dev: path "${pathArg}" is not a directory`);
39
- process.exit(1);
40
- }
41
- } catch {
42
- console.error(`zen dev: cannot stat "${pathArg}"`);
43
- process.exit(1);
44
- }
45
- return {
46
- projectDir,
47
- detach,
48
- verbose
49
- };
50
- }
51
- function resolveLocalElectron(projectDir) {
52
- const candidates = [path.join(projectDir, "node_modules", "electron", "dist", "Electron.app", "Contents", "MacOS", "Electron"), path.join(projectDir, "node_modules", ".bin", "electron")];
53
- for (const candidate of candidates) if (existsSync(candidate)) return candidate;
54
- throw new Error(`Electron is not installed in ${projectDir}. Run \`pnpm install\` in the app.`);
55
- }
56
- function ensureSetupGate(projectDir) {
57
- const setupGate = path.join(projectDir, "node_modules", "@zenbujs", "core", "dist", "setup-gate.mjs");
58
- if (!existsSync(setupGate)) throw new Error(`@zenbujs/core setup-gate not found at ${setupGate}. Run \`pnpm install\` in the app.`);
59
- }
60
- async function runDev(argv) {
61
- const { projectDir, detach, verbose } = parseArgs(argv);
62
- if (verbose) console.error("[zen dev] launching:", projectDir);
63
- const electron = resolveLocalElectron(projectDir);
64
- ensureSetupGate(projectDir);
65
- const electronArgs = [projectDir, `--project=${projectDir}`];
66
- if (detach) {
67
- spawn(electron, electronArgs, {
68
- cwd: projectDir,
69
- detached: true,
70
- stdio: "ignore"
71
- }).unref();
72
- return;
73
- }
74
- const child = spawn(electron, electronArgs, {
75
- cwd: projectDir,
76
- stdio: "inherit"
77
- });
78
- process.on("SIGINT", () => child.kill("SIGINT"));
79
- process.on("SIGTERM", () => child.kill("SIGTERM"));
80
- child.on("exit", (code, signal) => {
81
- process.exit(code ?? (signal ? 1 : 0));
82
- });
83
- }
84
- //#endregion
85
- export { runDev };
@@ -1,61 +0,0 @@
1
- import { n as SchemaRoot } from "./schema-Dl85YjXW.mjs";
2
-
3
- //#region src/registry.d.ts
4
- type CoreEvents = {
5
- advice: {
6
- reload: {
7
- scope: string;
8
- };
9
- };
10
- };
11
- type Events = CoreEvents;
12
- type CoreDbSections = {
13
- core: SchemaRoot;
14
- };
15
- type CorePreloads = {};
16
- type CoreServiceRouter = {};
17
- /**
18
- * Module-augmentation point for plugin authors. `zen link` generates
19
- * `<app>/types/zenbu-register.ts` which declares:
20
- *
21
- * declare module "@zenbujs/core/registry" {
22
- * interface ZenbuRegister {
23
- * db: DbRoot
24
- * rpc: ServiceRouter
25
- * events: PluginEvents
26
- * }
27
- * }
28
- *
29
- * Server services (`DbService.client`, `RpcService.emit`) and renderer hooks
30
- * (`useDb`, `useRpc`, `useEvents`) all read their types from this single
31
- * registry, so the user's plugin types flow everywhere automatically.
32
- *
33
- * Mirrors the pattern TanStack Router uses for `Register`.
34
- */
35
- interface ZenbuRegister {}
36
- /**
37
- * Resolve the DB-root type from `ZenbuRegister["db"]`, falling back to a
38
- * core-only root when no augmentation has been declared (e.g. a plugin that
39
- * only emits events / RPC and doesn't define its own DB sections).
40
- */
41
- type ResolvedDbRoot = ZenbuRegister extends {
42
- db: infer T;
43
- } ? T : {
44
- plugin: CoreDbSections;
45
- };
46
- /**
47
- * Resolve the RPC router type from `ZenbuRegister["rpc"]`, falling back to
48
- * the core router when no augmentation has been declared.
49
- */
50
- type ResolvedServiceRouter = ZenbuRegister extends {
51
- rpc: infer T;
52
- } ? T : CoreServiceRouter;
53
- /**
54
- * Resolve the events tree from `ZenbuRegister["events"]`, falling back to
55
- * `CoreEvents` when no augmentation has been declared.
56
- */
57
- type ResolvedEvents = ZenbuRegister extends {
58
- events: infer T;
59
- } ? T : CoreEvents;
60
- //#endregion
61
- export { Events as a, ResolvedServiceRouter as c, CoreServiceRouter as i, ZenbuRegister as l, CoreEvents as n, ResolvedDbRoot as o, CorePreloads as r, ResolvedEvents as s, CoreDbSections as t };
@@ -1,47 +0,0 @@
1
- //#region src/cli/lib/transforms.ts
2
- const STRIP_START = /^\s*\/\/\s*@zenbu:strip-if\s+(!?)([A-Za-z_][A-Za-z0-9_]*)\s*$/;
3
- const STRIP_END = /^\s*\/\/\s*@zenbu:end\s*$/;
4
- /**
5
- * Marker-based feature-flag stripping. Removes lines between
6
- * // @zenbu:strip-if FLAG (strip when FLAG is truthy)
7
- * // @zenbu:strip-if !FLAG (strip when FLAG is falsy)
8
- * ...
9
- * // @zenbu:end
10
- *
11
- * Pure string/line ops — no AST, no compiler dep.
12
- */
13
- function stripIfDisabled(flags) {
14
- return (file) => {
15
- const lines = file.code.split("\n");
16
- const out = [];
17
- let stripDepth = 0;
18
- for (const line of lines) {
19
- const startMatch = STRIP_START.exec(line);
20
- if (startMatch) {
21
- const negated = startMatch[1] === "!";
22
- const flagValue = flags[startMatch[2]] ?? false;
23
- if ((negated ? !flagValue : flagValue) || stripDepth > 0) stripDepth += 1;
24
- continue;
25
- }
26
- if (STRIP_END.test(line)) {
27
- if (stripDepth > 0) stripDepth -= 1;
28
- continue;
29
- }
30
- if (stripDepth === 0) out.push(line);
31
- }
32
- return { code: out.join("\n") };
33
- };
34
- }
35
- /**
36
- * Drop files whose path matches the given pattern (relative path from the
37
- * source root, posix slashes). Also covered by `ignore` globs in the config;
38
- * use this when a regex is more convenient than a glob.
39
- */
40
- function dropFiles(pattern) {
41
- const test = typeof pattern === "function" ? pattern : (p) => pattern.test(p);
42
- return (file) => {
43
- if (test(file.path)) return { drop: true };
44
- };
45
- }
46
- //#endregion
47
- export { stripIfDisabled as n, dropFiles as t };
File without changes