@wcstack/media-query 4.10.1 → 4.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +1 -1
- package/README.md +1 -1
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.esm.js +65 -3
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ A media query that only changes *styling* belongs in a stylesheet. This node is
|
|
|
34
34
|
npm install @wcstack/media-query
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
CDN (pinned): `https://esm.run/@wcstack/media-query@4.
|
|
37
|
+
CDN (pinned): `https://esm.run/@wcstack/media-query@4.11.0/auto`
|
|
38
38
|
|
|
39
39
|
## Quick Start
|
|
40
40
|
|
package/dist/auto.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={tagNames:{mediaQuery:"wcs-media-query"}}
|
|
1
|
+
const e={tagNames:{mediaQuery:"wcs-media-query"}};var t="@wcstack/media-query",s="4.11.0";const n=Object.freeze({matched:!1,media:"",supported:!1}),r=Object.freeze({matched:!1,media:"",supported:!0});class i extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"matched",event:"wcs-media-query:change",semantics:"state",getter:e=>e.detail.matched},{name:"media",event:"wcs-media-query:change",semantics:"state",getter:e=>e.detail.media},{name:"supported",event:"wcs-media-query:change",semantics:"state",getter:e=>e.detail.supported}],commands:[]};_target;_snapshot=n;_query="";_unsubscribe=null;_subscribed=!1;_gen=0;_injectedMatchMedia;_ready=Promise.resolve();constructor(e,t){super(),this._target=e??this,this._injectedMatchMedia=t?.matchMedia??null}get ready(){return this._ready}get query(){return this._query}get matched(){return this._snapshot.matched}get media(){return this._snapshot.media}get supported(){return this._snapshot.supported}observe(e=this._query){return this._subscribed&&e===this._query||(this._teardown(),this._query=e,this._subscribed=!0,this._subscribe(e)),this._ready}dispose(){this._subscribed=!1,this._teardown()}_resolveMatchMedia(){if(null!==this._injectedMatchMedia)return this._injectedMatchMedia;const e=globalThis;return"function"==typeof e.matchMedia?t=>e.matchMedia(t):null}_subscribe(e){const t=++this._gen,s=this._resolveMatchMedia();if(null===s)return void this._apply(n);if(""===e)return void this._apply(r);let i=null;try{i=s(e);const n=()=>{t===this._gen&&this._apply(this._read(i))};this._unsubscribe=function(e,t){if("function"==typeof e.addEventListener&&"function"==typeof e.removeEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);if("function"==typeof e.addListener&&"function"==typeof e.removeListener)return e.addListener(t),()=>e.removeListener(t);return()=>{}}(i,n)}catch{i=null,this._unsubscribe=null}this._apply(null===i?r:this._read(i))}_teardown(){if(this._gen++,null!==this._unsubscribe){const e=this._unsubscribe;this._unsubscribe=null;try{e()}catch{}}}_read(e){return{matched:!0===e.matches,media:"string"==typeof e.media?e.media:"",supported:!0}}_apply(e){const t=this._snapshot;t.matched===e.matched&&t.media===e.media&&t.supported===e.supported||(this._snapshot=e,this._target.dispatchEvent(new CustomEvent("wcs-media-query:change",{detail:e,bubbles:!0})))}}function a(e,t){let s=Object.getPrototypeOf(e);for(;null!==s;){const e=Object.getOwnPropertyDescriptor(s,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;s=Object.getPrototypeOf(s)}return!1}const o=new WeakSet;function c(e,t,s){if(o.has(e))return;o.add(e);const n=e.localName??"element";console.warn(`[wcs/input-as-attribute] <${n}> has the attribute ${t}="${s}": 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)}const u=new WeakMap;function d(e,t,s){const n=function(e,t){let s=u.get(e);return void 0===s&&(s=new Map,u.set(e,s)),s.has(t)||s.set(t,e.getAttribute(t)),s.get(t)}(e,t);!function(e,t,s){null===s?e.removeAttribute(t):e.setAttribute(t,s)}(e,t,void 0===s?n:null===s?null:String(s))}class h extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...i.wcBindable,inputs:[{name:"query",attribute:"query"}],commands:i.wcBindable.commands};static get observedAttributes(){return["query"]}_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new i(this),this._internals=this._initInternals(),this._wireStates({"wcs-media-query:change":e=>({matched:!0===e.matched,supported:!0===e.supported})})}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[s,n]of Object.entries(e))this.addEventListener(s,e=>{const s=this.hasAttribute("debug-states");for(const[r,i]of Object.entries(n(e.detail))){try{i?t.add(r):t.delete(r)}catch{}s&&this.toggleAttribute(`data-wcs-state-${r}`,i)}})}get query(){return this.getAttribute("query")??""}set query(e){d(this,"query",e)}get matched(){return this._core.matched}get media(){return this._core.media}get supported(){return this._core.supported}get connectedCallbackPromise(){return this._connectedCallbackPromise}attributeChangedCallback(e,t,s){"query"===e&&this.isConnected&&this._core.observe(s??"")}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,s=t?.inputs;if(void 0===s)return;const n=e.getAttribute;for(const t of s){const s=t.name,r="function"==typeof n?n.call(e,s.toLowerCase()):null;if(null!==r&&r.startsWith("[object ")&&c(e,s,r),!Object.prototype.hasOwnProperty.call(e,s))continue;if(!a(e,s))continue;const i=e,o=i[s];delete i[s],i[s]=o}}(this),this.style.display="none",this._connectedCallbackPromise=this._core.observe(this.query)}disconnectedCallback(){this._core.dispose()}}const l=Symbol.for("wcstack.package"),p=new WeakSet;function b(e,t){Object.defineProperty(e,l,{value:t,configurable:!0})}function m(e,t,s,n,r){if(void 0!==n&&(s===n||s.prototype instanceof n))return;const i=s[l];if(i===r||p.has(e))return;p.add(e);const a=r.slice(0,r.lastIndexOf("@"));console.warn(`[${a}] [wcs/package-twice] <${t}> is already defined by ${i??`another copy of ${a} that does not name its version`}; this copy, ${r}, does nothing. Load each package once.`)}function f(n=customElements){!function(e,t,s){for(const[n,r]of s){const s=e.get(n);void 0===s?(b(r,t),e.define(n,r)):m(e,n,s,r,t)}}(n,`${t}@${s}`,[[e.tagNames.mediaQuery,h]])}var _;f(_);
|
|
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/MediaQueryCore.ts","../src/protocol/upgradeProperties.ts","../src/protocol/inputAttribute.ts","../src/components/MediaQuery.ts","../src/bootstrapMediaQuery.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n mediaQuery: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n mediaQuery: \"wcs-media-query\",\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: `bootstrapMediaQuery` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/media-query] bootstrapMediaQuery: \"${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 {\n IWcBindable, WcsMatchMedia, WcsMediaQueryCoreOptions, WcsMediaQueryList, WcsMediaQuerySnapshot,\n} from \"../types.js\";\n\nconst UNSUPPORTED_SNAPSHOT: WcsMediaQuerySnapshot = Object.freeze({\n matched: false,\n media: \"\",\n supported: false,\n});\n\n// \"matchMedia exists but there is nothing to watch\": an empty query, or a\n// matchMedia call that threw. Same shape as UNSUPPORTED_SNAPSHOT except that\n// `supported` stays honest about the API being present.\nconst IDLE_SNAPSHOT: WcsMediaQuerySnapshot = Object.freeze({\n matched: false,\n media: \"\",\n supported: true,\n});\n\n/**\n * Headless media-query primitive. A thin, framework-agnostic wrapper around\n * `window.matchMedia` exposed through the wc-bindable protocol.\n *\n * `observe(query)` subscribes to one `MediaQueryList` and republishes its\n * `matches` / `media` as `matched` / `media` state; a different query while subscribed tears the\n * old list down and subscribes to the new one. Subscribing is synchronous, but\n * — unlike `@wcstack/network` — this Core does keep a `_gen` generation guard\n * (§3.4): each subscription's `change` listener captures the generation it was\n * created under and bails when it is stale, so a `MediaQueryList` whose\n * `removeEventListener` / `removeListener` misbehaves can never write the old\n * query's `matched` over the new query's (docs/media-query-tag-design.md §6).\n *\n * `matchMedia` is universally available in browsers; `supported === false` is\n * the non-browser case (SSR, workers) rather than a browser quirk.\n */\nexport class MediaQueryCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"matched\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.matched },\n { name: \"media\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.media },\n { name: \"supported\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.supported },\n ],\n // Pure monitor: a MediaQueryList has no action to invoke.\n //\n // `matched`, not `matches`: `Element.prototype.matches(selector)` exists on\n // every element, and a wc-bindable property name is read straight off the\n // Shell — a boolean `matches` would shadow the platform method\n // (docs/media-query-tag-design.md §2.1).\n commands: [],\n };\n\n private _target: EventTarget;\n private _snapshot: WcsMediaQuerySnapshot = UNSUPPORTED_SNAPSHOT;\n\n // The query currently subscribed (or last requested). \"\" means \"nothing to watch\".\n private _query = \"\";\n\n // Detaches the live `change` listener of the current subscription, if any.\n private _unsubscribe: (() => void) | null = null;\n\n // True between observe() and dispose(). Guards observe() so a redundant call\n // with the same query does not re-subscribe; dispose() resets it.\n private _subscribed = false;\n\n // Generation guard (§3.4). Bumped by every (re)subscription and by dispose().\n // A `change` listener captures its generation and ignores the event once a\n // newer subscription exists — see the class docs for why this is kept even\n // though subscribing itself is synchronous.\n private _gen = 0;\n\n // Injected matchMedia (tests / non-window hosts). `null` = resolve\n // `globalThis.matchMedia` at call time (§3.7).\n private _injectedMatchMedia: WcsMatchMedia | null;\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, options?: WcsMediaQueryCoreOptions) {\n super();\n this._target = target ?? this;\n this._injectedMatchMedia = options?.matchMedia ?? null;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get query(): string {\n return this._query;\n }\n\n get matched(): boolean {\n return this._snapshot.matched;\n }\n\n get media(): string {\n return this._snapshot.media;\n }\n\n get supported(): boolean {\n return this._snapshot.supported;\n }\n\n // Lifecycle (§3.5). Idempotent: observe() with the query already subscribed\n // is a no-op (no double listener, no redundant dispatch). A different query\n // re-subscribes (dispose-then-observe semantics in one call). Omitting the\n // argument keeps the current query — the reconnect case for the Shell.\n // Synchronous overall (no probe to await), so the returned promise is only\n // for API uniformity with other IO nodes.\n observe(query: string = this._query): Promise<void> {\n if (this._subscribed && query === this._query) {\n return this._ready;\n }\n this._teardown();\n this._query = query;\n this._subscribed = true;\n this._subscribe(query);\n return this._ready;\n }\n\n dispose(): void {\n this._subscribed = false;\n this._teardown();\n }\n\n // API resolution is call-time, never cached (§3.7): lets tests install/remove\n // globalThis.matchMedia freely and lets a non-browser host be detected\n // correctly on every observe(). Called as a method of globalThis so the\n // native implementation keeps its `this` (calling it unbound throws).\n private _resolveMatchMedia(): WcsMatchMedia | null {\n if (this._injectedMatchMedia !== null) {\n return this._injectedMatchMedia;\n }\n const g = globalThis as { matchMedia?: WcsMatchMedia };\n return typeof g.matchMedia === \"function\" ? (q: string) => g.matchMedia!(q) : null;\n }\n\n private _subscribe(query: string): void {\n const gen = ++this._gen;\n const matchMedia = this._resolveMatchMedia();\n if (matchMedia === null) {\n this._apply(UNSUPPORTED_SNAPSHOT);\n return;\n }\n if (query === \"\") {\n this._apply(IDLE_SNAPSHOT);\n return;\n }\n // never-throw (§3.6): browsers do not throw on an invalid query string\n // (they return `media: \"not all\"`), but a hostile host or a broken\n // MediaQueryList polyfill might — that must not kill observe().\n let list: WcsMediaQueryList | null = null;\n try {\n list = matchMedia(query);\n const onChange = (): void => {\n if (gen !== this._gen) return; // stale subscription — never write\n this._apply(this._read(list!));\n };\n this._unsubscribe = attachChange(list, onChange);\n } catch {\n list = null;\n this._unsubscribe = null;\n }\n this._apply(list === null ? IDLE_SNAPSHOT : this._read(list));\n }\n\n private _teardown(): void {\n this._gen++;\n if (this._unsubscribe !== null) {\n const unsubscribe = this._unsubscribe;\n this._unsubscribe = null;\n try {\n unsubscribe();\n } catch {\n // never-throw: a list that refuses to detach is already neutralized\n // by the generation bump above.\n }\n }\n }\n\n private _read(list: WcsMediaQueryList): WcsMediaQuerySnapshot {\n return {\n matched: list.matches === true,\n media: typeof list.media === \"string\" ? list.media : \"\",\n supported: true,\n };\n }\n\n // Same-value guard (§3.3 MUST): the native `change` event already fires only\n // when `matches` flips, but this Core still verifies field-by-field before\n // dispatching — a re-subscription to an equivalent query, or a legacy\n // `addListener` double-fire, must not produce a redundant event.\n private _apply(next: WcsMediaQuerySnapshot): void {\n const prev = this._snapshot;\n if (\n prev.matched === next.matched &&\n prev.media === next.media &&\n prev.supported === next.supported\n ) {\n return;\n }\n this._snapshot = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-media-query: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// Subscribe to a MediaQueryList's `change` with whichever listener API it has.\n// Modern engines: EventTarget-style. Old Safari (< 14): the deprecated\n// addListener / removeListener pair. Neither: no live updates — the snapshot\n// taken at observe() is all there is (a static polyfill, for instance).\n// Returns the matching detach function.\nfunction attachChange(list: WcsMediaQueryList, listener: () => void): () => void {\n if (typeof list.addEventListener === \"function\" && typeof list.removeEventListener === \"function\") {\n list.addEventListener(\"change\", listener);\n return () => list.removeEventListener!(\"change\", listener);\n }\n if (typeof list.addListener === \"function\" && typeof list.removeListener === \"function\") {\n list.addListener(listener);\n return () => list.removeListener!(listener);\n }\n return () => {};\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","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { IWcBindable } from \"../types.js\";\nimport { MediaQueryCore } from \"../core/MediaQueryCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-media-query query=\"(prefers-color-scheme: dark)\">` — declarative\n * `matchMedia` monitor.\n *\n * One attribute (`query`), three outputs (`matched` / `media` / `supported`),\n * no commands. Changing `query` while connected re-subscribes the Core to the\n * new MediaQueryList (docs/media-query-tag-design.md §7).\n */\nexport class WcsMediaQuery 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.\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...MediaQueryCore.wcBindable,\n // Shell-level settable surface: the media query string, mirrored to the\n // `query` attribute (idempotent reflect, so a binder writing through\n // inputs[].attribute is safe).\n inputs: [\n { name: \"query\", attribute: \"query\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。network と同型。\n commands: MediaQueryCore.wcBindable.commands,\n };\n\n // `query` is the only attribute worth re-subscribing for; it is the whole\n // configuration of this node.\n static get observedAttributes(): string[] { return [\"query\"]; }\n\n private _core: MediaQueryCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new MediaQueryCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-media-query:change\": (d) => ({\n matched: d.matched === 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 // --- Attribute accessors ---\n\n get query(): string {\n return this.getAttribute(\"query\") ?? \"\";\n }\n\n // Never lets setAttribute stringify null / undefined (matchMedia(\"undefined\")\n // is a valid, never-matching query): `null` removes the attribute (\"watch\n // nothing\"), `undefined` restores the attribute the element started with\n // (wc-bindable producer guidance P1; React 19 and a direct assignment deliver\n // it, @wcstack/state does not). Either way attributeChangedCallback\n // re-subscribes.\n set query(value: string | null | undefined) {\n reflectAttribute(this, \"query\", value);\n }\n\n // --- Core delegated getters ---\n\n get matched(): boolean {\n return this._core.matched;\n }\n\n get media(): string {\n return this._core.media;\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 attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void {\n // Re-subscribe on a live query change. Removing the attribute (newValue\n // null) is a real change too — it means \"watch nothing\", so `matched`\n // drops to false instead of lingering on the old query's value. Before\n // connect the attribute is simply read by connectedCallback.\n if (name === \"query\" && this.isConnected) {\n this._core.observe(newValue ?? \"\");\n }\n }\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(this.query);\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 bootstrapMediaQuery(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n","import { WcsMediaQuery } from \"./components/MediaQuery.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.mediaQuery)) {\n registry.define(config.tagNames.mediaQuery, WcsMediaQuery);\n }\n}\n"],"names":["config","tagNames","mediaQuery","UNSUPPORTED_SNAPSHOT","Object","freeze","matched","media","supported","IDLE_SNAPSHOT","MediaQueryCore","EventTarget","static","protocol","version","properties","name","event","semantics","getter","e","detail","commands","_target","_snapshot","_query","_unsubscribe","_subscribed","_gen","_injectedMatchMedia","_ready","Promise","resolve","constructor","target","options","super","this","matchMedia","ready","query","observe","_teardown","_subscribe","dispose","_resolveMatchMedia","g","globalThis","q","gen","_apply","list","onChange","_read","listener","addEventListener","removeEventListener","addListener","removeListener","attachChange","unsubscribe","matches","next","prev","dispatchEvent","CustomEvent","bubbles","hasAccessorOnPrototype","proto","getPrototypeOf","descriptor","getOwnPropertyDescriptor","undefined","get","set","toldObjectAttribute","WeakSet","warnObjectAttribute","element","value","has","add","tag","localName","console","warn","initialAttributes","WeakMap","reflectAttribute","el","initial","byName","Map","getAttribute","initialAttribute","removeAttribute","setAttribute","writeAttribute","String","WcsMediaQuery","HTMLElement","wcBindable","inputs","attribute","observedAttributes","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","connectedCallbackPromise","attributeChangedCallback","_oldValue","newValue","isConnected","connectedCallback","declaration","input","call","toLowerCase","startsWith","prototype","hasOwnProperty","record","upgradeProperties","style","display","disconnectedCallback","registry","customElements","define","registerComponents"],"mappings":"AAQA,MA0BaA,EA1BoB,CAC/BC,SAAU,CACRC,WAAY,oBCNVC,EAA8CC,OAAOC,OAAO,CAChEC,SAAS,EACTC,MAAO,GACPC,WAAW,IAMPC,EAAuCL,OAAOC,OAAO,CACzDC,SAAS,EACTC,MAAO,GACPC,WAAW,IAmBP,MAAOE,UAAuBC,YAClCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,UAAWC,MAAO,yBAA0BC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOf,SACxH,CAAEU,KAAM,QAASC,MAAO,yBAA0BC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOd,OACtH,CAAES,KAAM,YAAaC,MAAO,yBAA0BC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOb,YAQ5Hc,SAAU,IAGJC,QACAC,UAAmCrB,EAGnCsB,OAAS,GAGTC,aAAoC,KAIpCC,aAAc,EAMdC,KAAO,EAIPC,oBAIAC,OAAwBC,QAAQC,UAExC,WAAAC,CAAYC,EAAsBC,GAChCC,QACAC,KAAKd,QAAUW,GAAUG,KACzBA,KAAKR,oBAAsBM,GAASG,YAAc,IACpD,CAEA,SAAIC,GACF,OAAOF,KAAKP,MACd,CAEA,SAAIU,GACF,OAAOH,KAAKZ,MACd,CAEA,WAAInB,GACF,OAAO+B,KAAKb,UAAUlB,OACxB,CAEA,SAAIC,GACF,OAAO8B,KAAKb,UAAUjB,KACxB,CAEA,aAAIC,GACF,OAAO6B,KAAKb,UAAUhB,SACxB,CAQA,OAAAiC,CAAQD,EAAgBH,KAAKZ,QAC3B,OAAIY,KAAKV,aAAea,IAAUH,KAAKZ,SAGvCY,KAAKK,YACLL,KAAKZ,OAASe,E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G,KAAKoE,MAAM7D,SACb,EC/II,IAA4DiG,GCI5D,SAA6BA,EAAkCC,gBAC9DD,EAASpE,IAAIzE,EAAOC,SAASC,aAChC2I,EAASE,OAAO/I,EAAOC,SAASC,WAAYiG,EAEhD,CDJE6C,CAAmBH"}
|
|
1
|
+
{"version":3,"file":"auto.min.js","sources":["../../src/config.ts","../../src/core/MediaQueryCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/MediaQuery.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapMediaQuery.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n mediaQuery: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n mediaQuery: \"wcs-media-query\",\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: `bootstrapMediaQuery` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/media-query] bootstrapMediaQuery: \"${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 {\n IWcBindable, WcsMatchMedia, WcsMediaQueryCoreOptions, WcsMediaQueryList, WcsMediaQuerySnapshot,\n} from \"../types.js\";\n\nconst UNSUPPORTED_SNAPSHOT: WcsMediaQuerySnapshot = Object.freeze({\n matched: false,\n media: \"\",\n supported: false,\n});\n\n// \"matchMedia exists but there is nothing to watch\": an empty query, or a\n// matchMedia call that threw. Same shape as UNSUPPORTED_SNAPSHOT except that\n// `supported` stays honest about the API being present.\nconst IDLE_SNAPSHOT: WcsMediaQuerySnapshot = Object.freeze({\n matched: false,\n media: \"\",\n supported: true,\n});\n\n/**\n * Headless media-query primitive. A thin, framework-agnostic wrapper around\n * `window.matchMedia` exposed through the wc-bindable protocol.\n *\n * `observe(query)` subscribes to one `MediaQueryList` and republishes its\n * `matches` / `media` as `matched` / `media` state; a different query while subscribed tears the\n * old list down and subscribes to the new one. Subscribing is synchronous, but\n * — unlike `@wcstack/network` — this Core does keep a `_gen` generation guard\n * (§3.4): each subscription's `change` listener captures the generation it was\n * created under and bails when it is stale, so a `MediaQueryList` whose\n * `removeEventListener` / `removeListener` misbehaves can never write the old\n * query's `matched` over the new query's (docs/media-query-tag-design.md §6).\n *\n * `matchMedia` is universally available in browsers; `supported === false` is\n * the non-browser case (SSR, workers) rather than a browser quirk.\n */\nexport class MediaQueryCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"matched\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.matched },\n { name: \"media\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.media },\n { name: \"supported\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.supported },\n ],\n // Pure monitor: a MediaQueryList has no action to invoke.\n //\n // `matched`, not `matches`: `Element.prototype.matches(selector)` exists on\n // every element, and a wc-bindable property name is read straight off the\n // Shell — a boolean `matches` would shadow the platform method\n // (docs/media-query-tag-design.md §2.1).\n commands: [],\n };\n\n private _target: EventTarget;\n private _snapshot: WcsMediaQuerySnapshot = UNSUPPORTED_SNAPSHOT;\n\n // The query currently subscribed (or last requested). \"\" means \"nothing to watch\".\n private _query = \"\";\n\n // Detaches the live `change` listener of the current subscription, if any.\n private _unsubscribe: (() => void) | null = null;\n\n // True between observe() and dispose(). Guards observe() so a redundant call\n // with the same query does not re-subscribe; dispose() resets it.\n private _subscribed = false;\n\n // Generation guard (§3.4). Bumped by every (re)subscription and by dispose().\n // A `change` listener captures its generation and ignores the event once a\n // newer subscription exists — see the class docs for why this is kept even\n // though subscribing itself is synchronous.\n private _gen = 0;\n\n // Injected matchMedia (tests / non-window hosts). `null` = resolve\n // `globalThis.matchMedia` at call time (§3.7).\n private _injectedMatchMedia: WcsMatchMedia | null;\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, options?: WcsMediaQueryCoreOptions) {\n super();\n this._target = target ?? this;\n this._injectedMatchMedia = options?.matchMedia ?? null;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get query(): string {\n return this._query;\n }\n\n get matched(): boolean {\n return this._snapshot.matched;\n }\n\n get media(): string {\n return this._snapshot.media;\n }\n\n get supported(): boolean {\n return this._snapshot.supported;\n }\n\n // Lifecycle (§3.5). Idempotent: observe() with the query already subscribed\n // is a no-op (no double listener, no redundant dispatch). A different query\n // re-subscribes (dispose-then-observe semantics in one call). Omitting the\n // argument keeps the current query — the reconnect case for the Shell.\n // Synchronous overall (no probe to await), so the returned promise is only\n // for API uniformity with other IO nodes.\n observe(query: string = this._query): Promise<void> {\n if (this._subscribed && query === this._query) {\n return this._ready;\n }\n this._teardown();\n this._query = query;\n this._subscribed = true;\n this._subscribe(query);\n return this._ready;\n }\n\n dispose(): void {\n this._subscribed = false;\n this._teardown();\n }\n\n // API resolution is call-time, never cached (§3.7): lets tests install/remove\n // globalThis.matchMedia freely and lets a non-browser host be detected\n // correctly on every observe(). Called as a method of globalThis so the\n // native implementation keeps its `this` (calling it unbound throws).\n private _resolveMatchMedia(): WcsMatchMedia | null {\n if (this._injectedMatchMedia !== null) {\n return this._injectedMatchMedia;\n }\n const g = globalThis as { matchMedia?: WcsMatchMedia };\n return typeof g.matchMedia === \"function\" ? (q: string) => g.matchMedia!(q) : null;\n }\n\n private _subscribe(query: string): void {\n const gen = ++this._gen;\n const matchMedia = this._resolveMatchMedia();\n if (matchMedia === null) {\n this._apply(UNSUPPORTED_SNAPSHOT);\n return;\n }\n if (query === \"\") {\n this._apply(IDLE_SNAPSHOT);\n return;\n }\n // never-throw (§3.6): browsers do not throw on an invalid query string\n // (they return `media: \"not all\"`), but a hostile host or a broken\n // MediaQueryList polyfill might — that must not kill observe().\n let list: WcsMediaQueryList | null = null;\n try {\n list = matchMedia(query);\n const onChange = (): void => {\n if (gen !== this._gen) return; // stale subscription — never write\n this._apply(this._read(list!));\n };\n this._unsubscribe = attachChange(list, onChange);\n } catch {\n list = null;\n this._unsubscribe = null;\n }\n this._apply(list === null ? IDLE_SNAPSHOT : this._read(list));\n }\n\n private _teardown(): void {\n this._gen++;\n if (this._unsubscribe !== null) {\n const unsubscribe = this._unsubscribe;\n this._unsubscribe = null;\n try {\n unsubscribe();\n } catch {\n // never-throw: a list that refuses to detach is already neutralized\n // by the generation bump above.\n }\n }\n }\n\n private _read(list: WcsMediaQueryList): WcsMediaQuerySnapshot {\n return {\n matched: list.matches === true,\n media: typeof list.media === \"string\" ? list.media : \"\",\n supported: true,\n };\n }\n\n // Same-value guard (§3.3 MUST): the native `change` event already fires only\n // when `matches` flips, but this Core still verifies field-by-field before\n // dispatching — a re-subscription to an equivalent query, or a legacy\n // `addListener` double-fire, must not produce a redundant event.\n private _apply(next: WcsMediaQuerySnapshot): void {\n const prev = this._snapshot;\n if (\n prev.matched === next.matched &&\n prev.media === next.media &&\n prev.supported === next.supported\n ) {\n return;\n }\n this._snapshot = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-media-query: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// Subscribe to a MediaQueryList's `change` with whichever listener API it has.\n// Modern engines: EventTarget-style. Old Safari (< 14): the deprecated\n// addListener / removeListener pair. Neither: no live updates — the snapshot\n// taken at observe() is all there is (a static polyfill, for instance).\n// Returns the matching detach function.\nfunction attachChange(list: WcsMediaQueryList, listener: () => void): () => void {\n if (typeof list.addEventListener === \"function\" && typeof list.removeEventListener === \"function\") {\n list.addEventListener(\"change\", listener);\n return () => list.removeEventListener!(\"change\", listener);\n }\n if (typeof list.addListener === \"function\" && typeof list.removeListener === \"function\") {\n list.addListener(listener);\n return () => list.removeListener!(listener);\n }\n return () => {};\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","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { IWcBindable } from \"../types.js\";\nimport { MediaQueryCore } from \"../core/MediaQueryCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-media-query query=\"(prefers-color-scheme: dark)\">` — declarative\n * `matchMedia` monitor.\n *\n * One attribute (`query`), three outputs (`matched` / `media` / `supported`),\n * no commands. Changing `query` while connected re-subscribes the Core to the\n * new MediaQueryList (docs/media-query-tag-design.md §7).\n */\nexport class WcsMediaQuery 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.\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...MediaQueryCore.wcBindable,\n // Shell-level settable surface: the media query string, mirrored to the\n // `query` attribute (idempotent reflect, so a binder writing through\n // inputs[].attribute is safe).\n inputs: [\n { name: \"query\", attribute: \"query\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。network と同型。\n commands: MediaQueryCore.wcBindable.commands,\n };\n\n // `query` is the only attribute worth re-subscribing for; it is the whole\n // configuration of this node.\n static get observedAttributes(): string[] { return [\"query\"]; }\n\n private _core: MediaQueryCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new MediaQueryCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-media-query:change\": (d) => ({\n matched: d.matched === 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 // --- Attribute accessors ---\n\n get query(): string {\n return this.getAttribute(\"query\") ?? \"\";\n }\n\n // Never lets setAttribute stringify null / undefined (matchMedia(\"undefined\")\n // is a valid, never-matching query): `null` removes the attribute (\"watch\n // nothing\"), `undefined` restores the attribute the element started with\n // (wc-bindable producer guidance P1; React 19 and a direct assignment deliver\n // it, @wcstack/state does not). Either way attributeChangedCallback\n // re-subscribes.\n set query(value: string | null | undefined) {\n reflectAttribute(this, \"query\", value);\n }\n\n // --- Core delegated getters ---\n\n get matched(): boolean {\n return this._core.matched;\n }\n\n get media(): string {\n return this._core.media;\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 attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void {\n // Re-subscribe on a live query change. Removing the attribute (newValue\n // null) is a real change too — it means \"watch nothing\", so `matched`\n // drops to false instead of lingering on the old query's value. Before\n // connect the attribute is simply read by connectedCallback.\n if (name === \"query\" && this.isConnected) {\n this._core.observe(newValue ?? \"\");\n }\n }\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(this.query);\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/define-element.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * One copy of each package on a page (docs/timing-and-firing-contract.md §24). The first copy the\n * page evaluates defines the tags and a second one does nothing, so a copy that finds its tag defined\n * by another copy of the package — not its class, not a subclass of it, not the same version — warns\n * `[wcs/package-twice]` once per registry, naming both versions. The classes it defines carry\n * `\"<package>@<version>\"` under `Symbol.for(\"wcstack.package\")`; a class without it is named\n * \"another copy of <package> that does not name its version\" (an older copy, or one loaded through\n * an entry that does not stamp).\n */\n\n/** The static a class defined through this helper carries: `\"@wcstack/fetch@<version>\"`. */\nexport const PACKAGE_STAMP: unique symbol = Symbol.for(\"wcstack.package\");\n\ntype Stamped = { [PACKAGE_STAMP]?: string };\n\n/** The registries this copy warned about: one warning per package per registry. */\nconst warned = new WeakSet<CustomElementRegistry>();\n\n/**\n * Marks `cls` as defined by `pkg` (`\"@wcstack/fetch@<version>\"`). A subclass inherits the mark, and\n * `defineProperty` writes it even where a parent's mark is read-only.\n */\nexport function stampPackage(cls: CustomElementConstructor, pkg: string): void {\n Object.defineProperty(cls, PACKAGE_STAMP, { value: pkg, configurable: true });\n}\n\n/**\n * Warns when `tag` is defined as `existing` by another copy of the package `pkg` names: `existing`\n * is neither `own` nor a subclass of it (omit `own` when the copy has no class to compare with), and\n * carries another version or none. Once per registry.\n */\nexport function warnIfAnotherCopy(\n registry: CustomElementRegistry,\n tag: string,\n existing: CustomElementConstructor,\n own: CustomElementConstructor | undefined,\n pkg: string,\n): void {\n if (own !== undefined && (existing === own || existing.prototype instanceof own)) return;\n const theirs = (existing as Stamped)[PACKAGE_STAMP];\n if (theirs === pkg || warned.has(registry)) return;\n warned.add(registry);\n const name = pkg.slice(0, pkg.lastIndexOf(\"@\"));\n console.warn(\n `[${name}] [wcs/package-twice] <${tag}> is already defined by ` +\n `${theirs ?? `another copy of ${name} that does not name its version`}; ` +\n `this copy, ${pkg}, does nothing. Load each package once.`,\n );\n}\n\n/**\n * Defines each `[tag, class]` in `registry` unless the tag is already defined, stamping the class\n * with `pkg` (`\"@wcstack/fetch@<version>\"`). A tag another copy of the package defined first is left\n * as it is, with the warning above.\n */\nexport function defineElements(\n registry: CustomElementRegistry,\n pkg: string,\n definitions: readonly (readonly [tag: string, cls: CustomElementConstructor])[],\n): void {\n for (const [tag, cls] of definitions) {\n const existing = registry.get(tag);\n if (existing === undefined) {\n stampPackage(cls, pkg);\n registry.define(tag, cls);\n } else {\n warnIfAnotherCopy(registry, tag, existing, cls, pkg);\n }\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\nimport { WcsMediaQuery } from \"./components/MediaQuery.js\";\nimport { config } from \"./config.js\";\nimport { defineElements } from \"./protocol/defineElement.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 defineElements(registry, `${pkg.name}@${pkg.version}`, [\n [config.tagNames.mediaQuery, WcsMediaQuery],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapMediaQuery(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":["config","tagNames","mediaQuery","UNSUPPORTED_SNAPSHOT","Object","freeze","matched","media","supported","IDLE_SNAPSHOT","MediaQueryCore","EventTarget","static","protocol","version","properties","name","event","semantics","getter","e","detail","commands","_target","_snapshot","_query","_unsubscribe","_subscribed","_gen","_injectedMatchMedia","_ready","Promise","resolve","constructor","target","options","super","this","matchMedia","ready","query","observe","_teardown","_subscribe","dispose","_resolveMatchMedia","g","globalThis","q","gen","_apply","list","onChange","_read","listener","addEventListener","removeEventListener","addListener","removeListener","attachChange","unsubscribe","matches","next","prev","dispatchEvent","CustomEvent","bubbles","hasAccessorOnPrototype","proto","getPrototypeOf","descriptor","getOwnPropertyDescriptor","undefined","get","set","toldObjectAttribute","WeakSet","warnObjectAttribute","element","value","has","add","tag","localName","console","warn","initialAttributes","WeakMap","reflectAttribute","el","initial","byName","Map","getAttribute","initialAttribute","removeAttribute","setAttribute","writeAttribute","String","WcsMediaQuery","HTMLElement","wcBindable","inputs","attribute","observedAttributes","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","connectedCallbackPromise","attributeChangedCallback","_oldValue","newValue","isConnected","connectedCallback","declaration","input","call","toLowerCase","startsWith","prototype","hasOwnProperty","record","upgradeProperties","style","display","disconnectedCallback","PACKAGE_STAMP","Symbol","for","warned","stampPackage","cls","pkg","defineProperty","configurable","warnIfAnotherCopy","registry","existing","own","theirs","slice","lastIndexOf","registerComponents","customElements","definitions","define","defineElements"],"mappings":"AAQA,MA0BaA,EA1BoB,CAC/BC,SAAU,CACRC,WAAY,4DCNhB,MAAMC,EAA8CC,OAAOC,OAAO,CAChEC,SAAS,EACTC,MAAO,GACPC,WAAW,IAMPC,EAAuCL,OAAOC,OAAO,CACzDC,SAAS,EACTC,MAAO,GACPC,WAAW,IAmBP,MAAOE,UAAuBC,YAClCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,UAAWC,MAAO,yBAA0BC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOf,SACxH,CAAEU,KAAM,QAASC,MAAO,yBAA0BC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOd,OACtH,CAAES,KAAM,YAAaC,MAAO,yBAA0BC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOb,YAQ5Hc,SAAU,IAGJC,QACAC,UAAmCrB,EAGnCsB,OAAS,GAGTC,aAAoC,KAIpCC,aAAc,EAMdC,KA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BI,EAAkBC,EAAUrE,EAAKsE,EAAUN,EAAKC,EAEpD,CACF,CChEEc,CAAeV,EAAU,GAAGJ,KAAYA,IAAe,CACrD,CAACnJ,EAAOC,SAASC,WAAYiG,IAEjC,CCVM,IAA4DoD,EAIhEM,EAAmBN"}
|
package/dist/index.esm.js
CHANGED
|
@@ -58,6 +58,8 @@ function setConfig(partialConfig) {
|
|
|
58
58
|
frozenConfig = null;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
var pkg = {"name":"@wcstack/media-query","version":"4.11.0"};
|
|
62
|
+
|
|
61
63
|
const UNSUPPORTED_SNAPSHOT = Object.freeze({
|
|
62
64
|
matched: false,
|
|
63
65
|
media: "",
|
|
@@ -508,15 +510,75 @@ class WcsMediaQuery extends HTMLElement {
|
|
|
508
510
|
}
|
|
509
511
|
}
|
|
510
512
|
|
|
513
|
+
// ===========================================================================
|
|
514
|
+
// AUTO-GENERATED FILE - DO NOT EDIT.
|
|
515
|
+
// Generated from /protocol/define-element.ts by scripts/sync-protocol-types.mjs.
|
|
516
|
+
// Run `node scripts/sync-protocol-types.mjs` after editing the source.
|
|
517
|
+
// ===========================================================================
|
|
518
|
+
/**
|
|
519
|
+
* One copy of each package on a page (docs/timing-and-firing-contract.md §24). The first copy the
|
|
520
|
+
* page evaluates defines the tags and a second one does nothing, so a copy that finds its tag defined
|
|
521
|
+
* by another copy of the package — not its class, not a subclass of it, not the same version — warns
|
|
522
|
+
* `[wcs/package-twice]` once per registry, naming both versions. The classes it defines carry
|
|
523
|
+
* `"<package>@<version>"` under `Symbol.for("wcstack.package")`; a class without it is named
|
|
524
|
+
* "another copy of <package> that does not name its version" (an older copy, or one loaded through
|
|
525
|
+
* an entry that does not stamp).
|
|
526
|
+
*/
|
|
527
|
+
/** The static a class defined through this helper carries: `"@wcstack/fetch@<version>"`. */
|
|
528
|
+
const PACKAGE_STAMP = Symbol.for("wcstack.package");
|
|
529
|
+
/** The registries this copy warned about: one warning per package per registry. */
|
|
530
|
+
const warned = new WeakSet();
|
|
531
|
+
/**
|
|
532
|
+
* Marks `cls` as defined by `pkg` (`"@wcstack/fetch@<version>"`). A subclass inherits the mark, and
|
|
533
|
+
* `defineProperty` writes it even where a parent's mark is read-only.
|
|
534
|
+
*/
|
|
535
|
+
function stampPackage(cls, pkg) {
|
|
536
|
+
Object.defineProperty(cls, PACKAGE_STAMP, { value: pkg, configurable: true });
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Warns when `tag` is defined as `existing` by another copy of the package `pkg` names: `existing`
|
|
540
|
+
* is neither `own` nor a subclass of it (omit `own` when the copy has no class to compare with), and
|
|
541
|
+
* carries another version or none. Once per registry.
|
|
542
|
+
*/
|
|
543
|
+
function warnIfAnotherCopy(registry, tag, existing, own, pkg) {
|
|
544
|
+
if (own !== undefined && (existing === own || existing.prototype instanceof own))
|
|
545
|
+
return;
|
|
546
|
+
const theirs = existing[PACKAGE_STAMP];
|
|
547
|
+
if (theirs === pkg || warned.has(registry))
|
|
548
|
+
return;
|
|
549
|
+
warned.add(registry);
|
|
550
|
+
const name = pkg.slice(0, pkg.lastIndexOf("@"));
|
|
551
|
+
console.warn(`[${name}] [wcs/package-twice] <${tag}> is already defined by ` +
|
|
552
|
+
`${theirs ?? `another copy of ${name} that does not name its version`}; ` +
|
|
553
|
+
`this copy, ${pkg}, does nothing. Load each package once.`);
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Defines each `[tag, class]` in `registry` unless the tag is already defined, stamping the class
|
|
557
|
+
* with `pkg` (`"@wcstack/fetch@<version>"`). A tag another copy of the package defined first is left
|
|
558
|
+
* as it is, with the warning above.
|
|
559
|
+
*/
|
|
560
|
+
function defineElements(registry, pkg, definitions) {
|
|
561
|
+
for (const [tag, cls] of definitions) {
|
|
562
|
+
const existing = registry.get(tag);
|
|
563
|
+
if (existing === undefined) {
|
|
564
|
+
stampPackage(cls, pkg);
|
|
565
|
+
registry.define(tag, cls);
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
warnIfAnotherCopy(registry, tag, existing, cls, pkg);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
511
573
|
/**
|
|
512
574
|
* Register this package's tags. Pass a scoped `CustomElementRegistry` to define
|
|
513
575
|
* them for a single shadow tree -- scoped registries do not inherit the global
|
|
514
576
|
* one, so a tree using one needs its own definitions.
|
|
515
577
|
*/
|
|
516
578
|
function registerComponents(registry = customElements) {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
579
|
+
defineElements(registry, `${pkg.name}@${pkg.version}`, [
|
|
580
|
+
[config.tagNames.mediaQuery, WcsMediaQuery],
|
|
581
|
+
]);
|
|
520
582
|
}
|
|
521
583
|
|
|
522
584
|
function bootstrapMediaQuery(userConfig, registry) {
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/MediaQueryCore.ts","../src/protocol/upgradeProperties.ts","../src/protocol/inputAttribute.ts","../src/components/MediaQuery.ts","../src/registerComponents.ts","../src/bootstrapMediaQuery.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n mediaQuery: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n mediaQuery: \"wcs-media-query\",\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: `bootstrapMediaQuery` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/media-query] bootstrapMediaQuery: \"${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 {\n IWcBindable, WcsMatchMedia, WcsMediaQueryCoreOptions, WcsMediaQueryList, WcsMediaQuerySnapshot,\n} from \"../types.js\";\n\nconst UNSUPPORTED_SNAPSHOT: WcsMediaQuerySnapshot = Object.freeze({\n matched: false,\n media: \"\",\n supported: false,\n});\n\n// \"matchMedia exists but there is nothing to watch\": an empty query, or a\n// matchMedia call that threw. Same shape as UNSUPPORTED_SNAPSHOT except that\n// `supported` stays honest about the API being present.\nconst IDLE_SNAPSHOT: WcsMediaQuerySnapshot = Object.freeze({\n matched: false,\n media: \"\",\n supported: true,\n});\n\n/**\n * Headless media-query primitive. A thin, framework-agnostic wrapper around\n * `window.matchMedia` exposed through the wc-bindable protocol.\n *\n * `observe(query)` subscribes to one `MediaQueryList` and republishes its\n * `matches` / `media` as `matched` / `media` state; a different query while subscribed tears the\n * old list down and subscribes to the new one. Subscribing is synchronous, but\n * — unlike `@wcstack/network` — this Core does keep a `_gen` generation guard\n * (§3.4): each subscription's `change` listener captures the generation it was\n * created under and bails when it is stale, so a `MediaQueryList` whose\n * `removeEventListener` / `removeListener` misbehaves can never write the old\n * query's `matched` over the new query's (docs/media-query-tag-design.md §6).\n *\n * `matchMedia` is universally available in browsers; `supported === false` is\n * the non-browser case (SSR, workers) rather than a browser quirk.\n */\nexport class MediaQueryCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"matched\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.matched },\n { name: \"media\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.media },\n { name: \"supported\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.supported },\n ],\n // Pure monitor: a MediaQueryList has no action to invoke.\n //\n // `matched`, not `matches`: `Element.prototype.matches(selector)` exists on\n // every element, and a wc-bindable property name is read straight off the\n // Shell — a boolean `matches` would shadow the platform method\n // (docs/media-query-tag-design.md §2.1).\n commands: [],\n };\n\n private _target: EventTarget;\n private _snapshot: WcsMediaQuerySnapshot = UNSUPPORTED_SNAPSHOT;\n\n // The query currently subscribed (or last requested). \"\" means \"nothing to watch\".\n private _query = \"\";\n\n // Detaches the live `change` listener of the current subscription, if any.\n private _unsubscribe: (() => void) | null = null;\n\n // True between observe() and dispose(). Guards observe() so a redundant call\n // with the same query does not re-subscribe; dispose() resets it.\n private _subscribed = false;\n\n // Generation guard (§3.4). Bumped by every (re)subscription and by dispose().\n // A `change` listener captures its generation and ignores the event once a\n // newer subscription exists — see the class docs for why this is kept even\n // though subscribing itself is synchronous.\n private _gen = 0;\n\n // Injected matchMedia (tests / non-window hosts). `null` = resolve\n // `globalThis.matchMedia` at call time (§3.7).\n private _injectedMatchMedia: WcsMatchMedia | null;\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, options?: WcsMediaQueryCoreOptions) {\n super();\n this._target = target ?? this;\n this._injectedMatchMedia = options?.matchMedia ?? null;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get query(): string {\n return this._query;\n }\n\n get matched(): boolean {\n return this._snapshot.matched;\n }\n\n get media(): string {\n return this._snapshot.media;\n }\n\n get supported(): boolean {\n return this._snapshot.supported;\n }\n\n // Lifecycle (§3.5). Idempotent: observe() with the query already subscribed\n // is a no-op (no double listener, no redundant dispatch). A different query\n // re-subscribes (dispose-then-observe semantics in one call). Omitting the\n // argument keeps the current query — the reconnect case for the Shell.\n // Synchronous overall (no probe to await), so the returned promise is only\n // for API uniformity with other IO nodes.\n observe(query: string = this._query): Promise<void> {\n if (this._subscribed && query === this._query) {\n return this._ready;\n }\n this._teardown();\n this._query = query;\n this._subscribed = true;\n this._subscribe(query);\n return this._ready;\n }\n\n dispose(): void {\n this._subscribed = false;\n this._teardown();\n }\n\n // API resolution is call-time, never cached (§3.7): lets tests install/remove\n // globalThis.matchMedia freely and lets a non-browser host be detected\n // correctly on every observe(). Called as a method of globalThis so the\n // native implementation keeps its `this` (calling it unbound throws).\n private _resolveMatchMedia(): WcsMatchMedia | null {\n if (this._injectedMatchMedia !== null) {\n return this._injectedMatchMedia;\n }\n const g = globalThis as { matchMedia?: WcsMatchMedia };\n return typeof g.matchMedia === \"function\" ? (q: string) => g.matchMedia!(q) : null;\n }\n\n private _subscribe(query: string): void {\n const gen = ++this._gen;\n const matchMedia = this._resolveMatchMedia();\n if (matchMedia === null) {\n this._apply(UNSUPPORTED_SNAPSHOT);\n return;\n }\n if (query === \"\") {\n this._apply(IDLE_SNAPSHOT);\n return;\n }\n // never-throw (§3.6): browsers do not throw on an invalid query string\n // (they return `media: \"not all\"`), but a hostile host or a broken\n // MediaQueryList polyfill might — that must not kill observe().\n let list: WcsMediaQueryList | null = null;\n try {\n list = matchMedia(query);\n const onChange = (): void => {\n if (gen !== this._gen) return; // stale subscription — never write\n this._apply(this._read(list!));\n };\n this._unsubscribe = attachChange(list, onChange);\n } catch {\n list = null;\n this._unsubscribe = null;\n }\n this._apply(list === null ? IDLE_SNAPSHOT : this._read(list));\n }\n\n private _teardown(): void {\n this._gen++;\n if (this._unsubscribe !== null) {\n const unsubscribe = this._unsubscribe;\n this._unsubscribe = null;\n try {\n unsubscribe();\n } catch {\n // never-throw: a list that refuses to detach is already neutralized\n // by the generation bump above.\n }\n }\n }\n\n private _read(list: WcsMediaQueryList): WcsMediaQuerySnapshot {\n return {\n matched: list.matches === true,\n media: typeof list.media === \"string\" ? list.media : \"\",\n supported: true,\n };\n }\n\n // Same-value guard (§3.3 MUST): the native `change` event already fires only\n // when `matches` flips, but this Core still verifies field-by-field before\n // dispatching — a re-subscription to an equivalent query, or a legacy\n // `addListener` double-fire, must not produce a redundant event.\n private _apply(next: WcsMediaQuerySnapshot): void {\n const prev = this._snapshot;\n if (\n prev.matched === next.matched &&\n prev.media === next.media &&\n prev.supported === next.supported\n ) {\n return;\n }\n this._snapshot = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-media-query: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// Subscribe to a MediaQueryList's `change` with whichever listener API it has.\n// Modern engines: EventTarget-style. Old Safari (< 14): the deprecated\n// addListener / removeListener pair. Neither: no live updates — the snapshot\n// taken at observe() is all there is (a static polyfill, for instance).\n// Returns the matching detach function.\nfunction attachChange(list: WcsMediaQueryList, listener: () => void): () => void {\n if (typeof list.addEventListener === \"function\" && typeof list.removeEventListener === \"function\") {\n list.addEventListener(\"change\", listener);\n return () => list.removeEventListener!(\"change\", listener);\n }\n if (typeof list.addListener === \"function\" && typeof list.removeListener === \"function\") {\n list.addListener(listener);\n return () => list.removeListener!(listener);\n }\n return () => {};\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","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { IWcBindable } from \"../types.js\";\nimport { MediaQueryCore } from \"../core/MediaQueryCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-media-query query=\"(prefers-color-scheme: dark)\">` — declarative\n * `matchMedia` monitor.\n *\n * One attribute (`query`), three outputs (`matched` / `media` / `supported`),\n * no commands. Changing `query` while connected re-subscribes the Core to the\n * new MediaQueryList (docs/media-query-tag-design.md §7).\n */\nexport class WcsMediaQuery 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.\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...MediaQueryCore.wcBindable,\n // Shell-level settable surface: the media query string, mirrored to the\n // `query` attribute (idempotent reflect, so a binder writing through\n // inputs[].attribute is safe).\n inputs: [\n { name: \"query\", attribute: \"query\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。network と同型。\n commands: MediaQueryCore.wcBindable.commands,\n };\n\n // `query` is the only attribute worth re-subscribing for; it is the whole\n // configuration of this node.\n static get observedAttributes(): string[] { return [\"query\"]; }\n\n private _core: MediaQueryCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new MediaQueryCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-media-query:change\": (d) => ({\n matched: d.matched === 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 // --- Attribute accessors ---\n\n get query(): string {\n return this.getAttribute(\"query\") ?? \"\";\n }\n\n // Never lets setAttribute stringify null / undefined (matchMedia(\"undefined\")\n // is a valid, never-matching query): `null` removes the attribute (\"watch\n // nothing\"), `undefined` restores the attribute the element started with\n // (wc-bindable producer guidance P1; React 19 and a direct assignment deliver\n // it, @wcstack/state does not). Either way attributeChangedCallback\n // re-subscribes.\n set query(value: string | null | undefined) {\n reflectAttribute(this, \"query\", value);\n }\n\n // --- Core delegated getters ---\n\n get matched(): boolean {\n return this._core.matched;\n }\n\n get media(): string {\n return this._core.media;\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 attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void {\n // Re-subscribe on a live query change. Removing the attribute (newValue\n // null) is a real change too — it means \"watch nothing\", so `matched`\n // drops to false instead of lingering on the old query's value. Before\n // connect the attribute is simply read by connectedCallback.\n if (name === \"query\" && this.isConnected) {\n this._core.observe(newValue ?? \"\");\n }\n }\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(this.query);\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","import { WcsMediaQuery } from \"./components/MediaQuery.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.mediaQuery)) {\n registry.define(config.tagNames.mediaQuery, WcsMediaQuery);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapMediaQuery(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,UAAU,EAAE,iBAAiB;AAC9B,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,S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U,CAAC,EAAE;QAC7C,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IAC5D;AACF;;ACRM,SAAU,mBAAmB,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAChG,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/MediaQueryCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/MediaQuery.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapMediaQuery.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n mediaQuery: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n mediaQuery: \"wcs-media-query\",\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: `bootstrapMediaQuery` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/media-query] bootstrapMediaQuery: \"${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 {\n IWcBindable, WcsMatchMedia, WcsMediaQueryCoreOptions, WcsMediaQueryList, WcsMediaQuerySnapshot,\n} from \"../types.js\";\n\nconst UNSUPPORTED_SNAPSHOT: WcsMediaQuerySnapshot = Object.freeze({\n matched: false,\n media: \"\",\n supported: false,\n});\n\n// \"matchMedia exists but there is nothing to watch\": an empty query, or a\n// matchMedia call that threw. Same shape as UNSUPPORTED_SNAPSHOT except that\n// `supported` stays honest about the API being present.\nconst IDLE_SNAPSHOT: WcsMediaQuerySnapshot = Object.freeze({\n matched: false,\n media: \"\",\n supported: true,\n});\n\n/**\n * Headless media-query primitive. A thin, framework-agnostic wrapper around\n * `window.matchMedia` exposed through the wc-bindable protocol.\n *\n * `observe(query)` subscribes to one `MediaQueryList` and republishes its\n * `matches` / `media` as `matched` / `media` state; a different query while subscribed tears the\n * old list down and subscribes to the new one. Subscribing is synchronous, but\n * — unlike `@wcstack/network` — this Core does keep a `_gen` generation guard\n * (§3.4): each subscription's `change` listener captures the generation it was\n * created under and bails when it is stale, so a `MediaQueryList` whose\n * `removeEventListener` / `removeListener` misbehaves can never write the old\n * query's `matched` over the new query's (docs/media-query-tag-design.md §6).\n *\n * `matchMedia` is universally available in browsers; `supported === false` is\n * the non-browser case (SSR, workers) rather than a browser quirk.\n */\nexport class MediaQueryCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"matched\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.matched },\n { name: \"media\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.media },\n { name: \"supported\", event: \"wcs-media-query:change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail.supported },\n ],\n // Pure monitor: a MediaQueryList has no action to invoke.\n //\n // `matched`, not `matches`: `Element.prototype.matches(selector)` exists on\n // every element, and a wc-bindable property name is read straight off the\n // Shell — a boolean `matches` would shadow the platform method\n // (docs/media-query-tag-design.md §2.1).\n commands: [],\n };\n\n private _target: EventTarget;\n private _snapshot: WcsMediaQuerySnapshot = UNSUPPORTED_SNAPSHOT;\n\n // The query currently subscribed (or last requested). \"\" means \"nothing to watch\".\n private _query = \"\";\n\n // Detaches the live `change` listener of the current subscription, if any.\n private _unsubscribe: (() => void) | null = null;\n\n // True between observe() and dispose(). Guards observe() so a redundant call\n // with the same query does not re-subscribe; dispose() resets it.\n private _subscribed = false;\n\n // Generation guard (§3.4). Bumped by every (re)subscription and by dispose().\n // A `change` listener captures its generation and ignores the event once a\n // newer subscription exists — see the class docs for why this is kept even\n // though subscribing itself is synchronous.\n private _gen = 0;\n\n // Injected matchMedia (tests / non-window hosts). `null` = resolve\n // `globalThis.matchMedia` at call time (§3.7).\n private _injectedMatchMedia: WcsMatchMedia | null;\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, options?: WcsMediaQueryCoreOptions) {\n super();\n this._target = target ?? this;\n this._injectedMatchMedia = options?.matchMedia ?? null;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n get query(): string {\n return this._query;\n }\n\n get matched(): boolean {\n return this._snapshot.matched;\n }\n\n get media(): string {\n return this._snapshot.media;\n }\n\n get supported(): boolean {\n return this._snapshot.supported;\n }\n\n // Lifecycle (§3.5). Idempotent: observe() with the query already subscribed\n // is a no-op (no double listener, no redundant dispatch). A different query\n // re-subscribes (dispose-then-observe semantics in one call). Omitting the\n // argument keeps the current query — the reconnect case for the Shell.\n // Synchronous overall (no probe to await), so the returned promise is only\n // for API uniformity with other IO nodes.\n observe(query: string = this._query): Promise<void> {\n if (this._subscribed && query === this._query) {\n return this._ready;\n }\n this._teardown();\n this._query = query;\n this._subscribed = true;\n this._subscribe(query);\n return this._ready;\n }\n\n dispose(): void {\n this._subscribed = false;\n this._teardown();\n }\n\n // API resolution is call-time, never cached (§3.7): lets tests install/remove\n // globalThis.matchMedia freely and lets a non-browser host be detected\n // correctly on every observe(). Called as a method of globalThis so the\n // native implementation keeps its `this` (calling it unbound throws).\n private _resolveMatchMedia(): WcsMatchMedia | null {\n if (this._injectedMatchMedia !== null) {\n return this._injectedMatchMedia;\n }\n const g = globalThis as { matchMedia?: WcsMatchMedia };\n return typeof g.matchMedia === \"function\" ? (q: string) => g.matchMedia!(q) : null;\n }\n\n private _subscribe(query: string): void {\n const gen = ++this._gen;\n const matchMedia = this._resolveMatchMedia();\n if (matchMedia === null) {\n this._apply(UNSUPPORTED_SNAPSHOT);\n return;\n }\n if (query === \"\") {\n this._apply(IDLE_SNAPSHOT);\n return;\n }\n // never-throw (§3.6): browsers do not throw on an invalid query string\n // (they return `media: \"not all\"`), but a hostile host or a broken\n // MediaQueryList polyfill might — that must not kill observe().\n let list: WcsMediaQueryList | null = null;\n try {\n list = matchMedia(query);\n const onChange = (): void => {\n if (gen !== this._gen) return; // stale subscription — never write\n this._apply(this._read(list!));\n };\n this._unsubscribe = attachChange(list, onChange);\n } catch {\n list = null;\n this._unsubscribe = null;\n }\n this._apply(list === null ? IDLE_SNAPSHOT : this._read(list));\n }\n\n private _teardown(): void {\n this._gen++;\n if (this._unsubscribe !== null) {\n const unsubscribe = this._unsubscribe;\n this._unsubscribe = null;\n try {\n unsubscribe();\n } catch {\n // never-throw: a list that refuses to detach is already neutralized\n // by the generation bump above.\n }\n }\n }\n\n private _read(list: WcsMediaQueryList): WcsMediaQuerySnapshot {\n return {\n matched: list.matches === true,\n media: typeof list.media === \"string\" ? list.media : \"\",\n supported: true,\n };\n }\n\n // Same-value guard (§3.3 MUST): the native `change` event already fires only\n // when `matches` flips, but this Core still verifies field-by-field before\n // dispatching — a re-subscription to an equivalent query, or a legacy\n // `addListener` double-fire, must not produce a redundant event.\n private _apply(next: WcsMediaQuerySnapshot): void {\n const prev = this._snapshot;\n if (\n prev.matched === next.matched &&\n prev.media === next.media &&\n prev.supported === next.supported\n ) {\n return;\n }\n this._snapshot = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-media-query: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// Subscribe to a MediaQueryList's `change` with whichever listener API it has.\n// Modern engines: EventTarget-style. Old Safari (< 14): the deprecated\n// addListener / removeListener pair. Neither: no live updates — the snapshot\n// taken at observe() is all there is (a static polyfill, for instance).\n// Returns the matching detach function.\nfunction attachChange(list: WcsMediaQueryList, listener: () => void): () => void {\n if (typeof list.addEventListener === \"function\" && typeof list.removeEventListener === \"function\") {\n list.addEventListener(\"change\", listener);\n return () => list.removeEventListener!(\"change\", listener);\n }\n if (typeof list.addListener === \"function\" && typeof list.removeListener === \"function\") {\n list.addListener(listener);\n return () => list.removeListener!(listener);\n }\n return () => {};\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","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { IWcBindable } from \"../types.js\";\nimport { MediaQueryCore } from \"../core/MediaQueryCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-media-query query=\"(prefers-color-scheme: dark)\">` — declarative\n * `matchMedia` monitor.\n *\n * One attribute (`query`), three outputs (`matched` / `media` / `supported`),\n * no commands. Changing `query` while connected re-subscribes the Core to the\n * new MediaQueryList (docs/media-query-tag-design.md §7).\n */\nexport class WcsMediaQuery 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.\n static hasConnectedCallbackPromise = true;\n\n static wcBindable: IWcBindable = {\n ...MediaQueryCore.wcBindable,\n // Shell-level settable surface: the media query string, mirrored to the\n // `query` attribute (idempotent reflect, so a binder writing through\n // inputs[].attribute is safe).\n inputs: [\n { name: \"query\", attribute: \"query\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。network と同型。\n commands: MediaQueryCore.wcBindable.commands,\n };\n\n // `query` is the only attribute worth re-subscribing for; it is the whole\n // configuration of this node.\n static get observedAttributes(): string[] { return [\"query\"]; }\n\n private _core: MediaQueryCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new MediaQueryCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-media-query:change\": (d) => ({\n matched: d.matched === 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 // --- Attribute accessors ---\n\n get query(): string {\n return this.getAttribute(\"query\") ?? \"\";\n }\n\n // Never lets setAttribute stringify null / undefined (matchMedia(\"undefined\")\n // is a valid, never-matching query): `null` removes the attribute (\"watch\n // nothing\"), `undefined` restores the attribute the element started with\n // (wc-bindable producer guidance P1; React 19 and a direct assignment deliver\n // it, @wcstack/state does not). Either way attributeChangedCallback\n // re-subscribes.\n set query(value: string | null | undefined) {\n reflectAttribute(this, \"query\", value);\n }\n\n // --- Core delegated getters ---\n\n get matched(): boolean {\n return this._core.matched;\n }\n\n get media(): string {\n return this._core.media;\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 attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void {\n // Re-subscribe on a live query change. Removing the attribute (newValue\n // null) is a real change too — it means \"watch nothing\", so `matched`\n // drops to false instead of lingering on the old query's value. Before\n // connect the attribute is simply read by connectedCallback.\n if (name === \"query\" && this.isConnected) {\n this._core.observe(newValue ?? \"\");\n }\n }\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(this.query);\n }\n\n disconnectedCallback(): void {\n this._core.dispose();\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/define-element.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * One copy of each package on a page (docs/timing-and-firing-contract.md §24). The first copy the\n * page evaluates defines the tags and a second one does nothing, so a copy that finds its tag defined\n * by another copy of the package — not its class, not a subclass of it, not the same version — warns\n * `[wcs/package-twice]` once per registry, naming both versions. The classes it defines carry\n * `\"<package>@<version>\"` under `Symbol.for(\"wcstack.package\")`; a class without it is named\n * \"another copy of <package> that does not name its version\" (an older copy, or one loaded through\n * an entry that does not stamp).\n */\n\n/** The static a class defined through this helper carries: `\"@wcstack/fetch@<version>\"`. */\nexport const PACKAGE_STAMP: unique symbol = Symbol.for(\"wcstack.package\");\n\ntype Stamped = { [PACKAGE_STAMP]?: string };\n\n/** The registries this copy warned about: one warning per package per registry. */\nconst warned = new WeakSet<CustomElementRegistry>();\n\n/**\n * Marks `cls` as defined by `pkg` (`\"@wcstack/fetch@<version>\"`). A subclass inherits the mark, and\n * `defineProperty` writes it even where a parent's mark is read-only.\n */\nexport function stampPackage(cls: CustomElementConstructor, pkg: string): void {\n Object.defineProperty(cls, PACKAGE_STAMP, { value: pkg, configurable: true });\n}\n\n/**\n * Warns when `tag` is defined as `existing` by another copy of the package `pkg` names: `existing`\n * is neither `own` nor a subclass of it (omit `own` when the copy has no class to compare with), and\n * carries another version or none. Once per registry.\n */\nexport function warnIfAnotherCopy(\n registry: CustomElementRegistry,\n tag: string,\n existing: CustomElementConstructor,\n own: CustomElementConstructor | undefined,\n pkg: string,\n): void {\n if (own !== undefined && (existing === own || existing.prototype instanceof own)) return;\n const theirs = (existing as Stamped)[PACKAGE_STAMP];\n if (theirs === pkg || warned.has(registry)) return;\n warned.add(registry);\n const name = pkg.slice(0, pkg.lastIndexOf(\"@\"));\n console.warn(\n `[${name}] [wcs/package-twice] <${tag}> is already defined by ` +\n `${theirs ?? `another copy of ${name} that does not name its version`}; ` +\n `this copy, ${pkg}, does nothing. Load each package once.`,\n );\n}\n\n/**\n * Defines each `[tag, class]` in `registry` unless the tag is already defined, stamping the class\n * with `pkg` (`\"@wcstack/fetch@<version>\"`). A tag another copy of the package defined first is left\n * as it is, with the warning above.\n */\nexport function defineElements(\n registry: CustomElementRegistry,\n pkg: string,\n definitions: readonly (readonly [tag: string, cls: CustomElementConstructor])[],\n): void {\n for (const [tag, cls] of definitions) {\n const existing = registry.get(tag);\n if (existing === undefined) {\n stampPackage(cls, pkg);\n registry.define(tag, cls);\n } else {\n warnIfAnotherCopy(registry, tag, existing, cls, pkg);\n }\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\nimport { WcsMediaQuery } from \"./components/MediaQuery.js\";\nimport { config } from \"./config.js\";\nimport { defineElements } from \"./protocol/defineElement.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 defineElements(registry, `${pkg.name}@${pkg.version}`, [\n [config.tagNames.mediaQuery, WcsMediaQuery],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapMediaQuery(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,UAAU,EAAE,iBAAiB;AAC9B,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAA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,EAC/B,GAAW,EACX,WAA+E,EAAA;IAE/E,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,WAAW,EAAE;QACpC,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC;AAClC,QAAA,IAAI,QAAQ,KAAK,SAAS,EAAE;AAC1B,YAAA,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC;AACtB,YAAA,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC;QAC3B;aAAO;YACL,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC;QACtD;IACF;AACF;;ACtEA;;;;AAIG;AACG,SAAU,kBAAkB,CAAC,QAAA,GAAkC,cAAc,EAAA;AACjF,IAAA,cAAc,CAAC,QAAQ,EAAE,CAAA,EAAG,GAAG,CAAC,IAAI,CAAA,CAAA,EAAI,GAAG,CAAC,OAAO,CAAA,CAAE,EAAE;AACrD,QAAA,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;AAC5C,KAAA,CAAC;AACJ;;ACVM,SAAU,mBAAmB,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAChG,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/media-query",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.0",
|
|
4
4
|
"description": "Declarative matchMedia component for Web Components. Framework-agnostic media-query monitor (prefers-color-scheme, prefers-reduced-motion, viewport width) via wc-bindable-protocol.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.esm.js",
|