@ng-native/web 0.17.1 → 0.18.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/browser-engine.d.ts +3 -0
- package/dist/browser-engine.js +10 -0
- package/dist/browser-engine.js.map +1 -1
- package/dist/browser-renderer.d.ts +4 -5
- package/dist/browser-renderer.js +6 -7
- package/dist/browser-renderer.js.map +1 -1
- package/dist/dom-node.d.ts +5 -2
- package/dist/dom-node.js +138 -10
- package/dist/dom-node.js.map +1 -1
- package/dist/mount.js +15 -2
- package/dist/mount.js.map +1 -1
- package/dist/responder.d.ts +5 -3
- package/dist/responder.js +31 -16
- package/dist/responder.js.map +1 -1
- package/package.json +8 -8
package/dist/browser-engine.d.ts
CHANGED
|
@@ -109,6 +109,9 @@ export declare class BrowserEngine extends HostEngine {
|
|
|
109
109
|
private readonly adopted;
|
|
110
110
|
commit(): boolean;
|
|
111
111
|
get focused(): BrowserNode | null;
|
|
112
|
+
/** A `text-input`, the `<input>` or `<textarea>` it commits as; a focused button is not one. */
|
|
113
|
+
get focusedField(): BrowserNode | null;
|
|
114
|
+
blurFocused(): void;
|
|
112
115
|
private isAttached;
|
|
113
116
|
/**
|
|
114
117
|
* A `require()`d numeric asset has no web analogue - there is no bundler-provided asset
|
package/dist/browser-engine.js
CHANGED
|
@@ -314,6 +314,16 @@ export class BrowserEngine extends HostEngine {
|
|
|
314
314
|
this.focusedNode = null;
|
|
315
315
|
return this.focusedNode;
|
|
316
316
|
}
|
|
317
|
+
/** A `text-input`, the `<input>` or `<textarea>` it commits as; a focused button is not one. */
|
|
318
|
+
get focusedField() {
|
|
319
|
+
const node = this.focused;
|
|
320
|
+
return node?.tag === 'text-input' ? node : null;
|
|
321
|
+
}
|
|
322
|
+
blurFocused() {
|
|
323
|
+
const field = this.focusedField;
|
|
324
|
+
if (field)
|
|
325
|
+
this.dispatchCommand(field, 'blur');
|
|
326
|
+
}
|
|
317
327
|
isAttached(node) {
|
|
318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Is: the browser counterpart to `packages/fabric/src/engine.ts`'s\n * `Engine`.\n *\n * One instance per `mount()` call. It owns the prop/DOM translation (`props.ts`), the element\n * mapping (`elements.ts`), and the responder negotiation (`responder.ts`); this file is mostly\n * the wiring between them and the handful of DOM event listeners the whole tree shares - one\n * `pointerdown`/`pointermove`/`pointerup`/`pointercancel` set on `document` for the responder\n * system, one `focusin`/`focusout` set for `:focus` tracking, because both need to see every\n * node's events rather than each node installing its own (Fabric's own engine is exactly this\n * shape: one `registerEventHandler` callback for the whole tree, not one per view).\n *\n * `dispatchEvent` mirrors `engine.ts`'s method of the same name step for step: run the responder\n * negotiation first, then propagate to whatever `(eventName)` bindings are listening, in the\n * same two-phase order a real touch would arrive in on native.\n */\nimport {\n DIRECT_EVENTS,\n HostEngine,\n SyntheticEvent,\n type ResponderEvent,\n type ResponderHandlers,\n type WindowFrame,\n} from '@ng-native/fabric';\nimport {\n makeAnchorNode,\n makeElementNode,\n makeTextNode,\n nearestNodeOf,\n nodeOf,\n rebindElement,\n type BrowserNode,\n} from './dom-node.ts';\nimport { createDomElement, textFieldLike } from './elements.ts';\nimport { applyProp } from './props.ts';\nimport { ResponderSystem } from './responder.ts';\n\nconst TOUCH_EVENT_NAMES: Record<string, string> = {\n pointerdown: 'topTouchStart',\n pointermove: 'topTouchMove',\n pointerup: 'topTouchEnd',\n pointercancel: 'topTouchCancel',\n};\n\nfunction scrollToEnd(el: HTMLElement, args: readonly unknown[]): void {\n const [animated = true] = args as [boolean?];\n const horizontal = el.scrollWidth > el.clientWidth && el.scrollHeight <= el.clientHeight;\n el.scrollTo(\n horizontal\n ? { left: el.scrollWidth, behavior: animated ? 'smooth' : 'auto' }\n : { top: el.scrollHeight, behavior: animated ? 'smooth' : 'auto' },\n );\n}\n\n/** Focuses `field` with the caret or selection `old` had, as a field swapped in for it. */\nfunction focusLike(field: HTMLInputElement | HTMLTextAreaElement, old: typeof field): void {\n field.focus();\n const { selectionStart, selectionEnd, selectionDirection } = old;\n if (selectionStart === null || selectionEnd === null) return;\n field.setSelectionRange(selectionStart, selectionEnd, selectionDirection ?? undefined);\n}\n\nfunction setTextAndSelection(el: HTMLElement, args: readonly unknown[]): void {\n const [, text, start, end] = args as [number, string | null, number, number];\n const textarea = el as HTMLTextAreaElement;\n if (text !== null && text !== undefined) textarea.value = text;\n if (start !== -1) textarea.setSelectionRange(start, end === -1 ? start : end);\n}\n\n/**\n * View commands, by name. A lookup table for the same reason `props.ts`'s tables are one: it is\n * where a review sees which commands do something and which do not, in one place, rather than\n * spread across a `switch`'s branches.\n *\n * `flashScrollIndicators`, `zoomToRect`, `hotspotUpdate`, `setPressed`, `setNativeRefreshing`:\n * no web equivalent (a browser's scrollbar has no imperative \"flash\", pinch-zoom is not\n * scriptable, and there is no Android ripple to drive) - absent rather than a `noop` entry,\n * because unlike a prop there is no generic fallback for a command name to fall through to; an\n * absent command is already silently ignored below.\n */\nconst COMMANDS: Record<string, (el: HTMLElement, args: readonly unknown[]) => void> = {\n focus: (el) => el.focus(),\n blur: (el) => el.blur(),\n scrollTo: (el, args) => {\n const [x = 0, y = 0, animated = true] = args as [number?, number?, boolean?];\n el.scrollTo({ left: x, top: y, behavior: animated ? 'smooth' : 'auto' });\n },\n scrollToEnd,\n setTextAndSelection,\n // `<switch>` putting back a flip the app refused; the checkbox is what the user clicked.\n setValue: (el, [value]) => {\n (el as HTMLInputElement).checked = value === true;\n },\n};\n\n/**\n * The events this engine owns, which are React Native's rather than the DOM's.\n *\n * Each is either synthesised here from something else - `topLayout` from a `ResizeObserver`,\n * `topTouch*` from pointer events, `topFocus` from `focusin` - or not implemented yet. Either way\n * a handler bound to one expects React Native's `{ nativeEvent }` payload with React Native's own\n * fields in it, so they must not be wired straight to the DOM event of the same name: a\n * `scroll-view`'s `(scroll)` reads `nativeEvent.contentOffset`, and handing it a raw DOM `Event`\n * would turn a binding that quietly does nothing into one that throws on the first scroll.\n *\n * The list is the events `@ng-native/components` actually binds, found by\n * reading their host and template bindings rather than guessed. Anything outside it is a plain\n * DOM event and is bound as one.\n *\n * `topLoad` and `topError` are deliberately *not* here, though an `<image>` binds both. A\n * background image fires neither on its own, so `props.ts` loads the URL with a detached `Image()`\n * and dispatches a real DOM `load` or `error` on the element - which means there is a genuine DOM\n * event of each name to bind, and the general path is the right one. Reserving them was what left\n * a broken image URL blank rather than showing a fallback.\n */\nconst ENGINE_EVENTS = new Set([\n 'topLayout',\n 'topChange',\n 'topContentSizeChange',\n 'topRefresh',\n 'topScroll',\n 'topEndReached',\n 'topSelectionChange',\n 'topKeyPress',\n 'topMomentumScrollBegin',\n 'topMomentumScrollEnd',\n 'topTouchStart',\n 'topTouchMove',\n 'topTouchEnd',\n 'topTouchCancel',\n 'topFocus',\n 'topBlur',\n 'topPointerEnter',\n 'topPointerLeave',\n]);\n\nexport class BrowserEngine extends HostEngine {\n private readonly document: Document;\n private readonly responders = new ResponderSystem();\n private focusedNode: BrowserNode | null = null;\n /** `TextInput`'s echo protocol: a change count that only ever goes up. One counter per field. */\n private readonly eventCounts = new WeakMap<BrowserNode, number>();\n /** Mount points `wrapRoot` wrapped; see `isRoot`. */\n private readonly roots = new WeakSet<BrowserNode>();\n /**\n * The node each in-progress gesture began on, by `pointerId`, so `pointermove`/`pointerup`\n * resolve to the same node however far the finger has travelled - `setPointerCapture` keeps\n * the browser routing them there; this is what this class trusts instead of re-reading\n * `event.target`. Keyed by `pointerId` rather than holding just one, so two fingers on two\n * different controls (a phone reports multi-touch) do not clobber each other.\n */\n private readonly activeTouches = new Map<number, BrowserNode>();\n /**\n * The element nodes this engine made, and so the only ones its document listeners act for.\n *\n * Every engine listens on the one `document`, and a page can hold several - one per island, or\n * the documentation site's three roots - while `nearestNodeOf` finds a node whichever engine\n * made it. Without this, each engine delivered every focus, blur and touch in any root on the\n * page, so a text field's `(blur)` ran once per island.\n */\n private readonly owned = new WeakSet<BrowserNode>();\n /** Removes the document listeners, once the app they served is gone; see `dispose`. */\n private readonly listening: AbortController;\n\n constructor(document: Document) {\n super();\n this.document = document;\n // The document's own, so the signal is one its `addEventListener` recognises.\n this.listening = new (document.defaultView?.AbortController ?? AbortController)();\n this.installGlobalListeners();\n }\n\n /** Stop listening to the document. `mount` calls this as its app is destroyed. */\n dispose(): void {\n this.listening.abort();\n this.activeTouches.clear();\n }\n\n // --- element creation, called from BrowserRenderer ----------------------------------------\n\n createElementNode(name: string): BrowserNode {\n const el = createDomElement(this.document, name);\n const node = makeElementNode(name, el);\n this.owned.add(node);\n this.wireAlwaysOnListeners(node);\n return node;\n }\n\n createTextNode(value: string): BrowserNode {\n return makeTextNode(this.document.createTextNode(value));\n }\n\n createAnchorNode(): BrowserNode {\n return makeAnchorNode(this.document.createComment(''));\n }\n\n /**\n * Wrap an existing real element - the app's own mount point - as the tree's root node.\n *\n * `ngSkipHydration` is Angular's own opt-out, and true of every tree this engine renders: none\n * is server-rendered, so there is no markup to reuse. With hydration on, Angular reads it on a\n * root component's host element, and without it walks that element's DOM for text markers,\n * which a node is not.\n */\n wrapRoot(el: Element): BrowserNode {\n const node = makeElementNode(el.tagName.toLowerCase(), el);\n el.setAttribute('data-rn', 'root');\n el.setAttribute('ngSkipHydration', '');\n this.roots.add(node);\n this.owned.add(node);\n return node;\n }\n\n /**\n * Whether `node` is a mount point `wrapRoot` wrapped. It belongs to whoever called `mount`, not\n * to the app rendered into it, so the renderer empties it rather than removing it.\n */\n isRoot(node: BrowserNode): boolean {\n return this.roots.has(node);\n }\n\n // --- HostEngine -----------------------------------------------------------------------------\n\n setProp(node: BrowserNode, key: string, value: unknown): void {\n const clear = value === undefined || value === null;\n if (clear) {\n if (!(key in node.props)) return;\n delete node.props[key];\n } else {\n if (node.props[key] === value) return;\n node.props[key] = value;\n }\n if (key === 'multiline' && node.tag === 'text-input') this.fieldFor(node, value === true);\n applyProp(node, key, value, clear);\n }\n\n /**\n * A `<textarea>` for a multiline field and an `<input>` for a one-line one, swapped in place when\n * `multiline` arrives, which is after the element was made (see `elements.ts`).\n *\n * The new element takes the old one's attributes (inline style and scoping attributes among\n * them), its value, its focus and its selection, and the engine's own listeners are installed on it again.\n */\n private fieldFor(node: BrowserNode, multiline: boolean): void {\n const old = node.el as HTMLInputElement | HTMLTextAreaElement;\n if ((old.tagName === 'TEXTAREA') === multiline) return;\n const field = textFieldLike(old, multiline);\n // An input strips line breaks from its value, so text set before `multiline` lost them. Taken\n // from the prop again unless the user has typed since.\n const text = node.props['text'];\n if (multiline && text != null && old.value === String(text).replace(/[\\r\\n]/g, '')) {\n field.value = String(text);\n }\n const focused = this.document.activeElement === old;\n this.layoutObservers.get(node)?.disconnect();\n old.replaceWith(field);\n rebindElement(node, field);\n this.wireAlwaysOnListeners(node);\n const optedIn = node.optedIn;\n node.optedIn = null;\n for (const type of optedIn ?? []) this.wireOptIn(node, type);\n for (const key of ['secureTextEntry', 'keyboardType', 'numberOfLines']) {\n if (key in node.props) applyProp(node, key, node.props[key], false);\n }\n if (focused) focusLike(field, old);\n }\n\n /** Each node's `topLayout` observer, so a field swapped for another stops watching the old one. */\n private readonly layoutObservers = new WeakMap<BrowserNode, ResizeObserver>();\n\n setEventListener(\n node: BrowserNode,\n topLevelType: string,\n fn: (event: unknown) => void,\n ): () => void {\n const listeners = (node.listeners ??= new Map());\n let set = listeners.get(topLevelType);\n if (!set) listeners.set(topLevelType, (set = new Set()));\n set.add(fn);\n this.wireOptIn(node, topLevelType);\n return () => set!.delete(fn);\n }\n\n setResponder(node: BrowserNode, handlers: ResponderHandlers): () => void {\n return this.responders.setResponder(node, handlers);\n }\n\n /**\n * Where a node is, relative to the mount root rather than to the viewport.\n *\n * `measureInWindow` on native answers in window coordinates, and the overlay host is a\n * full-screen absolutely positioned view at the window's origin, so the two agree and an\n * anchored overlay can use one as the other. `getBoundingClientRect` answers in *viewport*\n * coordinates, and `<overlay-host>` is absolutely positioned inside the mount root - so\n * those two agree only when the root sits at the top left of an unscrolled viewport.\n *\n * That is true of a full-page app, which is why every popover in the gallery lands correctly\n * and this went unnoticed. It is false in the two cases that matter: an app mounted into a box\n * partway down a page, where every overlay is offset by the box's own position, and a document\n * that scrolls, where the offset changes as you scroll. Subtracting the root's own rect from a\n * viewport-relative one cancels the scroll term as well as the offset, since both rects move\n * together as the page scrolls - so one subtraction fixes both cases at once.\n *\n * `closest`, not `querySelector`: a page can hold more than one mounted root at a time (the\n * documentation site's own home page does, three of them), and `querySelector` always answers\n * the first one in document order regardless of which root's own tree `node` actually lives in.\n * That made every root after the first measure its overlays against someone else's box.\n * `closest` walks up from the node itself, so each root only ever measures against its own.\n */\n measure(node: BrowserNode, into: (frame: WindowFrame) => void): void {\n const el = node.el as Element;\n const rect = el.getBoundingClientRect();\n const root = el.closest('[data-rn-root]');\n const origin = root ? root.getBoundingClientRect() : { x: 0, y: 0 };\n into({ x: rect.x - origin.x, y: rect.y - origin.y, width: rect.width, height: rect.height });\n }\n\n dispatchCommand(node: BrowserNode, name: string, args: readonly unknown[] = []): void {\n COMMANDS[name]?.(node.el as HTMLElement, args);\n }\n\n /**\n * The scoping attribute Angular's emulated encapsulation stamps on `like`, stamped on `node`,\n * or taken off again when `like` is null.\n */\n override adoptScope(node: BrowserNode, like: BrowserNode | null): void {\n const el = node.el as Element;\n for (const name of this.adopted.get(node) ?? []) el.removeAttribute(name);\n const names = like\n ? [...(like.el as Element).attributes]\n .map((attribute) => attribute.name)\n .filter((name) => name.startsWith('_ngcontent-') && !el.hasAttribute(name))\n : [];\n for (const name of names) el.setAttribute(name, '');\n this.adopted.set(node, names);\n }\n\n /** The scoping attributes `adoptScope` added to each node, which it alone takes off. */\n private readonly adopted = new WeakMap<BrowserNode, string[]>();\n\n commit(): boolean {\n // Every write above already reached the DOM synchronously; there is nothing batched to flush.\n return false;\n }\n\n get focused(): BrowserNode | null {\n if (this.focusedNode && !this.isAttached(this.focusedNode)) this.focusedNode = null;\n return this.focusedNode;\n }\n\n private isAttached(node: BrowserNode): boolean {\n return (node.el as Element).isConnected;\n }\n\n /**\n * A `require()`d numeric asset has no web analogue - there is no bundler-provided asset\n * registry this package can read at runtime - so it resolves to nothing rather than a guess.\n * A `{uri}` source, or an array of them, passes through unchanged: `props.ts`'s image handler\n * reads it directly.\n */\n resolveAsset(value: unknown): unknown {\n if (typeof value === 'number') return undefined;\n return value;\n }\n\n /**\n * A colour the app wrote is passed straight through: CSS accepts the same hex/rgb/named\n * strings RN does. `platform-color(...)`'s semantic iOS/Android names have no web colour\n * system to resolve against, so they resolve to nothing rather than to a wrong guess.\n */\n color(value: unknown): unknown {\n if (value === undefined) return undefined;\n if (typeof value === 'object' && value !== null && 'platformColor' in value) return undefined;\n return value;\n }\n\n // --- event dispatch, mirrors engine.ts's `dispatchEvent` -----------------------------------\n\n dispatchEvent(target: BrowserNode, topLevelType: string, nativeEvent: unknown): void {\n const event = new SyntheticEvent(nativeEvent, target) as ResponderEvent & SyntheticEvent;\n if (topLevelType.startsWith('topTouch'))\n this.responders.runResponder(target, topLevelType, event);\n this.propagate(target, topLevelType, event);\n }\n\n /** As on native: a listener that stops the event ends the bubble after its own node. */\n private propagate(target: BrowserNode, topLevelType: string, event: SyntheticEvent): void {\n for (\n let node: BrowserNode | null = target;\n node && !event.isPropagationStopped();\n node = DIRECT_EVENTS.has(topLevelType) ? null : node.parent\n ) {\n const listeners = node.listeners?.get(topLevelType);\n if (listeners) for (const fn of [...listeners]) fn(event);\n }\n }\n\n // --- always-on listeners, installed once per element at creation ---------------------------\n\n private wireAlwaysOnListeners(node: BrowserNode): void {\n if (node.tag === 'scroll-view' || node.tag === 'virtual-list') this.wireScroll(node);\n if (node.tag === 'text-input') this.wireTextInput(node);\n if (node.tag === 'switch') this.wireSwitch(node);\n }\n\n /**\n * `scroll` does not bubble, so this is a real per-node listener rather than a document one.\n *\n * `scrollend` is the browser saying the scroll has come to rest, whatever moved it: a wheel's\n * or a trackpad's glide, a flick, or an animated `scrollTo`. That is the moment a device reports\n * as `(momentumScrollEnd)` - iOS sends it after an animated `scrollTo` as well as after a fling -\n * and the event a paging carousel reads its page from, which never arrived here at all.\n */\n private wireScroll(node: BrowserNode): void {\n const el = node.el as HTMLElement;\n const offsets = () => ({\n contentOffset: { x: el.scrollLeft, y: el.scrollTop },\n contentSize: { width: el.scrollWidth, height: el.scrollHeight },\n layoutMeasurement: { width: el.clientWidth, height: el.clientHeight },\n contentInset: { top: 0, left: 0, bottom: 0, right: 0 },\n zoomScale: 1,\n });\n el.addEventListener('scroll', () => {\n this.responders.notifyScroll(node);\n this.dispatchEvent(node, 'topScroll', offsets());\n });\n el.addEventListener('scrollend', () => {\n this.dispatchEvent(node, 'topMomentumScrollEnd', offsets());\n });\n }\n\n /** Each field's last reported selection, kept across a swap, which keeps the selection too. */\n private readonly selections = new WeakMap<BrowserNode, string>();\n\n private wireTextInput(node: BrowserNode): void {\n const el = node.el as HTMLTextAreaElement;\n const nextCount = () => {\n const count = (this.eventCounts.get(node) ?? 0) + 1;\n this.eventCounts.set(node, count);\n return count;\n };\n el.addEventListener('input', () => {\n this.dispatchEvent(node, 'topChange', { text: el.value, eventCount: nextCount(), target: 0 });\n });\n // `(keyPress)` names a key as a device does: `Backspace`, `Enter`, or the character typed.\n // A device reports only keys that edit the field, so arrows, modifiers and shortcuts send\n // nothing, nor does a key inside an IME composition or one pressed on a read-only field.\n el.addEventListener('keydown', (event) => {\n if (event.isComposing || event.keyCode === 229 || event.metaKey || el.readOnly) return;\n if (event.ctrlKey && !event.getModifierState('AltGraph')) return;\n const { key } = event;\n if (key !== 'Backspace' && key !== 'Enter' && [...key].length !== 1) return;\n this.dispatchEvent(node, 'topKeyPress', {\n key,\n eventCount: this.eventCounts.get(node) ?? 0,\n target: 0,\n });\n });\n // A caret moved by a click, an arrow or typing, and a range selected, each report once.\n const reportSelection = () => {\n const start = el.selectionStart ?? 0;\n const end = el.selectionEnd ?? start;\n if (this.selections.get(node) === `${start}:${end}`) return;\n this.selections.set(node, `${start}:${end}`);\n this.dispatchEvent(node, 'topSelectionChange', { selection: { start, end }, target: 0 });\n };\n for (const type of ['selectionchange', 'select', 'input']) {\n el.addEventListener(type, reportSelection);\n }\n el.addEventListener('focus', () => {\n if (el.hasAttribute('data-select-on-focus')) el.select();\n });\n el.addEventListener('blur', () => {\n this.dispatchEvent(node, 'topEndEditing', {\n text: el.value,\n eventCount: nextCount(),\n target: 0,\n });\n });\n // `Enter` does what `submitBehavior` says, as on a device: `newline` inserts one, `submit`\n // submits and keeps focus, and `blurAndSubmit` submits and then lets go of the field. The\n // component resolves the default, `blurAndSubmit` on one line and `newline` on many; the\n // fallback here is the same rule, for a field whose binding has not landed yet. An `Enter`\n // that confirms an IME composition belongs to the composition, not to the field.\n el.addEventListener('keydown', (event) => {\n if (event.key !== 'Enter' || event.isComposing) return;\n const behavior =\n node.props['submitBehavior'] ??\n (el.hasAttribute('data-multiline') ? 'newline' : 'blurAndSubmit');\n if (behavior === 'newline') return;\n event.preventDefault();\n this.dispatchEvent(node, 'topSubmitEditing', {\n text: el.value,\n eventCount: nextCount(),\n target: 0,\n });\n if (behavior === 'blurAndSubmit') el.blur();\n });\n }\n\n private wireSwitch(node: BrowserNode): void {\n const el = node.el as HTMLInputElement;\n el.addEventListener('change', () => {\n this.dispatchEvent(node, 'topChange', { value: el.checked, target: 0 });\n });\n }\n\n /**\n * `topLayout` and hover, opted into once per node the first time something listens for them -\n * never torn down again, exactly as `engine.ts`'s own `EVENT_OPT_IN_PROPS` never unsets the\n * native prop it wrote either. A second listener for the same type on the same node (unusual,\n * but not forbidden) shares the one observer rather than getting a duplicate.\n */\n private wireOptIn(node: BrowserNode, topLevelType: string): void {\n const optedIn = (node.optedIn ??= new Set());\n if (optedIn.has(topLevelType)) return;\n optedIn.add(topLevelType);\n\n if (topLevelType === 'topLayout') {\n /*\n * The observer says *when*, and the bounding rect says *how big*. The size deliberately\n * does not come from the entry's `contentBoxSize`, which is what it used to come from.\n *\n * Yoga lays out border-box: a React Native view styled `width: 192` with `padding: 16` and\n * a hairline border is 192 wide, and `onLayout` reports 192. `contentBoxSize` is the CSS\n * *content* box, so the same element in a browser reported 158 - the padding and the border\n * subtracted. Every `(layout)` consumer in the library was therefore being handed a size\n * smaller than its native counterpart by however much padding the element happened to have,\n * and each one used it for something different: an accordion animated to a height that cut\n * its own padding off, and an anchored overlay both centred itself on a width it did not\n * have and decided it had room on a side where it did not, because `fits()` was asked about\n * a shorter card than the one about to be painted.\n *\n * `measure()` in this same file has always answered from `getBoundingClientRect()`, which\n * is the border box - so the engine was reporting two different sizes for one element\n * depending on which way you asked. This is the half that was wrong.\n *\n * `x`/`y` are the other half, and a different frame from `measure()`'s: `engine.ts`'s own\n * doc comment for `measure()` says it plainly - \"`(layout)` reports a frame in the parent's\n * coordinates\" - because a layout tells a view how big it is and where it sits inside\n * whatever it is stacked in, not where it is on screen. Reporting the raw viewport rect here\n * answered a question nothing asked: a consumer that reads `layout.y` as an item's offset\n * within its scrolling parent compares it against a scroll position in that same space, so\n * a viewport-relative `y` was wrong by the scroll container's own position on the page - right only for a scroll view\n * pinned at the top of an unscrolled full-page app, wrong the moment it sits lower on the\n * page or the page itself scrolls. Subtracting the immediate DOM parent's rect - never an\n * anchor comment; `browser-renderer.ts`'s `appendChild`/`insertBefore` only ever set\n * `child.parent` to a node backed by a real element - puts it back in the parent's frame.\n */\n const observer = new ResizeObserver(() => {\n const rect = (node.el as Element).getBoundingClientRect();\n const parent = node.parent?.el as Element | undefined;\n const origin = parent ? parent.getBoundingClientRect() : { x: 0, y: 0 };\n this.dispatchEvent(node, 'topLayout', {\n layout: {\n x: rect.x - origin.x,\n y: rect.y - origin.y,\n width: rect.width,\n height: rect.height,\n },\n });\n });\n observer.observe(node.el as Element);\n this.layoutObservers.set(node, observer);\n return;\n }\n if (topLevelType === 'topPointerEnter' || topLevelType === 'topPointerLeave') {\n const domName = topLevelType === 'topPointerEnter' ? 'pointerenter' : 'pointerleave';\n (node.el as Element).addEventListener(domName, () =>\n this.dispatchEvent(node, topLevelType, {}),\n );\n return;\n }\n\n /*\n * Anything else is an ordinary DOM event, bound for real.\n *\n * Without this, `renderer.listen` put the callback in the node's map and stopped: the map is\n * only ever read by `dispatchEvent`, and nothing dispatches a `topClick`. So `(click)`,\n * `(keydown)`, `(input)` and every other plain binding registered successfully and never\n * fired - including Angular's own `RouterLink`, which is why no link in the gallery navigated\n * and no `(click)` anywhere in an app would have worked.\n *\n * The name maps straight down: DOM event types are lowercase, so `topClick` is `click` and\n * `topKeyDown` is `keydown`.\n *\n * The event reaches the handler raw, not wrapped in `{ nativeEvent }`, because that is what a\n * handler written for a browser expects - `RouterLink` reads `button`, `ctrlKey` and\n * `metaKey` off it and calls `preventDefault` itself. Returning `false` from a binding\n * prevents the default, as it does in any Angular app.\n *\n * Delivered only to this node's own listeners rather than through `propagate`, and that is\n * the subtle half. `propagate` walks this package's retained tree to emulate the bubbling\n * React Native does in JavaScript. The DOM already bubbles, so a click on a child arrives at\n * an ancestor's listener by itself, and running both would call every ancestor handler twice.\n */\n if (ENGINE_EVENTS.has(topLevelType)) return;\n (node.el as Element).addEventListener(topLevelType.slice(3).toLowerCase(), (event) => {\n for (const listener of [...(node.listeners?.get(topLevelType) ?? [])]) {\n if ((listener as (value: unknown) => unknown)(event) === false) event.preventDefault();\n }\n });\n }\n\n // --- document-level listeners, shared by the whole tree ------------------------------------\n\n private installGlobalListeners(): void {\n const on = <K extends keyof DocumentEventMap>(\n type: K,\n listener: (event: DocumentEventMap[K]) => void,\n ): void => this.document.addEventListener(type, listener, { signal: this.listening.signal });\n for (const type of ['pointerdown', 'pointermove', 'pointerup', 'pointercancel'] as const) {\n on(type, (event) => this.onPointer(event, type));\n }\n on('focusin', (event) => this.onFocusChange(event, true));\n on('focusout', (event) => this.onFocusChange(event, false));\n on('keydown', (event) => this.onKey(event, true));\n on('keyup', (event) => this.onKey(event, false));\n }\n\n /** The control a held Space is pressing, released on the matching `keyup`. */\n private keyPress: BrowserNode | null = null;\n\n /**\n * Enter and Space press the focused control, as they press a `<button>`.\n *\n * A pressable is focusable and announces itself as a button, but it presses through the\n * responder negotiation, which only pointer events drove - so a keyboard user could tab to it\n * and do nothing with it. The key becomes the same touch a finger would make, on the control\n * itself, so `pressIn`, `press` and `pressOut` all fire, in order, through the same code.\n *\n * Enter presses on the way down and Space on the way up, which is the browser's own rule for a\n * button; Space is also kept from scrolling the page. A text field and a switch are left alone,\n * because the browser's own control already does the right thing with both keys.\n */\n private onKey(event: KeyboardEvent, down: boolean): void {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n const space = event.key === ' ';\n if (!down) {\n const node = this.keyPress;\n if (!space || !node) return;\n this.keyPress = null;\n this.dispatchEvent(node, 'topTouchEnd', this.keyTouch(node));\n return;\n }\n const node = this.keyTarget(event);\n if (!node) return;\n event.preventDefault();\n if (event.repeat || this.keyPress) return;\n this.dispatchEvent(node, 'topTouchStart', this.keyTouch(node));\n if (space) this.keyPress = node;\n else this.dispatchEvent(node, 'topTouchEnd', this.keyTouch(node));\n }\n\n /** The focused control a key would press, or null where the key belongs to something else. */\n private keyTarget(event: KeyboardEvent): BrowserNode | null {\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return null;\n const node = nodeOf(event.target as Element | null);\n if (!node || node.tag === 'text-input' || node.tag === 'switch') return null;\n return this.responders.responds(node) ? node : null;\n }\n\n /** A touch at the control's centre, so nothing downstream mistakes it for a drag. */\n private keyTouch(node: BrowserNode): { pageX: number; pageY: number; identifier: number } {\n const rect = (node.el as Element).getBoundingClientRect();\n return { pageX: rect.x + rect.width / 2, pageY: rect.y + rect.height / 2, identifier: -1 };\n }\n\n private onPointer(event: PointerEvent, domType: keyof typeof TOUCH_EVENT_NAMES): void {\n let target: BrowserNode | undefined;\n if (domType === 'pointerdown') {\n // A right or middle click opens a menu or a tab; only the primary button presses.\n if (event.button > 0) return;\n target = nearestNodeOf(event.target as Element | null) ?? undefined;\n if (!target || !this.owned.has(target)) return;\n this.activeTouches.set(event.pointerId, target);\n // Pins every later event in this gesture to the element the finger actually landed on,\n // regardless of where it wanders - what makes the negotiation's `target` mean the same\n // thing `topTouchMove`/`topTouchEnd` that Fabric's continuous per-finger delivery does.\n (event.target as Element).setPointerCapture?.(event.pointerId);\n } else {\n target = this.activeTouches.get(event.pointerId);\n if (!target) return;\n if (domType === 'pointerup' || domType === 'pointercancel')\n this.activeTouches.delete(event.pointerId);\n }\n this.dispatchEvent(target, TOUCH_EVENT_NAMES[domType]!, {\n pageX: event.pageX,\n pageY: event.pageY,\n identifier: event.pointerId,\n });\n }\n\n private onFocusChange(event: FocusEvent, focused: boolean): void {\n const node = nearestNodeOf(event.target as Element | null);\n if (!node || !this.owned.has(node)) return;\n if (focused) this.focusedNode = node;\n else if (this.focusedNode === node) this.focusedNode = null;\n this.dispatchEvent(node, focused ? 'topFocus' : 'topBlur', { target: 0 });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"browser-engine.js","sourceRoot":"","sources":["../src/browser-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,GAIf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,cAAc,EACd,eAAe,EACf,YAAY,EACZ,aAAa,EACb,MAAM,EACN,aAAa,GAEd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,iBAAiB,GAA2B;IAChD,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,cAAc;IAC3B,SAAS,EAAE,aAAa;IACxB,aAAa,EAAE,gBAAgB;CAChC,CAAC;AAEF,SAAS,WAAW,CAAC,EAAe,EAAE,IAAwB;IAC5D,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,IAAkB,CAAC;IAC7C,MAAM,UAAU,GAAG,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,IAAI,EAAE,CAA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aAAa,CAAC,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAE,EAAE;YACtD,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,UAAU,EAAE,KAAK,CAAC,SAAS;SAC5B,CAAC,CAAC;IACL,CAAC;IAEO,aAAa,CAAC,KAAiB,EAAE,OAAgB;QACvD,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,MAAwB,CAAC,CAAC;QAC3D,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO;QAC3C,IAAI,OAAO;YAAE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;aAChC,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI;YAAE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC5D,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;CACF","sourcesContent":["/**\n * `HostEngine` over real DOM APIs: the browser counterpart to `packages/fabric/src/engine.ts`'s\n * `Engine`.\n *\n * One instance per `mount()` call. It owns the prop/DOM translation (`props.ts`), the element\n * mapping (`elements.ts`), and the responder negotiation (`responder.ts`); this file is mostly\n * the wiring between them and the handful of DOM event listeners the whole tree shares - one\n * `pointerdown`/`pointermove`/`pointerup`/`pointercancel` set on `document` for the responder\n * system, one `focusin`/`focusout` set for `:focus` tracking, because both need to see every\n * node's events rather than each node installing its own (Fabric's own engine is exactly this\n * shape: one `registerEventHandler` callback for the whole tree, not one per view).\n *\n * `dispatchEvent` mirrors `engine.ts`'s method of the same name step for step: run the responder\n * negotiation first, then propagate to whatever `(eventName)` bindings are listening, in the\n * same two-phase order a real touch would arrive in on native.\n */\nimport {\n DIRECT_EVENTS,\n HostEngine,\n SyntheticEvent,\n type ResponderEvent,\n type ResponderHandlers,\n type WindowFrame,\n} from '@ng-native/fabric';\nimport {\n makeAnchorNode,\n makeElementNode,\n makeTextNode,\n nearestNodeOf,\n nodeOf,\n rebindElement,\n type BrowserNode,\n} from './dom-node.ts';\nimport { createDomElement, textFieldLike } from './elements.ts';\nimport { applyProp } from './props.ts';\nimport { ResponderSystem } from './responder.ts';\n\nconst TOUCH_EVENT_NAMES: Record<string, string> = {\n pointerdown: 'topTouchStart',\n pointermove: 'topTouchMove',\n pointerup: 'topTouchEnd',\n pointercancel: 'topTouchCancel',\n};\n\nfunction scrollToEnd(el: HTMLElement, args: readonly unknown[]): void {\n const [animated = true] = args as [boolean?];\n const horizontal = el.scrollWidth > el.clientWidth && el.scrollHeight <= el.clientHeight;\n el.scrollTo(\n horizontal\n ? { left: el.scrollWidth, behavior: animated ? 'smooth' : 'auto' }\n : { top: el.scrollHeight, behavior: animated ? 'smooth' : 'auto' },\n );\n}\n\n/** Focuses `field` with the caret or selection `old` had, as a field swapped in for it. */\nfunction focusLike(field: HTMLInputElement | HTMLTextAreaElement, old: typeof field): void {\n field.focus();\n const { selectionStart, selectionEnd, selectionDirection } = old;\n if (selectionStart === null || selectionEnd === null) return;\n field.setSelectionRange(selectionStart, selectionEnd, selectionDirection ?? undefined);\n}\n\nfunction setTextAndSelection(el: HTMLElement, args: readonly unknown[]): void {\n const [, text, start, end] = args as [number, string | null, number, number];\n const textarea = el as HTMLTextAreaElement;\n if (text !== null && text !== undefined) textarea.value = text;\n if (start !== -1) textarea.setSelectionRange(start, end === -1 ? start : end);\n}\n\n/**\n * View commands, by name. A lookup table for the same reason `props.ts`'s tables are one: it is\n * where a review sees which commands do something and which do not, in one place, rather than\n * spread across a `switch`'s branches.\n *\n * `flashScrollIndicators`, `zoomToRect`, `hotspotUpdate`, `setPressed`, `setNativeRefreshing`:\n * no web equivalent (a browser's scrollbar has no imperative \"flash\", pinch-zoom is not\n * scriptable, and there is no Android ripple to drive) - absent rather than a `noop` entry,\n * because unlike a prop there is no generic fallback for a command name to fall through to; an\n * absent command is already silently ignored below.\n */\nconst COMMANDS: Record<string, (el: HTMLElement, args: readonly unknown[]) => void> = {\n focus: (el) => el.focus(),\n blur: (el) => el.blur(),\n scrollTo: (el, args) => {\n const [x = 0, y = 0, animated = true] = args as [number?, number?, boolean?];\n el.scrollTo({ left: x, top: y, behavior: animated ? 'smooth' : 'auto' });\n },\n scrollToEnd,\n setTextAndSelection,\n // `<switch>` putting back a flip the app refused; the checkbox is what the user clicked.\n setValue: (el, [value]) => {\n (el as HTMLInputElement).checked = value === true;\n },\n};\n\n/**\n * The events this engine owns, which are React Native's rather than the DOM's.\n *\n * Each is either synthesised here from something else - `topLayout` from a `ResizeObserver`,\n * `topTouch*` from pointer events, `topFocus` from `focusin` - or not implemented yet. Either way\n * a handler bound to one expects React Native's `{ nativeEvent }` payload with React Native's own\n * fields in it, so they must not be wired straight to the DOM event of the same name: a\n * `scroll-view`'s `(scroll)` reads `nativeEvent.contentOffset`, and handing it a raw DOM `Event`\n * would turn a binding that quietly does nothing into one that throws on the first scroll.\n *\n * The list is the events `@ng-native/components` actually binds, found by\n * reading their host and template bindings rather than guessed. Anything outside it is a plain\n * DOM event and is bound as one.\n *\n * `topLoad` and `topError` are deliberately *not* here, though an `<image>` binds both. A\n * background image fires neither on its own, so `props.ts` loads the URL with a detached `Image()`\n * and dispatches a real DOM `load` or `error` on the element - which means there is a genuine DOM\n * event of each name to bind, and the general path is the right one. Reserving them was what left\n * a broken image URL blank rather than showing a fallback.\n */\nconst ENGINE_EVENTS = new Set([\n 'topLayout',\n 'topChange',\n 'topContentSizeChange',\n 'topRefresh',\n 'topScroll',\n 'topEndReached',\n 'topSelectionChange',\n 'topKeyPress',\n 'topMomentumScrollBegin',\n 'topMomentumScrollEnd',\n 'topTouchStart',\n 'topTouchMove',\n 'topTouchEnd',\n 'topTouchCancel',\n 'topFocus',\n 'topBlur',\n 'topPointerEnter',\n 'topPointerLeave',\n]);\n\nexport class BrowserEngine extends HostEngine {\n private readonly document: Document;\n private readonly responders = new ResponderSystem();\n private focusedNode: BrowserNode | null = null;\n /** `TextInput`'s echo protocol: a change count that only ever goes up. One counter per field. */\n private readonly eventCounts = new WeakMap<BrowserNode, number>();\n /** Mount points `wrapRoot` wrapped; see `isRoot`. */\n private readonly roots = new WeakSet<BrowserNode>();\n /**\n * The node each in-progress gesture began on, by `pointerId`, so `pointermove`/`pointerup`\n * resolve to the same node however far the finger has travelled - `setPointerCapture` keeps\n * the browser routing them there; this is what this class trusts instead of re-reading\n * `event.target`. Keyed by `pointerId` rather than holding just one, so two fingers on two\n * different controls (a phone reports multi-touch) do not clobber each other.\n */\n private readonly activeTouches = new Map<number, BrowserNode>();\n /**\n * The element nodes this engine made, and so the only ones its document listeners act for.\n *\n * Every engine listens on the one `document`, and a page can hold several - one per island, or\n * the documentation site's three roots - while `nearestNodeOf` finds a node whichever engine\n * made it. Without this, each engine delivered every focus, blur and touch in any root on the\n * page, so a text field's `(blur)` ran once per island.\n */\n private readonly owned = new WeakSet<BrowserNode>();\n /** Removes the document listeners, once the app they served is gone; see `dispose`. */\n private readonly listening: AbortController;\n\n constructor(document: Document) {\n super();\n this.document = document;\n // The document's own, so the signal is one its `addEventListener` recognises.\n this.listening = new (document.defaultView?.AbortController ?? AbortController)();\n this.installGlobalListeners();\n }\n\n /** Stop listening to the document. `mount` calls this as its app is destroyed. */\n dispose(): void {\n this.listening.abort();\n this.activeTouches.clear();\n }\n\n // --- element creation, called from BrowserRenderer ----------------------------------------\n\n createElementNode(name: string): BrowserNode {\n const el = createDomElement(this.document, name);\n const node = makeElementNode(name, el);\n this.owned.add(node);\n this.wireAlwaysOnListeners(node);\n return node;\n }\n\n createTextNode(value: string): BrowserNode {\n return makeTextNode(this.document.createTextNode(value));\n }\n\n createAnchorNode(): BrowserNode {\n return makeAnchorNode(this.document.createComment(''));\n }\n\n /**\n * Wrap an existing real element - the app's own mount point - as the tree's root node.\n *\n * `ngSkipHydration` is Angular's own opt-out, and true of every tree this engine renders: none\n * is server-rendered, so there is no markup to reuse. With hydration on, Angular reads it on a\n * root component's host element, and without it walks that element's DOM for text markers,\n * which a node is not.\n */\n wrapRoot(el: Element): BrowserNode {\n const node = makeElementNode(el.tagName.toLowerCase(), el);\n el.setAttribute('data-rn', 'root');\n el.setAttribute('ngSkipHydration', '');\n this.roots.add(node);\n this.owned.add(node);\n return node;\n }\n\n /**\n * Whether `node` is a mount point `wrapRoot` wrapped. It belongs to whoever called `mount`, not\n * to the app rendered into it, so the renderer empties it rather than removing it.\n */\n isRoot(node: BrowserNode): boolean {\n return this.roots.has(node);\n }\n\n // --- HostEngine -----------------------------------------------------------------------------\n\n setProp(node: BrowserNode, key: string, value: unknown): void {\n const clear = value === undefined || value === null;\n if (clear) {\n if (!(key in node.props)) return;\n delete node.props[key];\n } else {\n if (node.props[key] === value) return;\n node.props[key] = value;\n }\n if (key === 'multiline' && node.tag === 'text-input') this.fieldFor(node, value === true);\n applyProp(node, key, value, clear);\n }\n\n /**\n * A `<textarea>` for a multiline field and an `<input>` for a one-line one, swapped in place when\n * `multiline` arrives, which is after the element was made (see `elements.ts`).\n *\n * The new element takes the old one's attributes (inline style and scoping attributes among\n * them), its value, its focus and its selection, and the engine's own listeners are installed on it again.\n */\n private fieldFor(node: BrowserNode, multiline: boolean): void {\n const old = node.el as HTMLInputElement | HTMLTextAreaElement;\n if ((old.tagName === 'TEXTAREA') === multiline) return;\n const field = textFieldLike(old, multiline);\n // An input strips line breaks from its value, so text set before `multiline` lost them. Taken\n // from the prop again unless the user has typed since.\n const text = node.props['text'];\n if (multiline && text != null && old.value === String(text).replace(/[\\r\\n]/g, '')) {\n field.value = String(text);\n }\n const focused = this.document.activeElement === old;\n this.layoutObservers.get(node)?.disconnect();\n old.replaceWith(field);\n rebindElement(node, field);\n this.wireAlwaysOnListeners(node);\n const optedIn = node.optedIn;\n node.optedIn = null;\n for (const type of optedIn ?? []) this.wireOptIn(node, type);\n for (const key of ['secureTextEntry', 'keyboardType', 'numberOfLines']) {\n if (key in node.props) applyProp(node, key, node.props[key], false);\n }\n if (focused) focusLike(field, old);\n }\n\n /** Each node's `topLayout` observer, so a field swapped for another stops watching the old one. */\n private readonly layoutObservers = new WeakMap<BrowserNode, ResizeObserver>();\n\n setEventListener(\n node: BrowserNode,\n topLevelType: string,\n fn: (event: unknown) => void,\n ): () => void {\n const listeners = (node.listeners ??= new Map());\n let set = listeners.get(topLevelType);\n if (!set) listeners.set(topLevelType, (set = new Set()));\n set.add(fn);\n this.wireOptIn(node, topLevelType);\n return () => set!.delete(fn);\n }\n\n setResponder(node: BrowserNode, handlers: ResponderHandlers): () => void {\n return this.responders.setResponder(node, handlers);\n }\n\n /**\n * Where a node is, relative to the mount root rather than to the viewport.\n *\n * `measureInWindow` on native answers in window coordinates, and the overlay host is a\n * full-screen absolutely positioned view at the window's origin, so the two agree and an\n * anchored overlay can use one as the other. `getBoundingClientRect` answers in *viewport*\n * coordinates, and `<overlay-host>` is absolutely positioned inside the mount root - so\n * those two agree only when the root sits at the top left of an unscrolled viewport.\n *\n * That is true of a full-page app, which is why every popover in the gallery lands correctly\n * and this went unnoticed. It is false in the two cases that matter: an app mounted into a box\n * partway down a page, where every overlay is offset by the box's own position, and a document\n * that scrolls, where the offset changes as you scroll. Subtracting the root's own rect from a\n * viewport-relative one cancels the scroll term as well as the offset, since both rects move\n * together as the page scrolls - so one subtraction fixes both cases at once.\n *\n * `closest`, not `querySelector`: a page can hold more than one mounted root at a time (the\n * documentation site's own home page does, three of them), and `querySelector` always answers\n * the first one in document order regardless of which root's own tree `node` actually lives in.\n * That made every root after the first measure its overlays against someone else's box.\n * `closest` walks up from the node itself, so each root only ever measures against its own.\n */\n measure(node: BrowserNode, into: (frame: WindowFrame) => void): void {\n const el = node.el as Element;\n const rect = el.getBoundingClientRect();\n const root = el.closest('[data-rn-root]');\n const origin = root ? root.getBoundingClientRect() : { x: 0, y: 0 };\n into({ x: rect.x - origin.x, y: rect.y - origin.y, width: rect.width, height: rect.height });\n }\n\n dispatchCommand(node: BrowserNode, name: string, args: readonly unknown[] = []): void {\n COMMANDS[name]?.(node.el as HTMLElement, args);\n }\n\n /**\n * The scoping attribute Angular's emulated encapsulation stamps on `like`, stamped on `node`,\n * or taken off again when `like` is null.\n */\n override adoptScope(node: BrowserNode, like: BrowserNode | null): void {\n const el = node.el as Element;\n for (const name of this.adopted.get(node) ?? []) el.removeAttribute(name);\n const names = like\n ? [...(like.el as Element).attributes]\n .map((attribute) => attribute.name)\n .filter((name) => name.startsWith('_ngcontent-') && !el.hasAttribute(name))\n : [];\n for (const name of names) el.setAttribute(name, '');\n this.adopted.set(node, names);\n }\n\n /** The scoping attributes `adoptScope` added to each node, which it alone takes off. */\n private readonly adopted = new WeakMap<BrowserNode, string[]>();\n\n commit(): boolean {\n // Every write above already reached the DOM synchronously; there is nothing batched to flush.\n return false;\n }\n\n get focused(): BrowserNode | null {\n if (this.focusedNode && !this.isAttached(this.focusedNode)) this.focusedNode = null;\n return this.focusedNode;\n }\n\n /** A `text-input`, the `<input>` or `<textarea>` it commits as; a focused button is not one. */\n get focusedField(): BrowserNode | null {\n const node = this.focused;\n return node?.tag === 'text-input' ? node : null;\n }\n\n blurFocused(): void {\n const field = this.focusedField;\n if (field) this.dispatchCommand(field, 'blur');\n }\n\n private isAttached(node: BrowserNode): boolean {\n return (node.el as Element).isConnected;\n }\n\n /**\n * A `require()`d numeric asset has no web analogue - there is no bundler-provided asset\n * registry this package can read at runtime - so it resolves to nothing rather than a guess.\n * A `{uri}` source, or an array of them, passes through unchanged: `props.ts`'s image handler\n * reads it directly.\n */\n resolveAsset(value: unknown): unknown {\n if (typeof value === 'number') return undefined;\n return value;\n }\n\n /**\n * A colour the app wrote is passed straight through: CSS accepts the same hex/rgb/named\n * strings RN does. `platform-color(...)`'s semantic iOS/Android names have no web colour\n * system to resolve against, so they resolve to nothing rather than to a wrong guess.\n */\n color(value: unknown): unknown {\n if (value === undefined) return undefined;\n if (typeof value === 'object' && value !== null && 'platformColor' in value) return undefined;\n return value;\n }\n\n // --- event dispatch, mirrors engine.ts's `dispatchEvent` -----------------------------------\n\n dispatchEvent(target: BrowserNode, topLevelType: string, nativeEvent: unknown): void {\n const event = new SyntheticEvent(nativeEvent, target) as ResponderEvent & SyntheticEvent;\n if (topLevelType.startsWith('topTouch'))\n this.responders.runResponder(target, topLevelType, event);\n this.propagate(target, topLevelType, event);\n }\n\n /** As on native: a listener that stops the event ends the bubble after its own node. */\n private propagate(target: BrowserNode, topLevelType: string, event: SyntheticEvent): void {\n for (\n let node: BrowserNode | null = target;\n node && !event.isPropagationStopped();\n node = DIRECT_EVENTS.has(topLevelType) ? null : node.parent\n ) {\n const listeners = node.listeners?.get(topLevelType);\n if (listeners) for (const fn of [...listeners]) fn(event);\n }\n }\n\n // --- always-on listeners, installed once per element at creation ---------------------------\n\n private wireAlwaysOnListeners(node: BrowserNode): void {\n if (node.tag === 'scroll-view' || node.tag === 'virtual-list') this.wireScroll(node);\n if (node.tag === 'text-input') this.wireTextInput(node);\n if (node.tag === 'switch') this.wireSwitch(node);\n }\n\n /**\n * `scroll` does not bubble, so this is a real per-node listener rather than a document one.\n *\n * `scrollend` is the browser saying the scroll has come to rest, whatever moved it: a wheel's\n * or a trackpad's glide, a flick, or an animated `scrollTo`. That is the moment a device reports\n * as `(momentumScrollEnd)` - iOS sends it after an animated `scrollTo` as well as after a fling -\n * and the event a paging carousel reads its page from, which never arrived here at all.\n */\n private wireScroll(node: BrowserNode): void {\n const el = node.el as HTMLElement;\n const offsets = () => ({\n contentOffset: { x: el.scrollLeft, y: el.scrollTop },\n contentSize: { width: el.scrollWidth, height: el.scrollHeight },\n layoutMeasurement: { width: el.clientWidth, height: el.clientHeight },\n contentInset: { top: 0, left: 0, bottom: 0, right: 0 },\n zoomScale: 1,\n });\n el.addEventListener('scroll', () => {\n this.responders.notifyScroll(node);\n this.dispatchEvent(node, 'topScroll', offsets());\n });\n el.addEventListener('scrollend', () => {\n this.dispatchEvent(node, 'topMomentumScrollEnd', offsets());\n });\n }\n\n /** Each field's last reported selection, kept across a swap, which keeps the selection too. */\n private readonly selections = new WeakMap<BrowserNode, string>();\n\n private wireTextInput(node: BrowserNode): void {\n const el = node.el as HTMLTextAreaElement;\n const nextCount = () => {\n const count = (this.eventCounts.get(node) ?? 0) + 1;\n this.eventCounts.set(node, count);\n return count;\n };\n el.addEventListener('input', () => {\n this.dispatchEvent(node, 'topChange', { text: el.value, eventCount: nextCount(), target: 0 });\n });\n // `(keyPress)` names a key as a device does: `Backspace`, `Enter`, or the character typed.\n // A device reports only keys that edit the field, so arrows, modifiers and shortcuts send\n // nothing, nor does a key inside an IME composition or one pressed on a read-only field.\n el.addEventListener('keydown', (event) => {\n if (event.isComposing || event.keyCode === 229 || event.metaKey || el.readOnly) return;\n if (event.ctrlKey && !event.getModifierState('AltGraph')) return;\n const { key } = event;\n if (key !== 'Backspace' && key !== 'Enter' && [...key].length !== 1) return;\n this.dispatchEvent(node, 'topKeyPress', {\n key,\n eventCount: this.eventCounts.get(node) ?? 0,\n target: 0,\n });\n });\n // A caret moved by a click, an arrow or typing, and a range selected, each report once.\n const reportSelection = () => {\n const start = el.selectionStart ?? 0;\n const end = el.selectionEnd ?? start;\n if (this.selections.get(node) === `${start}:${end}`) return;\n this.selections.set(node, `${start}:${end}`);\n this.dispatchEvent(node, 'topSelectionChange', { selection: { start, end }, target: 0 });\n };\n for (const type of ['selectionchange', 'select', 'input']) {\n el.addEventListener(type, reportSelection);\n }\n el.addEventListener('focus', () => {\n if (el.hasAttribute('data-select-on-focus')) el.select();\n });\n el.addEventListener('blur', () => {\n this.dispatchEvent(node, 'topEndEditing', {\n text: el.value,\n eventCount: nextCount(),\n target: 0,\n });\n });\n // `Enter` does what `submitBehavior` says, as on a device: `newline` inserts one, `submit`\n // submits and keeps focus, and `blurAndSubmit` submits and then lets go of the field. The\n // component resolves the default, `blurAndSubmit` on one line and `newline` on many; the\n // fallback here is the same rule, for a field whose binding has not landed yet. An `Enter`\n // that confirms an IME composition belongs to the composition, not to the field.\n el.addEventListener('keydown', (event) => {\n if (event.key !== 'Enter' || event.isComposing) return;\n const behavior =\n node.props['submitBehavior'] ??\n (el.hasAttribute('data-multiline') ? 'newline' : 'blurAndSubmit');\n if (behavior === 'newline') return;\n event.preventDefault();\n this.dispatchEvent(node, 'topSubmitEditing', {\n text: el.value,\n eventCount: nextCount(),\n target: 0,\n });\n if (behavior === 'blurAndSubmit') el.blur();\n });\n }\n\n private wireSwitch(node: BrowserNode): void {\n const el = node.el as HTMLInputElement;\n el.addEventListener('change', () => {\n this.dispatchEvent(node, 'topChange', { value: el.checked, target: 0 });\n });\n }\n\n /**\n * `topLayout` and hover, opted into once per node the first time something listens for them -\n * never torn down again, exactly as `engine.ts`'s own `EVENT_OPT_IN_PROPS` never unsets the\n * native prop it wrote either. A second listener for the same type on the same node (unusual,\n * but not forbidden) shares the one observer rather than getting a duplicate.\n */\n private wireOptIn(node: BrowserNode, topLevelType: string): void {\n const optedIn = (node.optedIn ??= new Set());\n if (optedIn.has(topLevelType)) return;\n optedIn.add(topLevelType);\n\n if (topLevelType === 'topLayout') {\n /*\n * The observer says *when*, and the bounding rect says *how big*. The size deliberately\n * does not come from the entry's `contentBoxSize`, which is what it used to come from.\n *\n * Yoga lays out border-box: a React Native view styled `width: 192` with `padding: 16` and\n * a hairline border is 192 wide, and `onLayout` reports 192. `contentBoxSize` is the CSS\n * *content* box, so the same element in a browser reported 158 - the padding and the border\n * subtracted. Every `(layout)` consumer in the library was therefore being handed a size\n * smaller than its native counterpart by however much padding the element happened to have,\n * and each one used it for something different: an accordion animated to a height that cut\n * its own padding off, and an anchored overlay both centred itself on a width it did not\n * have and decided it had room on a side where it did not, because `fits()` was asked about\n * a shorter card than the one about to be painted.\n *\n * `measure()` in this same file has always answered from `getBoundingClientRect()`, which\n * is the border box - so the engine was reporting two different sizes for one element\n * depending on which way you asked. This is the half that was wrong.\n *\n * `x`/`y` are the other half, and a different frame from `measure()`'s: `engine.ts`'s own\n * doc comment for `measure()` says it plainly - \"`(layout)` reports a frame in the parent's\n * coordinates\" - because a layout tells a view how big it is and where it sits inside\n * whatever it is stacked in, not where it is on screen. Reporting the raw viewport rect here\n * answered a question nothing asked: a consumer that reads `layout.y` as an item's offset\n * within its scrolling parent compares it against a scroll position in that same space, so\n * a viewport-relative `y` was wrong by the scroll container's own position on the page - right only for a scroll view\n * pinned at the top of an unscrolled full-page app, wrong the moment it sits lower on the\n * page or the page itself scrolls. Subtracting the immediate DOM parent's rect - never an\n * anchor comment; `browser-renderer.ts`'s `appendChild`/`insertBefore` only ever set\n * `child.parent` to a node backed by a real element - puts it back in the parent's frame.\n */\n const observer = new ResizeObserver(() => {\n const rect = (node.el as Element).getBoundingClientRect();\n const parent = node.parent?.el as Element | undefined;\n const origin = parent ? parent.getBoundingClientRect() : { x: 0, y: 0 };\n this.dispatchEvent(node, 'topLayout', {\n layout: {\n x: rect.x - origin.x,\n y: rect.y - origin.y,\n width: rect.width,\n height: rect.height,\n },\n });\n });\n observer.observe(node.el as Element);\n this.layoutObservers.set(node, observer);\n return;\n }\n if (topLevelType === 'topPointerEnter' || topLevelType === 'topPointerLeave') {\n const domName = topLevelType === 'topPointerEnter' ? 'pointerenter' : 'pointerleave';\n (node.el as Element).addEventListener(domName, () =>\n this.dispatchEvent(node, topLevelType, {}),\n );\n return;\n }\n\n /*\n * Anything else is an ordinary DOM event, bound for real.\n *\n * Without this, `renderer.listen` put the callback in the node's map and stopped: the map is\n * only ever read by `dispatchEvent`, and nothing dispatches a `topClick`. So `(click)`,\n * `(keydown)`, `(input)` and every other plain binding registered successfully and never\n * fired - including Angular's own `RouterLink`, which is why no link in the gallery navigated\n * and no `(click)` anywhere in an app would have worked.\n *\n * The name maps straight down: DOM event types are lowercase, so `topClick` is `click` and\n * `topKeyDown` is `keydown`.\n *\n * The event reaches the handler raw, not wrapped in `{ nativeEvent }`, because that is what a\n * handler written for a browser expects - `RouterLink` reads `button`, `ctrlKey` and\n * `metaKey` off it and calls `preventDefault` itself. Returning `false` from a binding\n * prevents the default, as it does in any Angular app.\n *\n * Delivered only to this node's own listeners rather than through `propagate`, and that is\n * the subtle half. `propagate` walks this package's retained tree to emulate the bubbling\n * React Native does in JavaScript. The DOM already bubbles, so a click on a child arrives at\n * an ancestor's listener by itself, and running both would call every ancestor handler twice.\n */\n if (ENGINE_EVENTS.has(topLevelType)) return;\n (node.el as Element).addEventListener(topLevelType.slice(3).toLowerCase(), (event) => {\n for (const listener of [...(node.listeners?.get(topLevelType) ?? [])]) {\n if ((listener as (value: unknown) => unknown)(event) === false) event.preventDefault();\n }\n });\n }\n\n // --- document-level listeners, shared by the whole tree ------------------------------------\n\n private installGlobalListeners(): void {\n const on = <K extends keyof DocumentEventMap>(\n type: K,\n listener: (event: DocumentEventMap[K]) => void,\n ): void => this.document.addEventListener(type, listener, { signal: this.listening.signal });\n for (const type of ['pointerdown', 'pointermove', 'pointerup', 'pointercancel'] as const) {\n on(type, (event) => this.onPointer(event, type));\n }\n on('focusin', (event) => this.onFocusChange(event, true));\n on('focusout', (event) => this.onFocusChange(event, false));\n on('keydown', (event) => this.onKey(event, true));\n on('keyup', (event) => this.onKey(event, false));\n }\n\n /** The control a held Space is pressing, released on the matching `keyup`. */\n private keyPress: BrowserNode | null = null;\n\n /**\n * Enter and Space press the focused control, as they press a `<button>`.\n *\n * A pressable is focusable and announces itself as a button, but it presses through the\n * responder negotiation, which only pointer events drove - so a keyboard user could tab to it\n * and do nothing with it. The key becomes the same touch a finger would make, on the control\n * itself, so `pressIn`, `press` and `pressOut` all fire, in order, through the same code.\n *\n * Enter presses on the way down and Space on the way up, which is the browser's own rule for a\n * button; Space is also kept from scrolling the page. A text field and a switch are left alone,\n * because the browser's own control already does the right thing with both keys.\n */\n private onKey(event: KeyboardEvent, down: boolean): void {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n const space = event.key === ' ';\n if (!down) {\n const node = this.keyPress;\n if (!space || !node) return;\n this.keyPress = null;\n this.dispatchEvent(node, 'topTouchEnd', this.keyTouch(node));\n return;\n }\n const node = this.keyTarget(event);\n if (!node) return;\n event.preventDefault();\n if (event.repeat || this.keyPress) return;\n this.dispatchEvent(node, 'topTouchStart', this.keyTouch(node));\n if (space) this.keyPress = node;\n else this.dispatchEvent(node, 'topTouchEnd', this.keyTouch(node));\n }\n\n /** The focused control a key would press, or null where the key belongs to something else. */\n private keyTarget(event: KeyboardEvent): BrowserNode | null {\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return null;\n const node = nodeOf(event.target as Element | null);\n if (!node || node.tag === 'text-input' || node.tag === 'switch') return null;\n return this.responders.responds(node) ? node : null;\n }\n\n /** A touch at the control's centre, so nothing downstream mistakes it for a drag. */\n private keyTouch(node: BrowserNode): { pageX: number; pageY: number; identifier: number } {\n const rect = (node.el as Element).getBoundingClientRect();\n return { pageX: rect.x + rect.width / 2, pageY: rect.y + rect.height / 2, identifier: -1 };\n }\n\n private onPointer(event: PointerEvent, domType: keyof typeof TOUCH_EVENT_NAMES): void {\n let target: BrowserNode | undefined;\n if (domType === 'pointerdown') {\n // A right or middle click opens a menu or a tab; only the primary button presses.\n if (event.button > 0) return;\n target = nearestNodeOf(event.target as Element | null) ?? undefined;\n if (!target || !this.owned.has(target)) return;\n this.activeTouches.set(event.pointerId, target);\n // Pins every later event in this gesture to the element the finger actually landed on,\n // regardless of where it wanders - what makes the negotiation's `target` mean the same\n // thing `topTouchMove`/`topTouchEnd` that Fabric's continuous per-finger delivery does.\n (event.target as Element).setPointerCapture?.(event.pointerId);\n } else {\n target = this.activeTouches.get(event.pointerId);\n if (!target) return;\n if (domType === 'pointerup' || domType === 'pointercancel')\n this.activeTouches.delete(event.pointerId);\n }\n this.dispatchEvent(target, TOUCH_EVENT_NAMES[domType]!, {\n pageX: event.pageX,\n pageY: event.pageY,\n identifier: event.pointerId,\n });\n }\n\n private onFocusChange(event: FocusEvent, focused: boolean): void {\n const node = nearestNodeOf(event.target as Element | null);\n if (!node || !this.owned.has(node)) return;\n if (focused) this.focusedNode = node;\n else if (this.focusedNode === node) this.focusedNode = null;\n this.dispatchEvent(node, focused ? 'topFocus' : 'topBlur', { target: 0 });\n }\n}\n"]}
|
|
@@ -15,11 +15,10 @@
|
|
|
15
15
|
*
|
|
16
16
|
* `setStyle`/`removeStyle` do one thing beyond the real DOM write: they keep `node.props['style']`
|
|
17
17
|
* in sync as a plain object, mirroring `NativeRenderer`'s own `OWN_STYLES`-owned-object trick.
|
|
18
|
-
*
|
|
19
|
-
* engine - `
|
|
20
|
-
* `
|
|
21
|
-
*
|
|
22
|
-
* would read whatever was there before Angular's *first* style write, forever.
|
|
18
|
+
* Two components read `this.node.props['style']` directly rather than going through the
|
|
19
|
+
* engine - `image-background.ts` (the outer view's width/height, copied onto the
|
|
20
|
+
* absolutely-filled image), `animated-style.ts` (the style an animation frame merges into) - and
|
|
21
|
+
* without this they would read whatever was there before Angular's *first* style write, forever.
|
|
23
22
|
*/
|
|
24
23
|
import { RendererStyleFlags2, ViewEncapsulation, type Renderer2, type RendererFactory2 } from '@angular/core';
|
|
25
24
|
import { type BrowserNode } from './dom-node.ts';
|
package/dist/browser-renderer.js
CHANGED
|
@@ -15,15 +15,14 @@
|
|
|
15
15
|
*
|
|
16
16
|
* `setStyle`/`removeStyle` do one thing beyond the real DOM write: they keep `node.props['style']`
|
|
17
17
|
* in sync as a plain object, mirroring `NativeRenderer`'s own `OWN_STYLES`-owned-object trick.
|
|
18
|
-
*
|
|
19
|
-
* engine - `
|
|
20
|
-
* `
|
|
21
|
-
*
|
|
22
|
-
* would read whatever was there before Angular's *first* style write, forever.
|
|
18
|
+
* Two components read `this.node.props['style']` directly rather than going through the
|
|
19
|
+
* engine - `image-background.ts` (the outer view's width/height, copied onto the
|
|
20
|
+
* absolutely-filled image), `animated-style.ts` (the style an animation frame merges into) - and
|
|
21
|
+
* without this they would read whatever was there before Angular's *first* style write, forever.
|
|
23
22
|
*/
|
|
24
23
|
import { RendererStyleFlags2, ViewEncapsulation, } from '@angular/core';
|
|
25
24
|
import { reportUnboundFormsInput } from '@ng-native/fabric';
|
|
26
|
-
import {
|
|
25
|
+
import { letBrowserNodesPassAsDomNodes } from "./dom-node.js";
|
|
27
26
|
import { dashCase } from "./css-units.js";
|
|
28
27
|
import { writeStyleKey } from "./native-style.js";
|
|
29
28
|
/** `(touchEnd)` -> `topTouchEnd`. No alias for `press`; see `packages/platform/src/adapter.ts`. */
|
|
@@ -255,7 +254,7 @@ export class BrowserRendererFactory {
|
|
|
255
254
|
this.engine = engine;
|
|
256
255
|
this.document = document;
|
|
257
256
|
this.renderer = new BrowserRenderer(engine, document);
|
|
258
|
-
|
|
257
|
+
letBrowserNodesPassAsDomNodes();
|
|
259
258
|
}
|
|
260
259
|
/**
|
|
261
260
|
* One shared renderer for every component without styles of its own, and one per component
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-renderer.js","sourceRoot":"","sources":["../src/browser-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAGlB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAoB,MAAM,eAAe,CAAC;AAE7E,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,mGAAmG;AACnG,SAAS,YAAY,CAAC,SAAiB;IACrC,OAAO,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,GAAG,IAAI,OAAO,EAAU,CAAC;AAEzC,MAAM,OAAO,eAAe;IACjB,IAAI,GAA4B,MAA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,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,IAAI;YAAE,QAAQ,CAAC,WAAW,CAAC,IAAmB,CAAC,CAAC;QACpD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,SAAS,CAAC,EAAU,EAAE,MAAyB;QACrD,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO;QAChC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACnD,KAAK,CAAC,YAAY,CAAC,0BAA0B,EAAE,EAAE,CAAC,CAAC;QACnD,KAAK,CAAC,WAAW,GAAG,MAAM;aACvB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;aAC1E,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["/**\n * `Renderer2`/`RendererFactory2` over `BrowserEngine`, the browser counterpart to\n * `packages/platform/src/adapter.ts`'s `NativeRenderer`/`NativeRendererFactory`.\n *\n * Much smaller than that file, and for the reason its own doc comment gives: a real DOM already\n * does attribute, class and style writes, and there is no style resolver here at all - the class\n * strings Angular writes with `addClass`/`removeClass` are matched by a real stylesheet loaded\n * into the page, the way they would be in any other Angular app. What is not smaller is\n * `setProperty`/`setAttribute`: those still delegate to `BrowserEngine.setProp`, not to a raw DOM\n * write, because a component's own host bindings (`text-input.ts`'s forty-odd, `switch.ts`'s\n * handful) are *logical* props with a translation `props.ts` owns - exactly the reason\n * `NativeRenderer.setProperty` delegates to `engine.setProp` rather than writing a native prop\n * directly. `class` and `style` are the two genuine exceptions, because a browser's own cascade is\n * what resolves them and nothing here needs to get in front of that.\n *\n * `setStyle`/`removeStyle` do one thing beyond the real DOM write: they keep `node.props['style']`\n * in sync as a plain object, mirroring `NativeRenderer`'s own `OWN_STYLES`-owned-object trick.\n * Three components read `this.node.props['style']` directly rather than going through the\n * engine - `touchable-opacity.ts` (the resting opacity a fade eases back to),\n * `image-background.ts` (the outer view's width/height, copied onto the absolutely-filled\n * image), `animated-style.ts` (the style an animation frame merges into) - and without this they\n * would read whatever was there before Angular's *first* style write, forever.\n */\nimport {\n RendererStyleFlags2,\n ViewEncapsulation,\n type Renderer2,\n type RendererFactory2,\n} from '@angular/core';\nimport { reportUnboundFormsInput } from '@ng-native/fabric';\nimport { letBrowserNodesPassAsNodes, type BrowserNode } from './dom-node.ts';\nimport type { BrowserEngine } from './browser-engine.ts';\nimport { dashCase } from './css-units.ts';\nimport { writeStyleKey } from './native-style.ts';\n\n/** `(touchEnd)` -> `topTouchEnd`. No alias for `press`; see `packages/platform/src/adapter.ts`. */\nfunction topLevelType(eventName: string): string {\n return 'top' + eventName.charAt(0).toUpperCase() + eventName.slice(1);\n}\n\n/** The style objects this renderer made, and may therefore mutate in place. See the file doc. */\nconst OWN_STYLES = new WeakSet<object>();\n\nexport class BrowserRenderer implements Renderer2 {\n readonly data: Record<string, unknown> = Object.create(null);\n /** Nothing here needs teardown beyond garbage collection; matches the native adapter's null. */\n readonly destroyNode: ((node: unknown) => void) | null = null;\n\n private readonly engine: BrowserEngine;\n private readonly document: Document;\n\n constructor(engine: BrowserEngine, document: Document) {\n this.engine = engine;\n this.document = document;\n }\n\n destroy(): void {}\n\n createElement(name: string): BrowserNode {\n return this.engine.createElementNode(name);\n }\n\n createComment(): BrowserNode {\n return this.engine.createAnchorNode();\n }\n\n createText(value: string): BrowserNode {\n return this.engine.createTextNode(value);\n }\n\n appendChild(parent: BrowserNode, child: BrowserNode): void {\n this.detach(child);\n child.parent = parent;\n parent.childList.push(child);\n (parent.el as Element).appendChild(child.el);\n }\n\n insertBefore(parent: BrowserNode, child: BrowserNode, refChild: BrowserNode | null): void {\n if (!parent) return;\n this.detach(child);\n child.parent = parent;\n const at = refChild ? parent.childList.indexOf(refChild) : -1;\n if (at === -1) parent.childList.push(child);\n else parent.childList.splice(at, 0, child);\n (parent.el as Element).insertBefore(child.el, refChild?.el ?? null);\n }\n\n removeChild(parent: BrowserNode | null, child: BrowserNode): void {\n // Angular removes a root component's host element when the component is destroyed. Here that\n // element is the one `mount` was given - a `<div>` of the caller's, or an `<ng-native-island>`\n // in a host app's template - and it is not this app's to take out of the page. What was\n // rendered into it goes; the element stays, empty, for its owner.\n if (this.engine.isRoot(child)) {\n for (const node of [...child.childList]) this.removeChild(child, node);\n // A root is always an element: `wrapRoot` only ever wraps one.\n (child.el as Element).replaceChildren();\n return;\n }\n const actualParent = parent ?? child.parent;\n if (actualParent) {\n const at = actualParent.childList.indexOf(child);\n if (at !== -1) actualParent.childList.splice(at, 1);\n }\n child.el.parentNode?.removeChild(child.el);\n child.parent = null;\n }\n\n private detach(child: BrowserNode): void {\n if (child.parent) this.removeChild(child.parent, child);\n }\n\n selectRootElement(selectorOrNode: string | BrowserNode): BrowserNode {\n if (typeof selectorOrNode !== 'string') return selectorOrNode;\n const found = this.document.querySelector(selectorOrNode);\n if (!found) throw new Error(`BrowserRenderer: no element matches '${selectorOrNode}'`);\n found.textContent = '';\n return this.engine.wrapRoot(found);\n }\n\n parentNode(node: BrowserNode): BrowserNode | null {\n return node.parent;\n }\n\n nextSibling(node: BrowserNode): BrowserNode | null {\n const siblings = node.parent?.childList;\n if (!siblings) return null;\n return siblings[siblings.indexOf(node) + 1] ?? null;\n }\n\n setAttribute(node: BrowserNode, name: string, value: string): void {\n // `class` drives real CSS selector matching; nothing about it goes through `props.ts`.\n //\n // `setAttribute('class', ...)`, not `.className =`: an SVG element's `className` is a\n // read-only `SVGAnimatedString` - only `.baseVal` is writable - so a direct assignment throws\n // in strict mode (every file in this package is a module, so every file is strict mode).\n // `setAttribute` is the one spelling that commits a class list on both an `HTMLElement` and\n // an `SVGElement`, which is what a static `class=\"...\"` on an icon's `<svg>`/`<path>` needs -\n // found by every test that opens a dialog with its default close button, an icon with a\n // static class the compiler writes through this exact path.\n if (name === 'class') {\n (node.el as Element).setAttribute('class', value);\n return;\n }\n this.engine.setProp(node, name, value);\n }\n\n removeAttribute(node: BrowserNode, name: string): void {\n if (name === 'class') {\n (node.el as Element).removeAttribute('class');\n return;\n }\n this.engine.setProp(node, name, null);\n }\n\n addClass(node: BrowserNode, name: string): void {\n (node.el as Element).classList.add(name);\n }\n\n removeClass(node: BrowserNode, name: string): void {\n (node.el as Element).classList.remove(name);\n }\n\n setStyle(node: BrowserNode, style: string, value: unknown, flags?: RendererStyleFlags2): void {\n if (value === null || value === undefined) {\n this.removeStyle(node, style);\n return;\n }\n const key = styleName(style);\n const important = !!(flags && flags & RendererStyleFlags2.Important);\n this.mirrorStyle(node, key, value);\n this.writeStyle(node, key, important ? 'important' : '');\n }\n\n removeStyle(node: BrowserNode, style: string): void {\n const key = styleName(style);\n this.mirrorStyle(node, key, undefined);\n this.writeStyle(node, key, '');\n }\n\n /** From the mirror, which is the whole style: see `native-style.ts` for why one key needs it. */\n private writeStyle(node: BrowserNode, key: string, priority: string): void {\n const style = (node.props['style'] ?? {}) as Record<string, unknown>;\n writeStyleKey((node.el as HTMLElement).style, key, style, priority);\n }\n\n /** Keeps `node.props['style']` an accurate mirror of the real inline style. See the file doc. */\n private mirrorStyle(node: BrowserNode, key: string, value: unknown): void {\n const current = node.props['style'] as Record<string, unknown> | undefined;\n if (current && OWN_STYLES.has(current)) {\n if (value === undefined) delete current[key];\n else current[key] = value;\n return;\n }\n if (value === undefined && (!current || !(key in current))) return;\n const next = { ...current };\n if (value === undefined) delete next[key];\n else next[key] = value;\n OWN_STYLES.add(next);\n node.props['style'] = next;\n }\n\n setProperty(node: BrowserNode, name: string, value: unknown): void {\n // `ngDevMode`, not a build-time flag: this package ships to a browser bundler rather than\n // through Metro, so there is no `__DEV__` to fold away - `ngDevMode` is the one dev/release\n // signal Angular itself sets the same way here as it does natively. See\n // `packages/platform/src/adapter.ts`'s `NativeRenderer.setProperty` for the native check this\n // mirrors, and `@ng-native/fabric`'s `forms-inputs.ts` for the table and report both share.\n if (typeof ngDevMode !== 'undefined' && ngDevMode)\n reportUnboundFormsInput(this.engine, node, name);\n this.engine.setProp(node, name, value);\n }\n\n setValue(node: BrowserNode, value: string): void {\n node.nodeText = value;\n (node.el as Text).data = value;\n }\n\n listen(\n target: BrowserNode,\n eventName: string,\n callback: (event: unknown) => boolean | void,\n ): () => void {\n return this.engine.setEventListener(target, topLevelType(eventName), callback);\n }\n}\n\n/**\n * A component with emulated encapsulation: every element its template creates carries\n * `_ngcontent-<id>`, and its host carries `_nghost-<id>`, which is what the selectors Angular's\n * compiler rewrote (`.card[_ngcontent-%COMP%]`, `[_nghost-%COMP%]`) match. These are the\n * attributes `@angular/platform-browser`'s own emulated renderer writes, so a component's CSS is\n * scoped here exactly as in any other Angular app - and as on a device, where a component's\n * renderer only ever matches its own elements against its own sheet.\n */\nclass EmulatedRenderer extends BrowserRenderer {\n private readonly contentAttr: string;\n private readonly hostAttr: string;\n\n constructor(engine: BrowserEngine, document: Document, id: string) {\n super(engine, document);\n this.contentAttr = `_ngcontent-${id}`;\n this.hostAttr = `_nghost-${id}`;\n }\n\n applyToHost(host: BrowserNode): void {\n if (host.nodeKind === 'element') (host.el as Element).setAttribute(this.hostAttr, '');\n }\n\n override createElement(name: string): BrowserNode {\n const node = super.createElement(name);\n (node.el as Element).setAttribute(this.contentAttr, '');\n return node;\n }\n}\n\n/** The slice of Angular's component definition `createRenderer` is handed that matters here. */\ninterface ComponentDefLike {\n readonly id: string;\n readonly styles?: readonly string[];\n readonly encapsulation?: ViewEncapsulation;\n}\n\n/** The placeholder Angular's compiler writes into scoped selectors, for the renderer to resolve. */\nconst COMPONENT_ID = /%COMP%/g;\n\n/**\n * The placeholder Angular 22's compiler writes into every custom property in a component's\n * styles, `--%NS%tint`, for a renderer to fill with the app's CSS variable namespace. This host\n * has no namespace, as platform-browser has none by default, so it is filled with nothing: left\n * in, `var(--tint)` never finds `--%NS%tint` and every custom property silently does nothing.\n */\nconst CSS_VAR_NAMESPACE = /%NS%/g;\n\n/**\n * The property a style binding names. A bound custom property, `[style.--tint]`, arrives with the\n * same placeholder as `--%NS%tint`, filled with nothing for the same reason, and keeps its case:\n * `--brandTint` and `--brand-tint` are two different properties.\n */\nfunction styleName(style: string): string {\n return style.startsWith('--') ? style.replace(CSS_VAR_NAMESPACE, '') : dashCase(style);\n}\n\nexport class BrowserRendererFactory implements RendererFactory2 {\n private readonly renderer: BrowserRenderer;\n /** One renderer per component with scoped styles, because each stamps its own attribute. */\n private readonly byComponent = new Map<string, EmulatedRenderer>();\n /** Component ids whose stylesheet is already in the document. */\n private readonly styled = new Set<string>();\n private readonly document: Document;\n readonly engine: BrowserEngine;\n\n constructor(engine: BrowserEngine, document: Document) {\n this.engine = engine;\n this.document = document;\n this.renderer = new BrowserRenderer(engine, document);\n letBrowserNodesPassAsNodes();\n }\n\n /**\n * One shared renderer for every component without styles of its own, and one per component\n * with them. A component's `styles` go into the document once, the first time it renders, with\n * the compiler's `%COMP%` placeholder resolved to its id. `ViewEncapsulation.None` adds them as\n * written and needs no attributes. Shadow DOM encapsulation is treated as emulated: a native\n * view has no shadow root either, and emulated scoping is what the device's matcher does.\n *\n * The compiler already turns `Emulated` into `None` for a component with no styles, so the\n * shared renderer is still what nearly every component here gets.\n */\n createRenderer(host: unknown, type: ComponentDefLike | null): Renderer2 {\n if (!type?.styles?.length) return this.renderer;\n this.addStyles(type.id, type.styles);\n if (type.encapsulation === ViewEncapsulation.None) return this.renderer;\n\n let renderer = this.byComponent.get(type.id);\n if (!renderer) {\n renderer = new EmulatedRenderer(this.engine, this.document, type.id);\n this.byComponent.set(type.id, renderer);\n }\n if (host) renderer.applyToHost(host as BrowserNode);\n return renderer;\n }\n\n private addStyles(id: string, styles: readonly string[]): void {\n if (this.styled.has(id)) return;\n this.styled.add(id);\n const style = this.document.createElement('style');\n style.setAttribute('data-ng-native-component', id);\n style.textContent = styles\n .map((css) => css.replace(COMPONENT_ID, id).replace(CSS_VAR_NAMESPACE, ''))\n .join('\\n');\n this.document.head.appendChild(style);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"browser-renderer.js","sourceRoot":"","sources":["../src/browser-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAGlB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,6BAA6B,EAAoB,MAAM,eAAe,CAAC;AAEhF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,mGAAmG;AACnG,SAAS,YAAY,CAAC,SAAiB;IACrC,OAAO,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,GAAG,IAAI,OAAO,EAAU,CAAC;AAEzC,MAAM,OAAO,eAAe;IACjB,IAAI,GAA4B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7D,gGAAgG;IACvF,WAAW,GAAqC,IAAI,CAAC;IAE7C,MAAM,CAAgB;IACtB,QAAQ,CAAW;IAEpC,YAAY,MAAqB,EAAE,QAAkB;QACnD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,OAAO,KAAU,CAAC;IAElB,aAAa,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC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B,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACnD,KAAK,CAAC,YAAY,CAAC,0BAA0B,EAAE,EAAE,CAAC,CAAC;QACnD,KAAK,CAAC,WAAW,GAAG,MAAM;aACvB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;aAC1E,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["/**\n * `Renderer2`/`RendererFactory2` over `BrowserEngine`, the browser counterpart to\n * `packages/platform/src/adapter.ts`'s `NativeRenderer`/`NativeRendererFactory`.\n *\n * Much smaller than that file, and for the reason its own doc comment gives: a real DOM already\n * does attribute, class and style writes, and there is no style resolver here at all - the class\n * strings Angular writes with `addClass`/`removeClass` are matched by a real stylesheet loaded\n * into the page, the way they would be in any other Angular app. What is not smaller is\n * `setProperty`/`setAttribute`: those still delegate to `BrowserEngine.setProp`, not to a raw DOM\n * write, because a component's own host bindings (`text-input.ts`'s forty-odd, `switch.ts`'s\n * handful) are *logical* props with a translation `props.ts` owns - exactly the reason\n * `NativeRenderer.setProperty` delegates to `engine.setProp` rather than writing a native prop\n * directly. `class` and `style` are the two genuine exceptions, because a browser's own cascade is\n * what resolves them and nothing here needs to get in front of that.\n *\n * `setStyle`/`removeStyle` do one thing beyond the real DOM write: they keep `node.props['style']`\n * in sync as a plain object, mirroring `NativeRenderer`'s own `OWN_STYLES`-owned-object trick.\n * Two components read `this.node.props['style']` directly rather than going through the\n * engine - `image-background.ts` (the outer view's width/height, copied onto the\n * absolutely-filled image), `animated-style.ts` (the style an animation frame merges into) - and\n * without this they would read whatever was there before Angular's *first* style write, forever.\n */\nimport {\n RendererStyleFlags2,\n ViewEncapsulation,\n type Renderer2,\n type RendererFactory2,\n} from '@angular/core';\nimport { reportUnboundFormsInput } from '@ng-native/fabric';\nimport { letBrowserNodesPassAsDomNodes, type BrowserNode } from './dom-node.ts';\nimport type { BrowserEngine } from './browser-engine.ts';\nimport { dashCase } from './css-units.ts';\nimport { writeStyleKey } from './native-style.ts';\n\n/** `(touchEnd)` -> `topTouchEnd`. No alias for `press`; see `packages/platform/src/adapter.ts`. */\nfunction topLevelType(eventName: string): string {\n return 'top' + eventName.charAt(0).toUpperCase() + eventName.slice(1);\n}\n\n/** The style objects this renderer made, and may therefore mutate in place. See the file doc. */\nconst OWN_STYLES = new WeakSet<object>();\n\nexport class BrowserRenderer implements Renderer2 {\n readonly data: Record<string, unknown> = Object.create(null);\n /** Nothing here needs teardown beyond garbage collection; matches the native adapter's null. */\n readonly destroyNode: ((node: unknown) => void) | null = null;\n\n private readonly engine: BrowserEngine;\n private readonly document: Document;\n\n constructor(engine: BrowserEngine, document: Document) {\n this.engine = engine;\n this.document = document;\n }\n\n destroy(): void {}\n\n createElement(name: string): BrowserNode {\n return this.engine.createElementNode(name);\n }\n\n createComment(): BrowserNode {\n return this.engine.createAnchorNode();\n }\n\n createText(value: string): BrowserNode {\n return this.engine.createTextNode(value);\n }\n\n appendChild(parent: BrowserNode, child: BrowserNode): void {\n this.detach(child);\n child.parent = parent;\n parent.childList.push(child);\n (parent.el as Element).appendChild(child.el);\n }\n\n insertBefore(parent: BrowserNode, child: BrowserNode, refChild: BrowserNode | null): void {\n if (!parent) return;\n this.detach(child);\n child.parent = parent;\n const at = refChild ? parent.childList.indexOf(refChild) : -1;\n if (at === -1) parent.childList.push(child);\n else parent.childList.splice(at, 0, child);\n (parent.el as Element).insertBefore(child.el, refChild?.el ?? null);\n }\n\n removeChild(parent: BrowserNode | null, child: BrowserNode): void {\n // Angular removes a root component's host element when the component is destroyed. Here that\n // element is the one `mount` was given - a `<div>` of the caller's, or an `<ng-native-island>`\n // in a host app's template - and it is not this app's to take out of the page. What was\n // rendered into it goes; the element stays, empty, for its owner.\n if (this.engine.isRoot(child)) {\n for (const node of [...child.childList]) this.removeChild(child, node);\n // A root is always an element: `wrapRoot` only ever wraps one.\n (child.el as Element).replaceChildren();\n return;\n }\n const actualParent = parent ?? child.parent;\n if (actualParent) {\n const at = actualParent.childList.indexOf(child);\n if (at !== -1) actualParent.childList.splice(at, 1);\n }\n child.el.parentNode?.removeChild(child.el);\n child.parent = null;\n }\n\n private detach(child: BrowserNode): void {\n if (child.parent) this.removeChild(child.parent, child);\n }\n\n selectRootElement(selectorOrNode: string | BrowserNode): BrowserNode {\n if (typeof selectorOrNode !== 'string') return selectorOrNode;\n const found = this.document.querySelector(selectorOrNode);\n if (!found) throw new Error(`BrowserRenderer: no element matches '${selectorOrNode}'`);\n found.textContent = '';\n return this.engine.wrapRoot(found);\n }\n\n parentNode(node: BrowserNode): BrowserNode | null {\n return node.parent;\n }\n\n nextSibling(node: BrowserNode): BrowserNode | null {\n const siblings = node.parent?.childList;\n if (!siblings) return null;\n return siblings[siblings.indexOf(node) + 1] ?? null;\n }\n\n setAttribute(node: BrowserNode, name: string, value: string): void {\n // `class` drives real CSS selector matching; nothing about it goes through `props.ts`.\n //\n // `setAttribute('class', ...)`, not `.className =`: an SVG element's `className` is a\n // read-only `SVGAnimatedString` - only `.baseVal` is writable - so a direct assignment throws\n // in strict mode (every file in this package is a module, so every file is strict mode).\n // `setAttribute` is the one spelling that commits a class list on both an `HTMLElement` and\n // an `SVGElement`, which is what a static `class=\"...\"` on an icon's `<svg>`/`<path>` needs -\n // found by every test that opens a dialog with its default close button, an icon with a\n // static class the compiler writes through this exact path.\n if (name === 'class') {\n (node.el as Element).setAttribute('class', value);\n return;\n }\n this.engine.setProp(node, name, value);\n }\n\n removeAttribute(node: BrowserNode, name: string): void {\n if (name === 'class') {\n (node.el as Element).removeAttribute('class');\n return;\n }\n this.engine.setProp(node, name, null);\n }\n\n addClass(node: BrowserNode, name: string): void {\n (node.el as Element).classList.add(name);\n }\n\n removeClass(node: BrowserNode, name: string): void {\n (node.el as Element).classList.remove(name);\n }\n\n setStyle(node: BrowserNode, style: string, value: unknown, flags?: RendererStyleFlags2): void {\n if (value === null || value === undefined) {\n this.removeStyle(node, style);\n return;\n }\n const key = styleName(style);\n const important = !!(flags && flags & RendererStyleFlags2.Important);\n this.mirrorStyle(node, key, value);\n this.writeStyle(node, key, important ? 'important' : '');\n }\n\n removeStyle(node: BrowserNode, style: string): void {\n const key = styleName(style);\n this.mirrorStyle(node, key, undefined);\n this.writeStyle(node, key, '');\n }\n\n /** From the mirror, which is the whole style: see `native-style.ts` for why one key needs it. */\n private writeStyle(node: BrowserNode, key: string, priority: string): void {\n const style = (node.props['style'] ?? {}) as Record<string, unknown>;\n writeStyleKey((node.el as HTMLElement).style, key, style, priority);\n }\n\n /** Keeps `node.props['style']` an accurate mirror of the real inline style. See the file doc. */\n private mirrorStyle(node: BrowserNode, key: string, value: unknown): void {\n const current = node.props['style'] as Record<string, unknown> | undefined;\n if (current && OWN_STYLES.has(current)) {\n if (value === undefined) delete current[key];\n else current[key] = value;\n return;\n }\n if (value === undefined && (!current || !(key in current))) return;\n const next = { ...current };\n if (value === undefined) delete next[key];\n else next[key] = value;\n OWN_STYLES.add(next);\n node.props['style'] = next;\n }\n\n setProperty(node: BrowserNode, name: string, value: unknown): void {\n // `ngDevMode`, not a build-time flag: this package ships to a browser bundler rather than\n // through Metro, so there is no `__DEV__` to fold away - `ngDevMode` is the one dev/release\n // signal Angular itself sets the same way here as it does natively. See\n // `packages/platform/src/adapter.ts`'s `NativeRenderer.setProperty` for the native check this\n // mirrors, and `@ng-native/fabric`'s `forms-inputs.ts` for the table and report both share.\n if (typeof ngDevMode !== 'undefined' && ngDevMode)\n reportUnboundFormsInput(this.engine, node, name);\n this.engine.setProp(node, name, value);\n }\n\n setValue(node: BrowserNode, value: string): void {\n node.nodeText = value;\n (node.el as Text).data = value;\n }\n\n listen(\n target: BrowserNode,\n eventName: string,\n callback: (event: unknown) => boolean | void,\n ): () => void {\n return this.engine.setEventListener(target, topLevelType(eventName), callback);\n }\n}\n\n/**\n * A component with emulated encapsulation: every element its template creates carries\n * `_ngcontent-<id>`, and its host carries `_nghost-<id>`, which is what the selectors Angular's\n * compiler rewrote (`.card[_ngcontent-%COMP%]`, `[_nghost-%COMP%]`) match. These are the\n * attributes `@angular/platform-browser`'s own emulated renderer writes, so a component's CSS is\n * scoped here exactly as in any other Angular app - and as on a device, where a component's\n * renderer only ever matches its own elements against its own sheet.\n */\nclass EmulatedRenderer extends BrowserRenderer {\n private readonly contentAttr: string;\n private readonly hostAttr: string;\n\n constructor(engine: BrowserEngine, document: Document, id: string) {\n super(engine, document);\n this.contentAttr = `_ngcontent-${id}`;\n this.hostAttr = `_nghost-${id}`;\n }\n\n applyToHost(host: BrowserNode): void {\n if (host.nodeKind === 'element') (host.el as Element).setAttribute(this.hostAttr, '');\n }\n\n override createElement(name: string): BrowserNode {\n const node = super.createElement(name);\n (node.el as Element).setAttribute(this.contentAttr, '');\n return node;\n }\n}\n\n/** The slice of Angular's component definition `createRenderer` is handed that matters here. */\ninterface ComponentDefLike {\n readonly id: string;\n readonly styles?: readonly string[];\n readonly encapsulation?: ViewEncapsulation;\n}\n\n/** The placeholder Angular's compiler writes into scoped selectors, for the renderer to resolve. */\nconst COMPONENT_ID = /%COMP%/g;\n\n/**\n * The placeholder Angular 22's compiler writes into every custom property in a component's\n * styles, `--%NS%tint`, for a renderer to fill with the app's CSS variable namespace. This host\n * has no namespace, as platform-browser has none by default, so it is filled with nothing: left\n * in, `var(--tint)` never finds `--%NS%tint` and every custom property silently does nothing.\n */\nconst CSS_VAR_NAMESPACE = /%NS%/g;\n\n/**\n * The property a style binding names. A bound custom property, `[style.--tint]`, arrives with the\n * same placeholder as `--%NS%tint`, filled with nothing for the same reason, and keeps its case:\n * `--brandTint` and `--brand-tint` are two different properties.\n */\nfunction styleName(style: string): string {\n return style.startsWith('--') ? style.replace(CSS_VAR_NAMESPACE, '') : dashCase(style);\n}\n\nexport class BrowserRendererFactory implements RendererFactory2 {\n private readonly renderer: BrowserRenderer;\n /** One renderer per component with scoped styles, because each stamps its own attribute. */\n private readonly byComponent = new Map<string, EmulatedRenderer>();\n /** Component ids whose stylesheet is already in the document. */\n private readonly styled = new Set<string>();\n private readonly document: Document;\n readonly engine: BrowserEngine;\n\n constructor(engine: BrowserEngine, document: Document) {\n this.engine = engine;\n this.document = document;\n this.renderer = new BrowserRenderer(engine, document);\n letBrowserNodesPassAsDomNodes();\n }\n\n /**\n * One shared renderer for every component without styles of its own, and one per component\n * with them. A component's `styles` go into the document once, the first time it renders, with\n * the compiler's `%COMP%` placeholder resolved to its id. `ViewEncapsulation.None` adds them as\n * written and needs no attributes. Shadow DOM encapsulation is treated as emulated: a native\n * view has no shadow root either, and emulated scoping is what the device's matcher does.\n *\n * The compiler already turns `Emulated` into `None` for a component with no styles, so the\n * shared renderer is still what nearly every component here gets.\n */\n createRenderer(host: unknown, type: ComponentDefLike | null): Renderer2 {\n if (!type?.styles?.length) return this.renderer;\n this.addStyles(type.id, type.styles);\n if (type.encapsulation === ViewEncapsulation.None) return this.renderer;\n\n let renderer = this.byComponent.get(type.id);\n if (!renderer) {\n renderer = new EmulatedRenderer(this.engine, this.document, type.id);\n this.byComponent.set(type.id, renderer);\n }\n if (host) renderer.applyToHost(host as BrowserNode);\n return renderer;\n }\n\n private addStyles(id: string, styles: readonly string[]): void {\n if (this.styled.has(id)) return;\n this.styled.add(id);\n const style = this.document.createElement('style');\n style.setAttribute('data-ng-native-component', id);\n style.textContent = styles\n .map((css) => css.replace(COMPONENT_ID, id).replace(CSS_VAR_NAMESPACE, ''))\n .join('\\n');\n this.document.head.appendChild(style);\n }\n}\n"]}
|
package/dist/dom-node.d.ts
CHANGED
|
@@ -51,12 +51,15 @@ export interface BrowserNode extends HostNode {
|
|
|
51
51
|
*/
|
|
52
52
|
optedIn: Set<string> | null;
|
|
53
53
|
}
|
|
54
|
-
export declare function
|
|
54
|
+
export declare function letBrowserNodesPassAsDomNodes(): void;
|
|
55
55
|
export declare function makeElementNode(name: string, el: Element): BrowserNode;
|
|
56
56
|
export declare function makeTextNode(text: Text): BrowserNode;
|
|
57
57
|
/** Angular's `@if`/`@for`/`ViewContainerRef` markers, backed by a real `Comment`. */
|
|
58
58
|
export declare function makeAnchorNode(comment: Comment): BrowserNode;
|
|
59
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Puts `el` in place of the element `node` wraps, so `nodeOf` finds the node from either, and moves
|
|
61
|
+
* the listeners and observations added through `node` from the old element to `el`.
|
|
62
|
+
*/
|
|
60
63
|
export declare function rebindElement(node: BrowserNode, el: Element): void;
|
|
61
64
|
/** The `BrowserNode` a real DOM node was created with, or `null` for one this package did not make. */
|
|
62
65
|
export declare function nodeOf(el: Element | Text | Comment | null): BrowserNode | null;
|
package/dist/dom-node.js
CHANGED
|
@@ -2,25 +2,140 @@
|
|
|
2
2
|
const registry = new WeakMap();
|
|
3
3
|
const made = new WeakSet();
|
|
4
4
|
const answered = new WeakSet();
|
|
5
|
-
export function
|
|
6
|
-
const
|
|
7
|
-
|
|
5
|
+
export function letBrowserNodesPassAsDomNodes() {
|
|
6
|
+
const scope = globalThis;
|
|
7
|
+
letPass(scope.Node, (value) => made.has(value));
|
|
8
|
+
letPass(scope.Element, (value) => made.has(value) && value.nodeKind === 'element');
|
|
9
|
+
letBrowserNodesBeObserved();
|
|
10
|
+
}
|
|
11
|
+
function letPass(target, ours) {
|
|
12
|
+
if (typeof target !== 'function' || answered.has(target))
|
|
8
13
|
return;
|
|
9
|
-
answered.add(
|
|
10
|
-
const own =
|
|
11
|
-
Object.defineProperty(
|
|
14
|
+
answered.add(target);
|
|
15
|
+
const own = target[Symbol.hasInstance];
|
|
16
|
+
Object.defineProperty(target, Symbol.hasInstance, {
|
|
12
17
|
configurable: true,
|
|
13
18
|
value(value) {
|
|
14
|
-
return (this ===
|
|
19
|
+
return (this === target && ours(value)) || own.call(this, value);
|
|
15
20
|
},
|
|
16
21
|
});
|
|
17
22
|
}
|
|
23
|
+
function unwrap(target) {
|
|
24
|
+
return made.has(target) ? target.el : target;
|
|
25
|
+
}
|
|
26
|
+
const observedBy = new WeakMap();
|
|
27
|
+
function letBrowserNodesBeObserved() {
|
|
28
|
+
const scope = globalThis;
|
|
29
|
+
const Native = scope.IntersectionObserver;
|
|
30
|
+
if (typeof Native !== 'function' || answered.has(Native))
|
|
31
|
+
return;
|
|
32
|
+
const asSeen = (wrapped, entry) => {
|
|
33
|
+
const node = wrapped.get(entry.target);
|
|
34
|
+
if (!node)
|
|
35
|
+
return entry;
|
|
36
|
+
return {
|
|
37
|
+
time: entry.time,
|
|
38
|
+
rootBounds: entry.rootBounds,
|
|
39
|
+
boundingClientRect: entry.boundingClientRect,
|
|
40
|
+
intersectionRect: entry.intersectionRect,
|
|
41
|
+
intersectionRatio: entry.intersectionRatio,
|
|
42
|
+
isIntersecting: entry.isIntersecting,
|
|
43
|
+
target: node,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
class Observer extends Native {
|
|
47
|
+
wrapped = new WeakMap();
|
|
48
|
+
constructor(callback, options) {
|
|
49
|
+
super((entries, observer) => callback(entries.map((entry) => asSeen(observer.wrapped, entry)), observer), options);
|
|
50
|
+
}
|
|
51
|
+
observe(target) {
|
|
52
|
+
const el = unwrap(target);
|
|
53
|
+
if (el !== target) {
|
|
54
|
+
const node = target;
|
|
55
|
+
this.wrapped.set(el, node);
|
|
56
|
+
let observers = observedBy.get(node);
|
|
57
|
+
if (!observers)
|
|
58
|
+
observedBy.set(node, (observers = new Set()));
|
|
59
|
+
observers.add(this);
|
|
60
|
+
}
|
|
61
|
+
else
|
|
62
|
+
this.wrapped.delete(el);
|
|
63
|
+
super.observe(el);
|
|
64
|
+
}
|
|
65
|
+
unobserve(target) {
|
|
66
|
+
const el = unwrap(target);
|
|
67
|
+
this.wrapped.delete(el);
|
|
68
|
+
super.unobserve(el);
|
|
69
|
+
}
|
|
70
|
+
disconnect() {
|
|
71
|
+
this.wrapped = new WeakMap();
|
|
72
|
+
super.disconnect();
|
|
73
|
+
}
|
|
74
|
+
takeRecords() {
|
|
75
|
+
return super.takeRecords().map((entry) => asSeen(this.wrapped, entry));
|
|
76
|
+
}
|
|
77
|
+
moveTo(node, from, to) {
|
|
78
|
+
if (this.wrapped.get(from) !== node)
|
|
79
|
+
return false;
|
|
80
|
+
this.unobserve(from);
|
|
81
|
+
this.observe(to);
|
|
82
|
+
this.wrapped.set(to, node);
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
answered.add(Observer);
|
|
87
|
+
scope.IntersectionObserver = Observer;
|
|
88
|
+
}
|
|
89
|
+
const addedTo = new WeakMap();
|
|
90
|
+
const captures = (options) => typeof options === 'boolean' ? options : options?.capture === true;
|
|
91
|
+
function addEventListener(type, listener, options) {
|
|
92
|
+
const capture = captures(options);
|
|
93
|
+
let added = addedTo.get(this);
|
|
94
|
+
if (!added)
|
|
95
|
+
addedTo.set(this, (added = []));
|
|
96
|
+
if (added.some((a) => a.type === type && a.listener === listener && a.capture === capture)) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const signal = typeof options === 'object' ? options.signal : undefined;
|
|
100
|
+
if (signal?.aborted)
|
|
101
|
+
return;
|
|
102
|
+
const list = added;
|
|
103
|
+
const forget = () => {
|
|
104
|
+
const at = list.indexOf(entry);
|
|
105
|
+
if (at !== -1)
|
|
106
|
+
list.splice(at, 1);
|
|
107
|
+
signal?.removeEventListener('abort', forget);
|
|
108
|
+
};
|
|
109
|
+
// A `once` listener is forgotten before it runs, so a swap never brings it back: not when it
|
|
110
|
+
// stops the event, and not when it swaps the element itself.
|
|
111
|
+
const registered = typeof options === 'object' && options.once === true
|
|
112
|
+
? function (event) {
|
|
113
|
+
forget();
|
|
114
|
+
if (typeof listener === 'function')
|
|
115
|
+
listener.call(this, event);
|
|
116
|
+
else
|
|
117
|
+
listener.handleEvent(event);
|
|
118
|
+
}
|
|
119
|
+
: listener;
|
|
120
|
+
const entry = { type, listener, options, capture, registered, forget };
|
|
121
|
+
list.push(entry);
|
|
122
|
+
signal?.addEventListener('abort', forget);
|
|
123
|
+
this.el.addEventListener(type, registered, options);
|
|
124
|
+
}
|
|
125
|
+
function removeEventListener(type, listener, options) {
|
|
126
|
+
const capture = captures(options);
|
|
127
|
+
const added = addedTo
|
|
128
|
+
.get(this)
|
|
129
|
+
?.find((a) => a.type === type && a.listener === listener && a.capture === capture);
|
|
130
|
+
this.el.removeEventListener(type, added?.registered ?? listener, options);
|
|
131
|
+
added?.forget();
|
|
132
|
+
}
|
|
18
133
|
/**
|
|
19
134
|
* The prototype of every element node. Angular's development build reports a binding as an unknown
|
|
20
135
|
* property (NG0303) unless `name in element` is true, and every binding on an element here goes to
|
|
21
136
|
* `setProperty`, whatever its name.
|
|
22
137
|
*/
|
|
23
|
-
const anyProperty = new Proxy({}, { has: (_, name) => typeof name === 'string' });
|
|
138
|
+
const anyProperty = new Proxy({ addEventListener, removeEventListener }, { has: (_, name) => typeof name === 'string' });
|
|
24
139
|
/**
|
|
25
140
|
* The SVG names whose `fill`/`stroke` need a seeded `props` entry from the moment they are
|
|
26
141
|
* created - see the block below for why. `svg-line` is left out: a `<line>` has no fill of its
|
|
@@ -113,11 +228,24 @@ export function makeAnchorNode(comment) {
|
|
|
113
228
|
made.add(node);
|
|
114
229
|
return node;
|
|
115
230
|
}
|
|
116
|
-
/**
|
|
231
|
+
/**
|
|
232
|
+
* Puts `el` in place of the element `node` wraps, so `nodeOf` finds the node from either, and moves
|
|
233
|
+
* the listeners and observations added through `node` from the old element to `el`.
|
|
234
|
+
*/
|
|
117
235
|
export function rebindElement(node, el) {
|
|
118
|
-
|
|
236
|
+
const old = node.el;
|
|
237
|
+
registry.delete(old);
|
|
119
238
|
node.el = el;
|
|
120
239
|
registry.set(el, node);
|
|
240
|
+
for (const added of addedTo.get(node) ?? []) {
|
|
241
|
+
old.removeEventListener(added.type, added.registered, added.capture);
|
|
242
|
+
el.addEventListener(added.type, added.registered, added.options);
|
|
243
|
+
}
|
|
244
|
+
const observers = observedBy.get(node);
|
|
245
|
+
for (const observer of observers ?? []) {
|
|
246
|
+
if (!observer.moveTo(node, old, el))
|
|
247
|
+
observers.delete(observer);
|
|
248
|
+
}
|
|
121
249
|
}
|
|
122
250
|
/** The `BrowserNode` a real DOM node was created with, or `null` for one this package did not make. */
|
|
123
251
|
export function nodeOf(el) {
|
package/dist/dom-node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-node.js","sourceRoot":"","sources":["../src/dom-node.ts"],"names":[],"mappings":"AAwDA,mGAAmG;AACnG,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAyC,CAAC;AAEtE,MAAM,IAAI,GAAG,IAAI,OAAO,EAAU,CAAC;AACnC,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAU,CAAC;AAIvC,MAAM,UAAU,0BAA0B;IACxC,MAAM,IAAI,GAAI,UAAqC,CAAC,IAAI,CAAC;IACzD,IAAI,OAAO,IAAI,KAAK,UAAU,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO;IAC7D,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnB,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACrC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE;QAC9C,YAAY,EAAE,IAAI;QAClB,KAAK,CAAoB,KAAc;YACrC,OAAO,CAAC,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,KAAe,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC/E,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,WAAW,GAAG,IAAI,KAAK,CAAC,E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AE,CAAC;IACnD,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,MAAM,CAAC,EAAmC;IACxD,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,EAAkB;IAC9C,KAAK,IAAI,OAAO,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAChE,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;IACxB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,MAAM,CAAC,IAAiB;IACtC,MAAM,IAAI,GAAkB,EAAE,CAAC;IAC/B,KAAK,IAAI,OAAO,GAAuB,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM;QAC5E,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;AACxB,CAAC","sourcesContent":["/**\n * The retained node this package hands Angular as `ElementRef.nativeElement`, and the thing every\n * `HostEngine` method actually operates on.\n *\n * `packages/fabric/src/engine.ts`'s `EngineNode` is not reusable here (its constructor-free shape\n * still carries Fabric-only bookkeeping - `committed`, `styleCache`, `templateSheet`...), but the shared\n * packages never ask for that: they ask for `HostNode`'s five fields, plus whatever a component\n * reads directly off `this.node` after `inject(ElementRef).nativeElement as EngineNode` casts it\n * back. Grepping every such read (`view-base.ts`, `pressable.ts`'s `TouchableBase`, `scroll-view.ts`,\n * `select.ts`'s `textOf`) turns up exactly `nodeKind`, `props`, `nodeText`, `childList` and `parent` - so a\n * class that implements `HostNode` honestly, backed by a real DOM node, satisfies every one of\n * them without a cast.\n *\n * `childList`/`parent` are maintained by hand rather than read live off the DOM (`el.parentElement`,\n * `el.childNodes`) for the same reason `Engine` keeps its own tree: a live DOM walk would have to\n * filter out nodes this package did not create (there are none today, but a consumer's own\n * `document.createElement` inside a projected template is not this package's to assume against),\n * and `select.ts`'s `textOf` recursion wants exactly the nodes Angular put here, in order.\n */\nimport type { HostNode } from '@ng-native/fabric';\n\nexport type BrowserNodeKind = 'element' | 'text' | 'anchor';\n\nexport interface BrowserNode extends HostNode {\n readonly nodeKind: BrowserNodeKind;\n /** The real DOM node this wraps. An `Element` for `element`, a `Text` for `text`. */\n readonly el: Element | Text | Comment;\n /** Lowercase template spelling, e.g. `view`. Mirrors `EngineNode.tag`; never the DOM tag. */\n readonly tag: string;\n /** `tag` again on an element, for Angular 22.0, which reads it on a component's host element. */\n readonly tagName?: string;\n /**\n * The wrapped element's attributes, on an element, for Angular's hydration. Once an app on the\n * page calls `provideClientHydration()`, every component's host element is asked for\n * `ngSkipHydration` and `ngh`, an island's included, whatever renderer created it. See\n * `BrowserEngine.wrapRoot` for the answer that keeps hydration out of an island.\n */\n readonly hasAttribute?: (this: BrowserNode, name: string) => boolean;\n readonly getAttribute?: (this: BrowserNode, name: string) => string | null;\n props: Record<string, unknown>;\n nodeText: string;\n childList: BrowserNode[];\n parent: BrowserNode | null;\n /**\n * Registered listeners, by top-level type (`topTouchStart`, `topChange`, ...). `null` until\n * the first one, so a node nothing ever listens to costs one field rather than one `Map`.\n */\n listeners: Map<string, Set<(event: unknown) => void>> | null;\n /**\n * Which opt-in event types (`topLayout`, `topPointerEnter`, `topPointerLeave`) already have\n * their real DOM listener installed - `browser-engine.ts`'s `wireOptIn` guard. `null` until\n * the first one, matching `listeners` above.\n */\n optedIn: Set<string> | null;\n}\n\n/** `event.target`, and anything else holding a real DOM node, back to the `BrowserNode` for it. */\nconst registry = new WeakMap<Element | Text | Comment, BrowserNode>();\n\nconst made = new WeakSet<object>();\nconst answered = new WeakSet<object>();\n\ntype Constructor = abstract new (...args: never[]) => object;\n\nexport function letBrowserNodesPassAsNodes(): void {\n const node = (globalThis as { Node?: Constructor }).Node;\n if (typeof node !== 'function' || answered.has(node)) return;\n answered.add(node);\n const own = node[Symbol.hasInstance];\n Object.defineProperty(node, Symbol.hasInstance, {\n configurable: true,\n value(this: Constructor, value: unknown): boolean {\n return (this === node && made.has(value as object)) || own.call(this, value);\n },\n });\n}\n\n/**\n * The prototype of every element node. Angular's development build reports a binding as an unknown\n * property (NG0303) unless `name in element` is true, and every binding on an element here goes to\n * `setProperty`, whatever its name.\n */\nconst anyProperty = new Proxy({}, { has: (_, name) => typeof name === 'string' });\n\n/**\n * The SVG names whose `fill`/`stroke` need a seeded `props` entry from the moment they are\n * created - see the block below for why. `svg-line` is left out: a `<line>` has no fill of its\n * own to paint (react-native-svg's `Line` never reads `fill` either), so there is nothing an\n * explicit `fill=\"none\"` there could mean.\n */\nconst SVG_BRUSH_ELEMENTS = new Set([\n 'svg-g',\n 'svg-path',\n 'svg-circle',\n 'svg-ellipse',\n 'svg-rect',\n 'svg-text',\n 'svg-tspan',\n]);\n\nfunction hasAttribute(this: BrowserNode, name: string): boolean {\n return (this.el as Element).hasAttribute(name);\n}\n\nfunction getAttribute(this: BrowserNode, name: string): string | null {\n return (this.el as Element).getAttribute(name);\n}\n\nexport function makeElementNode(name: string, el: Element): BrowserNode {\n const props: Record<string, unknown> = {};\n // `packages/icons/src/svg-props.ts`'s `brushOf` turns a literal `fill=\"none\"`/`stroke=\"none\"`\n // into `null` - a real, meaningful value (\"paint nothing\"), not an absent one. But\n // `BrowserEngine.setProp` treats `null` exactly like `undefined` on a key it has never seen\n // before: `if (!(key in node.props)) return;`, its fast path for \"nothing to remove, so nothing\n // changed\". That path is right for almost everything a `null` prop could mean, and wrong here -\n // it would skip `applyProp` entirely on a chart line's `fill=\"none\"` (`chart-line.ts`,\n // `chart-area.ts`), leaving the attribute unset, and an unset `fill` defaults to opaque black in\n // a browser (the real SVG initial value) rather than to unpainted (what react-native-svg's own\n // `propList` convention, and every one of these charts, is relying on). Seeding the key here -\n // present, value `undefined` - costs nothing on a shape that never touches the prop again, and\n // is what lets that first `null` reach `props.ts`'s real translation instead of being dropped by\n // the fast path. See `props.ts`'s `applyBrush` for the other half: it is what turns a seeded\n // key's `null` into a written `fill=\"none\"`/`stroke=\"none\"` rather than a removed attribute.\n if (SVG_BRUSH_ELEMENTS.has(name)) {\n props['fill'] = undefined;\n props['stroke'] = undefined;\n }\n const node: BrowserNode = {\n nodeKind: 'element',\n el,\n tag: name,\n tagName: name,\n hasAttribute,\n getAttribute,\n props,\n nodeText: '',\n childList: [],\n parent: null,\n listeners: null,\n optedIn: null,\n };\n Object.setPrototypeOf(node, anyProperty);\n registry.set(el, node);\n made.add(node);\n return node;\n}\n\nexport function makeTextNode(text: Text): BrowserNode {\n const node: BrowserNode = {\n nodeKind: 'text',\n el: text,\n tag: '#text',\n props: {},\n nodeText: text.data,\n childList: [],\n parent: null,\n listeners: null,\n optedIn: null,\n };\n registry.set(text, node);\n made.add(node);\n return node;\n}\n\n/** Angular's `@if`/`@for`/`ViewContainerRef` markers, backed by a real `Comment`. */\nexport function makeAnchorNode(comment: Comment): BrowserNode {\n const node: BrowserNode = {\n nodeKind: 'anchor',\n el: comment,\n tag: '#anchor',\n props: {},\n nodeText: '',\n childList: [],\n parent: null,\n listeners: null,\n optedIn: null,\n };\n registry.set(comment, node);\n made.add(node);\n return node;\n}\n\n/** Puts `el` in place of the element `node` wraps, so `nodeOf` finds the node from either. */\nexport function rebindElement(node: BrowserNode, el: Element): void {\n registry.delete(node.el);\n (node as { el: Element | Text | Comment }).el = el;\n registry.set(el, node);\n}\n\n/** The `BrowserNode` a real DOM node was created with, or `null` for one this package did not make. */\nexport function nodeOf(el: Element | Text | Comment | null): BrowserNode | null {\n return el ? (registry.get(el) ?? null) : null;\n}\n\n/**\n * The nearest `BrowserNode` starting at a real `Element` and walking up `parentElement`.\n *\n * Used to resolve `event.target` for events this package listens for on `document` rather than\n * per-node (the responder system's pointer events, focus/blur, selection change): the physical\n * hit is always a real element this package created, but it is not always one with its own\n * listeners, so the search has to climb past any that are not tracked before it gets to `body`\n * and turns up nothing.\n */\nexport function nearestNodeOf(el: Element | null): BrowserNode | null {\n for (let current = el; current; current = current.parentElement) {\n const node = registry.get(current);\n if (node) return node;\n }\n return null;\n}\n\n/** Root-first path from the tree's root to `node`, inclusive. Mirrors `Engine`'s own `pathTo`. */\nexport function pathTo(node: BrowserNode): BrowserNode[] {\n const path: BrowserNode[] = [];\n for (let current: BrowserNode | null = node; current; current = current.parent)\n path.push(current);\n return path.reverse();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dom-node.js","sourceRoot":"","sources":["../src/dom-node.ts"],"names":[],"mappings":"AAwDA,mGAAmG;AACnG,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAyC,CAAC;AAEtE,MAAM,IAAI,GAAG,IAAI,OAAO,EAAU,CAAC;AACnC,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAU,CAAC;AAIvC,MAAM,UAAU,6BAA6B;IAC3C,MAAM,KAAK,GAAG,UAA2D,CAAC;IAC1E,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAe,CAAC,CAAC,CAAC;IAC1D,OAAO,CACL,KAAK,CAAC,OAAO,EACb,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAe,CAAC,IAAK,KAAqB,CAAC,QAAQ,KAAK,SAAS,CACtF,CAAC;IACF,yBAAyB,EAAE,CAAC;AAC9B,CAAC;AAED,SAAS,OAAO,CAAC,MAA+B,EAAE,IAAiC;IACjF,IAAI,OAAO,MAAM,KAAK,UAAU,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC;QAAE,OAAO;IACjE,QAA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AC;IACvC,KAAK,MAAM,QAAQ,IAAI,SAAS,IAAI,EAAE,EAAE,CAAC;QACvC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;YAAE,SAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,MAAM,CAAC,EAAmC;IACxD,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,EAAkB;IAC9C,KAAK,IAAI,OAAO,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAChE,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;IACxB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,MAAM,CAAC,IAAiB;IACtC,MAAM,IAAI,GAAkB,EAAE,CAAC;IAC/B,KAAK,IAAI,OAAO,GAAuB,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM;QAC5E,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;AACxB,CAAC","sourcesContent":["/**\n * The retained node this package hands Angular as `ElementRef.nativeElement`, and the thing every\n * `HostEngine` method actually operates on.\n *\n * `packages/fabric/src/engine.ts`'s `EngineNode` is not reusable here (its constructor-free shape\n * still carries Fabric-only bookkeeping - `committed`, `styleCache`, `templateSheet`...), but the shared\n * packages never ask for that: they ask for `HostNode`'s five fields, plus whatever a component\n * reads directly off `this.node` after `inject(ElementRef).nativeElement as EngineNode` casts it\n * back. Grepping every such read (`view-base.ts`, `pressable.ts`'s `TouchableBase`, `scroll-view.ts`,\n * `select.ts`'s `textOf`) turns up exactly `nodeKind`, `props`, `nodeText`, `childList` and `parent` - so a\n * class that implements `HostNode` honestly, backed by a real DOM node, satisfies every one of\n * them without a cast.\n *\n * `childList`/`parent` are maintained by hand rather than read live off the DOM (`el.parentElement`,\n * `el.childNodes`) for the same reason `Engine` keeps its own tree: a live DOM walk would have to\n * filter out nodes this package did not create (there are none today, but a consumer's own\n * `document.createElement` inside a projected template is not this package's to assume against),\n * and `select.ts`'s `textOf` recursion wants exactly the nodes Angular put here, in order.\n */\nimport type { HostNode } from '@ng-native/fabric';\n\nexport type BrowserNodeKind = 'element' | 'text' | 'anchor';\n\nexport interface BrowserNode extends HostNode {\n readonly nodeKind: BrowserNodeKind;\n /** The real DOM node this wraps. An `Element` for `element`, a `Text` for `text`. */\n readonly el: Element | Text | Comment;\n /** Lowercase template spelling, e.g. `view`. Mirrors `EngineNode.tag`; never the DOM tag. */\n readonly tag: string;\n /** `tag` again on an element, for Angular 22.0, which reads it on a component's host element. */\n readonly tagName?: string;\n /**\n * The wrapped element's attributes, on an element, for Angular's hydration. Once an app on the\n * page calls `provideClientHydration()`, every component's host element is asked for\n * `ngSkipHydration` and `ngh`, an island's included, whatever renderer created it. See\n * `BrowserEngine.wrapRoot` for the answer that keeps hydration out of an island.\n */\n readonly hasAttribute?: (this: BrowserNode, name: string) => boolean;\n readonly getAttribute?: (this: BrowserNode, name: string) => string | null;\n props: Record<string, unknown>;\n nodeText: string;\n childList: BrowserNode[];\n parent: BrowserNode | null;\n /**\n * Registered listeners, by top-level type (`topTouchStart`, `topChange`, ...). `null` until\n * the first one, so a node nothing ever listens to costs one field rather than one `Map`.\n */\n listeners: Map<string, Set<(event: unknown) => void>> | null;\n /**\n * Which opt-in event types (`topLayout`, `topPointerEnter`, `topPointerLeave`) already have\n * their real DOM listener installed - `browser-engine.ts`'s `wireOptIn` guard. `null` until\n * the first one, matching `listeners` above.\n */\n optedIn: Set<string> | null;\n}\n\n/** `event.target`, and anything else holding a real DOM node, back to the `BrowserNode` for it. */\nconst registry = new WeakMap<Element | Text | Comment, BrowserNode>();\n\nconst made = new WeakSet<object>();\nconst answered = new WeakSet<object>();\n\ntype Constructor = abstract new (...args: never[]) => object;\n\nexport function letBrowserNodesPassAsDomNodes(): void {\n const scope = globalThis as { Node?: Constructor; Element?: Constructor };\n letPass(scope.Node, (value) => made.has(value as object));\n letPass(\n scope.Element,\n (value) => made.has(value as object) && (value as BrowserNode).nodeKind === 'element',\n );\n letBrowserNodesBeObserved();\n}\n\nfunction letPass(target: Constructor | undefined, ours: (value: unknown) => boolean): void {\n if (typeof target !== 'function' || answered.has(target)) return;\n answered.add(target);\n const own = target[Symbol.hasInstance];\n Object.defineProperty(target, Symbol.hasInstance, {\n configurable: true,\n value(this: Constructor, value: unknown): boolean {\n return (this === target && ours(value)) || own.call(this, value);\n },\n });\n}\n\nfunction unwrap(target: unknown): unknown {\n return made.has(target as object) ? (target as BrowserNode).el : target;\n}\n\nconst observedBy = new WeakMap<\n BrowserNode,\n Set<{ moveTo(node: BrowserNode, from: Element, to: Element): boolean }>\n>();\n\nfunction letBrowserNodesBeObserved(): void {\n const scope = globalThis as { IntersectionObserver?: typeof IntersectionObserver };\n const Native = scope.IntersectionObserver;\n if (typeof Native !== 'function' || answered.has(Native)) return;\n const asSeen = (wrapped: WeakMap<Element, BrowserNode>, entry: IntersectionObserverEntry) => {\n const node = wrapped.get(entry.target);\n if (!node) return entry;\n return {\n time: entry.time,\n rootBounds: entry.rootBounds,\n boundingClientRect: entry.boundingClientRect,\n intersectionRect: entry.intersectionRect,\n intersectionRatio: entry.intersectionRatio,\n isIntersecting: entry.isIntersecting,\n target: node,\n } as unknown as IntersectionObserverEntry;\n };\n class Observer extends Native {\n private wrapped = new WeakMap<Element, BrowserNode>();\n\n constructor(callback: IntersectionObserverCallback, options?: IntersectionObserverInit) {\n super(\n (entries, observer) =>\n callback(\n entries.map((entry) => asSeen((observer as Observer).wrapped, entry)),\n observer,\n ),\n options,\n );\n }\n\n override observe(target: Element): void {\n const el = unwrap(target) as Element;\n if (el !== target) {\n const node = target as unknown as BrowserNode;\n this.wrapped.set(el, node);\n let observers = observedBy.get(node);\n if (!observers) observedBy.set(node, (observers = new Set()));\n observers.add(this);\n } else this.wrapped.delete(el);\n super.observe(el);\n }\n\n override unobserve(target: Element): void {\n const el = unwrap(target) as Element;\n this.wrapped.delete(el);\n super.unobserve(el);\n }\n\n override disconnect(): void {\n this.wrapped = new WeakMap();\n super.disconnect();\n }\n\n override takeRecords(): IntersectionObserverEntry[] {\n return super.takeRecords().map((entry) => asSeen(this.wrapped, entry));\n }\n\n moveTo(node: BrowserNode, from: Element, to: Element): boolean {\n if (this.wrapped.get(from) !== node) return false;\n this.unobserve(from);\n this.observe(to);\n this.wrapped.set(to, node);\n return true;\n }\n }\n answered.add(Observer);\n scope.IntersectionObserver = Observer;\n}\n\ninterface Added {\n readonly type: string;\n readonly listener: EventListenerOrEventListenerObject;\n readonly options: AddEventListenerOptions | boolean | undefined;\n readonly capture: boolean;\n /** What the element was given: `listener`, or for a `once` one, a wrapper that forgets it. */\n readonly registered: EventListenerOrEventListenerObject;\n readonly forget: () => void;\n}\n\nconst addedTo = new WeakMap<BrowserNode, Added[]>();\n\nconst captures = (options: EventListenerOptions | boolean | undefined) =>\n typeof options === 'boolean' ? options : options?.capture === true;\n\nfunction addEventListener(\n this: BrowserNode,\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: AddEventListenerOptions | boolean,\n): void {\n const capture = captures(options);\n let added = addedTo.get(this);\n if (!added) addedTo.set(this, (added = []));\n if (added.some((a) => a.type === type && a.listener === listener && a.capture === capture)) {\n return;\n }\n const signal = typeof options === 'object' ? options.signal : undefined;\n if (signal?.aborted) return;\n const list = added;\n const forget = () => {\n const at = list.indexOf(entry);\n if (at !== -1) list.splice(at, 1);\n signal?.removeEventListener('abort', forget);\n };\n // A `once` listener is forgotten before it runs, so a swap never brings it back: not when it\n // stops the event, and not when it swaps the element itself.\n const registered =\n typeof options === 'object' && options.once === true\n ? function (this: EventTarget, event: Event) {\n forget();\n if (typeof listener === 'function') listener.call(this, event);\n else listener.handleEvent(event);\n }\n : listener;\n const entry: Added = { type, listener, options, capture, registered, forget };\n list.push(entry);\n signal?.addEventListener('abort', forget);\n this.el.addEventListener(type, registered, options);\n}\n\nfunction removeEventListener(\n this: BrowserNode,\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: EventListenerOptions | boolean,\n): void {\n const capture = captures(options);\n const added = addedTo\n .get(this)\n ?.find((a) => a.type === type && a.listener === listener && a.capture === capture);\n this.el.removeEventListener(type, added?.registered ?? listener, options);\n added?.forget();\n}\n\n/**\n * The prototype of every element node. Angular's development build reports a binding as an unknown\n * property (NG0303) unless `name in element` is true, and every binding on an element here goes to\n * `setProperty`, whatever its name.\n */\nconst anyProperty = new Proxy(\n { addEventListener, removeEventListener },\n { has: (_, name) => typeof name === 'string' },\n);\n\n/**\n * The SVG names whose `fill`/`stroke` need a seeded `props` entry from the moment they are\n * created - see the block below for why. `svg-line` is left out: a `<line>` has no fill of its\n * own to paint (react-native-svg's `Line` never reads `fill` either), so there is nothing an\n * explicit `fill=\"none\"` there could mean.\n */\nconst SVG_BRUSH_ELEMENTS = new Set([\n 'svg-g',\n 'svg-path',\n 'svg-circle',\n 'svg-ellipse',\n 'svg-rect',\n 'svg-text',\n 'svg-tspan',\n]);\n\nfunction hasAttribute(this: BrowserNode, name: string): boolean {\n return (this.el as Element).hasAttribute(name);\n}\n\nfunction getAttribute(this: BrowserNode, name: string): string | null {\n return (this.el as Element).getAttribute(name);\n}\n\nexport function makeElementNode(name: string, el: Element): BrowserNode {\n const props: Record<string, unknown> = {};\n // `packages/icons/src/svg-props.ts`'s `brushOf` turns a literal `fill=\"none\"`/`stroke=\"none\"`\n // into `null` - a real, meaningful value (\"paint nothing\"), not an absent one. But\n // `BrowserEngine.setProp` treats `null` exactly like `undefined` on a key it has never seen\n // before: `if (!(key in node.props)) return;`, its fast path for \"nothing to remove, so nothing\n // changed\". That path is right for almost everything a `null` prop could mean, and wrong here -\n // it would skip `applyProp` entirely on a chart line's `fill=\"none\"` (`chart-line.ts`,\n // `chart-area.ts`), leaving the attribute unset, and an unset `fill` defaults to opaque black in\n // a browser (the real SVG initial value) rather than to unpainted (what react-native-svg's own\n // `propList` convention, and every one of these charts, is relying on). Seeding the key here -\n // present, value `undefined` - costs nothing on a shape that never touches the prop again, and\n // is what lets that first `null` reach `props.ts`'s real translation instead of being dropped by\n // the fast path. See `props.ts`'s `applyBrush` for the other half: it is what turns a seeded\n // key's `null` into a written `fill=\"none\"`/`stroke=\"none\"` rather than a removed attribute.\n if (SVG_BRUSH_ELEMENTS.has(name)) {\n props['fill'] = undefined;\n props['stroke'] = undefined;\n }\n const node: BrowserNode = {\n nodeKind: 'element',\n el,\n tag: name,\n tagName: name,\n hasAttribute,\n getAttribute,\n props,\n nodeText: '',\n childList: [],\n parent: null,\n listeners: null,\n optedIn: null,\n };\n Object.setPrototypeOf(node, anyProperty);\n registry.set(el, node);\n made.add(node);\n return node;\n}\n\nexport function makeTextNode(text: Text): BrowserNode {\n const node: BrowserNode = {\n nodeKind: 'text',\n el: text,\n tag: '#text',\n props: {},\n nodeText: text.data,\n childList: [],\n parent: null,\n listeners: null,\n optedIn: null,\n };\n registry.set(text, node);\n made.add(node);\n return node;\n}\n\n/** Angular's `@if`/`@for`/`ViewContainerRef` markers, backed by a real `Comment`. */\nexport function makeAnchorNode(comment: Comment): BrowserNode {\n const node: BrowserNode = {\n nodeKind: 'anchor',\n el: comment,\n tag: '#anchor',\n props: {},\n nodeText: '',\n childList: [],\n parent: null,\n listeners: null,\n optedIn: null,\n };\n registry.set(comment, node);\n made.add(node);\n return node;\n}\n\n/**\n * Puts `el` in place of the element `node` wraps, so `nodeOf` finds the node from either, and moves\n * the listeners and observations added through `node` from the old element to `el`.\n */\nexport function rebindElement(node: BrowserNode, el: Element): void {\n const old = node.el as Element;\n registry.delete(old);\n (node as { el: Element | Text | Comment }).el = el;\n registry.set(el, node);\n for (const added of addedTo.get(node) ?? []) {\n old.removeEventListener(added.type, added.registered, added.capture);\n el.addEventListener(added.type, added.registered, added.options);\n }\n const observers = observedBy.get(node);\n for (const observer of observers ?? []) {\n if (!observer.moveTo(node, old, el)) observers!.delete(observer);\n }\n}\n\n/** The `BrowserNode` a real DOM node was created with, or `null` for one this package did not make. */\nexport function nodeOf(el: Element | Text | Comment | null): BrowserNode | null {\n return el ? (registry.get(el) ?? null) : null;\n}\n\n/**\n * The nearest `BrowserNode` starting at a real `Element` and walking up `parentElement`.\n *\n * Used to resolve `event.target` for events this package listens for on `document` rather than\n * per-node (the responder system's pointer events, focus/blur, selection change): the physical\n * hit is always a real element this package created, but it is not always one with its own\n * listeners, so the search has to climb past any that are not tracked before it gets to `body`\n * and turns up nothing.\n */\nexport function nearestNodeOf(el: Element | null): BrowserNode | null {\n for (let current = el; current; current = current.parentElement) {\n const node = registry.get(current);\n if (node) return node;\n }\n return null;\n}\n\n/** Root-first path from the tree's root to `node`, inclusive. Mirrors `Engine`'s own `pathTo`. */\nexport function pathTo(node: BrowserNode): BrowserNode[] {\n const path: BrowserNode[] = [];\n for (let current: BrowserNode | null = node; current; current = current.parent)\n path.push(current);\n return path.reverse();\n}\n"]}
|
package/dist/mount.js
CHANGED
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
* Refresh's fallback path specifically; a browser dev server has its own, unrelated story for
|
|
34
34
|
* picking up an edit, so wiring `__angularNativeReload` here would install a hook nothing calls.
|
|
35
35
|
*/
|
|
36
|
-
import { APP_BOOTSTRAP_LISTENER, ApplicationRef, DOCUMENT, PLATFORM_ID, EnvironmentInjector, ErrorHandler, LOCALE_ID, RendererFactory2, createComponent, effect, createEnvironmentInjector, ɵcreateOrReusePlatformInjector as createOrReusePlatformInjector, ɵINJECTOR_SCOPE as INJECTOR_SCOPE, ɵprovideZonelessChangeDetectionInternal as provideZonelessChangeDetectionInternal, ɵsetLocaleId as setLocaleId, } from '@angular/core';
|
|
36
|
+
import { APP_BOOTSTRAP_LISTENER, ApplicationInitStatus, ApplicationRef, DOCUMENT, PLATFORM_ID, EnvironmentInjector, ErrorHandler, LOCALE_ID, RendererFactory2, createComponent, effect, createEnvironmentInjector, ɵcreateOrReusePlatformInjector as createOrReusePlatformInjector, ɵINJECTOR_SCOPE as INJECTOR_SCOPE, ɵprovideZonelessChangeDetectionInternal as provideZonelessChangeDetectionInternal, ɵsetLocaleId as setLocaleId, } from '@angular/core';
|
|
37
37
|
import { HostEngine } from '@ng-native/fabric';
|
|
38
|
-
import { ColorScheme, Direction, HardwareBack, Screen, StatusBar } from '@ng-native/device';
|
|
38
|
+
import { ColorScheme, Direction, HardwareBack, OS, Screen, StatusBar } from '@ng-native/device';
|
|
39
39
|
import { browserColorSchemeSource, browserDirectionSource, browserScreenSource, } from "./device-sources.js";
|
|
40
40
|
import { BrowserEngine } from "./browser-engine.js";
|
|
41
41
|
import { BrowserRendererFactory } from "./browser-renderer.js";
|
|
@@ -136,6 +136,8 @@ function hostProviders(engine, factory, view) {
|
|
|
136
136
|
{ provide: Direction.SOURCE, useValue: browserDirectionSource(view) },
|
|
137
137
|
]
|
|
138
138
|
: []),
|
|
139
|
+
// The engine renders as iOS here, so the off-device fallback would say iOS too.
|
|
140
|
+
{ provide: OS, useValue: 'web' },
|
|
139
141
|
// A tab has no hardware back button, so this is the same inert fallback
|
|
140
142
|
// `hardwareBackSource()`'s own off-device branch answers with, provided here so the browser
|
|
141
143
|
// host says so itself rather than relying on that branch.
|
|
@@ -169,6 +171,7 @@ function mountAlone(rootNode, component, providers, inputs, document, host) {
|
|
|
169
171
|
{ provide: ErrorHandler, useClass: ErrorHandler },
|
|
170
172
|
...providers,
|
|
171
173
|
], platformInjector);
|
|
174
|
+
runInitializers(injector);
|
|
172
175
|
setLocaleId(injector.get(LOCALE_ID) || 'en-US');
|
|
173
176
|
const componentRef = createComponent(component, {
|
|
174
177
|
environmentInjector: injector,
|
|
@@ -203,6 +206,16 @@ function mountAlone(rootNode, component, providers, inputs, document, host) {
|
|
|
203
206
|
},
|
|
204
207
|
};
|
|
205
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* The app initializers, before the root component exists, as the native `mount()` runs them (see
|
|
211
|
+
* its `runInitializers` for why through `ApplicationInitStatus`): a promise is started, not awaited,
|
|
212
|
+
* and a failed one reaches the `ErrorHandler`. A copy, as this package cannot import the platform.
|
|
213
|
+
*/
|
|
214
|
+
function runInitializers(injector) {
|
|
215
|
+
const status = injector.get(ApplicationInitStatus);
|
|
216
|
+
status.runInitializers();
|
|
217
|
+
status.donePromise.catch((error) => injector.get(ErrorHandler).handleError(error));
|
|
218
|
+
}
|
|
206
219
|
/**
|
|
207
220
|
* An island inside a running app. Its environment injector is a child of the host's, without a
|
|
208
221
|
* root scope of its own, so anything it does not provide - a `providedIn: 'root'` service, the
|
package/dist/mount.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,MAAM,EACN,yBAAyB,EAMzB,8BAA8B,IAAI,6BAA6B,EAC/D,eAAe,IAAI,cAAc,EACjC,uCAAuC,IAAI,sCAAsC,EACjF,YAAY,IAAI,WAAW,GAC5B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EACL,wB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AAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACzF,CAAC","sourcesContent":["/**\n * Put an Angular application on a page.\n *\n * The browser counterpart to `@ng-native/platform`'s `mount()`, and named the same on\n * purpose: an app imports one or the other, never both, and which one it gets is the import path's\n * job to say rather than the identifier's. Reading the native one first is worth it - this follows\n * its shape and its documented distinction\n * between `ApplicationRef` and the root `ComponentRef` (`createComponent` resolves the latter;\n * `applicationRef.components` needs it pushed by hand, the same bookkeeping\n * `ApplicationRef.bootstrap()` would otherwise do, for the same reason - a routed app's initial\n * navigation checks `applicationRef.components[0]` before it will run at all).\n *\n * What is different from the native `mount()`, and why:\n *\n * - **The first argument is a real `Element`, not a numeric root tag.** Fabric addresses its root\n * by the tag React Native's host gave it; a browser page has no such number, only the element\n * an app mounts into (`document.getElementById('app-root')`, or one `document.body` itself).\n * - **No `FabricUIManager`, and no `Engine` provided under its own token.** Only `HostEngine` is\n * provided. `worklet-style`, `worklet-scroll` and `native-gesture`\n * `inject(Engine)` directly (see `packages/fabric/src/host.ts`'s doc comment for why that is\n * the honest place to draw the line) - on native `Engine` is provided under both tokens so both\n * paths resolve; here it is provided under neither, so an app that uses one of those three on\n * the web gets Angular's own `NullInjectorError` at the point it tries to inject `Engine`,\n * which names exactly what is unsupported rather than rendering something silently wrong.\n * - **`DOCUMENT` is the real `document`**, not the stub the native `mount()` builds for\n * `TransferState`'s\n * `getElementById`. A browser host already has one.\n * - **No dev-mode animation warning, no HMR reload hook.** The native check exists\n * because `@angular/core` reads whether `animate.enter`/`animate.leave` do anything from a\n * global a Metro polyfill has to set before `@angular/core` first evaluates; a real browser\n * already has `document.documentElement.getAnimations`, which is the same thing that global\n * stands in for on native, so there is nothing to warn about. The reload hook is Metro Fast\n * Refresh's fallback path specifically; a browser dev server has its own, unrelated story for\n * picking up an edit, so wiring `__angularNativeReload` here would install a hook nothing calls.\n */\nimport {\n APP_BOOTSTRAP_LISTENER,\n ApplicationRef,\n DOCUMENT,\n PLATFORM_ID,\n EnvironmentInjector,\n ErrorHandler,\n LOCALE_ID,\n RendererFactory2,\n createComponent,\n effect,\n createEnvironmentInjector,\n type ComponentRef,\n type EnvironmentProviders,\n type Injector,\n type Provider,\n type Type,\n ɵcreateOrReusePlatformInjector as createOrReusePlatformInjector,\n ɵINJECTOR_SCOPE as INJECTOR_SCOPE,\n ɵprovideZonelessChangeDetectionInternal as provideZonelessChangeDetectionInternal,\n ɵsetLocaleId as setLocaleId,\n} from '@angular/core';\nimport { HostEngine } from '@ng-native/fabric';\nimport { ColorScheme, Direction, HardwareBack, Screen, StatusBar } from '@ng-native/device';\nimport {\n browserColorSchemeSource,\n browserDirectionSource,\n browserScreenSource,\n} from './device-sources.ts';\nimport { BrowserEngine } from './browser-engine.ts';\nimport { BrowserRendererFactory } from './browser-renderer.ts';\nimport { ISLAND_RESET_CSS, RESET_CSS } from './reset-css.ts';\n\nconst RESET_STYLE_ID = 'angular-native-web-reset';\nconst ISLAND_RESET_STYLE_ID = 'angular-native-web-island-reset';\n\n/**\n * Injects `reset.css`'s content as a `<style>` in `document.head`, once per document. Idempotent,\n * so an app free to call it itself (or to load `reset.css` through its own bundler instead, and\n * pass `injectReset: false` to `mount`) never ends up with the rule twice.\n */\nexport function injectResetStylesheet(document: Document): void {\n injectStyle(document, RESET_STYLE_ID, RESET_CSS);\n}\n\n/**\n * The same for an island inside someone else's page: `ISLAND_RESET_CSS`, which leaves the host's\n * `html` and `body` alone. Its own id, so it sits beside a full reset if the page has both kinds.\n */\nexport function injectIslandResetStylesheet(document: Document): void {\n injectStyle(document, ISLAND_RESET_STYLE_ID, ISLAND_RESET_CSS);\n}\n\nfunction injectStyle(document: Document, id: string, css: string): void {\n if (document.getElementById(id)) return;\n const style = document.createElement('style');\n style.id = id;\n // In Tailwind's `base` layer, below every utility, as `@import '@ng-native/web/reset.css'\n // layer(base)` puts it. Injected unlayered after the app's stylesheet, a reset rule is as\n // specific as a class and later, so it beat `border-2`, `flex-row` and `hidden` alike. With no\n // Tailwind on the page, a layered rule still loses to every unlayered one, as a reset should.\n style.textContent = `@layer base {\\n${css}\\n}`;\n // First in the head: a layer is ordered by where it is first declared, and the documented entry\n // (theme.css and utilities.css) declares no `base`. Declared after it, `base` came after\n // `utilities` and beat every utility again.\n document.head.insertBefore(style, document.head.firstChild);\n}\n\nexport interface MountOptions {\n readonly providers?: (Provider | EnvironmentProviders)[];\n /**\n * The component's inputs, by their public name, set before its first render - so an\n * `input.required()` has its value from the start rather than throwing on the first check.\n * Change them afterwards with `componentRef.setInput`.\n */\n readonly inputs?: Readonly<Record<string, unknown>>;\n /**\n * Injects the reset stylesheet into `document.head` before mounting. Defaults to `true`. With\n * `injector` it is the island reset, which leaves the host page's `html` and `body` alone.\n */\n readonly injectReset?: boolean;\n /**\n * Mount inside an existing Angular app instead of as an app of its own: pass an injector from\n * that app - `inject(Injector)` in the component that owns `rootElement` is the usual one.\n *\n * The island then shares the host app's services (anything `providedIn: 'root'`, and anything\n * its `bootstrapApplication` or a component above it provides) and is checked by the host's\n * change detection. Only what the island has to render differently is its own: the renderer,\n * the engine, and the device services that read the browser rather than a phone. See\n * `packages/web/islands.md` in the documentation.\n */\n readonly injector?: Injector;\n /**\n * Keeps a `dark` class on `rootElement` in step with `ColorScheme`, which is what\n * `@ng-native/tailwind`'s `dark:` variant and a theme's `.dark` block match beneath: the system's\n * `prefers-color-scheme`, or what `ColorScheme.set()` chose over it. Defaults to `true`, as\n * `watchConditions` does on a device. An app that puts `dark` on its own root view turns it off.\n */\n readonly darkClass?: boolean;\n}\n\nexport interface MountResult {\n readonly componentRef: ComponentRef<unknown>;\n /** The island's own app, or with `injector` the host app it was mounted into. */\n readonly applicationRef: ApplicationRef;\n readonly factory: BrowserRendererFactory;\n readonly engine: BrowserEngine;\n /**\n * Takes the island down: its component, and whatever it owns. With `injector` that is only the\n * island - the host app it was mounted into keeps running - so call this rather than\n * `applicationRef.destroy()`, which there would destroy the host.\n */\n destroy(): void;\n}\n\nexport function mount(\n rootElement: Element,\n component: Type<unknown>,\n options: MountOptions = {},\n): MountResult {\n const {\n providers: extraProviders = [],\n inputs = {},\n injectReset = true,\n injector: host,\n darkClass = true,\n } = options;\n const document = rootElement.ownerDocument;\n if (injectReset) {\n if (host) injectIslandResetStylesheet(document);\n else injectResetStylesheet(document);\n }\n // What `reset.css` hangs the root's height off. Stamped rather than required of the app,\n // because an app that forgot it would get a page whose `flex: 1` silently resolved to zero.\n rootElement.setAttribute('data-rn-root', '');\n // What `@ng-native/tailwind`'s `web:` variant matches beneath, as `platform-ios` does on a phone.\n rootElement.classList.add('platform-web');\n\n const engine = new BrowserEngine(document);\n const factory = new BrowserRendererFactory(engine, document);\n // `wrapRoot` marks the element `ngSkipHydration`; an island gives back what it had on unmount.\n const skipHydration = rootElement.getAttribute('ngSkipHydration');\n const rootNode = engine.wrapRoot(rootElement) as unknown as Element;\n const own = hostProviders(engine, factory, document.defaultView);\n\n const mounted = host\n ? mountInside(\n host,\n rootElement,\n rootNode,\n component,\n [...own, ...extraProviders],\n inputs,\n {\n factory,\n engine,\n },\n skipHydration,\n )\n : mountAlone(rootNode, component, [...own, ...extraProviders], inputs, document, {\n factory,\n engine,\n });\n // The engine listens on the whole document, so it has to stop once its app is gone, however\n // the app went: through `destroy()` or straight through the component ref.\n mounted.componentRef.onDestroy(() => engine.dispose());\n if (darkClass) keepDarkClass(rootElement, mounted.componentRef);\n return mounted;\n}\n\n/** The `darkClass` option: the class now, and again whenever `ColorScheme` changes. */\nfunction keepDarkClass(rootElement: Element, componentRef: ComponentRef<unknown>): void {\n const scheme = componentRef.injector.get(ColorScheme);\n const apply = () => rootElement.classList.toggle('dark', scheme.current() === 'dark');\n apply();\n effect(apply, { injector: componentRef.injector });\n componentRef.onDestroy(() => rootElement.classList.remove('dark'));\n}\n\n/**\n * What an island has to have of its own, whichever way it is mounted: the renderer and engine\n * that turn `<view>` into a `<div>`, and the device capabilities answered by the browser.\n */\nfunction hostProviders(\n engine: BrowserEngine,\n factory: BrowserRendererFactory,\n view: Document['defaultView'],\n): (Provider | EnvironmentProviders)[] {\n return [\n { provide: RendererFactory2, useValue: factory },\n // The one seam the shared packages inject. See the file doc for why `Engine` itself is not\n // also provided here.\n { provide: HostEngine, useValue: engine },\n // The device capabilities, from the browser rather than from React Native. Without these\n // `Screen` falls back to its off-device answer of a zero-sized window, and every component\n // that branches on `compact()` takes the phone tree. See `device-sources.ts`.\n ...(view\n ? [\n { provide: Screen.SOURCE, useValue: browserScreenSource(view) },\n { provide: ColorScheme.SOURCE, useValue: browserColorSchemeSource(view) },\n { provide: Direction.SOURCE, useValue: browserDirectionSource(view) },\n ]\n : []),\n // A tab has no hardware back button, so this is the same inert fallback\n // `hardwareBackSource()`'s own off-device branch answers with, provided here so the browser\n // host says so itself rather than relying on that branch.\n { provide: HardwareBack.SOURCE, useValue: { subscribe: () => () => {} } },\n // A tab has no status bar either.\n {\n provide: StatusBar.SOURCE,\n useValue: {\n setStyle: () => {},\n setHidden: () => {},\n setBackgroundColor: () => {},\n setTranslucent: () => {},\n height: undefined,\n },\n },\n ];\n}\n\n/** An app of its own: its own root injector, change detection and `ApplicationRef`. */\nfunction mountAlone(\n rootNode: Element,\n component: Type<unknown>,\n providers: (Provider | EnvironmentProviders)[],\n inputs: Readonly<Record<string, unknown>>,\n document: Document,\n host: { factory: BrowserRendererFactory; engine: BrowserEngine },\n): MountResult {\n // Parent the app injector to the platform injector, exactly as `internalCreateApplication`\n // does and `mount()` documents: some Angular services are `providedIn: 'platform'`, and with a\n // null parent they simply do not exist.\n const platformInjector = createOrReusePlatformInjector();\n\n const injector = createEnvironmentInjector(\n [\n { provide: INJECTOR_SCOPE, useValue: 'root' },\n provideZonelessChangeDetectionInternal(),\n { provide: DOCUMENT, useValue: document },\n // A DOM is what this is running in, so libraries that check isPlatformBrowser() are right to\n // use it. An island inside an app is the app's own and inherits its value instead.\n { provide: PLATFORM_ID, useValue: 'browser' },\n { provide: ErrorHandler, useClass: ErrorHandler },\n ...providers,\n ],\n platformInjector as EnvironmentInjector,\n );\n setLocaleId(injector.get(LOCALE_ID) || 'en-US');\n\n const componentRef = createComponent(component, {\n environmentInjector: injector,\n hostElement: rootNode,\n });\n setInputs(componentRef, inputs);\n\n const applicationRef = injector.get(ApplicationRef);\n\n // Mirrors `ApplicationRef.bootstrap()`, which is not used directly because it wants a DOM\n // selector rather than an element `mount`'s own caller already resolved.\n applicationRef.componentTypes.push(component);\n applicationRef.attachView(componentRef.hostView);\n applicationRef.tick();\n // Load-bearing, not bookkeeping: the router's bootstrap listener returns early unless the ref\n // it is handed is `ApplicationRef.components[0]`.\n applicationRef.components.push(componentRef);\n componentRef.onDestroy(() => {\n applicationRef.detachView(componentRef.hostView);\n const at = applicationRef.components.indexOf(componentRef);\n if (at !== -1) applicationRef.components.splice(at, 1);\n });\n\n for (const listener of injector.get(APP_BOOTSTRAP_LISTENER, [])) {\n listener(componentRef);\n }\n\n return {\n componentRef,\n applicationRef,\n ...host,\n destroy: () => {\n componentRef.destroy();\n applicationRef.destroy();\n },\n };\n}\n\n/**\n * An island inside a running app. Its environment injector is a child of the host's, without a\n * root scope of its own, so anything it does not provide - a `providedIn: 'root'` service, the\n * host's `ApplicationRef` and scheduler, its `ErrorHandler` - resolves from the host, once, for\n * both. What it does provide is only what has to differ: the renderer and engine, the browser's\n * device sources, and the five device services that read them. Those five are provided here as\n * classes so they are built in the island, against its sources, rather than in the host's root\n * against the phone defaults.\n *\n * The host's element injector goes in too, so a service a component above the island provides\n * is visible to it as well as one the app does.\n */\nfunction mountInside(\n hostInjector: Injector,\n rootElement: Element,\n rootNode: Element,\n component: Type<unknown>,\n providers: (Provider | EnvironmentProviders)[],\n inputs: Readonly<Record<string, unknown>>,\n host: { factory: BrowserRendererFactory; engine: BrowserEngine },\n skipHydration: string | null,\n): MountResult {\n const injector = createEnvironmentInjector(\n [Screen, ColorScheme, Direction, HardwareBack, StatusBar, ...providers],\n hostInjector.get(EnvironmentInjector),\n );\n\n const componentRef = createComponent(component, {\n environmentInjector: injector,\n elementInjector: hostInjector,\n hostElement: rootNode,\n });\n setInputs(componentRef, inputs);\n\n // The host's own change detection checks the island from here on, like any view of its own.\n const applicationRef = hostInjector.get(ApplicationRef);\n applicationRef.attachView(componentRef.hostView);\n componentRef.changeDetectorRef.detectChanges();\n\n return {\n componentRef,\n applicationRef,\n ...host,\n destroy: () => {\n componentRef.destroy();\n injector.destroy();\n rootElement.removeAttribute('data-rn-root');\n if (skipHydration === null) rootElement.removeAttribute('ngSkipHydration');\n else rootElement.setAttribute('ngSkipHydration', skipHydration);\n rootElement.classList.remove('platform-web');\n },\n };\n}\n\nfunction setInputs(componentRef: ComponentRef<unknown>, inputs: Readonly<Record<string, unknown>>) {\n for (const [name, value] of Object.entries(inputs)) componentRef.setInput(name, value);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,EACd,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,MAAM,EACN,yBAAyB,EAMzB,8BAA8B,IAAI,6BAA6B,EAC/D,eAAe,IAAI,cAAc,EACjC,uCAAuC,IAAI,sCAAsC,EACjF,YAAY,IAAI,WAAW,GAC5B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAChG,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AA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AAC;YACnB,WAAW,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;YAC5C,IAAI,aAAa,KAAK,IAAI;gBAAE,WAAW,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;;gBACtE,WAAW,CAAC,YAAY,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;YAChE,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QAC/C,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,YAAmC,EAAE,MAAyC;IAC/F,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACzF,CAAC","sourcesContent":["/**\n * Put an Angular application on a page.\n *\n * The browser counterpart to `@ng-native/platform`'s `mount()`, and named the same on\n * purpose: an app imports one or the other, never both, and which one it gets is the import path's\n * job to say rather than the identifier's. Reading the native one first is worth it - this follows\n * its shape and its documented distinction\n * between `ApplicationRef` and the root `ComponentRef` (`createComponent` resolves the latter;\n * `applicationRef.components` needs it pushed by hand, the same bookkeeping\n * `ApplicationRef.bootstrap()` would otherwise do, for the same reason - a routed app's initial\n * navigation checks `applicationRef.components[0]` before it will run at all).\n *\n * What is different from the native `mount()`, and why:\n *\n * - **The first argument is a real `Element`, not a numeric root tag.** Fabric addresses its root\n * by the tag React Native's host gave it; a browser page has no such number, only the element\n * an app mounts into (`document.getElementById('app-root')`, or one `document.body` itself).\n * - **No `FabricUIManager`, and no `Engine` provided under its own token.** Only `HostEngine` is\n * provided. `worklet-style`, `worklet-scroll` and `native-gesture`\n * `inject(Engine)` directly (see `packages/fabric/src/host.ts`'s doc comment for why that is\n * the honest place to draw the line) - on native `Engine` is provided under both tokens so both\n * paths resolve; here it is provided under neither, so an app that uses one of those three on\n * the web gets Angular's own `NullInjectorError` at the point it tries to inject `Engine`,\n * which names exactly what is unsupported rather than rendering something silently wrong.\n * - **`DOCUMENT` is the real `document`**, not the stub the native `mount()` builds for\n * `TransferState`'s\n * `getElementById`. A browser host already has one.\n * - **No dev-mode animation warning, no HMR reload hook.** The native check exists\n * because `@angular/core` reads whether `animate.enter`/`animate.leave` do anything from a\n * global a Metro polyfill has to set before `@angular/core` first evaluates; a real browser\n * already has `document.documentElement.getAnimations`, which is the same thing that global\n * stands in for on native, so there is nothing to warn about. The reload hook is Metro Fast\n * Refresh's fallback path specifically; a browser dev server has its own, unrelated story for\n * picking up an edit, so wiring `__angularNativeReload` here would install a hook nothing calls.\n */\nimport {\n APP_BOOTSTRAP_LISTENER,\n ApplicationInitStatus,\n ApplicationRef,\n DOCUMENT,\n PLATFORM_ID,\n EnvironmentInjector,\n ErrorHandler,\n LOCALE_ID,\n RendererFactory2,\n createComponent,\n effect,\n createEnvironmentInjector,\n type ComponentRef,\n type EnvironmentProviders,\n type Injector,\n type Provider,\n type Type,\n ɵcreateOrReusePlatformInjector as createOrReusePlatformInjector,\n ɵINJECTOR_SCOPE as INJECTOR_SCOPE,\n ɵprovideZonelessChangeDetectionInternal as provideZonelessChangeDetectionInternal,\n ɵsetLocaleId as setLocaleId,\n} from '@angular/core';\nimport { HostEngine } from '@ng-native/fabric';\nimport { ColorScheme, Direction, HardwareBack, OS, Screen, StatusBar } from '@ng-native/device';\nimport {\n browserColorSchemeSource,\n browserDirectionSource,\n browserScreenSource,\n} from './device-sources.ts';\nimport { BrowserEngine } from './browser-engine.ts';\nimport { BrowserRendererFactory } from './browser-renderer.ts';\nimport { ISLAND_RESET_CSS, RESET_CSS } from './reset-css.ts';\n\nconst RESET_STYLE_ID = 'angular-native-web-reset';\nconst ISLAND_RESET_STYLE_ID = 'angular-native-web-island-reset';\n\n/**\n * Injects `reset.css`'s content as a `<style>` in `document.head`, once per document. Idempotent,\n * so an app free to call it itself (or to load `reset.css` through its own bundler instead, and\n * pass `injectReset: false` to `mount`) never ends up with the rule twice.\n */\nexport function injectResetStylesheet(document: Document): void {\n injectStyle(document, RESET_STYLE_ID, RESET_CSS);\n}\n\n/**\n * The same for an island inside someone else's page: `ISLAND_RESET_CSS`, which leaves the host's\n * `html` and `body` alone. Its own id, so it sits beside a full reset if the page has both kinds.\n */\nexport function injectIslandResetStylesheet(document: Document): void {\n injectStyle(document, ISLAND_RESET_STYLE_ID, ISLAND_RESET_CSS);\n}\n\nfunction injectStyle(document: Document, id: string, css: string): void {\n if (document.getElementById(id)) return;\n const style = document.createElement('style');\n style.id = id;\n // In Tailwind's `base` layer, below every utility, as `@import '@ng-native/web/reset.css'\n // layer(base)` puts it. Injected unlayered after the app's stylesheet, a reset rule is as\n // specific as a class and later, so it beat `border-2`, `flex-row` and `hidden` alike. With no\n // Tailwind on the page, a layered rule still loses to every unlayered one, as a reset should.\n style.textContent = `@layer base {\\n${css}\\n}`;\n // First in the head: a layer is ordered by where it is first declared, and the documented entry\n // (theme.css and utilities.css) declares no `base`. Declared after it, `base` came after\n // `utilities` and beat every utility again.\n document.head.insertBefore(style, document.head.firstChild);\n}\n\nexport interface MountOptions {\n readonly providers?: (Provider | EnvironmentProviders)[];\n /**\n * The component's inputs, by their public name, set before its first render - so an\n * `input.required()` has its value from the start rather than throwing on the first check.\n * Change them afterwards with `componentRef.setInput`.\n */\n readonly inputs?: Readonly<Record<string, unknown>>;\n /**\n * Injects the reset stylesheet into `document.head` before mounting. Defaults to `true`. With\n * `injector` it is the island reset, which leaves the host page's `html` and `body` alone.\n */\n readonly injectReset?: boolean;\n /**\n * Mount inside an existing Angular app instead of as an app of its own: pass an injector from\n * that app - `inject(Injector)` in the component that owns `rootElement` is the usual one.\n *\n * The island then shares the host app's services (anything `providedIn: 'root'`, and anything\n * its `bootstrapApplication` or a component above it provides) and is checked by the host's\n * change detection. Only what the island has to render differently is its own: the renderer,\n * the engine, and the device services that read the browser rather than a phone. See\n * `packages/web/islands.md` in the documentation.\n */\n readonly injector?: Injector;\n /**\n * Keeps a `dark` class on `rootElement` in step with `ColorScheme`, which is what\n * `@ng-native/tailwind`'s `dark:` variant and a theme's `.dark` block match beneath: the system's\n * `prefers-color-scheme`, or what `ColorScheme.set()` chose over it. Defaults to `true`, as\n * `watchConditions` does on a device. An app that puts `dark` on its own root view turns it off.\n */\n readonly darkClass?: boolean;\n}\n\nexport interface MountResult {\n readonly componentRef: ComponentRef<unknown>;\n /** The island's own app, or with `injector` the host app it was mounted into. */\n readonly applicationRef: ApplicationRef;\n readonly factory: BrowserRendererFactory;\n readonly engine: BrowserEngine;\n /**\n * Takes the island down: its component, and whatever it owns. With `injector` that is only the\n * island - the host app it was mounted into keeps running - so call this rather than\n * `applicationRef.destroy()`, which there would destroy the host.\n */\n destroy(): void;\n}\n\nexport function mount(\n rootElement: Element,\n component: Type<unknown>,\n options: MountOptions = {},\n): MountResult {\n const {\n providers: extraProviders = [],\n inputs = {},\n injectReset = true,\n injector: host,\n darkClass = true,\n } = options;\n const document = rootElement.ownerDocument;\n if (injectReset) {\n if (host) injectIslandResetStylesheet(document);\n else injectResetStylesheet(document);\n }\n // What `reset.css` hangs the root's height off. Stamped rather than required of the app,\n // because an app that forgot it would get a page whose `flex: 1` silently resolved to zero.\n rootElement.setAttribute('data-rn-root', '');\n // What `@ng-native/tailwind`'s `web:` variant matches beneath, as `platform-ios` does on a phone.\n rootElement.classList.add('platform-web');\n\n const engine = new BrowserEngine(document);\n const factory = new BrowserRendererFactory(engine, document);\n // `wrapRoot` marks the element `ngSkipHydration`; an island gives back what it had on unmount.\n const skipHydration = rootElement.getAttribute('ngSkipHydration');\n const rootNode = engine.wrapRoot(rootElement) as unknown as Element;\n const own = hostProviders(engine, factory, document.defaultView);\n\n const mounted = host\n ? mountInside(\n host,\n rootElement,\n rootNode,\n component,\n [...own, ...extraProviders],\n inputs,\n {\n factory,\n engine,\n },\n skipHydration,\n )\n : mountAlone(rootNode, component, [...own, ...extraProviders], inputs, document, {\n factory,\n engine,\n });\n // The engine listens on the whole document, so it has to stop once its app is gone, however\n // the app went: through `destroy()` or straight through the component ref.\n mounted.componentRef.onDestroy(() => engine.dispose());\n if (darkClass) keepDarkClass(rootElement, mounted.componentRef);\n return mounted;\n}\n\n/** The `darkClass` option: the class now, and again whenever `ColorScheme` changes. */\nfunction keepDarkClass(rootElement: Element, componentRef: ComponentRef<unknown>): void {\n const scheme = componentRef.injector.get(ColorScheme);\n const apply = () => rootElement.classList.toggle('dark', scheme.current() === 'dark');\n apply();\n effect(apply, { injector: componentRef.injector });\n componentRef.onDestroy(() => rootElement.classList.remove('dark'));\n}\n\n/**\n * What an island has to have of its own, whichever way it is mounted: the renderer and engine\n * that turn `<view>` into a `<div>`, and the device capabilities answered by the browser.\n */\nfunction hostProviders(\n engine: BrowserEngine,\n factory: BrowserRendererFactory,\n view: Document['defaultView'],\n): (Provider | EnvironmentProviders)[] {\n return [\n { provide: RendererFactory2, useValue: factory },\n // The one seam the shared packages inject. See the file doc for why `Engine` itself is not\n // also provided here.\n { provide: HostEngine, useValue: engine },\n // The device capabilities, from the browser rather than from React Native. Without these\n // `Screen` falls back to its off-device answer of a zero-sized window, and every component\n // that branches on `compact()` takes the phone tree. See `device-sources.ts`.\n ...(view\n ? [\n { provide: Screen.SOURCE, useValue: browserScreenSource(view) },\n { provide: ColorScheme.SOURCE, useValue: browserColorSchemeSource(view) },\n { provide: Direction.SOURCE, useValue: browserDirectionSource(view) },\n ]\n : []),\n // The engine renders as iOS here, so the off-device fallback would say iOS too.\n { provide: OS, useValue: 'web' },\n // A tab has no hardware back button, so this is the same inert fallback\n // `hardwareBackSource()`'s own off-device branch answers with, provided here so the browser\n // host says so itself rather than relying on that branch.\n { provide: HardwareBack.SOURCE, useValue: { subscribe: () => () => {} } },\n // A tab has no status bar either.\n {\n provide: StatusBar.SOURCE,\n useValue: {\n setStyle: () => {},\n setHidden: () => {},\n setBackgroundColor: () => {},\n setTranslucent: () => {},\n height: undefined,\n },\n },\n ];\n}\n\n/** An app of its own: its own root injector, change detection and `ApplicationRef`. */\nfunction mountAlone(\n rootNode: Element,\n component: Type<unknown>,\n providers: (Provider | EnvironmentProviders)[],\n inputs: Readonly<Record<string, unknown>>,\n document: Document,\n host: { factory: BrowserRendererFactory; engine: BrowserEngine },\n): MountResult {\n // Parent the app injector to the platform injector, exactly as `internalCreateApplication`\n // does and `mount()` documents: some Angular services are `providedIn: 'platform'`, and with a\n // null parent they simply do not exist.\n const platformInjector = createOrReusePlatformInjector();\n\n const injector = createEnvironmentInjector(\n [\n { provide: INJECTOR_SCOPE, useValue: 'root' },\n provideZonelessChangeDetectionInternal(),\n { provide: DOCUMENT, useValue: document },\n // A DOM is what this is running in, so libraries that check isPlatformBrowser() are right to\n // use it. An island inside an app is the app's own and inherits its value instead.\n { provide: PLATFORM_ID, useValue: 'browser' },\n { provide: ErrorHandler, useClass: ErrorHandler },\n ...providers,\n ],\n platformInjector as EnvironmentInjector,\n );\n runInitializers(injector);\n setLocaleId(injector.get(LOCALE_ID) || 'en-US');\n\n const componentRef = createComponent(component, {\n environmentInjector: injector,\n hostElement: rootNode,\n });\n setInputs(componentRef, inputs);\n\n const applicationRef = injector.get(ApplicationRef);\n\n // Mirrors `ApplicationRef.bootstrap()`, which is not used directly because it wants a DOM\n // selector rather than an element `mount`'s own caller already resolved.\n applicationRef.componentTypes.push(component);\n applicationRef.attachView(componentRef.hostView);\n applicationRef.tick();\n // Load-bearing, not bookkeeping: the router's bootstrap listener returns early unless the ref\n // it is handed is `ApplicationRef.components[0]`.\n applicationRef.components.push(componentRef);\n componentRef.onDestroy(() => {\n applicationRef.detachView(componentRef.hostView);\n const at = applicationRef.components.indexOf(componentRef);\n if (at !== -1) applicationRef.components.splice(at, 1);\n });\n\n for (const listener of injector.get(APP_BOOTSTRAP_LISTENER, [])) {\n listener(componentRef);\n }\n\n return {\n componentRef,\n applicationRef,\n ...host,\n destroy: () => {\n componentRef.destroy();\n applicationRef.destroy();\n },\n };\n}\n\n/**\n * The app initializers, before the root component exists, as the native `mount()` runs them (see\n * its `runInitializers` for why through `ApplicationInitStatus`): a promise is started, not awaited,\n * and a failed one reaches the `ErrorHandler`. A copy, as this package cannot import the platform.\n */\nfunction runInitializers(injector: EnvironmentInjector): void {\n const status = injector.get(ApplicationInitStatus);\n (status as unknown as { runInitializers(): void }).runInitializers();\n status.donePromise.catch((error: unknown) => injector.get(ErrorHandler).handleError(error));\n}\n\n/**\n * An island inside a running app. Its environment injector is a child of the host's, without a\n * root scope of its own, so anything it does not provide - a `providedIn: 'root'` service, the\n * host's `ApplicationRef` and scheduler, its `ErrorHandler` - resolves from the host, once, for\n * both. What it does provide is only what has to differ: the renderer and engine, the browser's\n * device sources, and the five device services that read them. Those five are provided here as\n * classes so they are built in the island, against its sources, rather than in the host's root\n * against the phone defaults.\n *\n * The host's element injector goes in too, so a service a component above the island provides\n * is visible to it as well as one the app does.\n */\nfunction mountInside(\n hostInjector: Injector,\n rootElement: Element,\n rootNode: Element,\n component: Type<unknown>,\n providers: (Provider | EnvironmentProviders)[],\n inputs: Readonly<Record<string, unknown>>,\n host: { factory: BrowserRendererFactory; engine: BrowserEngine },\n skipHydration: string | null,\n): MountResult {\n const injector = createEnvironmentInjector(\n [Screen, ColorScheme, Direction, HardwareBack, StatusBar, ...providers],\n hostInjector.get(EnvironmentInjector),\n );\n\n const componentRef = createComponent(component, {\n environmentInjector: injector,\n elementInjector: hostInjector,\n hostElement: rootNode,\n });\n setInputs(componentRef, inputs);\n\n // The host's own change detection checks the island from here on, like any view of its own.\n const applicationRef = hostInjector.get(ApplicationRef);\n applicationRef.attachView(componentRef.hostView);\n componentRef.changeDetectorRef.detectChanges();\n\n return {\n componentRef,\n applicationRef,\n ...host,\n destroy: () => {\n componentRef.destroy();\n injector.destroy();\n rootElement.removeAttribute('data-rn-root');\n if (skipHydration === null) rootElement.removeAttribute('ngSkipHydration');\n else rootElement.setAttribute('ngSkipHydration', skipHydration);\n rootElement.classList.remove('platform-web');\n },\n };\n}\n\nfunction setInputs(componentRef: ComponentRef<unknown>, inputs: Readonly<Record<string, unknown>>) {\n for (const [name, value] of Object.entries(inputs)) componentRef.setInput(name, value);\n}\n"]}
|
package/dist/responder.d.ts
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
*
|
|
11
11
|
* ## What is faithfully reproduced
|
|
12
12
|
*
|
|
13
|
-
* The whole negotiation: capture pre-emption, bubble election,
|
|
14
|
-
* scroll view taking over a drag mid-press
|
|
15
|
-
* `cancelPressForScroll`). `pressable.test.ts`-equivalent scenarios - a pressable nested in a
|
|
13
|
+
* The whole negotiation: capture pre-emption, bubble election, a node above the responder taking
|
|
14
|
+
* the touch on a move, termination requests, and a scroll view taking over a drag mid-press
|
|
15
|
+
* (`notifyScroll`, the counterpart of `engine.ts`'s `cancelPressForScroll`). `pressable.test.ts`-equivalent scenarios - a pressable nested in a
|
|
16
16
|
* scroll view nested in a dialog - behave the same on both platforms because this is the same
|
|
17
17
|
* algorithm, not a different one that happens to agree on simple cases.
|
|
18
18
|
*
|
|
@@ -50,6 +50,8 @@ export declare class ResponderSystem {
|
|
|
50
50
|
private release;
|
|
51
51
|
/** Drives the negotiation from a synthesised `topTouchStart`/`Move`/`End`/`Cancel`. */
|
|
52
52
|
runResponder(target: BrowserNode, type: string, event: ResponderEvent): void;
|
|
53
|
+
/** Asked on every move, from above both the responder and the target. Mirrors `engine.ts`. */
|
|
54
|
+
private move;
|
|
53
55
|
/** A scroll container moved under the finger. Cancels a press inside it; see the file doc. */
|
|
54
56
|
notifyScroll(scrollNode: BrowserNode): void;
|
|
55
57
|
}
|
package/dist/responder.js
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
*
|
|
11
11
|
* ## What is faithfully reproduced
|
|
12
12
|
*
|
|
13
|
-
* The whole negotiation: capture pre-emption, bubble election,
|
|
14
|
-
* scroll view taking over a drag mid-press
|
|
15
|
-
* `cancelPressForScroll`). `pressable.test.ts`-equivalent scenarios - a pressable nested in a
|
|
13
|
+
* The whole negotiation: capture pre-emption, bubble election, a node above the responder taking
|
|
14
|
+
* the touch on a move, termination requests, and a scroll view taking over a drag mid-press
|
|
15
|
+
* (`notifyScroll`, the counterpart of `engine.ts`'s `cancelPressForScroll`). `pressable.test.ts`-equivalent scenarios - a pressable nested in a
|
|
16
16
|
* scroll view nested in a dialog - behave the same on both platforms because this is the same
|
|
17
17
|
* algorithm, not a different one that happens to agree on simple cases.
|
|
18
18
|
*
|
|
@@ -37,6 +37,19 @@
|
|
|
37
37
|
*/
|
|
38
38
|
import { SyntheticEvent } from '@ng-native/fabric';
|
|
39
39
|
import { pathTo } from "./dom-node.js";
|
|
40
|
+
/** The lowest node both are in, either of them included. Mirrors `engine.ts`. */
|
|
41
|
+
function commonAncestor(a, b) {
|
|
42
|
+
for (let node = b; node; node = node.parent)
|
|
43
|
+
if (node === a)
|
|
44
|
+
return a;
|
|
45
|
+
const above = new Set();
|
|
46
|
+
for (let node = a; node; node = node.parent)
|
|
47
|
+
above.add(node);
|
|
48
|
+
for (let node = b; node; node = node.parent)
|
|
49
|
+
if (above.has(node))
|
|
50
|
+
return node;
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
40
53
|
export class ResponderSystem {
|
|
41
54
|
responders = new WeakMap();
|
|
42
55
|
current = null;
|
|
@@ -59,8 +72,8 @@ export class ResponderSystem {
|
|
|
59
72
|
};
|
|
60
73
|
}
|
|
61
74
|
/** Root-first capture, then target-first bubble. Mirrors `engine.ts`'s `negotiate`. */
|
|
62
|
-
negotiate(target, event, phase) {
|
|
63
|
-
const path = pathTo(
|
|
75
|
+
negotiate(target, event, phase, from = target) {
|
|
76
|
+
const path = pathTo(from);
|
|
64
77
|
const capture = `on${phase}ShouldSetResponderCapture`;
|
|
65
78
|
const bubble = `on${phase}ShouldSetResponder`;
|
|
66
79
|
for (const node of path) {
|
|
@@ -106,21 +119,23 @@ export class ResponderSystem {
|
|
|
106
119
|
this.grant(elected, event);
|
|
107
120
|
return;
|
|
108
121
|
}
|
|
109
|
-
if (type === 'topTouchMove')
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
else {
|
|
113
|
-
const elected = this.negotiate(target, event, 'Move');
|
|
114
|
-
if (elected)
|
|
115
|
-
this.grant(elected, event);
|
|
116
|
-
}
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
if (type === 'topTouchEnd')
|
|
122
|
+
if (type === 'topTouchMove')
|
|
123
|
+
this.move(target, event);
|
|
124
|
+
else if (type === 'topTouchEnd')
|
|
120
125
|
this.release(event, false);
|
|
121
126
|
else if (type === 'topTouchCancel')
|
|
122
127
|
this.release(event, true);
|
|
123
128
|
}
|
|
129
|
+
/** Asked on every move, from above both the responder and the target. Mirrors `engine.ts`. */
|
|
130
|
+
move(target, event) {
|
|
131
|
+
const holder = this.current;
|
|
132
|
+
const from = holder ? commonAncestor(holder, target) : target;
|
|
133
|
+
const elected = from ? this.negotiate(target, event, 'Move', from) : null;
|
|
134
|
+
if (elected && elected !== holder)
|
|
135
|
+
this.grant(elected, event);
|
|
136
|
+
if (this.current)
|
|
137
|
+
this.responders.get(this.current)?.onResponderMove?.(event);
|
|
138
|
+
}
|
|
124
139
|
/** A scroll container moved under the finger. Cancels a press inside it; see the file doc. */
|
|
125
140
|
notifyScroll(scrollNode) {
|
|
126
141
|
const responder = this.current;
|
package/dist/responder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responder.js","sourceRoot":"","sources":["../src/responder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,cAAc,EAA+C,MAAM,mBAAmB,CAAC;AAChG,OAAO,EAAoB,MAAM,EAAE,MAAM,eAAe,CAAC;AAEzD,MAAM,OAAO,eAAe;IACT,UAAU,GAAG,IAAI,OAAO,EAAkC,CAAC;IACpE,OAAO,GAAuB,IAAI,CAAC;IAE3C,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,gGAAgG;IAChG,QAAQ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O;QACT,CAAC;QACD,IAAI,IAAI,KAAK,cAAc,EAAE,CAAC;YAC5B,IAAI,IAAI,CAAC,OAAO;gBAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC,KAAK,CAAC,CAAC;iBACzE,CAAC;gBACJ,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;gBACtD,IAAI,OAAO;oBAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC1C,CAAC;YACD,OAAO;QACT,CAAC;QACD,IAAI,IAAI,KAAK,aAAa;YAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;aAClD,IAAI,IAAI,KAAK,gBAAgB;YAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAChE,CAAC;IAED,8FAA8F;IAC9F,YAAY,CAAC,UAAuB;QAClC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,SAAS,IAAI,SAAS,KAAK,UAAU;YAAE,OAAO;QACnD,KAAK,IAAI,IAAI,GAAuB,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YACxE,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;gBACxB,IAAI,CAAC,OAAO,CAAC,IAAI,cAAc,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;gBAC3C,OAAO;YACT,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * The JS responder negotiation, over DOM pointer events instead of Fabric's raw touch stream.\n *\n * `packages/fabric/src/engine.ts` runs a two-phase election on every `topTouchStart`: a capture\n * pass root-to-target where an ancestor (a scroll view) can pre-empt, then a bubble pass\n * target-to-root where the innermost interested node wins. Exactly one node ever holds the\n * gesture, and a `grant` can be refused by `onResponderTerminationRequest`. This file is that\n * algorithm, ported line for line from `negotiate`/`grant`/`release` in `engine.ts`, over\n * `BrowserNode`'s `.parent` chain instead of `EngineNode`'s.\n *\n * ## What is faithfully reproduced\n *\n * The whole negotiation: capture pre-emption, bubble election, termination requests, and a\n * scroll view taking over a drag mid-press (`notifyScroll`, the counterpart of `engine.ts`'s\n * `cancelPressForScroll`). `pressable.test.ts`-equivalent scenarios - a pressable nested in a\n * scroll view nested in a dialog - behave the same on both platforms because this is the same\n * algorithm, not a different one that happens to agree on simple cases.\n *\n * ## What differs, and why\n *\n * There is no native side to tell who currently owns the gesture (`tellNative`/`setIsJSResponder`\n * in `engine.ts`): a DOM scroll container has no separate \"JS responder\" concept to defer to, it\n * simply does not receive the pointer events this system does not propagate to it as a drag. So\n * `blockNativeResponder` is accepted (for API parity - a component that sets it does not break)\n * and does nothing, which is a real gap only for a native scroll gesture that would otherwise\n * fight a JS one; on the web the browser's own scroll only starts from events this system's\n * `setPointerCapture` call (`browser-engine.ts`) already keeps from reaching it while a responder\n * holds the gesture.\n *\n * `notifyScroll`'s cancellation is coarser than `engine.ts`'s: native tells the responder system\n * apart a real drag from a momentum settle or a programmatic `scrollTo` because it is the same\n * code sending both `topScroll` and `topScrollBeginDrag`. A DOM `scroll` event carries no such\n * distinction, so this cancels on the first `scroll` a descendant responder sees, drag or not.\n * The one case that reads differently: a programmatic `scrollTo()` call that happens to run while\n * something inside that scroll view is mid-press will cancel the press on the web and not on\n * native. Narrow, and named here rather than found by a user later.\n */\nimport { SyntheticEvent, type ResponderEvent, type ResponderHandlers } from '@ng-native/fabric';\nimport { type BrowserNode, pathTo } from './dom-node.ts';\n\nexport class ResponderSystem {\n private readonly responders = new WeakMap<BrowserNode, ResponderHandlers>();\n private current: BrowserNode | null = null;\n\n get responder(): BrowserNode | null {\n return this.current;\n }\n\n /** Whether `node` takes part in the negotiation at all: a control, rather than a plain view. */\n responds(node: BrowserNode): boolean {\n return this.responders.has(node);\n }\n\n setResponder(node: BrowserNode, handlers: ResponderHandlers): () => void {\n this.responders.set(node, handlers);\n return () => {\n this.responders.delete(node);\n if (this.current !== node) return;\n // Torn down mid-gesture: no release is coming, so the responder is cleared here or the\n // negotiation would believe forever that a node no longer registered still holds it.\n this.current = null;\n };\n }\n\n /** Root-first capture, then target-first bubble. Mirrors `engine.ts`'s `negotiate`. */\n private negotiate(\n target: BrowserNode,\n event: ResponderEvent,\n phase: 'Start' | 'Move',\n ): BrowserNode | null {\n const path = pathTo(target);\n const capture = `on${phase}ShouldSetResponderCapture` as const;\n const bubble = `on${phase}ShouldSetResponder` as const;\n\n for (const node of path) {\n if (this.responders.get(node)?.[capture]?.(event, target as never)) return node;\n }\n for (let i = path.length - 1; i >= 0; i--) {\n if (this.responders.get(path[i]!)?.[bubble]?.(event, target as never)) return path[i]!;\n }\n return null;\n }\n\n private grant(node: BrowserNode, event: ResponderEvent): void {\n const previous = this.current;\n if (previous === node) return;\n\n if (previous) {\n const handlers = this.responders.get(previous);\n // `undefined` means yes: RN's default is to allow the takeover.\n if (handlers?.onResponderTerminationRequest?.(event) === false) return;\n handlers?.onResponderTerminate?.(event);\n }\n\n this.current = node;\n this.responders.get(node)?.onResponderGrant?.(event);\n }\n\n private release(event: ResponderEvent, terminated: boolean): void {\n const node = this.current;\n if (!node) return;\n this.current = null;\n const handlers = this.responders.get(node);\n if (terminated) handlers?.onResponderTerminate?.(event);\n else handlers?.onResponderRelease?.(event);\n }\n\n /** Drives the negotiation from a synthesised `topTouchStart`/`Move`/`End`/`Cancel`. */\n runResponder(target: BrowserNode, type: string, event: ResponderEvent): void {\n if (type === 'topTouchStart') {\n const elected = this.negotiate(target, event, 'Start');\n if (elected) this.grant(elected, event);\n return;\n }\n if (type === 'topTouchMove') {\n if (this.current) this.responders.get(this.current)?.onResponderMove?.(event);\n else {\n const elected = this.negotiate(target, event, 'Move');\n if (elected) this.grant(elected, event);\n }\n return;\n }\n if (type === 'topTouchEnd') this.release(event, false);\n else if (type === 'topTouchCancel') this.release(event, true);\n }\n\n /** A scroll container moved under the finger. Cancels a press inside it; see the file doc. */\n notifyScroll(scrollNode: BrowserNode): void {\n const responder = this.current;\n if (!responder || responder === scrollNode) return;\n for (let node: BrowserNode | null = responder; node; node = node.parent) {\n if (node === scrollNode) {\n this.release(new SyntheticEvent({}), true);\n return;\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"responder.js","sourceRoot":"","sources":["../src/responder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,cAAc,EAA+C,MAAM,mBAAmB,CAAC;AAChG,OAAO,EAAoB,MAAM,EAAE,MAAM,eAAe,CAAC;AAEzD,iFAAiF;AACjF,SAAS,cAAc,CAAC,CAAc,EAAE,CAAc;IACpD,KAAK,IAAI,IAAI,GAAuB,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,MAAM;QAAE,IAAI,IAAI,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC;IAC1F,MAAM,KAAK,GAAG,IAAI,GAAG,EAAe,CAAC;IACrC,KAAK,IAAI,IAAI,GAAuB,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,MAAM;QAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjF,KAAK,IAAI,IAAI,GAAuB,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,MAAM;QAAE,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;IAClG,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,OAAO,eAAe;IACT,UAAU,GAAG,IAAI,OAAO,EAAkC,CAAC;IACpE,OAAO,GAAuB,IAAI,CAAC;IAE3C,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,gGAAgG;IAChG,QAAQ,CAAC,I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AAC,OAAO,CAAC,IAAI,cAAc,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;gBAC3C,OAAO;YACT,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * The JS responder negotiation, over DOM pointer events instead of Fabric's raw touch stream.\n *\n * `packages/fabric/src/engine.ts` runs a two-phase election on every `topTouchStart`: a capture\n * pass root-to-target where an ancestor (a scroll view) can pre-empt, then a bubble pass\n * target-to-root where the innermost interested node wins. Exactly one node ever holds the\n * gesture, and a `grant` can be refused by `onResponderTerminationRequest`. This file is that\n * algorithm, ported line for line from `negotiate`/`grant`/`release` in `engine.ts`, over\n * `BrowserNode`'s `.parent` chain instead of `EngineNode`'s.\n *\n * ## What is faithfully reproduced\n *\n * The whole negotiation: capture pre-emption, bubble election, a node above the responder taking\n * the touch on a move, termination requests, and a scroll view taking over a drag mid-press\n * (`notifyScroll`, the counterpart of `engine.ts`'s `cancelPressForScroll`). `pressable.test.ts`-equivalent scenarios - a pressable nested in a\n * scroll view nested in a dialog - behave the same on both platforms because this is the same\n * algorithm, not a different one that happens to agree on simple cases.\n *\n * ## What differs, and why\n *\n * There is no native side to tell who currently owns the gesture (`tellNative`/`setIsJSResponder`\n * in `engine.ts`): a DOM scroll container has no separate \"JS responder\" concept to defer to, it\n * simply does not receive the pointer events this system does not propagate to it as a drag. So\n * `blockNativeResponder` is accepted (for API parity - a component that sets it does not break)\n * and does nothing, which is a real gap only for a native scroll gesture that would otherwise\n * fight a JS one; on the web the browser's own scroll only starts from events this system's\n * `setPointerCapture` call (`browser-engine.ts`) already keeps from reaching it while a responder\n * holds the gesture.\n *\n * `notifyScroll`'s cancellation is coarser than `engine.ts`'s: native tells the responder system\n * apart a real drag from a momentum settle or a programmatic `scrollTo` because it is the same\n * code sending both `topScroll` and `topScrollBeginDrag`. A DOM `scroll` event carries no such\n * distinction, so this cancels on the first `scroll` a descendant responder sees, drag or not.\n * The one case that reads differently: a programmatic `scrollTo()` call that happens to run while\n * something inside that scroll view is mid-press will cancel the press on the web and not on\n * native. Narrow, and named here rather than found by a user later.\n */\nimport { SyntheticEvent, type ResponderEvent, type ResponderHandlers } from '@ng-native/fabric';\nimport { type BrowserNode, pathTo } from './dom-node.ts';\n\n/** The lowest node both are in, either of them included. Mirrors `engine.ts`. */\nfunction commonAncestor(a: BrowserNode, b: BrowserNode): BrowserNode | null {\n for (let node: BrowserNode | null = b; node; node = node.parent) if (node === a) return a;\n const above = new Set<BrowserNode>();\n for (let node: BrowserNode | null = a; node; node = node.parent) above.add(node);\n for (let node: BrowserNode | null = b; node; node = node.parent) if (above.has(node)) return node;\n return null;\n}\n\nexport class ResponderSystem {\n private readonly responders = new WeakMap<BrowserNode, ResponderHandlers>();\n private current: BrowserNode | null = null;\n\n get responder(): BrowserNode | null {\n return this.current;\n }\n\n /** Whether `node` takes part in the negotiation at all: a control, rather than a plain view. */\n responds(node: BrowserNode): boolean {\n return this.responders.has(node);\n }\n\n setResponder(node: BrowserNode, handlers: ResponderHandlers): () => void {\n this.responders.set(node, handlers);\n return () => {\n this.responders.delete(node);\n if (this.current !== node) return;\n // Torn down mid-gesture: no release is coming, so the responder is cleared here or the\n // negotiation would believe forever that a node no longer registered still holds it.\n this.current = null;\n };\n }\n\n /** Root-first capture, then target-first bubble. Mirrors `engine.ts`'s `negotiate`. */\n private negotiate(\n target: BrowserNode,\n event: ResponderEvent,\n phase: 'Start' | 'Move',\n from: BrowserNode = target,\n ): BrowserNode | null {\n const path = pathTo(from);\n const capture = `on${phase}ShouldSetResponderCapture` as const;\n const bubble = `on${phase}ShouldSetResponder` as const;\n\n for (const node of path) {\n if (this.responders.get(node)?.[capture]?.(event, target as never)) return node;\n }\n for (let i = path.length - 1; i >= 0; i--) {\n if (this.responders.get(path[i]!)?.[bubble]?.(event, target as never)) return path[i]!;\n }\n return null;\n }\n\n private grant(node: BrowserNode, event: ResponderEvent): void {\n const previous = this.current;\n if (previous === node) return;\n\n if (previous) {\n const handlers = this.responders.get(previous);\n // `undefined` means yes: RN's default is to allow the takeover.\n if (handlers?.onResponderTerminationRequest?.(event) === false) return;\n handlers?.onResponderTerminate?.(event);\n }\n\n this.current = node;\n this.responders.get(node)?.onResponderGrant?.(event);\n }\n\n private release(event: ResponderEvent, terminated: boolean): void {\n const node = this.current;\n if (!node) return;\n this.current = null;\n const handlers = this.responders.get(node);\n if (terminated) handlers?.onResponderTerminate?.(event);\n else handlers?.onResponderRelease?.(event);\n }\n\n /** Drives the negotiation from a synthesised `topTouchStart`/`Move`/`End`/`Cancel`. */\n runResponder(target: BrowserNode, type: string, event: ResponderEvent): void {\n if (type === 'topTouchStart') {\n const elected = this.negotiate(target, event, 'Start');\n if (elected) this.grant(elected, event);\n return;\n }\n if (type === 'topTouchMove') this.move(target, event);\n else if (type === 'topTouchEnd') this.release(event, false);\n else if (type === 'topTouchCancel') this.release(event, true);\n }\n\n /** Asked on every move, from above both the responder and the target. Mirrors `engine.ts`. */\n private move(target: BrowserNode, event: ResponderEvent): void {\n const holder = this.current;\n const from = holder ? commonAncestor(holder, target) : target;\n const elected = from ? this.negotiate(target, event, 'Move', from) : null;\n if (elected && elected !== holder) this.grant(elected, event);\n if (this.current) this.responders.get(this.current)?.onResponderMove?.(event);\n }\n\n /** A scroll container moved under the finger. Cancels a press inside it; see the file doc. */\n notifyScroll(scrollNode: BrowserNode): void {\n const responder = this.current;\n if (!responder || responder === scrollNode) return;\n for (let node: BrowserNode | null = responder; node; node = node.parent) {\n if (node === scrollNode) {\n this.release(new SyntheticEvent({}), true);\n return;\n }\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-native/web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "A browser host for Angular Native: the same components, rendered into the DOM instead of native views.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ng-native/device": "0.
|
|
39
|
-
"@ng-native/fabric": "0.
|
|
38
|
+
"@ng-native/device": "0.18.0",
|
|
39
|
+
"@ng-native/fabric": "0.18.0",
|
|
40
40
|
"@oxc-angular/vite": "0.0.41"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
"@angular/localize": "22.2.0",
|
|
55
55
|
"@angular/platform-browser": "22.2.0",
|
|
56
56
|
"@ng-icons/core": "^36.0.0",
|
|
57
|
-
"@ng-native/components": "0.
|
|
58
|
-
"@ng-native/icons": "0.
|
|
59
|
-
"@ng-native/metro": "0.
|
|
60
|
-
"@ng-native/tailwind": "0.
|
|
61
|
-
"@ng-native/testing": "0.
|
|
57
|
+
"@ng-native/components": "0.18.0",
|
|
58
|
+
"@ng-native/icons": "0.18.0",
|
|
59
|
+
"@ng-native/metro": "0.18.0",
|
|
60
|
+
"@ng-native/tailwind": "0.18.0",
|
|
61
|
+
"@ng-native/testing": "0.18.0",
|
|
62
62
|
"@tailwindcss/vite": "^4.3.3",
|
|
63
63
|
"@types/jsdom": "^27.0.0",
|
|
64
64
|
"@vitest/browser": "^5.0.2",
|