@gtkx/react 1.0.0-rc.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/adw/dialog.d.ts +3 -4
- package/dist/adw/dialog.d.ts.map +1 -1
- package/dist/adw/dialog.js +18 -21
- package/dist/adw/dialog.js.map +1 -1
- package/dist/adw/element-behaviors.js +102 -54
- package/dist/adw/element-behaviors.js.map +1 -1
- package/dist/adw/element-config.d.ts +0 -6
- package/dist/adw/element-config.d.ts.map +1 -1
- package/dist/adw/element-config.js +15 -17
- package/dist/adw/element-config.js.map +1 -1
- package/dist/adw/prop-types.d.ts +34 -3
- package/dist/adw/prop-types.d.ts.map +1 -1
- package/dist/adw/prop-types.js.map +1 -1
- package/dist/components/application-window.d.ts +5 -0
- package/dist/components/application-window.d.ts.map +1 -0
- package/dist/components/application-window.js +7 -0
- package/dist/components/application-window.js.map +1 -0
- package/dist/components/application.d.ts +2 -8
- package/dist/components/application.d.ts.map +1 -1
- package/dist/components/application.js +31 -7
- package/dist/components/application.js.map +1 -1
- package/dist/components/element.d.ts +13 -1
- package/dist/components/element.d.ts.map +1 -1
- package/dist/components/element.js +39 -14
- package/dist/components/element.js.map +1 -1
- package/dist/components/portaled.d.ts +5 -0
- package/dist/components/portaled.d.ts.map +1 -0
- package/dist/components/portaled.js +8 -0
- package/dist/components/portaled.js.map +1 -0
- package/dist/components/window.d.ts +5 -5
- package/dist/components/window.d.ts.map +1 -1
- package/dist/components/window.js +16 -16
- package/dist/components/window.js.map +1 -1
- package/dist/config.d.ts +3 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -1
- package/dist/element-behaviors.js +11 -1
- package/dist/element-behaviors.js.map +1 -1
- package/dist/element-config.d.ts.map +1 -1
- package/dist/element-config.js +7 -4
- package/dist/element-config.js.map +1 -1
- package/dist/hooks/use-merged-refs.d.ts +1 -4
- package/dist/hooks/use-merged-refs.d.ts.map +1 -1
- package/dist/hooks/use-merged-refs.js +1 -1
- package/dist/hooks/use-merged-refs.js.map +1 -1
- package/dist/hooks/use-presented-instance.d.ts +12 -0
- package/dist/hooks/use-presented-instance.d.ts.map +1 -0
- package/dist/hooks/use-presented-instance.js +27 -0
- package/dist/hooks/use-presented-instance.js.map +1 -0
- package/dist/hooks/use-property.d.ts +2 -1
- package/dist/hooks/use-property.d.ts.map +1 -1
- package/dist/hooks/use-property.js.map +1 -1
- package/dist/hooks/use-signal.d.ts +2 -1
- package/dist/hooks/use-signal.d.ts.map +1 -1
- package/dist/hooks/use-signal.js.map +1 -1
- package/dist/internal.d.ts +5 -3
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +5 -2
- package/dist/internal.js.map +1 -1
- package/dist/prop-types.d.ts +29 -5
- package/dist/prop-types.d.ts.map +1 -1
- package/dist/prop-types.js.map +1 -1
- package/dist/reconciler/apply-props.d.ts +4 -4
- package/dist/reconciler/apply-props.d.ts.map +1 -1
- package/dist/reconciler/apply-props.js +62 -20
- package/dist/reconciler/apply-props.js.map +1 -1
- package/dist/reconciler/behaviors.d.ts +9 -5
- package/dist/reconciler/behaviors.d.ts.map +1 -1
- package/dist/reconciler/behaviors.js +40 -22
- package/dist/reconciler/behaviors.js.map +1 -1
- package/dist/reconciler/devtools.d.ts +6 -0
- package/dist/reconciler/devtools.d.ts.map +1 -0
- package/dist/reconciler/devtools.js +11 -0
- package/dist/reconciler/devtools.js.map +1 -0
- package/dist/reconciler/host-config.d.ts.map +1 -1
- package/dist/reconciler/host-config.js +18 -25
- package/dist/reconciler/host-config.js.map +1 -1
- package/dist/reconciler/instance.d.ts.map +1 -1
- package/dist/reconciler/instance.js +5 -3
- package/dist/reconciler/instance.js.map +1 -1
- package/dist/reconciler/metadata.d.ts +1 -1
- package/dist/reconciler/metadata.d.ts.map +1 -1
- package/dist/reconciler/metadata.js +2 -4
- package/dist/reconciler/metadata.js.map +1 -1
- package/dist/reconciler/node.d.ts +3 -2
- package/dist/reconciler/node.d.ts.map +1 -1
- package/dist/reconciler/node.js +7 -6
- package/dist/reconciler/node.js.map +1 -1
- package/dist/reconciler/placement.js +20 -20
- package/dist/reconciler/placement.js.map +1 -1
- package/dist/reconciler/registry.d.ts +9 -7
- package/dist/reconciler/registry.d.ts.map +1 -1
- package/dist/reconciler/registry.js.map +1 -1
- package/dist/reconciler/root-element.d.ts +1 -0
- package/dist/reconciler/root-element.d.ts.map +1 -1
- package/dist/reconciler/root-element.js.map +1 -1
- package/dist/reconciler/root.d.ts +17 -3
- package/dist/reconciler/root.d.ts.map +1 -1
- package/dist/reconciler/root.js +22 -8
- package/dist/reconciler/root.js.map +1 -1
- package/dist/reconciler/signals.d.ts +1 -2
- package/dist/reconciler/signals.d.ts.map +1 -1
- package/dist/reconciler/signals.js +1 -1
- package/dist/reconciler/signals.js.map +1 -1
- package/dist/utils/accessible-props.d.ts +8 -8
- package/dist/utils/accessible-props.d.ts.map +1 -1
- package/dist/utils/accessible-props.js +11 -13
- package/dist/utils/accessible-props.js.map +1 -1
- package/dist/utils/settings.d.ts +2 -1
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/settings.js.map +1 -1
- package/dist/utils/variant.d.ts +33 -1
- package/dist/utils/variant.d.ts.map +1 -1
- package/dist/utils/variant.js.map +1 -1
- package/package.json +14 -4
- package/src/adw/dialog.tsx +25 -25
- package/src/adw/element-behaviors.ts +129 -57
- package/src/adw/element-config.ts +15 -17
- package/src/adw/prop-types.ts +35 -2
- package/src/components/application-window.tsx +10 -0
- package/src/components/application.tsx +45 -6
- package/src/components/element.tsx +52 -16
- package/src/components/portaled.tsx +14 -0
- package/src/components/window.tsx +24 -23
- package/src/config.ts +10 -1
- package/src/element-behaviors.ts +20 -0
- package/src/element-config.ts +7 -4
- package/src/hooks/use-merged-refs.ts +1 -1
- package/src/hooks/use-presented-instance.tsx +50 -0
- package/src/hooks/use-property.ts +2 -1
- package/src/hooks/use-signal.ts +2 -1
- package/src/internal.ts +5 -3
- package/src/prop-types.ts +34 -7
- package/src/reconciler/apply-props.ts +77 -24
- package/src/reconciler/behaviors.ts +72 -30
- package/src/reconciler/devtools.ts +18 -0
- package/src/reconciler/host-config.ts +20 -30
- package/src/reconciler/instance.ts +6 -3
- package/src/reconciler/metadata.ts +3 -6
- package/src/reconciler/node.ts +10 -7
- package/src/reconciler/placement.ts +25 -25
- package/src/reconciler/registry.ts +9 -7
- package/src/reconciler/root-element.ts +4 -1
- package/src/reconciler/root.ts +38 -12
- package/src/reconciler/signals.ts +0 -1
- package/src/utils/accessible-props.ts +21 -24
- package/src/utils/settings.ts +2 -1
- package/src/utils/variant.ts +33 -1
- package/dist/utils/accessible-metadata.d.ts +0 -5
- package/dist/utils/accessible-metadata.d.ts.map +0 -1
- package/dist/utils/accessible-metadata.js +0 -18
- package/dist/utils/accessible-metadata.js.map +0 -1
- package/src/utils/accessible-metadata.ts +0 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placement.js","sourceRoot":"","sources":["../../src/reconciler/placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACH,YAAY,EACZ,YAAY,EAEZ,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,UAAU,GAGb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAI1C,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,IAAmB,EAAsB,EAAE;IAC1E,M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AAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAEhE,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACf,OAAO;IACX,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAEzC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,SAAS,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { getOrInsert, indexBeforeOrEnd, remove } from \"@gtkx/utils\";\nimport type { DetachInfo, ElementBehavior, PlaceInfo } from \"./registry.js\";\nimport { applyAdoptedProps, markFlush } from \"./apply-props.js\";\nimport { typeInfoFor } from \"./metadata.js\";\nimport {\n DEFAULT_SLOT,\n ELEMENT_KIND,\n type ElementNode,\n getOrCreateContext,\n LAZY_KIND,\n lazyTarget,\n nodeObject,\n type PlaceableNode,\n type PlacedChild,\n} from \"./node.js\";\nimport { applyWrite } from \"./signals.js\";\nimport { markTextDirty } from \"./text.js\";\n\ntype AttachContext = { parent: ElementNode; entry: PlacedChild; index: number; sibling: GObject.Object | null };\n\nconst createEntry = (slot: string, node: PlaceableNode): PlacedChild | null => {\n const object = nodeObject(node);\n\n if (object === null) {\n return null;\n }\n\n return { node, object, adopted: null, slot, behavior: null, isAttached: false };\n};\n\nconst siblingAt = (entries: PlacedChild[], index: number): GObject.Object | null =>\n index > 0 ? (entries[index - 1]?.object ?? null) : null;\n\nconst placeInfo = (entry: PlacedChild, index: number, sibling: GObject.Object | null, context: unknown): PlaceInfo => ({\n slot: entry.slot,\n index,\n sibling,\n adopted: entry.adopted,\n props: entry.node.props,\n context,\n});\n\nconst adoptedFrom = (parent: ElementNode, entry: PlacedChild, behavior: ElementBehavior, claim: unknown): void => {\n if (behavior.resolve !== undefined) {\n entry.adopted = behavior.resolve(parent.object, entry.object);\n\n return;\n }\n\n entry.adopted = claim instanceof GObject.Object ? claim : null;\n};\n\nconst applyLazyProps = (entry: PlacedChild): void => {\n if (entry.node.kind !== LAZY_KIND || entry.adopted === null) {\n return;\n }\n\n applyAdoptedProps(lazyTarget(entry.node, entry.adopted), {}, entry.node.props);\n entry.node.adopted = entry.adopted;\n};\n\nconst wireBufferView = (node: PlaceableNode, parent: ElementNode): void => {\n if (!(node.kind === ELEMENT_KIND && node.contentKind === \"buffer\" && parent.object instanceof Gtk.TextView)) {\n return;\n }\n\n node.bufferView = parent.object;\n markTextDirty(node);\n};\n\nconst writeSlot = (parent: ElementNode, entry: PlacedChild, value: GObject.Object | null): void => {\n applyWrite(() => {\n Reflect.set(parent.object, entry.slot, value);\n });\n};\n\nconst setObjectSlot = (parent: ElementNode, entry: PlacedChild): void => {\n writeSlot(parent, entry, entry.object);\n wireBufferView(entry.node, parent);\n entry.behavior = null;\n entry.isAttached = true;\n};\n\nconst didAttach = (ctx: AttachContext, behavior: ElementBehavior): boolean => {\n const attach = behavior.attach;\n\n if (attach === undefined) {\n return false;\n }\n\n const context = getOrCreateContext(ctx.parent, behavior);\n const claim = attach(ctx.parent.object, ctx.entry.object, placeInfo(ctx.entry, ctx.index, ctx.sibling, context));\n\n if (claim === undefined) {\n return false;\n }\n\n ctx.entry.behavior = behavior;\n adoptedFrom(ctx.parent, ctx.entry, behavior, claim);\n ctx.entry.isAttached = true;\n applyLazyProps(ctx.entry);\n\n return true;\n};\n\nconst runAttach = (parent: ElementNode, entry: PlacedChild, index: number, sibling: GObject.Object | null): void => {\n const ctx: AttachContext = { parent, entry, index, sibling };\n\n for (const behavior of typeInfoFor(parent.typeName).behaviors) {\n if (didAttach(ctx, behavior)) {\n return;\n }\n }\n\n if (entry.slot !== DEFAULT_SLOT) {\n setObjectSlot(parent, entry);\n }\n};\n\nconst attachEntry = (parent: ElementNode, entry: PlacedChild, index: number, sibling: GObject.Object | null): void => {\n applyWrite(() => {\n runAttach(parent, entry, index, sibling);\n });\n};\n\nconst detachInfo = (entry: PlacedChild, context: unknown): DetachInfo => ({\n slot: entry.slot,\n adopted: entry.adopted,\n props: entry.node.props,\n context,\n});\n\nconst runDetach = (parent: ElementNode, entry: PlacedChild): void => {\n const behavior = entry.behavior;\n\n if (behavior === null) {\n if (entry.slot !== DEFAULT_SLOT) {\n writeSlot(parent, entry, null);\n }\n\n return;\n }\n\n behavior.detach?.(parent.object, entry.object, detachInfo(entry, getOrCreateContext(parent, behavior)));\n};\n\nconst detachEntry = (parent: ElementNode, entry: PlacedChild): void => {\n if (!entry.isAttached) {\n return;\n }\n\n entry.isAttached = false;\n\n applyWrite(() => {\n runDetach(parent, entry);\n });\n};\n\nconst rebuild = (parent: ElementNode, entries: PlacedChild[]): void => {\n for (const entry of entries) {\n detachEntry(parent, entry);\n }\n\n for (const [index, entry] of entries.entries()) {\n entry.behavior = null;\n attachEntry(parent, entry, index, siblingAt(entries, index));\n }\n};\n\nconst getPosition = (entries: PlacedChild[], before: PlaceableNode | null): number =>\n indexBeforeOrEnd(entries, before, (entry, target) => entry.node === target);\n\nconst placeNew = (parent: ElementNode, entry: PlacedChild, entries: PlacedChild[], index: number): void => {\n attachEntry(parent, entry, index, siblingAt(entries, index));\n\n if (!entry.isAttached) {\n remove(entries, entry);\n\n return;\n }\n\n const isInsertedBeforeEnd = index < entries.length - 1;\n const isCannotReorderInPlace = entry.behavior !== null && entry.behavior.reorder === undefined;\n\n if (isInsertedBeforeEnd && isCannotReorderInPlace) {\n rebuild(parent, entries);\n }\n};\n\nconst moveEntry = (parent: ElementNode, entry: PlacedChild, entries: PlacedChild[], index: number): void => {\n const behavior = entry.behavior;\n const reorder = behavior?.reorder;\n\n if (behavior === null || reorder === undefined) {\n rebuild(parent, entries);\n\n return;\n }\n\n const context = getOrCreateContext(parent, behavior);\n const claim = reorder(parent.object, entry.object, placeInfo(entry, index, siblingAt(entries, index), context));\n adoptedFrom(parent, entry, behavior, claim);\n applyLazyProps(entry);\n};\n\nconst resolveEntry = (\n entries: PlacedChild[],\n existing: number,\n slot: string,\n node: PlaceableNode,\n): PlacedChild | null => {\n if (existing >= 0) {\n return entries[existing] ?? null;\n }\n\n return createEntry(slot, node);\n};\n\nconst placeChild = (\n parent: ElementNode,\n slot: string,\n node: PlaceableNode,\n before: PlaceableNode | null,\n): void => {\n const entries = getOrInsert(parent.placements, slot, () => []);\n const existing = entries.findIndex((entry) => entry.node === node);\n const entry = resolveEntry(entries, existing, slot, node);\n\n if (entry === null) {\n return;\n }\n\n const isMove = existing !== -1;\n\n if (isMove) {\n entries.splice(existing, 1);\n }\n\n const index = getPosition(entries, before);\n entries.splice(index, 0, entry);\n\n if (isMove) {\n moveEntry(parent, entry, entries, index);\n } else {\n placeNew(parent, entry, entries, index);\n }\n\n markFlush(parent);\n};\n\nconst unplaceChild = (parent: ElementNode, slot: string, node: PlaceableNode): void => {\n const entries = parent.placements.get(slot);\n\n if (entries === undefined) {\n return;\n }\n\n const index = entries.findIndex((entry) => entry.node === node);\n\n if (index === -1) {\n return;\n }\n\n const [entry] = entries.splice(index, 1);\n\n if (entry !== undefined) {\n detachEntry(parent, entry);\n }\n\n markFlush(parent);\n};\n\nexport { placeChild, unplaceChild };\n"]}
|
|
1
|
+
{"version":3,"file":"placement.js","sourceRoot":"","sources":["../../src/reconciler/placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,e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MAAmB,EAAE,IAAY,EAAE,IAAmB,EAAQ,EAAE;IAClF,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAE5C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO;IACX,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAEhE,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACf,OAAO;IACX,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAEzC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,SAAS,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { getOrInsert, indexBeforeOrEnd } from \"@gtkx/utils\";\nimport type { DetachInfo, ElementBehavior, PlaceInfo } from \"./registry.js\";\nimport { applyAdoptedProps, markFlush } from \"./apply-props.js\";\nimport { typeInfoFor } from \"./metadata.js\";\nimport {\n DEFAULT_SLOT,\n ELEMENT_KIND,\n type ElementNode,\n getOrCreateContext,\n LAZY_KIND,\n lazyTarget,\n leafElement,\n type PlaceableNode,\n type PlacedChild,\n} from \"./node.js\";\nimport { applyWrite } from \"./signals.js\";\nimport { markTextDirty } from \"./text.js\";\n\ntype AttachContext = { parent: ElementNode; entry: PlacedChild; index: number; sibling: GObject.Object | null };\n\nconst createEntry = (slot: string, node: PlaceableNode): PlacedChild | null => {\n const leaf = leafElement(node);\n\n if (leaf === null) {\n return null;\n }\n\n return {\n node,\n object: leaf.object,\n typeName: leaf.typeName,\n adopted: null,\n slot,\n behavior: null,\n };\n};\n\nconst siblingAt = (entries: PlacedChild[], index: number): GObject.Object | null =>\n index > 0 ? (entries[index - 1]?.object ?? null) : null;\n\nconst placeInfo = (entry: PlacedChild, index: number, sibling: GObject.Object | null, context: unknown): PlaceInfo => ({\n slot: entry.slot,\n index,\n sibling,\n adopted: entry.adopted,\n props: entry.node.props,\n context,\n});\n\nconst adoptedFrom = (parent: ElementNode, entry: PlacedChild, behavior: ElementBehavior, claim: unknown): void => {\n if (behavior.resolve !== undefined) {\n entry.adopted = behavior.resolve(parent.object, entry.object);\n\n return;\n }\n\n entry.adopted = claim instanceof GObject.Object ? claim : null;\n};\n\nconst applyLazyProps = (entry: PlacedChild): void => {\n if (entry.node.kind !== LAZY_KIND || entry.adopted === null) {\n return;\n }\n\n applyAdoptedProps(lazyTarget(entry.node, entry.adopted), {}, entry.node.props);\n entry.node.adopted = entry.adopted;\n};\n\nconst wireBufferView = (node: PlaceableNode, parent: ElementNode): void => {\n if (!(node.kind === ELEMENT_KIND && node.contentKind === \"buffer\" && parent.object instanceof Gtk.TextView)) {\n return;\n }\n\n node.bufferView = parent.object;\n markTextDirty(node);\n};\n\nconst writeSlot = (parent: ElementNode, entry: PlacedChild, value: GObject.Object | null): void => {\n applyWrite(() => {\n Reflect.set(parent.object, entry.slot, value);\n });\n};\n\nconst setObjectSlot = (parent: ElementNode, entry: PlacedChild): void => {\n writeSlot(parent, entry, entry.object);\n wireBufferView(entry.node, parent);\n entry.behavior = null;\n};\n\nconst didAttach = (ctx: AttachContext, behavior: ElementBehavior): boolean => {\n const attach = behavior.attach;\n\n if (attach === undefined) {\n return false;\n }\n\n const context = getOrCreateContext(ctx.parent, behavior);\n const claim = attach(ctx.parent.object, ctx.entry.object, placeInfo(ctx.entry, ctx.index, ctx.sibling, context));\n\n if (claim === undefined) {\n return false;\n }\n\n ctx.entry.behavior = behavior;\n adoptedFrom(ctx.parent, ctx.entry, behavior, claim);\n applyLazyProps(ctx.entry);\n\n return true;\n};\n\nconst unclaimedChildError = (parentTypeName: string, childTypeName: string): Error =>\n new Error(\n `<${childTypeName}> cannot be a child of <${parentTypeName}>. Pass it to the ` +\n `<${parentTypeName}> prop that takes it, if there is one, portal it to rootElement with createPortal ` +\n `if it does not belong inside <${parentTypeName}>, or register an attach behavior for ` +\n `<${parentTypeName}> with defineElements from \"@gtkx/react/config\" if it belongs among its children.`,\n );\n\nconst runAttach = (parent: ElementNode, entry: PlacedChild, index: number, sibling: GObject.Object | null): void => {\n const ctx: AttachContext = { parent, entry, index, sibling };\n\n for (const behavior of typeInfoFor(parent.typeName).behaviors) {\n if (didAttach(ctx, behavior)) {\n return;\n }\n }\n\n if (entry.slot === DEFAULT_SLOT) {\n throw unclaimedChildError(parent.typeName, entry.typeName);\n }\n\n setObjectSlot(parent, entry);\n};\n\nconst attachEntry = (parent: ElementNode, entry: PlacedChild, index: number, sibling: GObject.Object | null): void => {\n applyWrite(() => {\n runAttach(parent, entry, index, sibling);\n });\n};\n\nconst detachInfo = (entry: PlacedChild, context: unknown): DetachInfo => ({\n slot: entry.slot,\n adopted: entry.adopted,\n props: entry.node.props,\n context,\n});\n\nconst runDetach = (parent: ElementNode, entry: PlacedChild): void => {\n const behavior = entry.behavior;\n\n if (behavior === null) {\n writeSlot(parent, entry, null);\n\n return;\n }\n\n behavior.detach?.(parent.object, entry.object, detachInfo(entry, getOrCreateContext(parent, behavior)));\n};\n\nconst detachEntry = (parent: ElementNode, entry: PlacedChild): void => {\n applyWrite(() => {\n runDetach(parent, entry);\n });\n};\n\nconst rebuild = (parent: ElementNode, entries: PlacedChild[]): void => {\n for (const entry of entries) {\n detachEntry(parent, entry);\n }\n\n for (const [index, entry] of entries.entries()) {\n entry.behavior = null;\n attachEntry(parent, entry, index, siblingAt(entries, index));\n }\n};\n\nconst getPosition = (entries: PlacedChild[], before: PlaceableNode | null): number =>\n indexBeforeOrEnd(entries, before, (entry, target) => entry.node === target);\n\nconst placeNew = (parent: ElementNode, entry: PlacedChild, entries: PlacedChild[], index: number): void => {\n attachEntry(parent, entry, index, siblingAt(entries, index));\n const isInsertedBeforeEnd = index < entries.length - 1;\n const isCannotReorderInPlace = entry.behavior !== null && entry.behavior.reorder === undefined;\n\n if (isInsertedBeforeEnd && isCannotReorderInPlace) {\n rebuild(parent, entries);\n }\n};\n\nconst moveEntry = (parent: ElementNode, entry: PlacedChild, entries: PlacedChild[], index: number): void => {\n const behavior = entry.behavior;\n const reorder = behavior?.reorder;\n\n if (behavior === null || reorder === undefined) {\n rebuild(parent, entries);\n\n return;\n }\n\n const context = getOrCreateContext(parent, behavior);\n const claim = reorder(parent.object, entry.object, placeInfo(entry, index, siblingAt(entries, index), context));\n adoptedFrom(parent, entry, behavior, claim);\n applyLazyProps(entry);\n};\n\nconst resolveEntry = (\n entries: PlacedChild[],\n existing: number,\n slot: string,\n node: PlaceableNode,\n): PlacedChild | null => {\n if (existing >= 0) {\n return entries[existing] ?? null;\n }\n\n return createEntry(slot, node);\n};\n\nconst placeChild = (\n parent: ElementNode,\n slot: string,\n node: PlaceableNode,\n before: PlaceableNode | null,\n): void => {\n const entries = getOrInsert(parent.placements, slot, () => []);\n const existing = entries.findIndex((entry) => entry.node === node);\n const entry = resolveEntry(entries, existing, slot, node);\n\n if (entry === null) {\n return;\n }\n\n const isMove = existing !== -1;\n\n if (isMove) {\n entries.splice(existing, 1);\n }\n\n const index = getPosition(entries, before);\n entries.splice(index, 0, entry);\n\n if (isMove) {\n moveEntry(parent, entry, entries, index);\n } else {\n placeNew(parent, entry, entries, index);\n }\n\n markFlush(parent);\n};\n\nconst unplaceChild = (parent: ElementNode, slot: string, node: PlaceableNode): void => {\n const entries = parent.placements.get(slot);\n\n if (entries === undefined) {\n return;\n }\n\n const index = entries.findIndex((entry) => entry.node === node);\n\n if (index === -1) {\n return;\n }\n\n const [entry] = entries.splice(index, 1);\n\n if (entry !== undefined) {\n detachEntry(parent, entry);\n }\n\n markFlush(parent);\n};\n\nexport { placeChild, unplaceChild };\n"]}
|
|
@@ -29,9 +29,9 @@ type DetachInfo = {
|
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
31
|
* Customizes how one element type places children and applies props. Hooks other than `create` receive the
|
|
32
|
-
* GObject instance; `update
|
|
33
|
-
* `
|
|
34
|
-
*
|
|
32
|
+
* GObject instance; `update` and `flush` also take the private per-node context `initialize` built, and
|
|
33
|
+
* `attach`, `reorder` and `detach` read it off their info object. Subtypes inherit a type's behaviors,
|
|
34
|
+
* except for `create`, which is consulted only for the type it is registered on.
|
|
35
35
|
*/
|
|
36
36
|
type ElementBehavior<T extends GObject.Object = GObject.Object> = {
|
|
37
37
|
/** Builds the GObject from its construct props, for types whose constructor does more than set properties. */
|
|
@@ -50,12 +50,14 @@ type ElementBehavior<T extends GObject.Object = GObject.Object> = {
|
|
|
50
50
|
update?: (object: T, prev: Props, next: Props, context: unknown) => Iterable<string> | undefined;
|
|
51
51
|
/** Runs after the commit that touched the node, once every child has been placed. */
|
|
52
52
|
flush?: (object: T, context: unknown) => void;
|
|
53
|
-
/** Runs once the node and its initial children are attached. */
|
|
54
|
-
mount?: (object: T, context: unknown) => void;
|
|
55
|
-
/** Runs when React deletes the node. */
|
|
56
|
-
unmount?: (object: T, context: unknown) => void;
|
|
57
53
|
/** Props to withhold from the constructor, leaving them for a later hook to apply. */
|
|
58
54
|
deferred?: string[];
|
|
55
|
+
/**
|
|
56
|
+
* Props the behavior can only apply while the element is being built, because the library exposes no
|
|
57
|
+
* counterpart to whatever applied them. Changing one after it has been applied throws instead of
|
|
58
|
+
* silently applying the new value on top of the old.
|
|
59
|
+
*/
|
|
60
|
+
constructOnly?: string[];
|
|
59
61
|
};
|
|
60
62
|
/** A named export in a module, referenced as plain data (the module is never imported at runtime). */
|
|
61
63
|
type ModuleExport = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/reconciler/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AAI,EAAE,EAAE,MAAM,CAAC,CAAC;QAChE,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CACrB,GAAyC,EACzC,UAAqC,EAAE,EACnC,EAAE;IACN,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,QAAQ,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC;IAClG,CAAC;AACL,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,cAAc,GAAG,CAAC,QAA8C,EAAwC,EAAE,CAC5G,QAAQ,CAAC;AAEb;;;;;;;;;GASG;AACH,MAAM,cAAc,GAAG,CAA2B,KAAyB,EAA0B,EAAE,CAAC,KAAK,CAAC;AAE9G,MAAM,QAAQ,GAAG,CAAC,KAAe,EAAE,MAA4B,EAAwC,EAAE,CACrG,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AAE5D,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAgB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AAEpG,OAAO,EACH,QAAQ,EACR,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,QAAQ,EACR,QAAQ,GAOX,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\n\n/** The props of a host element or node, as React passes them through the reconciler. */\ntype Props = Record<string, unknown>;\n\n/** Per-child values a slot hook receives while placing or moving one child. */\ntype PlaceInfo = {\n /** Name of the slot being filled: `children`, or the prop the child was nested under. */\n slot: string;\n /** Position of the child among the slot's children. */\n index: number;\n /** Object of the preceding child in the slot, or null when the child comes first. */\n sibling: GObject.Object | null;\n /** Object adopted for this child by an earlier attach, or null before it has one. */\n adopted: GObject.Object | null;\n /** Props of the child element. */\n props: Props;\n /** Value `initialize` returned for this behavior on the parent. */\n context: unknown;\n};\n\n/** Per-child values a slot hook receives while removing one child. */\ntype DetachInfo = {\n /** Name of the slot the child is leaving. */\n slot: string;\n /** Object the container adopted for this child, or null when it adopted none. */\n adopted: GObject.Object | null;\n /** Props of the child element. */\n props: Props;\n /** Value `initialize` returned for this behavior on the parent. */\n context: unknown;\n};\n\n/**\n * Customizes how one element type places children and applies props. Hooks other than `create` receive the\n * GObject instance; `update`, `flush`, `mount` and `unmount` also take the private per-node context\n * `initialize` built, and `attach`, `reorder` and `detach` read it off their info object. Subtypes inherit a\n * type's behaviors, except for `create`, which is consulted only for the type it is registered on.\n */\ntype ElementBehavior<T extends GObject.Object = GObject.Object> = {\n /** Builds the GObject from its construct props, for types whose constructor does more than set properties. */\n create?: (props: Props) => GObject.Object;\n /** Builds the private per-node context the other hooks receive, once per node. */\n initialize?: (object: T) => unknown;\n /** Places a child, claiming it by returning anything other than `undefined`. */\n attach?: (object: T, child: GObject.Object, info: PlaceInfo) => unknown;\n /** Moves an already-attached child; without it, the whole slot is detached and re-attached in order. */\n reorder?: (object: T, child: GObject.Object, info: PlaceInfo) => unknown;\n /** Removes a child this behavior attached. */\n detach?: (object: T, child: GObject.Object, info: DetachInfo) => void;\n /** Returns the object the container adopts for a child, overriding whatever `attach` returned. */\n resolve?: (object: T, child: GObject.Object) => GObject.Object | null;\n /** Applies changed props and returns the names it consumed, which are then not set as GObject properties. */\n update?: (object: T, prev: Props, next: Props, context: unknown) => Iterable<string> | undefined;\n /** Runs after the commit that touched the node, once every child has been placed. */\n flush?: (object: T, context: unknown) => void;\n /** Runs once the node and its initial children are attached. */\n mount?: (object: T, context: unknown) => void;\n /** Runs when React deletes the node. */\n unmount?: (object: T, context: unknown) => void;\n /** Props to withhold from the constructor, leaving them for a later hook to apply. */\n deferred?: string[];\n};\n\n/** A named export in a module, referenced as plain data (the module is never imported at runtime). */\ntype ModuleExport = {\n /** Specifier the export is imported from. */\n module: string;\n /** Identifier the module exports it under. */\n export: string;\n};\n\n/**\n * How one GLib type is rendered. `component`, `props` and `omittedProps` are inert at runtime; they are\n * read only by codegen.\n */\ntype ElementConfig<T extends GObject.Object = GObject.Object> = {\n /** The element has no GObject of its own; its parent container creates one, as it does for pages. */\n isLazy?: boolean;\n /** Behaviors bound to the type, consulted in registration order and inherited by its subtypes. */\n behaviors?: ElementBehavior<T>[];\n /** Component that wraps the generated element. */\n component?: ModuleExport;\n /** Base props interface the generated props extend. */\n props?: ModuleExport;\n /** GObject properties to leave out of the generated props, such as those a behavior writes from children. */\n omittedProps?: string[];\n};\n\n/**\n * Every registered element config, keyed by GLib type name. Adwaita entries appear once `@gtkx/react/adw`\n * is loaded.\n */\nconst ELEMENTS: Record<string, ElementConfig> = {};\n\nconst deferredProps = (behavior: ElementBehavior): string[] => behavior.deferred ?? [];\n\nconst mergeBehaviors = (base: ElementConfig, added: ElementBehavior[], isPrepended: boolean): ElementBehavior[] => {\n const baseBehaviors = base.behaviors ?? [];\n\n return isPrepended ? [...added, ...baseBehaviors] : [...baseBehaviors, ...added];\n};\n\nconst mergeConfigEntry = (base: ElementConfig, added: ElementConfig<never>, isPrepended = false): ElementConfig => {\n const { behaviors, isLazy, omittedProps, ...rest } = added;\n const entry: ElementConfig = { ...base, ...rest };\n\n if (behaviors !== undefined) {\n entry.behaviors = mergeBehaviors(base, behaviors as ElementBehavior[], isPrepended);\n }\n\n if (omittedProps !== undefined) {\n entry.omittedProps = [...(base.omittedProps ?? []), ...omittedProps];\n }\n\n if (isLazy === true) {\n entry.isLazy = true;\n }\n\n return entry;\n};\n\n/**\n * Merges maps of {@link ElementConfig} keyed by GLib type name into one, concatenating each type's\n * behaviors and omitted props in the order the maps are given (an earlier map's behaviors come first),\n * taking the last component and props seen, and marking a type lazy if any map does. Use it to combine\n * an app's element config with its behaviors.\n */\nconst mergeElementConfigs = (...maps: Record<string, ElementConfig<never>>[]): Record<string, ElementConfig> => {\n const merged: Record<string, ElementConfig> = {};\n\n for (const map of maps) {\n for (const [type, config] of Object.entries(map)) {\n merged[type] = mergeConfigEntry(merged[type] ?? {}, config);\n }\n }\n\n return merged;\n};\n\nconst registerElements = (\n map: Record<string, ElementConfig<never>>,\n options: { isPrepended?: boolean } = {},\n): void => {\n for (const [type, config] of Object.entries(map)) {\n ELEMENTS[type] = mergeConfigEntry(ELEMENTS[type] ?? {}, config, options.isPrepended === true);\n }\n};\n\n/**\n * Identity helper that types the module named by `elements.behaviors` in `gtkx.config.ts`, enabling\n * editor autocompletion and type checking. Key each entry by GLib type name and write each behavior\n * with {@link defineBehavior} so its hooks receive the concrete GObject class.\n */\nconst defineElements = (elements: Record<string, ElementConfig<never>>): Record<string, ElementConfig<never>> =>\n elements;\n\n/**\n * Types one behavior against the GObject class it applies to, so every hook's object parameter is\n * inferred rather than annotated by hand. Pass the class as the type argument.\n *\n * ```ts\n * defineElements({\n * GtkFrame: { behaviors: [defineBehavior<Gtk.Frame>({ attach: (frame, child) => frame.setChild(child) })] },\n * });\n * ```\n */\nconst defineBehavior = <T extends GObject.Object>(hooks: ElementBehavior<T>): ElementBehavior<never> => hooks;\n\nconst forTypes = (types: string[], config: ElementConfig<never>): Record<string, ElementConfig<never>> =>\n Object.fromEntries(types.map((type) => [type, config]));\n\nconst internal = (name: string): ModuleExport => ({ module: \"@gtkx/react/internal\", export: name });\n\nexport {\n ELEMENTS,\n deferredProps,\n mergeElementConfigs,\n registerElements,\n defineElements,\n defineBehavior,\n forTypes,\n internal,\n type Props,\n type PlaceInfo,\n type DetachInfo,\n type ElementBehavior,\n type ModuleExport,\n type ElementConfig,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/reconciler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,CAAC;AAEpG,OAAO,EACH,QAAQ,EACR,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,QAAQ,EACR,QAAQ,GAOX,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\n\n/** The props of a host element or node, as React passes them through the reconciler. */\ntype Props = Record<string, unknown>;\n\n/** Per-child values a slot hook receives while placing or moving one child. */\ntype PlaceInfo = {\n /** Name of the slot being filled: `children`, or the prop the child was nested under. */\n slot: string;\n /** Position of the child among the slot's children. */\n index: number;\n /** Object of the preceding child in the slot, or null when the child comes first. */\n sibling: GObject.Object | null;\n /** Object adopted for this child by an earlier attach, or null before it has one. */\n adopted: GObject.Object | null;\n /** Props of the child element. */\n props: Props;\n /** Value `initialize` returned for this behavior on the parent. */\n context: unknown;\n};\n\n/** Per-child values a slot hook receives while removing one child. */\ntype DetachInfo = {\n /** Name of the slot the child is leaving. */\n slot: string;\n /** Object the container adopted for this child, or null when it adopted none. */\n adopted: GObject.Object | null;\n /** Props of the child element. */\n props: Props;\n /** Value `initialize` returned for this behavior on the parent. */\n context: unknown;\n};\n\n/**\n * Customizes how one element type places children and applies props. Hooks other than `create` receive the\n * GObject instance; `update` and `flush` also take the private per-node context `initialize` built, and\n * `attach`, `reorder` and `detach` read it off their info object. Subtypes inherit a type's behaviors,\n * except for `create`, which is consulted only for the type it is registered on.\n */\ntype ElementBehavior<T extends GObject.Object = GObject.Object> = {\n /** Builds the GObject from its construct props, for types whose constructor does more than set properties. */\n create?: (props: Props) => GObject.Object;\n /** Builds the private per-node context the other hooks receive, once per node. */\n initialize?: (object: T) => unknown;\n /** Places a child, claiming it by returning anything other than `undefined`. */\n attach?: (object: T, child: GObject.Object, info: PlaceInfo) => unknown;\n /** Moves an already-attached child; without it, the whole slot is detached and re-attached in order. */\n reorder?: (object: T, child: GObject.Object, info: PlaceInfo) => unknown;\n /** Removes a child this behavior attached. */\n detach?: (object: T, child: GObject.Object, info: DetachInfo) => void;\n /** Returns the object the container adopts for a child, overriding whatever `attach` returned. */\n resolve?: (object: T, child: GObject.Object) => GObject.Object | null;\n /** Applies changed props and returns the names it consumed, which are then not set as GObject properties. */\n update?: (object: T, prev: Props, next: Props, context: unknown) => Iterable<string> | undefined;\n /** Runs after the commit that touched the node, once every child has been placed. */\n flush?: (object: T, context: unknown) => void;\n /** Props to withhold from the constructor, leaving them for a later hook to apply. */\n deferred?: string[];\n /**\n * Props the behavior can only apply while the element is being built, because the library exposes no\n * counterpart to whatever applied them. Changing one after it has been applied throws instead of\n * silently applying the new value on top of the old.\n */\n constructOnly?: string[];\n};\n\n/** A named export in a module, referenced as plain data (the module is never imported at runtime). */\ntype ModuleExport = {\n /** Specifier the export is imported from. */\n module: string;\n /** Identifier the module exports it under. */\n export: string;\n};\n\n/**\n * How one GLib type is rendered. `component`, `props` and `omittedProps` are inert at runtime; they are\n * read only by codegen.\n */\ntype ElementConfig<T extends GObject.Object = GObject.Object> = {\n /** The element has no GObject of its own; its parent container creates one, as it does for pages. */\n isLazy?: boolean;\n /** Behaviors bound to the type, consulted in registration order and inherited by its subtypes. */\n behaviors?: ElementBehavior<T>[];\n /** Component that wraps the generated element. */\n component?: ModuleExport;\n /** Base props interface the generated props extend. */\n props?: ModuleExport;\n /** GObject properties to leave out of the generated props, such as those a behavior writes from children. */\n omittedProps?: string[];\n};\n\n/**\n * Every registered element config, keyed by GLib type name. Adwaita entries appear once `@gtkx/react/adw`\n * is loaded.\n */\nconst ELEMENTS: Record<string, ElementConfig> = {};\n\nconst deferredProps = (behavior: ElementBehavior): string[] => behavior.deferred ?? [];\n\nconst mergeBehaviors = (base: ElementConfig, added: ElementBehavior[], isPrepended: boolean): ElementBehavior[] => {\n const baseBehaviors = base.behaviors ?? [];\n\n return isPrepended ? [...added, ...baseBehaviors] : [...baseBehaviors, ...added];\n};\n\nconst mergeConfigEntry = (base: ElementConfig, added: ElementConfig<never>, isPrepended = false): ElementConfig => {\n const { behaviors, isLazy, omittedProps, ...rest } = added;\n const entry: ElementConfig = { ...base, ...rest };\n\n if (behaviors !== undefined) {\n entry.behaviors = mergeBehaviors(base, behaviors as ElementBehavior[], isPrepended);\n }\n\n if (omittedProps !== undefined) {\n entry.omittedProps = [...(base.omittedProps ?? []), ...omittedProps];\n }\n\n if (isLazy === true) {\n entry.isLazy = true;\n }\n\n return entry;\n};\n\n/**\n * Merges maps of {@link ElementConfig} keyed by GLib type name into one, concatenating each type's\n * behaviors and omitted props in the order the maps are given (an earlier map's behaviors come first),\n * taking the last component and props seen, and marking a type lazy if any map does. Use it to combine\n * an app's element config with its behaviors.\n */\nconst mergeElementConfigs = (...maps: Record<string, ElementConfig<never>>[]): Record<string, ElementConfig> => {\n const merged: Record<string, ElementConfig> = {};\n\n for (const map of maps) {\n for (const [type, config] of Object.entries(map)) {\n merged[type] = mergeConfigEntry(merged[type] ?? {}, config);\n }\n }\n\n return merged;\n};\n\nconst registerElements = (\n map: Record<string, ElementConfig<never>>,\n options: { isPrepended?: boolean } = {},\n): void => {\n for (const [type, config] of Object.entries(map)) {\n ELEMENTS[type] = mergeConfigEntry(ELEMENTS[type] ?? {}, config, options.isPrepended === true);\n }\n};\n\n/**\n * Identity helper that types the module named by `elements.behaviors` in `gtkx.config.ts`, enabling\n * editor autocompletion and type checking. Key each entry by GLib type name and write each behavior\n * with {@link defineBehavior} so its hooks receive the concrete GObject class.\n */\nconst defineElements = (elements: Record<string, ElementConfig<never>>): Record<string, ElementConfig<never>> =>\n elements;\n\n/**\n * Types one behavior against the GObject class it applies to, so every hook's object parameter is\n * inferred rather than annotated by hand. Pass the class as the type argument.\n *\n * ```ts\n * defineElements({\n * GtkFrame: { behaviors: [defineBehavior<Gtk.Frame>({ attach: (frame, child) => frame.setChild(child) })] },\n * });\n * ```\n */\nconst defineBehavior = <T extends GObject.Object>(hooks: ElementBehavior<T>): ElementBehavior<never> => hooks;\n\nconst forTypes = (types: string[], config: ElementConfig<never>): Record<string, ElementConfig<never>> =>\n Object.fromEntries(types.map((type) => [type, config]));\n\nconst internal = (name: string): ModuleExport => ({ module: \"@gtkx/react/internal\", export: name });\n\nexport {\n ELEMENTS,\n deferredProps,\n mergeElementConfigs,\n registerElements,\n defineElements,\n defineBehavior,\n forTypes,\n internal,\n type Props,\n type PlaceInfo,\n type DetachInfo,\n type ElementBehavior,\n type ModuleExport,\n type ElementConfig,\n};\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** The type of the shared {@link rootElement} marker used as a default top-level container. */
|
|
2
2
|
type RootElement = {
|
|
3
|
+
/** Marks a container as the top level rather than a GObject; `isRootElement` tests for it. */
|
|
3
4
|
[ROOT_ELEMENT_BRAND]: true;
|
|
4
5
|
};
|
|
5
6
|
declare const ROOT_ELEMENT_BRAND: unique symbol;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root-element.d.ts","sourceRoot":"","sources":["../../src/reconciler/root-element.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,KAAK,WAAW,GAAG;
|
|
1
|
+
{"version":3,"file":"root-element.d.ts","sourceRoot":"","sources":["../../src/reconciler/root-element.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,KAAK,WAAW,GAAG;IACf,8FAA8F;IAC9F,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAC;CAC9B,CAAC;AAEF,QAAA,MAAM,kBAAkB,EAAE,OAAO,MAAwC,CAAC;AAC1E,+FAA+F;AAC/F,QAAA,MAAM,WAAW,EAAE,WAA4C,CAAC;AAEhE,QAAA,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,WAC0C,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root-element.js","sourceRoot":"","sources":["../../src/reconciler/root-element.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"root-element.js","sourceRoot":"","sources":["../../src/reconciler/root-element.ts"],"names":[],"mappings":"AAMA,MAAM,kBAAkB,GAAkB,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAC1E,+FAA+F;AAC/F,MAAM,WAAW,GAAgB,EAAE,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,CAAC;AAEhE,MAAM,aAAa,GAAG,CAAC,KAAc,EAAwB,EAAE,CAC3D,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAE,aAAa,EAAoB,CAAC","sourcesContent":["/** The type of the shared {@link rootElement} marker used as a default top-level container. */\ntype RootElement = {\n /** Marks a container as the top level rather than a GObject; `isRootElement` tests for it. */\n [ROOT_ELEMENT_BRAND]: true;\n};\n\nconst ROOT_ELEMENT_BRAND: unique symbol = Symbol.for(\"gtkx:root-element\");\n/** A shared marker value used as the default top-level container for rendering and portals. */\nconst rootElement: RootElement = { [ROOT_ELEMENT_BRAND]: true };\n\nconst isRootElement = (value: unknown): value is RootElement =>\n typeof value === \"object\" && value !== null && Object.hasOwn(value, ROOT_ELEMENT_BRAND);\n\nexport { rootElement, isRootElement, type RootElement };\n"]}
|
|
@@ -9,13 +9,22 @@ type RootErrorCallbacks = {
|
|
|
9
9
|
type ReconcilerRootOptions = RootErrorCallbacks & {
|
|
10
10
|
containerInfo: Container;
|
|
11
11
|
};
|
|
12
|
+
/** A render root whose updates and teardown the caller drives, with error handling left to it. */
|
|
12
13
|
type ReconcilerRoot = {
|
|
14
|
+
/**
|
|
15
|
+
* Mounts an element tree into the container, or updates the tree already mounted there. Passing `null` unmounts
|
|
16
|
+
* the container instead.
|
|
17
|
+
*/
|
|
13
18
|
update: (element: ReactNode) => void;
|
|
19
|
+
/** Hands the root to `teardown`, then stops {@link quit} from unmounting the container. */
|
|
14
20
|
unmount: (teardown: (root: ReconcilerRoot) => Promise<void>) => Promise<void>;
|
|
15
21
|
};
|
|
16
22
|
/** The object {@link createRoot} returns: it renders an element tree into a container and can tear it down. */
|
|
17
23
|
type Root = {
|
|
18
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Mounts an element tree into the container, or updates the tree already mounted there. Rendering `null` unmounts
|
|
26
|
+
* the container instead.
|
|
27
|
+
*/
|
|
19
28
|
render: (element: ReactNode) => void;
|
|
20
29
|
/** Unmounts the rendered tree and runs its effect cleanups. */
|
|
21
30
|
unmount: () => void;
|
|
@@ -30,8 +39,13 @@ declare const createReconcilerRoot: (options: ReconcilerRootOptions) => Reconcil
|
|
|
30
39
|
* @param container The GObject to render into; defaults to the shared {@link rootElement}, which holds no object.
|
|
31
40
|
*/
|
|
32
41
|
declare const createRoot: (container?: Container) => Root;
|
|
33
|
-
/**
|
|
34
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Unmounts every render root that currently holds a mounted tree.
|
|
44
|
+
*
|
|
45
|
+
* @returns `Gdk.EVENT_STOP` when at least one root came down, so a close-request handler keeps GTK4 from closing the
|
|
46
|
+
* window itself, and `Gdk.EVENT_PROPAGATE` when there was nothing to unmount, so the default handler still runs.
|
|
47
|
+
*/
|
|
48
|
+
declare const quit: () => typeof Gdk.EVENT_PROPAGATE | typeof Gdk.EVENT_STOP;
|
|
35
49
|
/**
|
|
36
50
|
* Renders children into a container other than the surrounding tree.
|
|
37
51
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/reconciler/root.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/reconciler/root.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,WA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AW,SAAuB,KAAG,IAcxD,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,IAAI,QAAO,OAAO,GAAG,CAAC,eAAe,GAAG,OAAO,GAAG,CAAC,UAQxD,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,YAAY,GAAI,UAAU,SAAS,EAAE,WAAW,SAAS,EAAE,MAAM,MAAM,KAAG,WACa,CAAC;AAE9F,OAAO,EACH,yBAAyB,EACzB,oBAAoB,EACpB,UAAU,EACV,IAAI,EACJ,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,IAAI,GACZ,CAAC"}
|
package/dist/reconciler/root.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Gdk from "@gtkx/gi/gdk";
|
|
2
2
|
import { createLogger } from "@gtkx/utils";
|
|
3
3
|
import { ConcurrentRoot } from "react-reconciler/constants.js";
|
|
4
|
+
import { injectIntoDevTools } from "./devtools.js";
|
|
4
5
|
import { reconciler } from "./host-config.js";
|
|
5
6
|
import { rootElement } from "./root-element.js";
|
|
6
7
|
const log = createLogger("react");
|
|
@@ -25,7 +26,8 @@ const logCaughtRenderError = (error) => {
|
|
|
25
26
|
log.error("caught render error", error);
|
|
26
27
|
};
|
|
27
28
|
const openContainer = (containerInfo, callbacks) => {
|
|
28
|
-
|
|
29
|
+
injectIntoDevTools(reconciler);
|
|
30
|
+
return reconciler.createContainer(containerInfo, ConcurrentRoot, null, false, null, "", (error, info) => {
|
|
29
31
|
errorHandlerSlot.get()?.(error);
|
|
30
32
|
callbacks.onUncaughtError?.(error, info);
|
|
31
33
|
}, (error, info) => {
|
|
@@ -34,18 +36,24 @@ const openContainer = (containerInfo, callbacks) => {
|
|
|
34
36
|
}, (error, info) => {
|
|
35
37
|
callbacks.onRecoverableError?.(error, info);
|
|
36
38
|
}, () => undefined);
|
|
37
|
-
activeRoots.add(container);
|
|
38
|
-
return container;
|
|
39
39
|
};
|
|
40
40
|
const unmountContainer = (container) => {
|
|
41
41
|
reconciler.updateContainer(null, container, null, null);
|
|
42
42
|
activeRoots.delete(container);
|
|
43
43
|
};
|
|
44
|
+
const mountContainer = (container, element) => {
|
|
45
|
+
if (element === null) {
|
|
46
|
+
unmountContainer(container);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
activeRoots.add(container);
|
|
50
|
+
reconciler.updateContainer(element, container, null, null);
|
|
51
|
+
};
|
|
44
52
|
const createReconcilerRoot = (options) => {
|
|
45
53
|
const container = openContainer(options.containerInfo, options);
|
|
46
54
|
const root = {
|
|
47
55
|
update: (element) => {
|
|
48
|
-
|
|
56
|
+
mountContainer(container, element);
|
|
49
57
|
},
|
|
50
58
|
unmount: async (teardown) => {
|
|
51
59
|
await teardown(root);
|
|
@@ -67,19 +75,25 @@ const createRoot = (container = rootElement) => {
|
|
|
67
75
|
});
|
|
68
76
|
return {
|
|
69
77
|
render: (element) => {
|
|
70
|
-
|
|
78
|
+
mountContainer(opaque, element);
|
|
71
79
|
},
|
|
72
80
|
unmount: () => {
|
|
73
81
|
unmountContainer(opaque);
|
|
74
82
|
},
|
|
75
83
|
};
|
|
76
84
|
};
|
|
77
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Unmounts every render root that currently holds a mounted tree.
|
|
87
|
+
*
|
|
88
|
+
* @returns `Gdk.EVENT_STOP` when at least one root came down, so a close-request handler keeps GTK4 from closing the
|
|
89
|
+
* window itself, and `Gdk.EVENT_PROPAGATE` when there was nothing to unmount, so the default handler still runs.
|
|
90
|
+
*/
|
|
78
91
|
const quit = () => {
|
|
79
|
-
|
|
92
|
+
const containers = [...activeRoots];
|
|
93
|
+
for (const container of containers) {
|
|
80
94
|
unmountContainer(container);
|
|
81
95
|
}
|
|
82
|
-
return Gdk.EVENT_STOP;
|
|
96
|
+
return containers.length > 0 ? Gdk.EVENT_STOP : Gdk.EVENT_PROPAGATE;
|
|
83
97
|
};
|
|
84
98
|
/**
|
|
85
99
|
* Renders children into a container other than the surrounding tree.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.js","sourceRoot":"","sources":["../../src/reconciler/root.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,YAAY,EAAe,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAkB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"root.js","sourceRoot":"","sources":["../../src/reconciler/root.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,YAAY,EAAe,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAkB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAsChD,MAAM,GAAG,GAAW,YAAY,CAAC,OAAO,CAAC,CAAC;AAC1C,MAAM,WAAW,GAAoB,IAAI,GAAG,EAAE,CAAC;AAC/C,MAAM,gBAAgB,GAAG,sBAAsB,EAAE,CAAC;AAElD,SAAS,sBAAsB;IAC3B,IAAI,OAAO,GAAwB,IAAI,CAAC;IAExC,OAAO;QACH,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO;QAClB,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE;YACb,MAAM,QAAQ,GAAG,OAAO,CAAC;YACzB,OAAO,GAAG,OAAO,CAAC;YAElB,OAAO,QAAQ,CAAC;QACpB,CAAC;KACJ,CAAC;AACN,CAAC;AAED,MAAM,yBAAyB,GAAG,CAAC,OAAqB,EAAuB,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CA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AC,GAAG,WAAW,CAAC,CAAC;IAEpC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACjC,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC;AACxE,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,YAAY,GAAG,CAAC,QAAmB,EAAE,SAAoB,EAAE,GAAY,EAAe,EAAE,CAC1F,UAAU,CAAC,YAAY,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,IAAI,IAAI,CAA2B,CAAC;AAE9F,OAAO,EACH,yBAAyB,EACzB,oBAAoB,EACpB,UAAU,EACV,IAAI,EACJ,YAAY,GAGf,CAAC","sourcesContent":["import type { ErrorInfo, ReactNode, ReactPortal } from \"react\";\nimport * as Gdk from \"@gtkx/gi/gdk\";\nimport { createLogger, type Logger } from \"@gtkx/utils\";\nimport { ConcurrentRoot } from \"react-reconciler/constants.js\";\nimport { injectIntoDevTools } from \"./devtools.js\";\nimport { type Container, reconciler } from \"./host-config.js\";\nimport { rootElement } from \"./root-element.js\";\n\ntype OpaqueRoot = { [opaqueRoot]: true };\n\ntype RootErrorCallbacks = {\n onUncaughtError?: (error: unknown, info: ErrorInfo) => void;\n onCaughtError?: (error: unknown, info: ErrorInfo) => void;\n onRecoverableError?: (error: unknown, info: ErrorInfo) => void;\n};\n\ntype ReconcilerRootOptions = RootErrorCallbacks & { containerInfo: Container };\n\n/** A render root whose updates and teardown the caller drives, with error handling left to it. */\ntype ReconcilerRoot = {\n /**\n * Mounts an element tree into the container, or updates the tree already mounted there. Passing `null` unmounts\n * the container instead.\n */\n update: (element: ReactNode) => void;\n /** Hands the root to `teardown`, then stops {@link quit} from unmounting the container. */\n unmount: (teardown: (root: ReconcilerRoot) => Promise<void>) => Promise<void>;\n};\n\n/** The object {@link createRoot} returns: it renders an element tree into a container and can tear it down. */\ntype Root = {\n /**\n * Mounts an element tree into the container, or updates the tree already mounted there. Rendering `null` unmounts\n * the container instead.\n */\n render: (element: ReactNode) => void;\n /** Unmounts the rendered tree and runs its effect cleanups. */\n unmount: () => void;\n};\n\ntype ErrorHandler = (error: unknown) => void;\ntype ErrorHandlerSlot = { get: () => ErrorHandler | null; set: (handler: ErrorHandler) => ErrorHandler | null };\n\ndeclare const opaqueRoot: unique symbol;\nconst log: Logger = createLogger(\"react\");\nconst activeRoots: Set<OpaqueRoot> = new Set();\nconst errorHandlerSlot = createErrorHandlerSlot();\n\nfunction createErrorHandlerSlot(): ErrorHandlerSlot {\n let current: ErrorHandler | null = null;\n\n return {\n get: () => current,\n set: (handler) => {\n const previous = current;\n current = handler;\n\n return previous;\n },\n };\n}\n\nconst setReconcilerErrorHandler = (handler: ErrorHandler): ErrorHandler | null => errorHandlerSlot.set(handler);\n\nconst rethrowUncaughtRenderError = (error: unknown): never => {\n throw error;\n};\n\nconst logCaughtRenderError = (error: unknown): void => {\n log.error(\"caught render error\", error);\n};\n\nconst openContainer = (containerInfo: Container, callbacks: RootErrorCallbacks): OpaqueRoot => {\n injectIntoDevTools(reconciler);\n\n return reconciler.createContainer(\n containerInfo,\n ConcurrentRoot,\n null,\n false,\n null,\n \"\",\n (error, info) => {\n errorHandlerSlot.get()?.(error);\n callbacks.onUncaughtError?.(error, info);\n },\n (error, info) => {\n errorHandlerSlot.get()?.(error);\n callbacks.onCaughtError?.(error, info);\n },\n (error, info) => {\n callbacks.onRecoverableError?.(error, info);\n },\n (): void => undefined,\n ) as OpaqueRoot;\n};\n\nconst unmountContainer = (container: OpaqueRoot): void => {\n reconciler.updateContainer(null, container, null, null);\n activeRoots.delete(container);\n};\n\nconst mountContainer = (container: OpaqueRoot, element: ReactNode): void => {\n if (element === null) {\n unmountContainer(container);\n\n return;\n }\n\n activeRoots.add(container);\n reconciler.updateContainer(element, container, null, null);\n};\n\nconst createReconcilerRoot = (options: ReconcilerRootOptions): ReconcilerRoot => {\n const container = openContainer(options.containerInfo, options);\n\n const root: ReconcilerRoot = {\n update: (element) => {\n mountContainer(container, element);\n },\n unmount: async (teardown) => {\n await teardown(root);\n activeRoots.delete(container);\n },\n };\n\n return root;\n};\n\n/**\n * Creates a render root for a GTKX application. Uncaught render errors are rethrown and errors caught by an\n * error boundary are logged.\n *\n * @param container The GObject to render into; defaults to the shared {@link rootElement}, which holds no object.\n */\nconst createRoot = (container: Container = rootElement): Root => {\n const opaque = openContainer(container, {\n onUncaughtError: rethrowUncaughtRenderError,\n onCaughtError: logCaughtRenderError,\n });\n\n return {\n render: (element) => {\n mountContainer(opaque, element);\n },\n unmount: () => {\n unmountContainer(opaque);\n },\n };\n};\n\n/**\n * Unmounts every render root that currently holds a mounted tree.\n *\n * @returns `Gdk.EVENT_STOP` when at least one root came down, so a close-request handler keeps GTK4 from closing the\n * window itself, and `Gdk.EVENT_PROPAGATE` when there was nothing to unmount, so the default handler still runs.\n */\nconst quit = (): typeof Gdk.EVENT_PROPAGATE | typeof Gdk.EVENT_STOP => {\n const containers = [...activeRoots];\n\n for (const container of containers) {\n unmountContainer(container);\n }\n\n return containers.length > 0 ? Gdk.EVENT_STOP : Gdk.EVENT_PROPAGATE;\n};\n\n/**\n * Renders children into a container other than the surrounding tree.\n *\n * @param container The GObject to render into, or {@link rootElement} to render at the top level.\n */\nconst createPortal = (children: ReactNode, container: Container, key?: string): ReactPortal =>\n reconciler.createPortal(children, container, null, key ?? null) as unknown as ReactPortal;\n\nexport {\n setReconcilerErrorHandler,\n createReconcilerRoot,\n createRoot,\n quit,\n createPortal,\n type ReconcilerRoot,\n type Root,\n};\n"]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { type SignalHandler } from "@gtkx/runtime";
|
|
2
2
|
import type { SignalTarget } from "./node.js";
|
|
3
|
-
declare const isApplyingWrite: () => boolean;
|
|
4
3
|
declare const applyWrite: <T>(write: () => T) => T;
|
|
5
4
|
declare const connectHandler: (target: SignalTarget, prop: string, signal: string, handler: SignalHandler) => void;
|
|
6
5
|
declare const disconnectHandler: (target: SignalTarget, prop: string) => void;
|
|
7
6
|
declare const disconnectAllHandlers: (target: SignalTarget) => void;
|
|
8
|
-
export { applyWrite,
|
|
7
|
+
export { applyWrite, connectHandler, disconnectHandler, disconnectAllHandlers, };
|
|
9
8
|
//# sourceMappingURL=signals.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../src/reconciler/signals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../src/reconciler/signals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,WAAW,CAAC;AAQ7D,QAAA,MAAM,UAAU,GAAI,CAAC,EAAE,OAAO,MAAM,CAAC,KAAG,CAQvC,CAAC;AA2BF,QAAA,MAAM,cAAc,GAAI,QAAQ,YAAY,EAAE,MAAM,MAAM,EAAE,QAAQ,MAAM,EAAE,SAAS,aAAa,KAAG,IAmBpG,CAAC;AAEF,QAAA,MAAM,iBAAiB,GAAI,QAAQ,YAAY,EAAE,MAAM,MAAM,KAAG,IAS/D,CAAC;AAEF,QAAA,MAAM,qBAAqB,GAAI,QAAQ,YAAY,KAAG,IAMrD,CAAC;AAEF,OAAO,EACH,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,qBAAqB,GACxB,CAAC"}
|
|
@@ -54,5 +54,5 @@ const disconnectAllHandlers = (target) => {
|
|
|
54
54
|
}
|
|
55
55
|
target.handlers.clear();
|
|
56
56
|
};
|
|
57
|
-
export { applyWrite,
|
|
57
|
+
export { applyWrite, connectHandler, disconnectHandler, disconnectAllHandlers, };
|
|
58
58
|
//# sourceMappingURL=signals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signals.js","sourceRoot":"","sources":["../../src/reconciler/signals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAsB,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAiB,WAAW,EAAE,MAAM,eAAe,CAAC;AAE3D,MAAM,oBAAoB,GAAG,UAAU,CAAC;AACxC,MAAM,UAAU,GAAsB,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAEnD,MAAM,eAAe,GAAG,GAAY,EAAE,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC;AAE5D,MAAM,UAAU,GAAG,CAAI,KAAc,EAAK,EAAE;IACxC,UAAU,CAAC,KAAK,IAAI,CAAC,CAAC;IAEtB,IAAI,CAAC;QACD,OAAO,KAAK,EAAE,CAAC;IACnB,CAAC;YAAS,CAAC;QACP,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IACzD,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAiB,EAAE,CACxD,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAE1G,MAAM,iBAAiB,GAAG,CAAC,IAAc,EAAE,MAAc,EAAW,EAAE,CAClE,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;AAEzD,MAAM,aAAa,GAAG,CAClB,MAAoB,EACpB,MAAqB,EACrB,c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C,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,MAAoB,EAAE,IAAY,EAAQ,EAAE;IACnE,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEzC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO;IACX,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACjD,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,MAAoB,EAAQ,EAAE;IACzD,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;QAC5C,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC5B,CAAC,CAAC;AAEF,OAAO,EACH,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,qBAAqB,GACxB,CAAC","sourcesContent":["import { getSignalBaseName, type SignalHandler } from \"@gtkx/runtime\";\nimport { camelCase } from \"@gtkx/utils\";\nimport type { HandlerRecord, SignalTarget } from \"./node.js\";\nimport { type TypeInfo, typeInfoFor } from \"./metadata.js\";\n\nconst NOTIFY_DETAIL_PREFIX = \"notify::\";\nconst writeState: { depth: number } = { depth: 0 };\n\nconst isApplyingWrite = (): boolean => writeState.depth > 0;\n\nconst applyWrite = <T>(write: () => T): T => {\n writeState.depth += 1;\n\n try {\n return write();\n } finally {\n writeState.depth = Math.max(0, writeState.depth - 1);\n }\n};\n\nconst getNotifyProperty = (signal: string): string | null =>\n signal.startsWith(NOTIFY_DETAIL_PREFIX) ? camelCase(signal.slice(NOTIFY_DETAIL_PREFIX.length)) : null;\n\nconst isBlockableSignal = (info: TypeInfo, signal: string): boolean =>\n info.userEventSignals.has(getSignalBaseName(signal));\n\nconst invokeHandler = (\n target: SignalTarget,\n record: HandlerRecord,\n notifyProperty: string | null,\n args: unknown[],\n): unknown =>\n notifyProperty === null\n ? record.handler(...args, target.object)\n : record.handler(Reflect.get(target.object, notifyProperty), target.object);\n\nconst wrapHandler = (target: SignalTarget, record: HandlerRecord, notifyProperty: string | null): SignalHandler =>\n (...args: unknown[]): unknown => {\n if (record.isBlockable && isApplyingWrite()) {\n return undefined;\n }\n\n return target.dispatch(() => invokeHandler(target, record, notifyProperty, args));\n };\n\nconst connectHandler = (target: SignalTarget, prop: string, signal: string, handler: SignalHandler): void => {\n const existing = target.handlers.get(prop);\n\n if (existing?.signal === signal) {\n existing.handler = handler;\n\n return;\n }\n\n if (existing !== undefined) {\n target.object.off(existing.signal, existing.wrapped);\n }\n\n const isBlockable = isBlockableSignal(typeInfoFor(target.typeName), signal);\n const notifyProperty = getNotifyProperty(signal);\n const record: HandlerRecord = { signal, handler, wrapped: (): undefined => undefined, isBlockable };\n record.wrapped = wrapHandler(target, record, notifyProperty);\n target.object.on(signal, record.wrapped);\n target.handlers.set(prop, record);\n};\n\nconst disconnectHandler = (target: SignalTarget, prop: string): void => {\n const record = target.handlers.get(prop);\n\n if (record === undefined) {\n return;\n }\n\n target.object.off(record.signal, record.wrapped);\n target.handlers.delete(prop);\n};\n\nconst disconnectAllHandlers = (target: SignalTarget): void => {\n for (const record of target.handlers.values()) {\n target.object.off(record.signal, record.wrapped);\n }\n\n target.handlers.clear();\n};\n\nexport {\n applyWrite,\n connectHandler,\n disconnectHandler,\n disconnectAllHandlers,\n};\n"]}
|
|
@@ -66,7 +66,7 @@ type AccessibleProps = {
|
|
|
66
66
|
/** Whether the link has already been followed. */
|
|
67
67
|
accessibleVisited?: boolean | null | undefined;
|
|
68
68
|
/** Descendant that holds the focus while the widget itself keeps it. */
|
|
69
|
-
accessibleActiveDescendant?: Gtk.
|
|
69
|
+
accessibleActiveDescendant?: Gtk.Accessible | null | undefined;
|
|
70
70
|
/** Total number of columns in the table, including any that are not rendered. */
|
|
71
71
|
accessibleColCount?: number | null | undefined;
|
|
72
72
|
/** One-based column position of the cell within its table. */
|
|
@@ -76,19 +76,19 @@ type AccessibleProps = {
|
|
|
76
76
|
/** Number of columns the cell spans. */
|
|
77
77
|
accessibleColSpan?: number | null | undefined;
|
|
78
78
|
/** Widgets whose content or presence this widget controls. */
|
|
79
|
-
accessibleControls?: Gtk.
|
|
79
|
+
accessibleControls?: Gtk.Accessible[] | null | undefined;
|
|
80
80
|
/** Widgets that describe this one. */
|
|
81
|
-
accessibleDescribedBy?: Gtk.
|
|
81
|
+
accessibleDescribedBy?: Gtk.Accessible[] | null | undefined;
|
|
82
82
|
/** Widgets holding extended detail about this one. */
|
|
83
|
-
accessibleDetails?: Gtk.
|
|
83
|
+
accessibleDetails?: Gtk.Accessible[] | null | undefined;
|
|
84
84
|
/** Widgets holding the message that explains why the value is invalid. */
|
|
85
|
-
accessibleErrorMessage?: Gtk.
|
|
85
|
+
accessibleErrorMessage?: Gtk.Accessible[] | null | undefined;
|
|
86
86
|
/** Widgets to read next, overriding the default reading order. */
|
|
87
|
-
accessibleFlowTo?: Gtk.
|
|
87
|
+
accessibleFlowTo?: Gtk.Accessible[] | null | undefined;
|
|
88
88
|
/** Widgets that label this one. */
|
|
89
|
-
accessibleLabelledBy?: Gtk.
|
|
89
|
+
accessibleLabelledBy?: Gtk.Accessible[] | null | undefined;
|
|
90
90
|
/** Widgets this one owns that the widget hierarchy does not already imply. */
|
|
91
|
-
accessibleOwns?: Gtk.
|
|
91
|
+
accessibleOwns?: Gtk.Accessible[] | null | undefined;
|
|
92
92
|
/** One-based position of the widget within its set. */
|
|
93
93
|
accessiblePosInSet?: number | null | undefined;
|
|
94
94
|
/** Total number of rows in the table, including any that are not rendered. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessible-props.d.ts","sourceRoot":"","sources":["../../src/utils/accessible-props.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"accessible-props.d.ts","sourceRoot":"","sources":["../../src/utils/accessible-props.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEvD;;;;;GAKG;AACH,KAAK,eAAe,GAAG;IACnB,6DAA6D;IAC7D,sBAAsB,CAAC,EAAE,GAAG,CAAC,sBAAsB,GAAG,IAAI,GAAG,SAAS,CAAC;IACvE,oDAAoD;IACpD,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClD,mDAAmD;IACnD,kBAAkB,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IAChD,mDAAmD;IACnD,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,2CAA2C;IAC3C,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C,oFAAoF;IACpF,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C,uEAAuE;IACvE,eAAe,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IAC7C,yDAAyD;IACzD,mBAAmB,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IACjD,6EAA6E;IAC7E,yBAAyB,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IAC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,UAAU,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IACvD,mCAAmC;IACnC,oBAAoB,CAAC,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3D,8EAA8E;IAC9E,cAAc,CAAC,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IACrD,uDAAuD;IACvD,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/C,8EAA8E;IAC9E,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/C,2DAA2D;IAC3D,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/C,8DAA8D;IAC9D,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,qCAAqC;IACrC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C,8DAA8D;IAC9D,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACjD,CAAC;AA4IF,QAAA,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,IAAI,IAAI,MAAM,eACX,CAAC;AAqE7C,QAAA,MAAM,oBAAoB,GAAI,QAAQ,GAAG,CAAC,UAAU,EAAE,UAAU,KAAK,GAAG,IAAI,EAAE,UAAU,KAAK,KAAG,IAM/F,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,KAAK,eAAe,EAAE,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as GObject from "@gtkx/gi/gobject";
|
|
2
2
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
3
|
-
import { deleteAccessibleMetadata, setAccessibleMetadata } from "./accessible-metadata.js";
|
|
4
3
|
const ACCESSIBLE_PROP_MAP = {
|
|
5
4
|
accessibleAutocomplete: buildProperty(Gtk.AccessibleProperty.AUTOCOMPLETE, "int"),
|
|
6
5
|
accessibleDescription: buildProperty(Gtk.AccessibleProperty.DESCRIPTION, "string"),
|
|
@@ -25,12 +24,12 @@ const ACCESSIBLE_PROP_MAP = {
|
|
|
25
24
|
accessibleBusy: buildState(Gtk.AccessibleState.BUSY, "boolean"),
|
|
26
25
|
accessibleChecked: buildState(Gtk.AccessibleState.CHECKED, "int"),
|
|
27
26
|
accessibleDisabled: buildState(Gtk.AccessibleState.DISABLED, "boolean"),
|
|
28
|
-
accessibleExpanded: buildState(Gtk.AccessibleState.EXPANDED, "
|
|
27
|
+
accessibleExpanded: buildState(Gtk.AccessibleState.EXPANDED, "optionalBoolean"),
|
|
29
28
|
accessibleHidden: buildState(Gtk.AccessibleState.HIDDEN, "boolean"),
|
|
30
29
|
accessibleInvalid: buildState(Gtk.AccessibleState.INVALID, "int"),
|
|
31
30
|
accessiblePressed: buildState(Gtk.AccessibleState.PRESSED, "int"),
|
|
32
|
-
accessibleSelected: buildState(Gtk.AccessibleState.SELECTED, "
|
|
33
|
-
accessibleVisited: buildState(Gtk.AccessibleState.VISITED, "
|
|
31
|
+
accessibleSelected: buildState(Gtk.AccessibleState.SELECTED, "optionalBoolean"),
|
|
32
|
+
accessibleVisited: buildState(Gtk.AccessibleState.VISITED, "optionalBoolean"),
|
|
34
33
|
accessibleActiveDescendant: buildRelation(Gtk.AccessibleRelation.ACTIVE_DESCENDANT, "object"),
|
|
35
34
|
accessibleColCount: buildRelation(Gtk.AccessibleRelation.COL_COUNT, "int"),
|
|
36
35
|
accessibleColIndex: buildRelation(Gtk.AccessibleRelation.COL_INDEX, "int"),
|
|
@@ -83,6 +82,11 @@ const buildValue = (descriptor, jsValue) => {
|
|
|
83
82
|
v.setBoolean(jsValue);
|
|
84
83
|
});
|
|
85
84
|
}
|
|
85
|
+
case "optionalBoolean": {
|
|
86
|
+
return GObject.buildValue(GObject.TYPE_INT, (v) => {
|
|
87
|
+
v.setInt(jsValue === true ? 1 : 0);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
86
90
|
case "int": {
|
|
87
91
|
return GObject.buildValue(GObject.TYPE_INT, (v) => {
|
|
88
92
|
v.setInt(jsValue);
|
|
@@ -143,22 +147,17 @@ function resetDescriptor(widget, descriptor) {
|
|
|
143
147
|
const applyChangedProp = (widget, name, newValue) => {
|
|
144
148
|
if (newValue == null) {
|
|
145
149
|
resetDescriptor(widget, ACCESSIBLE_PROP_MAP[name]);
|
|
146
|
-
deleteAccessibleMetadata(widget, name);
|
|
147
150
|
}
|
|
148
151
|
else {
|
|
149
152
|
applyDescriptor(widget, ACCESSIBLE_PROP_MAP[name], newValue);
|
|
150
|
-
setAccessibleMetadata(widget, name, newValue);
|
|
151
153
|
}
|
|
152
154
|
};
|
|
153
|
-
const applyChangedProps = (widget,
|
|
155
|
+
const applyChangedProps = (widget, newProps) => {
|
|
154
156
|
for (const name in newProps) {
|
|
155
157
|
if (!isAccessibleProp(name)) {
|
|
156
158
|
continue;
|
|
157
159
|
}
|
|
158
|
-
|
|
159
|
-
if (oldProps?.[name] !== newValue) {
|
|
160
|
-
applyChangedProp(widget, name, newValue);
|
|
161
|
-
}
|
|
160
|
+
applyChangedProp(widget, name, newProps[name]);
|
|
162
161
|
}
|
|
163
162
|
};
|
|
164
163
|
const isRemovedAccessibleProp = (name, oldProps, newProps) => !Object.hasOwn(newProps, name) && isAccessibleProp(name) && oldProps[name] !== undefined;
|
|
@@ -168,11 +167,10 @@ const resetRemovedProps = (widget, oldProps, newProps) => {
|
|
|
168
167
|
continue;
|
|
169
168
|
}
|
|
170
169
|
resetDescriptor(widget, ACCESSIBLE_PROP_MAP[name]);
|
|
171
|
-
deleteAccessibleMetadata(widget, name);
|
|
172
170
|
}
|
|
173
171
|
};
|
|
174
172
|
const applyAccessibleProps = (widget, oldProps, newProps) => {
|
|
175
|
-
applyChangedProps(widget,
|
|
173
|
+
applyChangedProps(widget, newProps);
|
|
176
174
|
if (oldProps) {
|
|
177
175
|
resetRemovedProps(widget, oldProps, newProps);
|
|
178
176
|
}
|