@wcstack/camera 4.10.0 → 4.11.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.esm.js CHANGED
@@ -62,6 +62,8 @@ function setConfig(partialConfig) {
62
62
  frozenConfig = null;
63
63
  }
64
64
 
65
+ var pkg = {"name":"@wcstack/camera","version":"4.11.0"};
66
+
65
67
  // ===========================================================================
66
68
  // AUTO-GENERATED FILE - DO NOT EDIT.
67
69
  // Generated from /io-core/platform-capability.ts by scripts/sync-io-core.mjs.
@@ -1825,18 +1827,76 @@ class WcsRecorder extends HTMLElement {
1825
1827
  }
1826
1828
  }
1827
1829
 
1830
+ // ===========================================================================
1831
+ // AUTO-GENERATED FILE - DO NOT EDIT.
1832
+ // Generated from /protocol/define-element.ts by scripts/sync-protocol-types.mjs.
1833
+ // Run `node scripts/sync-protocol-types.mjs` after editing the source.
1834
+ // ===========================================================================
1835
+ /**
1836
+ * One copy of each package on a page (docs/timing-and-firing-contract.md §24). The first copy the
1837
+ * page evaluates defines the tags and a second one does nothing, so a copy that finds its tag defined
1838
+ * by another copy of the package — not its class, not a subclass of it, not the same version — warns
1839
+ * `[wcs/package-twice]` once per registry, naming both versions. The classes it defines carry
1840
+ * `"<package>@<version>"` under `Symbol.for("wcstack.package")`; a class without it is named
1841
+ * "another copy of <package> that does not name its version" (an older copy, or one loaded through
1842
+ * an entry that does not stamp).
1843
+ */
1844
+ /** The static a class defined through this helper carries: `"@wcstack/fetch@<version>"`. */
1845
+ const PACKAGE_STAMP = Symbol.for("wcstack.package");
1846
+ /** The registries this copy warned about: one warning per package per registry. */
1847
+ const warned = new WeakSet();
1848
+ /**
1849
+ * Marks `cls` as defined by `pkg` (`"@wcstack/fetch@<version>"`). A subclass inherits the mark, and
1850
+ * `defineProperty` writes it even where a parent's mark is read-only.
1851
+ */
1852
+ function stampPackage(cls, pkg) {
1853
+ Object.defineProperty(cls, PACKAGE_STAMP, { value: pkg, configurable: true });
1854
+ }
1855
+ /**
1856
+ * Warns when `tag` is defined as `existing` by another copy of the package `pkg` names: `existing`
1857
+ * is neither `own` nor a subclass of it (omit `own` when the copy has no class to compare with), and
1858
+ * carries another version or none. Once per registry.
1859
+ */
1860
+ function warnIfAnotherCopy(registry, tag, existing, own, pkg) {
1861
+ if (own !== undefined && (existing === own || existing.prototype instanceof own))
1862
+ return;
1863
+ const theirs = existing[PACKAGE_STAMP];
1864
+ if (theirs === pkg || warned.has(registry))
1865
+ return;
1866
+ warned.add(registry);
1867
+ const name = pkg.slice(0, pkg.lastIndexOf("@"));
1868
+ console.warn(`[${name}] [wcs/package-twice] <${tag}> is already defined by ` +
1869
+ `${theirs ?? `another copy of ${name} that does not name its version`}; ` +
1870
+ `this copy, ${pkg}, does nothing. Load each package once.`);
1871
+ }
1872
+ /**
1873
+ * Defines each `[tag, class]` in `registry` unless the tag is already defined, stamping the class
1874
+ * with `pkg` (`"@wcstack/fetch@<version>"`). A tag another copy of the package defined first is left
1875
+ * as it is, with the warning above.
1876
+ */
1877
+ function defineElements(registry, pkg, definitions) {
1878
+ for (const [tag, cls] of definitions) {
1879
+ const existing = registry.get(tag);
1880
+ if (existing === undefined) {
1881
+ stampPackage(cls, pkg);
1882
+ registry.define(tag, cls);
1883
+ }
1884
+ else {
1885
+ warnIfAnotherCopy(registry, tag, existing, cls, pkg);
1886
+ }
1887
+ }
1888
+ }
1889
+
1828
1890
  /**
1829
1891
  * Register this package's tags. Pass a scoped `CustomElementRegistry` to define
1830
1892
  * them for a single shadow tree -- scoped registries do not inherit the global
1831
1893
  * one, so a tree using one needs its own definitions.
1832
1894
  */
1833
1895
  function registerComponents(registry = customElements) {
1834
- if (!registry.get(config.tagNames.camera)) {
1835
- registry.define(config.tagNames.camera, WcsCamera);
1836
- }
1837
- if (!registry.get(config.tagNames.recorder)) {
1838
- registry.define(config.tagNames.recorder, WcsRecorder);
1839
- }
1896
+ defineElements(registry, `${pkg.name}@${pkg.version}`, [
1897
+ [config.tagNames.camera, WcsCamera],
1898
+ [config.tagNames.recorder, WcsRecorder],
1899
+ ]);
1840
1900
  }
1841
1901
 
1842
1902
  function bootstrapCamera(userConfig, registry) {