@zenbujs/core 0.0.1

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 (94) hide show
  1. package/LICENSE +11 -0
  2. package/dist/advice-config-CjgkEf2E.mjs +135 -0
  3. package/dist/advice-config-Cy133IQP.mjs +2 -0
  4. package/dist/advice-runtime.d.mts +35 -0
  5. package/dist/advice-runtime.mjs +131 -0
  6. package/dist/advice.d.mts +36 -0
  7. package/dist/advice.mjs +2 -0
  8. package/dist/base-window-BUt8pwbw.mjs +94 -0
  9. package/dist/base-window-DEIAk618.mjs +2 -0
  10. package/dist/build-config-pbv0w4oN.mjs +17 -0
  11. package/dist/build-electron-B4Gd0Gi4.mjs +516 -0
  12. package/dist/build-source-_q1n1zTV.mjs +162 -0
  13. package/dist/chunk-Dm34NbLt.mjs +6 -0
  14. package/dist/cli/bin.d.mts +1 -0
  15. package/dist/cli/bin.mjs +88 -0
  16. package/dist/cli/build.d.mts +53 -0
  17. package/dist/cli/build.mjs +48 -0
  18. package/dist/cli-BLbQQIVB.mjs +8054 -0
  19. package/dist/config-CdVrW85P.mjs +59 -0
  20. package/dist/config-LK73dJmO.mjs +2 -0
  21. package/dist/db-ByKPbnP6.mjs +2 -0
  22. package/dist/db-DhuAJrye.mjs +531 -0
  23. package/dist/db.d.mts +16 -0
  24. package/dist/db.mjs +16 -0
  25. package/dist/dev-BuqklM0k.mjs +85 -0
  26. package/dist/env-bootstrap-BtVME-CU.d.mts +16 -0
  27. package/dist/env-bootstrap-rj7I-59x.mjs +53 -0
  28. package/dist/env-bootstrap.d.mts +2 -0
  29. package/dist/env-bootstrap.mjs +2 -0
  30. package/dist/http-IBcLzbYu.mjs +2 -0
  31. package/dist/index-Bhlbyrn7.d.mts +63 -0
  32. package/dist/index-CPZ5d6Hl.d.mts +442 -0
  33. package/dist/index-FtE8MXJ_.d.mts +1 -0
  34. package/dist/index.d.mts +6 -0
  35. package/dist/index.mjs +5 -0
  36. package/dist/launcher.mjs +173 -0
  37. package/dist/link-6roQ7Cn6.mjs +580 -0
  38. package/dist/loaders/zenbu.d.mts +22 -0
  39. package/dist/loaders/zenbu.mjs +267 -0
  40. package/dist/log-CyKv8hQg.mjs +20 -0
  41. package/dist/mirror-sync-CodOnwkD.mjs +332 -0
  42. package/dist/monorepo-CmGPHsVm.mjs +119 -0
  43. package/dist/node-D4M19_mV.mjs +5 -0
  44. package/dist/node-loader.d.mts +17 -0
  45. package/dist/node-loader.mjs +33 -0
  46. package/dist/pause-DvAUNmKn.mjs +52 -0
  47. package/dist/publish-source-BVgB62Zj.mjs +131 -0
  48. package/dist/react.d.mts +76 -0
  49. package/dist/react.mjs +291 -0
  50. package/dist/registry-Dh_e7HU1.d.mts +61 -0
  51. package/dist/registry.d.mts +2 -0
  52. package/dist/registry.mjs +1 -0
  53. package/dist/reloader-BCkLjDhS.mjs +2 -0
  54. package/dist/reloader-lLAJ3lqg.mjs +164 -0
  55. package/dist/renderer-host-Bg8QdeeH.mjs +1508 -0
  56. package/dist/renderer-host-DpvBPTHJ.mjs +2 -0
  57. package/dist/rpc-BwwQK6hD.mjs +71 -0
  58. package/dist/rpc-CqitnyR4.mjs +2 -0
  59. package/dist/rpc.d.mts +2 -0
  60. package/dist/rpc.mjs +2 -0
  61. package/dist/runtime-CjqDr8Yf.d.mts +109 -0
  62. package/dist/runtime-DUFKDIe4.mjs +409 -0
  63. package/dist/runtime.d.mts +2 -0
  64. package/dist/runtime.mjs +2 -0
  65. package/dist/schema-CIg4GzHQ.mjs +100 -0
  66. package/dist/schema-DMoSkwUx.d.mts +62 -0
  67. package/dist/schema-dGK6qkfR.mjs +28 -0
  68. package/dist/schema.d.mts +2 -0
  69. package/dist/schema.mjs +2 -0
  70. package/dist/server-BXwZEQ-n.mjs +66 -0
  71. package/dist/server-DjrZUbbu.mjs +2 -0
  72. package/dist/services/default.d.mts +11 -0
  73. package/dist/services/default.mjs +22 -0
  74. package/dist/services/index.d.mts +276 -0
  75. package/dist/services/index.mjs +7 -0
  76. package/dist/setup-gate-BeD6WS6d.mjs +110 -0
  77. package/dist/setup-gate-BqOzm7zp.d.mts +4 -0
  78. package/dist/setup-gate.d.mts +2 -0
  79. package/dist/setup-gate.mjs +2 -0
  80. package/dist/src-pELM4_iH.mjs +376 -0
  81. package/dist/trace-DCB7qFzT.mjs +10 -0
  82. package/dist/transform-DJH3vN4b.mjs +84041 -0
  83. package/dist/transport-BMSzG2-F.mjs +1045 -0
  84. package/dist/view-registry-BualWgAf.mjs +2 -0
  85. package/dist/vite-plugins-Bh3SCOw-.mjs +331 -0
  86. package/dist/vite.d.mts +68 -0
  87. package/dist/vite.mjs +2 -0
  88. package/dist/window-CM2a9Kyc.mjs +2 -0
  89. package/dist/window-CmmpCVX6.mjs +156 -0
  90. package/dist/write-9dRFczGJ.mjs +1248 -0
  91. package/migrations/0000_migration.ts +34 -0
  92. package/migrations/meta/0000_snapshot.json +18 -0
  93. package/migrations/meta/_journal.json +10 -0
  94. package/package.json +124 -0
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env node
2
+ //#region src/cli/bin.ts
3
+ const PUBLIC_SUBCOMMANDS = new Set([
4
+ "dev",
5
+ "build:source",
6
+ "build:electron",
7
+ "publish:source",
8
+ "link"
9
+ ]);
10
+ const INTERNAL_SUBCOMMANDS = new Set(["monorepo", "db"]);
11
+ function printUsage() {
12
+ console.log(`
13
+ zen — Zenbu CLI
14
+
15
+ Usage:
16
+ zen dev Run the local app in Electron with HMR
17
+ zen build:source Transform user TS into a portable seed
18
+ tree (default: .zenbu/build/seed)
19
+ zen build:electron [-- <eb args>] Stage seed + bundled bun/pnpm + launcher,
20
+ then invoke electron-builder against
21
+ the project's electron-builder config.
22
+ Pass-through args after \`--\` go to
23
+ electron-builder (e.g. \`-- --publish always\`).
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)
30
+ `);
31
+ }
32
+ async function main() {
33
+ const argv = process.argv.slice(2);
34
+ const first = argv[0];
35
+ if (!first || first === "help" || first === "--help" || first === "-h") {
36
+ printUsage();
37
+ return;
38
+ }
39
+ if (!PUBLIC_SUBCOMMANDS.has(first) && !INTERNAL_SUBCOMMANDS.has(first)) {
40
+ console.error(`zen: unknown command "${first}"`);
41
+ console.error(`run \`zen --help\` to see available commands`);
42
+ process.exit(1);
43
+ }
44
+ const rest = argv.slice(1);
45
+ switch (first) {
46
+ case "dev": {
47
+ const { runDev } = await import("../dev-BuqklM0k.mjs");
48
+ await runDev(rest);
49
+ return;
50
+ }
51
+ case "build:source": {
52
+ const { runBuildSource } = await import("../build-source-_q1n1zTV.mjs");
53
+ await runBuildSource(rest);
54
+ return;
55
+ }
56
+ case "build:electron": {
57
+ const { runBuildElectron } = await import("../build-electron-B4Gd0Gi4.mjs");
58
+ await runBuildElectron(rest);
59
+ return;
60
+ }
61
+ case "publish:source": {
62
+ const { runPublishSource } = await import("../publish-source-BVgB62Zj.mjs");
63
+ await runPublishSource(rest);
64
+ return;
65
+ }
66
+ case "link": {
67
+ const { runLink } = await import("../link-6roQ7Cn6.mjs");
68
+ await runLink(rest);
69
+ return;
70
+ }
71
+ case "monorepo": {
72
+ const { runMonorepo } = await import("../monorepo-CmGPHsVm.mjs");
73
+ await runMonorepo(rest);
74
+ return;
75
+ }
76
+ case "db": {
77
+ const { runDb } = await import("../db-DhuAJrye.mjs");
78
+ await runDb(rest);
79
+ return;
80
+ }
81
+ }
82
+ }
83
+ main().catch((err) => {
84
+ console.error(err);
85
+ process.exit(1);
86
+ });
87
+ //#endregion
88
+ export {};
@@ -0,0 +1,53 @@
1
+ //#region src/cli/lib/build-config.d.ts
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
53
+ export { type BuildConfig, type BundleConfig, type MirrorConfig, type ResolvedBuildConfig, type Transform, type TransformInput, type TransformOutput, defineBuildConfig, dropFiles, resolveBuildConfig, stripIfDisabled };
@@ -0,0 +1,48 @@
1
+ import { n as resolveBuildConfig, t as defineBuildConfig } from "../build-config-pbv0w4oN.mjs";
2
+ //#region src/cli/lib/transforms.ts
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
48
+ export { defineBuildConfig, dropFiles, resolveBuildConfig, stripIfDisabled };