@isoloop/dom 0.0.0-next.56111e3 → 0.0.0-next.5bbb503

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.
@@ -171,6 +171,10 @@ function createApplier(container, policy) {
171
171
  out.key = e.key;
172
172
  out.code = e.code;
173
173
  }
174
+ if (e.type === "scroll" && el instanceof Element) {
175
+ out.scrollTop = el.scrollTop;
176
+ out.scrollLeft = el.scrollLeft;
177
+ }
174
178
  if (e instanceof MouseEvent) {
175
179
  out.x = e.clientX;
176
180
  out.y = e.clientY;
@@ -528,6 +528,11 @@ var WElement = class extends WParentNode {
528
528
  /** @internal */ isoStyle = null;
529
529
  /** @internal */ isoClassList = null;
530
530
  /** @internal */ isoDataset = null;
531
+ /** @internal The offsets the last `scroll` event brought (design §4.6). */
532
+ isoScroll = {
533
+ top: 0,
534
+ left: 0
535
+ };
531
536
  constructor(doc, id, localName, ns) {
532
537
  super(doc, id);
533
538
  this.localName = localName;
@@ -594,6 +599,16 @@ var WElement = class extends WParentNode {
594
599
  this.isoDataset ??= createDataset(this);
595
600
  return this.isoDataset;
596
601
  }
602
+ /**
603
+ * Read only, and as of the last `scroll` event the element got: the host
604
+ * owns scrolling. 0 until the element is scrolled and listens for `scroll`.
605
+ */
606
+ get scrollTop() {
607
+ return this.isoScroll.top;
608
+ }
609
+ get scrollLeft() {
610
+ return this.isoScroll.left;
611
+ }
597
612
  get id() {
598
613
  return this.getAttribute("id") ?? "";
599
614
  }
@@ -1016,6 +1031,10 @@ function createDom(opts) {
1016
1031
  if (!node) return;
1017
1032
  if ((node instanceof WHTMLInputElement || node instanceof WHTMLTextAreaElement || node instanceof WHTMLSelectElement) && event.value !== void 0) node.isoSetProp("value", event.value, false);
1018
1033
  if (node instanceof WHTMLInputElement && event.checked !== void 0) node.isoSetProp("checked", event.checked, false);
1034
+ if (event.type === "scroll" && node instanceof WElement) node.isoScroll = {
1035
+ top: event.scrollTop ?? 0,
1036
+ left: event.scrollLeft ?? 0
1037
+ };
1019
1038
  node.dispatchEvent(toEvent(event));
1020
1039
  }
1021
1040
  };
@@ -1023,7 +1042,7 @@ function createDom(opts) {
1023
1042
  /** A real `Event` with the fields frameworks read from mouse and keyboard events. */
1024
1043
  function toEvent(e) {
1025
1044
  const ev = new Event(e.type, {
1026
- bubbles: true,
1045
+ bubbles: e.type !== "scroll",
1027
1046
  cancelable: true
1028
1047
  });
1029
1048
  const mods = {
@@ -1,4 +1,4 @@
1
- import { i as DomRecord, n as DomEvent, o as Namespace, s as NodeId, t as DomBatch, u as SyncedProp } from "./records-2Jf3U4Sp.js";
1
+ import { i as DomRecord, n as DomEvent, o as Namespace, s as NodeId, t as DomBatch, u as SyncedProp } from "./records-OXGckMg9.js";
2
2
  type ListenerFn = (event: Event) => void;
3
3
  type Listener = {
4
4
  fn: ListenerFn | {
@@ -165,6 +165,11 @@ declare class WElement extends WParentNode {
165
165
  /** @internal */ isoStyle: WStyle | null;
166
166
  /** @internal */ isoClassList: WDOMTokenList | null;
167
167
  /** @internal */ isoDataset: Record<string, string | undefined> | null;
168
+ /** @internal The offsets the last `scroll` event brought (design §4.6). */
169
+ isoScroll: {
170
+ top: number;
171
+ left: number;
172
+ };
168
173
  constructor(doc: WDocument, id: NodeId, localName: string, ns: Namespace);
169
174
  get tagName(): string;
170
175
  get nodeName(): string;
@@ -183,6 +188,12 @@ declare class WElement extends WParentNode {
183
188
  get style(): WStyle;
184
189
  get classList(): WDOMTokenList;
185
190
  get dataset(): Record<string, string | undefined>;
191
+ /**
192
+ * Read only, and as of the last `scroll` event the element got: the host
193
+ * owns scrolling. 0 until the element is scrolled and listens for `scroll`.
194
+ */
195
+ get scrollTop(): number;
196
+ get scrollLeft(): number;
186
197
  get id(): string;
187
198
  set id(v: string);
188
199
  /** @internal */ isoSetProp(name: SyncedProp, value: string | boolean, record: boolean): void;
package/dist/host.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as ISOLOOP_DOM_FMT, c as ROOT_ID, d as isDomBatch, i as DomRecord, l as SerializedNode, n as DomEvent, o as Namespace, r as DomMods, s as NodeId, t as DomBatch, u as SyncedProp } from "./records-2Jf3U4Sp.js";
1
+ import { a as ISOLOOP_DOM_FMT, c as ROOT_ID, d as isDomBatch, i as DomRecord, l as SerializedNode, n as DomEvent, o as Namespace, r as DomMods, s as NodeId, t as DomBatch, u as SyncedProp } from "./records-OXGckMg9.js";
2
2
  /** Decides what the applier may create and write. Supplied by the host; required. */
3
3
  interface SanitisePolicy {
4
4
  /** The host element to create for an isolate's tag. */
package/dist/host.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import { n as ROOT_ID, r as isDomBatch, t as ISOLOOP_DOM_FMT } from "./records-wVZrPpqr.js";
2
- import { t as createApplier } from "./applier-CkaI6Dw-.js";
2
+ import { t as createApplier } from "./applier-BSeEH9MP.js";
3
3
  export { ISOLOOP_DOM_FMT, ROOT_ID, createApplier, isDomBatch };
@@ -1,4 +1,4 @@
1
- import { _ as WText, a as WDocumentFragment, c as WHTMLElement, d as WHTMLOptionElement, f as WHTMLSelectElement, g as WSVGElement, l as WHTMLIFrameElement, m as WNode, n as WComment, o as WElement, p as WHTMLTextAreaElement, r as WDOMTokenList, u as WHTMLInputElement } from "./dom-9S5T0UVQ.js";
1
+ import { _ as WText, a as WDocumentFragment, c as WHTMLElement, d as WHTMLOptionElement, f as WHTMLSelectElement, g as WSVGElement, l as WHTMLIFrameElement, m as WNode, n as WComment, o as WElement, p as WHTMLTextAreaElement, r as WDOMTokenList, u as WHTMLInputElement } from "./dom-7EzPoV0N.js";
2
2
  // src/worker/install.ts
3
3
  /** The DOM globals the subset provides (ADR 0010 point 2), by their DOM names. */
4
4
  const DOM_GLOBALS = {
@@ -52,6 +52,9 @@ type DomEvent = {
52
52
  /** For `resize` on a transferred canvas: its new CSS size (design §4.7). */
53
53
  width?: number;
54
54
  height?: number;
55
+ /** For `scroll`: the scrolled element's offsets, mirrored on the worker node. */
56
+ scrollTop?: number;
57
+ scrollLeft?: number;
55
58
  };
56
59
  /** The batch comes from an isolate, so its shape is checked before anything touches the DOM. */
57
60
  declare function isDomBatch(x: unknown): x is DomBatch;
@@ -1,5 +1,5 @@
1
- import { t as DomBatch } from "./records-2Jf3U4Sp.js";
2
- import { s as WorkerDom } from "./dom-BrJVEi7G.js";
1
+ import { t as DomBatch } from "./records-OXGckMg9.js";
2
+ import { s as WorkerDom } from "./dom-ANUAQHqi.js";
3
3
  /** One framework major's log, as `packages/dom/usage/<project>.json` stores it. */
4
4
  export type UsageLog = {
5
5
  /** E.g. `preact@10.29.8`. */
@@ -1,5 +1,5 @@
1
- import { n as install, t as DOM_GLOBALS } from "./install-DBKGtAel.js";
2
- import { h as WParentNode, i as WDocument, o as WElement, s as WEventTarget, t as WCharacterData, v as createDom } from "./dom-9S5T0UVQ.js";
1
+ import { n as install, t as DOM_GLOBALS } from "./install-DE1VIvyG.js";
2
+ import { h as WParentNode, i as WDocument, o as WElement, s as WEventTarget, t as WCharacterData, v as createDom } from "./dom-7EzPoV0N.js";
3
3
  // src/testing/worker.ts
4
4
  /** Everything a framework sees: the classes `install()` exposes, and `document`. */
5
5
  const CLASSES = [
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { s as WorkerDom } from "./dom-BrJVEi7G.js";
1
+ import { s as WorkerDom } from "./dom-ANUAQHqi.js";
2
2
  import { FixtureMessage, UsageLog } from "./testing-worker.js";
3
3
  /** An event as a host bridge sends it to the isolate, reduced to what the suite reads. */
4
4
  type ConformanceEvent = {
package/dist/testing.js CHANGED
@@ -1,5 +1,5 @@
1
- import { h as WParentNode, o as WElement, t as WCharacterData, v as createDom } from "./dom-9S5T0UVQ.js";
2
- import { t as createApplier } from "./applier-CkaI6Dw-.js";
1
+ import { h as WParentNode, o as WElement, t as WCharacterData, v as createDom } from "./dom-7EzPoV0N.js";
2
+ import { t as createApplier } from "./applier-BSeEH9MP.js";
3
3
  import { afterEach, describe, expect, it } from "vitest";
4
4
  import { commands } from "vitest/browser";
5
5
  // src/testing/conformance.ts
package/dist/worker.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as ISOLOOP_DOM_FMT, c as ROOT_ID, i as DomRecord, l as SerializedNode, n as DomEvent, o as Namespace, r as DomMods, s as NodeId, t as DomBatch, u as SyncedProp } from "./records-2Jf3U4Sp.js";
2
- import { a as WNode, c as WorkerDomOptions, i as WElement, l as createDom, n as WDocument, o as WText, r as WDocumentFragment, s as WorkerDom, t as WComment } from "./dom-BrJVEi7G.js";
1
+ import { a as ISOLOOP_DOM_FMT, c as ROOT_ID, i as DomRecord, l as SerializedNode, n as DomEvent, o as Namespace, r as DomMods, s as NodeId, t as DomBatch, u as SyncedProp } from "./records-OXGckMg9.js";
2
+ import { a as WNode, c as WorkerDomOptions, i as WElement, l as createDom, n as WDocument, o as WText, r as WDocumentFragment, s as WorkerDom, t as WComment } from "./dom-ANUAQHqi.js";
3
3
  /** The DOM globals the subset provides (ADR 0010 point 2), by their DOM names. */
4
4
  export declare const DOM_GLOBALS: Readonly<Record<string, unknown>>;
5
5
  /**
package/dist/worker.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { n as ROOT_ID, t as ISOLOOP_DOM_FMT } from "./records-wVZrPpqr.js";
2
- import { _ as WText, a as WDocumentFragment, i as WDocument, m as WNode, n as WComment, o as WElement, v as createDom } from "./dom-9S5T0UVQ.js";
3
- import { n as install, t as DOM_GLOBALS } from "./install-DBKGtAel.js";
2
+ import { _ as WText, a as WDocumentFragment, i as WDocument, m as WNode, n as WComment, o as WElement, v as createDom } from "./dom-7EzPoV0N.js";
3
+ import { n as install, t as DOM_GLOBALS } from "./install-DE1VIvyG.js";
4
4
  export { DOM_GLOBALS, ISOLOOP_DOM_FMT, ROOT_ID, WComment, WDocument, WDocumentFragment, WElement, WNode, WText, createDom, install };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isoloop/dom",
3
- "version": "0.0.0-next.56111e3",
3
+ "version": "0.0.0-next.5bbb503",
4
4
  "description": "Internal: Isoloop's render bridge (isoloop-dom@1). Used by @isoloop/runtime and @isoloop/host; not for app code.",
5
5
  "license": "MIT",
6
6
  "type": "module",