@wcstack/network 4.0.4 → 4.1.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 +3 -1
- package/README.md +3 -1
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.esm.js +26 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -39,8 +39,8 @@ npm install @wcstack/network
|
|
|
39
39
|
### 1. 回線品質に応じた画像品質の切り替え
|
|
40
40
|
|
|
41
41
|
```html
|
|
42
|
-
<script type="module" src="https://esm.run/@wcstack/state/auto"></script>
|
|
43
42
|
<script type="module" src="https://esm.run/@wcstack/network/auto"></script>
|
|
43
|
+
<script type="module" src="https://esm.run/@wcstack/state/auto"></script>
|
|
44
44
|
|
|
45
45
|
<wcs-state>
|
|
46
46
|
<script type="module">
|
|
@@ -109,6 +109,7 @@ npm install @wcstack/network
|
|
|
109
109
|
| `rtt` | `wcs-network:change` | 概算往復遅延(ms)、非対応環境では `null`。 |
|
|
110
110
|
| `saveData` | `wcs-network:change` | ユーザーがデータセーバーモードを有効にしていれば `true`、非対応環境では `null`。 |
|
|
111
111
|
| `supported` | `wcs-network:change` | 実在する `navigator.connection` が見つかれば `true`、それ以外は `false`。 |
|
|
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` の名前がイベントの束縛になるため)。 |
|
|
112
113
|
|
|
113
114
|
5 つすべては単一の `wcs-network:change` イベントから派生します(ネイティブ API が全フィールドを1つの `change` イベントで報告するのと同じく、スナップショット全体を1つのイベントにまとめて発火します)。また、`supported` が `true` の環境でも、ブラウザが該当フィールドを欠落または期待外の型で報告した場合、4 つのデータフィールドは個別に `null` へ正規化されます。
|
|
114
115
|
|
|
@@ -142,6 +143,7 @@ npm install @wcstack/network
|
|
|
142
143
|
|----------|----------------|
|
|
143
144
|
| `save-data` | `wcs-network:change` が `saveData === true` で発火(`saveData` が `null`=非対応の場合も含め off) |
|
|
144
145
|
| `supported` | `wcs-network:change` が `supported === true` で発火(`supported === false` で off) |
|
|
146
|
+
| `offline` | `wcs-network:change` が `offline === true` で発火(オンラインの間と、`offline` が `null` のときは off) |
|
|
145
147
|
|
|
146
148
|
`effectiveType` / `downlink` / `rtt` は反映されません — 理由は `docs/custom-state-reflection-design.ja.md` §3.2(連続値・高頻度値は `:state()` 反映の対象外)を参照してください。
|
|
147
149
|
|
package/README.md
CHANGED
|
@@ -39,8 +39,8 @@ npm install @wcstack/network
|
|
|
39
39
|
### 1. Adaptive image quality
|
|
40
40
|
|
|
41
41
|
```html
|
|
42
|
-
<script type="module" src="https://esm.run/@wcstack/state/auto"></script>
|
|
43
42
|
<script type="module" src="https://esm.run/@wcstack/network/auto"></script>
|
|
43
|
+
<script type="module" src="https://esm.run/@wcstack/state/auto"></script>
|
|
44
44
|
|
|
45
45
|
<wcs-state>
|
|
46
46
|
<script type="module">
|
|
@@ -109,6 +109,7 @@ Every bound state path must be declared up front — binding an undeclared path
|
|
|
109
109
|
| `rtt` | `wcs-network:change` | Estimated round-trip time in ms, or `null` when unsupported. |
|
|
110
110
|
| `saveData` | `wcs-network:change` | `true` when the user has enabled Data Saver mode, or `null` when unsupported. |
|
|
111
111
|
| `supported` | `wcs-network:change` | `true` once a real `navigator.connection` was found; `false` otherwise. |
|
|
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.) |
|
|
112
113
|
|
|
113
114
|
All five 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.
|
|
114
115
|
|
|
@@ -142,6 +143,7 @@ so you can style it directly from CSS with the `:state()` pseudo-class — no
|
|
|
142
143
|
|-------|---------|
|
|
143
144
|
| `save-data` | `wcs-network:change` fires with `saveData === true` (off — including when `saveData` is `null`, i.e. unsupported) |
|
|
144
145
|
| `supported` | `wcs-network:change` fires with `supported === true` (off when `supported === false`) |
|
|
146
|
+
| `offline` | `wcs-network:change` fires with `offline === true` (off while online, and when `offline` is `null`) |
|
|
145
147
|
|
|
146
148
|
`effectiveType` / `downlink` / `rtt` are not reflected — see `docs/custom-state-reflection-design.md` §3.2 (continuous/high-frequency values are excluded from `:state()` reflection).
|
|
147
149
|
|
package/dist/auto.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const
|
|
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}class i 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)for(const t of n){const n=t.name;if(!Object.prototype.hasOwnProperty.call(e,n))continue;if(!s(e,n))continue;const i=e,o=i[n];delete i[n],i[n]=o}}(this),this.style.display="none",this._connectedCallbackPromise=this._core.observe()}disconnectedCallback(){this._core.dispose()}}var o;!function(t=customElements){t.get(e.tagNames.network)||t.define(e.tagNames.network,i)}(o);
|
|
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});\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 ],\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 // 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._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 }\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 if (!c) {\n return UNSUPPORTED_SNAPSHOT;\n }\n return {\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 ) {\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 }),\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 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","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","_apply","_read","dispose","removeEventListener","nav","globalThis","navigator","connection","undefined","c","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,IAgBP,MAAOC,UAAoBC,YAC/BC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,gBAAiBC,MAAO,qBAAsBC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAA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,MAAMwB,KAASxB,EAAQ,CAC1B,MAAMjD,EAAOyE,EAAMzE,KACnB,IAAKb,OAAOuF,UAAUC,eAAeC,KAAKL,EAASvE,GAAO,SAC1D,IAAKuC,EAAuBgC,EAASvE,GAAO,SAC5C,MAAM6E,EAASN,EACTO,EAAQD,EAAO7E,UACd6E,EAAO7E,GACd6E,EAAO7E,GAAQ8E,CACjB,CACF,CCsDIC,CAAkB9D,MAClBA,KAAK+D,MAAMC,QAAU,OACrBhE,KAAKkC,0BAA4BlC,KAAKiC,MAAM/B,SAC9C,CAEA,oBAAA+D,GACEjE,KAAKiC,MAAMxB,SACb,ECpHI,IAAyDyD,GCIzD,SAA6BA,EAAkCC,gBAC9DD,EAASvC,IAAI7D,EAAOC,SAASC,UAChCkG,EAASE,OAAOtG,EAAOC,SAASC,QAAS6D,EAE7C,CDJEwC,CAAmBH"}
|
|
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,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,GAAUE,IAC3B,CAEA,SAAIC,GACF,OAAOD,KAAKN,MACd,CAEA,iBAAIvB,GACF,OAAO6B,KAAKT,UAAUpB,aACxB,CAEA,YAAIC,GACF,OAAO4B,KAAKT,UAAUnB,QACxB,CAEA,OAAIC,GACF,OAAO2B,KAAKT,UAAUlB,GACxB,CAEA,YAAIC,GACF,OAAO0B,KAAKT,UAAUjB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C,EAAuBgC,EAAS3E,GAAO,SAC5C,MAAMiF,EAASN,EACTO,EAAQD,EAAOjF,UACdiF,EAAOjF,GACdiF,EAAOjF,GAAQkF,CACjB,CACF,CC2DIC,CAAkBlE,MAClBA,KAAKmE,MAAMC,QAAU,OACrBpE,KAAKsC,0BAA4BtC,KAAKqC,MAAMnC,SAC9C,CAEA,oBAAAmE,GACErE,KAAKqC,MAAM3B,SACb,ECzHI,IAAyD4D,GCIzD,SAA6BA,EAAkCC,gBAC9DD,EAASvC,IAAIlE,EAAOC,SAASC,UAChCuG,EAASE,OAAO3G,EAAOC,SAASC,QAASkE,EAE7C,CDJEwC,CAAmBH"}
|
package/dist/index.d.ts
CHANGED
|
@@ -64,6 +64,13 @@ interface WcsNetworkSnapshot {
|
|
|
64
64
|
rtt: number | null;
|
|
65
65
|
saveData: boolean | null;
|
|
66
66
|
supported: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* `!navigator.onLine`, followed through the window's `online` / `offline` events. Every browser
|
|
69
|
+
* has it, so it does not depend on `supported` (Network Information). `null` where there is no
|
|
70
|
+
* navigator (SSR). Named `offline`, not `online`: a `data-wcs` name starting with `on` is an
|
|
71
|
+
* event binding (`online:` would listen for a "line" event).
|
|
72
|
+
*/
|
|
73
|
+
offline: boolean | null;
|
|
67
74
|
}
|
|
68
75
|
/**
|
|
69
76
|
* Value types for NetworkCore (headless) — the observable state properties.
|
|
@@ -114,8 +121,11 @@ declare class NetworkCore extends EventTarget {
|
|
|
114
121
|
get rtt(): number | null;
|
|
115
122
|
get saveData(): boolean | null;
|
|
116
123
|
get supported(): boolean;
|
|
124
|
+
get offline(): boolean | null;
|
|
117
125
|
observe(): Promise<void>;
|
|
118
126
|
dispose(): void;
|
|
127
|
+
/** The window the online / offline events fire on (none under SSR). Call-time, as _api(). */
|
|
128
|
+
private _window;
|
|
119
129
|
private _api;
|
|
120
130
|
private _read;
|
|
121
131
|
private _onChange;
|
|
@@ -145,6 +155,7 @@ declare class WcsNetwork extends HTMLElement {
|
|
|
145
155
|
get rtt(): number | null;
|
|
146
156
|
get saveData(): boolean | null;
|
|
147
157
|
get supported(): boolean;
|
|
158
|
+
get offline(): boolean | null;
|
|
148
159
|
get connectedCallbackPromise(): Promise<void>;
|
|
149
160
|
connectedCallback(): void;
|
|
150
161
|
disconnectedCallback(): void;
|
package/dist/index.esm.js
CHANGED
|
@@ -64,6 +64,7 @@ const UNSUPPORTED_SNAPSHOT = Object.freeze({
|
|
|
64
64
|
rtt: null,
|
|
65
65
|
saveData: null,
|
|
66
66
|
supported: false,
|
|
67
|
+
offline: null,
|
|
67
68
|
});
|
|
68
69
|
/**
|
|
69
70
|
* Headless Network Information primitive. A thin, framework-agnostic wrapper
|
|
@@ -88,6 +89,9 @@ class NetworkCore extends EventTarget {
|
|
|
88
89
|
{ name: "rtt", event: "wcs-network:change", semantics: "state", getter: (e) => e.detail.rtt },
|
|
89
90
|
{ name: "saveData", event: "wcs-network:change", semantics: "state", getter: (e) => e.detail.saveData },
|
|
90
91
|
{ name: "supported", event: "wcs-network:change", semantics: "state", getter: (e) => e.detail.supported },
|
|
92
|
+
// Offline (docs/seam-apps.md, state-collab-board: a page had to listen on window itself). Not
|
|
93
|
+
// `online`: a data-wcs name starting with `on` is an event binding.
|
|
94
|
+
{ name: "offline", event: "wcs-network:change", semantics: "state", getter: (e) => e.detail.offline },
|
|
91
95
|
],
|
|
92
96
|
// Pure monitor: navigator.connection has no request()/action method to invoke.
|
|
93
97
|
commands: [],
|
|
@@ -126,6 +130,9 @@ class NetworkCore extends EventTarget {
|
|
|
126
130
|
get supported() {
|
|
127
131
|
return this._snapshot.supported;
|
|
128
132
|
}
|
|
133
|
+
get offline() {
|
|
134
|
+
return this._snapshot.offline;
|
|
135
|
+
}
|
|
129
136
|
// Lifecycle (§3.5). Idempotent: a second observe() while already subscribed
|
|
130
137
|
// is a no-op (no double listener, no redundant dispatch). Synchronous overall
|
|
131
138
|
// (no probe to await), so the returned promise is only for API uniformity
|
|
@@ -138,6 +145,8 @@ class NetworkCore extends EventTarget {
|
|
|
138
145
|
this._connection = api;
|
|
139
146
|
api.addEventListener("change", this._onChange);
|
|
140
147
|
}
|
|
148
|
+
this._window()?.addEventListener("online", this._onChange);
|
|
149
|
+
this._window()?.addEventListener("offline", this._onChange);
|
|
141
150
|
this._apply(this._read());
|
|
142
151
|
}
|
|
143
152
|
return this._ready;
|
|
@@ -148,6 +157,13 @@ class NetworkCore extends EventTarget {
|
|
|
148
157
|
this._connection.removeEventListener("change", this._onChange);
|
|
149
158
|
this._connection = null;
|
|
150
159
|
}
|
|
160
|
+
this._window()?.removeEventListener("online", this._onChange);
|
|
161
|
+
this._window()?.removeEventListener("offline", this._onChange);
|
|
162
|
+
}
|
|
163
|
+
/** The window the online / offline events fire on (none under SSR). Call-time, as _api(). */
|
|
164
|
+
_window() {
|
|
165
|
+
const w = globalThis.window;
|
|
166
|
+
return typeof w !== "undefined" && typeof w.addEventListener === "function" ? w : undefined;
|
|
151
167
|
}
|
|
152
168
|
// API resolution is call-time, never cached (§3.7): lets tests install/remove
|
|
153
169
|
// navigator.connection freely and lets an unsupported environment be detected
|
|
@@ -158,10 +174,13 @@ class NetworkCore extends EventTarget {
|
|
|
158
174
|
}
|
|
159
175
|
_read() {
|
|
160
176
|
const c = this._api();
|
|
177
|
+
const nav = globalThis.navigator;
|
|
178
|
+
const offline = typeof nav !== "undefined" && typeof nav.onLine === "boolean" ? !nav.onLine : null;
|
|
161
179
|
if (!c) {
|
|
162
|
-
return UNSUPPORTED_SNAPSHOT;
|
|
180
|
+
return offline === null ? UNSUPPORTED_SNAPSHOT : { ...UNSUPPORTED_SNAPSHOT, offline };
|
|
163
181
|
}
|
|
164
182
|
return {
|
|
183
|
+
offline,
|
|
165
184
|
effectiveType: typeof c.effectiveType === "string" ? c.effectiveType : null,
|
|
166
185
|
downlink: typeof c.downlink === "number" ? c.downlink : null,
|
|
167
186
|
rtt: typeof c.rtt === "number" ? c.rtt : null,
|
|
@@ -182,7 +201,8 @@ class NetworkCore extends EventTarget {
|
|
|
182
201
|
prev.downlink === next.downlink &&
|
|
183
202
|
prev.rtt === next.rtt &&
|
|
184
203
|
prev.saveData === next.saveData &&
|
|
185
|
-
prev.supported === next.supported
|
|
204
|
+
prev.supported === next.supported &&
|
|
205
|
+
prev.offline === next.offline) {
|
|
186
206
|
return;
|
|
187
207
|
}
|
|
188
208
|
this._snapshot = next;
|
|
@@ -268,6 +288,7 @@ class WcsNetwork extends HTMLElement {
|
|
|
268
288
|
"wcs-network:change": (d) => ({
|
|
269
289
|
"save-data": d.saveData === true,
|
|
270
290
|
supported: d.supported === true,
|
|
291
|
+
offline: d.offline === true,
|
|
271
292
|
}),
|
|
272
293
|
});
|
|
273
294
|
}
|
|
@@ -335,6 +356,9 @@ class WcsNetwork extends HTMLElement {
|
|
|
335
356
|
get supported() {
|
|
336
357
|
return this._core.supported;
|
|
337
358
|
}
|
|
359
|
+
get offline() {
|
|
360
|
+
return this._core.offline;
|
|
361
|
+
}
|
|
338
362
|
get connectedCallbackPromise() {
|
|
339
363
|
return this._connectedCallbackPromise;
|
|
340
364
|
}
|
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});\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 ],\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 // 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._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 }\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 if (!c) {\n return UNSUPPORTED_SNAPSHOT;\n }\n return {\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 ) {\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 }),\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 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,Y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AAE,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/**\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,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,I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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.0
|
|
3
|
+
"version": "4.1.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",
|