@zenbujs/core 0.0.1 → 0.0.2

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.
@@ -0,0 +1,40 @@
1
+ import { n as resolveBuildConfig } from "./build-config-pbv0w4oN.mjs";
2
+ import { createRequire } from "node:module";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import { pathToFileURL } from "node:url";
6
+ //#region src/cli/lib/load-build-config.ts
7
+ const localRequire = createRequire(import.meta.url);
8
+ const CONFIG_NAMES = [
9
+ "zenbu.build.ts",
10
+ "zenbu.build.mts",
11
+ "zenbu.build.js",
12
+ "zenbu.build.mjs"
13
+ ];
14
+ function findBuildConfig(projectDir) {
15
+ for (const name of CONFIG_NAMES) {
16
+ const candidate = path.join(projectDir, name);
17
+ if (fs.existsSync(candidate)) return candidate;
18
+ }
19
+ throw new Error(`No zenbu.build config found at ${projectDir}. Expected one of: ${CONFIG_NAMES.join(", ")}`);
20
+ }
21
+ let tsxRegistered = null;
22
+ function ensureTsxRegistered() {
23
+ if (tsxRegistered) return tsxRegistered;
24
+ tsxRegistered = (async () => {
25
+ try {
26
+ const tsxApi = localRequire("tsx/esm/api");
27
+ if (typeof tsxApi.register === "function") tsxApi.register();
28
+ } catch {}
29
+ })();
30
+ return tsxRegistered;
31
+ }
32
+ async function loadBuildConfig(configPath) {
33
+ await ensureTsxRegistered();
34
+ const mod = await import(pathToFileURL(path.resolve(configPath)).href);
35
+ const config = mod.default ?? mod;
36
+ if (!config || !Array.isArray(config.include)) throw new Error(`${path.basename(configPath)} must export a config object (via defineBuildConfig) with an 'include' array.`);
37
+ return resolveBuildConfig(config);
38
+ }
39
+ //#endregion
40
+ export { loadBuildConfig as n, findBuildConfig as t };
@@ -7,7 +7,7 @@ const verbose = process.env.ZENBU_VERBOSE === "1";
7
7
  const { subscribe } = createRequire(import.meta.url)("@parcel/watcher");
8
8
  let registerWatcherClosable = () => {};
9
9
  try {
10
- const pause = await import("../pause-DvAUNmKn.mjs");
10
+ const pause = await import("@zenbujs/hmr/pause");
11
11
  registerWatcherClosable = typeof pause.registerWatcherClosable === "function" ? pause.registerWatcherClosable : registerWatcherClosable;
12
12
  } catch {}
13
13
  const loaderName = "zenbu-loader";
@@ -1,47 +1,10 @@
1
- import { n as resolveBuildConfig } from "./build-config-pbv0w4oN.mjs";
2
- import { createRequire } from "node:module";
3
- import fs from "node:fs";
1
+ import "node:fs";
4
2
  import os from "node:os";
5
3
  import path from "node:path";
6
- import { pathToFileURL } from "node:url";
7
4
  import crypto from "node:crypto";
8
5
  import fsp from "node:fs/promises";
9
6
  import { execFile } from "node:child_process";
10
7
  import { promisify } from "node:util";
11
- //#region src/cli/lib/load-build-config.ts
12
- const localRequire = createRequire(import.meta.url);
13
- const CONFIG_NAMES = [
14
- "zenbu.build.ts",
15
- "zenbu.build.mts",
16
- "zenbu.build.js",
17
- "zenbu.build.mjs"
18
- ];
19
- function findBuildConfig(projectDir) {
20
- for (const name of CONFIG_NAMES) {
21
- const candidate = path.join(projectDir, name);
22
- if (fs.existsSync(candidate)) return candidate;
23
- }
24
- throw new Error(`No zenbu.build config found at ${projectDir}. Expected one of: ${CONFIG_NAMES.join(", ")}`);
25
- }
26
- let tsxRegistered = null;
27
- function ensureTsxRegistered() {
28
- if (tsxRegistered) return tsxRegistered;
29
- tsxRegistered = (async () => {
30
- try {
31
- const tsxApi = localRequire("tsx/esm/api");
32
- if (typeof tsxApi.register === "function") tsxApi.register();
33
- } catch {}
34
- })();
35
- return tsxRegistered;
36
- }
37
- async function loadBuildConfig(configPath) {
38
- await ensureTsxRegistered();
39
- const mod = await import(pathToFileURL(path.resolve(configPath)).href);
40
- const config = mod.default ?? mod;
41
- if (!config || !Array.isArray(config.include)) throw new Error(`${path.basename(configPath)} must export a config object (via defineBuildConfig) with an 'include' array.`);
42
- return resolveBuildConfig(config);
43
- }
44
- //#endregion
45
8
  //#region src/cli/lib/mirror-sync.ts
46
9
  const execFile$1 = promisify(execFile);
47
10
  const SYNCED_FROM_RE = /\[synced from ([0-9a-f]{7,40})\]/;
@@ -242,68 +205,6 @@ async function push(options) {
242
205
  });
243
206
  }
244
207
  }
245
- /**
246
- * Initialize a local git working tree at `dir` whose `origin` is `mirrorUrl`
247
- * and whose HEAD is a fresh commit of `dir`'s contents. Used by `build:desktop`
248
- * to make the seed inside the .app a real git repo, so the user's apps-dir
249
- * after first launch can later `git pull` from the mirror.
250
- *
251
- * The commit SHA produced here is local-only; on the user's machine, after a
252
- * future `zen pull`, they'll fast-forward to whatever's actually on the
253
- * mirror.
254
- */
255
- async function initSeedRepo(options) {
256
- const branch = options.branch ?? "main";
257
- const env = {
258
- ...process.env,
259
- GIT_TERMINAL_PROMPT: "0"
260
- };
261
- if (!fs.existsSync(path.join(options.dir, ".git"))) await execFile$1("git", [
262
- "init",
263
- "-b",
264
- branch
265
- ], {
266
- cwd: options.dir,
267
- env
268
- });
269
- await execFile$1("git", [
270
- "remote",
271
- "remove",
272
- "origin"
273
- ], {
274
- cwd: options.dir,
275
- env
276
- }).catch(() => {});
277
- await execFile$1("git", [
278
- "remote",
279
- "add",
280
- "origin",
281
- options.mirrorUrl
282
- ], {
283
- cwd: options.dir,
284
- env
285
- });
286
- await execFile$1("git", ["add", "-A"], {
287
- cwd: options.dir,
288
- env
289
- });
290
- const localEnv = {
291
- ...env,
292
- GIT_AUTHOR_NAME: "zenbu",
293
- GIT_COMMITTER_NAME: "zenbu",
294
- GIT_AUTHOR_EMAIL: "zenbu@local",
295
- GIT_COMMITTER_EMAIL: "zenbu@local"
296
- };
297
- await execFile$1("git", [
298
- "commit",
299
- "--allow-empty",
300
- "-m",
301
- `seed ${options.sourceSha.slice(0, 7)}\n\n[synced from ${options.sourceSha}]\n`
302
- ], {
303
- cwd: options.dir,
304
- env: localEnv
305
- });
306
- }
307
208
  /** Hash a directory tree's content; used by `build:source` for the .sha file. */
308
209
  async function hashDir(dir) {
309
210
  const hash = crypto.createHash("sha256");
@@ -329,4 +230,4 @@ async function collectFiles(root, dir, out) {
329
230
  }
330
231
  }
331
232
  //#endregion
332
- export { findBuildConfig as a, push as i, init as n, loadBuildConfig as o, initSeedRepo as r, hashDir as t };
233
+ export { init as n, push as r, hashDir as t };
@@ -1,4 +1,5 @@
1
- import { a as findBuildConfig, i as push, n as init, o as loadBuildConfig } from "./mirror-sync-CodOnwkD.mjs";
1
+ import { n as loadBuildConfig, t as findBuildConfig } from "./load-build-config-DozuRhAN.mjs";
2
+ import { n as init, r as push } from "./mirror-sync-BN59kMCG.mjs";
2
3
  import fs from "node:fs";
3
4
  import path from "node:path";
4
5
  import fsp from "node:fs/promises";
@@ -41,14 +41,14 @@ function loadElectronApp() {
41
41
  return electron.app;
42
42
  }
43
43
  async function closeRegisteredWatchers() {
44
- await (await import("./pause-DvAUNmKn.mjs")).closeAllWatchers?.();
44
+ await (await import("@zenbujs/hmr/pause")).closeAllWatchers?.();
45
45
  }
46
46
  async function registerLoaders(tsconfig, projectRoot) {
47
47
  register(import.meta.resolve("@zenbujs/core/loaders/zenbu"));
48
48
  register$1({ tsconfig });
49
49
  process.env.ZENBU_ADVICE_ROOT = projectRoot;
50
50
  await import("./node-D4M19_mV.mjs");
51
- const dynohot = await import(pathToFileURL(createRequire(import.meta.url).resolve("dynohot/register")).href);
51
+ const dynohot = await import(pathToFileURL(createRequire(import.meta.url).resolve("@zenbujs/hmr/register")).href);
52
52
  if (typeof dynohot.register === "function") dynohot.register({ ignore: /[/\\](?:node_modules|dist)[/\\]/ });
53
53
  }
54
54
  async function setupGate() {
@@ -1,2 +1,2 @@
1
- import { t as setupGate } from "./setup-gate-BeD6WS6d.mjs";
1
+ import { t as setupGate } from "./setup-gate-BcoqWu8S.mjs";
2
2
  export { setupGate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenbujs/core",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -77,6 +77,14 @@
77
77
  "migrations",
78
78
  "package.json"
79
79
  ],
80
+ "scripts": {
81
+ "build": "node --max-old-space-size=8192 ./node_modules/tsdown/dist/run.mjs",
82
+ "dev": "tsdown --watch",
83
+ "link:types": "node ../zen/dist/bin.mjs link --types-config ./zenbu-types.config.json --registry ./types",
84
+ "db:generate": "node ../zen/dist/bin.mjs db generate --schema src/schema.ts --migrations ./migrations",
85
+ "typecheck": "tsc --noEmit -p tsconfig.json",
86
+ "lint": "eslint . --max-warnings=0"
87
+ },
80
88
  "peerDependencies": {
81
89
  "electron": "^42.0.0",
82
90
  "react": ">=18"
@@ -89,6 +97,7 @@
89
97
  "dependencies": {
90
98
  "@parcel/watcher": "^2.5.0",
91
99
  "@vitejs/plugin-react": "^5.0.0",
100
+ "@zenbujs/hmr": "workspace:*",
92
101
  "dugite": "^3.2.1",
93
102
  "effect": "^3.21.1",
94
103
  "electron-context-menu": "^4.1.2",
@@ -103,22 +112,13 @@
103
112
  "@types/node": "^22.0.0",
104
113
  "@types/react": "^19.0.0",
105
114
  "@types/ws": "^8.18.0",
115
+ "@zenbu/advice": "workspace:*",
116
+ "@zenbu/kyju": "workspace:*",
117
+ "@zenbu/lint": "workspace:*",
118
+ "@zenbu/zenrpc": "workspace:*",
106
119
  "electron": "^42.0.0",
107
120
  "eslint": "^9.0.0",
108
121
  "tsdown": "^0.21.10",
109
- "typescript": "^5.4.5",
110
- "@zenbu/advice": "0.0.0",
111
- "@zenbu/kyju": "0.0.0",
112
- "dynohot": "2.1.1",
113
- "@zenbu/lint": "0.0.0",
114
- "@zenbu/zenrpc": "0.0.0"
115
- },
116
- "scripts": {
117
- "build": "node --max-old-space-size=8192 ./node_modules/tsdown/dist/run.mjs",
118
- "dev": "tsdown --watch",
119
- "link:types": "node ../zen/dist/bin.mjs link --types-config ./zenbu-types.config.json --registry ./types",
120
- "db:generate": "node ../zen/dist/bin.mjs db generate --schema src/schema.ts --migrations ./migrations",
121
- "typecheck": "tsc --noEmit -p tsconfig.json",
122
- "lint": "eslint . --max-warnings=0"
122
+ "typescript": "^5.4.5"
123
123
  }
124
- }
124
+ }
package/LICENSE DELETED
@@ -1,11 +0,0 @@
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,52 +0,0 @@
1
- //#region ../dynohot/dist/runtime/pause.js
2
- /**
3
- * Registry of fs.watch-backed watchers that need to be `.close()`'d before
4
- * process exit. On macOS, `fs.watch` uses FSEvents.framework on a
5
- * background thread; if we `_exit(0)` (or skip shutdown hooks) while
6
- * watchers are still armed, FSEvents will try to dispatch events into a
7
- * dying V8 isolate → `napi_call_function` assertion → SIGABRT. Callers
8
- * (dynohot's FileWatcher, the kernel's zenbu-loader-hooks) register their
9
- * fs watchers here and the shell invokes `closeAllWatchers()` as part of
10
- * shutdown.
11
- */
12
- const WATCHER_SET_KEY = Symbol.for("dynohot.fileWatcher.closables");
13
- function getClosables() {
14
- const g = globalThis;
15
- let set = g[WATCHER_SET_KEY];
16
- if (!set) {
17
- set = /* @__PURE__ */ new Set();
18
- g[WATCHER_SET_KEY] = set;
19
- }
20
- return set;
21
- }
22
- /**
23
- * Register a closable (typically an `fs.FSWatcher`) for shutdown cleanup.
24
- * Returns a de-registration function — call it when the watcher is
25
- * closed normally, so the shutdown list doesn't grow unbounded.
26
- */
27
- function registerWatcherClosable(watcher) {
28
- const set = getClosables();
29
- set.add(watcher);
30
- return () => {
31
- set.delete(watcher);
32
- };
33
- }
34
- /**
35
- * Close every registered watcher. Call this synchronously immediately
36
- * before a hard process exit so FSEvents stops dispatching before the V8
37
- * isolate dies.
38
- */
39
- async function closeAllWatchers() {
40
- const set = getClosables();
41
- const all = [...set];
42
- set.clear();
43
- await Promise.allSettled(all.map((w) => {
44
- try {
45
- return w.close();
46
- } catch {
47
- return;
48
- }
49
- }));
50
- }
51
- //#endregion
52
- export { closeAllWatchers, registerWatcherClosable };
File without changes
File without changes
File without changes