@camstack/ui-library 1.0.6 → 1.0.7

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.
@@ -80,7 +80,7 @@ var BTN_PRIMARY = "rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1
80
80
  /** Coerce an arbitrary `cells` array to exactly `width*height` booleans. */
81
81
  function normaliseCells(cells, width, height) {
82
82
  const total = width * height;
83
- const next = new Array(total);
83
+ const next = Array.from({ length: total });
84
84
  for (let i = 0; i < total; i += 1) next[i] = cells[i] === true;
85
85
  return next;
86
86
  }
@@ -115,7 +115,7 @@ function cameraToUi(c, cameraDim, uiDim) {
115
115
  function coarsenCells(cameraCells, cw, ch, m) {
116
116
  const uw = coarseDim(cw, m);
117
117
  const uh = coarseDim(ch, m);
118
- const out = new Array(uw * uh).fill(false);
118
+ const out = Array.from({ length: uw * uh }, () => false);
119
119
  for (let cy = 0; cy < ch; cy += 1) {
120
120
  const uy = cameraToUi(cy, ch, uh);
121
121
  for (let cx = 0; cx < cw; cx += 1) {
@@ -136,7 +136,7 @@ function coarsenCells(cameraCells, cw, ch, m) {
136
136
  function expandCells(uiCells, cw, ch, m) {
137
137
  const uw = coarseDim(cw, m);
138
138
  const uh = coarseDim(ch, m);
139
- const out = new Array(cw * ch).fill(false);
139
+ const out = Array.from({ length: cw * ch }, () => false);
140
140
  for (let cy = 0; cy < ch; cy += 1) {
141
141
  const uy = cameraToUi(cy, ch, uh);
142
142
  for (let cx = 0; cx < cw; cx += 1) out[cy * cw + cx] = uiCells[uy * uw + cameraToUi(cx, cw, uw)] === true;
@@ -204,7 +204,7 @@ function MotionZonesSettings({ deviceId }) {
204
204
  const cameraTotal = cw * ch;
205
205
  const uiTotal = uiWidth * uiHeight;
206
206
  const setAll = (0, react.useCallback)((value) => {
207
- if (uiTotal > 0) setUiCells(new Array(uiTotal).fill(value));
207
+ if (uiTotal > 0) setUiCells(Array.from({ length: uiTotal }, () => value));
208
208
  }, [uiTotal]);
209
209
  const invert = (0, react.useCallback)(() => {
210
210
  setUiCells((prev) => prev ? prev.map((c) => !c) : prev);
@@ -80,7 +80,7 @@ var BTN_PRIMARY = "rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1
80
80
  /** Coerce an arbitrary `cells` array to exactly `width*height` booleans. */
81
81
  function normaliseCells(cells, width, height) {
82
82
  const total = width * height;
83
- const next = new Array(total);
83
+ const next = Array.from({ length: total });
84
84
  for (let i = 0; i < total; i += 1) next[i] = cells[i] === true;
85
85
  return next;
86
86
  }
@@ -115,7 +115,7 @@ function cameraToUi(c, cameraDim, uiDim) {
115
115
  function coarsenCells(cameraCells, cw, ch, m) {
116
116
  const uw = coarseDim(cw, m);
117
117
  const uh = coarseDim(ch, m);
118
- const out = new Array(uw * uh).fill(false);
118
+ const out = Array.from({ length: uw * uh }, () => false);
119
119
  for (let cy = 0; cy < ch; cy += 1) {
120
120
  const uy = cameraToUi(cy, ch, uh);
121
121
  for (let cx = 0; cx < cw; cx += 1) {
@@ -136,7 +136,7 @@ function coarsenCells(cameraCells, cw, ch, m) {
136
136
  function expandCells(uiCells, cw, ch, m) {
137
137
  const uw = coarseDim(cw, m);
138
138
  const uh = coarseDim(ch, m);
139
- const out = new Array(cw * ch).fill(false);
139
+ const out = Array.from({ length: cw * ch }, () => false);
140
140
  for (let cy = 0; cy < ch; cy += 1) {
141
141
  const uy = cameraToUi(cy, ch, uh);
142
142
  for (let cx = 0; cx < cw; cx += 1) out[cy * cw + cx] = uiCells[uy * uw + cameraToUi(cx, cw, uw)] === true;
@@ -204,7 +204,7 @@ function MotionZonesSettings({ deviceId }) {
204
204
  const cameraTotal = cw * ch;
205
205
  const uiTotal = uiWidth * uiHeight;
206
206
  const setAll = useCallback((value) => {
207
- if (uiTotal > 0) setUiCells(new Array(uiTotal).fill(value));
207
+ if (uiTotal > 0) setUiCells(Array.from({ length: uiTotal }, () => value));
208
208
  }, [uiTotal]);
209
209
  const invert = useCallback(() => {
210
210
  setUiCells((prev) => prev ? prev.map((c) => !c) : prev);
package/dist/index.cjs CHANGED
@@ -28402,17 +28402,17 @@ function ImageSelector({ images, selectedFilename, uploadedName, onSelect, onUpl
28402
28402
  const input = document.createElement("input");
28403
28403
  input.type = "file";
28404
28404
  input.accept = accept;
28405
- input.onchange = () => {
28405
+ input.addEventListener("change", () => {
28406
28406
  const file = input.files?.[0];
28407
28407
  if (!file) return;
28408
28408
  const reader = new FileReader();
28409
- reader.onload = () => {
28409
+ reader.addEventListener("load", () => {
28410
28410
  const dataUrl = reader.result;
28411
28411
  const b64 = dataUrl.split(",")[1];
28412
28412
  if (b64) onUpload(b64, file.name, dataUrl);
28413
- };
28413
+ });
28414
28414
  reader.readAsDataURL(file);
28415
- };
28415
+ });
28416
28416
  input.click();
28417
28417
  };
28418
28418
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -32168,7 +32168,7 @@ function RecordingPanel({ deviceId }) {
32168
32168
  * `type:'widget'` ConfigField. `WidgetSlot` resolves these BEFORE the
32169
32169
  * Module-Federation `WidgetRegistry`. ids are namespaced `host/<name>`. */
32170
32170
  var HOST_WIDGETS = {
32171
- "host/motion-zones-grid": (0, react$1.lazy)(() => Promise.resolve().then(() => require("./MotionZonesSettings-Ci1mzrki.cjs")).then((m) => ({ default: m.MotionZonesSettings }))),
32171
+ "host/motion-zones-grid": (0, react$1.lazy)(() => Promise.resolve().then(() => require("./MotionZonesSettings-BP9p0pFB.cjs")).then((m) => ({ default: m.MotionZonesSettings }))),
32172
32172
  "host/privacy-mask-grid": (0, react$1.lazy)(() => Promise.resolve().then(() => require("./PrivacyMaskSettings-yC-UPYPg.cjs")).then((m) => ({ default: m.PrivacyMaskSettings }))),
32173
32173
  "host/ptz-panel": PtzPanel,
32174
32174
  "host/consumables-panel": ConsumablesPanel,
@@ -35415,8 +35415,8 @@ function AddonGlobalSettingsForm({ trpc, addonId, nodeId, title, disabled, onAft
35415
35415
  ...overlay ? { overlay } : {}
35416
35416
  }).then((res) => {
35417
35417
  if (cancelled) return;
35418
- setHydrated(res);
35419
- if (!overlay) setBaseValues(extractValues(res));
35418
+ setHydrated((prev) => res ?? prev);
35419
+ if (!overlay && res) setBaseValues(extractValues(res));
35420
35420
  setLoading(false);
35421
35421
  }).catch((err) => {
35422
35422
  if (cancelled) return;
@@ -35459,10 +35459,11 @@ function AddonGlobalSettingsForm({ trpc, addonId, nodeId, title, disabled, onAft
35459
35459
  nodeId,
35460
35460
  patch
35461
35461
  });
35462
- setHydrated(await trpc.addonSettings.getGlobalSettings.query({
35462
+ const next = await trpc.addonSettings.getGlobalSettings.query({
35463
35463
  addonId,
35464
35464
  nodeId
35465
- }));
35465
+ });
35466
+ if (next) setHydrated(next);
35466
35467
  onAfterChange?.();
35467
35468
  } catch (err) {
35468
35469
  setError(err instanceof Error ? err.message : String(err));
@@ -42222,7 +42223,7 @@ function useDeviceCapSlice(trpc, deviceId, capName) {
42222
42223
  * Render inside `<Suspense>` at all call sites. */
42223
42224
  var MaskShapeCanvas = (0, react$1.lazy)(() => Promise.resolve().then(() => require("./MaskShapeCanvas-BByN3jvt.cjs")).then((m) => ({ default: m.MaskShapeCanvas })));
42224
42225
  /** Lazy-wrapped `MotionZonesSettings` — code-split off the main bundle. */
42225
- var MotionZonesSettings = (0, react$1.lazy)(() => Promise.resolve().then(() => require("./MotionZonesSettings-Ci1mzrki.cjs")).then((m) => ({ default: m.MotionZonesSettings })));
42226
+ var MotionZonesSettings = (0, react$1.lazy)(() => Promise.resolve().then(() => require("./MotionZonesSettings-BP9p0pFB.cjs")).then((m) => ({ default: m.MotionZonesSettings })));
42226
42227
  /** Lazy-wrapped `PrivacyMaskSettings` — code-split off the main bundle. */
42227
42228
  var PrivacyMaskSettings = (0, react$1.lazy)(() => Promise.resolve().then(() => require("./PrivacyMaskSettings-yC-UPYPg.cjs")).then((m) => ({ default: m.PrivacyMaskSettings })));
42228
42229
  //#endregion
package/dist/index.js CHANGED
@@ -28378,17 +28378,17 @@ function ImageSelector({ images, selectedFilename, uploadedName, onSelect, onUpl
28378
28378
  const input = document.createElement("input");
28379
28379
  input.type = "file";
28380
28380
  input.accept = accept;
28381
- input.onchange = () => {
28381
+ input.addEventListener("change", () => {
28382
28382
  const file = input.files?.[0];
28383
28383
  if (!file) return;
28384
28384
  const reader = new FileReader();
28385
- reader.onload = () => {
28385
+ reader.addEventListener("load", () => {
28386
28386
  const dataUrl = reader.result;
28387
28387
  const b64 = dataUrl.split(",")[1];
28388
28388
  if (b64) onUpload(b64, file.name, dataUrl);
28389
- };
28389
+ });
28390
28390
  reader.readAsDataURL(file);
28391
- };
28391
+ });
28392
28392
  input.click();
28393
28393
  };
28394
28394
  return /* @__PURE__ */ jsxs("div", {
@@ -32144,7 +32144,7 @@ function RecordingPanel({ deviceId }) {
32144
32144
  * `type:'widget'` ConfigField. `WidgetSlot` resolves these BEFORE the
32145
32145
  * Module-Federation `WidgetRegistry`. ids are namespaced `host/<name>`. */
32146
32146
  var HOST_WIDGETS = {
32147
- "host/motion-zones-grid": lazy(() => import("./MotionZonesSettings-C1EEbk2V.js").then((m) => ({ default: m.MotionZonesSettings }))),
32147
+ "host/motion-zones-grid": lazy(() => import("./MotionZonesSettings-NcxxQN8r.js").then((m) => ({ default: m.MotionZonesSettings }))),
32148
32148
  "host/privacy-mask-grid": lazy(() => import("./PrivacyMaskSettings-APgPLF7p.js").then((m) => ({ default: m.PrivacyMaskSettings }))),
32149
32149
  "host/ptz-panel": PtzPanel,
32150
32150
  "host/consumables-panel": ConsumablesPanel,
@@ -35391,8 +35391,8 @@ function AddonGlobalSettingsForm({ trpc, addonId, nodeId, title, disabled, onAft
35391
35391
  ...overlay ? { overlay } : {}
35392
35392
  }).then((res) => {
35393
35393
  if (cancelled) return;
35394
- setHydrated(res);
35395
- if (!overlay) setBaseValues(extractValues(res));
35394
+ setHydrated((prev) => res ?? prev);
35395
+ if (!overlay && res) setBaseValues(extractValues(res));
35396
35396
  setLoading(false);
35397
35397
  }).catch((err) => {
35398
35398
  if (cancelled) return;
@@ -35435,10 +35435,11 @@ function AddonGlobalSettingsForm({ trpc, addonId, nodeId, title, disabled, onAft
35435
35435
  nodeId,
35436
35436
  patch
35437
35437
  });
35438
- setHydrated(await trpc.addonSettings.getGlobalSettings.query({
35438
+ const next = await trpc.addonSettings.getGlobalSettings.query({
35439
35439
  addonId,
35440
35440
  nodeId
35441
- }));
35441
+ });
35442
+ if (next) setHydrated(next);
35442
35443
  onAfterChange?.();
35443
35444
  } catch (err) {
35444
35445
  setError(err instanceof Error ? err.message : String(err));
@@ -42198,7 +42199,7 @@ function useDeviceCapSlice(trpc, deviceId, capName) {
42198
42199
  * Render inside `<Suspense>` at all call sites. */
42199
42200
  var MaskShapeCanvas = lazy(() => import("./MaskShapeCanvas-DI4BY7W2.js").then((m) => ({ default: m.MaskShapeCanvas })));
42200
42201
  /** Lazy-wrapped `MotionZonesSettings` — code-split off the main bundle. */
42201
- var MotionZonesSettings = lazy(() => import("./MotionZonesSettings-C1EEbk2V.js").then((m) => ({ default: m.MotionZonesSettings })));
42202
+ var MotionZonesSettings = lazy(() => import("./MotionZonesSettings-NcxxQN8r.js").then((m) => ({ default: m.MotionZonesSettings })));
42202
42203
  /** Lazy-wrapped `PrivacyMaskSettings` — code-split off the main bundle. */
42203
42204
  var PrivacyMaskSettings = lazy(() => import("./PrivacyMaskSettings-APgPLF7p.js").then((m) => ({ default: m.PrivacyMaskSettings })));
42204
42205
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/ui-library",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",