@wcstack/fetch 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
@@ -68,6 +68,8 @@ function setConfig(partialConfig) {
68
68
  frozenConfig = null;
69
69
  }
70
70
 
71
+ var pkg = {"name":"@wcstack/fetch","version":"4.11.0"};
72
+
71
73
  // ===========================================================================
72
74
  // AUTO-GENERATED FILE - DO NOT EDIT.
73
75
  // Generated from /io-core/operation-lane.ts by scripts/sync-io-core.mjs.
@@ -1797,24 +1799,78 @@ class InfiniteScroll extends HTMLElement {
1797
1799
  }
1798
1800
  }
1799
1801
 
1802
+ // ===========================================================================
1803
+ // AUTO-GENERATED FILE - DO NOT EDIT.
1804
+ // Generated from /protocol/define-element.ts by scripts/sync-protocol-types.mjs.
1805
+ // Run `node scripts/sync-protocol-types.mjs` after editing the source.
1806
+ // ===========================================================================
1807
+ /**
1808
+ * One copy of each package on a page (docs/timing-and-firing-contract.md §24). The first copy the
1809
+ * page evaluates defines the tags and a second one does nothing, so a copy that finds its tag defined
1810
+ * by another copy of the package — not its class, not a subclass of it, not the same version — warns
1811
+ * `[wcs/package-twice]` once per registry, naming both versions. The classes it defines carry
1812
+ * `"<package>@<version>"` under `Symbol.for("wcstack.package")`; a class without it is named
1813
+ * "another copy of <package> that does not name its version" (an older copy, or one loaded through
1814
+ * an entry that does not stamp).
1815
+ */
1816
+ /** The static a class defined through this helper carries: `"@wcstack/fetch@<version>"`. */
1817
+ const PACKAGE_STAMP = Symbol.for("wcstack.package");
1818
+ /** The registries this copy warned about: one warning per package per registry. */
1819
+ const warned = new WeakSet();
1820
+ /**
1821
+ * Marks `cls` as defined by `pkg` (`"@wcstack/fetch@<version>"`). A subclass inherits the mark, and
1822
+ * `defineProperty` writes it even where a parent's mark is read-only.
1823
+ */
1824
+ function stampPackage(cls, pkg) {
1825
+ Object.defineProperty(cls, PACKAGE_STAMP, { value: pkg, configurable: true });
1826
+ }
1827
+ /**
1828
+ * Warns when `tag` is defined as `existing` by another copy of the package `pkg` names: `existing`
1829
+ * is neither `own` nor a subclass of it (omit `own` when the copy has no class to compare with), and
1830
+ * carries another version or none. Once per registry.
1831
+ */
1832
+ function warnIfAnotherCopy(registry, tag, existing, own, pkg) {
1833
+ if (own !== undefined && (existing === own || existing.prototype instanceof own))
1834
+ return;
1835
+ const theirs = existing[PACKAGE_STAMP];
1836
+ if (theirs === pkg || warned.has(registry))
1837
+ return;
1838
+ warned.add(registry);
1839
+ const name = pkg.slice(0, pkg.lastIndexOf("@"));
1840
+ console.warn(`[${name}] [wcs/package-twice] <${tag}> is already defined by ` +
1841
+ `${theirs ?? `another copy of ${name} that does not name its version`}; ` +
1842
+ `this copy, ${pkg}, does nothing. Load each package once.`);
1843
+ }
1844
+ /**
1845
+ * Defines each `[tag, class]` in `registry` unless the tag is already defined, stamping the class
1846
+ * with `pkg` (`"@wcstack/fetch@<version>"`). A tag another copy of the package defined first is left
1847
+ * as it is, with the warning above.
1848
+ */
1849
+ function defineElements(registry, pkg, definitions) {
1850
+ for (const [tag, cls] of definitions) {
1851
+ const existing = registry.get(tag);
1852
+ if (existing === undefined) {
1853
+ stampPackage(cls, pkg);
1854
+ registry.define(tag, cls);
1855
+ }
1856
+ else {
1857
+ warnIfAnotherCopy(registry, tag, existing, cls, pkg);
1858
+ }
1859
+ }
1860
+ }
1861
+
1800
1862
  /**
1801
1863
  * Register this package's tags. Pass a scoped `CustomElementRegistry` to define
1802
1864
  * them for a single shadow tree -- scoped registries do not inherit the global
1803
1865
  * one, so a tree using one needs its own definitions.
1804
1866
  */
1805
1867
  function registerComponents(registry = customElements) {
1806
- if (!registry.get(config.tagNames.fetch)) {
1807
- registry.define(config.tagNames.fetch, Fetch);
1808
- }
1809
- if (!registry.get(config.tagNames.fetchHeader)) {
1810
- registry.define(config.tagNames.fetchHeader, FetchHeader);
1811
- }
1812
- if (!registry.get(config.tagNames.fetchBody)) {
1813
- registry.define(config.tagNames.fetchBody, FetchBody);
1814
- }
1815
- if (!registry.get(config.tagNames.infiniteScroll)) {
1816
- registry.define(config.tagNames.infiniteScroll, InfiniteScroll);
1817
- }
1868
+ defineElements(registry, `${pkg.name}@${pkg.version}`, [
1869
+ [config.tagNames.fetch, Fetch],
1870
+ [config.tagNames.fetchHeader, FetchHeader],
1871
+ [config.tagNames.fetchBody, FetchBody],
1872
+ [config.tagNames.infiniteScroll, InfiniteScroll],
1873
+ ]);
1818
1874
  }
1819
1875
 
1820
1876
  function bootstrapFetch(userConfig, registry) {