@zenbujs/core 0.0.1 → 0.0.3

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.3",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -97,7 +97,8 @@
97
97
  "tsx": "^4.21.0",
98
98
  "vite": "^6.0.0",
99
99
  "ws": "^8.18.0",
100
- "zod": "^4.3.6"
100
+ "zod": "^4.3.6",
101
+ "@zenbujs/hmr": "0.0.1"
101
102
  },
102
103
  "devDependencies": {
103
104
  "@types/node": "^22.0.0",
@@ -107,10 +108,9 @@
107
108
  "eslint": "^9.0.0",
108
109
  "tsdown": "^0.21.10",
109
110
  "typescript": "^5.4.5",
110
- "@zenbu/advice": "0.0.0",
111
111
  "@zenbu/kyju": "0.0.0",
112
- "dynohot": "2.1.1",
113
112
  "@zenbu/lint": "0.0.0",
113
+ "@zenbu/advice": "0.0.0",
114
114
  "@zenbu/zenrpc": "0.0.0"
115
115
  },
116
116
  "scripts": {
@@ -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