@camstack/addon-pipeline 1.2.119 → 1.2.121

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 (34) hide show
  1. package/dist/{addon-utils-RAHF2hmW.js → addon-utils-DpyYShEF.js} +1 -1
  2. package/dist/audio-analyzer/index.js +3 -3
  3. package/dist/audio-analyzer/index.mjs +2 -2
  4. package/dist/detection-pipeline/index.js +5 -5
  5. package/dist/detection-pipeline/index.mjs +3 -3
  6. package/dist/{dist-Db664g2O.mjs → dist-BJFxSye4.mjs} +17 -2
  7. package/dist/{dist-DIsM42Ex.js → dist-CDNpiyq6.js} +17 -2
  8. package/dist/{event-loop-stall-monitor-CSpdFZb6.js → event-loop-stall-monitor-BnqO_H2Z.js} +1 -1
  9. package/dist/{event-loop-stall-monitor-DY6339bX.mjs → event-loop-stall-monitor-CcHh1ovi.mjs} +1 -1
  10. package/dist/{lazy-sharp-LSlEXQe_.js → lazy-sharp-B39XqJD6.js} +1 -1
  11. package/dist/motion-wasm/index.js +2 -2
  12. package/dist/motion-wasm/index.mjs +1 -1
  13. package/dist/pipeline-runner/index.js +4 -4
  14. package/dist/pipeline-runner/index.mjs +3 -3
  15. package/dist/{process-memory-CPm5TMBl.mjs → process-memory-BeCXh3iT.mjs} +1 -1
  16. package/dist/{process-memory-DpSJQF-p.js → process-memory-QlU7BsBQ.js} +1 -1
  17. package/dist/recorder/index.js +125 -27
  18. package/dist/recorder/index.mjs +124 -26
  19. package/dist/segment-demux-js-BuaascIe.mjs +7288 -0
  20. package/dist/segment-demux-js-DZ6bRNvA.js +7310 -0
  21. package/dist/session-decode/decode-worker-child.js +2 -2
  22. package/dist/session-decode/decode-worker-child.mjs +1 -1
  23. package/dist/stream-broker/_stub.js +1 -1
  24. package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-CstvrzmK.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-DN_gNdAs.mjs} +2 -2
  25. package/dist/stream-broker/{_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-BiNja8Hw.mjs → _virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-Cs8bmrWP.mjs} +1 -1
  26. package/dist/stream-broker/demux-worker-child.js +46 -0
  27. package/dist/stream-broker/demux-worker-child.mjs +47 -0
  28. package/dist/stream-broker/{hostInit-kHeLqEod.mjs → hostInit-F493PnEJ.mjs} +2 -2
  29. package/dist/stream-broker/index.js +429 -7425
  30. package/dist/stream-broker/index.mjs +430 -7423
  31. package/dist/stream-broker/remoteEntry.js +1 -1
  32. package/dist/{worker-protocol-C1tr8WP3.js → worker-protocol-BPx6jK4-.js} +1 -1
  33. package/dist/{worker-protocol-_zMPqSas.mjs → worker-protocol-Djzf2BTN.mjs} +1 -1
  34. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { B as deriveRecordingMode, Dt as hydrateSchema, Gt as string, Ht as number, M as batteryCapability, Pt as selectAssignedProfileSlots, R as deriveBatteryPresence, St as BaseAddon, T as RecordingConfigSchema, Tt as DeviceType, Ut as object, Wt as record, at as recordingCapability, b as OpsLogEntrySchema, d as DEFAULT_EVENTS_BAND_BUFFER_SEC, ft as storageEvictableCapability, g as ExportRecordSchema, gt as errMsg, i as BatteryStatusSchema, jt as nodePin, m as EVENT_PAD_MS, ot as recordingExportCapability, qt as EventCategory, ut as resolveRecordingProfiles, w as RECORDING_EXPORT_MAX_READ_BYTES, wt as DeviceFeature } from "../dist-Db664g2O.mjs";
1
+ import { B as deriveRecordingMode, Dt as hydrateSchema, Gt as string, Ht as number, M as batteryCapability, Pt as selectAssignedProfileSlots, R as deriveBatteryPresence, St as BaseAddon, T as RecordingConfigSchema, Tt as DeviceType, Ut as object, Wt as record, at as recordingCapability, b as OpsLogEntrySchema, d as DEFAULT_EVENTS_BAND_BUFFER_SEC, ft as storageEvictableCapability, g as ExportRecordSchema, gt as errMsg, i as BatteryStatusSchema, jt as nodePin, m as EVENT_PAD_MS, ot as recordingExportCapability, qt as EventCategory, ut as resolveRecordingProfiles, w as RECORDING_EXPORT_MAX_READ_BYTES, wt as DeviceFeature } from "../dist-BJFxSye4.mjs";
2
2
  import { t as resolveHubHostname } from "../hub-hostname-cCknRYKj.mjs";
3
3
  import { r as withRecordingIntent } from "../restream-intent-B4BXZra7.mjs";
4
4
  import { n as createFileDataPlaneHandler, s as parseRangeHeader, t as contentTypeFor } from "../addon-utils-CgBCF-mE.mjs";
@@ -538,12 +538,38 @@ function segmentRelPath(deviceId, profile, startMs, durMs, bytes) {
538
538
  return `${deviceId}/${profile}/${d.getUTCFullYear()}/${p2(d.getUTCMonth() + 1)}/${p2(d.getUTCDate())}/${p2(d.getUTCHours())}/${startMs}-${durMs}-${bytes}.m4s`;
539
539
  }
540
540
  var SEG_RE = /^(\d+)\/([^/]+)\/\d{4}\/\d{2}\/\d{2}\/\d{2}\/(\d+)-(\d+)-(\d+)\.m4s$/;
541
+ /**
542
+ * The profile names the recorder writes. Used ONLY to hand back a shared string
543
+ * instead of a fresh one — never to reject a name.
544
+ *
545
+ * `SEG_RE`'s second group is a slice of the path, so V8 materialises a new
546
+ * string for it on every parse. The whole fleet has three profile names and the
547
+ * index holds one row per segment, so that is one redundant string per segment
548
+ * held for the segment's whole life. Measured on the production shape (17
549
+ * cameras x 2 profiles x 12 days of 10 s segments = 3.53 M rows): 798 MB
550
+ * without this, 717 MB with it — 80.7 MB, 24 B/row, ~10% of the index.
551
+ *
552
+ * A name outside this set falls through to the parsed slice unchanged, so an
553
+ * unrecognised profile is never renamed, never dropped, and costs exactly what
554
+ * it costs today. That fall-through is the property the tests pin.
555
+ */
556
+ var CANONICAL_PROFILES = [
557
+ "high",
558
+ "mid",
559
+ "low"
560
+ ];
561
+ /** The shared instance of `profile` when it is one of {@link CANONICAL_PROFILES},
562
+ * otherwise `profile` itself. */
563
+ function canonicalProfile(profile) {
564
+ for (const known of CANONICAL_PROFILES) if (known === profile) return known;
565
+ return profile;
566
+ }
541
567
  function parseSegmentPath(relPath) {
542
568
  const m = SEG_RE.exec(relPath);
543
569
  if (!m) return null;
544
570
  return {
545
571
  deviceId: Number(m[1]),
546
- profile: m[2],
572
+ profile: canonicalProfile(m[2]),
547
573
  startMs: Number(m[3]),
548
574
  durMs: Number(m[4]),
549
575
  bytes: Number(m[5])
@@ -589,6 +615,9 @@ var RecordingIndex = class {
589
615
  sortedByDevice = /* @__PURE__ */ new Map();
590
616
  fullRebuilds = 0;
591
617
  incrementalInserts = 0;
618
+ /** See {@link HydrateReuseStats}. */
619
+ rowsReused = 0;
620
+ rowsAllocated = 0;
592
621
  /** Hour buckets this device has been walked for; `ALL_HOURS` after a full
593
622
  * hydrate. Empty = nothing has been looked at, which is NOT the same as
594
623
  * "there is nothing" — see {@link hydrationOf}. */
@@ -627,6 +656,13 @@ var RecordingIndex = class {
627
656
  incrementalInserts: this.incrementalInserts
628
657
  };
629
658
  }
659
+ /** See {@link HydrateReuseStats}. Cumulative over the process. */
660
+ hydrateReuseStats() {
661
+ return {
662
+ rowsReused: this.rowsReused,
663
+ rowsAllocated: this.rowsAllocated
664
+ };
665
+ }
630
666
  /**
631
667
  * Ordered insert of ONE NEW row into every live view it belongs to (the
632
668
  * all-profiles view and its own profile's view). Views not yet materialised
@@ -644,25 +680,70 @@ var RecordingIndex = class {
644
680
  }
645
681
  }
646
682
  /**
683
+ * The row to index for `path` at `locationId`, REUSING the held one when the
684
+ * index already has it.
685
+ *
686
+ * ## Why a re-walk must not re-allocate (the second copy of every path)
687
+ *
688
+ * Every field of a `SegmentRow` except `locationId` is derived from `path`,
689
+ * so a held row at the same location is not merely EQUAL to a rebuilt one —
690
+ * it is the same fact. Rebuilding it allocates a second byte-identical path
691
+ * string, and that second string does not stay a garbage-collectable
692
+ * duplicate: `SegmentHourLedger`'s mirror still holds the FIRST one, because
693
+ * `reconcileFromIndex` skips its `ledger.put` exactly when the contents
694
+ * match. The archive walk (`roots.ts`) composes a fresh `${deviceId}/${entry}`
695
+ * for every file it reads, so before this reuse existed the first walk after
696
+ * every boot doubled the retained path strings of the whole archive,
697
+ * permanently.
698
+ *
699
+ * Measured on the production shape (26 cameras x 2 profiles x 12 days of
700
+ * 10 s segments = 5.39 M rows): 1218 MB held before the walk, 1591 MB after
701
+ * — +373 MB, 69 B/row, one extra `SeqOneByteString` per segment.
702
+ *
703
+ * Interning the strings instead was measured and is WORSE (+597 MB): the
704
+ * intern table costs more than the duplicate it removes. Not allocating is
705
+ * the only cheap answer.
706
+ *
707
+ * `null` = not a segment path, or another device's.
708
+ */
709
+ rowFor(held, path, deviceId, locationId) {
710
+ const prev = held.get(path);
711
+ if (prev !== void 0 && prev.locationId === locationId) {
712
+ this.rowsReused += 1;
713
+ return prev;
714
+ }
715
+ const p = parseSegmentPath(path);
716
+ if (!p || p.deviceId !== deviceId) return null;
717
+ this.rowsAllocated += 1;
718
+ return {
719
+ deviceId: p.deviceId,
720
+ profile: p.profile,
721
+ startMs: p.startMs,
722
+ durMs: p.durMs,
723
+ bytes: p.bytes,
724
+ path,
725
+ locationId
726
+ };
727
+ }
728
+ /**
647
729
  * Replace a device's segments FOR ONE LOCATION from a `storage.list` result (paths relative to that
648
730
  * location root). Rows on other locations are preserved. Non-segment paths and other devices are ignored.
731
+ *
732
+ * Deliberately NOT delete-all-then-reinsert: the archive walk re-reports rows
733
+ * this index already holds, with freshly built path strings, and dropping the
734
+ * held rows first would make those fresh strings the permanent ones — a
735
+ * second copy of the whole archive's paths. See {@link retainedPathStrings}.
649
736
  */
650
737
  hydrateDevice(deviceId, locationId, relPaths) {
651
738
  const m = this.mapFor(deviceId);
652
- for (const [path, existing] of m) if (existing.locationId === locationId) m.delete(path);
739
+ const seen = /* @__PURE__ */ new Set();
653
740
  for (const path of relPaths) {
654
- const p = parseSegmentPath(path);
655
- if (!p || p.deviceId !== deviceId) continue;
656
- m.set(path, {
657
- deviceId: p.deviceId,
658
- profile: p.profile,
659
- startMs: p.startMs,
660
- durMs: p.durMs,
661
- bytes: p.bytes,
662
- path,
663
- locationId
664
- });
741
+ const row = this.rowFor(m, path, deviceId, locationId);
742
+ if (row === null) continue;
743
+ if (row.path !== path || m.get(path) !== row) m.set(path, row);
744
+ seen.add(path);
665
745
  }
746
+ for (const [path, existing] of m) if (existing.locationId === locationId && !seen.has(path)) m.delete(path);
666
747
  this.invalidateSorted(deviceId);
667
748
  }
668
749
  /**
@@ -707,20 +788,15 @@ var RecordingIndex = class {
707
788
  */
708
789
  hydrateHour(deviceId, locationId, hourStartMs, relPaths) {
709
790
  const m = this.mapFor(deviceId);
791
+ let changed = false;
710
792
  for (const path of relPaths) {
711
- const p = parseSegmentPath(path);
712
- if (!p || p.deviceId !== deviceId) continue;
713
- m.set(path, {
714
- deviceId: p.deviceId,
715
- profile: p.profile,
716
- startMs: p.startMs,
717
- durMs: p.durMs,
718
- bytes: p.bytes,
719
- path,
720
- locationId
721
- });
793
+ const row = this.rowFor(m, path, deviceId, locationId);
794
+ if (row === null) continue;
795
+ if (m.get(path) === row) continue;
796
+ m.set(path, row);
797
+ changed = true;
722
798
  }
723
- this.invalidateSorted(deviceId);
799
+ if (changed) this.invalidateSorted(deviceId);
724
800
  this.markHydrated(deviceId, hourStartMs, hourStartMs + HOUR_MS$5);
725
801
  }
726
802
  /**
@@ -5846,16 +5922,22 @@ async function hydrateDeviceFromStorage(_api, index, deviceId, locations, logger
5846
5922
  }
5847
5923
  for (const location of aliases) if (!pathsByLocation.has(location.id)) pathsByLocation.set(location.id, []);
5848
5924
  let indexed = 0;
5925
+ const reuseBefore = index.hydrateReuseStats();
5849
5926
  for (const [locationId, relPaths] of pathsByLocation) {
5850
5927
  index.hydrateDevice(deviceId, locationId, relPaths);
5851
5928
  indexed += relPaths.length;
5852
5929
  }
5930
+ const reuseAfter = index.hydrateReuseStats();
5931
+ const reused = reuseAfter.rowsReused - reuseBefore.rowsReused;
5932
+ const allocated = reuseAfter.rowsAllocated - reuseBefore.rowsAllocated;
5853
5933
  logger.info("recorder: hydrated a device from one recordings root", {
5854
5934
  tags: { deviceId },
5855
5935
  meta: {
5856
5936
  root,
5857
5937
  entries: entries.length,
5858
5938
  indexed,
5939
+ reused,
5940
+ allocated,
5859
5941
  locationIds: [...pathsByLocation.keys()],
5860
5942
  walkMs: walkedMs - startedMs,
5861
5943
  ms: Date.now() - startedMs
@@ -5965,6 +6047,8 @@ async function hydrateWindowFromStorage(index, deviceId, fromMs, toMs, locations
5965
6047
  continue;
5966
6048
  }
5967
6049
  const first = Math.floor(fromMs / HOUR_MS$2) * HOUR_MS$2;
6050
+ const reuseBefore = index.hydrateReuseStats();
6051
+ let hoursRead = 0;
5968
6052
  for (let hour = first; hour < toMs; hour += HOUR_MS$2) for (const profile of profiles) {
5969
6053
  const rel = hourDirRelPath(deviceId, profile, hour);
5970
6054
  let files;
@@ -5973,9 +6057,23 @@ async function hydrateWindowFromStorage(index, deviceId, fromMs, toMs, locations
5973
6057
  } catch {
5974
6058
  continue;
5975
6059
  }
6060
+ hoursRead += 1;
5976
6061
  index.hydrateHour(deviceId, locationForHydratedProfile(aliases, profile).id, hour, files.filter((f) => f.endsWith(".m4s")).map((f) => `${rel}/${f}`));
5977
6062
  }
5978
6063
  index.markHydrated(deviceId, fromMs, toMs);
6064
+ if (hoursRead === 0) continue;
6065
+ const reuseAfter = index.hydrateReuseStats();
6066
+ const reused = reuseAfter.rowsReused - reuseBefore.rowsReused;
6067
+ const allocated = reuseAfter.rowsAllocated - reuseBefore.rowsAllocated;
6068
+ logger.info("recorder: hydrated a window from one recordings root", {
6069
+ tags: { deviceId },
6070
+ meta: {
6071
+ root,
6072
+ hoursRead,
6073
+ reused,
6074
+ allocated
6075
+ }
6076
+ });
5979
6077
  }
5980
6078
  }
5981
6079
  //#endregion