@camstack/system 1.2.348 → 1.2.350

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 (68) hide show
  1. package/dist/addon-runner.js +2 -2
  2. package/dist/addon-runner.mjs +1 -1
  3. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  4. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  5. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  6. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  7. package/dist/builtins/alerts/alerts.addon.d.ts +8 -0
  8. package/dist/builtins/alerts/alerts.addon.js +146 -31
  9. package/dist/builtins/alerts/alerts.addon.mjs +146 -31
  10. package/dist/builtins/alerts/device-label.d.ts +8 -0
  11. package/dist/builtins/autotrack/index.js +1 -1
  12. package/dist/builtins/autotrack/index.mjs +1 -1
  13. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  14. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  15. package/dist/builtins/calendars/calendars.addon.js +1 -1
  16. package/dist/builtins/calendars/calendars.addon.mjs +1 -1
  17. package/dist/builtins/camera-grid/index.js +1 -1
  18. package/dist/builtins/camera-grid/index.mjs +1 -1
  19. package/dist/builtins/composer/composer.addon.js +2 -2
  20. package/dist/builtins/composer/composer.addon.mjs +2 -2
  21. package/dist/builtins/console-logging/index.js +1 -1
  22. package/dist/builtins/console-logging/index.mjs +1 -1
  23. package/dist/builtins/core-blocks/block-type-defs.d.ts +20 -5
  24. package/dist/builtins/core-blocks/core-blocks.addon.js +171 -26
  25. package/dist/builtins/core-blocks/core-blocks.addon.mjs +171 -26
  26. package/dist/builtins/device-manager/device-bindings-store.d.ts +3 -1
  27. package/dist/builtins/device-manager/device-manager.addon.js +4 -56
  28. package/dist/builtins/device-manager/device-manager.addon.mjs +4 -56
  29. package/dist/builtins/hub-forwarder/index.js +1 -1
  30. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  31. package/dist/builtins/liveness-monitor/liveness-checks.d.ts +7 -0
  32. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +8 -4
  33. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +8 -4
  34. package/dist/builtins/local-auth/local-auth.addon.js +1 -1
  35. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  36. package/dist/builtins/local-network/local-network.addon.js +1 -1
  37. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  38. package/dist/builtins/loki-logging/index.js +1 -1
  39. package/dist/builtins/loki-logging/index.mjs +1 -1
  40. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  41. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  42. package/dist/builtins/platform-probe/index.js +1 -1
  43. package/dist/builtins/platform-probe/index.mjs +1 -1
  44. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  45. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  46. package/dist/builtins/snapshot/index.js +1 -1
  47. package/dist/builtins/snapshot/index.mjs +1 -1
  48. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  49. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  50. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  51. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  52. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  53. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  54. package/dist/builtins/system-config/system-config.addon.js +1 -1
  55. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  56. package/dist/builtins/winston-logging/index.js +1 -1
  57. package/dist/builtins/winston-logging/index.mjs +1 -1
  58. package/dist/{child-cap-dispatch-k3dEOCnu.js → child-cap-dispatch-CYgHiMdj.js} +1 -1
  59. package/dist/{child-cap-dispatch-B2N_gWV-.mjs → child-cap-dispatch-zEt3rqy-.mjs} +1 -1
  60. package/dist/{composition-sources-C42s3_1h.js → composition-sources-DyxH-DLr.js} +1 -1
  61. package/dist/{composition-sources-D7cxA4Yv.mjs → composition-sources-d7zXAC70.mjs} +1 -1
  62. package/dist/{dist-BgV_QADz.js → dist-DZKm2EOp.js} +103 -3
  63. package/dist/{dist-nUn3vto_.mjs → dist-Di0aX2zy.mjs} +103 -3
  64. package/dist/index.js +2 -2
  65. package/dist/index.mjs +2 -2
  66. package/dist/{retired-settings-keys-D980hwnw.js → retired-settings-keys-BEY9Wjf1.js} +1 -1
  67. package/dist/{retired-settings-keys-pKNWq-CL.mjs → retired-settings-keys-jzB4iJpq.mjs} +1 -1
  68. package/package.json +1 -1
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-BgV_QADz.js");
6
+ const require_dist = require("../../dist-DZKm2EOp.js");
7
7
  let zod = require("zod");
8
8
  let _camstack_types_node = require("@camstack/types/node");
9
9
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { $ as cameraGridLayoutCapability, Gn as DeviceFeature, Jn as errMsg, Jt as memoizePinnedFfmpeg, Pn as buildFfmpegArgs, Tn as streamCatalogCapability, Yn as BaseAddon, Zt as motionCapability, ar as createEvent, bn as snapshotCapability, br as EventCategory, ft as declarationOwnerNodeId, i as BaseDevice, k as MOTION_CLOSE_AFTER_MS, lr as hydrateSchema, qn as DeviceType, v as DERIVED_CAMERA_SILENCED_CAP_NAMES, y as DeclaredDevices } from "../../dist-nUn3vto_.mjs";
1
+ import { $ as cameraGridLayoutCapability, Gn as DeviceFeature, Jn as errMsg, Jt as memoizePinnedFfmpeg, Pn as buildFfmpegArgs, Tn as streamCatalogCapability, Yn as BaseAddon, Zt as motionCapability, ar as createEvent, bn as snapshotCapability, br as EventCategory, ft as declarationOwnerNodeId, i as BaseDevice, k as MOTION_CLOSE_AFTER_MS, lr as hydrateSchema, qn as DeviceType, v as DERIVED_CAMERA_SILENCED_CAP_NAMES, y as DeclaredDevices } from "../../dist-Di0aX2zy.mjs";
2
2
  import { z } from "zod";
3
3
  import { FfmpegProcess } from "@camstack/types/node";
4
4
  import { join } from "node:path";
@@ -3,8 +3,8 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-BgV_QADz.js");
7
- const require_composition_sources = require("../../composition-sources-C42s3_1h.js");
6
+ const require_dist = require("../../dist-DZKm2EOp.js");
7
+ const require_composition_sources = require("../../composition-sources-DyxH-DLr.js");
8
8
  let zod = require("zod");
9
9
  //#region src/builtins/shared/device-state-changed.ts
10
10
  /** Structural narrowing helper for untrusted bus payloads. */
@@ -1,5 +1,5 @@
1
- import { Bn as compositionSliceKey, Fn as cloneStatefulExpressionMemory, Hn as createStatefulExpressionMemory, In as composedDeviceRef, Jn as errMsg, Ln as composedDeviceStableId, Nn as COMPOSER_ADDON_ID, Rn as compositionFeatureEnabled, Un as disarmRoseMemory, Vn as compositionSourceKey, Wn as toExpressionValue, X as buildCapabilityLookup, Yn as BaseAddon, ar as createEvent, br as EventCategory, c as COMPOSED_ITEM_FIXED_FIELDS, i as BaseDevice, nt as compositionFieldKey, qn as DeviceType, rn as planComposition, t as ALL_CAPABILITY_DEFINITIONS, tt as composerCapability, wt as evaluateCompositionField, y as DeclaredDevices, zn as compositionItemFieldPath } from "../../dist-nUn3vto_.mjs";
2
- import { n as normalizedNativeOwner } from "../../composition-sources-D7cxA4Yv.mjs";
1
+ import { Bn as compositionSliceKey, Fn as cloneStatefulExpressionMemory, Hn as createStatefulExpressionMemory, In as composedDeviceRef, Jn as errMsg, Ln as composedDeviceStableId, Nn as COMPOSER_ADDON_ID, Rn as compositionFeatureEnabled, Un as disarmRoseMemory, Vn as compositionSourceKey, Wn as toExpressionValue, X as buildCapabilityLookup, Yn as BaseAddon, ar as createEvent, br as EventCategory, c as COMPOSED_ITEM_FIXED_FIELDS, i as BaseDevice, nt as compositionFieldKey, qn as DeviceType, rn as planComposition, t as ALL_CAPABILITY_DEFINITIONS, tt as composerCapability, wt as evaluateCompositionField, y as DeclaredDevices, zn as compositionItemFieldPath } from "../../dist-Di0aX2zy.mjs";
2
+ import { n as normalizedNativeOwner } from "../../composition-sources-d7zXAC70.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/builtins/shared/device-state-changed.ts
5
5
  /** Structural narrowing helper for untrusted bus payloads. */
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-BgV_QADz.js");
6
+ const require_dist = require("../../dist-DZKm2EOp.js");
7
7
  const require_formatter = require("../../formatter-DqAKDlvN.js");
8
8
  //#region src/builtins/console-logging/console-destination.ts
9
9
  var LEVEL_RANK = {
@@ -1,4 +1,4 @@
1
- import { Ut as logDestinationCapability, Yn as BaseAddon } from "../../dist-nUn3vto_.mjs";
1
+ import { Ut as logDestinationCapability, Yn as BaseAddon } from "../../dist-Di0aX2zy.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
3
3
  //#region src/builtins/console-logging/console-destination.ts
4
4
  var LEVEL_RANK = {
@@ -4,11 +4,26 @@ export interface BlockTypeLib {
4
4
  readonly content: string;
5
5
  }
6
6
  /**
7
- * Read every `.d.ts` under the installed `@camstack/types` dist.
7
+ * Minimal Node surface for block authorship. Not `@types/node` — that package
8
+ * is a build-time dep and is not in the production closure. This is enough
9
+ * that Save is not refused for the builtins real scripts use (`process`,
10
+ * `node:net`, `node:fs`, `node:path`, `node:http(s)`, `node:crypto`, timers).
11
+ * Widen when a block hits a new missing name; do not paste the full DefinitelyTyped
12
+ * tree into every getTypeDefs response.
13
+ */
14
+ export declare const BLOCK_NODE_AMBIENT: string;
15
+ /**
16
+ * Read every declaration a block editor needs: `@camstack/types`, `zod`, and
17
+ * the Node ambient.
8
18
  *
9
- * Best-effort by design: a node that cannot find them serves an EMPTY list, and
10
- * the editor then registers an empty lib set rather than keeping a stale one —
11
- * so an author sees "no types" instead of validating against a contract that
12
- * has moved.
19
+ * Best-effort by design: a node that cannot find `@camstack/types` serves an
20
+ * EMPTY types list (plus whatever else resolved), and the editor then registers
21
+ * an empty lib set rather than keeping a stale one — so an author sees "no
22
+ * types" instead of validating against a contract that has moved.
13
23
  */
14
24
  export declare function loadBlockTypeDefs(logger: IScopedLogger): Promise<readonly BlockTypeLib[]>;
25
+ /**
26
+ * Resolve a package's directory that holds `index.d.ts` (the types dist root).
27
+ * Exported for the test that pins createRequire-over-cwd.
28
+ */
29
+ export declare function resolveTypesDist(): Promise<string | null>;
@@ -1,13 +1,14 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("../../chunk-Cek0wNdY.js");
3
- const require_dist = require("../../dist-BgV_QADz.js");
4
- const require_composition_sources = require("../../composition-sources-C42s3_1h.js");
3
+ const require_dist = require("../../dist-DZKm2EOp.js");
4
+ const require_composition_sources = require("../../composition-sources-DyxH-DLr.js");
5
5
  let node_crypto = require("node:crypto");
6
6
  let _camstack_types_node = require("@camstack/types/node");
7
7
  let node_fs_promises = require("node:fs/promises");
8
8
  node_fs_promises = require_chunk.__toESM(node_fs_promises);
9
9
  let node_path = require("node:path");
10
10
  node_path = require_chunk.__toESM(node_path);
11
+ let node_module = require("node:module");
11
12
  let node_os = require("node:os");
12
13
  node_os = require_chunk.__toESM(node_os);
13
14
  let node_url = require("node:url");
@@ -570,37 +571,180 @@ var BlockSettingsStore = class {
570
571
  * `file:///node_modules/@camstack/types/…` loads and then resolves NOTHING —
571
572
  * the failure that looks most like success, because the editor keeps working
572
573
  * and simply stops knowing anything.
574
+ *
575
+ * **Resolution must not use `import.meta.resolve`.** The hub loads the CJS
576
+ * build of this package; the bundler erases `import.meta` to `{}`, so
577
+ * `import.meta.resolve?.('@camstack/types')` is always undefined and the old
578
+ * fallback — `process.cwd()/node_modules/@camstack/types` — wins. On a live
579
+ * hub `cwd` is the image seed (`/opt/camstack-hub`), not the active data-root
580
+ * closure that actually runs. That served a months-old `ConfigSelectField`
581
+ * without `optionsFrom` while `/data/server-root/current` already had it, and
582
+ * Monaco blocked Save on a property the runtime hydrate already understood.
583
+ * `createRequire(import.meta.url)` survives the CJS emit (becomes
584
+ * `createRequire(pathToFileURL(__filename))`) and walks from THIS module to
585
+ * the sibling `@camstack/types` the process loaded.
586
+ *
587
+ * Beside `@camstack/types`, the editor also gets `zod` (real package `.d.ts`)
588
+ * and a small Node ambient. Blocks are Node processes; without those, a
589
+ * legitimate `import { z } from 'zod'` / `import net from 'node:net'` /
590
+ * `process.env` is a Save-blocking Error even though esbuild will emit and
591
+ * the runner will execute it.
592
+ */
593
+ /** Where Monaco must think `@camstack/types` lives for imports to resolve. */
594
+ var TYPES_VIRTUAL_ROOT = "file:///node_modules/@camstack/types";
595
+ /** Where Monaco must think `zod` lives. */
596
+ var ZOD_VIRTUAL_ROOT = "file:///node_modules/zod";
597
+ /**
598
+ * Virtual path for the Node ambient. Monaco's Node moduleResolution looks for
599
+ * `@types/node` under `node_modules`; a single index is enough for `node:*`
600
+ * ambient modules declared inside it.
573
601
  */
574
- /** Where Monaco must think the files live for `@camstack/types` to resolve. */
575
- var VIRTUAL_ROOT = "file:///node_modules/@camstack/types";
602
+ var NODE_AMBIENT_PATH = "file:///node_modules/@types/node/index.d.ts";
576
603
  /**
577
- * Read every `.d.ts` under the installed `@camstack/types` dist.
604
+ * Minimal Node surface for block authorship. Not `@types/node` — that package
605
+ * is a build-time dep and is not in the production closure. This is enough
606
+ * that Save is not refused for the builtins real scripts use (`process`,
607
+ * `node:net`, `node:fs`, `node:path`, `node:http(s)`, `node:crypto`, timers).
608
+ * Widen when a block hits a new missing name; do not paste the full DefinitelyTyped
609
+ * tree into every getTypeDefs response.
610
+ */
611
+ var BLOCK_NODE_AMBIENT = `
612
+ declare const process: {
613
+ env: Record<string, string | undefined>
614
+ cwd(): string
615
+ exit(code?: number): never
616
+ stdout: { write(chunk: string): boolean }
617
+ stderr: { write(chunk: string): boolean }
618
+ }
619
+
620
+ declare function setTimeout(handler: (...args: unknown[]) => void, ms?: number, ...args: unknown[]): unknown
621
+ declare function clearTimeout(handle: unknown): void
622
+ declare function setInterval(handler: (...args: unknown[]) => void, ms?: number, ...args: unknown[]): unknown
623
+ declare function clearInterval(handle: unknown): void
624
+ declare function setImmediate(handler: (...args: unknown[]) => void, ...args: unknown[]): unknown
625
+ declare function clearImmediate(handle: unknown): void
626
+
627
+ declare const Buffer: {
628
+ from(data: string | ArrayBuffer | Uint8Array, encoding?: string): Uint8Array
629
+ concat(list: readonly Uint8Array[]): Uint8Array
630
+ alloc(size: number): Uint8Array
631
+ isBuffer(value: unknown): value is Uint8Array
632
+ }
633
+
634
+ declare module 'node:net' {
635
+ export interface Socket {
636
+ write(data: string | Uint8Array): boolean
637
+ end(data?: string | Uint8Array): void
638
+ destroy(): void
639
+ on(event: string, listener: (...args: unknown[]) => void): this
640
+ once(event: string, listener: (...args: unknown[]) => void): this
641
+ setTimeout(ms: number, callback?: () => void): this
642
+ remoteAddress?: string
643
+ remotePort?: number
644
+ }
645
+ export interface Server {
646
+ listen(port: number, host?: string, listeningListener?: () => void): this
647
+ close(callback?: (err?: Error) => void): this
648
+ on(event: string, listener: (...args: unknown[]) => void): this
649
+ address(): { port: number; family: string; address: string } | string | null
650
+ }
651
+ export function createServer(connectionListener?: (socket: Socket) => void): Server
652
+ export function connect(
653
+ options: { host?: string; port: number } | number,
654
+ connectionListener?: () => void,
655
+ ): Socket
656
+ const net: {
657
+ createServer: typeof createServer
658
+ connect: typeof connect
659
+ }
660
+ export default net
661
+ }
662
+
663
+ declare module 'node:fs' {
664
+ const fs: Record<string, unknown>
665
+ export default fs
666
+ }
667
+ declare module 'node:fs/promises' {
668
+ const fs: Record<string, unknown>
669
+ export default fs
670
+ }
671
+ declare module 'node:path' {
672
+ const path: Record<string, unknown>
673
+ export default path
674
+ }
675
+ declare module 'node:http' {
676
+ const http: Record<string, unknown>
677
+ export default http
678
+ }
679
+ declare module 'node:https' {
680
+ const https: Record<string, unknown>
681
+ export default https
682
+ }
683
+ declare module 'node:crypto' {
684
+ const crypto: Record<string, unknown>
685
+ export default crypto
686
+ }
687
+ declare module 'node:url' {
688
+ const url: Record<string, unknown>
689
+ export default url
690
+ }
691
+ declare module 'node:os' {
692
+ const os: Record<string, unknown>
693
+ export default os
694
+ }
695
+ declare module 'node:child_process' {
696
+ const cp: Record<string, unknown>
697
+ export default cp
698
+ }
699
+ declare module 'node:stream' {
700
+ const stream: Record<string, unknown>
701
+ export default stream
702
+ }
703
+ declare module 'node:buffer' {
704
+ export { Buffer }
705
+ }
706
+ `.trim();
707
+ /**
708
+ * Read every declaration a block editor needs: `@camstack/types`, `zod`, and
709
+ * the Node ambient.
578
710
  *
579
- * Best-effort by design: a node that cannot find them serves an EMPTY list, and
580
- * the editor then registers an empty lib set rather than keeping a stale one —
581
- * so an author sees "no types" instead of validating against a contract that
582
- * has moved.
711
+ * Best-effort by design: a node that cannot find `@camstack/types` serves an
712
+ * EMPTY types list (plus whatever else resolved), and the editor then registers
713
+ * an empty lib set rather than keeping a stale one — so an author sees "no
714
+ * types" instead of validating against a contract that has moved.
583
715
  */
584
716
  async function loadBlockTypeDefs(logger) {
585
- const root = await resolveTypesDist();
586
- if (root === null) {
587
- logger.warn("core-blocks: @camstack/types declarations not found — the editor gets no types");
588
- return [];
589
- }
590
717
  const out = [];
591
- await walk(root, root, out);
718
+ const typesRoot = await resolvePackageDist("@camstack/types");
719
+ if (typesRoot === null) logger.warn("core-blocks: @camstack/types declarations not found — the editor gets no types");
720
+ else await walkDts(typesRoot, typesRoot, TYPES_VIRTUAL_ROOT, out);
721
+ const zodRoot = await resolvePackageRoot("zod");
722
+ if (zodRoot === null) logger.warn("core-blocks: zod declarations not found — blocks that import zod will fail Monaco");
723
+ else await walkDts(zodRoot, zodRoot, ZOD_VIRTUAL_ROOT, out);
724
+ out.push({
725
+ filePath: NODE_AMBIENT_PATH,
726
+ content: BLOCK_NODE_AMBIENT
727
+ });
592
728
  return out;
593
729
  }
594
- async function resolveTypesDist() {
730
+ async function resolvePackageDist(pkg) {
731
+ const root = await resolvePackageRoot(pkg);
732
+ if (root === null) return null;
733
+ if (await exists(node_path.join(root, "index.d.ts"))) return root;
734
+ const dist = node_path.join(root, "dist");
735
+ if (await exists(node_path.join(dist, "index.d.ts"))) return dist;
736
+ return null;
737
+ }
738
+ async function resolvePackageRoot(pkg) {
595
739
  try {
596
- const entry = await {}.resolve?.("@camstack/types");
597
- if (typeof entry === "string") {
598
- const dir = node_path.dirname(entry.replace("file://", ""));
599
- if (await exists(node_path.join(dir, "index.d.ts"))) return dir;
600
- }
740
+ const entry = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href).resolve(pkg);
741
+ return node_path.dirname(entry);
601
742
  } catch {}
602
- const guess = node_path.resolve(process.cwd(), "node_modules/@camstack/types/dist");
603
- return await exists(guess) ? guess : null;
743
+ const guess = node_path.resolve(process.cwd(), "node_modules", pkg);
744
+ if (await exists(node_path.join(guess, "package.json"))) return guess;
745
+ const guessDist = node_path.resolve(process.cwd(), "node_modules", pkg, "dist");
746
+ if (await exists(node_path.join(guessDist, "index.d.ts"))) return guessDist;
747
+ return null;
604
748
  }
605
749
  async function exists(p) {
606
750
  try {
@@ -610,19 +754,20 @@ async function exists(p) {
610
754
  return false;
611
755
  }
612
756
  }
613
- async function walk(root, dir, out) {
757
+ async function walkDts(root, dir, virtualRoot, out) {
614
758
  const entries = await node_fs_promises.readdir(dir, { withFileTypes: true });
615
759
  for (const entry of entries) {
616
760
  const full = node_path.join(dir, entry.name);
617
761
  if (entry.isDirectory()) {
618
- await walk(root, full, out);
762
+ if (entry.name === "node_modules") continue;
763
+ await walkDts(root, full, virtualRoot, out);
619
764
  continue;
620
765
  }
621
766
  if (!entry.name.endsWith(".d.ts")) continue;
622
767
  const content = await node_fs_promises.readFile(full, "utf-8");
623
768
  const relative = node_path.relative(root, full).split(node_path.sep).join("/");
624
769
  out.push({
625
- filePath: `${VIRTUAL_ROOT}/${relative}`,
770
+ filePath: `${virtualRoot}/${relative}`,
626
771
  content
627
772
  });
628
773
  }
@@ -1,5 +1,6 @@
1
- import { In as composedDeviceRef, Jn as errMsg, On as validateComposition, Qt as normalizeCoreBlockWrite, Vn as compositionSourceKey, X as buildCapabilityLookup, Yn as BaseAddon, at as coreBlockComposition, cn as replacedFieldKeys, ct as coreBlocksCapability, d as CORE_BLOCK_ADDON_PREFIX, dn as resolveCoreBlockFiles, gt as describeComposableCaps, it as coreBlockAddonId, l as COMPOSER_RUNNER_ID, lr as hydrateSchema, ot as coreBlockIdFromAddonId, p as CoreBlockSchema, rn as planComposition, rt as compositionSourceRefs, st as coreBlockSourceKind, t as ALL_CAPABILITY_DEFINITIONS, u as CORE_BLOCKS_ADDON_ID, un as resolveCoreBlockEntry, y as DeclaredDevices } from "../../dist-nUn3vto_.mjs";
2
- import { t as describeCompositionSources } from "../../composition-sources-D7cxA4Yv.mjs";
1
+ import { In as composedDeviceRef, Jn as errMsg, On as validateComposition, Qt as normalizeCoreBlockWrite, Vn as compositionSourceKey, X as buildCapabilityLookup, Yn as BaseAddon, at as coreBlockComposition, cn as replacedFieldKeys, ct as coreBlocksCapability, d as CORE_BLOCK_ADDON_PREFIX, dn as resolveCoreBlockFiles, gt as describeComposableCaps, it as coreBlockAddonId, l as COMPOSER_RUNNER_ID, lr as hydrateSchema, ot as coreBlockIdFromAddonId, p as CoreBlockSchema, rn as planComposition, rt as compositionSourceRefs, st as coreBlockSourceKind, t as ALL_CAPABILITY_DEFINITIONS, u as CORE_BLOCKS_ADDON_ID, un as resolveCoreBlockEntry, y as DeclaredDevices } from "../../dist-Di0aX2zy.mjs";
2
+ import { t as describeCompositionSources } from "../../composition-sources-d7zXAC70.mjs";
3
+ import { createRequire } from "node:module";
3
4
  import { randomUUID } from "node:crypto";
4
5
  import { customizationBlockName } from "@camstack/types/node";
5
6
  import * as fs from "node:fs/promises";
@@ -565,37 +566,180 @@ var BlockSettingsStore = class {
565
566
  * `file:///node_modules/@camstack/types/…` loads and then resolves NOTHING —
566
567
  * the failure that looks most like success, because the editor keeps working
567
568
  * and simply stops knowing anything.
569
+ *
570
+ * **Resolution must not use `import.meta.resolve`.** The hub loads the CJS
571
+ * build of this package; the bundler erases `import.meta` to `{}`, so
572
+ * `import.meta.resolve?.('@camstack/types')` is always undefined and the old
573
+ * fallback — `process.cwd()/node_modules/@camstack/types` — wins. On a live
574
+ * hub `cwd` is the image seed (`/opt/camstack-hub`), not the active data-root
575
+ * closure that actually runs. That served a months-old `ConfigSelectField`
576
+ * without `optionsFrom` while `/data/server-root/current` already had it, and
577
+ * Monaco blocked Save on a property the runtime hydrate already understood.
578
+ * `createRequire(import.meta.url)` survives the CJS emit (becomes
579
+ * `createRequire(pathToFileURL(__filename))`) and walks from THIS module to
580
+ * the sibling `@camstack/types` the process loaded.
581
+ *
582
+ * Beside `@camstack/types`, the editor also gets `zod` (real package `.d.ts`)
583
+ * and a small Node ambient. Blocks are Node processes; without those, a
584
+ * legitimate `import { z } from 'zod'` / `import net from 'node:net'` /
585
+ * `process.env` is a Save-blocking Error even though esbuild will emit and
586
+ * the runner will execute it.
587
+ */
588
+ /** Where Monaco must think `@camstack/types` lives for imports to resolve. */
589
+ var TYPES_VIRTUAL_ROOT = "file:///node_modules/@camstack/types";
590
+ /** Where Monaco must think `zod` lives. */
591
+ var ZOD_VIRTUAL_ROOT = "file:///node_modules/zod";
592
+ /**
593
+ * Virtual path for the Node ambient. Monaco's Node moduleResolution looks for
594
+ * `@types/node` under `node_modules`; a single index is enough for `node:*`
595
+ * ambient modules declared inside it.
568
596
  */
569
- /** Where Monaco must think the files live for `@camstack/types` to resolve. */
570
- var VIRTUAL_ROOT = "file:///node_modules/@camstack/types";
597
+ var NODE_AMBIENT_PATH = "file:///node_modules/@types/node/index.d.ts";
571
598
  /**
572
- * Read every `.d.ts` under the installed `@camstack/types` dist.
599
+ * Minimal Node surface for block authorship. Not `@types/node` — that package
600
+ * is a build-time dep and is not in the production closure. This is enough
601
+ * that Save is not refused for the builtins real scripts use (`process`,
602
+ * `node:net`, `node:fs`, `node:path`, `node:http(s)`, `node:crypto`, timers).
603
+ * Widen when a block hits a new missing name; do not paste the full DefinitelyTyped
604
+ * tree into every getTypeDefs response.
605
+ */
606
+ var BLOCK_NODE_AMBIENT = `
607
+ declare const process: {
608
+ env: Record<string, string | undefined>
609
+ cwd(): string
610
+ exit(code?: number): never
611
+ stdout: { write(chunk: string): boolean }
612
+ stderr: { write(chunk: string): boolean }
613
+ }
614
+
615
+ declare function setTimeout(handler: (...args: unknown[]) => void, ms?: number, ...args: unknown[]): unknown
616
+ declare function clearTimeout(handle: unknown): void
617
+ declare function setInterval(handler: (...args: unknown[]) => void, ms?: number, ...args: unknown[]): unknown
618
+ declare function clearInterval(handle: unknown): void
619
+ declare function setImmediate(handler: (...args: unknown[]) => void, ...args: unknown[]): unknown
620
+ declare function clearImmediate(handle: unknown): void
621
+
622
+ declare const Buffer: {
623
+ from(data: string | ArrayBuffer | Uint8Array, encoding?: string): Uint8Array
624
+ concat(list: readonly Uint8Array[]): Uint8Array
625
+ alloc(size: number): Uint8Array
626
+ isBuffer(value: unknown): value is Uint8Array
627
+ }
628
+
629
+ declare module 'node:net' {
630
+ export interface Socket {
631
+ write(data: string | Uint8Array): boolean
632
+ end(data?: string | Uint8Array): void
633
+ destroy(): void
634
+ on(event: string, listener: (...args: unknown[]) => void): this
635
+ once(event: string, listener: (...args: unknown[]) => void): this
636
+ setTimeout(ms: number, callback?: () => void): this
637
+ remoteAddress?: string
638
+ remotePort?: number
639
+ }
640
+ export interface Server {
641
+ listen(port: number, host?: string, listeningListener?: () => void): this
642
+ close(callback?: (err?: Error) => void): this
643
+ on(event: string, listener: (...args: unknown[]) => void): this
644
+ address(): { port: number; family: string; address: string } | string | null
645
+ }
646
+ export function createServer(connectionListener?: (socket: Socket) => void): Server
647
+ export function connect(
648
+ options: { host?: string; port: number } | number,
649
+ connectionListener?: () => void,
650
+ ): Socket
651
+ const net: {
652
+ createServer: typeof createServer
653
+ connect: typeof connect
654
+ }
655
+ export default net
656
+ }
657
+
658
+ declare module 'node:fs' {
659
+ const fs: Record<string, unknown>
660
+ export default fs
661
+ }
662
+ declare module 'node:fs/promises' {
663
+ const fs: Record<string, unknown>
664
+ export default fs
665
+ }
666
+ declare module 'node:path' {
667
+ const path: Record<string, unknown>
668
+ export default path
669
+ }
670
+ declare module 'node:http' {
671
+ const http: Record<string, unknown>
672
+ export default http
673
+ }
674
+ declare module 'node:https' {
675
+ const https: Record<string, unknown>
676
+ export default https
677
+ }
678
+ declare module 'node:crypto' {
679
+ const crypto: Record<string, unknown>
680
+ export default crypto
681
+ }
682
+ declare module 'node:url' {
683
+ const url: Record<string, unknown>
684
+ export default url
685
+ }
686
+ declare module 'node:os' {
687
+ const os: Record<string, unknown>
688
+ export default os
689
+ }
690
+ declare module 'node:child_process' {
691
+ const cp: Record<string, unknown>
692
+ export default cp
693
+ }
694
+ declare module 'node:stream' {
695
+ const stream: Record<string, unknown>
696
+ export default stream
697
+ }
698
+ declare module 'node:buffer' {
699
+ export { Buffer }
700
+ }
701
+ `.trim();
702
+ /**
703
+ * Read every declaration a block editor needs: `@camstack/types`, `zod`, and
704
+ * the Node ambient.
573
705
  *
574
- * Best-effort by design: a node that cannot find them serves an EMPTY list, and
575
- * the editor then registers an empty lib set rather than keeping a stale one —
576
- * so an author sees "no types" instead of validating against a contract that
577
- * has moved.
706
+ * Best-effort by design: a node that cannot find `@camstack/types` serves an
707
+ * EMPTY types list (plus whatever else resolved), and the editor then registers
708
+ * an empty lib set rather than keeping a stale one — so an author sees "no
709
+ * types" instead of validating against a contract that has moved.
578
710
  */
579
711
  async function loadBlockTypeDefs(logger) {
580
- const root = await resolveTypesDist();
581
- if (root === null) {
582
- logger.warn("core-blocks: @camstack/types declarations not found — the editor gets no types");
583
- return [];
584
- }
585
712
  const out = [];
586
- await walk(root, root, out);
713
+ const typesRoot = await resolvePackageDist("@camstack/types");
714
+ if (typesRoot === null) logger.warn("core-blocks: @camstack/types declarations not found — the editor gets no types");
715
+ else await walkDts(typesRoot, typesRoot, TYPES_VIRTUAL_ROOT, out);
716
+ const zodRoot = await resolvePackageRoot("zod");
717
+ if (zodRoot === null) logger.warn("core-blocks: zod declarations not found — blocks that import zod will fail Monaco");
718
+ else await walkDts(zodRoot, zodRoot, ZOD_VIRTUAL_ROOT, out);
719
+ out.push({
720
+ filePath: NODE_AMBIENT_PATH,
721
+ content: BLOCK_NODE_AMBIENT
722
+ });
587
723
  return out;
588
724
  }
589
- async function resolveTypesDist() {
725
+ async function resolvePackageDist(pkg) {
726
+ const root = await resolvePackageRoot(pkg);
727
+ if (root === null) return null;
728
+ if (await exists(path$1.join(root, "index.d.ts"))) return root;
729
+ const dist = path$1.join(root, "dist");
730
+ if (await exists(path$1.join(dist, "index.d.ts"))) return dist;
731
+ return null;
732
+ }
733
+ async function resolvePackageRoot(pkg) {
590
734
  try {
591
- const entry = await import.meta.resolve?.("@camstack/types");
592
- if (typeof entry === "string") {
593
- const dir = path$1.dirname(entry.replace("file://", ""));
594
- if (await exists(path$1.join(dir, "index.d.ts"))) return dir;
595
- }
735
+ const entry = createRequire(import.meta.url).resolve(pkg);
736
+ return path$1.dirname(entry);
596
737
  } catch {}
597
- const guess = path$1.resolve(process.cwd(), "node_modules/@camstack/types/dist");
598
- return await exists(guess) ? guess : null;
738
+ const guess = path$1.resolve(process.cwd(), "node_modules", pkg);
739
+ if (await exists(path$1.join(guess, "package.json"))) return guess;
740
+ const guessDist = path$1.resolve(process.cwd(), "node_modules", pkg, "dist");
741
+ if (await exists(path$1.join(guessDist, "index.d.ts"))) return guessDist;
742
+ return null;
599
743
  }
600
744
  async function exists(p) {
601
745
  try {
@@ -605,19 +749,20 @@ async function exists(p) {
605
749
  return false;
606
750
  }
607
751
  }
608
- async function walk(root, dir, out) {
752
+ async function walkDts(root, dir, virtualRoot, out) {
609
753
  const entries = await fs.readdir(dir, { withFileTypes: true });
610
754
  for (const entry of entries) {
611
755
  const full = path$1.join(dir, entry.name);
612
756
  if (entry.isDirectory()) {
613
- await walk(root, full, out);
757
+ if (entry.name === "node_modules") continue;
758
+ await walkDts(root, full, virtualRoot, out);
614
759
  continue;
615
760
  }
616
761
  if (!entry.name.endsWith(".d.ts")) continue;
617
762
  const content = await fs.readFile(full, "utf-8");
618
763
  const relative = path$1.relative(root, full).split(path$1.sep).join("/");
619
764
  out.push({
620
- filePath: `${VIRTUAL_ROOT}/${relative}`,
765
+ filePath: `${virtualRoot}/${relative}`,
621
766
  content
622
767
  });
623
768
  }
@@ -256,7 +256,9 @@ export interface ListDeviceIdsByCapsInput {
256
256
  export declare function listDeviceIdsByCaps(deps: BindingsDeps, input: ListDeviceIdsByCapsInput): Promise<number[]>;
257
257
  /**
258
258
  * Resolve a numeric deviceId to a stableId via persisted meta.
259
- * Used only by the device-identity section of the device-details
259
+ * Used by callers that need a persisted stableId when the live registry
260
+ * does not hold the device (cross-process / mid-restart). Formerly fed
261
+ * the Config Identity section; that section left Config for Overview.
260
262
  * aggregator (see `buildBaseDeviceSection`) to surface the stableId as
261
263
  * a readonly display field. All runtime/registry lookups are keyed by
262
264
  * numeric deviceId; this helper is display-only.