@camstack/system 1.2.2 → 1.2.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.
Files changed (50) hide show
  1. package/dist/addon-runner.js +2 -2
  2. package/dist/addon-runner.mjs +2 -2
  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.js +1 -1
  8. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  9. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  10. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  11. package/dist/builtins/console-logging/index.js +1 -1
  12. package/dist/builtins/console-logging/index.mjs +1 -1
  13. package/dist/builtins/device-manager/device-manager.addon.js +1 -1
  14. package/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  15. package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
  16. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
  17. package/dist/builtins/hub-forwarder/index.js +1 -1
  18. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  19. package/dist/builtins/local-auth/local-auth.addon.js +1 -1
  20. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  21. package/dist/builtins/local-network/local-network.addon.js +1 -1
  22. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  23. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  24. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  25. package/dist/builtins/platform-probe/index.js +1 -1
  26. package/dist/builtins/platform-probe/index.mjs +1 -1
  27. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  28. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  29. package/dist/builtins/snapshot/index.js +1 -1
  30. package/dist/builtins/snapshot/index.mjs +1 -1
  31. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  32. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  33. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +1 -1
  34. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +1 -1
  35. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  36. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  37. package/dist/builtins/system-config/system-config.addon.js +1 -1
  38. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  39. package/dist/builtins/winston-logging/index.js +1 -1
  40. package/dist/builtins/winston-logging/index.mjs +1 -1
  41. package/dist/{dist-DTTTjPCL.mjs → dist-72yufD8v.mjs} +2 -1
  42. package/dist/{dist-CkdNC8US.js → dist-CQZxGJ8u.js} +2 -1
  43. package/dist/index.d.ts +1 -0
  44. package/dist/index.js +163 -21
  45. package/dist/index.mjs +156 -16
  46. package/dist/kernel/deps/ensure-native-prebuilds.d.ts +36 -0
  47. package/dist/kernel/deps/manifest-native-deps.d.ts +17 -0
  48. package/dist/{manifest-python-deps-s_-uULmp.mjs → manifest-python-deps-6__QF75g.mjs} +88 -2
  49. package/dist/{manifest-python-deps-DRq5MreI.js → manifest-python-deps-Cd7ocUBi.js} +93 -1
  50. package/package.json +1 -1
@@ -23,3 +23,20 @@ import { IScopedLogger } from '@camstack/types';
23
23
  * otherwise).
24
24
  */
25
25
  export declare function installManifestNativeDeps(addonDir: string, pkgRaw: Record<string, unknown>, logger: IScopedLogger, registry?: string, npmCacheDir?: string): Promise<void>;
26
+ /**
27
+ * Propagate PREBUILT native modules from a bundled addon copy's own
28
+ * `node_modules` (the packaged-desktop 'local' source at
29
+ * `<resources>/addons/<addon>`) into the freshly-copied target
30
+ * (`<data>/addons/@camstack/<addon>`), BEFORE the target's `npm install` runs.
31
+ *
32
+ * Why (Mac desktop first-boot FATAL, 2026-07-21): `installCopy` copies only
33
+ * `dist/` then `npm install`s the addon's runtime deps. On a toolchain-less Mac
34
+ * that install leaves the traditional native `better-sqlite3` SOURCE-ONLY in
35
+ * `<addon>/node_modules` — a broken copy that then SHADOWS the good hoisted
36
+ * `.node` NODE_PATH would otherwise resolve, crashing the runner with "Could
37
+ * not locate the bindings file". Seeding the prebuilt copy here makes the npm
38
+ * install treat the native as satisfied (no re-run of `prebuild-install`), so
39
+ * the good `.node` stays in place. A no-op in dev / docker where the source
40
+ * carries no bundled natives.
41
+ */
42
+ export declare function copyBundledNativeModules(sourceDir: string, targetDir: string, logger: IScopedLogger): void;
@@ -1,4 +1,4 @@
1
- import { q as readNodePin } from "./dist-DTTTjPCL.mjs";
1
+ import { q as readNodePin } from "./dist-72yufD8v.mjs";
2
2
  import { ensureBinary, ensureFfmpeg, ensurePython, installPythonPackages, installPythonRequirements } from "@camstack/types/node";
3
3
  import { createServer } from "node:http";
4
4
  import * as fs from "node:fs";
@@ -437,6 +437,92 @@ function copyPrebuiltNativeDep(name, addonDir, logger) {
437
437
  }
438
438
  return false;
439
439
  }
440
+ /**
441
+ * Native packages the packaged desktop ships PREBUILT inside each bundled addon
442
+ * copy (`scripts/stage-deps.mjs` plants them), keyed to the platform SIBLING
443
+ * scopes that hold the N-API binary. The traditional `better-sqlite3` carries
444
+ * its `.node` in its own dir; `sharp`/`node-av` carry it in a `@img`/`@seydx`
445
+ * sibling.
446
+ */
447
+ var BUNDLED_NATIVE_SIBLING_SCOPES = {
448
+ "better-sqlite3": [],
449
+ sharp: ["@img"],
450
+ "node-av": ["@seydx"]
451
+ };
452
+ /** Bounded recursive scan for ANY `*.node` under `dir`. */
453
+ function hasAnyDotNode(dir, maxDepth) {
454
+ let entries;
455
+ try {
456
+ entries = fs.readdirSync(dir, { withFileTypes: true });
457
+ } catch {
458
+ return false;
459
+ }
460
+ for (const entry of entries) if (entry.isFile() && entry.name.endsWith(".node")) return true;
461
+ if (maxDepth <= 0) return false;
462
+ for (const entry of entries) if (entry.isDirectory() && hasAnyDotNode(path$1.join(dir, entry.name), maxDepth - 1)) return true;
463
+ return false;
464
+ }
465
+ /** Copy `<src>` → `<dst>` when `<src>` carries a `.node`. Best-effort. */
466
+ function copyPrebuiltModuleDir(src, dst, label, logger) {
467
+ if (!hasAnyDotNode(src, 5)) return;
468
+ if (hasAnyDotNode(dst, 5)) return;
469
+ try {
470
+ fs.rmSync(dst, {
471
+ recursive: true,
472
+ force: true
473
+ });
474
+ fs.mkdirSync(path$1.dirname(dst), { recursive: true });
475
+ fs.cpSync(src, dst, {
476
+ recursive: true,
477
+ dereference: true
478
+ });
479
+ logger.info("Prebuilt native module propagated from bundled addon copy", { meta: {
480
+ module: label,
481
+ src,
482
+ dst
483
+ } });
484
+ } catch (err) {
485
+ logger.warn("Prebuilt native module propagation failed (npm install will retry)", { meta: {
486
+ module: label,
487
+ src,
488
+ error: errMsg(err)
489
+ } });
490
+ }
491
+ }
492
+ /**
493
+ * Propagate PREBUILT native modules from a bundled addon copy's own
494
+ * `node_modules` (the packaged-desktop 'local' source at
495
+ * `<resources>/addons/<addon>`) into the freshly-copied target
496
+ * (`<data>/addons/@camstack/<addon>`), BEFORE the target's `npm install` runs.
497
+ *
498
+ * Why (Mac desktop first-boot FATAL, 2026-07-21): `installCopy` copies only
499
+ * `dist/` then `npm install`s the addon's runtime deps. On a toolchain-less Mac
500
+ * that install leaves the traditional native `better-sqlite3` SOURCE-ONLY in
501
+ * `<addon>/node_modules` — a broken copy that then SHADOWS the good hoisted
502
+ * `.node` NODE_PATH would otherwise resolve, crashing the runner with "Could
503
+ * not locate the bindings file". Seeding the prebuilt copy here makes the npm
504
+ * install treat the native as satisfied (no re-run of `prebuild-install`), so
505
+ * the good `.node` stays in place. A no-op in dev / docker where the source
506
+ * carries no bundled natives.
507
+ */
508
+ function copyBundledNativeModules(sourceDir, targetDir, logger) {
509
+ const srcNm = path$1.join(sourceDir, "node_modules");
510
+ if (!fs.existsSync(srcNm)) return;
511
+ const dstNm = path$1.join(targetDir, "node_modules");
512
+ for (const [name, scopes] of Object.entries(BUNDLED_NATIVE_SIBLING_SCOPES)) {
513
+ copyPrebuiltModuleDir(path$1.join(srcNm, name), path$1.join(dstNm, name), name, logger);
514
+ for (const scope of scopes) {
515
+ const scopeSrc = path$1.join(srcNm, scope);
516
+ let siblings;
517
+ try {
518
+ siblings = fs.readdirSync(scopeSrc);
519
+ } catch {
520
+ continue;
521
+ }
522
+ for (const sibling of siblings) copyPrebuiltModuleDir(path$1.join(scopeSrc, sibling), path$1.join(dstNm, scope, sibling), `${scope}/${sibling}`, logger);
523
+ }
524
+ }
525
+ }
440
526
  /** A package dir is "built" when it carries a compiled `.node` or a prebuilds tree. */
441
527
  function hasBuiltBinary(pkgDir) {
442
528
  if (!fs.existsSync(path$1.join(pkgDir, "package.json"))) return false;
@@ -7320,4 +7406,4 @@ async function installManifestPythonDeps(declaration, addonDir, deps, logger) {
7320
7406
  await deps.installPythonRequirements(reqAbs);
7321
7407
  }
7322
7408
  //#endregion
7323
- export { buildNativeCapProxy as $, createHubCapForwardService as A, AGENT_CAP_FWD_ACTION as B, brokerTransportLink as C, createAddonDataPlaneFacility as Ct, localProviderLink as D, ipcParentLink as E, createUdsLogger as F, callWithServiceDiscovery as G, CapRouteResolver as H, createUdsLoggerWithControl as I, UdsLocalTransportServer as J, createLocalTransport as K, LocalChildClient as L, createUdsEventBridge as M, createUdsEventBus as N, HUB_CAP_FWD_ACTION as O, udsChildLogToWorkerEntry as P, encodeFrame as Q, LocalChildRegistry as R, brokerCallForCap as S, resolveAddonClass as St, ipcChildLink as T, CapRouteError as U, AGENT_CAP_FWD_SERVICE as V, classifyCapRoute as W, localEndpointPath as X, SocketChannel as Y, FrameDecoder as Z, createKernelHwAccel as _, CapabilityHandle as _t, getWorkerDeviceRegistry as a, setWorkerNativeCapsChangeListener as at, __resetCapUsageRegistryForTests as b, resolveNpmInvocation as bt, setHubConnected as c, NATIVE_PROVIDER_SERVICE_INFIX as ct, getBrokerEventBus as d, capBareAction as dt, buildUdsNativeCapProxy as et, getMoleculerEventStats as f, capServiceName as ft, AddonDepsManager as g, DeviceRegistry as gt, subscribePassthrough as h, serializeTypedArrays as ht, createUdsAddonContext as i, mountNativeCapService as it, createParentUnownedCallHandler as j, HUB_CAP_FWD_SERVICE as k, EVENT_TOPIC_PREFIX as l, capActionName as lt, setNodeEventInterest as m, deserializeTypedArrays as mt, adaptBrokerToCluster as n, getWorkerNativeCapProvider as nt, getOrInitReadinessRegistry as o, createAddonService as ot, registerEventBusService as p, parseCapAction as pt, UdsLocalTransportClient as q, createAddonContext as r, getWorkerNativeCapSnapshot as rt, getOrInitReadinessRegistryForClient as s, validateProviderRegistrations as st, installManifestPythonDeps as t, createBrokerDeviceManagerApi as tt, clusterEventTopic as u, capActionSuffix as ut, resolveHwAccel as v, CapabilityUnavailableError as vt, buildLinkChain as w, getCapUsageRegistry as x, runNpm as xt, CapUsageRegistry as y, installManifestNativeDeps as yt, UDS_NO_ROUTE_PREFIX as z };
7409
+ export { buildNativeCapProxy as $, createHubCapForwardService as A, AGENT_CAP_FWD_ACTION as B, brokerTransportLink as C, resolveAddonClass as Ct, localProviderLink as D, ipcParentLink as E, createUdsLogger as F, callWithServiceDiscovery as G, CapRouteResolver as H, createUdsLoggerWithControl as I, UdsLocalTransportServer as J, createLocalTransport as K, LocalChildClient as L, createUdsEventBridge as M, createUdsEventBus as N, HUB_CAP_FWD_ACTION as O, udsChildLogToWorkerEntry as P, encodeFrame as Q, LocalChildRegistry as R, brokerCallForCap as S, runNpm as St, ipcChildLink as T, CapRouteError as U, AGENT_CAP_FWD_SERVICE as V, classifyCapRoute as W, localEndpointPath as X, SocketChannel as Y, FrameDecoder as Z, createKernelHwAccel as _, CapabilityHandle as _t, getWorkerDeviceRegistry as a, setWorkerNativeCapsChangeListener as at, __resetCapUsageRegistryForTests as b, installManifestNativeDeps as bt, setHubConnected as c, NATIVE_PROVIDER_SERVICE_INFIX as ct, getBrokerEventBus as d, capBareAction as dt, buildUdsNativeCapProxy as et, getMoleculerEventStats as f, capServiceName as ft, AddonDepsManager as g, DeviceRegistry as gt, subscribePassthrough as h, serializeTypedArrays as ht, createUdsAddonContext as i, mountNativeCapService as it, createParentUnownedCallHandler as j, HUB_CAP_FWD_SERVICE as k, EVENT_TOPIC_PREFIX as l, capActionName as lt, setNodeEventInterest as m, deserializeTypedArrays as mt, adaptBrokerToCluster as n, getWorkerNativeCapProvider as nt, getOrInitReadinessRegistry as o, createAddonService as ot, registerEventBusService as p, parseCapAction as pt, UdsLocalTransportClient as q, createAddonContext as r, getWorkerNativeCapSnapshot as rt, getOrInitReadinessRegistryForClient as s, validateProviderRegistrations as st, installManifestPythonDeps as t, createBrokerDeviceManagerApi as tt, clusterEventTopic as u, capActionSuffix as ut, resolveHwAccel as v, CapabilityUnavailableError as vt, buildLinkChain as w, createAddonDataPlaneFacility as wt, getCapUsageRegistry as x, resolveNpmInvocation as xt, CapUsageRegistry as y, copyBundledNativeModules as yt, UDS_NO_ROUTE_PREFIX as z };
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_dist = require("./dist-CkdNC8US.js");
2
+ const require_dist = require("./dist-CQZxGJ8u.js");
3
3
  let _camstack_types_node = require("@camstack/types/node");
4
4
  let node_http = require("node:http");
5
5
  let node_fs = require("node:fs");
@@ -439,6 +439,92 @@ function copyPrebuiltNativeDep(name, addonDir, logger) {
439
439
  }
440
440
  return false;
441
441
  }
442
+ /**
443
+ * Native packages the packaged desktop ships PREBUILT inside each bundled addon
444
+ * copy (`scripts/stage-deps.mjs` plants them), keyed to the platform SIBLING
445
+ * scopes that hold the N-API binary. The traditional `better-sqlite3` carries
446
+ * its `.node` in its own dir; `sharp`/`node-av` carry it in a `@img`/`@seydx`
447
+ * sibling.
448
+ */
449
+ var BUNDLED_NATIVE_SIBLING_SCOPES = {
450
+ "better-sqlite3": [],
451
+ sharp: ["@img"],
452
+ "node-av": ["@seydx"]
453
+ };
454
+ /** Bounded recursive scan for ANY `*.node` under `dir`. */
455
+ function hasAnyDotNode(dir, maxDepth) {
456
+ let entries;
457
+ try {
458
+ entries = node_fs.readdirSync(dir, { withFileTypes: true });
459
+ } catch {
460
+ return false;
461
+ }
462
+ for (const entry of entries) if (entry.isFile() && entry.name.endsWith(".node")) return true;
463
+ if (maxDepth <= 0) return false;
464
+ for (const entry of entries) if (entry.isDirectory() && hasAnyDotNode(node_path.join(dir, entry.name), maxDepth - 1)) return true;
465
+ return false;
466
+ }
467
+ /** Copy `<src>` → `<dst>` when `<src>` carries a `.node`. Best-effort. */
468
+ function copyPrebuiltModuleDir(src, dst, label, logger) {
469
+ if (!hasAnyDotNode(src, 5)) return;
470
+ if (hasAnyDotNode(dst, 5)) return;
471
+ try {
472
+ node_fs.rmSync(dst, {
473
+ recursive: true,
474
+ force: true
475
+ });
476
+ node_fs.mkdirSync(node_path.dirname(dst), { recursive: true });
477
+ node_fs.cpSync(src, dst, {
478
+ recursive: true,
479
+ dereference: true
480
+ });
481
+ logger.info("Prebuilt native module propagated from bundled addon copy", { meta: {
482
+ module: label,
483
+ src,
484
+ dst
485
+ } });
486
+ } catch (err) {
487
+ logger.warn("Prebuilt native module propagation failed (npm install will retry)", { meta: {
488
+ module: label,
489
+ src,
490
+ error: (0, _camstack_types_addon.errMsg)(err)
491
+ } });
492
+ }
493
+ }
494
+ /**
495
+ * Propagate PREBUILT native modules from a bundled addon copy's own
496
+ * `node_modules` (the packaged-desktop 'local' source at
497
+ * `<resources>/addons/<addon>`) into the freshly-copied target
498
+ * (`<data>/addons/@camstack/<addon>`), BEFORE the target's `npm install` runs.
499
+ *
500
+ * Why (Mac desktop first-boot FATAL, 2026-07-21): `installCopy` copies only
501
+ * `dist/` then `npm install`s the addon's runtime deps. On a toolchain-less Mac
502
+ * that install leaves the traditional native `better-sqlite3` SOURCE-ONLY in
503
+ * `<addon>/node_modules` — a broken copy that then SHADOWS the good hoisted
504
+ * `.node` NODE_PATH would otherwise resolve, crashing the runner with "Could
505
+ * not locate the bindings file". Seeding the prebuilt copy here makes the npm
506
+ * install treat the native as satisfied (no re-run of `prebuild-install`), so
507
+ * the good `.node` stays in place. A no-op in dev / docker where the source
508
+ * carries no bundled natives.
509
+ */
510
+ function copyBundledNativeModules(sourceDir, targetDir, logger) {
511
+ const srcNm = node_path.join(sourceDir, "node_modules");
512
+ if (!node_fs.existsSync(srcNm)) return;
513
+ const dstNm = node_path.join(targetDir, "node_modules");
514
+ for (const [name, scopes] of Object.entries(BUNDLED_NATIVE_SIBLING_SCOPES)) {
515
+ copyPrebuiltModuleDir(node_path.join(srcNm, name), node_path.join(dstNm, name), name, logger);
516
+ for (const scope of scopes) {
517
+ const scopeSrc = node_path.join(srcNm, scope);
518
+ let siblings;
519
+ try {
520
+ siblings = node_fs.readdirSync(scopeSrc);
521
+ } catch {
522
+ continue;
523
+ }
524
+ for (const sibling of siblings) copyPrebuiltModuleDir(node_path.join(scopeSrc, sibling), node_path.join(dstNm, scope, sibling), `${scope}/${sibling}`, logger);
525
+ }
526
+ }
527
+ }
442
528
  /** A package dir is "built" when it carries a compiled `.node` or a prebuilds tree. */
443
529
  function hasBuiltBinary(pkgDir) {
444
530
  if (!node_fs.existsSync(node_path.join(pkgDir, "package.json"))) return false;
@@ -7526,6 +7612,12 @@ Object.defineProperty(exports, "clusterEventTopic", {
7526
7612
  return clusterEventTopic;
7527
7613
  }
7528
7614
  });
7615
+ Object.defineProperty(exports, "copyBundledNativeModules", {
7616
+ enumerable: true,
7617
+ get: function() {
7618
+ return copyBundledNativeModules;
7619
+ }
7620
+ });
7529
7621
  Object.defineProperty(exports, "createAddonContext", {
7530
7622
  enumerable: true,
7531
7623
  get: function() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/system",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Core addon for CamStack — builtins, pipeline, process management, auth, logging, events",
5
5
  "keywords": [
6
6
  "camstack",