@wcstack/network 4.4.0 → 4.6.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/README.ja.md +1 -1
- package/README.md +1 -1
- package/dist/auto.d.ts +2 -0
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.esm.js +20 -0
- package/dist/index.esm.js.map +1 -1
- package/package.json +5 -2
package/README.ja.md
CHANGED
|
@@ -111,7 +111,7 @@ npm install @wcstack/network
|
|
|
111
111
|
| `supported` | `wcs-network:change` | 実在する `navigator.connection` が見つかれば `true`、それ以外は `false`。 |
|
|
112
112
|
| `offline` | `wcs-network:change` | `!navigator.onLine`。window の `online` / `offline` イベントで追う — `supported` に関わらずどのブラウザにもある。navigator が無ければ(SSR)`null`。ネットワークが要る操作を止めるのに束ねる(`data-wcs="offline: offline"` と `disabled: offline`)。`navigator.onLine` と同じく、`false` はネットワークがあることで、サーバーが応えることではない(`online` という名前にしないのは、`on` で始まる `data-wcs` の名前がイベントの束縛になるため)。 |
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
6 つすべては単一の `wcs-network:change` イベントから派生します(ネイティブ API が全フィールドを1つの `change` イベントで報告するのと同じく、スナップショット全体を1つのイベントにまとめて発火します)。また、`supported` が `true` の環境でも、ブラウザが該当フィールドを欠落または期待外の型で報告した場合、4 つのデータフィールドは個別に `null` へ正規化されます。
|
|
115
115
|
|
|
116
116
|
`downlinkMax` と接続種別(wifi/cellular等)の `type` は意図的に公開していません — 理由は `docs/network-tag-design.md` §2 を参照(実用上の使用例が乏しい、`type` はfingerprinting対策によりブラウザ間で信頼性が低い)。
|
|
117
117
|
|
package/README.md
CHANGED
|
@@ -111,7 +111,7 @@ Every bound state path must be declared up front — binding an undeclared path
|
|
|
111
111
|
| `supported` | `wcs-network:change` | `true` once a real `navigator.connection` was found; `false` otherwise. |
|
|
112
112
|
| `offline` | `wcs-network:change` | `!navigator.onLine`, followed through the window's `online` / `offline` events — every browser has it, whatever `supported` says. `null` without a navigator (SSR). Bind it to disable what needs the network (`data-wcs="offline: offline"` + `disabled: offline`). Like `navigator.onLine`, `false` means a network is there, not that your server answers. (It is not called `online`: a `data-wcs` name starting with `on` is an event binding.) |
|
|
113
113
|
|
|
114
|
-
All
|
|
114
|
+
All six derive from the single `wcs-network:change` event (a full snapshot dispatched together, mirroring how the native API reports all fields on one `change` event). The four data fields also normalize to `null` individually — even when `supported` is `true` — if the browser reports a field as missing or with an unexpected type.
|
|
115
115
|
|
|
116
116
|
`downlinkMax` and connection `type` (wifi/cellular/…) are intentionally not surfaced — see `docs/network-tag-design.md` §2 for the rationale (low real-world utility, and `type` is unreliable across browsers for fingerprinting-mitigation reasons).
|
|
117
117
|
|
package/dist/auto.d.ts
ADDED
package/dist/auto.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={tagNames:{network:"wcs-network"}},t=Object.freeze({effectiveType:null,downlink:null,rtt:null,saveData:null,supported:!1,offline:null});class n extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"effectiveType",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.effectiveType},{name:"downlink",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.downlink},{name:"rtt",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.rtt},{name:"saveData",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.saveData},{name:"supported",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.supported},{name:"offline",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.offline}],commands:[]};_target;_snapshot=t;_connection=null;_subscribed=!1;_ready=Promise.resolve();constructor(e){super(),this._target=e??this}get ready(){return this._ready}get effectiveType(){return this._snapshot.effectiveType}get downlink(){return this._snapshot.downlink}get rtt(){return this._snapshot.rtt}get saveData(){return this._snapshot.saveData}get supported(){return this._snapshot.supported}get offline(){return this._snapshot.offline}observe(){if(!this._subscribed){this._subscribed=!0;const e=this._api();e&&(this._connection=e,e.addEventListener("change",this._onChange)),this._window()?.addEventListener("online",this._onChange),this._window()?.addEventListener("offline",this._onChange),this._apply(this._read())}return this._ready}dispose(){this._subscribed=!1,this._connection&&(this._connection.removeEventListener("change",this._onChange),this._connection=null),this._window()?.removeEventListener("online",this._onChange),this._window()?.removeEventListener("offline",this._onChange)}_window(){const e=globalThis.window;return void 0!==e&&"function"==typeof e.addEventListener?e:void 0}_api(){const e=globalThis.navigator;return void 0!==e&&e.connection?e.connection:void 0}_read(){const e=this._api(),n=globalThis.navigator,s=void 0!==n&&"boolean"==typeof n.onLine?!n.onLine:null;return e?{offline:s,effectiveType:"string"==typeof e.effectiveType?e.effectiveType:null,downlink:"number"==typeof e.downlink?e.downlink:null,rtt:"number"==typeof e.rtt?e.rtt:null,saveData:"boolean"==typeof e.saveData?e.saveData:null,supported:!0}:null===s?t:{...t,offline:s}}_onChange=()=>{this._apply(this._read())};_apply(e){const t=this._snapshot;t.effectiveType===e.effectiveType&&t.downlink===e.downlink&&t.rtt===e.rtt&&t.saveData===e.saveData&&t.supported===e.supported&&t.offline===e.offline||(this._snapshot=e,this._target.dispatchEvent(new CustomEvent("wcs-network:change",{detail:e,bubbles:!0})))}}function s(e,t){let n=Object.getPrototypeOf(e);for(;null!==n;){const e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;n=Object.getPrototypeOf(n)}return!1}
|
|
1
|
+
const e={tagNames:{network:"wcs-network"}},t=Object.freeze({effectiveType:null,downlink:null,rtt:null,saveData:null,supported:!1,offline:null});class n extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"effectiveType",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.effectiveType},{name:"downlink",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.downlink},{name:"rtt",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.rtt},{name:"saveData",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.saveData},{name:"supported",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.supported},{name:"offline",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.offline}],commands:[]};_target;_snapshot=t;_connection=null;_subscribed=!1;_ready=Promise.resolve();constructor(e){super(),this._target=e??this}get ready(){return this._ready}get effectiveType(){return this._snapshot.effectiveType}get downlink(){return this._snapshot.downlink}get rtt(){return this._snapshot.rtt}get saveData(){return this._snapshot.saveData}get supported(){return this._snapshot.supported}get offline(){return this._snapshot.offline}observe(){if(!this._subscribed){this._subscribed=!0;const e=this._api();e&&(this._connection=e,e.addEventListener("change",this._onChange)),this._window()?.addEventListener("online",this._onChange),this._window()?.addEventListener("offline",this._onChange),this._apply(this._read())}return this._ready}dispose(){this._subscribed=!1,this._connection&&(this._connection.removeEventListener("change",this._onChange),this._connection=null),this._window()?.removeEventListener("online",this._onChange),this._window()?.removeEventListener("offline",this._onChange)}_window(){const e=globalThis.window;return void 0!==e&&"function"==typeof e.addEventListener?e:void 0}_api(){const e=globalThis.navigator;return void 0!==e&&e.connection?e.connection:void 0}_read(){const e=this._api(),n=globalThis.navigator,s=void 0!==n&&"boolean"==typeof n.onLine?!n.onLine:null;return e?{offline:s,effectiveType:"string"==typeof e.effectiveType?e.effectiveType:null,downlink:"number"==typeof e.downlink?e.downlink:null,rtt:"number"==typeof e.rtt?e.rtt:null,saveData:"boolean"==typeof e.saveData?e.saveData:null,supported:!0}:null===s?t:{...t,offline:s}}_onChange=()=>{this._apply(this._read())};_apply(e){const t=this._snapshot;t.effectiveType===e.effectiveType&&t.downlink===e.downlink&&t.rtt===e.rtt&&t.saveData===e.saveData&&t.supported===e.supported&&t.offline===e.offline||(this._snapshot=e,this._target.dispatchEvent(new CustomEvent("wcs-network:change",{detail:e,bubbles:!0})))}}function s(e,t){let n=Object.getPrototypeOf(e);for(;null!==n;){const e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;n=Object.getPrototypeOf(n)}return!1}const i=new WeakSet;function o(e,t,n){if(i.has(e))return;i.add(e);const s=e.localName??"element";console.warn(`[wcs/input-as-attribute] <${s}> has the attribute ${t}="${n}": an object was written as an attribute, so the element did not receive it. A framework does that when the property is set before the element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, or assign the property through a ref (Vue: .prop). (Said once per element.)`,e)}class a extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...n.wcBindable,inputs:[],commands:n.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new n(this),this._internals=this._initInternals(),this._wireStates({"wcs-network:change":e=>({"save-data":!0===e.saveData,supported:!0===e.supported,offline:!0===e.offline})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const e=this.attachInternals();return e.states.add("wcs-probe"),e.states.delete("wcs-probe"),e}catch{return null}}_wireStates(e){if(null===this._internals)return;const t=this._internals.states;for(const[n,s]of Object.entries(e))this.addEventListener(n,e=>{const n=this.hasAttribute("debug-states");for(const[i,o]of Object.entries(s(e.detail))){try{o?t.add(i):t.delete(i)}catch{}n&&this.toggleAttribute(`data-wcs-state-${i}`,o)}})}get effectiveType(){return this._core.effectiveType}get downlink(){return this._core.downlink}get rtt(){return this._core.rtt}get saveData(){return this._core.saveData}get supported(){return this._core.supported}get offline(){return this._core.offline}get connectedCallbackPromise(){return this._connectedCallbackPromise}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,n=t?.inputs;if(void 0===n)return;const i=e.getAttribute;for(const t of n){const n=t.name,a="function"==typeof i?i.call(e,n.toLowerCase()):null;if(null!==a&&a.startsWith("[object ")&&o(e,n,a),!Object.prototype.hasOwnProperty.call(e,n))continue;if(!s(e,n))continue;const r=e,c=r[n];delete r[n],r[n]=c}}(this),this.style.display="none",this._connectedCallbackPromise=this._core.observe()}disconnectedCallback(){this._core.dispose()}}var r;!function(t=customElements){t.get(e.tagNames.network)||t.define(e.tagNames.network,a)}(r);
|
|
2
2
|
//# sourceMappingURL=auto.min.js.map
|
package/dist/auto.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto.min.js","sources":["../src/config.ts","../src/core/NetworkCore.ts","../src/protocol/upgradeProperties.ts","../src/components/Network.ts","../src/bootstrapNetwork.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n network: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n network: \"wcs-network\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapNetwork` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/network] bootstrapNetwork: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","import { IWcBindable, WcsNetworkSnapshot } from \"../types.js\";\n\nconst UNSUPPORTED_SNAPSHOT: WcsNetworkSnapshot = Object.freeze({\n effectiveType: null,\n downlink: null,\n rtt: null,\n saveData: null,\n supported: false,\n offline: null,\n});\n\n/**\n * Headless Network Information primitive. A thin, framework-agnostic wrapper\n * around `navigator.connection` exposed through the wc-bindable protocol.\n *\n * Unlike most wcstack IO nodes, this Core needs no `_gen` generation guard\n * (§3.4): subscribing/unsubscribing to `navigator.connection`'s `change` event\n * is fully synchronous, so there is no asynchronous probe whose stale\n * resolution could race a dispose() (docs/network-tag-design.md §5).\n *\n * `navigator.connection` is unimplemented in Firefox/Safari — unsupported is\n * the common case here, not an edge case (docs/network-tag-design.md §0). All\n * four data fields collapse to `null` and `supported` to `false` in that case.\n */\nexport class NetworkCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"effectiveType\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.effectiveType },\n { name: \"downlink\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.downlink },\n { name: \"rtt\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.rtt },\n { name: \"saveData\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.saveData },\n { name: \"supported\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.supported },\n // Offline (docs/seam-apps.md, state-collab-board: a page had to listen on window itself). Not\n // `online`: a data-wcs name starting with `on` is an event binding.\n { name: \"offline\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.offline },\n ],\n // Pure monitor: navigator.connection has no request()/action method to invoke.\n commands: [],\n };\n\n private _target: EventTarget;\n private _snapshot: WcsNetworkSnapshot = UNSUPPORTED_SNAPSHOT;\n\n // The live NetworkInformation object the `change` listener is attached to (kept\n // so dispose() can remove it precisely; not read for anything else).\n private _connection: EventTarget | null = null;\n\n // True once observe() has attached the live listener (or determined there is\n // nothing to attach to). Guards observe() so a redundant call does not\n // re-subscribe; dispose() resets it so a later observe() resumes cleanly.\n private _subscribed = false;\n\n // SSR (§3.8): no asynchronous probe to await — observe() completes\n // synchronously, so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get effectiveType(): string | null {\n return this._snapshot.effectiveType;\n }\n\n get downlink(): number | null {\n return this._snapshot.downlink;\n }\n\n get rtt(): number | null {\n return this._snapshot.rtt;\n }\n\n get saveData(): boolean | null {\n return this._snapshot.saveData;\n }\n\n get supported(): boolean {\n return this._snapshot.supported;\n }\n\n get offline(): boolean | null {\n return this._snapshot.offline;\n }\n\n // Lifecycle (§3.5). Idempotent: a second observe() while already subscribed\n // is a no-op (no double listener, no redundant dispatch). Synchronous overall\n // (no probe to await), so the returned promise is only for API uniformity\n // with other IO nodes.\n observe(): Promise<void> {\n if (!this._subscribed) {\n this._subscribed = true;\n const api = this._api();\n if (api) {\n this._connection = api;\n api.addEventListener(\"change\", this._onChange);\n }\n this._window()?.addEventListener(\"online\", this._onChange);\n this._window()?.addEventListener(\"offline\", this._onChange);\n this._apply(this._read());\n }\n return this._ready;\n }\n\n dispose(): void {\n this._subscribed = false;\n if (this._connection) {\n this._connection.removeEventListener(\"change\", this._onChange);\n this._connection = null;\n }\n this._window()?.removeEventListener(\"online\", this._onChange);\n this._window()?.removeEventListener(\"offline\", this._onChange);\n }\n\n /** The window the online / offline events fire on (none under SSR). Call-time, as _api(). */\n private _window(): EventTarget | undefined {\n const w = (globalThis as any).window;\n return typeof w !== \"undefined\" && typeof w.addEventListener === \"function\" ? w : undefined;\n }\n\n // API resolution is call-time, never cached (§3.7): lets tests install/remove\n // navigator.connection freely and lets an unsupported environment be detected\n // correctly on every observe()/reading.\n private _api(): (EventTarget & { effectiveType?: string; downlink?: number; rtt?: number; saveData?: boolean }) | undefined {\n const nav = (globalThis as any).navigator;\n return typeof nav !== \"undefined\" && nav.connection ? nav.connection : undefined;\n }\n\n private _read(): WcsNetworkSnapshot {\n const c = this._api();\n const nav = (globalThis as any).navigator;\n const offline = typeof nav !== \"undefined\" && typeof nav.onLine === \"boolean\" ? !nav.onLine : null;\n if (!c) {\n return offline === null ? UNSUPPORTED_SNAPSHOT : { ...UNSUPPORTED_SNAPSHOT, offline };\n }\n return {\n offline,\n effectiveType: typeof c.effectiveType === \"string\" ? c.effectiveType : null,\n downlink: typeof c.downlink === \"number\" ? c.downlink : null,\n rtt: typeof c.rtt === \"number\" ? c.rtt : null,\n saveData: typeof c.saveData === \"boolean\" ? c.saveData : null,\n supported: true,\n };\n }\n\n private _onChange = (): void => {\n this._apply(this._read());\n };\n\n // Same-value guard (§3.3 MUST): the native `change` event already fires only\n // on a real change, but this Core still verifies field-by-field before\n // dispatching — defense in depth against a browser quirk double-firing\n // `change` with identical values.\n private _apply(next: WcsNetworkSnapshot): void {\n const prev = this._snapshot;\n if (\n prev.effectiveType === next.effectiveType &&\n prev.downlink === next.downlink &&\n prev.rtt === next.rtt &&\n prev.saveData === next.saveData &&\n prev.supported === next.supported &&\n prev.offline === next.offline\n ) {\n return;\n }\n this._snapshot = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-network:change\", {\n detail: next,\n // Family-wide MUST (async-io-node-guidelines.md §3.3): the event bubbles\n // from the Shell element so document-level consumers can delegate.\n bubbles: true,\n }));\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n for (const input of inputs) {\n const name = input.name;\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","import { IWcBindable } from \"../types.js\";\nimport { NetworkCore } from \"../core/NetworkCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\n\n/**\n * `<wcs-network>` — declarative Network Information API monitor.\n *\n * The smallest Shell in the batch (docs/network-tag-design.md §9): no\n * attributes at all. `navigator.connection` is a single global with nothing to\n * configure, unlike target-based nodes (`intersection`/`resize`) or\n * descriptor-based ones (`permission`).\n */\nexport class WcsNetwork extends HTMLElement {\n // SSR (§4.4): observe() completes synchronously, but the Shell still exposes\n // connectedCallbackPromise so SSR (@wcstack/server render.ts) can await it\n // uniformly across all IO nodes before snapshotting the HTML. Mirrors\n // WcsPermission.connectedCallbackPromise.\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...NetworkCore.wcBindable,\n inputs: [],\n // Core の commands をそのまま継承(単一情報源)。permission と同型。\n commands: NetworkCore.wcBindable.commands,\n };\n\n private _core: NetworkCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new NetworkCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-network:change\": (d) => ({\n \"save-data\": d.saveData === true,\n supported: d.supported === true,\n offline: d.offline === true,\n }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Core delegated getters ---\n\n get effectiveType(): string | null {\n return this._core.effectiveType;\n }\n\n get downlink(): number | null {\n return this._core.downlink;\n }\n\n get rtt(): number | null {\n return this._core.rtt;\n }\n\n get saveData(): boolean | null {\n return this._core.saveData;\n }\n\n get supported(): boolean {\n return this._core.supported;\n }\n\n get offline(): boolean | null {\n return this._core.offline;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n this._connectedCallbackPromise = this._core.observe();\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapNetwork(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n","import { WcsNetwork } from \"./components/Network.js\";\nimport { config } from \"./config.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n if (!registry.get(config.tagNames.network)) {\n registry.define(config.tagNames.network, WcsNetwork);\n }\n}\n"],"names":["config","tagNames","network","UNSUPPORTED_SNAPSHOT","Object","freeze","effectiveType","downlink","rtt","saveData","supported","offline","NetworkCore","EventTarget","static","protocol","version","properties","name","event","semantics","getter","e","detail","commands","_target","_snapshot","_connection","_subscribed","_ready","Promise","resolve","constructor","target","super","this","ready","observe","api","_api","addEventListener","_onChange","_window","_apply","_read","dispose","removeEventListener","w","globalThis","window","undefined","nav","navigator","connection","c","onLine","next","prev","dispatchEvent","CustomEvent","bubbles","hasAccessorOnPrototype","proto","getPrototypeOf","descriptor","getOwnPropertyDescriptor","get","set","WcsNetwork","HTMLElement","wcBindable","inputs","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","add","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","connectedCallbackPromise","connectedCallback","element","declaration","input","prototype","hasOwnProperty","call","record","value","upgradeProperties","style","display","disconnectedCallback","registry","customElements","define","registerComponents"],"mappings":"AAQA,MA0BaA,EA1BoB,CAC/BC,SAAU,CACRC,QAAS,gBCRPC,EAA2CC,OAAOC,OAAO,CAC7DC,cAAe,KACfC,SAAU,KACVC,IAAK,KACLC,SAAU,KACVC,WAAW,EACXC,QAAS,OAgBL,MAAOC,UAAoBC,YAC/BC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,gBAAiBC,MAAO,qBAAsBC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOjB,eAC1H,CAAEY,KAAM,WAAYC,MAAO,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workCore.ts","../src/protocol/upgradeProperties.ts","../src/components/Network.ts","../src/bootstrapNetwork.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n network: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n network: \"wcs-network\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapNetwork` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/network] bootstrapNetwork: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","import { IWcBindable, WcsNetworkSnapshot } from \"../types.js\";\n\nconst UNSUPPORTED_SNAPSHOT: WcsNetworkSnapshot = Object.freeze({\n effectiveType: null,\n downlink: null,\n rtt: null,\n saveData: null,\n supported: false,\n offline: null,\n});\n\n/**\n * Headless Network Information primitive. A thin, framework-agnostic wrapper\n * around `navigator.connection` exposed through the wc-bindable protocol.\n *\n * Unlike most wcstack IO nodes, this Core needs no `_gen` generation guard\n * (§3.4): subscribing/unsubscribing to `navigator.connection`'s `change` event\n * is fully synchronous, so there is no asynchronous probe whose stale\n * resolution could race a dispose() (docs/network-tag-design.md §5).\n *\n * `navigator.connection` is unimplemented in Firefox/Safari — unsupported is\n * the common case here, not an edge case (docs/network-tag-design.md §0). All\n * four data fields collapse to `null` and `supported` to `false` in that case.\n */\nexport class NetworkCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"effectiveType\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.effectiveType },\n { name: \"downlink\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.downlink },\n { name: \"rtt\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.rtt },\n { name: \"saveData\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.saveData },\n { name: \"supported\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.supported },\n // Offline (docs/seam-apps.md, state-collab-board: a page had to listen on window itself). Not\n // `online`: a data-wcs name starting with `on` is an event binding.\n { name: \"offline\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.offline },\n ],\n // Pure monitor: navigator.connection has no request()/action method to invoke.\n commands: [],\n };\n\n private _target: EventTarget;\n private _snapshot: WcsNetworkSnapshot = UNSUPPORTED_SNAPSHOT;\n\n // The live NetworkInformation object the `change` listener is attached to (kept\n // so dispose() can remove it precisely; not read for anything else).\n private _connection: EventTarget | null = null;\n\n // True once observe() has attached the live listener (or determined there is\n // nothing to attach to). Guards observe() so a redundant call does not\n // re-subscribe; dispose() resets it so a later observe() resumes cleanly.\n private _subscribed = false;\n\n // SSR (§3.8): no asynchronous probe to await — observe() completes\n // synchronously, so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get effectiveType(): string | null {\n return this._snapshot.effectiveType;\n }\n\n get downlink(): number | null {\n return this._snapshot.downlink;\n }\n\n get rtt(): number | null {\n return this._snapshot.rtt;\n }\n\n get saveData(): boolean | null {\n return this._snapshot.saveData;\n }\n\n get supported(): boolean {\n return this._snapshot.supported;\n }\n\n get offline(): boolean | null {\n return this._snapshot.offline;\n }\n\n // Lifecycle (§3.5). Idempotent: a second observe() while already subscribed\n // is a no-op (no double listener, no redundant dispatch). Synchronous overall\n // (no probe to await), so the returned promise is only for API uniformity\n // with other IO nodes.\n observe(): Promise<void> {\n if (!this._subscribed) {\n this._subscribed = true;\n const api = this._api();\n if (api) {\n this._connection = api;\n api.addEventListener(\"change\", this._onChange);\n }\n this._window()?.addEventListener(\"online\", this._onChange);\n this._window()?.addEventListener(\"offline\", this._onChange);\n this._apply(this._read());\n }\n return this._ready;\n }\n\n dispose(): void {\n this._subscribed = false;\n if (this._connection) {\n this._connection.removeEventListener(\"change\", this._onChange);\n this._connection = null;\n }\n this._window()?.removeEventListener(\"online\", this._onChange);\n this._window()?.removeEventListener(\"offline\", this._onChange);\n }\n\n /** The window the online / offline events fire on (none under SSR). Call-time, as _api(). */\n private _window(): EventTarget | undefined {\n const w = (globalThis as any).window;\n return typeof w !== \"undefined\" && typeof w.addEventListener === \"function\" ? w : undefined;\n }\n\n // API resolution is call-time, never cached (§3.7): lets tests install/remove\n // navigator.connection freely and lets an unsupported environment be detected\n // correctly on every observe()/reading.\n private _api(): (EventTarget & { effectiveType?: string; downlink?: number; rtt?: number; saveData?: boolean }) | undefined {\n const nav = (globalThis as any).navigator;\n return typeof nav !== \"undefined\" && nav.connection ? nav.connection : undefined;\n }\n\n private _read(): WcsNetworkSnapshot {\n const c = this._api();\n const nav = (globalThis as any).navigator;\n const offline = typeof nav !== \"undefined\" && typeof nav.onLine === \"boolean\" ? !nav.onLine : null;\n if (!c) {\n return offline === null ? UNSUPPORTED_SNAPSHOT : { ...UNSUPPORTED_SNAPSHOT, offline };\n }\n return {\n offline,\n effectiveType: typeof c.effectiveType === \"string\" ? c.effectiveType : null,\n downlink: typeof c.downlink === \"number\" ? c.downlink : null,\n rtt: typeof c.rtt === \"number\" ? c.rtt : null,\n saveData: typeof c.saveData === \"boolean\" ? c.saveData : null,\n supported: true,\n };\n }\n\n private _onChange = (): void => {\n this._apply(this._read());\n };\n\n // Same-value guard (§3.3 MUST): the native `change` event already fires only\n // on a real change, but this Core still verifies field-by-field before\n // dispatching — defense in depth against a browser quirk double-firing\n // `change` with identical values.\n private _apply(next: WcsNetworkSnapshot): void {\n const prev = this._snapshot;\n if (\n prev.effectiveType === next.effectiveType &&\n prev.downlink === next.downlink &&\n prev.rtt === next.rtt &&\n prev.saveData === next.saveData &&\n prev.supported === next.supported &&\n prev.offline === next.offline\n ) {\n return;\n }\n this._snapshot = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-network:change\", {\n detail: next,\n // Family-wide MUST (async-io-node-guidelines.md §3.3): the event bubbles\n // from the Shell element so document-level consumers can delegate.\n bubbles: true,\n }));\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","import { IWcBindable } from \"../types.js\";\nimport { NetworkCore } from \"../core/NetworkCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\n\n/**\n * `<wcs-network>` — declarative Network Information API monitor.\n *\n * The smallest Shell in the batch (docs/network-tag-design.md §9): no\n * attributes at all. `navigator.connection` is a single global with nothing to\n * configure, unlike target-based nodes (`intersection`/`resize`) or\n * descriptor-based ones (`permission`).\n */\nexport class WcsNetwork extends HTMLElement {\n // SSR (§4.4): observe() completes synchronously, but the Shell still exposes\n // connectedCallbackPromise so SSR (@wcstack/server render.ts) can await it\n // uniformly across all IO nodes before snapshotting the HTML. Mirrors\n // WcsPermission.connectedCallbackPromise.\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...NetworkCore.wcBindable,\n inputs: [],\n // Core の commands をそのまま継承(単一情報源)。permission と同型。\n commands: NetworkCore.wcBindable.commands,\n };\n\n private _core: NetworkCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new NetworkCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-network:change\": (d) => ({\n \"save-data\": d.saveData === true,\n supported: d.supported === true,\n offline: d.offline === true,\n }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Core delegated getters ---\n\n get effectiveType(): string | null {\n return this._core.effectiveType;\n }\n\n get downlink(): number | null {\n return this._core.downlink;\n }\n\n get rtt(): number | null {\n return this._core.rtt;\n }\n\n get saveData(): boolean | null {\n return this._core.saveData;\n }\n\n get supported(): boolean {\n return this._core.supported;\n }\n\n get offline(): boolean | null {\n return this._core.offline;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n this._connectedCallbackPromise = this._core.observe();\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapNetwork(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n","import { WcsNetwork } from \"./components/Network.js\";\nimport { config } from \"./config.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n if (!registry.get(config.tagNames.network)) {\n registry.define(config.tagNames.network, WcsNetwork);\n }\n}\n"],"names":["config","tagNames","network","UNSUPPORTED_SNAPSHOT","Object","freeze","effectiveType","downlink","rtt","saveData","supported","offline","NetworkCore","EventTarget","static","protocol","version","properties","name","event","semantics","getter","e","detail","commands","_target","_snapshot","_connection","_subscribed","_ready","Promise","resolve","constructor","target","super","this","ready","observe","api","_api","addEventListener","_onChange","_window","_apply","_read","dispose","removeEventListener","w","globalThis","window","undefined","nav","navigator","connection","c","onLine","next","prev","dispatchEvent","CustomEvent","bubbles","hasAccessorOnPrototype","proto","getPrototypeOf","descriptor","getOwnPropertyDescriptor","get","set","toldObjectAttribute","WeakSet","warnObjectAttribute","element","value","has","add","tag","localName","console","warn","WcsNetwork","HTMLElement","wcBindable","inputs","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","connectedCallbackPromise","connectedCallback","declaration","getAttribute","input","attribute","call","toLowerCase","startsWith","prototype","hasOwnProperty","record","upgradeProperties","style","display","disconnectedCallback","registry","customElements","define","registerComponents"],"mappings":"AAQA,MA0BaA,EA1BoB,CAC/BC,SAAU,CACRC,QAAS,gBCRPC,EAA2CC,OAAOC,OAAO,CAC7DC,cAAe,KACfC,SAAU,KACVC,IAAK,KACLC,SAAU,KACVC,WAAW,EACXC,QAAS,OAgBL,MAAOC,UAAoBC,YAC/BC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,gBAAiBC,MAAO,qBAAsBC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOjB,eAC1H,CAAEY,KAAM,WAAYC,MAAO,qBAAsBC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOhB,UACrH,CAAEW,KAAM,MAAOC,MAAO,qBAAsBC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOf,KAChH,CAAEU,KAAM,WAAYC,MAAO,qBAAsBC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOd,UACrH,CAAES,KAAM,YAAaC,MAAO,qBAAsBC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOb,WAGtH,CAAEQ,KAAM,UAAWC,MAAO,qBAAsBC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOZ,UAGtHa,SAAU,IAGJC,QACAC,UAAgCvB,EAIhCwB,YAAkC,KAKlCC,aAAc,EAIdC,OAAwBC,QAAQC,UAExC,WAAAC,CAAYC,GACVC,QACAC,KAAKV,QAAUQ,G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AAO2B,KAAKgD,MAAM3E,GACpB,CAEA,YAAIC,GACF,OAAO0B,KAAKgD,MAAM1E,QACpB,CAEA,aAAIC,GACF,OAAOyB,KAAKgD,MAAMzE,SACpB,CAEA,WAAIC,GACF,OAAOwB,KAAKgD,MAAMxE,OACpB,CAEA,4BAAI0F,GACF,OAAOlE,KAAKiD,yBACd,CAIA,iBAAAkB,IDlDI,SAA4B/B,GAChC,MAAMgC,EAAehC,EAA2DvC,aAAaiD,WACvFC,EAASqB,GAAarB,OAC5B,QAAehC,IAAXgC,EAAsB,OAC1B,MAAMsB,EAAgBjC,EAA+DiC,aACrF,IAAK,MAAMC,KAASvB,EAAQ,CAC1B,MAAMhE,EAAOuF,EAAMvF,KACbwF,EAAoC,mBAAjBF,EAA8BA,EAAaG,KAAKpC,EAASrD,EAAK0F,eAAiB,KAExG,GADkB,OAAdF,GAAsBA,EAAUG,WAAW,aAAavC,EAAoBC,EAASrD,EAAMwF,IAC1FtG,OAAO0G,UAAUC,eAAeJ,KAAKpC,EAASrD,GAAO,SAC1D,IAAK2C,EAAuBU,EAASrD,GAAO,SAC5C,MAAM8F,EAASzC,EACTC,EAAQwC,EAAO9F,UACd8F,EAAO9F,GACd8F,EAAO9F,GAAQsD,CACjB,CACF,CCoCIyC,CAAkB9E,MAClBA,KAAK+E,MAAMC,QAAU,OACrBhF,KAAKiD,0BAA4BjD,KAAKgD,MAAM9C,SAC9C,CAEA,oBAAA+E,GACEjF,KAAKgD,MAAMtC,SACb,ECzHI,IAAyDwE,GCIzD,SAA6BA,EAAkCC,gBAC9DD,EAASnD,IAAIlE,EAAOC,SAASC,UAChCmH,EAASE,OAAOvH,EAAOC,SAASC,QAAS6E,EAE7C,CDJEyC,CAAmBH"}
|
package/dist/index.esm.js
CHANGED
|
@@ -231,6 +231,21 @@ function hasAccessorOnPrototype(target, name) {
|
|
|
231
231
|
}
|
|
232
232
|
return false;
|
|
233
233
|
}
|
|
234
|
+
// 属性になってしまったオブジェクトの入力(`files="[object File]"`)を、要素ごとに 1 回だけ言う。
|
|
235
|
+
// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も
|
|
236
|
+
// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった
|
|
237
|
+
// (docs/seam-apps.md、fw-inventory)。
|
|
238
|
+
const toldObjectAttribute = new WeakSet();
|
|
239
|
+
function warnObjectAttribute(element, name, value) {
|
|
240
|
+
if (toldObjectAttribute.has(element))
|
|
241
|
+
return;
|
|
242
|
+
toldObjectAttribute.add(element);
|
|
243
|
+
const tag = element.localName ?? "element";
|
|
244
|
+
console.warn(`[wcs/input-as-attribute] <${tag}> has the attribute ${name}="${value}": an object was written as an ` +
|
|
245
|
+
`attribute, so the element did not receive it. A framework does that when the property is set before the ` +
|
|
246
|
+
`element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +
|
|
247
|
+
`or assign the property through a ref (Vue: .prop). (Said once per element.)`, element);
|
|
248
|
+
}
|
|
234
249
|
/**
|
|
235
250
|
* `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で
|
|
236
251
|
* accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。
|
|
@@ -238,14 +253,19 @@ function hasAccessorOnPrototype(target, name) {
|
|
|
238
253
|
* - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。
|
|
239
254
|
* - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。
|
|
240
255
|
* - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。
|
|
256
|
+
* - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。
|
|
241
257
|
*/
|
|
242
258
|
function upgradeProperties(element) {
|
|
243
259
|
const declaration = element.constructor?.wcBindable;
|
|
244
260
|
const inputs = declaration?.inputs;
|
|
245
261
|
if (inputs === undefined)
|
|
246
262
|
return;
|
|
263
|
+
const getAttribute = element.getAttribute;
|
|
247
264
|
for (const input of inputs) {
|
|
248
265
|
const name = input.name;
|
|
266
|
+
const attribute = typeof getAttribute === "function" ? getAttribute.call(element, name.toLowerCase()) : null;
|
|
267
|
+
if (attribute !== null && attribute.startsWith("[object "))
|
|
268
|
+
warnObjectAttribute(element, name, attribute);
|
|
249
269
|
if (!Object.prototype.hasOwnProperty.call(element, name))
|
|
250
270
|
continue;
|
|
251
271
|
if (!hasAccessorOnPrototype(element, name))
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/NetworkCore.ts","../src/protocol/upgradeProperties.ts","../src/components/Network.ts","../src/registerComponents.ts","../src/bootstrapNetwork.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n network: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n network: \"wcs-network\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapNetwork` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/network] bootstrapNetwork: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","import { IWcBindable, WcsNetworkSnapshot } from \"../types.js\";\n\nconst UNSUPPORTED_SNAPSHOT: WcsNetworkSnapshot = Object.freeze({\n effectiveType: null,\n downlink: null,\n rtt: null,\n saveData: null,\n supported: false,\n offline: null,\n});\n\n/**\n * Headless Network Information primitive. A thin, framework-agnostic wrapper\n * around `navigator.connection` exposed through the wc-bindable protocol.\n *\n * Unlike most wcstack IO nodes, this Core needs no `_gen` generation guard\n * (§3.4): subscribing/unsubscribing to `navigator.connection`'s `change` event\n * is fully synchronous, so there is no asynchronous probe whose stale\n * resolution could race a dispose() (docs/network-tag-design.md §5).\n *\n * `navigator.connection` is unimplemented in Firefox/Safari — unsupported is\n * the common case here, not an edge case (docs/network-tag-design.md §0). All\n * four data fields collapse to `null` and `supported` to `false` in that case.\n */\nexport class NetworkCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"effectiveType\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.effectiveType },\n { name: \"downlink\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.downlink },\n { name: \"rtt\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.rtt },\n { name: \"saveData\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.saveData },\n { name: \"supported\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.supported },\n // Offline (docs/seam-apps.md, state-collab-board: a page had to listen on window itself). Not\n // `online`: a data-wcs name starting with `on` is an event binding.\n { name: \"offline\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.offline },\n ],\n // Pure monitor: navigator.connection has no request()/action method to invoke.\n commands: [],\n };\n\n private _target: EventTarget;\n private _snapshot: WcsNetworkSnapshot = UNSUPPORTED_SNAPSHOT;\n\n // The live NetworkInformation object the `change` listener is attached to (kept\n // so dispose() can remove it precisely; not read for anything else).\n private _connection: EventTarget | null = null;\n\n // True once observe() has attached the live listener (or determined there is\n // nothing to attach to). Guards observe() so a redundant call does not\n // re-subscribe; dispose() resets it so a later observe() resumes cleanly.\n private _subscribed = false;\n\n // SSR (§3.8): no asynchronous probe to await — observe() completes\n // synchronously, so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get effectiveType(): string | null {\n return this._snapshot.effectiveType;\n }\n\n get downlink(): number | null {\n return this._snapshot.downlink;\n }\n\n get rtt(): number | null {\n return this._snapshot.rtt;\n }\n\n get saveData(): boolean | null {\n return this._snapshot.saveData;\n }\n\n get supported(): boolean {\n return this._snapshot.supported;\n }\n\n get offline(): boolean | null {\n return this._snapshot.offline;\n }\n\n // Lifecycle (§3.5). Idempotent: a second observe() while already subscribed\n // is a no-op (no double listener, no redundant dispatch). Synchronous overall\n // (no probe to await), so the returned promise is only for API uniformity\n // with other IO nodes.\n observe(): Promise<void> {\n if (!this._subscribed) {\n this._subscribed = true;\n const api = this._api();\n if (api) {\n this._connection = api;\n api.addEventListener(\"change\", this._onChange);\n }\n this._window()?.addEventListener(\"online\", this._onChange);\n this._window()?.addEventListener(\"offline\", this._onChange);\n this._apply(this._read());\n }\n return this._ready;\n }\n\n dispose(): void {\n this._subscribed = false;\n if (this._connection) {\n this._connection.removeEventListener(\"change\", this._onChange);\n this._connection = null;\n }\n this._window()?.removeEventListener(\"online\", this._onChange);\n this._window()?.removeEventListener(\"offline\", this._onChange);\n }\n\n /** The window the online / offline events fire on (none under SSR). Call-time, as _api(). */\n private _window(): EventTarget | undefined {\n const w = (globalThis as any).window;\n return typeof w !== \"undefined\" && typeof w.addEventListener === \"function\" ? w : undefined;\n }\n\n // API resolution is call-time, never cached (§3.7): lets tests install/remove\n // navigator.connection freely and lets an unsupported environment be detected\n // correctly on every observe()/reading.\n private _api(): (EventTarget & { effectiveType?: string; downlink?: number; rtt?: number; saveData?: boolean }) | undefined {\n const nav = (globalThis as any).navigator;\n return typeof nav !== \"undefined\" && nav.connection ? nav.connection : undefined;\n }\n\n private _read(): WcsNetworkSnapshot {\n const c = this._api();\n const nav = (globalThis as any).navigator;\n const offline = typeof nav !== \"undefined\" && typeof nav.onLine === \"boolean\" ? !nav.onLine : null;\n if (!c) {\n return offline === null ? UNSUPPORTED_SNAPSHOT : { ...UNSUPPORTED_SNAPSHOT, offline };\n }\n return {\n offline,\n effectiveType: typeof c.effectiveType === \"string\" ? c.effectiveType : null,\n downlink: typeof c.downlink === \"number\" ? c.downlink : null,\n rtt: typeof c.rtt === \"number\" ? c.rtt : null,\n saveData: typeof c.saveData === \"boolean\" ? c.saveData : null,\n supported: true,\n };\n }\n\n private _onChange = (): void => {\n this._apply(this._read());\n };\n\n // Same-value guard (§3.3 MUST): the native `change` event already fires only\n // on a real change, but this Core still verifies field-by-field before\n // dispatching — defense in depth against a browser quirk double-firing\n // `change` with identical values.\n private _apply(next: WcsNetworkSnapshot): void {\n const prev = this._snapshot;\n if (\n prev.effectiveType === next.effectiveType &&\n prev.downlink === next.downlink &&\n prev.rtt === next.rtt &&\n prev.saveData === next.saveData &&\n prev.supported === next.supported &&\n prev.offline === next.offline\n ) {\n return;\n }\n this._snapshot = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-network:change\", {\n detail: next,\n // Family-wide MUST (async-io-node-guidelines.md §3.3): the event bubbles\n // from the Shell element so document-level consumers can delegate.\n bubbles: true,\n }));\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n for (const input of inputs) {\n const name = input.name;\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","import { IWcBindable } from \"../types.js\";\nimport { NetworkCore } from \"../core/NetworkCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\n\n/**\n * `<wcs-network>` — declarative Network Information API monitor.\n *\n * The smallest Shell in the batch (docs/network-tag-design.md §9): no\n * attributes at all. `navigator.connection` is a single global with nothing to\n * configure, unlike target-based nodes (`intersection`/`resize`) or\n * descriptor-based ones (`permission`).\n */\nexport class WcsNetwork extends HTMLElement {\n // SSR (§4.4): observe() completes synchronously, but the Shell still exposes\n // connectedCallbackPromise so SSR (@wcstack/server render.ts) can await it\n // uniformly across all IO nodes before snapshotting the HTML. Mirrors\n // WcsPermission.connectedCallbackPromise.\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...NetworkCore.wcBindable,\n inputs: [],\n // Core の commands をそのまま継承(単一情報源)。permission と同型。\n commands: NetworkCore.wcBindable.commands,\n };\n\n private _core: NetworkCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new NetworkCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-network:change\": (d) => ({\n \"save-data\": d.saveData === true,\n supported: d.supported === true,\n offline: d.offline === true,\n }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Core delegated getters ---\n\n get effectiveType(): string | null {\n return this._core.effectiveType;\n }\n\n get downlink(): number | null {\n return this._core.downlink;\n }\n\n get rtt(): number | null {\n return this._core.rtt;\n }\n\n get saveData(): boolean | null {\n return this._core.saveData;\n }\n\n get supported(): boolean {\n return this._core.supported;\n }\n\n get offline(): boolean | null {\n return this._core.offline;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n this._connectedCallbackPromise = this._core.observe();\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","import { WcsNetwork } from \"./components/Network.js\";\nimport { config } from \"./config.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n if (!registry.get(config.tagNames.network)) {\n registry.define(config.tagNames.network, WcsNetwork);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapNetwork(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":[],"mappings":"AAQA,MAAM,OAAO,GAAoB;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,OAAO,EAAE,aAAa;AACvB,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,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;AC1HF;;;;AAIG;AACG,SAAU,kBAAkB,CAAC,QAAA,GAAkC,cAAc,EAAA;AACjF,IAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QAC1C,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IACtD;AACF;;ACRM,SAAU,gBAAgB,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAC7F,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;IACA,kBAAkB,CAAC,QAAQ,CAAC;AAC9B;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/NetworkCore.ts","../src/protocol/upgradeProperties.ts","../src/components/Network.ts","../src/registerComponents.ts","../src/bootstrapNetwork.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n network: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n network: \"wcs-network\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapNetwork` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/network] bootstrapNetwork: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","import { IWcBindable, WcsNetworkSnapshot } from \"../types.js\";\n\nconst UNSUPPORTED_SNAPSHOT: WcsNetworkSnapshot = Object.freeze({\n effectiveType: null,\n downlink: null,\n rtt: null,\n saveData: null,\n supported: false,\n offline: null,\n});\n\n/**\n * Headless Network Information primitive. A thin, framework-agnostic wrapper\n * around `navigator.connection` exposed through the wc-bindable protocol.\n *\n * Unlike most wcstack IO nodes, this Core needs no `_gen` generation guard\n * (§3.4): subscribing/unsubscribing to `navigator.connection`'s `change` event\n * is fully synchronous, so there is no asynchronous probe whose stale\n * resolution could race a dispose() (docs/network-tag-design.md §5).\n *\n * `navigator.connection` is unimplemented in Firefox/Safari — unsupported is\n * the common case here, not an edge case (docs/network-tag-design.md §0). All\n * four data fields collapse to `null` and `supported` to `false` in that case.\n */\nexport class NetworkCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"effectiveType\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.effectiveType },\n { name: \"downlink\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.downlink },\n { name: \"rtt\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.rtt },\n { name: \"saveData\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.saveData },\n { name: \"supported\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.supported },\n // Offline (docs/seam-apps.md, state-collab-board: a page had to listen on window itself). Not\n // `online`: a data-wcs name starting with `on` is an event binding.\n { name: \"offline\", event: \"wcs-network:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.offline },\n ],\n // Pure monitor: navigator.connection has no request()/action method to invoke.\n commands: [],\n };\n\n private _target: EventTarget;\n private _snapshot: WcsNetworkSnapshot = UNSUPPORTED_SNAPSHOT;\n\n // The live NetworkInformation object the `change` listener is attached to (kept\n // so dispose() can remove it precisely; not read for anything else).\n private _connection: EventTarget | null = null;\n\n // True once observe() has attached the live listener (or determined there is\n // nothing to attach to). Guards observe() so a redundant call does not\n // re-subscribe; dispose() resets it so a later observe() resumes cleanly.\n private _subscribed = false;\n\n // SSR (§3.8): no asynchronous probe to await — observe() completes\n // synchronously, so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get effectiveType(): string | null {\n return this._snapshot.effectiveType;\n }\n\n get downlink(): number | null {\n return this._snapshot.downlink;\n }\n\n get rtt(): number | null {\n return this._snapshot.rtt;\n }\n\n get saveData(): boolean | null {\n return this._snapshot.saveData;\n }\n\n get supported(): boolean {\n return this._snapshot.supported;\n }\n\n get offline(): boolean | null {\n return this._snapshot.offline;\n }\n\n // Lifecycle (§3.5). Idempotent: a second observe() while already subscribed\n // is a no-op (no double listener, no redundant dispatch). Synchronous overall\n // (no probe to await), so the returned promise is only for API uniformity\n // with other IO nodes.\n observe(): Promise<void> {\n if (!this._subscribed) {\n this._subscribed = true;\n const api = this._api();\n if (api) {\n this._connection = api;\n api.addEventListener(\"change\", this._onChange);\n }\n this._window()?.addEventListener(\"online\", this._onChange);\n this._window()?.addEventListener(\"offline\", this._onChange);\n this._apply(this._read());\n }\n return this._ready;\n }\n\n dispose(): void {\n this._subscribed = false;\n if (this._connection) {\n this._connection.removeEventListener(\"change\", this._onChange);\n this._connection = null;\n }\n this._window()?.removeEventListener(\"online\", this._onChange);\n this._window()?.removeEventListener(\"offline\", this._onChange);\n }\n\n /** The window the online / offline events fire on (none under SSR). Call-time, as _api(). */\n private _window(): EventTarget | undefined {\n const w = (globalThis as any).window;\n return typeof w !== \"undefined\" && typeof w.addEventListener === \"function\" ? w : undefined;\n }\n\n // API resolution is call-time, never cached (§3.7): lets tests install/remove\n // navigator.connection freely and lets an unsupported environment be detected\n // correctly on every observe()/reading.\n private _api(): (EventTarget & { effectiveType?: string; downlink?: number; rtt?: number; saveData?: boolean }) | undefined {\n const nav = (globalThis as any).navigator;\n return typeof nav !== \"undefined\" && nav.connection ? nav.connection : undefined;\n }\n\n private _read(): WcsNetworkSnapshot {\n const c = this._api();\n const nav = (globalThis as any).navigator;\n const offline = typeof nav !== \"undefined\" && typeof nav.onLine === \"boolean\" ? !nav.onLine : null;\n if (!c) {\n return offline === null ? UNSUPPORTED_SNAPSHOT : { ...UNSUPPORTED_SNAPSHOT, offline };\n }\n return {\n offline,\n effectiveType: typeof c.effectiveType === \"string\" ? c.effectiveType : null,\n downlink: typeof c.downlink === \"number\" ? c.downlink : null,\n rtt: typeof c.rtt === \"number\" ? c.rtt : null,\n saveData: typeof c.saveData === \"boolean\" ? c.saveData : null,\n supported: true,\n };\n }\n\n private _onChange = (): void => {\n this._apply(this._read());\n };\n\n // Same-value guard (§3.3 MUST): the native `change` event already fires only\n // on a real change, but this Core still verifies field-by-field before\n // dispatching — defense in depth against a browser quirk double-firing\n // `change` with identical values.\n private _apply(next: WcsNetworkSnapshot): void {\n const prev = this._snapshot;\n if (\n prev.effectiveType === next.effectiveType &&\n prev.downlink === next.downlink &&\n prev.rtt === next.rtt &&\n prev.saveData === next.saveData &&\n prev.supported === next.supported &&\n prev.offline === next.offline\n ) {\n return;\n }\n this._snapshot = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-network:change\", {\n detail: next,\n // Family-wide MUST (async-io-node-guidelines.md §3.3): the event bubbles\n // from the Shell element so document-level consumers can delegate.\n bubbles: true,\n }));\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","import { IWcBindable } from \"../types.js\";\nimport { NetworkCore } from \"../core/NetworkCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\n\n/**\n * `<wcs-network>` — declarative Network Information API monitor.\n *\n * The smallest Shell in the batch (docs/network-tag-design.md §9): no\n * attributes at all. `navigator.connection` is a single global with nothing to\n * configure, unlike target-based nodes (`intersection`/`resize`) or\n * descriptor-based ones (`permission`).\n */\nexport class WcsNetwork extends HTMLElement {\n // SSR (§4.4): observe() completes synchronously, but the Shell still exposes\n // connectedCallbackPromise so SSR (@wcstack/server render.ts) can await it\n // uniformly across all IO nodes before snapshotting the HTML. Mirrors\n // WcsPermission.connectedCallbackPromise.\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...NetworkCore.wcBindable,\n inputs: [],\n // Core の commands をそのまま継承(単一情報源)。permission と同型。\n commands: NetworkCore.wcBindable.commands,\n };\n\n private _core: NetworkCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new NetworkCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-network:change\": (d) => ({\n \"save-data\": d.saveData === true,\n supported: d.supported === true,\n offline: d.offline === true,\n }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Core delegated getters ---\n\n get effectiveType(): string | null {\n return this._core.effectiveType;\n }\n\n get downlink(): number | null {\n return this._core.downlink;\n }\n\n get rtt(): number | null {\n return this._core.rtt;\n }\n\n get saveData(): boolean | null {\n return this._core.saveData;\n }\n\n get supported(): boolean {\n return this._core.supported;\n }\n\n get offline(): boolean | null {\n return this._core.offline;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n this._connectedCallbackPromise = this._core.observe();\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","import { WcsNetwork } from \"./components/Network.js\";\nimport { config } from \"./config.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n if (!registry.get(config.tagNames.network)) {\n registry.define(config.tagNames.network, WcsNetwork);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapNetwork(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":[],"mappings":"AAQA,MAAM,OAAO,GAAoB;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,OAAO,EAAE,aAAa;AACvB,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IAC/D;AACA,IAAA,OAAO,KAAU;AACnB;AAEA,IAAI,YAAY,GAAmB,IAAI;AAEhC,MAAM,MAAM,GAAY,OAAkB;SAEjC,SAAS,GAAA;IACvB,IAAI,CAAC,YAAY,EAAE;QACjB,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/C;AACA,IAAA,OAAO,YAAY;AACrB;AAEA;AACA,SAAS,OAAO,CAAC,GAAW,EAAA;AAC1B,IAAA,MAAM,IA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ACX,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS;IAC7B;AAEA,IAAA,IAAI,OAAO,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO;IAC3B;AAEA,IAAA,IAAI,wBAAwB,GAAA;QAC1B,OAAO,IAAI,CAAC,yBAAyB;IACvC;;IAIA,iBAAiB,GAAA;;QAEf,iBAAiB,CAAC,IAAI,CAAC;AACvB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM;QAC3B,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACvD;IAEA,oBAAoB,GAAA;AAClB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACtB;;;AC1HF;;;;AAIG;AACG,SAAU,kBAAkB,CAAC,QAAA,GAAkC,cAAc,EAAA;AACjF,IAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QAC1C,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IACtD;AACF;;ACRM,SAAU,gBAAgB,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAC7F,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;IACA,kBAAkB,CAAC,QAAQ,CAAC;AAC9B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wcstack/network",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"description": "Declarative Network Information component for Web Components. Framework-agnostic navigator.connection monitor via wc-bindable-protocol.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.esm.js",
|
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.esm.js"
|
|
13
13
|
},
|
|
14
|
-
"./auto":
|
|
14
|
+
"./auto": {
|
|
15
|
+
"types": "./dist/auto.d.ts",
|
|
16
|
+
"import": "./dist/auto.min.js"
|
|
17
|
+
}
|
|
15
18
|
},
|
|
16
19
|
"files": [
|
|
17
20
|
"dist"
|