@wcstack/camera 1.23.0 → 1.25.0
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.
- package/dist/index.d.ts +17 -0
- package/dist/index.esm.js +65 -19
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -9,10 +9,27 @@ interface WcsIoErrorInfo {
|
|
|
9
9
|
readonly message: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Observation semantics of a `properties` entry.
|
|
14
|
+
*
|
|
15
|
+
* "state" — current value. A snapshot may cache it, and equality-based dedupe is safe.
|
|
16
|
+
* "event" — occurrence. Repeated identical payloads are distinct occurrences; never dedupe.
|
|
17
|
+
* "handle" — live / opaque resource with its own lifecycle (e.g. MediaStream). Not
|
|
18
|
+
* snapshot-safe and not necessarily serializable; consumers need an explicit
|
|
19
|
+
* ref / callback surface rather than a value slot.
|
|
20
|
+
*/
|
|
21
|
+
type WcBindableSemantics = "state" | "event" | "handle";
|
|
12
22
|
interface IWcBindableProperty {
|
|
13
23
|
readonly name: string;
|
|
14
24
|
readonly event: string;
|
|
15
25
|
readonly getter?: (event: Event) => any;
|
|
26
|
+
/**
|
|
27
|
+
* Optional, additive, forward-compatible. An absent value means **unspecified**, NOT
|
|
28
|
+
* "state": a reader that finds no `semantics` MUST keep the behavior it had before this
|
|
29
|
+
* field existed (deliver the update as-is; do not start deduping, caching or serializing
|
|
30
|
+
* on assumption). Only an explicit value licenses a reader to change its handling.
|
|
31
|
+
*/
|
|
32
|
+
readonly semantics?: WcBindableSemantics;
|
|
16
33
|
}
|
|
17
34
|
interface IWcBindableInput {
|
|
18
35
|
readonly name: string;
|
package/dist/index.esm.js
CHANGED
|
@@ -294,22 +294,22 @@ class CameraCore extends EventTarget {
|
|
|
294
294
|
protocol: "wc-bindable",
|
|
295
295
|
version: 1,
|
|
296
296
|
properties: [
|
|
297
|
-
{ name: "active", event: "wcs-camera:active-changed" },
|
|
298
|
-
{ name: "permission", event: "wcs-camera:permission-changed" },
|
|
299
|
-
{ name: "audioPermission", event: "wcs-camera:audio-permission-changed" },
|
|
300
|
-
{ name: "deviceId", event: "wcs-camera:device-changed" },
|
|
301
|
-
{ name: "devices", event: "wcs-camera:devices-changed" },
|
|
302
|
-
{ name: "error", event: "wcs-camera:error" },
|
|
297
|
+
{ name: "active", event: "wcs-camera:active-changed", semantics: "state" },
|
|
298
|
+
{ name: "permission", event: "wcs-camera:permission-changed", semantics: "state" },
|
|
299
|
+
{ name: "audioPermission", event: "wcs-camera:audio-permission-changed", semantics: "state" },
|
|
300
|
+
{ name: "deviceId", event: "wcs-camera:device-changed", semantics: "state" },
|
|
301
|
+
{ name: "devices", event: "wcs-camera:devices-changed", semantics: "state" },
|
|
302
|
+
{ name: "error", event: "wcs-camera:error", semantics: "state" },
|
|
303
303
|
// Serializable failure taxonomy (stable code / phase / recoverable), or null.
|
|
304
304
|
// Additive bindable output derived from `error` (the DOMException name /
|
|
305
305
|
// "unsupported" sentinel); the existing `error` property/event are unchanged.
|
|
306
306
|
// Fires wcs-camera:error-info-changed. No lane — acquisition is switchMap'd by
|
|
307
307
|
// `_gen`, so there is no per-node operation policy to attach here.
|
|
308
|
-
{ name: "errorInfo", event: "wcs-camera:error-info-changed" },
|
|
308
|
+
{ name: "errorInfo", event: "wcs-camera:error-info-changed", semantics: "state" },
|
|
309
309
|
// Direct-channel handle: event-token only — never bound as a reactive value.
|
|
310
|
-
{ name: "streamReady", event: "wcs-camera:stream-ready", getter: (e) => e.detail },
|
|
310
|
+
{ name: "streamReady", event: "wcs-camera:stream-ready", semantics: "handle", getter: (e) => e.detail },
|
|
311
311
|
// event-token: a bare signal (detail is always null) — surface detail, not the raw Event.
|
|
312
|
-
{ name: "ended", event: "wcs-camera:ended", getter: (e) => e.detail },
|
|
312
|
+
{ name: "ended", event: "wcs-camera:ended", semantics: "event", getter: (e) => e.detail },
|
|
313
313
|
],
|
|
314
314
|
commands: [
|
|
315
315
|
{ name: "start" },
|
|
@@ -638,6 +638,48 @@ class CameraCore extends EventTarget {
|
|
|
638
638
|
}
|
|
639
639
|
}
|
|
640
640
|
|
|
641
|
+
// ===========================================================================
|
|
642
|
+
// AUTO-GENERATED FILE - DO NOT EDIT.
|
|
643
|
+
// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.
|
|
644
|
+
// Run `node scripts/sync-protocol-types.mjs` after editing the source.
|
|
645
|
+
// ===========================================================================
|
|
646
|
+
function hasAccessorOnPrototype(target, name) {
|
|
647
|
+
let proto = Object.getPrototypeOf(target);
|
|
648
|
+
while (proto !== null) {
|
|
649
|
+
const descriptor = Object.getOwnPropertyDescriptor(proto, name);
|
|
650
|
+
if (descriptor !== undefined) {
|
|
651
|
+
return typeof descriptor.get === "function" || typeof descriptor.set === "function";
|
|
652
|
+
}
|
|
653
|
+
proto = Object.getPrototypeOf(proto);
|
|
654
|
+
}
|
|
655
|
+
return false;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で
|
|
659
|
+
* accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。
|
|
660
|
+
*
|
|
661
|
+
* - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。
|
|
662
|
+
* - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。
|
|
663
|
+
* - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。
|
|
664
|
+
*/
|
|
665
|
+
function upgradeProperties(element) {
|
|
666
|
+
const declaration = element.constructor?.wcBindable;
|
|
667
|
+
const inputs = declaration?.inputs;
|
|
668
|
+
if (inputs === undefined)
|
|
669
|
+
return;
|
|
670
|
+
for (const input of inputs) {
|
|
671
|
+
const name = input.name;
|
|
672
|
+
if (!Object.prototype.hasOwnProperty.call(element, name))
|
|
673
|
+
continue;
|
|
674
|
+
if (!hasAccessorOnPrototype(element, name))
|
|
675
|
+
continue;
|
|
676
|
+
const record = element;
|
|
677
|
+
const value = record[name];
|
|
678
|
+
delete record[name];
|
|
679
|
+
record[name] = value;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
|
|
641
683
|
/**
|
|
642
684
|
* `<wcs-camera>` — declarative camera capture with a built-in preview.
|
|
643
685
|
*
|
|
@@ -856,6 +898,8 @@ class WcsCamera extends HTMLElement {
|
|
|
856
898
|
};
|
|
857
899
|
// --- Lifecycle ---
|
|
858
900
|
connectedCallback() {
|
|
901
|
+
// upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)
|
|
902
|
+
upgradeProperties(this);
|
|
859
903
|
this._connected = true;
|
|
860
904
|
this._connectedCallbackPromise = this._core.observe(this._constraints());
|
|
861
905
|
if (this.autostart) {
|
|
@@ -928,23 +972,23 @@ class RecorderCore extends EventTarget {
|
|
|
928
972
|
protocol: "wc-bindable",
|
|
929
973
|
version: 1,
|
|
930
974
|
properties: [
|
|
931
|
-
{ name: "recording", event: "wcs-recorder:recording-changed" },
|
|
932
|
-
{ name: "paused", event: "wcs-recorder:paused-changed" },
|
|
933
|
-
{ name: "duration", event: "wcs-recorder:duration-changed" },
|
|
934
|
-
{ name: "mimeType", event: "wcs-recorder:mimetype-changed" },
|
|
935
|
-
{ name: "blob", event: "wcs-recorder:recorded", getter: (e) => e.detail?.blob ?? null },
|
|
936
|
-
{ name: "objectURL", event: "wcs-recorder:recorded", getter: (e) => e.detail?.objectURL ?? null },
|
|
937
|
-
{ name: "error", event: "wcs-recorder:error" },
|
|
975
|
+
{ name: "recording", event: "wcs-recorder:recording-changed", semantics: "state" },
|
|
976
|
+
{ name: "paused", event: "wcs-recorder:paused-changed", semantics: "state" },
|
|
977
|
+
{ name: "duration", event: "wcs-recorder:duration-changed", semantics: "state" },
|
|
978
|
+
{ name: "mimeType", event: "wcs-recorder:mimetype-changed", semantics: "state" },
|
|
979
|
+
{ name: "blob", event: "wcs-recorder:recorded", semantics: "state", getter: (e) => e.detail?.blob ?? null },
|
|
980
|
+
{ name: "objectURL", event: "wcs-recorder:recorded", semantics: "state", getter: (e) => e.detail?.objectURL ?? null },
|
|
981
|
+
{ name: "error", event: "wcs-recorder:error", semantics: "state" },
|
|
938
982
|
// Serializable failure taxonomy (stable code / phase / recoverable), or null.
|
|
939
983
|
// Additive bindable output derived from `error` (the DOMException name /
|
|
940
984
|
// "unsupported"/"NoStreamError"/"RecorderError" sentinel); the existing `error`
|
|
941
985
|
// property/event are unchanged. Fires wcs-recorder:error-info-changed. No lane —
|
|
942
986
|
// recording is command-driven.
|
|
943
|
-
{ name: "errorInfo", event: "wcs-recorder:error-info-changed" },
|
|
987
|
+
{ name: "errorInfo", event: "wcs-recorder:error-info-changed", semantics: "state" },
|
|
944
988
|
// event-token: detail = the assembled clip { blob, objectURL, mimeType, duration }.
|
|
945
|
-
{ name: "recorded", event: "wcs-recorder:recorded", getter: (e) => e.detail },
|
|
989
|
+
{ name: "recorded", event: "wcs-recorder:recorded", semantics: "event", getter: (e) => e.detail },
|
|
946
990
|
// event-token (timeslice mode): detail = the streamed Blob chunk.
|
|
947
|
-
{ name: "dataavailable", event: "wcs-recorder:dataavailable", getter: (e) => e.detail },
|
|
991
|
+
{ name: "dataavailable", event: "wcs-recorder:dataavailable", semantics: "event", getter: (e) => e.detail },
|
|
948
992
|
],
|
|
949
993
|
commands: [
|
|
950
994
|
{ name: "attachStream" },
|
|
@@ -1385,6 +1429,8 @@ class WcsRecorder extends HTMLElement {
|
|
|
1385
1429
|
}
|
|
1386
1430
|
// --- Lifecycle ---
|
|
1387
1431
|
connectedCallback() {
|
|
1432
|
+
// upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)
|
|
1433
|
+
upgradeProperties(this);
|
|
1388
1434
|
this.style.display = "none";
|
|
1389
1435
|
this._connectedCallbackPromise = this._core.observe();
|
|
1390
1436
|
}
|