@wcstack/resize 1.14.0 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,15 +1,3 @@
1
- interface ITagNames {
2
- readonly resize: string;
3
- }
4
- interface IWritableTagNames {
5
- resize?: string;
6
- }
7
- interface IConfig {
8
- readonly tagNames: ITagNames;
9
- }
10
- interface IWritableConfig {
11
- tagNames?: IWritableTagNames;
12
- }
13
1
  interface IWcBindableProperty {
14
2
  readonly name: string;
15
3
  readonly event: string;
@@ -25,11 +13,25 @@ interface IWcBindableCommand {
25
13
  }
26
14
  interface IWcBindable {
27
15
  readonly protocol: "wc-bindable";
28
- readonly version: number;
29
- readonly properties: IWcBindableProperty[];
30
- readonly inputs?: IWcBindableInput[];
31
- readonly commands?: IWcBindableCommand[];
16
+ readonly version: 1;
17
+ readonly properties: readonly IWcBindableProperty[];
18
+ readonly inputs?: readonly IWcBindableInput[];
19
+ readonly commands?: readonly IWcBindableCommand[];
20
+ }
21
+
22
+ interface ITagNames {
23
+ readonly resize: string;
32
24
  }
25
+ interface IWritableTagNames {
26
+ resize?: string;
27
+ }
28
+ interface IConfig {
29
+ readonly tagNames: ITagNames;
30
+ }
31
+ interface IWritableConfig {
32
+ tagNames?: IWritableTagNames;
33
+ }
34
+
33
35
  /**
34
36
  * Which box-size CSS-side ResizeObserver reports. Mirrors `ResizeObserverBoxOptions`.
35
37
  * `device-pixel-content-box` is Chromium-only; the Core falls back to `content-box`
@@ -93,7 +95,7 @@ interface ResizeOptions {
93
95
  }
94
96
  /**
95
97
  * Value types for ResizeCore (headless) — the observable state properties.
96
- * Use with `bind()` from `@wc-bindable/core` for compile-time type checking.
98
+ * Use with `bind()` from `a wc-bindable binding core` for compile-time type checking.
97
99
  *
98
100
  * @example
99
101
  * ```typescript
@@ -190,7 +192,26 @@ declare class ResizeCore extends EventTarget {
190
192
  private _effectiveBox;
191
193
  private _entry;
192
194
  private _observing;
195
+ private _ready;
193
196
  constructor(target?: EventTarget);
197
+ /** Resolves once the first probe settles. Synchronous here, so already resolved. */
198
+ get ready(): Promise<void>;
199
+ /**
200
+ * Lifecycle entry point (§3.5). When called with no element it is an idempotent
201
+ * no-op that resolves once ready — resize is command-driven (the Shell resolves
202
+ * the target and calls observe(element)), so connect-time monitoring is started
203
+ * via that command, not here. The Shell backs `connectedCallbackPromise` with
204
+ * this no-arg form. When called with an element it delegates to the element
205
+ * observe command below and still returns `ready` for a uniform return shape.
206
+ */
207
+ observe(): Promise<void>;
208
+ observe(element: Element, options?: ResizeOptions): Promise<void>;
209
+ /**
210
+ * Tear down the observer and invalidate the lifecycle (§3.5). Mirrors disconnect()
211
+ * but is the lifecycle-named counterpart the Shell calls from disconnectedCallback;
212
+ * a later observe() rebuilds the observer.
213
+ */
214
+ dispose(): void;
194
215
  get entry(): WcsResizeEntry | null;
195
216
  get width(): number;
196
217
  get height(): number;
@@ -208,7 +229,7 @@ declare class ResizeCore extends EventTarget {
208
229
  * `content-box` before giving up; both giving-up paths leave `observing` false,
209
230
  * consistent with the never-throw design of the other @wcstack sensors.
210
231
  */
211
- observe(element: Element, options?: ResizeOptions): void;
232
+ private _observeElement;
212
233
  /**
213
234
  * Stop observing `element`. A no-op if it is not the currently observed element.
214
235
  * The observer instance is torn down (single-target Core), so a later observe()
@@ -267,7 +288,9 @@ declare class WcsResize extends HTMLElement {
267
288
  static wcBindable: IWcBindable;
268
289
  private _core;
269
290
  private _trigger;
291
+ private _connectedCallbackPromise;
270
292
  constructor();
293
+ get connectedCallbackPromise(): Promise<void>;
271
294
  get target(): string;
272
295
  set target(value: string);
273
296
  get box(): string;
package/dist/index.esm.js CHANGED
@@ -87,10 +87,32 @@ class ResizeCore extends EventTarget {
87
87
  _effectiveBox = "content-box";
88
88
  _entry = null;
89
89
  _observing = false;
90
+ // SSR: ResizeObserver delivers the initial size synchronously, so there is no
91
+ // asynchronous probe to await — readiness is immediate. Kept as a field so the
92
+ // Shell can expose it as connectedCallbackPromise uniformly with the other nodes.
93
+ _ready = Promise.resolve();
90
94
  constructor(target) {
91
95
  super();
92
96
  this._target = target ?? this;
93
97
  }
98
+ /** Resolves once the first probe settles. Synchronous here, so already resolved. */
99
+ get ready() {
100
+ return this._ready;
101
+ }
102
+ observe(element, options = {}) {
103
+ if (element) {
104
+ this._observeElement(element, options);
105
+ }
106
+ return this._ready;
107
+ }
108
+ /**
109
+ * Tear down the observer and invalidate the lifecycle (§3.5). Mirrors disconnect()
110
+ * but is the lifecycle-named counterpart the Shell calls from disconnectedCallback;
111
+ * a later observe() rebuilds the observer.
112
+ */
113
+ dispose() {
114
+ this.disconnect();
115
+ }
94
116
  get entry() {
95
117
  return this._entry;
96
118
  }
@@ -135,7 +157,7 @@ class ResizeCore extends EventTarget {
135
157
  * `content-box` before giving up; both giving-up paths leave `observing` false,
136
158
  * consistent with the never-throw design of the other @wcstack sensors.
137
159
  */
138
- observe(element, options = {}) {
160
+ _observeElement(element, options = {}) {
139
161
  if (this._observer && this._observed === element && this._optionsEqual(this._options, options)) {
140
162
  return;
141
163
  }
@@ -325,7 +347,7 @@ const BOX_VALUES = ["content-box", "border-box", "device-pixel-content-box"];
325
347
  * the `<wcs-resize>` host itself except in the `self` form.
326
348
  */
327
349
  class WcsResize extends HTMLElement {
328
- static hasConnectedCallbackPromise = false;
350
+ static hasConnectedCallbackPromise = true;
329
351
  // Only attributes that change *what or how* we observe trigger a re-observe.
330
352
  // `once` is intentionally excluded: it is evaluated at change fire time (in
331
353
  // `_onChange`), so toggling it takes effect without re-observing — and a
@@ -360,10 +382,17 @@ class WcsResize extends HTMLElement {
360
382
  };
361
383
  _core;
362
384
  _trigger = false;
385
+ _connectedCallbackPromise = Promise.resolve();
363
386
  constructor() {
364
387
  super();
365
388
  this._core = new ResizeCore(this);
366
389
  }
390
+ // SSR: the state binder awaits this before snapshotting. Backed by the Core's
391
+ // synchronous `ready` (resize delivers the initial size synchronously, so it is
392
+ // already resolved); exposed for uniformity with the other @wcstack IO nodes.
393
+ get connectedCallbackPromise() {
394
+ return this._connectedCallbackPromise;
395
+ }
367
396
  // --- Attribute accessors ---
368
397
  get target() {
369
398
  return this.getAttribute("target") ?? "";
@@ -553,10 +582,14 @@ class WcsResize extends HTMLElement {
553
582
  if (!this.manual) {
554
583
  this.observe();
555
584
  }
585
+ // SSR: back connectedCallbackPromise with the Core's readiness probe. The
586
+ // observation itself is started above via the element-observe command; this
587
+ // captures the (synchronously resolved) ready promise for the state binder.
588
+ this._connectedCallbackPromise = this._core.observe();
556
589
  }
557
590
  disconnectedCallback() {
558
591
  this.removeEventListener("wcs-resize:change", this._onChange);
559
- this._core.disconnect();
592
+ this._core.dispose();
560
593
  }
561
594
  attributeChangedCallback(_name, oldValue, newValue) {
562
595
  // Defensive same-value guard. Per the HTML spec, an attribute change reaction is
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/ResizeCore.ts","../src/components/Resize.ts","../src/registerComponents.ts","../src/bootstrapResize.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n resize: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n resize: \"wcs-resize\",\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\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import { IWcBindable, ResizeOptions, ResizeBoxOption, WcsResizeEntry, WcsResizeRect, WcsResizeBoxSize } from \"../types.js\";\n\n/**\n * Headless element-size primitive. A thin, framework-agnostic wrapper around the\n * ResizeObserver API exposed through the wc-bindable protocol.\n *\n * Like IntersectionCore, the thing being observed is a *DOM element* — so\n * `observe()` takes the target node. The Core stays DOM-resolution-agnostic: it\n * observes whatever element it is handed (the Shell resolves the `target` selector\n * before calling). It is a read-only producer — element/layout → state only.\n *\n * Every observer callback is published via the single `wcs-resize:change` event;\n * `width` / `height` are read from it through getters (mirroring how\n * IntersectionCore derives `intersecting` / `ratio` from one event), so an observer\n * binding any of them is notified on every change.\n *\n * `width` / `height` follow the observed `box` (border-box / device-pixel /\n * content-box) and are rounded to integers when `round` is set — `round` absorbs\n * the sub-pixel jitter that would otherwise let a size→layout→size loop oscillate.\n *\n * Single-target by design: the Shell observes exactly one element, so the state\n * reflects that element. Multi-target observation is intentionally out of scope.\n */\nexport class ResizeCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"entry\", event: \"wcs-resize:change\" },\n { name: \"width\", event: \"wcs-resize:change\", getter: (e: Event) => (e as CustomEvent).detail.width },\n { name: \"height\", event: \"wcs-resize:change\", getter: (e: Event) => (e as CustomEvent).detail.height },\n { name: \"observing\", event: \"wcs-resize:observing-changed\" },\n ],\n commands: [\n { name: \"observe\" },\n { name: \"unobserve\" },\n { name: \"disconnect\" },\n ],\n };\n\n private _target: EventTarget;\n\n // The live observer and the single element it observes. The *requested* options\n // are kept so a repeated observe() with identical options is a no-op (avoids the\n // create→observe→disconnect churn an autoloader upgrade can otherwise cause). It\n // is the requested box — not the effective one — so a re-observe of an unsupported\n // box (which falls back to content-box) still hits the idempotency guard instead\n // of rebuilding+falling-back every time. `_effectiveBox` separately tracks the box\n // actually in effect, which is what normalization reads.\n private _observer: ResizeObserver | null = null;\n private _observed: Element | null = null;\n private _options: ResizeOptions = {};\n private _effectiveBox: ResizeBoxOption = \"content-box\";\n\n private _entry: WcsResizeEntry | null = null;\n private _observing: boolean = false;\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get entry(): WcsResizeEntry | null {\n return this._entry;\n }\n\n get width(): number {\n return this._entry ? this._entry.width : 0;\n }\n\n get height(): number {\n return this._entry ? this._entry.height : 0;\n }\n\n get observing(): boolean {\n return this._observing;\n }\n\n // --- State setters with event dispatch ---\n\n private _setEntry(entry: WcsResizeEntry): void {\n // No same-value guard: `change` carries event semantics (every callback is a\n // distinct observation) and `width` / `height` are derived getters that must\n // re-fire on each entry, mirroring IntersectionCore's `change`.\n this._entry = entry;\n this._target.dispatchEvent(new CustomEvent(\"wcs-resize:change\", {\n detail: entry,\n bubbles: true,\n }));\n }\n\n private _setObserving(observing: boolean): void {\n if (this._observing === observing) return;\n this._observing = observing;\n this._target.dispatchEvent(new CustomEvent(\"wcs-resize:observing-changed\", {\n detail: observing,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing `element`. Idempotent while already observing the same element\n * with the same options. Changing the element or options tears down the current\n * observer and builds a new one (re-observing also re-delivers the initial size,\n * which is how a `round` toggle re-fires with the new rounding).\n *\n * If ResizeObserver is unavailable (SSR) this is a silent no-op — `observing`\n * stays false. If the requested `box` is unsupported, it retries once with\n * `content-box` before giving up; both giving-up paths leave `observing` false,\n * consistent with the never-throw design of the other @wcstack sensors.\n */\n observe(element: Element, options: ResizeOptions = {}): void {\n if (this._observer && this._observed === element && this._optionsEqual(this._options, options)) {\n return;\n }\n this._teardownObserver();\n const observer = this._createObserver();\n if (!observer) {\n // Unsupported environment (no ResizeObserver). If we were already observing,\n // that observation is now gone — reflect it rather than reporting a stale true.\n this._setObserving(false);\n return;\n }\n const effectiveBox = this._beginObserve(observer, element, options.box);\n if (effectiveBox === null) {\n // observe() threw even after the content-box fallback — no live observation.\n observer.disconnect();\n this._setObserving(false);\n return;\n }\n this._observer = observer;\n this._observed = element;\n // Store the *requested* options (raw) for the idempotency guard; `_effectiveBox`\n // holds the box that actually took effect (content-box after a fallback) for\n // normalization to read.\n this._options = { box: options.box, round: options.round };\n this._effectiveBox = effectiveBox;\n this._setObserving(true);\n }\n\n /**\n * Stop observing `element`. A no-op if it is not the currently observed element.\n * The observer instance is torn down (single-target Core), so a later observe()\n * rebuilds it.\n */\n unobserve(element: Element): void {\n if (this._observed !== element) return;\n this._teardownObserver();\n this._setObserving(false);\n }\n\n /** Stop all observation and release the observer. */\n disconnect(): void {\n this._teardownObserver();\n this._setObserving(false);\n }\n\n // --- Internal ---\n\n private _teardownObserver(): void {\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n this._observed = null;\n }\n\n private _createObserver(): ResizeObserver | null {\n // No constructor try/catch: unlike IntersectionObserver (which validates\n // rootMargin at construction), the ResizeObserver constructor takes only a\n // callback and has no throwing precondition. The throw path is on observe()\n // (an unsupported `box`), handled in _beginObserve.\n if (typeof ResizeObserver === \"undefined\") return null;\n return new ResizeObserver(this._onResize);\n }\n\n /**\n * Start observing with the requested `box`, retrying once with `content-box` if\n * the runtime rejects the box (e.g. `device-pixel-content-box` on engines that do\n * not support it). Returns the box actually in effect, or `null` if observation\n * could not start at all.\n */\n private _beginObserve(observer: ResizeObserver, element: Element, box?: ResizeBoxOption): ResizeBoxOption | null {\n const requested = box ?? \"content-box\";\n try {\n observer.observe(element, { box: requested });\n return requested;\n } catch {\n // Already content-box and it still threw — nothing safer to fall back to.\n if (requested === \"content-box\") return null;\n try {\n observer.observe(element, { box: \"content-box\" });\n return \"content-box\";\n } catch {\n return null;\n }\n }\n }\n\n private _onResize = (entries: ResizeObserverEntry[]): void => {\n for (const entry of entries) {\n this._setEntry(this._normalizeEntry(entry));\n }\n };\n\n private _normalizeEntry(entry: ResizeObserverEntry): WcsResizeEntry {\n const contentRect = this._normalizeRect(entry.contentRect);\n const contentBoxSize = this._firstBoxSize(entry.contentBoxSize);\n const borderBoxSize = this._firstBoxSize(entry.borderBoxSize);\n // devicePixelContentBoxSize is Chromium-only; absent on other engines.\n const devicePixelContentBoxSize = this._firstBoxSize((entry as { devicePixelContentBoxSize?: ReadonlyArray<ResizeObserverSize> }).devicePixelContentBoxSize);\n const { width, height } = this._headlineSize(contentBoxSize, borderBoxSize, devicePixelContentBoxSize, contentRect);\n return {\n width,\n height,\n contentRect,\n contentBoxSize,\n borderBoxSize,\n devicePixelContentBoxSize,\n target: entry.target,\n };\n }\n\n /**\n * Pick the headline width/height from the boxSize matching the observed `box`,\n * falling back to `contentRect` when that fragment is absent (older engines only\n * fill contentRect). `inlineSize`/`blockSize` map to width/height (correct for\n * horizontal writing modes). Rounds to integers when `round` is set.\n */\n private _headlineSize(\n contentBoxSize: WcsResizeBoxSize | null,\n borderBoxSize: WcsResizeBoxSize | null,\n devicePixelContentBoxSize: WcsResizeBoxSize | null,\n contentRect: WcsResizeRect,\n ): { width: number; height: number } {\n const box = this._effectiveBox;\n let size: WcsResizeBoxSize | null;\n if (box === \"border-box\") {\n size = borderBoxSize;\n } else if (box === \"device-pixel-content-box\") {\n size = devicePixelContentBoxSize;\n } else {\n size = contentBoxSize;\n }\n let width: number;\n let height: number;\n if (size) {\n width = size.inlineSize;\n height = size.blockSize;\n } else {\n width = contentRect.width;\n height = contentRect.height;\n }\n if (this._options.round) {\n width = Math.round(width);\n height = Math.round(height);\n }\n return { width, height };\n }\n\n private _firstBoxSize(list: ReadonlyArray<ResizeObserverSize> | undefined): WcsResizeBoxSize | null {\n if (!list || list.length === 0) return null;\n const first = list[0];\n return { inlineSize: first.inlineSize, blockSize: first.blockSize };\n }\n\n private _normalizeRect(rect: DOMRectReadOnly): WcsResizeRect {\n return {\n x: rect.x,\n y: rect.y,\n width: rect.width,\n height: rect.height,\n top: rect.top,\n right: rect.right,\n bottom: rect.bottom,\n left: rect.left,\n };\n }\n\n private _optionsEqual(a: ResizeOptions, b: ResizeOptions): boolean {\n if ((a.box ?? \"content-box\") !== (b.box ?? \"content-box\")) return false;\n return (a.round ?? false) === (b.round ?? false);\n }\n}\n","import { IWcBindable, ResizeOptions, ResizeBoxOption, WcsResizeEntry } from \"../types.js\";\nimport { ResizeCore } from \"../core/ResizeCore.js\";\n\nconst BOX_VALUES: ReadonlyArray<ResizeBoxOption> = [\"content-box\", \"border-box\", \"device-pixel-content-box\"];\n\n/**\n * `<wcs-resize>` — declarative ResizeObserver.\n *\n * The `target` attribute is the single knob that decides both *what* is observed\n * and how the element renders (it never injects a layout box unless asked):\n *\n * | `target` | observes | display | use case |\n * |-----------------|-----------------------|-------------|----------------------|\n * | omitted | first element child | `contents` | size a wrapped child |\n * | `\"#panel\"` / sel| the matched element | `none` | size an existing node|\n * | `\"self\"` | the element itself | `block` | container-width probe|\n *\n * `display:contents` means wrapping a child injects no box of its own (so a\n * `<wcs-resize><div></wcs-resize>` does not disturb a flex/grid parent); the\n * `target=\"self\"` form takes a `display:block` box that, as a zero-height element,\n * stretches to the parent's available inline size — a container-width probe.\n *\n * Note: a `display:contents` / `display:none` element generates no box, so the\n * observed node must be the child / selector target (which do have boxes), never\n * the `<wcs-resize>` host itself except in the `self` form.\n */\nexport class WcsResize extends HTMLElement {\n static hasConnectedCallbackPromise = false;\n // Only attributes that change *what or how* we observe trigger a re-observe.\n // `once` is intentionally excluded: it is evaluated at change fire time (in\n // `_onChange`), so toggling it takes effect without re-observing — and a\n // re-observe on its change would be a pure no-op (same target, same options).\n // `manual` is also excluded: it is a connect-time policy (\"don't auto-observe on\n // connect\"), not a live switch that should start/stop an active observation.\n // `box` and `round` ARE observed: changing them rebuilds the observer, and the\n // rebuild re-delivers the initial size — which is exactly how a `round` toggle\n // re-emits width/height with the new rounding.\n static observedAttributes = [\"target\", \"box\", \"round\"];\n\n static wcBindable: IWcBindable = {\n ...ResizeCore.wcBindable,\n properties: [\n ...ResizeCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-resize:trigger-changed\" },\n ],\n // Shell-level settable surface. Each input carries its mirrored `attribute`\n // hint; `trigger` has none — it is a momentary command-property, not a\n // declarative attribute. The observe / unobserve / disconnect commands are\n // inherited from the Core via the spread above.\n inputs: [\n { name: \"target\", attribute: \"target\" },\n { name: \"box\", attribute: \"box\" },\n { name: \"round\", attribute: \"round\" },\n { name: \"once\", attribute: \"once\" },\n { name: \"manual\", attribute: \"manual\" },\n { name: \"trigger\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。<wcs-intersect>/<wcs-sse> と同型。\n // spread でも継承されるが、Core に command 追加時の追従漏れを防ぐため明示参照する。\n commands: ResizeCore.wcBindable.commands,\n };\n\n private _core: ResizeCore;\n private _trigger: boolean = false;\n\n constructor() {\n super();\n this._core = new ResizeCore(this);\n }\n\n // --- Attribute accessors ---\n\n get target(): string {\n return this.getAttribute(\"target\") ?? \"\";\n }\n\n set target(value: string) {\n this.setAttribute(\"target\", value);\n }\n\n get box(): string {\n return this.getAttribute(\"box\") ?? \"\";\n }\n\n set box(value: string) {\n this.setAttribute(\"box\", value);\n }\n\n get round(): boolean {\n return this.hasAttribute(\"round\");\n }\n\n set round(value: boolean) {\n if (value) {\n this.setAttribute(\"round\", \"\");\n } else {\n this.removeAttribute(\"round\");\n }\n }\n\n get once(): boolean {\n return this.hasAttribute(\"once\");\n }\n\n set once(value: boolean) {\n if (value) {\n this.setAttribute(\"once\", \"\");\n } else {\n this.removeAttribute(\"once\");\n }\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean) {\n if (value) {\n this.setAttribute(\"manual\", \"\");\n } else {\n this.removeAttribute(\"manual\");\n }\n }\n\n // --- Core delegated getters ---\n\n get entry(): WcsResizeEntry | null {\n return this._core.entry;\n }\n\n get width(): number {\n return this._core.width;\n }\n\n get height(): number {\n return this._core.height;\n }\n\n get observing(): boolean {\n return this._core.observing;\n }\n\n // --- Command property ---\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n // Momentary command-property: a false→true write re-runs observe(). Mirrors the\n // trigger flag on <wcs-intersect> / <wcs-geo>. Prefer the command-token protocol\n // (`command.observe: $command.start`) for state-driven observation; this exists\n // mainly for simple boolean bindings.\n const v = !!value; // normalize truthy state-bindings, like <wcs-intersect>'s setter\n if (v) {\n this._trigger = true;\n // try/finally mirrors <wcs-intersect>'s set trigger: observe() is never-throw\n // today, but should a synchronous throw path ever appear, the finally still\n // auto-resets _trigger (no stuck-true latch) and emits the completion notice.\n try {\n this.observe();\n } finally {\n this._trigger = false;\n // Always auto-reset to false after the observe() attempt — this is the\n // *momentary acknowledgement* that the trigger was consumed, NOT a signal\n // that observation succeeded (whether the target resolved is reflected by\n // `observing`, not by this event). Read `observing` if you need the outcome.\n this.dispatchEvent(new CustomEvent(\"wcs-resize:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n }\n }\n }\n\n // --- Commands ---\n\n /** Re-resolve the target from the DOM and (re)start observing. */\n observe(): void {\n const { element, display } = this._resolveTarget();\n // `display` is derived from the `target` *mode* (self/selector/child), not from\n // whether the selector currently matches — so it is applied unconditionally,\n // before the resolution check. A `target=\"#x\"` whose node is momentarily absent\n // still renders `display:none` (it is a selector pointer, never a box).\n this.style.display = display;\n if (!element) {\n // The target is no longer resolvable (e.g. a `target` selector whose node was\n // removed from the DOM). Tear down any stale observation so `observing` does\n // not keep reporting true against a node that is gone.\n this._core.disconnect();\n return;\n }\n this._core.observe(element, this._options());\n }\n\n unobserve(): void {\n // Single-target Shell: \"stop observing my target\" is exactly the Core's\n // teardown. Delegate to the Core's tracked state rather than re-resolving the\n // selector, so a target that has since left the DOM can still be stopped\n // (re-resolving would yield null and silently leave the observer running).\n this._core.disconnect();\n }\n\n disconnect(): void {\n this._core.disconnect();\n }\n\n // --- Internal ---\n\n private _resolveTarget(): { element: Element | null; display: string } {\n const target = this.target;\n if (target === \"self\") {\n // Explicit sentinel: observe the element itself. As a display:block zero-height\n // box it stretches to the parent's available inline size — a container probe.\n return { element: this, display: \"block\" };\n }\n if (target !== \"\") {\n // Selector pointer: observe a referenced element in place, staying invisible.\n const scope = this.getRootNode() as Document | ShadowRoot;\n // A user-authored selector can be syntactically invalid (e.g. `#`, `:::`,\n // `[data-*`), which makes querySelector throw a SyntaxError. Swallow it and\n // treat the target as unresolvable — the same \"nothing to observe\" path as a\n // selector matching no element — so a bad attribute never lets the throw escape\n // observe() → connectedCallback / attributeChangedCallback (never-throw).\n return { element: this._safeQuery(scope, target), display: \"none\" };\n }\n // Omitted: observe the first element child without injecting a box of our own.\n const child = this.firstElementChild;\n if (child) {\n return { element: child, display: \"contents\" };\n }\n // No child to wrap (e.g. used as an empty marker) — fall back to self.\n return { element: this, display: \"block\" };\n }\n\n // Wrap querySelector so a syntactically invalid user-authored selector resolves to\n // null (unresolvable) instead of letting the SyntaxError escape — keeping the\n // sensor never-throw, mirroring intersection's _safeQuery guard.\n private _safeQuery(scope: Document | ShadowRoot, selector: string): Element | null {\n try {\n return scope.querySelector(selector);\n } catch {\n return null;\n }\n }\n\n private _parseBox(): ResizeBoxOption {\n const raw = this.box.trim();\n // Decision: an unrecognized box value falls back to content-box at parse time\n // (rather than letting the Core's observe() reject it), mirroring threshold's\n // range filter in <wcs-intersect>. The Core still has its own runtime fallback\n // for a *valid-but-unsupported* box (e.g. device-pixel-content-box on Safari).\n return (BOX_VALUES as ReadonlyArray<string>).includes(raw) ? (raw as ResizeBoxOption) : \"content-box\";\n }\n\n private _options(): ResizeOptions {\n return {\n box: this._parseBox(),\n round: this.round,\n };\n }\n\n private _onChange = (event: Event): void => {\n // `wcs-resize:change` bubbles, so a nested `<wcs-resize>` descendant's change\n // would otherwise reach this (ancestor) listener and let a *child's* resize tear\n // down *our* observer. Only act on our own Core's event. (This also avoids\n // reading `.detail` off a foreign event shape.)\n if (event.target !== this) return;\n // `once`: tear down after the first size observation. ResizeObserver always\n // delivers the initial size on observe(), so once = measure-once. Gated at fire\n // time so toggling the `once` attribute takes effect live.\n if (this.once) {\n this._core.disconnect();\n }\n };\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.addEventListener(\"wcs-resize:change\", this._onChange);\n if (!this.manual) {\n this.observe();\n }\n }\n\n disconnectedCallback(): void {\n this.removeEventListener(\"wcs-resize:change\", this._onChange);\n this._core.disconnect();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n // Defensive same-value guard. Per the HTML spec, an attribute change reaction is\n // enqueued whenever setAttribute() runs — including with an unchanged value — so\n // attributeChangedCallback CAN fire on a same-value write. Re-observing on an\n // unchanged attribute would be a wasted observer rebuild, so bail early when the\n // value did not actually change. Kept intentionally; do not remove.\n if (oldValue === newValue) return;\n // Only react once connected and in automatic mode. The Core's idempotency guard\n // absorbs the autoloader upgrade case (attributeChangedCallback +\n // connectedCallback both calling observe() with identical options).\n if (!this.isConnected || this.manual) return;\n this.observe();\n }\n}\n","import { WcsResize } from \"./components/Resize.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.resize)) {\n customElements.define(config.tagNames.resize, WcsResize);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapResize(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n"],"names":[],"mappings":"AAQA,MAAM,OAAO,GAAoB;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,MAAM,EAAE,YAAY;AACrB,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,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AS,GAAG,CAAC,KAAY,KAAU;;;;;AAKzC,QAAA,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI;YAAE;;;;AAI3B,QAAA,IAAI,IAAI,CAAC,IAAI,EAAE;AACb,YAAA,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;QACzB;AACF,IAAA,CAAC;;IAID,iBAAiB,GAAA;QACf,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC;AAC1D,QAAA,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,IAAI,CAAC,OAAO,EAAE;QAChB;IACF;IAEA,oBAAoB,GAAA;QAClB,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC;AAC7D,QAAA,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;IACzB;AAEA,IAAA,wBAAwB,CAAC,KAAa,EAAE,QAAuB,EAAE,QAAuB,EAAA;;;;;;QAMtF,IAAI,QAAQ,KAAK,QAAQ;YAAE;;;;AAI3B,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,MAAM;YAAE;QACtC,IAAI,CAAC,OAAO,EAAE;IAChB;;;SC3Sc,kBAAkB,GAAA;AAChC,IAAA,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAC/C,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC1D;AACF;;ACHM,SAAU,eAAe,CAAC,UAA4B,EAAA;IAC1D,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;AACA,IAAA,kBAAkB,EAAE;AACtB;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/ResizeCore.ts","../src/components/Resize.ts","../src/registerComponents.ts","../src/bootstrapResize.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n resize: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n resize: \"wcs-resize\",\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\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import { IWcBindable, ResizeOptions, ResizeBoxOption, WcsResizeEntry, WcsResizeRect, WcsResizeBoxSize } from \"../types.js\";\n\n/**\n * Headless element-size primitive. A thin, framework-agnostic wrapper around the\n * ResizeObserver API exposed through the wc-bindable protocol.\n *\n * Like IntersectionCore, the thing being observed is a *DOM element* — so\n * `observe()` takes the target node. The Core stays DOM-resolution-agnostic: it\n * observes whatever element it is handed (the Shell resolves the `target` selector\n * before calling). It is a read-only producer — element/layout → state only.\n *\n * Every observer callback is published via the single `wcs-resize:change` event;\n * `width` / `height` are read from it through getters (mirroring how\n * IntersectionCore derives `intersecting` / `ratio` from one event), so an observer\n * binding any of them is notified on every change.\n *\n * `width` / `height` follow the observed `box` (border-box / device-pixel /\n * content-box) and are rounded to integers when `round` is set — `round` absorbs\n * the sub-pixel jitter that would otherwise let a size→layout→size loop oscillate.\n *\n * Single-target by design: the Shell observes exactly one element, so the state\n * reflects that element. Multi-target observation is intentionally out of scope.\n */\nexport class ResizeCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"entry\", event: \"wcs-resize:change\" },\n { name: \"width\", event: \"wcs-resize:change\", getter: (e: Event) => (e as CustomEvent).detail.width },\n { name: \"height\", event: \"wcs-resize:change\", getter: (e: Event) => (e as CustomEvent).detail.height },\n { name: \"observing\", event: \"wcs-resize:observing-changed\" },\n ],\n commands: [\n { name: \"observe\" },\n { name: \"unobserve\" },\n { name: \"disconnect\" },\n ],\n };\n\n private _target: EventTarget;\n\n // The live observer and the single element it observes. The *requested* options\n // are kept so a repeated observe() with identical options is a no-op (avoids the\n // create→observe→disconnect churn an autoloader upgrade can otherwise cause). It\n // is the requested box — not the effective one — so a re-observe of an unsupported\n // box (which falls back to content-box) still hits the idempotency guard instead\n // of rebuilding+falling-back every time. `_effectiveBox` separately tracks the box\n // actually in effect, which is what normalization reads.\n private _observer: ResizeObserver | null = null;\n private _observed: Element | null = null;\n private _options: ResizeOptions = {};\n private _effectiveBox: ResizeBoxOption = \"content-box\";\n\n private _entry: WcsResizeEntry | null = null;\n private _observing: boolean = false;\n\n // SSR: ResizeObserver delivers the initial size synchronously, so there is no\n // asynchronous probe to await — readiness is immediate. Kept as a field so the\n // Shell can expose it as connectedCallbackPromise uniformly with the other nodes.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n /** Resolves once the first probe settles. Synchronous here, so already resolved. */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n /**\n * Lifecycle entry point (§3.5). When called with no element it is an idempotent\n * no-op that resolves once ready — resize is command-driven (the Shell resolves\n * the target and calls observe(element)), so connect-time monitoring is started\n * via that command, not here. The Shell backs `connectedCallbackPromise` with\n * this no-arg form. When called with an element it delegates to the element\n * observe command below and still returns `ready` for a uniform return shape.\n */\n observe(): Promise<void>;\n observe(element: Element, options?: ResizeOptions): Promise<void>;\n observe(element?: Element, options: ResizeOptions = {}): Promise<void> {\n if (element) {\n this._observeElement(element, options);\n }\n return this._ready;\n }\n\n /**\n * Tear down the observer and invalidate the lifecycle (§3.5). Mirrors disconnect()\n * but is the lifecycle-named counterpart the Shell calls from disconnectedCallback;\n * a later observe() rebuilds the observer.\n */\n dispose(): void {\n this.disconnect();\n }\n\n get entry(): WcsResizeEntry | null {\n return this._entry;\n }\n\n get width(): number {\n return this._entry ? this._entry.width : 0;\n }\n\n get height(): number {\n return this._entry ? this._entry.height : 0;\n }\n\n get observing(): boolean {\n return this._observing;\n }\n\n // --- State setters with event dispatch ---\n\n private _setEntry(entry: WcsResizeEntry): void {\n // No same-value guard: `change` carries event semantics (every callback is a\n // distinct observation) and `width` / `height` are derived getters that must\n // re-fire on each entry, mirroring IntersectionCore's `change`.\n this._entry = entry;\n this._target.dispatchEvent(new CustomEvent(\"wcs-resize:change\", {\n detail: entry,\n bubbles: true,\n }));\n }\n\n private _setObserving(observing: boolean): void {\n if (this._observing === observing) return;\n this._observing = observing;\n this._target.dispatchEvent(new CustomEvent(\"wcs-resize:observing-changed\", {\n detail: observing,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing `element`. Idempotent while already observing the same element\n * with the same options. Changing the element or options tears down the current\n * observer and builds a new one (re-observing also re-delivers the initial size,\n * which is how a `round` toggle re-fires with the new rounding).\n *\n * If ResizeObserver is unavailable (SSR) this is a silent no-op — `observing`\n * stays false. If the requested `box` is unsupported, it retries once with\n * `content-box` before giving up; both giving-up paths leave `observing` false,\n * consistent with the never-throw design of the other @wcstack sensors.\n */\n private _observeElement(element: Element, options: ResizeOptions = {}): void {\n if (this._observer && this._observed === element && this._optionsEqual(this._options, options)) {\n return;\n }\n this._teardownObserver();\n const observer = this._createObserver();\n if (!observer) {\n // Unsupported environment (no ResizeObserver). If we were already observing,\n // that observation is now gone — reflect it rather than reporting a stale true.\n this._setObserving(false);\n return;\n }\n const effectiveBox = this._beginObserve(observer, element, options.box);\n if (effectiveBox === null) {\n // observe() threw even after the content-box fallback — no live observation.\n observer.disconnect();\n this._setObserving(false);\n return;\n }\n this._observer = observer;\n this._observed = element;\n // Store the *requested* options (raw) for the idempotency guard; `_effectiveBox`\n // holds the box that actually took effect (content-box after a fallback) for\n // normalization to read.\n this._options = { box: options.box, round: options.round };\n this._effectiveBox = effectiveBox;\n this._setObserving(true);\n }\n\n /**\n * Stop observing `element`. A no-op if it is not the currently observed element.\n * The observer instance is torn down (single-target Core), so a later observe()\n * rebuilds it.\n */\n unobserve(element: Element): void {\n if (this._observed !== element) return;\n this._teardownObserver();\n this._setObserving(false);\n }\n\n /** Stop all observation and release the observer. */\n disconnect(): void {\n this._teardownObserver();\n this._setObserving(false);\n }\n\n // --- Internal ---\n\n private _teardownObserver(): void {\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n this._observed = null;\n }\n\n private _createObserver(): ResizeObserver | null {\n // No constructor try/catch: unlike IntersectionObserver (which validates\n // rootMargin at construction), the ResizeObserver constructor takes only a\n // callback and has no throwing precondition. The throw path is on observe()\n // (an unsupported `box`), handled in _beginObserve.\n if (typeof ResizeObserver === \"undefined\") return null;\n return new ResizeObserver(this._onResize);\n }\n\n /**\n * Start observing with the requested `box`, retrying once with `content-box` if\n * the runtime rejects the box (e.g. `device-pixel-content-box` on engines that do\n * not support it). Returns the box actually in effect, or `null` if observation\n * could not start at all.\n */\n private _beginObserve(observer: ResizeObserver, element: Element, box?: ResizeBoxOption): ResizeBoxOption | null {\n const requested = box ?? \"content-box\";\n try {\n observer.observe(element, { box: requested });\n return requested;\n } catch {\n // Already content-box and it still threw — nothing safer to fall back to.\n if (requested === \"content-box\") return null;\n try {\n observer.observe(element, { box: \"content-box\" });\n return \"content-box\";\n } catch {\n return null;\n }\n }\n }\n\n private _onResize = (entries: ResizeObserverEntry[]): void => {\n for (const entry of entries) {\n this._setEntry(this._normalizeEntry(entry));\n }\n };\n\n private _normalizeEntry(entry: ResizeObserverEntry): WcsResizeEntry {\n const contentRect = this._normalizeRect(entry.contentRect);\n const contentBoxSize = this._firstBoxSize(entry.contentBoxSize);\n const borderBoxSize = this._firstBoxSize(entry.borderBoxSize);\n // devicePixelContentBoxSize is Chromium-only; absent on other engines.\n const devicePixelContentBoxSize = this._firstBoxSize((entry as { devicePixelContentBoxSize?: ReadonlyArray<ResizeObserverSize> }).devicePixelContentBoxSize);\n const { width, height } = this._headlineSize(contentBoxSize, borderBoxSize, devicePixelContentBoxSize, contentRect);\n return {\n width,\n height,\n contentRect,\n contentBoxSize,\n borderBoxSize,\n devicePixelContentBoxSize,\n target: entry.target,\n };\n }\n\n /**\n * Pick the headline width/height from the boxSize matching the observed `box`,\n * falling back to `contentRect` when that fragment is absent (older engines only\n * fill contentRect). `inlineSize`/`blockSize` map to width/height (correct for\n * horizontal writing modes). Rounds to integers when `round` is set.\n */\n private _headlineSize(\n contentBoxSize: WcsResizeBoxSize | null,\n borderBoxSize: WcsResizeBoxSize | null,\n devicePixelContentBoxSize: WcsResizeBoxSize | null,\n contentRect: WcsResizeRect,\n ): { width: number; height: number } {\n const box = this._effectiveBox;\n let size: WcsResizeBoxSize | null;\n if (box === \"border-box\") {\n size = borderBoxSize;\n } else if (box === \"device-pixel-content-box\") {\n size = devicePixelContentBoxSize;\n } else {\n size = contentBoxSize;\n }\n let width: number;\n let height: number;\n if (size) {\n width = size.inlineSize;\n height = size.blockSize;\n } else {\n width = contentRect.width;\n height = contentRect.height;\n }\n if (this._options.round) {\n width = Math.round(width);\n height = Math.round(height);\n }\n return { width, height };\n }\n\n private _firstBoxSize(list: ReadonlyArray<ResizeObserverSize> | undefined): WcsResizeBoxSize | null {\n if (!list || list.length === 0) return null;\n const first = list[0];\n return { inlineSize: first.inlineSize, blockSize: first.blockSize };\n }\n\n private _normalizeRect(rect: DOMRectReadOnly): WcsResizeRect {\n return {\n x: rect.x,\n y: rect.y,\n width: rect.width,\n height: rect.height,\n top: rect.top,\n right: rect.right,\n bottom: rect.bottom,\n left: rect.left,\n };\n }\n\n private _optionsEqual(a: ResizeOptions, b: ResizeOptions): boolean {\n if ((a.box ?? \"content-box\") !== (b.box ?? \"content-box\")) return false;\n return (a.round ?? false) === (b.round ?? false);\n }\n}\n","import { IWcBindable, ResizeOptions, ResizeBoxOption, WcsResizeEntry } from \"../types.js\";\nimport { ResizeCore } from \"../core/ResizeCore.js\";\n\nconst BOX_VALUES: ReadonlyArray<ResizeBoxOption> = [\"content-box\", \"border-box\", \"device-pixel-content-box\"];\n\n/**\n * `<wcs-resize>` — declarative ResizeObserver.\n *\n * The `target` attribute is the single knob that decides both *what* is observed\n * and how the element renders (it never injects a layout box unless asked):\n *\n * | `target` | observes | display | use case |\n * |-----------------|-----------------------|-------------|----------------------|\n * | omitted | first element child | `contents` | size a wrapped child |\n * | `\"#panel\"` / sel| the matched element | `none` | size an existing node|\n * | `\"self\"` | the element itself | `block` | container-width probe|\n *\n * `display:contents` means wrapping a child injects no box of its own (so a\n * `<wcs-resize><div></wcs-resize>` does not disturb a flex/grid parent); the\n * `target=\"self\"` form takes a `display:block` box that, as a zero-height element,\n * stretches to the parent's available inline size — a container-width probe.\n *\n * Note: a `display:contents` / `display:none` element generates no box, so the\n * observed node must be the child / selector target (which do have boxes), never\n * the `<wcs-resize>` host itself except in the `self` form.\n */\nexport class WcsResize extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n // Only attributes that change *what or how* we observe trigger a re-observe.\n // `once` is intentionally excluded: it is evaluated at change fire time (in\n // `_onChange`), so toggling it takes effect without re-observing — and a\n // re-observe on its change would be a pure no-op (same target, same options).\n // `manual` is also excluded: it is a connect-time policy (\"don't auto-observe on\n // connect\"), not a live switch that should start/stop an active observation.\n // `box` and `round` ARE observed: changing them rebuilds the observer, and the\n // rebuild re-delivers the initial size — which is exactly how a `round` toggle\n // re-emits width/height with the new rounding.\n static observedAttributes = [\"target\", \"box\", \"round\"];\n\n static wcBindable: IWcBindable = {\n ...ResizeCore.wcBindable,\n properties: [\n ...ResizeCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-resize:trigger-changed\" },\n ],\n // Shell-level settable surface. Each input carries its mirrored `attribute`\n // hint; `trigger` has none — it is a momentary command-property, not a\n // declarative attribute. The observe / unobserve / disconnect commands are\n // inherited from the Core via the spread above.\n inputs: [\n { name: \"target\", attribute: \"target\" },\n { name: \"box\", attribute: \"box\" },\n { name: \"round\", attribute: \"round\" },\n { name: \"once\", attribute: \"once\" },\n { name: \"manual\", attribute: \"manual\" },\n { name: \"trigger\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。<wcs-intersect>/<wcs-sse> と同型。\n // spread でも継承されるが、Core に command 追加時の追従漏れを防ぐため明示参照する。\n commands: ResizeCore.wcBindable.commands,\n };\n\n private _core: ResizeCore;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n\n constructor() {\n super();\n this._core = new ResizeCore(this);\n }\n\n // SSR: the state binder awaits this before snapshotting. Backed by the Core's\n // synchronous `ready` (resize delivers the initial size synchronously, so it is\n // already resolved); exposed for uniformity with the other @wcstack IO nodes.\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n\n get target(): string {\n return this.getAttribute(\"target\") ?? \"\";\n }\n\n set target(value: string) {\n this.setAttribute(\"target\", value);\n }\n\n get box(): string {\n return this.getAttribute(\"box\") ?? \"\";\n }\n\n set box(value: string) {\n this.setAttribute(\"box\", value);\n }\n\n get round(): boolean {\n return this.hasAttribute(\"round\");\n }\n\n set round(value: boolean) {\n if (value) {\n this.setAttribute(\"round\", \"\");\n } else {\n this.removeAttribute(\"round\");\n }\n }\n\n get once(): boolean {\n return this.hasAttribute(\"once\");\n }\n\n set once(value: boolean) {\n if (value) {\n this.setAttribute(\"once\", \"\");\n } else {\n this.removeAttribute(\"once\");\n }\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean) {\n if (value) {\n this.setAttribute(\"manual\", \"\");\n } else {\n this.removeAttribute(\"manual\");\n }\n }\n\n // --- Core delegated getters ---\n\n get entry(): WcsResizeEntry | null {\n return this._core.entry;\n }\n\n get width(): number {\n return this._core.width;\n }\n\n get height(): number {\n return this._core.height;\n }\n\n get observing(): boolean {\n return this._core.observing;\n }\n\n // --- Command property ---\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n // Momentary command-property: a false→true write re-runs observe(). Mirrors the\n // trigger flag on <wcs-intersect> / <wcs-geo>. Prefer the command-token protocol\n // (`command.observe: $command.start`) for state-driven observation; this exists\n // mainly for simple boolean bindings.\n const v = !!value; // normalize truthy state-bindings, like <wcs-intersect>'s setter\n if (v) {\n this._trigger = true;\n // try/finally mirrors <wcs-intersect>'s set trigger: observe() is never-throw\n // today, but should a synchronous throw path ever appear, the finally still\n // auto-resets _trigger (no stuck-true latch) and emits the completion notice.\n try {\n this.observe();\n } finally {\n this._trigger = false;\n // Always auto-reset to false after the observe() attempt — this is the\n // *momentary acknowledgement* that the trigger was consumed, NOT a signal\n // that observation succeeded (whether the target resolved is reflected by\n // `observing`, not by this event). Read `observing` if you need the outcome.\n this.dispatchEvent(new CustomEvent(\"wcs-resize:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n }\n }\n }\n\n // --- Commands ---\n\n /** Re-resolve the target from the DOM and (re)start observing. */\n observe(): void {\n const { element, display } = this._resolveTarget();\n // `display` is derived from the `target` *mode* (self/selector/child), not from\n // whether the selector currently matches — so it is applied unconditionally,\n // before the resolution check. A `target=\"#x\"` whose node is momentarily absent\n // still renders `display:none` (it is a selector pointer, never a box).\n this.style.display = display;\n if (!element) {\n // The target is no longer resolvable (e.g. a `target` selector whose node was\n // removed from the DOM). Tear down any stale observation so `observing` does\n // not keep reporting true against a node that is gone.\n this._core.disconnect();\n return;\n }\n this._core.observe(element, this._options());\n }\n\n unobserve(): void {\n // Single-target Shell: \"stop observing my target\" is exactly the Core's\n // teardown. Delegate to the Core's tracked state rather than re-resolving the\n // selector, so a target that has since left the DOM can still be stopped\n // (re-resolving would yield null and silently leave the observer running).\n this._core.disconnect();\n }\n\n disconnect(): void {\n this._core.disconnect();\n }\n\n // --- Internal ---\n\n private _resolveTarget(): { element: Element | null; display: string } {\n const target = this.target;\n if (target === \"self\") {\n // Explicit sentinel: observe the element itself. As a display:block zero-height\n // box it stretches to the parent's available inline size — a container probe.\n return { element: this, display: \"block\" };\n }\n if (target !== \"\") {\n // Selector pointer: observe a referenced element in place, staying invisible.\n const scope = this.getRootNode() as Document | ShadowRoot;\n // A user-authored selector can be syntactically invalid (e.g. `#`, `:::`,\n // `[data-*`), which makes querySelector throw a SyntaxError. Swallow it and\n // treat the target as unresolvable — the same \"nothing to observe\" path as a\n // selector matching no element — so a bad attribute never lets the throw escape\n // observe() → connectedCallback / attributeChangedCallback (never-throw).\n return { element: this._safeQuery(scope, target), display: \"none\" };\n }\n // Omitted: observe the first element child without injecting a box of our own.\n const child = this.firstElementChild;\n if (child) {\n return { element: child, display: \"contents\" };\n }\n // No child to wrap (e.g. used as an empty marker) — fall back to self.\n return { element: this, display: \"block\" };\n }\n\n // Wrap querySelector so a syntactically invalid user-authored selector resolves to\n // null (unresolvable) instead of letting the SyntaxError escape — keeping the\n // sensor never-throw, mirroring intersection's _safeQuery guard.\n private _safeQuery(scope: Document | ShadowRoot, selector: string): Element | null {\n try {\n return scope.querySelector(selector);\n } catch {\n return null;\n }\n }\n\n private _parseBox(): ResizeBoxOption {\n const raw = this.box.trim();\n // Decision: an unrecognized box value falls back to content-box at parse time\n // (rather than letting the Core's observe() reject it), mirroring threshold's\n // range filter in <wcs-intersect>. The Core still has its own runtime fallback\n // for a *valid-but-unsupported* box (e.g. device-pixel-content-box on Safari).\n return (BOX_VALUES as ReadonlyArray<string>).includes(raw) ? (raw as ResizeBoxOption) : \"content-box\";\n }\n\n private _options(): ResizeOptions {\n return {\n box: this._parseBox(),\n round: this.round,\n };\n }\n\n private _onChange = (event: Event): void => {\n // `wcs-resize:change` bubbles, so a nested `<wcs-resize>` descendant's change\n // would otherwise reach this (ancestor) listener and let a *child's* resize tear\n // down *our* observer. Only act on our own Core's event. (This also avoids\n // reading `.detail` off a foreign event shape.)\n if (event.target !== this) return;\n // `once`: tear down after the first size observation. ResizeObserver always\n // delivers the initial size on observe(), so once = measure-once. Gated at fire\n // time so toggling the `once` attribute takes effect live.\n if (this.once) {\n this._core.disconnect();\n }\n };\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.addEventListener(\"wcs-resize:change\", this._onChange);\n if (!this.manual) {\n this.observe();\n }\n // SSR: back connectedCallbackPromise with the Core's readiness probe. The\n // observation itself is started above via the element-observe command; this\n // captures the (synchronously resolved) ready promise for the state binder.\n this._connectedCallbackPromise = this._core.observe();\n }\n\n disconnectedCallback(): void {\n this.removeEventListener(\"wcs-resize:change\", this._onChange);\n this._core.dispose();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n // Defensive same-value guard. Per the HTML spec, an attribute change reaction is\n // enqueued whenever setAttribute() runs — including with an unchanged value — so\n // attributeChangedCallback CAN fire on a same-value write. Re-observing on an\n // unchanged attribute would be a wasted observer rebuild, so bail early when the\n // value did not actually change. Kept intentionally; do not remove.\n if (oldValue === newValue) return;\n // Only react once connected and in automatic mode. The Core's idempotency guard\n // absorbs the autoloader upgrade case (attributeChangedCallback +\n // connectedCallback both calling observe() with identical options).\n if (!this.isConnected || this.manual) return;\n this.observe();\n }\n}\n","import { WcsResize } from \"./components/Resize.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.resize)) {\n customElements.define(config.tagNames.resize, WcsResize);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapResize(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n"],"names":[],"mappings":"AAQ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yB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACvD;IAEA,oBAAoB,GAAA;QAClB,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC;AAC7D,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACtB;AAEA,IAAA,wBAAwB,CAAC,KAAa,EAAE,QAAuB,EAAE,QAAuB,EAAA;;;;;;QAMtF,IAAI,QAAQ,KAAK,QAAQ;YAAE;;;;AAI3B,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,MAAM;YAAE;QACtC,IAAI,CAAC,OAAO,EAAE;IAChB;;;SCvTc,kBAAkB,GAAA;AAChC,IAAA,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAC/C,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC1D;AACF;;ACHM,SAAU,eAAe,CAAC,UAA4B,EAAA;IAC1D,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;AACA,IAAA,kBAAkB,EAAE;AACtB;;;;"}
@@ -1,2 +1,2 @@
1
- const e={tagNames:{resize:"wcs-resize"}};function t(e){if(null===e||"object"!=typeof e)return e;Object.freeze(e);for(const r of Object.keys(e))t(e[r]);return e}function r(e){if(null===e||"object"!=typeof e)return e;const t={};for(const n of Object.keys(e))t[n]=r(e[n]);return t}let n=null;const i=e;function s(){return n||(n=t(r(e))),n}class o extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"entry",event:"wcs-resize:change"},{name:"width",event:"wcs-resize:change",getter:e=>e.detail.width},{name:"height",event:"wcs-resize:change",getter:e=>e.detail.height},{name:"observing",event:"wcs-resize:observing-changed"}],commands:[{name:"observe"},{name:"unobserve"},{name:"disconnect"}]};_target;_observer=null;_observed=null;_options={};_effectiveBox="content-box";_entry=null;_observing=!1;constructor(e){super(),this._target=e??this}get entry(){return this._entry}get width(){return this._entry?this._entry.width:0}get height(){return this._entry?this._entry.height:0}get observing(){return this._observing}_setEntry(e){this._entry=e,this._target.dispatchEvent(new CustomEvent("wcs-resize:change",{detail:e,bubbles:!0}))}_setObserving(e){this._observing!==e&&(this._observing=e,this._target.dispatchEvent(new CustomEvent("wcs-resize:observing-changed",{detail:e,bubbles:!0})))}observe(e,t={}){if(this._observer&&this._observed===e&&this._optionsEqual(this._options,t))return;this._teardownObserver();const r=this._createObserver();if(!r)return void this._setObserving(!1);const n=this._beginObserve(r,e,t.box);if(null===n)return r.disconnect(),void this._setObserving(!1);this._observer=r,this._observed=e,this._options={box:t.box,round:t.round},this._effectiveBox=n,this._setObserving(!0)}unobserve(e){this._observed===e&&(this._teardownObserver(),this._setObserving(!1))}disconnect(){this._teardownObserver(),this._setObserving(!1)}_teardownObserver(){this._observer&&(this._observer.disconnect(),this._observer=null),this._observed=null}_createObserver(){return"undefined"==typeof ResizeObserver?null:new ResizeObserver(this._onResize)}_beginObserve(e,t,r){const n=r??"content-box";try{return e.observe(t,{box:n}),n}catch{if("content-box"===n)return null;try{return e.observe(t,{box:"content-box"}),"content-box"}catch{return null}}}_onResize=e=>{for(const t of e)this._setEntry(this._normalizeEntry(t))};_normalizeEntry(e){const t=this._normalizeRect(e.contentRect),r=this._firstBoxSize(e.contentBoxSize),n=this._firstBoxSize(e.borderBoxSize),i=this._firstBoxSize(e.devicePixelContentBoxSize),{width:s,height:o}=this._headlineSize(r,n,i,t);return{width:s,height:o,contentRect:t,contentBoxSize:r,borderBoxSize:n,devicePixelContentBoxSize:i,target:e.target}}_headlineSize(e,t,r,n){const i=this._effectiveBox;let s,o,h;return s="border-box"===i?t:"device-pixel-content-box"===i?r:e,s?(o=s.inlineSize,h=s.blockSize):(o=n.width,h=n.height),this._options.round&&(o=Math.round(o),h=Math.round(h)),{width:o,height:h}}_firstBoxSize(e){if(!e||0===e.length)return null;const t=e[0];return{inlineSize:t.inlineSize,blockSize:t.blockSize}}_normalizeRect(e){return{x:e.x,y:e.y,width:e.width,height:e.height,top:e.top,right:e.right,bottom:e.bottom,left:e.left}}_optionsEqual(e,t){return(e.box??"content-box")===(t.box??"content-box")&&(e.round??!1)===(t.round??!1)}}const h=["content-box","border-box","device-pixel-content-box"];class c extends HTMLElement{static hasConnectedCallbackPromise=!1;static observedAttributes=["target","box","round"];static wcBindable={...o.wcBindable,properties:[...o.wcBindable.properties,{name:"trigger",event:"wcs-resize:trigger-changed"}],inputs:[{name:"target",attribute:"target"},{name:"box",attribute:"box"},{name:"round",attribute:"round"},{name:"once",attribute:"once"},{name:"manual",attribute:"manual"},{name:"trigger"}],commands:o.wcBindable.commands};_core;_trigger=!1;constructor(){super(),this._core=new o(this)}get target(){return this.getAttribute("target")??""}set target(e){this.setAttribute("target",e)}get box(){return this.getAttribute("box")??""}set box(e){this.setAttribute("box",e)}get round(){return this.hasAttribute("round")}set round(e){e?this.setAttribute("round",""):this.removeAttribute("round")}get once(){return this.hasAttribute("once")}set once(e){e?this.setAttribute("once",""):this.removeAttribute("once")}get manual(){return this.hasAttribute("manual")}set manual(e){e?this.setAttribute("manual",""):this.removeAttribute("manual")}get entry(){return this._core.entry}get width(){return this._core.width}get height(){return this._core.height}get observing(){return this._core.observing}get trigger(){return this._trigger}set trigger(e){if(!!e){this._trigger=!0;try{this.observe()}finally{this._trigger=!1,this.dispatchEvent(new CustomEvent("wcs-resize:trigger-changed",{detail:!1,bubbles:!0}))}}}observe(){const{element:e,display:t}=this._resolveTarget();this.style.display=t,e?this._core.observe(e,this._options()):this._core.disconnect()}unobserve(){this._core.disconnect()}disconnect(){this._core.disconnect()}_resolveTarget(){const e=this.target;if("self"===e)return{element:this,display:"block"};if(""!==e){const t=this.getRootNode();return{element:this._safeQuery(t,e),display:"none"}}const t=this.firstElementChild;return t?{element:t,display:"contents"}:{element:this,display:"block"}}_safeQuery(e,t){try{return e.querySelector(t)}catch{return null}}_parseBox(){const e=this.box.trim();return h.includes(e)?e:"content-box"}_options(){return{box:this._parseBox(),round:this.round}}_onChange=e=>{e.target===this&&this.once&&this._core.disconnect()};connectedCallback(){this.addEventListener("wcs-resize:change",this._onChange),this.manual||this.observe()}disconnectedCallback(){this.removeEventListener("wcs-resize:change",this._onChange),this._core.disconnect()}attributeChangedCallback(e,t,r){t!==r&&this.isConnected&&!this.manual&&this.observe()}}function a(t){var r;t&&((r=t).tagNames&&Object.assign(e.tagNames,r.tagNames),n=null),customElements.get(i.tagNames.resize)||customElements.define(i.tagNames.resize,c)}export{o as ResizeCore,c as WcsResize,a as bootstrapResize,s as getConfig};
1
+ const e={tagNames:{resize:"wcs-resize"}};function t(e){if(null===e||"object"!=typeof e)return e;Object.freeze(e);for(const r of Object.keys(e))t(e[r]);return e}function r(e){if(null===e||"object"!=typeof e)return e;const t={};for(const n of Object.keys(e))t[n]=r(e[n]);return t}let n=null;const s=e;function i(){return n||(n=t(r(e))),n}class o extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"entry",event:"wcs-resize:change"},{name:"width",event:"wcs-resize:change",getter:e=>e.detail.width},{name:"height",event:"wcs-resize:change",getter:e=>e.detail.height},{name:"observing",event:"wcs-resize:observing-changed"}],commands:[{name:"observe"},{name:"unobserve"},{name:"disconnect"}]};_target;_observer=null;_observed=null;_options={};_effectiveBox="content-box";_entry=null;_observing=!1;_ready=Promise.resolve();constructor(e){super(),this._target=e??this}get ready(){return this._ready}observe(e,t={}){return e&&this._observeElement(e,t),this._ready}dispose(){this.disconnect()}get entry(){return this._entry}get width(){return this._entry?this._entry.width:0}get height(){return this._entry?this._entry.height:0}get observing(){return this._observing}_setEntry(e){this._entry=e,this._target.dispatchEvent(new CustomEvent("wcs-resize:change",{detail:e,bubbles:!0}))}_setObserving(e){this._observing!==e&&(this._observing=e,this._target.dispatchEvent(new CustomEvent("wcs-resize:observing-changed",{detail:e,bubbles:!0})))}_observeElement(e,t={}){if(this._observer&&this._observed===e&&this._optionsEqual(this._options,t))return;this._teardownObserver();const r=this._createObserver();if(!r)return void this._setObserving(!1);const n=this._beginObserve(r,e,t.box);if(null===n)return r.disconnect(),void this._setObserving(!1);this._observer=r,this._observed=e,this._options={box:t.box,round:t.round},this._effectiveBox=n,this._setObserving(!0)}unobserve(e){this._observed===e&&(this._teardownObserver(),this._setObserving(!1))}disconnect(){this._teardownObserver(),this._setObserving(!1)}_teardownObserver(){this._observer&&(this._observer.disconnect(),this._observer=null),this._observed=null}_createObserver(){return"undefined"==typeof ResizeObserver?null:new ResizeObserver(this._onResize)}_beginObserve(e,t,r){const n=r??"content-box";try{return e.observe(t,{box:n}),n}catch{if("content-box"===n)return null;try{return e.observe(t,{box:"content-box"}),"content-box"}catch{return null}}}_onResize=e=>{for(const t of e)this._setEntry(this._normalizeEntry(t))};_normalizeEntry(e){const t=this._normalizeRect(e.contentRect),r=this._firstBoxSize(e.contentBoxSize),n=this._firstBoxSize(e.borderBoxSize),s=this._firstBoxSize(e.devicePixelContentBoxSize),{width:i,height:o}=this._headlineSize(r,n,s,t);return{width:i,height:o,contentRect:t,contentBoxSize:r,borderBoxSize:n,devicePixelContentBoxSize:s,target:e.target}}_headlineSize(e,t,r,n){const s=this._effectiveBox;let i,o,c;return i="border-box"===s?t:"device-pixel-content-box"===s?r:e,i?(o=i.inlineSize,c=i.blockSize):(o=n.width,c=n.height),this._options.round&&(o=Math.round(o),c=Math.round(c)),{width:o,height:c}}_firstBoxSize(e){if(!e||0===e.length)return null;const t=e[0];return{inlineSize:t.inlineSize,blockSize:t.blockSize}}_normalizeRect(e){return{x:e.x,y:e.y,width:e.width,height:e.height,top:e.top,right:e.right,bottom:e.bottom,left:e.left}}_optionsEqual(e,t){return(e.box??"content-box")===(t.box??"content-box")&&(e.round??!1)===(t.round??!1)}}const c=["content-box","border-box","device-pixel-content-box"];class h extends HTMLElement{static hasConnectedCallbackPromise=!0;static observedAttributes=["target","box","round"];static wcBindable={...o.wcBindable,properties:[...o.wcBindable.properties,{name:"trigger",event:"wcs-resize:trigger-changed"}],inputs:[{name:"target",attribute:"target"},{name:"box",attribute:"box"},{name:"round",attribute:"round"},{name:"once",attribute:"once"},{name:"manual",attribute:"manual"},{name:"trigger"}],commands:o.wcBindable.commands};_core;_trigger=!1;_connectedCallbackPromise=Promise.resolve();constructor(){super(),this._core=new o(this)}get connectedCallbackPromise(){return this._connectedCallbackPromise}get target(){return this.getAttribute("target")??""}set target(e){this.setAttribute("target",e)}get box(){return this.getAttribute("box")??""}set box(e){this.setAttribute("box",e)}get round(){return this.hasAttribute("round")}set round(e){e?this.setAttribute("round",""):this.removeAttribute("round")}get once(){return this.hasAttribute("once")}set once(e){e?this.setAttribute("once",""):this.removeAttribute("once")}get manual(){return this.hasAttribute("manual")}set manual(e){e?this.setAttribute("manual",""):this.removeAttribute("manual")}get entry(){return this._core.entry}get width(){return this._core.width}get height(){return this._core.height}get observing(){return this._core.observing}get trigger(){return this._trigger}set trigger(e){if(!!e){this._trigger=!0;try{this.observe()}finally{this._trigger=!1,this.dispatchEvent(new CustomEvent("wcs-resize:trigger-changed",{detail:!1,bubbles:!0}))}}}observe(){const{element:e,display:t}=this._resolveTarget();this.style.display=t,e?this._core.observe(e,this._options()):this._core.disconnect()}unobserve(){this._core.disconnect()}disconnect(){this._core.disconnect()}_resolveTarget(){const e=this.target;if("self"===e)return{element:this,display:"block"};if(""!==e){const t=this.getRootNode();return{element:this._safeQuery(t,e),display:"none"}}const t=this.firstElementChild;return t?{element:t,display:"contents"}:{element:this,display:"block"}}_safeQuery(e,t){try{return e.querySelector(t)}catch{return null}}_parseBox(){const e=this.box.trim();return c.includes(e)?e:"content-box"}_options(){return{box:this._parseBox(),round:this.round}}_onChange=e=>{e.target===this&&this.once&&this._core.disconnect()};connectedCallback(){this.addEventListener("wcs-resize:change",this._onChange),this.manual||this.observe(),this._connectedCallbackPromise=this._core.observe()}disconnectedCallback(){this.removeEventListener("wcs-resize:change",this._onChange),this._core.dispose()}attributeChangedCallback(e,t,r){t!==r&&this.isConnected&&!this.manual&&this.observe()}}function a(t){var r;t&&((r=t).tagNames&&Object.assign(e.tagNames,r.tagNames),n=null),customElements.get(s.tagNames.resize)||customElements.define(s.tagNames.resize,h)}export{o as ResizeCore,h as WcsResize,a as bootstrapResize,i as getConfig};
2
2
  //# sourceMappingURL=index.esm.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/core/ResizeCore.ts","../src/components/Resize.ts","../src/bootstrapResize.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n resize: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n resize: \"wcs-resize\",\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\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import { IWcBindable, ResizeOptions, ResizeBoxOption, WcsResizeEntry, WcsResizeRect, WcsResizeBoxSize } from \"../types.js\";\n\n/**\n * Headless element-size primitive. A thin, framework-agnostic wrapper around the\n * ResizeObserver API exposed through the wc-bindable protocol.\n *\n * Like IntersectionCore, the thing being observed is a *DOM element* — so\n * `observe()` takes the target node. The Core stays DOM-resolution-agnostic: it\n * observes whatever element it is handed (the Shell resolves the `target` selector\n * before calling). It is a read-only producer — element/layout → state only.\n *\n * Every observer callback is published via the single `wcs-resize:change` event;\n * `width` / `height` are read from it through getters (mirroring how\n * IntersectionCore derives `intersecting` / `ratio` from one event), so an observer\n * binding any of them is notified on every change.\n *\n * `width` / `height` follow the observed `box` (border-box / device-pixel /\n * content-box) and are rounded to integers when `round` is set — `round` absorbs\n * the sub-pixel jitter that would otherwise let a size→layout→size loop oscillate.\n *\n * Single-target by design: the Shell observes exactly one element, so the state\n * reflects that element. Multi-target observation is intentionally out of scope.\n */\nexport class ResizeCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"entry\", event: \"wcs-resize:change\" },\n { name: \"width\", event: \"wcs-resize:change\", getter: (e: Event) => (e as CustomEvent).detail.width },\n { name: \"height\", event: \"wcs-resize:change\", getter: (e: Event) => (e as CustomEvent).detail.height },\n { name: \"observing\", event: \"wcs-resize:observing-changed\" },\n ],\n commands: [\n { name: \"observe\" },\n { name: \"unobserve\" },\n { name: \"disconnect\" },\n ],\n };\n\n private _target: EventTarget;\n\n // The live observer and the single element it observes. The *requested* options\n // are kept so a repeated observe() with identical options is a no-op (avoids the\n // create→observe→disconnect churn an autoloader upgrade can otherwise cause). It\n // is the requested box — not the effective one — so a re-observe of an unsupported\n // box (which falls back to content-box) still hits the idempotency guard instead\n // of rebuilding+falling-back every time. `_effectiveBox` separately tracks the box\n // actually in effect, which is what normalization reads.\n private _observer: ResizeObserver | null = null;\n private _observed: Element | null = null;\n private _options: ResizeOptions = {};\n private _effectiveBox: ResizeBoxOption = \"content-box\";\n\n private _entry: WcsResizeEntry | null = null;\n private _observing: boolean = false;\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get entry(): WcsResizeEntry | null {\n return this._entry;\n }\n\n get width(): number {\n return this._entry ? this._entry.width : 0;\n }\n\n get height(): number {\n return this._entry ? this._entry.height : 0;\n }\n\n get observing(): boolean {\n return this._observing;\n }\n\n // --- State setters with event dispatch ---\n\n private _setEntry(entry: WcsResizeEntry): void {\n // No same-value guard: `change` carries event semantics (every callback is a\n // distinct observation) and `width` / `height` are derived getters that must\n // re-fire on each entry, mirroring IntersectionCore's `change`.\n this._entry = entry;\n this._target.dispatchEvent(new CustomEvent(\"wcs-resize:change\", {\n detail: entry,\n bubbles: true,\n }));\n }\n\n private _setObserving(observing: boolean): void {\n if (this._observing === observing) return;\n this._observing = observing;\n this._target.dispatchEvent(new CustomEvent(\"wcs-resize:observing-changed\", {\n detail: observing,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing `element`. Idempotent while already observing the same element\n * with the same options. Changing the element or options tears down the current\n * observer and builds a new one (re-observing also re-delivers the initial size,\n * which is how a `round` toggle re-fires with the new rounding).\n *\n * If ResizeObserver is unavailable (SSR) this is a silent no-op — `observing`\n * stays false. If the requested `box` is unsupported, it retries once with\n * `content-box` before giving up; both giving-up paths leave `observing` false,\n * consistent with the never-throw design of the other @wcstack sensors.\n */\n observe(element: Element, options: ResizeOptions = {}): void {\n if (this._observer && this._observed === element && this._optionsEqual(this._options, options)) {\n return;\n }\n this._teardownObserver();\n const observer = this._createObserver();\n if (!observer) {\n // Unsupported environment (no ResizeObserver). If we were already observing,\n // that observation is now gone — reflect it rather than reporting a stale true.\n this._setObserving(false);\n return;\n }\n const effectiveBox = this._beginObserve(observer, element, options.box);\n if (effectiveBox === null) {\n // observe() threw even after the content-box fallback — no live observation.\n observer.disconnect();\n this._setObserving(false);\n return;\n }\n this._observer = observer;\n this._observed = element;\n // Store the *requested* options (raw) for the idempotency guard; `_effectiveBox`\n // holds the box that actually took effect (content-box after a fallback) for\n // normalization to read.\n this._options = { box: options.box, round: options.round };\n this._effectiveBox = effectiveBox;\n this._setObserving(true);\n }\n\n /**\n * Stop observing `element`. A no-op if it is not the currently observed element.\n * The observer instance is torn down (single-target Core), so a later observe()\n * rebuilds it.\n */\n unobserve(element: Element): void {\n if (this._observed !== element) return;\n this._teardownObserver();\n this._setObserving(false);\n }\n\n /** Stop all observation and release the observer. */\n disconnect(): void {\n this._teardownObserver();\n this._setObserving(false);\n }\n\n // --- Internal ---\n\n private _teardownObserver(): void {\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n this._observed = null;\n }\n\n private _createObserver(): ResizeObserver | null {\n // No constructor try/catch: unlike IntersectionObserver (which validates\n // rootMargin at construction), the ResizeObserver constructor takes only a\n // callback and has no throwing precondition. The throw path is on observe()\n // (an unsupported `box`), handled in _beginObserve.\n if (typeof ResizeObserver === \"undefined\") return null;\n return new ResizeObserver(this._onResize);\n }\n\n /**\n * Start observing with the requested `box`, retrying once with `content-box` if\n * the runtime rejects the box (e.g. `device-pixel-content-box` on engines that do\n * not support it). Returns the box actually in effect, or `null` if observation\n * could not start at all.\n */\n private _beginObserve(observer: ResizeObserver, element: Element, box?: ResizeBoxOption): ResizeBoxOption | null {\n const requested = box ?? \"content-box\";\n try {\n observer.observe(element, { box: requested });\n return requested;\n } catch {\n // Already content-box and it still threw — nothing safer to fall back to.\n if (requested === \"content-box\") return null;\n try {\n observer.observe(element, { box: \"content-box\" });\n return \"content-box\";\n } catch {\n return null;\n }\n }\n }\n\n private _onResize = (entries: ResizeObserverEntry[]): void => {\n for (const entry of entries) {\n this._setEntry(this._normalizeEntry(entry));\n }\n };\n\n private _normalizeEntry(entry: ResizeObserverEntry): WcsResizeEntry {\n const contentRect = this._normalizeRect(entry.contentRect);\n const contentBoxSize = this._firstBoxSize(entry.contentBoxSize);\n const borderBoxSize = this._firstBoxSize(entry.borderBoxSize);\n // devicePixelContentBoxSize is Chromium-only; absent on other engines.\n const devicePixelContentBoxSize = this._firstBoxSize((entry as { devicePixelContentBoxSize?: ReadonlyArray<ResizeObserverSize> }).devicePixelContentBoxSize);\n const { width, height } = this._headlineSize(contentBoxSize, borderBoxSize, devicePixelContentBoxSize, contentRect);\n return {\n width,\n height,\n contentRect,\n contentBoxSize,\n borderBoxSize,\n devicePixelContentBoxSize,\n target: entry.target,\n };\n }\n\n /**\n * Pick the headline width/height from the boxSize matching the observed `box`,\n * falling back to `contentRect` when that fragment is absent (older engines only\n * fill contentRect). `inlineSize`/`blockSize` map to width/height (correct for\n * horizontal writing modes). Rounds to integers when `round` is set.\n */\n private _headlineSize(\n contentBoxSize: WcsResizeBoxSize | null,\n borderBoxSize: WcsResizeBoxSize | null,\n devicePixelContentBoxSize: WcsResizeBoxSize | null,\n contentRect: WcsResizeRect,\n ): { width: number; height: number } {\n const box = this._effectiveBox;\n let size: WcsResizeBoxSize | null;\n if (box === \"border-box\") {\n size = borderBoxSize;\n } else if (box === \"device-pixel-content-box\") {\n size = devicePixelContentBoxSize;\n } else {\n size = contentBoxSize;\n }\n let width: number;\n let height: number;\n if (size) {\n width = size.inlineSize;\n height = size.blockSize;\n } else {\n width = contentRect.width;\n height = contentRect.height;\n }\n if (this._options.round) {\n width = Math.round(width);\n height = Math.round(height);\n }\n return { width, height };\n }\n\n private _firstBoxSize(list: ReadonlyArray<ResizeObserverSize> | undefined): WcsResizeBoxSize | null {\n if (!list || list.length === 0) return null;\n const first = list[0];\n return { inlineSize: first.inlineSize, blockSize: first.blockSize };\n }\n\n private _normalizeRect(rect: DOMRectReadOnly): WcsResizeRect {\n return {\n x: rect.x,\n y: rect.y,\n width: rect.width,\n height: rect.height,\n top: rect.top,\n right: rect.right,\n bottom: rect.bottom,\n left: rect.left,\n };\n }\n\n private _optionsEqual(a: ResizeOptions, b: ResizeOptions): boolean {\n if ((a.box ?? \"content-box\") !== (b.box ?? \"content-box\")) return false;\n return (a.round ?? false) === (b.round ?? false);\n }\n}\n","import { IWcBindable, ResizeOptions, ResizeBoxOption, WcsResizeEntry } from \"../types.js\";\nimport { ResizeCore } from \"../core/ResizeCore.js\";\n\nconst BOX_VALUES: ReadonlyArray<ResizeBoxOption> = [\"content-box\", \"border-box\", \"device-pixel-content-box\"];\n\n/**\n * `<wcs-resize>` — declarative ResizeObserver.\n *\n * The `target` attribute is the single knob that decides both *what* is observed\n * and how the element renders (it never injects a layout box unless asked):\n *\n * | `target` | observes | display | use case |\n * |-----------------|-----------------------|-------------|----------------------|\n * | omitted | first element child | `contents` | size a wrapped child |\n * | `\"#panel\"` / sel| the matched element | `none` | size an existing node|\n * | `\"self\"` | the element itself | `block` | container-width probe|\n *\n * `display:contents` means wrapping a child injects no box of its own (so a\n * `<wcs-resize><div></wcs-resize>` does not disturb a flex/grid parent); the\n * `target=\"self\"` form takes a `display:block` box that, as a zero-height element,\n * stretches to the parent's available inline size — a container-width probe.\n *\n * Note: a `display:contents` / `display:none` element generates no box, so the\n * observed node must be the child / selector target (which do have boxes), never\n * the `<wcs-resize>` host itself except in the `self` form.\n */\nexport class WcsResize extends HTMLElement {\n static hasConnectedCallbackPromise = false;\n // Only attributes that change *what or how* we observe trigger a re-observe.\n // `once` is intentionally excluded: it is evaluated at change fire time (in\n // `_onChange`), so toggling it takes effect without re-observing — and a\n // re-observe on its change would be a pure no-op (same target, same options).\n // `manual` is also excluded: it is a connect-time policy (\"don't auto-observe on\n // connect\"), not a live switch that should start/stop an active observation.\n // `box` and `round` ARE observed: changing them rebuilds the observer, and the\n // rebuild re-delivers the initial size — which is exactly how a `round` toggle\n // re-emits width/height with the new rounding.\n static observedAttributes = [\"target\", \"box\", \"round\"];\n\n static wcBindable: IWcBindable = {\n ...ResizeCore.wcBindable,\n properties: [\n ...ResizeCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-resize:trigger-changed\" },\n ],\n // Shell-level settable surface. Each input carries its mirrored `attribute`\n // hint; `trigger` has none — it is a momentary command-property, not a\n // declarative attribute. The observe / unobserve / disconnect commands are\n // inherited from the Core via the spread above.\n inputs: [\n { name: \"target\", attribute: \"target\" },\n { name: \"box\", attribute: \"box\" },\n { name: \"round\", attribute: \"round\" },\n { name: \"once\", attribute: \"once\" },\n { name: \"manual\", attribute: \"manual\" },\n { name: \"trigger\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。<wcs-intersect>/<wcs-sse> と同型。\n // spread でも継承されるが、Core に command 追加時の追従漏れを防ぐため明示参照する。\n commands: ResizeCore.wcBindable.commands,\n };\n\n private _core: ResizeCore;\n private _trigger: boolean = false;\n\n constructor() {\n super();\n this._core = new ResizeCore(this);\n }\n\n // --- Attribute accessors ---\n\n get target(): string {\n return this.getAttribute(\"target\") ?? \"\";\n }\n\n set target(value: string) {\n this.setAttribute(\"target\", value);\n }\n\n get box(): string {\n return this.getAttribute(\"box\") ?? \"\";\n }\n\n set box(value: string) {\n this.setAttribute(\"box\", value);\n }\n\n get round(): boolean {\n return this.hasAttribute(\"round\");\n }\n\n set round(value: boolean) {\n if (value) {\n this.setAttribute(\"round\", \"\");\n } else {\n this.removeAttribute(\"round\");\n }\n }\n\n get once(): boolean {\n return this.hasAttribute(\"once\");\n }\n\n set once(value: boolean) {\n if (value) {\n this.setAttribute(\"once\", \"\");\n } else {\n this.removeAttribute(\"once\");\n }\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean) {\n if (value) {\n this.setAttribute(\"manual\", \"\");\n } else {\n this.removeAttribute(\"manual\");\n }\n }\n\n // --- Core delegated getters ---\n\n get entry(): WcsResizeEntry | null {\n return this._core.entry;\n }\n\n get width(): number {\n return this._core.width;\n }\n\n get height(): number {\n return this._core.height;\n }\n\n get observing(): boolean {\n return this._core.observing;\n }\n\n // --- Command property ---\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n // Momentary command-property: a false→true write re-runs observe(). Mirrors the\n // trigger flag on <wcs-intersect> / <wcs-geo>. Prefer the command-token protocol\n // (`command.observe: $command.start`) for state-driven observation; this exists\n // mainly for simple boolean bindings.\n const v = !!value; // normalize truthy state-bindings, like <wcs-intersect>'s setter\n if (v) {\n this._trigger = true;\n // try/finally mirrors <wcs-intersect>'s set trigger: observe() is never-throw\n // today, but should a synchronous throw path ever appear, the finally still\n // auto-resets _trigger (no stuck-true latch) and emits the completion notice.\n try {\n this.observe();\n } finally {\n this._trigger = false;\n // Always auto-reset to false after the observe() attempt — this is the\n // *momentary acknowledgement* that the trigger was consumed, NOT a signal\n // that observation succeeded (whether the target resolved is reflected by\n // `observing`, not by this event). Read `observing` if you need the outcome.\n this.dispatchEvent(new CustomEvent(\"wcs-resize:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n }\n }\n }\n\n // --- Commands ---\n\n /** Re-resolve the target from the DOM and (re)start observing. */\n observe(): void {\n const { element, display } = this._resolveTarget();\n // `display` is derived from the `target` *mode* (self/selector/child), not from\n // whether the selector currently matches — so it is applied unconditionally,\n // before the resolution check. A `target=\"#x\"` whose node is momentarily absent\n // still renders `display:none` (it is a selector pointer, never a box).\n this.style.display = display;\n if (!element) {\n // The target is no longer resolvable (e.g. a `target` selector whose node was\n // removed from the DOM). Tear down any stale observation so `observing` does\n // not keep reporting true against a node that is gone.\n this._core.disconnect();\n return;\n }\n this._core.observe(element, this._options());\n }\n\n unobserve(): void {\n // Single-target Shell: \"stop observing my target\" is exactly the Core's\n // teardown. Delegate to the Core's tracked state rather than re-resolving the\n // selector, so a target that has since left the DOM can still be stopped\n // (re-resolving would yield null and silently leave the observer running).\n this._core.disconnect();\n }\n\n disconnect(): void {\n this._core.disconnect();\n }\n\n // --- Internal ---\n\n private _resolveTarget(): { element: Element | null; display: string } {\n const target = this.target;\n if (target === \"self\") {\n // Explicit sentinel: observe the element itself. As a display:block zero-height\n // box it stretches to the parent's available inline size — a container probe.\n return { element: this, display: \"block\" };\n }\n if (target !== \"\") {\n // Selector pointer: observe a referenced element in place, staying invisible.\n const scope = this.getRootNode() as Document | ShadowRoot;\n // A user-authored selector can be syntactically invalid (e.g. `#`, `:::`,\n // `[data-*`), which makes querySelector throw a SyntaxError. Swallow it and\n // treat the target as unresolvable — the same \"nothing to observe\" path as a\n // selector matching no element — so a bad attribute never lets the throw escape\n // observe() → connectedCallback / attributeChangedCallback (never-throw).\n return { element: this._safeQuery(scope, target), display: \"none\" };\n }\n // Omitted: observe the first element child without injecting a box of our own.\n const child = this.firstElementChild;\n if (child) {\n return { element: child, display: \"contents\" };\n }\n // No child to wrap (e.g. used as an empty marker) — fall back to self.\n return { element: this, display: \"block\" };\n }\n\n // Wrap querySelector so a syntactically invalid user-authored selector resolves to\n // null (unresolvable) instead of letting the SyntaxError escape — keeping the\n // sensor never-throw, mirroring intersection's _safeQuery guard.\n private _safeQuery(scope: Document | ShadowRoot, selector: string): Element | null {\n try {\n return scope.querySelector(selector);\n } catch {\n return null;\n }\n }\n\n private _parseBox(): ResizeBoxOption {\n const raw = this.box.trim();\n // Decision: an unrecognized box value falls back to content-box at parse time\n // (rather than letting the Core's observe() reject it), mirroring threshold's\n // range filter in <wcs-intersect>. The Core still has its own runtime fallback\n // for a *valid-but-unsupported* box (e.g. device-pixel-content-box on Safari).\n return (BOX_VALUES as ReadonlyArray<string>).includes(raw) ? (raw as ResizeBoxOption) : \"content-box\";\n }\n\n private _options(): ResizeOptions {\n return {\n box: this._parseBox(),\n round: this.round,\n };\n }\n\n private _onChange = (event: Event): void => {\n // `wcs-resize:change` bubbles, so a nested `<wcs-resize>` descendant's change\n // would otherwise reach this (ancestor) listener and let a *child's* resize tear\n // down *our* observer. Only act on our own Core's event. (This also avoids\n // reading `.detail` off a foreign event shape.)\n if (event.target !== this) return;\n // `once`: tear down after the first size observation. ResizeObserver always\n // delivers the initial size on observe(), so once = measure-once. Gated at fire\n // time so toggling the `once` attribute takes effect live.\n if (this.once) {\n this._core.disconnect();\n }\n };\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.addEventListener(\"wcs-resize:change\", this._onChange);\n if (!this.manual) {\n this.observe();\n }\n }\n\n disconnectedCallback(): void {\n this.removeEventListener(\"wcs-resize:change\", this._onChange);\n this._core.disconnect();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n // Defensive same-value guard. Per the HTML spec, an attribute change reaction is\n // enqueued whenever setAttribute() runs — including with an unchanged value — so\n // attributeChangedCallback CAN fire on a same-value write. Re-observing on an\n // unchanged attribute would be a wasted observer rebuild, so bail early when the\n // value did not actually change. Kept intentionally; do not remove.\n if (oldValue === newValue) return;\n // Only react once connected and in automatic mode. The Core's idempotency guard\n // absorbs the autoloader upgrade case (attributeChangedCallback +\n // connectedCallback both calling observe() with identical options).\n if (!this.isConnected || this.manual) return;\n this.observe();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapResize(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { WcsResize } from \"./components/Resize.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.resize)) {\n customElements.define(config.tagNames.resize, WcsResize);\n }\n}\n"],"names":["_config","tagNames","resize","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","ResizeCore","EventTarget","static","protocol","version","properties","name","event","getter","e","detail","width","height","commands","_target","_observer","_observed","_options","_effectiveBox","_entry","_observing","constructor","target","super","this","entry","observing","_setEntry","dispatchEvent","CustomEvent","bubbles","_setObserving","observe","element","options","_optionsEqual","_teardownObserver","observer","_createObserver","effectiveBox","_beginObserve","box","disconnect","round","unobserve","ResizeObserver","_onResize","requested","entries","_normalizeEntry","contentRect","_normalizeRect","contentBoxSize","_firstBoxSize","borderBoxSize","devicePixelContentBoxSize","_headlineSize","size","inlineSize","blockSize","Math","list","length","first","rect","x","y","top","right","bottom","left","a","b","BOX_VALUES","WcsResize","HTMLElement","wcBindable","inputs","attribute","_core","_trigger","getAttribute","value","setAttribute","hasAttribute","removeAttribute","once","manual","trigger","display","_resolveTarget","style","scope","getRootNode","_safeQuery","child","firstElementChild","selector","querySelector","_parseBox","raw","trim","includes","_onChange","connectedCallback","addEventListener","disconnectedCallback","removeEventListener","attributeChangedCallback","_name","oldValue","newValue","isConnected","bootstrapResize","userConfig","partialConfig","assign","customElements","get","define"],"mappings":"AAQA,MAAMA,EAA2B,CAC/BC,SAAU,CACRC,OAAQ,eAIZ,SAASC,EAAcC,GACrB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpDC,OAAOC,OAAOF,GACd,IAAK,MAAMG,KAAOF,OAAOG,KAAKJ,GAC5BD,EAAYC,EAAgCG,IAE9C,OAAOH,CACT,CAEA,SAASK,EAAaL,GACpB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpD,MAAMM,EAAiC,CAAA,EACvC,IAAK,MAAMH,KAAOF,OAAOG,KAAKJ,GAC5BM,EAAMH,GAAOE,EAAWL,EAAgCG,IAE1D,OAAOG,CACT,CAEA,IAAIC,EAA+B,KAE5B,MAAMC,EAAkBZ,WAEfa,IAId,OAHKF,IACHA,EAAeR,EAAWM,EAAUT,KAE/BW,CACT,CClBM,MAAOG,UAAmBC,YAC9BC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,QAASC,MAAO,qBACxB,CAAED,KAAM,QAASC,MAAO,oBAAqBC,OAASC,GAAcA,EAAkBC,OAAOC,OAC7F,CAAEL,KAAM,SAAUC,MAAO,oBAAqBC,OAASC,GAAcA,EAAkBC,OAAOE,QAC9F,CAAEN,KAAM,YAAaC,MAAO,iCAE9BM,SAAU,CACR,CAAEP,KAAM,WACR,CAAEA,KAAM,aACR,CAAEA,KAAM,gBAIJQ,QASAC,UAAmC,KACnCC,UAA4B,KAC5BC,SAA0B,CAAA,EAC1BC,cAAiC,cAEjCC,OAAgC,KAChCC,YAAsB,EAE9B,WAAAC,CAAYC,GACVC,QACAC,KAAKV,QAAUQ,GAAUE,IAC3B,CAEA,SAAIC,GACF,OAAOD,KAAKL,MACd,CAEA,SAAIR,GACF,OAAOa,KAAKL,OAASK,KAAKL,OAAOR,MAAQ,C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A,MAAMM,EAAQvE,KAAKwE,kBACnB,OAAID,EACK,CAAE9D,QAAS8D,EAAON,QAAS,YAG7B,CAAExD,QAAST,KAAMiE,QAAS,QACnC,CAKQ,UAAAK,CAAWF,EAA8BK,GAC/C,IACE,OAAOL,EAAMM,cAAcD,EAC7B,CAAE,MACA,OAAO,IACT,CACF,CAEQ,SAAAE,GACN,MAAMC,EAAM5E,KAAKiB,IAAI4D,OAKrB,OAAQ5B,EAAqC6B,SAASF,GAAQA,EAA0B,aAC1F,CAEQ,QAAAnF,GACN,MAAO,CACLwB,IAAKjB,KAAK2E,YACVxD,MAAOnB,KAAKmB,MAEhB,CAEQ4D,UAAahG,IAKfA,EAAMe,SAAWE,MAIjBA,KAAK8D,MACP9D,KAAKuD,MAAMrC,cAMf,iBAAA8D,GACEhF,KAAKiF,iBAAiB,oBAAqBjF,KAAK+E,WAC3C/E,KAAK+D,QACR/D,KAAKQ,SAET,CAEA,oBAAA0E,GACElF,KAAKmF,oBAAoB,oBAAqBnF,KAAK+E,WACnD/E,KAAKuD,MAAMrC,YACb,CAEA,wBAAAkE,CAAyBC,EAAeC,EAAyBC,GAM3DD,IAAaC,GAIZvF,KAAKwF,cAAexF,KAAK+D,QAC9B/D,KAAKQ,SACP,EC1SI,SAAUiF,EAAgBC,GHuC1B,IAAoBC,EGtCpBD,KHsCoBC,EGrCZD,GHsCM/H,UAChBI,OAAO6H,OAAOlI,EAAQC,SAAUgI,EAAchI,UAEhDU,EAAe,MI3CVwH,eAAeC,IAAIxH,EAAOX,SAASC,SACtCiI,eAAeE,OAAOzH,EAAOX,SAASC,OAAQsF,EDIlD"}
1
+ {"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/core/ResizeCore.ts","../src/components/Resize.ts","../src/bootstrapResize.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n resize: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n resize: \"wcs-resize\",\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\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import { IWcBindable, ResizeOptions, ResizeBoxOption, WcsResizeEntry, WcsResizeRect, WcsResizeBoxSize } from \"../types.js\";\n\n/**\n * Headless element-size primitive. A thin, framework-agnostic wrapper around the\n * ResizeObserver API exposed through the wc-bindable protocol.\n *\n * Like IntersectionCore, the thing being observed is a *DOM element* — so\n * `observe()` takes the target node. The Core stays DOM-resolution-agnostic: it\n * observes whatever element it is handed (the Shell resolves the `target` selector\n * before calling). It is a read-only producer — element/layout → state only.\n *\n * Every observer callback is published via the single `wcs-resize:change` event;\n * `width` / `height` are read from it through getters (mirroring how\n * IntersectionCore derives `intersecting` / `ratio` from one event), so an observer\n * binding any of them is notified on every change.\n *\n * `width` / `height` follow the observed `box` (border-box / device-pixel /\n * content-box) and are rounded to integers when `round` is set — `round` absorbs\n * the sub-pixel jitter that would otherwise let a size→layout→size loop oscillate.\n *\n * Single-target by design: the Shell observes exactly one element, so the state\n * reflects that element. Multi-target observation is intentionally out of scope.\n */\nexport class ResizeCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"entry\", event: \"wcs-resize:change\" },\n { name: \"width\", event: \"wcs-resize:change\", getter: (e: Event) => (e as CustomEvent).detail.width },\n { name: \"height\", event: \"wcs-resize:change\", getter: (e: Event) => (e as CustomEvent).detail.height },\n { name: \"observing\", event: \"wcs-resize:observing-changed\" },\n ],\n commands: [\n { name: \"observe\" },\n { name: \"unobserve\" },\n { name: \"disconnect\" },\n ],\n };\n\n private _target: EventTarget;\n\n // The live observer and the single element it observes. The *requested* options\n // are kept so a repeated observe() with identical options is a no-op (avoids the\n // create→observe→disconnect churn an autoloader upgrade can otherwise cause). It\n // is the requested box — not the effective one — so a re-observe of an unsupported\n // box (which falls back to content-box) still hits the idempotency guard instead\n // of rebuilding+falling-back every time. `_effectiveBox` separately tracks the box\n // actually in effect, which is what normalization reads.\n private _observer: ResizeObserver | null = null;\n private _observed: Element | null = null;\n private _options: ResizeOptions = {};\n private _effectiveBox: ResizeBoxOption = \"content-box\";\n\n private _entry: WcsResizeEntry | null = null;\n private _observing: boolean = false;\n\n // SSR: ResizeObserver delivers the initial size synchronously, so there is no\n // asynchronous probe to await — readiness is immediate. Kept as a field so the\n // Shell can expose it as connectedCallbackPromise uniformly with the other nodes.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n /** Resolves once the first probe settles. Synchronous here, so already resolved. */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n /**\n * Lifecycle entry point (§3.5). When called with no element it is an idempotent\n * no-op that resolves once ready — resize is command-driven (the Shell resolves\n * the target and calls observe(element)), so connect-time monitoring is started\n * via that command, not here. The Shell backs `connectedCallbackPromise` with\n * this no-arg form. When called with an element it delegates to the element\n * observe command below and still returns `ready` for a uniform return shape.\n */\n observe(): Promise<void>;\n observe(element: Element, options?: ResizeOptions): Promise<void>;\n observe(element?: Element, options: ResizeOptions = {}): Promise<void> {\n if (element) {\n this._observeElement(element, options);\n }\n return this._ready;\n }\n\n /**\n * Tear down the observer and invalidate the lifecycle (§3.5). Mirrors disconnect()\n * but is the lifecycle-named counterpart the Shell calls from disconnectedCallback;\n * a later observe() rebuilds the observer.\n */\n dispose(): void {\n this.disconnect();\n }\n\n get entry(): WcsResizeEntry | null {\n return this._entry;\n }\n\n get width(): number {\n return this._entry ? this._entry.width : 0;\n }\n\n get height(): number {\n return this._entry ? this._entry.height : 0;\n }\n\n get observing(): boolean {\n return this._observing;\n }\n\n // --- State setters with event dispatch ---\n\n private _setEntry(entry: WcsResizeEntry): void {\n // No same-value guard: `change` carries event semantics (every callback is a\n // distinct observation) and `width` / `height` are derived getters that must\n // re-fire on each entry, mirroring IntersectionCore's `change`.\n this._entry = entry;\n this._target.dispatchEvent(new CustomEvent(\"wcs-resize:change\", {\n detail: entry,\n bubbles: true,\n }));\n }\n\n private _setObserving(observing: boolean): void {\n if (this._observing === observing) return;\n this._observing = observing;\n this._target.dispatchEvent(new CustomEvent(\"wcs-resize:observing-changed\", {\n detail: observing,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing `element`. Idempotent while already observing the same element\n * with the same options. Changing the element or options tears down the current\n * observer and builds a new one (re-observing also re-delivers the initial size,\n * which is how a `round` toggle re-fires with the new rounding).\n *\n * If ResizeObserver is unavailable (SSR) this is a silent no-op — `observing`\n * stays false. If the requested `box` is unsupported, it retries once with\n * `content-box` before giving up; both giving-up paths leave `observing` false,\n * consistent with the never-throw design of the other @wcstack sensors.\n */\n private _observeElement(element: Element, options: ResizeOptions = {}): void {\n if (this._observer && this._observed === element && this._optionsEqual(this._options, options)) {\n return;\n }\n this._teardownObserver();\n const observer = this._createObserver();\n if (!observer) {\n // Unsupported environment (no ResizeObserver). If we were already observing,\n // that observation is now gone — reflect it rather than reporting a stale true.\n this._setObserving(false);\n return;\n }\n const effectiveBox = this._beginObserve(observer, element, options.box);\n if (effectiveBox === null) {\n // observe() threw even after the content-box fallback — no live observation.\n observer.disconnect();\n this._setObserving(false);\n return;\n }\n this._observer = observer;\n this._observed = element;\n // Store the *requested* options (raw) for the idempotency guard; `_effectiveBox`\n // holds the box that actually took effect (content-box after a fallback) for\n // normalization to read.\n this._options = { box: options.box, round: options.round };\n this._effectiveBox = effectiveBox;\n this._setObserving(true);\n }\n\n /**\n * Stop observing `element`. A no-op if it is not the currently observed element.\n * The observer instance is torn down (single-target Core), so a later observe()\n * rebuilds it.\n */\n unobserve(element: Element): void {\n if (this._observed !== element) return;\n this._teardownObserver();\n this._setObserving(false);\n }\n\n /** Stop all observation and release the observer. */\n disconnect(): void {\n this._teardownObserver();\n this._setObserving(false);\n }\n\n // --- Internal ---\n\n private _teardownObserver(): void {\n if (this._observer) {\n this._observer.disconnect();\n this._observer = null;\n }\n this._observed = null;\n }\n\n private _createObserver(): ResizeObserver | null {\n // No constructor try/catch: unlike IntersectionObserver (which validates\n // rootMargin at construction), the ResizeObserver constructor takes only a\n // callback and has no throwing precondition. The throw path is on observe()\n // (an unsupported `box`), handled in _beginObserve.\n if (typeof ResizeObserver === \"undefined\") return null;\n return new ResizeObserver(this._onResize);\n }\n\n /**\n * Start observing with the requested `box`, retrying once with `content-box` if\n * the runtime rejects the box (e.g. `device-pixel-content-box` on engines that do\n * not support it). Returns the box actually in effect, or `null` if observation\n * could not start at all.\n */\n private _beginObserve(observer: ResizeObserver, element: Element, box?: ResizeBoxOption): ResizeBoxOption | null {\n const requested = box ?? \"content-box\";\n try {\n observer.observe(element, { box: requested });\n return requested;\n } catch {\n // Already content-box and it still threw — nothing safer to fall back to.\n if (requested === \"content-box\") return null;\n try {\n observer.observe(element, { box: \"content-box\" });\n return \"content-box\";\n } catch {\n return null;\n }\n }\n }\n\n private _onResize = (entries: ResizeObserverEntry[]): void => {\n for (const entry of entries) {\n this._setEntry(this._normalizeEntry(entry));\n }\n };\n\n private _normalizeEntry(entry: ResizeObserverEntry): WcsResizeEntry {\n const contentRect = this._normalizeRect(entry.contentRect);\n const contentBoxSize = this._firstBoxSize(entry.contentBoxSize);\n const borderBoxSize = this._firstBoxSize(entry.borderBoxSize);\n // devicePixelContentBoxSize is Chromium-only; absent on other engines.\n const devicePixelContentBoxSize = this._firstBoxSize((entry as { devicePixelContentBoxSize?: ReadonlyArray<ResizeObserverSize> }).devicePixelContentBoxSize);\n const { width, height } = this._headlineSize(contentBoxSize, borderBoxSize, devicePixelContentBoxSize, contentRect);\n return {\n width,\n height,\n contentRect,\n contentBoxSize,\n borderBoxSize,\n devicePixelContentBoxSize,\n target: entry.target,\n };\n }\n\n /**\n * Pick the headline width/height from the boxSize matching the observed `box`,\n * falling back to `contentRect` when that fragment is absent (older engines only\n * fill contentRect). `inlineSize`/`blockSize` map to width/height (correct for\n * horizontal writing modes). Rounds to integers when `round` is set.\n */\n private _headlineSize(\n contentBoxSize: WcsResizeBoxSize | null,\n borderBoxSize: WcsResizeBoxSize | null,\n devicePixelContentBoxSize: WcsResizeBoxSize | null,\n contentRect: WcsResizeRect,\n ): { width: number; height: number } {\n const box = this._effectiveBox;\n let size: WcsResizeBoxSize | null;\n if (box === \"border-box\") {\n size = borderBoxSize;\n } else if (box === \"device-pixel-content-box\") {\n size = devicePixelContentBoxSize;\n } else {\n size = contentBoxSize;\n }\n let width: number;\n let height: number;\n if (size) {\n width = size.inlineSize;\n height = size.blockSize;\n } else {\n width = contentRect.width;\n height = contentRect.height;\n }\n if (this._options.round) {\n width = Math.round(width);\n height = Math.round(height);\n }\n return { width, height };\n }\n\n private _firstBoxSize(list: ReadonlyArray<ResizeObserverSize> | undefined): WcsResizeBoxSize | null {\n if (!list || list.length === 0) return null;\n const first = list[0];\n return { inlineSize: first.inlineSize, blockSize: first.blockSize };\n }\n\n private _normalizeRect(rect: DOMRectReadOnly): WcsResizeRect {\n return {\n x: rect.x,\n y: rect.y,\n width: rect.width,\n height: rect.height,\n top: rect.top,\n right: rect.right,\n bottom: rect.bottom,\n left: rect.left,\n };\n }\n\n private _optionsEqual(a: ResizeOptions, b: ResizeOptions): boolean {\n if ((a.box ?? \"content-box\") !== (b.box ?? \"content-box\")) return false;\n return (a.round ?? false) === (b.round ?? false);\n }\n}\n","import { IWcBindable, ResizeOptions, ResizeBoxOption, WcsResizeEntry } from \"../types.js\";\nimport { ResizeCore } from \"../core/ResizeCore.js\";\n\nconst BOX_VALUES: ReadonlyArray<ResizeBoxOption> = [\"content-box\", \"border-box\", \"device-pixel-content-box\"];\n\n/**\n * `<wcs-resize>` — declarative ResizeObserver.\n *\n * The `target` attribute is the single knob that decides both *what* is observed\n * and how the element renders (it never injects a layout box unless asked):\n *\n * | `target` | observes | display | use case |\n * |-----------------|-----------------------|-------------|----------------------|\n * | omitted | first element child | `contents` | size a wrapped child |\n * | `\"#panel\"` / sel| the matched element | `none` | size an existing node|\n * | `\"self\"` | the element itself | `block` | container-width probe|\n *\n * `display:contents` means wrapping a child injects no box of its own (so a\n * `<wcs-resize><div></wcs-resize>` does not disturb a flex/grid parent); the\n * `target=\"self\"` form takes a `display:block` box that, as a zero-height element,\n * stretches to the parent's available inline size — a container-width probe.\n *\n * Note: a `display:contents` / `display:none` element generates no box, so the\n * observed node must be the child / selector target (which do have boxes), never\n * the `<wcs-resize>` host itself except in the `self` form.\n */\nexport class WcsResize extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n // Only attributes that change *what or how* we observe trigger a re-observe.\n // `once` is intentionally excluded: it is evaluated at change fire time (in\n // `_onChange`), so toggling it takes effect without re-observing — and a\n // re-observe on its change would be a pure no-op (same target, same options).\n // `manual` is also excluded: it is a connect-time policy (\"don't auto-observe on\n // connect\"), not a live switch that should start/stop an active observation.\n // `box` and `round` ARE observed: changing them rebuilds the observer, and the\n // rebuild re-delivers the initial size — which is exactly how a `round` toggle\n // re-emits width/height with the new rounding.\n static observedAttributes = [\"target\", \"box\", \"round\"];\n\n static wcBindable: IWcBindable = {\n ...ResizeCore.wcBindable,\n properties: [\n ...ResizeCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-resize:trigger-changed\" },\n ],\n // Shell-level settable surface. Each input carries its mirrored `attribute`\n // hint; `trigger` has none — it is a momentary command-property, not a\n // declarative attribute. The observe / unobserve / disconnect commands are\n // inherited from the Core via the spread above.\n inputs: [\n { name: \"target\", attribute: \"target\" },\n { name: \"box\", attribute: \"box\" },\n { name: \"round\", attribute: \"round\" },\n { name: \"once\", attribute: \"once\" },\n { name: \"manual\", attribute: \"manual\" },\n { name: \"trigger\" },\n ],\n // Core の commands をそのまま継承(単一情報源)。<wcs-intersect>/<wcs-sse> と同型。\n // spread でも継承されるが、Core に command 追加時の追従漏れを防ぐため明示参照する。\n commands: ResizeCore.wcBindable.commands,\n };\n\n private _core: ResizeCore;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n\n constructor() {\n super();\n this._core = new ResizeCore(this);\n }\n\n // SSR: the state binder awaits this before snapshotting. Backed by the Core's\n // synchronous `ready` (resize delivers the initial size synchronously, so it is\n // already resolved); exposed for uniformity with the other @wcstack IO nodes.\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Attribute accessors ---\n\n get target(): string {\n return this.getAttribute(\"target\") ?? \"\";\n }\n\n set target(value: string) {\n this.setAttribute(\"target\", value);\n }\n\n get box(): string {\n return this.getAttribute(\"box\") ?? \"\";\n }\n\n set box(value: string) {\n this.setAttribute(\"box\", value);\n }\n\n get round(): boolean {\n return this.hasAttribute(\"round\");\n }\n\n set round(value: boolean) {\n if (value) {\n this.setAttribute(\"round\", \"\");\n } else {\n this.removeAttribute(\"round\");\n }\n }\n\n get once(): boolean {\n return this.hasAttribute(\"once\");\n }\n\n set once(value: boolean) {\n if (value) {\n this.setAttribute(\"once\", \"\");\n } else {\n this.removeAttribute(\"once\");\n }\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean) {\n if (value) {\n this.setAttribute(\"manual\", \"\");\n } else {\n this.removeAttribute(\"manual\");\n }\n }\n\n // --- Core delegated getters ---\n\n get entry(): WcsResizeEntry | null {\n return this._core.entry;\n }\n\n get width(): number {\n return this._core.width;\n }\n\n get height(): number {\n return this._core.height;\n }\n\n get observing(): boolean {\n return this._core.observing;\n }\n\n // --- Command property ---\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n // Momentary command-property: a false→true write re-runs observe(). Mirrors the\n // trigger flag on <wcs-intersect> / <wcs-geo>. Prefer the command-token protocol\n // (`command.observe: $command.start`) for state-driven observation; this exists\n // mainly for simple boolean bindings.\n const v = !!value; // normalize truthy state-bindings, like <wcs-intersect>'s setter\n if (v) {\n this._trigger = true;\n // try/finally mirrors <wcs-intersect>'s set trigger: observe() is never-throw\n // today, but should a synchronous throw path ever appear, the finally still\n // auto-resets _trigger (no stuck-true latch) and emits the completion notice.\n try {\n this.observe();\n } finally {\n this._trigger = false;\n // Always auto-reset to false after the observe() attempt — this is the\n // *momentary acknowledgement* that the trigger was consumed, NOT a signal\n // that observation succeeded (whether the target resolved is reflected by\n // `observing`, not by this event). Read `observing` if you need the outcome.\n this.dispatchEvent(new CustomEvent(\"wcs-resize:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n }\n }\n }\n\n // --- Commands ---\n\n /** Re-resolve the target from the DOM and (re)start observing. */\n observe(): void {\n const { element, display } = this._resolveTarget();\n // `display` is derived from the `target` *mode* (self/selector/child), not from\n // whether the selector currently matches — so it is applied unconditionally,\n // before the resolution check. A `target=\"#x\"` whose node is momentarily absent\n // still renders `display:none` (it is a selector pointer, never a box).\n this.style.display = display;\n if (!element) {\n // The target is no longer resolvable (e.g. a `target` selector whose node was\n // removed from the DOM). Tear down any stale observation so `observing` does\n // not keep reporting true against a node that is gone.\n this._core.disconnect();\n return;\n }\n this._core.observe(element, this._options());\n }\n\n unobserve(): void {\n // Single-target Shell: \"stop observing my target\" is exactly the Core's\n // teardown. Delegate to the Core's tracked state rather than re-resolving the\n // selector, so a target that has since left the DOM can still be stopped\n // (re-resolving would yield null and silently leave the observer running).\n this._core.disconnect();\n }\n\n disconnect(): void {\n this._core.disconnect();\n }\n\n // --- Internal ---\n\n private _resolveTarget(): { element: Element | null; display: string } {\n const target = this.target;\n if (target === \"self\") {\n // Explicit sentinel: observe the element itself. As a display:block zero-height\n // box it stretches to the parent's available inline size — a container probe.\n return { element: this, display: \"block\" };\n }\n if (target !== \"\") {\n // Selector pointer: observe a referenced element in place, staying invisible.\n const scope = this.getRootNode() as Document | ShadowRoot;\n // A user-authored selector can be syntactically invalid (e.g. `#`, `:::`,\n // `[data-*`), which makes querySelector throw a SyntaxError. Swallow it and\n // treat the target as unresolvable — the same \"nothing to observe\" path as a\n // selector matching no element — so a bad attribute never lets the throw escape\n // observe() → connectedCallback / attributeChangedCallback (never-throw).\n return { element: this._safeQuery(scope, target), display: \"none\" };\n }\n // Omitted: observe the first element child without injecting a box of our own.\n const child = this.firstElementChild;\n if (child) {\n return { element: child, display: \"contents\" };\n }\n // No child to wrap (e.g. used as an empty marker) — fall back to self.\n return { element: this, display: \"block\" };\n }\n\n // Wrap querySelector so a syntactically invalid user-authored selector resolves to\n // null (unresolvable) instead of letting the SyntaxError escape — keeping the\n // sensor never-throw, mirroring intersection's _safeQuery guard.\n private _safeQuery(scope: Document | ShadowRoot, selector: string): Element | null {\n try {\n return scope.querySelector(selector);\n } catch {\n return null;\n }\n }\n\n private _parseBox(): ResizeBoxOption {\n const raw = this.box.trim();\n // Decision: an unrecognized box value falls back to content-box at parse time\n // (rather than letting the Core's observe() reject it), mirroring threshold's\n // range filter in <wcs-intersect>. The Core still has its own runtime fallback\n // for a *valid-but-unsupported* box (e.g. device-pixel-content-box on Safari).\n return (BOX_VALUES as ReadonlyArray<string>).includes(raw) ? (raw as ResizeBoxOption) : \"content-box\";\n }\n\n private _options(): ResizeOptions {\n return {\n box: this._parseBox(),\n round: this.round,\n };\n }\n\n private _onChange = (event: Event): void => {\n // `wcs-resize:change` bubbles, so a nested `<wcs-resize>` descendant's change\n // would otherwise reach this (ancestor) listener and let a *child's* resize tear\n // down *our* observer. Only act on our own Core's event. (This also avoids\n // reading `.detail` off a foreign event shape.)\n if (event.target !== this) return;\n // `once`: tear down after the first size observation. ResizeObserver always\n // delivers the initial size on observe(), so once = measure-once. Gated at fire\n // time so toggling the `once` attribute takes effect live.\n if (this.once) {\n this._core.disconnect();\n }\n };\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.addEventListener(\"wcs-resize:change\", this._onChange);\n if (!this.manual) {\n this.observe();\n }\n // SSR: back connectedCallbackPromise with the Core's readiness probe. The\n // observation itself is started above via the element-observe command; this\n // captures the (synchronously resolved) ready promise for the state binder.\n this._connectedCallbackPromise = this._core.observe();\n }\n\n disconnectedCallback(): void {\n this.removeEventListener(\"wcs-resize:change\", this._onChange);\n this._core.dispose();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n // Defensive same-value guard. Per the HTML spec, an attribute change reaction is\n // enqueued whenever setAttribute() runs — including with an unchanged value — so\n // attributeChangedCallback CAN fire on a same-value write. Re-observing on an\n // unchanged attribute would be a wasted observer rebuild, so bail early when the\n // value did not actually change. Kept intentionally; do not remove.\n if (oldValue === newValue) return;\n // Only react once connected and in automatic mode. The Core's idempotency guard\n // absorbs the autoloader upgrade case (attributeChangedCallback +\n // connectedCallback both calling observe() with identical options).\n if (!this.isConnected || this.manual) return;\n this.observe();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapResize(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { WcsResize } from \"./components/Resize.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.resize)) {\n customElements.define(config.tagNames.resize, WcsResize);\n }\n}\n"],"names":["_config","tagNames","resize","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","ResizeCore","EventTarget","static","protocol","version","properties","name","event","getter","e","detail","width","height","commands","_target","_observer","_observed","_options","_effectiveBox","_entry","_observing","_ready","Promise","resolve","constructor","target","super","this","ready","observe","element","options","_observeElement","dispose","disconnect","entry","observing","_setEntry","dispatchEvent","CustomEvent","bubbles","_setObserving","_optionsEqual","_teardownObserver","observer","_createObserver","effectiveBox","_beginObserve","box","round","unobserve","ResizeObserver","_onResize","requested","entries","_normalizeEntry","contentRect","_normalizeRect","contentBoxSize","_firstBoxSize","borderBoxSize","devicePixelContentBoxSize","_headlineSize","size","inlineSize","blockSize","Math","list","length","first","rect","x","y","top","right","bottom","left","a","b","BOX_VALUES","WcsResize","HTMLElement","wcBindable","inputs","attribute","_core","_trigger","_connectedCallbackPromise","connectedCallbackPromise","getAttribute","value","setAttribute","hasAttribute","removeAttribute","once","manual","trigger","display","_resolveTarget","style","scope","getRootNode","_safeQuery","child","firstElementChild","selector","querySelector","_parseBox","raw","trim","includes","_onChange","connectedCallback","addEventListener","disconnectedCallback","removeEventListener","attributeChangedCallback","_name","oldValue","newValue","isConnected","bootstrapResize","userConfig","partialConfig","assign","customElements","get","define"],"mappings":"AAQA,MAAMA,EAA2B,CAC/BC,SAAU,CACRC,OAAQ,eAIZ,SAASC,EAAcC,GACrB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpDC,OAAOC,OAAOF,GACd,IAAK,MAAMG,KAAOF,OAAOG,KAAKJ,GAC5BD,EAAYC,EAAgCG,IAE9C,OAAOH,CACT,CAEA,SAASK,EAAaL,GACpB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpD,MAAMM,EAAiC,CAAA,EACvC,IAAK,MAAMH,KAAOF,OAAOG,KAAKJ,GAC5BM,EAAMH,GAAOE,EAAWL,EAAgCG,IAE1D,OAAOG,CACT,CAEA,IAAIC,EAA+B,KAE5B,MAAMC,EAAkBZ,WAEfa,IAId,OAHKF,IACHA,EAAeR,EAAWM,EAAUT,KAE/BW,CACT,CClBM,MAAOG,UAAmBC,YAC9BC,kB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O,CACL+B,IAAKrB,KAAKgF,YACV1D,MAAOtB,KAAKsB,MAEhB,CAEQ8D,UAAaxG,IAKfA,EAAMkB,SAAWE,MAIjBA,KAAKmE,MACPnE,KAAK0D,MAAMnD,cAMf,iBAAA8E,GACErF,KAAKsF,iBAAiB,oBAAqBtF,KAAKoF,WAC3CpF,KAAKoE,QACRpE,KAAKE,UAKPF,KAAK4D,0BAA4B5D,KAAK0D,MAAMxD,SAC9C,CAEA,oBAAAqF,GACEvF,KAAKwF,oBAAoB,oBAAqBxF,KAAKoF,WACnDpF,KAAK0D,MAAMpD,SACb,CAEA,wBAAAmF,CAAyBC,EAAeC,EAAyBC,GAM3DD,IAAaC,GAIZ5F,KAAK6F,cAAe7F,KAAKoE,QAC9BpE,KAAKE,SACP,ECtTI,SAAU4F,EAAgBC,GHuC1B,IAAoBC,EGtCpBD,KHsCoBC,EGrCZD,GHsCMvI,UAChBI,OAAOqI,OAAO1I,EAAQC,SAAUwI,EAAcxI,UAEhDU,EAAe,MI3CVgI,eAAeC,IAAIhI,EAAOX,SAASC,SACtCyI,eAAeE,OAAOjI,EAAOX,SAASC,OAAQ4F,EDIlD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/resize",
3
- "version": "1.14.0",
3
+ "version": "1.15.0",
4
4
  "description": "Declarative ResizeObserver component for Web Components. Framework-agnostic element-size primitive via wc-bindable-protocol.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.esm.js",