@gtkx/react 1.0.0-rc.3 → 1.0.0-rc.4
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 +4 -5
- package/dist/adw/config.d.ts +1 -0
- package/dist/adw/config.d.ts.map +1 -1
- package/dist/adw/config.js +1 -0
- package/dist/adw/config.js.map +1 -1
- package/dist/adw/dialog.d.ts +1 -0
- package/dist/adw/dialog.d.ts.map +1 -1
- package/dist/adw/dialog.js +1 -0
- package/dist/adw/dialog.js.map +1 -1
- package/dist/adw/element-behaviors.js +2 -3
- package/dist/adw/element-behaviors.js.map +1 -1
- package/dist/adw/element-config.d.ts +4 -3
- package/dist/adw/element-config.d.ts.map +1 -1
- package/dist/adw/element-config.js +14 -13
- package/dist/adw/element-config.js.map +1 -1
- package/dist/adw/index.d.ts +1 -0
- package/dist/adw/index.d.ts.map +1 -1
- package/dist/adw/index.js +1 -0
- package/dist/adw/index.js.map +1 -1
- package/dist/adw/prop-types.d.ts +1 -1
- package/dist/adw/prop-types.d.ts.map +1 -1
- package/dist/adw/prop-types.js.map +1 -1
- package/dist/bootstrap.js +1 -1
- package/dist/bootstrap.js.map +1 -1
- package/dist/components/application.d.ts +1 -0
- package/dist/components/application.d.ts.map +1 -1
- package/dist/components/application.js +1 -0
- package/dist/components/application.js.map +1 -1
- package/dist/components/element.d.ts +0 -1
- package/dist/components/element.d.ts.map +1 -1
- package/dist/components/element.js +0 -1
- package/dist/components/element.js.map +1 -1
- package/dist/components/window.d.ts +1 -0
- package/dist/components/window.d.ts.map +1 -1
- package/dist/components/window.js +1 -0
- package/dist/components/window.js.map +1 -1
- package/dist/config.d.ts +5 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -1
- package/dist/config.js.map +1 -1
- package/dist/element-behaviors.js +0 -1
- package/dist/element-behaviors.js.map +1 -1
- package/dist/element-config.d.ts +4 -3
- package/dist/element-config.d.ts.map +1 -1
- package/dist/element-config.js +12 -11
- package/dist/element-config.js.map +1 -1
- package/dist/hooks/use-bind-setting.d.ts +8 -7
- package/dist/hooks/use-bind-setting.d.ts.map +1 -1
- package/dist/hooks/use-bind-setting.js +2 -7
- package/dist/hooks/use-bind-setting.js.map +1 -1
- package/dist/hooks/use-parent-window.d.ts +3 -1
- package/dist/hooks/use-parent-window.d.ts.map +1 -1
- package/dist/hooks/use-parent-window.js +3 -1
- package/dist/hooks/use-parent-window.js.map +1 -1
- package/dist/hooks/use-property.d.ts +2 -2
- package/dist/hooks/use-property.d.ts.map +1 -1
- package/dist/hooks/use-property.js +1 -2
- package/dist/hooks/use-property.js.map +1 -1
- package/dist/hooks/use-setting.d.ts +2 -3
- package/dist/hooks/use-setting.d.ts.map +1 -1
- package/dist/hooks/use-setting.js +2 -3
- package/dist/hooks/use-setting.js.map +1 -1
- package/dist/hooks/use-signal.d.ts +13 -7
- package/dist/hooks/use-signal.d.ts.map +1 -1
- package/dist/hooks/use-signal.js +6 -8
- package/dist/hooks/use-signal.js.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +4 -3
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -3
- package/dist/internal.js.map +1 -1
- package/dist/prop-types.d.ts +60 -0
- package/dist/prop-types.d.ts.map +1 -1
- package/dist/prop-types.js.map +1 -1
- package/dist/reconciler/behaviors.d.ts +0 -15
- package/dist/reconciler/behaviors.d.ts.map +1 -1
- package/dist/reconciler/behaviors.js +5 -20
- package/dist/reconciler/behaviors.js.map +1 -1
- package/dist/reconciler/host-config.d.ts +1 -1
- package/dist/reconciler/host-config.d.ts.map +1 -1
- package/dist/reconciler/host-config.js.map +1 -1
- package/dist/reconciler/instance.js +1 -1
- 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 +7 -7
- package/dist/reconciler/metadata.js.map +1 -1
- package/dist/reconciler/node.d.ts +2 -2
- package/dist/reconciler/node.d.ts.map +1 -1
- package/dist/reconciler/node.js +1 -1
- package/dist/reconciler/node.js.map +1 -1
- package/dist/reconciler/placement.js +6 -6
- package/dist/reconciler/placement.js.map +1 -1
- package/dist/reconciler/registry.d.ts +42 -30
- package/dist/reconciler/registry.d.ts.map +1 -1
- package/dist/reconciler/registry.js +10 -19
- package/dist/reconciler/registry.js.map +1 -1
- package/dist/reconciler/root-element.d.ts +0 -1
- package/dist/reconciler/root-element.d.ts.map +1 -1
- package/dist/reconciler/root-element.js +0 -1
- package/dist/reconciler/root-element.js.map +1 -1
- package/dist/reconciler/root.d.ts +6 -20
- package/dist/reconciler/root.d.ts.map +1 -1
- package/dist/reconciler/root.js +4 -19
- package/dist/reconciler/root.js.map +1 -1
- package/dist/reconciler/signals.js +2 -2
- package/dist/reconciler/signals.js.map +1 -1
- package/dist/reconciler/text.js +5 -5
- package/dist/reconciler/text.js.map +1 -1
- package/dist/utils/accessible-metadata.d.ts +0 -7
- package/dist/utils/accessible-metadata.d.ts.map +1 -1
- package/dist/utils/accessible-metadata.js +0 -7
- package/dist/utils/accessible-metadata.js.map +1 -1
- package/dist/utils/accessible-props.d.ts +49 -1
- package/dist/utils/accessible-props.d.ts.map +1 -1
- package/dist/utils/accessible-props.js.map +1 -1
- package/dist/utils/ref-prop.d.ts +0 -6
- package/dist/utils/ref-prop.d.ts.map +1 -1
- package/dist/utils/ref-prop.js +0 -6
- package/dist/utils/ref-prop.js.map +1 -1
- package/dist/utils/settings.d.ts +6 -0
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/settings.js.map +1 -1
- package/env.d.ts +11 -4
- package/package.json +5 -5
- package/src/adw/config.ts +1 -0
- package/src/adw/dialog.tsx +1 -0
- package/src/adw/element-behaviors.ts +2 -3
- package/src/adw/element-config.ts +14 -13
- package/src/adw/index.ts +1 -0
- package/src/adw/prop-types.ts +1 -1
- package/src/bootstrap.ts +1 -1
- package/src/components/application.tsx +1 -0
- package/src/components/element.tsx +0 -1
- package/src/components/window.tsx +1 -0
- package/src/config.ts +5 -9
- package/src/element-behaviors.ts +0 -1
- package/src/element-config.ts +12 -11
- package/src/hooks/use-bind-setting.ts +8 -7
- package/src/hooks/use-parent-window.ts +3 -1
- package/src/hooks/use-property.ts +2 -2
- package/src/hooks/use-setting.ts +2 -3
- package/src/hooks/use-signal.ts +16 -10
- package/src/index.ts +10 -2
- package/src/internal.ts +4 -3
- package/src/prop-types.ts +86 -5
- package/src/reconciler/behaviors.ts +6 -21
- package/src/reconciler/host-config.ts +1 -1
- package/src/reconciler/instance.ts +1 -1
- package/src/reconciler/metadata.ts +8 -8
- package/src/reconciler/node.ts +3 -3
- package/src/reconciler/placement.ts +6 -6
- package/src/reconciler/registry.ts +52 -37
- package/src/reconciler/root-element.ts +0 -1
- package/src/reconciler/root.ts +6 -20
- package/src/reconciler/signals.ts +2 -2
- package/src/reconciler/text.ts +6 -6
- package/src/utils/accessible-metadata.ts +0 -7
- package/src/utils/accessible-props.ts +49 -1
- package/src/utils/ref-prop.ts +0 -6
- package/src/utils/settings.ts +6 -0
|
@@ -3,31 +3,30 @@
|
|
|
3
3
|
* is loaded.
|
|
4
4
|
*/
|
|
5
5
|
const ELEMENTS = {};
|
|
6
|
-
/** Props a behavior applies after construction; the constructor is never given them. */
|
|
7
6
|
const deferredProps = (behavior) => behavior.deferred ?? [];
|
|
8
7
|
const mergeBehaviors = (base, added, isPrepended) => {
|
|
9
8
|
const baseBehaviors = base.behaviors ?? [];
|
|
10
9
|
return isPrepended ? [...added, ...baseBehaviors] : [...baseBehaviors, ...added];
|
|
11
10
|
};
|
|
12
11
|
const mergeConfigEntry = (base, added, isPrepended = false) => {
|
|
13
|
-
const { behaviors,
|
|
12
|
+
const { behaviors, isLazy, omittedProps, ...rest } = added;
|
|
14
13
|
const entry = { ...base, ...rest };
|
|
15
14
|
if (behaviors !== undefined) {
|
|
16
15
|
entry.behaviors = mergeBehaviors(base, behaviors, isPrepended);
|
|
17
16
|
}
|
|
18
|
-
if (
|
|
19
|
-
entry.
|
|
17
|
+
if (omittedProps !== undefined) {
|
|
18
|
+
entry.omittedProps = [...(base.omittedProps ?? []), ...omittedProps];
|
|
20
19
|
}
|
|
21
|
-
if (
|
|
22
|
-
entry.
|
|
20
|
+
if (isLazy === true) {
|
|
21
|
+
entry.isLazy = true;
|
|
23
22
|
}
|
|
24
23
|
return entry;
|
|
25
24
|
};
|
|
26
25
|
/**
|
|
27
26
|
* Merges maps of {@link ElementConfig} keyed by GLib type name into one, concatenating each type's
|
|
28
|
-
* behaviors and omitted props in the order the maps are given (an earlier map's behaviors come first)
|
|
29
|
-
*
|
|
30
|
-
* with its behaviors.
|
|
27
|
+
* behaviors and omitted props in the order the maps are given (an earlier map's behaviors come first),
|
|
28
|
+
* taking the last component and props seen, and marking a type lazy if any map does. Use it to combine
|
|
29
|
+
* an app's element config with its behaviors.
|
|
31
30
|
*/
|
|
32
31
|
const mergeElementConfigs = (...maps) => {
|
|
33
32
|
const merged = {};
|
|
@@ -38,19 +37,13 @@ const mergeElementConfigs = (...maps) => {
|
|
|
38
37
|
}
|
|
39
38
|
return merged;
|
|
40
39
|
};
|
|
41
|
-
/**
|
|
42
|
-
* Registers a map of {@link ElementConfig} keyed by GLib type name, merging each entry into the
|
|
43
|
-
* registry. Behaviors are appended by default (the framework's built-ins register this way); pass
|
|
44
|
-
* `{ prepend: true }` for an app's own configuration so its behaviors are consulted before the
|
|
45
|
-
* built-ins for the same slot, letting it override them regardless of registration order.
|
|
46
|
-
*/
|
|
47
40
|
const registerElements = (map, options = {}) => {
|
|
48
41
|
for (const [type, config] of Object.entries(map)) {
|
|
49
|
-
ELEMENTS[type] = mergeConfigEntry(ELEMENTS[type] ?? {}, config, options.
|
|
42
|
+
ELEMENTS[type] = mergeConfigEntry(ELEMENTS[type] ?? {}, config, options.isPrepended === true);
|
|
50
43
|
}
|
|
51
44
|
};
|
|
52
45
|
/**
|
|
53
|
-
* Identity helper that types the module named by
|
|
46
|
+
* Identity helper that types the module named by `elements.behaviors` in `gtkx.config.ts`, enabling
|
|
54
47
|
* editor autocompletion and type checking. Key each entry by GLib type name and write each behavior
|
|
55
48
|
* with {@link defineBehavior} so its hooks receive the concrete GObject class.
|
|
56
49
|
*/
|
|
@@ -66,9 +59,7 @@ const defineElements = (elements) => elements;
|
|
|
66
59
|
* ```
|
|
67
60
|
*/
|
|
68
61
|
const defineBehavior = (hooks) => hooks;
|
|
69
|
-
/** Spreads one config across many GLib type names. */
|
|
70
62
|
const forTypes = (types, config) => Object.fromEntries(types.map((type) => [type, config]));
|
|
71
|
-
/** References a base props interface exported from `@gtkx/react/internal`. */
|
|
72
63
|
const internal = (name) => ({ module: "@gtkx/react/internal", export: name });
|
|
73
64
|
export { ELEMENTS, deferredProps, mergeElementConfigs, registerElements, defineElements, defineBehavior, forTypes, internal, };
|
|
74
65
|
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/reconciler/registry.ts"],"names":[],"mappings":"AAiEA;;;GAGG;AACH,MAAM,QAAQ,GAAkC,EAAE,CAAC;AAEnD,wFAAwF;AACxF,MAAM,aAAa,GAAG,CAAC,QAAyB,EAAY,EAAE,CAAC,QAAQ,CAAC,QAAQ,IAAI,EAAE,CAAC;AAEvF,MAAM,cAAc,GAAG,CAAC,IAAmB,EAAE,KAAwB,EAAE,WAAoB,EAAqB,EAAE;IAC9G,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IAE3C,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,aAAa,EAAE,GAAG,KAAK,CAAC,CAAC;AACrF,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,IAAmB,EAAE,KAA2B,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M,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,OAAO,KAAK,IAAI,CAAC,CAAC;IAC9F,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,sDAAsD;AACtD,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,8EAA8E;AAC9E,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 slot: string;\n index: number;\n sibling: GObject.Object | null;\n adopted: GObject.Object | null;\n props: Props;\n context: unknown;\n};\n\n/** Per-child values a slot hook receives while removing one child. */\ntype DetachInfo = {\n slot: string;\n adopted: GObject.Object | null;\n props: Props;\n context: unknown;\n};\n\n/**\n * Customizes how one element type places children and applies props. Every hook receives the\n * GObject instance and a private per-node `context` built once by `createContext`. A slot hook\n * claims a child by returning a non-`undefined` value; that value, or `resolve`, is the object\n * the container adopts for the child. `update` returns the prop names it consumed so those props\n * are not also set as plain GObject properties. `create` builds the GObject for types whose\n * constructor does more than set properties, and is consulted for its own type only, never\n * inherited by subtypes.\n */\ntype ElementBehavior<T extends GObject.Object = GObject.Object> = {\n create?: (props: Props) => GObject.Object;\n createContext?: (object: T) => unknown;\n attach?: (object: T, child: GObject.Object, info: PlaceInfo) => unknown;\n reorder?: (object: T, child: GObject.Object, info: PlaceInfo) => unknown;\n detach?: (object: T, child: GObject.Object, info: DetachInfo) => void;\n resolve?: (object: T, child: GObject.Object) => GObject.Object | null;\n update?: (object: T, prev: Props, next: Props, context: unknown) => Iterable<string> | undefined;\n flush?: (object: T, context: unknown) => void;\n mount?: (object: T, context: unknown) => void;\n unmount?: (object: T, context: unknown) => void;\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 = { module: string; export: string };\n\n/**\n * Per-element configuration keyed by GLib type name: whether the element is lazy (its GObject is\n * created by its parent container, as pages and layout children are), the custom behaviors bound to\n * its type, an optional component that wraps the generated element, the base props interface its\n * generated props extend, and the GObject properties to leave out of the generated props (those a\n * behavior already writes from children, such as the `child` and `content` properties). `component`,\n * `props` and `omitProps` are inert at runtime; they are read only by codegen.\n */\ntype ElementConfig<T extends GObject.Object = GObject.Object> = {\n lazy?: boolean;\n behaviors?: ElementBehavior<T>[];\n component?: ModuleExport;\n props?: ModuleExport;\n omitProps?: 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\n/** Props a behavior applies after construction; the constructor is never given them. */\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, lazy, omitProps, ...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 (omitProps !== undefined) {\n entry.omitProps = [...(base.omitProps ?? []), ...omitProps];\n }\n\n if (lazy === true) {\n entry.lazy = 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 * and taking the last lazy flag, component, and props seen. Use it to combine an app's element config\n * 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\n/**\n * Registers a map of {@link ElementConfig} keyed by GLib type name, merging each entry into the\n * registry. Behaviors are appended by default (the framework's built-ins register this way); pass\n * `{ prepend: true }` for an app's own configuration so its behaviors are consulted before the\n * built-ins for the same slot, letting it override them regardless of registration order.\n */\nconst registerElements = (\n map: Record<string, ElementConfig<never>>,\n options: { prepend?: boolean } = {},\n): void => {\n for (const [type, config] of Object.entries(map)) {\n ELEMENTS[type] = mergeConfigEntry(ELEMENTS[type] ?? {}, config, options.prepend === true);\n }\n};\n\n/**\n * Identity helper that types the module named by the `elements` entry of `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\n/** Spreads one config across many GLib type names. */\nconst forTypes = (types: string[], config: ElementConfig<never>): Record<string, ElementConfig<never>> =>\n Object.fromEntries(types.map((type) => [type, config]));\n\n/** References a base props interface exported from `@gtkx/react/internal`. */\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/registry.ts"],"names":[],"mappings":"AAyFA;;;GAGG;AACH,MAAM,QAAQ,GAAkC,EAAE,CAAC;AAEnD,MAAM,aAAa,GAAG,CAAC,QAAyB,EAAY,EAAE,CAAC,QAAQ,CAAC,QAAQ,IAAI,EAAE,CAAC;AAEvF,MAAM,cAAc,GAAG,CAAC,IAAmB,EAAE,KAAwB,EAAE,WAAoB,EAAqB,EAAE;IAC9G,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IAE3C,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,aAAa,EAAE,GAAG,KAAK,CAAC,CAAC;AACrF,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,IAAmB,EAAE,KAA2B,EAAE,WAAW,GAAG,KAAK,EAAiB,EAAE;IAC9G,MAAM,EAAE,SA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C,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"]}
|
|
@@ -5,7 +5,6 @@ type RootElement = {
|
|
|
5
5
|
declare const ROOT_ELEMENT_BRAND: unique symbol;
|
|
6
6
|
/** A shared marker value used as the default top-level container for rendering and portals. */
|
|
7
7
|
declare const rootElement: RootElement;
|
|
8
|
-
/** Reports whether an arbitrary value is a {@link rootElement} marker. */
|
|
9
8
|
declare const isRootElement: (value: unknown) => value is RootElement;
|
|
10
9
|
export { rootElement, isRootElement, type RootElement };
|
|
11
10
|
//# sourceMappingURL=root-element.d.ts.map
|
|
@@ -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;IAAE,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAElD,QAAA,MAAM,kBAAkB,EAAE,OAAO,MAAwC,CAAC;AAC1E,+FAA+F;AAC/F,QAAA,MAAM,WAAW,EAAE,WAA4C,CAAC;AAEhE,
|
|
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;IAAE,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAElD,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,7 +1,6 @@
|
|
|
1
1
|
const ROOT_ELEMENT_BRAND = Symbol.for("gtkx:root-element");
|
|
2
2
|
/** A shared marker value used as the default top-level container for rendering and portals. */
|
|
3
3
|
const rootElement = { [ROOT_ELEMENT_BRAND]: true };
|
|
4
|
-
/** Reports whether an arbitrary value is a {@link rootElement} marker. */
|
|
5
4
|
const isRootElement = (value) => typeof value === "object" && value !== null && Object.hasOwn(value, ROOT_ELEMENT_BRAND);
|
|
6
5
|
export { rootElement, isRootElement };
|
|
7
6
|
//# sourceMappingURL=root-element.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root-element.js","sourceRoot":"","sources":["../../src/reconciler/root-element.ts"],"names":[],"mappings":"AAGA,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,
|
|
1
|
+
{"version":3,"file":"root-element.js","sourceRoot":"","sources":["../../src/reconciler/root-element.ts"],"names":[],"mappings":"AAGA,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 = { [ROOT_ELEMENT_BRAND]: true };\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,36 +9,25 @@ type RootErrorCallbacks = {
|
|
|
9
9
|
type ReconcilerRootOptions = RootErrorCallbacks & {
|
|
10
10
|
containerInfo: Container;
|
|
11
11
|
};
|
|
12
|
-
/** A root that mounts an element tree into an explicit container and reports render errors. */
|
|
13
12
|
type ReconcilerRoot = {
|
|
14
13
|
update: (element: ReactNode) => void;
|
|
15
14
|
unmount: (teardown: (root: ReconcilerRoot) => Promise<void>) => Promise<void>;
|
|
16
15
|
};
|
|
17
16
|
/** The object {@link createRoot} returns: it renders an element tree into a container and can tear it down. */
|
|
18
17
|
type Root = {
|
|
18
|
+
/** Mounts an element tree into the container, or updates the tree already mounted there. */
|
|
19
19
|
render: (element: ReactNode) => void;
|
|
20
|
+
/** Unmounts the rendered tree and runs its effect cleanups. */
|
|
20
21
|
unmount: () => void;
|
|
21
22
|
};
|
|
22
23
|
type ErrorHandler = (error: unknown) => void;
|
|
23
|
-
/**
|
|
24
|
-
* Installs a process-wide handler for errors thrown while rendering or applying an update.
|
|
25
|
-
*
|
|
26
|
-
* @param handler The handler to install.
|
|
27
|
-
* @returns The previously installed handler, or null.
|
|
28
|
-
*/
|
|
29
24
|
declare const setReconcilerErrorHandler: (handler: ErrorHandler) => ErrorHandler | null;
|
|
30
|
-
/**
|
|
31
|
-
* Creates a root that mounts an element tree into a container, routing render errors to the supplied callbacks.
|
|
32
|
-
*
|
|
33
|
-
* @param options The container to render into and the error callbacks to route failures to.
|
|
34
|
-
* @returns A {@link ReconcilerRoot}.
|
|
35
|
-
*/
|
|
36
25
|
declare const createReconcilerRoot: (options: ReconcilerRootOptions) => ReconcilerRoot;
|
|
37
26
|
/**
|
|
38
|
-
* Creates a render root for a GTKX application.
|
|
27
|
+
* Creates a render root for a GTKX application. Uncaught render errors are rethrown and errors caught by an
|
|
28
|
+
* error boundary are logged.
|
|
39
29
|
*
|
|
40
|
-
* @param container The
|
|
41
|
-
* @returns A {@link Root} exposing render and unmount.
|
|
30
|
+
* @param container The GObject to render into; defaults to the shared {@link rootElement}, which holds no object.
|
|
42
31
|
*/
|
|
43
32
|
declare const createRoot: (container?: Container) => Root;
|
|
44
33
|
/** Unmounts every active render root and stops the originating signal from propagating further. */
|
|
@@ -46,10 +35,7 @@ declare const quit: () => typeof Gdk.EVENT_STOP;
|
|
|
46
35
|
/**
|
|
47
36
|
* Renders children into a container other than the surrounding tree.
|
|
48
37
|
*
|
|
49
|
-
* @param
|
|
50
|
-
* @param container The GObject, application, or {@link rootElement} to render into.
|
|
51
|
-
* @param key An optional stable key.
|
|
52
|
-
* @returns A React portal.
|
|
38
|
+
* @param container The GObject to render into, or {@link rootElement} to render at the top level.
|
|
53
39
|
*/
|
|
54
40
|
declare const createPortal: (children: ReactNode, container: Container, key?: string) => ReactPortal;
|
|
55
41
|
export { setReconcilerErrorHandler, createReconcilerRoot, createRoot, quit, createPortal, type ReconcilerRoot, type Root, };
|
|
@@ -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;AAGpC,OAAO,EAAE,KAAK,SAAS,EAAc,MAAM,kBAAkB,CAAC;AAK9D,KAAK,kBAAkB,GAAG;IACtB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IAC5D,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IAC1D,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CAClE,CAAC;AAEF,KAAK,qBAAqB,GAAG,kBAAkB,GAAG;IAAE,aAAa,EAAE,SAAS,CAAA;CAAE,CAAC;AAE/E
|
|
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;AAGpC,OAAO,EAAE,KAAK,SAAS,EAAc,MAAM,kBAAkB,CAAC;AAK9D,KAAK,kBAAkB,GAAG;IACtB,eAAe,C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AAC;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
|
@@ -17,12 +17,6 @@ function createErrorHandlerSlot() {
|
|
|
17
17
|
},
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Installs a process-wide handler for errors thrown while rendering or applying an update.
|
|
22
|
-
*
|
|
23
|
-
* @param handler The handler to install.
|
|
24
|
-
* @returns The previously installed handler, or null.
|
|
25
|
-
*/
|
|
26
20
|
const setReconcilerErrorHandler = (handler) => errorHandlerSlot.set(handler);
|
|
27
21
|
const rethrowUncaughtRenderError = (error) => {
|
|
28
22
|
throw error;
|
|
@@ -47,12 +41,6 @@ const unmountContainer = (container) => {
|
|
|
47
41
|
reconciler.updateContainer(null, container, null, null);
|
|
48
42
|
activeRoots.delete(container);
|
|
49
43
|
};
|
|
50
|
-
/**
|
|
51
|
-
* Creates a root that mounts an element tree into a container, routing render errors to the supplied callbacks.
|
|
52
|
-
*
|
|
53
|
-
* @param options The container to render into and the error callbacks to route failures to.
|
|
54
|
-
* @returns A {@link ReconcilerRoot}.
|
|
55
|
-
*/
|
|
56
44
|
const createReconcilerRoot = (options) => {
|
|
57
45
|
const container = openContainer(options.containerInfo, options);
|
|
58
46
|
const root = {
|
|
@@ -67,10 +55,10 @@ const createReconcilerRoot = (options) => {
|
|
|
67
55
|
return root;
|
|
68
56
|
};
|
|
69
57
|
/**
|
|
70
|
-
* Creates a render root for a GTKX application.
|
|
58
|
+
* Creates a render root for a GTKX application. Uncaught render errors are rethrown and errors caught by an
|
|
59
|
+
* error boundary are logged.
|
|
71
60
|
*
|
|
72
|
-
* @param container The
|
|
73
|
-
* @returns A {@link Root} exposing render and unmount.
|
|
61
|
+
* @param container The GObject to render into; defaults to the shared {@link rootElement}, which holds no object.
|
|
74
62
|
*/
|
|
75
63
|
const createRoot = (container = rootElement) => {
|
|
76
64
|
const opaque = openContainer(container, {
|
|
@@ -96,10 +84,7 @@ const quit = () => {
|
|
|
96
84
|
/**
|
|
97
85
|
* Renders children into a container other than the surrounding tree.
|
|
98
86
|
*
|
|
99
|
-
* @param
|
|
100
|
-
* @param container The GObject, application, or {@link rootElement} to render into.
|
|
101
|
-
* @param key An optional stable key.
|
|
102
|
-
* @returns A React portal.
|
|
87
|
+
* @param container The GObject to render into, or {@link rootElement} to render at the top level.
|
|
103
88
|
*/
|
|
104
89
|
const createPortal = (children, container, key) => reconciler.createPortal(children, container, null, key ?? null);
|
|
105
90
|
export { setReconcilerErrorHandler, createReconcilerRoot, createRoot, quit, createPortal, };
|
|
@@ -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,EAAkB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA6BhD,MAAM,GAAG,GAAW,YAAY,CAAC,OAAO,CAAC,CAAC;AAC1C,MAAM,WAAW,GAAoB,IAAI,GAAG,EAAE,CAAC;AAC/C,MAAM,gB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AAC,CAAC;QAC5D,CAAC;QACD,OAAO,EAAE,GAAG,EAAE;YACV,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAC7B,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,mGAAmG;AACnG,MAAM,IAAI,GAAG,GAA0B,EAAE;IACrC,KAAK,MAAM,SAAS,IAAI,WAAW,EAAE,CAAC;QAClC,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,GAAG,CAAC,UAAU,CAAC;AAC1B,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 { 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\ntype ReconcilerRoot = {\n update: (element: ReactNode) => void;\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 /** Mounts an element tree into the container, or updates the tree already mounted there. */\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 const container = 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 activeRoots.add(container);\n\n return container;\n};\n\nconst unmountContainer = (container: OpaqueRoot): void => {\n reconciler.updateContainer(null, container, null, null);\n activeRoots.delete(container);\n};\n\nconst createReconcilerRoot = (options: ReconcilerRootOptions): ReconcilerRoot => {\n const container = openContainer(options.containerInfo, options);\n\n const root: ReconcilerRoot = {\n update: (element) => {\n reconciler.updateContainer(element, container, null, null);\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 reconciler.updateContainer(element, opaque, null, null);\n },\n unmount: () => {\n unmountContainer(opaque);\n },\n };\n};\n\n/** Unmounts every active render root and stops the originating signal from propagating further. */\nconst quit = (): typeof Gdk.EVENT_STOP => {\n for (const container of activeRoots) {\n unmountContainer(container);\n }\n\n return Gdk.EVENT_STOP;\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"]}
|
|
@@ -19,7 +19,7 @@ const invokeHandler = (target, record, notifyProperty, args) => notifyProperty =
|
|
|
19
19
|
? record.handler(...args, target.object)
|
|
20
20
|
: record.handler(Reflect.get(target.object, notifyProperty), target.object);
|
|
21
21
|
const wrapHandler = (target, record, notifyProperty) => (...args) => {
|
|
22
|
-
if (record.
|
|
22
|
+
if (record.isBlockable && isApplyingWrite()) {
|
|
23
23
|
return undefined;
|
|
24
24
|
}
|
|
25
25
|
return target.dispatch(() => invokeHandler(target, record, notifyProperty, args));
|
|
@@ -35,7 +35,7 @@ const connectHandler = (target, prop, signal, handler) => {
|
|
|
35
35
|
}
|
|
36
36
|
const isBlockable = isBlockableSignal(typeInfoFor(target.typeName), signal);
|
|
37
37
|
const notifyProperty = getNotifyProperty(signal);
|
|
38
|
-
const record = { signal, handler, wrapped: () => undefined,
|
|
38
|
+
const record = { signal, handler, wrapped: () => undefined, isBlockable };
|
|
39
39
|
record.wrapped = wrapHandler(target, record, notifyProperty);
|
|
40
40
|
target.object.on(signal, record.wrapped);
|
|
41
41
|
target.handlers.set(prop, record);
|
|
@@ -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,cAA6B,EAC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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,eAAe,EACf,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 isApplyingWrite,\n connectHandler,\n disconnectHandler,\n disconnectAllHandlers,\n};\n"]}
|
package/dist/reconciler/text.js
CHANGED
|
@@ -49,23 +49,23 @@ const contentTextLength = (node) => {
|
|
|
49
49
|
const isTagElement = (node) => node.kind === ELEMENT_KIND && node.contentKind === "tag";
|
|
50
50
|
const stepOffset = (node, target, offset) => {
|
|
51
51
|
if (node === target) {
|
|
52
|
-
return {
|
|
52
|
+
return { wasFound: true, offset };
|
|
53
53
|
}
|
|
54
54
|
if (isTagElement(node)) {
|
|
55
55
|
return getOffset(node.content, target, offset);
|
|
56
56
|
}
|
|
57
|
-
return {
|
|
57
|
+
return { wasFound: false, offset: offset + contentTextLength(node) };
|
|
58
58
|
};
|
|
59
59
|
const getOffset = (nodes, target, start) => {
|
|
60
60
|
let offset = start;
|
|
61
61
|
for (const node of nodes) {
|
|
62
62
|
const step = stepOffset(node, target, offset);
|
|
63
|
-
if (step.
|
|
63
|
+
if (step.wasFound) {
|
|
64
64
|
return step;
|
|
65
65
|
}
|
|
66
66
|
offset = step.offset;
|
|
67
67
|
}
|
|
68
|
-
return {
|
|
68
|
+
return { wasFound: false, offset };
|
|
69
69
|
};
|
|
70
70
|
const enclosingTagNodes = (node) => {
|
|
71
71
|
const nodes = [];
|
|
@@ -264,7 +264,7 @@ const didUpdateTextSurgically = (host, node, oldText, newText) => {
|
|
|
264
264
|
return false;
|
|
265
265
|
}
|
|
266
266
|
const located = getOffset(host.content, node, 0);
|
|
267
|
-
if (!located.
|
|
267
|
+
if (!located.wasFound) {
|
|
268
268
|
return false;
|
|
269
269
|
}
|
|
270
270
|
const start = located.offset;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/reconciler/text.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGtD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAU1C,MAAM,UAAU,GAAqB,IAAI,GAAG,EAAE,CAAC;AAC/C,MAAM,SAAS,GAAsC,IAAI,OAAO,EAAE,CAAC;AACnE,MAAM,kBAAkB,GAAgB,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;AAC5E,MAAM,cAAc,GAAG,WAAW,CAAC;AACnC,MAAM,SAAS,GAAG,MAAM,CAAC;AAEzB,MAAM,iBAAiB,GAA2D;IAC9E;QACI,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,+EAA+E;KAC3F;IACD;QACI,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,sFAAsF;KAClG;IACD;QACI,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE,8FAA8F;KAC1G;CACJ,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CA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,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAEjD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IAE7B,UAAU,CAAC,GAAG,EAAE;QACZ,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,eAAe,CAAC,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAClG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,MAAM,CAAC,eAAe,CAAC,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;IACpE,kBAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAErD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,OAAO,EACH,SAAS,EACT,oBAAoB,EACpB,UAAU,EACV,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,aAAa,EACb,aAAa,EACb,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,uBAAuB,GAC1B,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gdk from \"@gtkx/gi/gdk\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { drain, indexBeforeOrEnd } from \"@gtkx/utils\";\nimport type { ContentChild, ContentKind, ElementNode, ParentNode, TextNode } from \"./node.js\";\nimport type { Props } from \"./registry.js\";\nimport { ELEMENT_KIND, TEXT_KIND } from \"./node.js\";\nimport { applyWrite } from \"./signals.js\";\n\ntype OffsetResult = { found: boolean; offset: number };\n\ntype BufferBuild = {\n buffer: Gtk.TextBuffer;\n view: Gtk.TextView | null;\n marks: { node: ElementNode; offset: number }[];\n};\n\nconst dirtyHosts: Set<ElementNode> = new Set();\nconst tagTables: WeakMap<object, Gtk.TextTagTable> = new WeakMap();\nconst TEXT_CONTENT_KINDS: Set<string> = new Set([\"label\", \"buffer\", \"tag\"]);\nconst PAINTABLE_PROP = \"paintable\";\nconst TEXT_PROP = \"text\";\n\nconst CONTENT_MIX_RULES: { kind: ContentKind; prop: string; message: string }[] = [\n {\n kind: \"label\",\n prop: \"label\",\n message: \"<GtkLabel> cannot mix a `label` prop with text children; use one or the other\",\n },\n {\n kind: \"buffer\",\n prop: \"text\",\n message: \"<GtkTextBuffer> cannot mix a `text` prop with content children; use one or the other\",\n },\n {\n kind: \"anchor\",\n prop: PAINTABLE_PROP,\n message: \"<GtkTextChildAnchor> cannot mix a `paintable` prop with a child widget; use one or the other\",\n },\n];\n\nconst charLength = (text: string): number => text[Symbol.iterator]().toArray().length;\n\nconst bufferText = (buffer: Gtk.TextBuffer): string =>\n buffer.getText(buffer.getStartIter(), buffer.getEndIter(), false);\n\nconst currentText = (object: GObject.Object): string | null => {\n if (object instanceof Gtk.TextBuffer) {\n return bufferText(object);\n }\n\n if (object instanceof Gtk.Editable || object instanceof Gtk.EntryBuffer) {\n return object.getText();\n }\n\n return null;\n};\n\nconst hasSameText = (object: GObject.Object, prop: string, value: unknown): boolean =>\n prop === TEXT_PROP && typeof value === \"string\" && currentText(object) === value;\n\nconst contentTextLength = (node: ContentChild): number => {\n if (node.kind === TEXT_KIND) {\n return charLength(node.text);\n }\n\n if (node.contentKind === \"tag\") {\n return node.content.reduce((sum, child) => sum + contentTextLength(child), 0);\n }\n\n return node.contentKind === \"anchor\" ? 1 : 0;\n};\n\nconst isTagElement = (node: ContentChild): node is ElementNode =>\n node.kind === ELEMENT_KIND && node.contentKind === \"tag\";\n\nconst stepOffset = (node: ContentChild, target: TextNode, offset: number): OffsetResult => {\n if (node === target) {\n return { found: true, offset };\n }\n\n if (isTagElement(node)) {\n return getOffset(node.content, target, offset);\n }\n\n return { found: false, offset: offset + contentTextLength(node) };\n};\n\nconst getOffset = (nodes: ContentChild[], target: TextNode, start: number): OffsetResult => {\n let offset = start;\n\n for (const node of nodes) {\n const step = stepOffset(node, target, offset);\n\n if (step.found) {\n return step;\n }\n\n offset = step.offset;\n }\n\n return { found: false, offset };\n};\n\nconst enclosingTagNodes = (node: TextNode): ElementNode[] => {\n const nodes: ElementNode[] = [];\n let current: ParentNode | null = node.parent;\n\n while (current !== null && current.kind === ELEMENT_KIND) {\n if (current.contentKind === \"tag\") {\n nodes.push(current);\n }\n\n current = current.parent;\n }\n\n return nodes;\n};\n\nconst textRestrictionError = (text: string): Error =>\n new Error(\n \"Text strings must be rendered within a <GtkLabel> or <GtkTextBuffer> element; \" +\n `received ${JSON.stringify(text)}`,\n );\n\nconst canAcceptText = (host: ElementNode): boolean =>\n host.contentKind !== null && TEXT_CONTENT_KINDS.has(host.contentKind);\n\nconst isRootHost = (node: ElementNode): boolean => node.contentKind === \"label\" || node.contentKind === \"buffer\";\n\nconst mapElementParent = <T>(parent: ParentNode | null, map: (element: ElementNode) => T): T | null =>\n parent !== null && parent.kind === ELEMENT_KIND ? map(parent) : null;\n\nconst parentElement = (node: ElementNode): ElementNode | null => mapElementParent(node.parent, (parent) => parent);\n\nconst getRootHost = (node: ElementNode): ElementNode | null => {\n let current: ElementNode | null = node;\n\n while (current !== null) {\n if (isRootHost(current)) {\n return current;\n }\n\n current = parentElement(current);\n }\n\n return null;\n};\n\nconst markTextDirty = (host: ElementNode): void => {\n const root = getRootHost(host);\n\n if (root !== null) {\n dirtyHosts.add(root);\n }\n};\n\nconst enclosingHost = (node: TextNode): ElementNode | null => mapElementParent(node.parent, getRootHost);\n\nconst addContent = (host: ElementNode, child: ContentChild, before: ContentChild | null): void => {\n const content = host.content;\n const existing = content.indexOf(child);\n\n if (existing !== -1) {\n content.splice(existing, 1);\n }\n\n content.splice(\n indexBeforeOrEnd(content, before, (item, target) => item === target),\n 0,\n child,\n );\n\n child.parent = host;\n markTextDirty(host);\n};\n\nconst removeContent = (host: ElementNode, child: ContentChild): void => {\n const index = host.content.indexOf(child);\n\n if (index !== -1) {\n host.content.splice(index, 1);\n }\n\n markTextDirty(host);\n};\n\nconst validateContentMix = (node: ElementNode, props: Props): void => {\n if (node.content.length === 0) {\n return;\n }\n\n const violated = CONTENT_MIX_RULES.find(\n (rule) => rule.kind === node.contentKind && props[rule.prop] !== undefined,\n );\n\n if (violated !== undefined) {\n throw new Error(violated.message);\n }\n};\n\nconst detachTag = (tag: Gtk.TextTag, table: Gtk.TextTagTable, name: string | null): void => {\n const previous = tagTables.get(tag);\n\n if (previous !== undefined && previous !== table) {\n previous.remove(tag);\n }\n\n if (name === null) {\n return;\n }\n\n const existing = table.lookup(name);\n\n if (existing !== null && existing !== tag) {\n table.remove(existing);\n }\n};\n\nconst ensureTag = (table: Gtk.TextTagTable, node: ElementNode): void => {\n const tag = node.object;\n\n if (!(tag instanceof Gtk.TextTag) || tagTables.get(tag) === table) {\n return;\n }\n\n const name = typeof node.props.name === \"string\" ? node.props.name : null;\n detachTag(tag, table, name);\n\n if (name === null || table.lookup(name) !== tag) {\n table.add(tag);\n }\n\n tagTables.set(tag, table);\n};\n\nconst insertTag = (build: BufferBuild, node: ElementNode): void => {\n const start = build.buffer.getCharCount();\n insertContent(build, node.content);\n const tag = node.object;\n\n if (tag instanceof Gtk.TextTag) {\n ensureTag(build.buffer.getTagTable(), node);\n build.buffer.applyTag(tag, build.buffer.getIterAtOffset(start), build.buffer.getEndIter());\n }\n};\n\nconst contentPaintable = (node: ElementNode): Gdk.Paintable | null => {\n const value = node.props[PAINTABLE_PROP];\n\n return value instanceof Gdk.Paintable ? value : null;\n};\n\nconst isContentPaintableProp = (node: ElementNode, name: string): boolean =>\n name === PAINTABLE_PROP && node.contentKind === \"anchor\";\n\nconst insertAnchor = (build: BufferBuild, node: ElementNode): void => {\n const paintable = contentPaintable(node);\n\n if (paintable !== null) {\n build.buffer.insertPaintable(build.buffer.getEndIter(), paintable);\n\n return;\n }\n\n const anchor = node.object;\n\n if (!(anchor instanceof Gtk.TextChildAnchor)) {\n return;\n }\n\n build.buffer.insertChildAnchor(build.buffer.getEndIter(), anchor);\n const child = node.content[0];\n\n if (build.view !== null && child?.kind === ELEMENT_KIND && child.object instanceof Gtk.Widget) {\n build.view.addChildAtAnchor(child.object, anchor);\n }\n};\n\nconst insertElement = (build: BufferBuild, node: ElementNode): void => {\n if (node.contentKind === \"tag\") {\n insertTag(build, node);\n } else if (node.contentKind === \"anchor\") {\n insertAnchor(build, node);\n } else {\n build.marks.push({ node, offset: build.buffer.getCharCount() });\n }\n};\n\nconst insertContent = (build: BufferBuild, nodes: ContentChild[]): void => {\n for (const child of nodes) {\n if (child.kind === TEXT_KIND) {\n build.buffer.insert(build.buffer.getEndIter(), child.text, -1);\n } else {\n insertElement(build, child);\n }\n }\n};\n\nconst placeMark = (buffer: Gtk.TextBuffer, node: ElementNode, offset: number): void => {\n const mark = node.object;\n\n if (!(mark instanceof Gtk.TextMark)) {\n return;\n }\n\n const iter = buffer.getIterAtOffset(offset);\n\n if (mark.getBuffer() === null) {\n buffer.addMark(mark, iter);\n } else {\n buffer.moveMark(mark, iter);\n }\n};\n\nconst rebuildBuffer = (node: ElementNode): void => {\n const buffer = node.object;\n\n if (node.props.text !== undefined || !(buffer instanceof Gtk.TextBuffer)) {\n return;\n }\n\n applyWrite(() => {\n buffer.setText(\"\", -1);\n const build: BufferBuild = { buffer, view: node.bufferView, marks: [] };\n insertContent(build, node.content);\n\n for (const mark of build.marks) {\n placeMark(buffer, mark.node, mark.offset);\n }\n });\n};\n\nconst rebuildLabel = (node: ElementNode): void => {\n if (node.props.label !== undefined) {\n return;\n }\n\n const label = node.object;\n\n if (!(label instanceof Gtk.Label)) {\n return;\n }\n\n label.setLabel(node.content.map((child) => (child.kind === TEXT_KIND ? child.text : \"\")).join(\"\"));\n};\n\nconst flushTextHosts = (): void => {\n drain(dirtyHosts, (host) => {\n if (host.contentKind === \"label\") {\n rebuildLabel(host);\n } else if (host.contentKind === \"buffer\") {\n rebuildBuffer(host);\n }\n });\n};\n\nconst applyEnclosingTags = (\n buffer: Gtk.TextBuffer,\n node: TextNode,\n startIter: Gtk.TextIter,\n endIter: Gtk.TextIter,\n): void => {\n for (const tagNode of enclosingTagNodes(node)) {\n ensureTag(buffer.getTagTable(), tagNode);\n\n if (tagNode.object instanceof Gtk.TextTag) {\n buffer.applyTag(tagNode.object, startIter, endIter);\n }\n }\n};\n\nconst didUpdateTextSurgically = (host: ElementNode, node: TextNode, oldText: string, newText: string): boolean => {\n const buffer = host.object;\n\n if (host.contentKind !== \"buffer\" || !(buffer instanceof Gtk.TextBuffer)) {\n return false;\n }\n\n const located = getOffset(host.content, node, 0);\n\n if (!located.found) {\n return false;\n }\n\n const start = located.offset;\n\n applyWrite(() => {\n buffer.delete(buffer.getIterAtOffset(start), buffer.getIterAtOffset(start + charLength(oldText)));\n buffer.insert(buffer.getIterAtOffset(start), newText, -1);\n });\n\n const startIter = buffer.getIterAtOffset(start);\n const endIter = buffer.getIterAtOffset(start + charLength(newText));\n applyEnclosingTags(buffer, node, startIter, endIter);\n\n return true;\n};\n\nexport {\n TEXT_PROP,\n textRestrictionError,\n bufferText,\n hasSameText,\n canAcceptText,\n isContentPaintableProp,\n markTextDirty,\n enclosingHost,\n addContent,\n removeContent,\n validateContentMix,\n flushTextHosts,\n didUpdateTextSurgically,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/reconciler/text.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGtD,OAAO,EAAE,Y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,MAAM,SAAS,GAAG,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,MAAM,CAAC,eAAe,CAAC,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;IACpE,kBAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAErD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,OAAO,EACH,SAAS,EACT,oBAAoB,EACpB,UAAU,EACV,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,aAAa,EACb,aAAa,EACb,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,uBAAuB,GAC1B,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gdk from \"@gtkx/gi/gdk\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { drain, indexBeforeOrEnd } from \"@gtkx/utils\";\nimport type { ContentChild, ContentKind, ElementNode, ParentNode, TextNode } from \"./node.js\";\nimport type { Props } from \"./registry.js\";\nimport { ELEMENT_KIND, TEXT_KIND } from \"./node.js\";\nimport { applyWrite } from \"./signals.js\";\n\ntype OffsetResult = { wasFound: boolean; offset: number };\n\ntype BufferBuild = {\n buffer: Gtk.TextBuffer;\n view: Gtk.TextView | null;\n marks: { node: ElementNode; offset: number }[];\n};\n\nconst dirtyHosts: Set<ElementNode> = new Set();\nconst tagTables: WeakMap<object, Gtk.TextTagTable> = new WeakMap();\nconst TEXT_CONTENT_KINDS: Set<string> = new Set([\"label\", \"buffer\", \"tag\"]);\nconst PAINTABLE_PROP = \"paintable\";\nconst TEXT_PROP = \"text\";\n\nconst CONTENT_MIX_RULES: { kind: ContentKind; prop: string; message: string }[] = [\n {\n kind: \"label\",\n prop: \"label\",\n message: \"<GtkLabel> cannot mix a `label` prop with text children; use one or the other\",\n },\n {\n kind: \"buffer\",\n prop: \"text\",\n message: \"<GtkTextBuffer> cannot mix a `text` prop with content children; use one or the other\",\n },\n {\n kind: \"anchor\",\n prop: PAINTABLE_PROP,\n message: \"<GtkTextChildAnchor> cannot mix a `paintable` prop with a child widget; use one or the other\",\n },\n];\n\nconst charLength = (text: string): number => text[Symbol.iterator]().toArray().length;\n\nconst bufferText = (buffer: Gtk.TextBuffer): string =>\n buffer.getText(buffer.getStartIter(), buffer.getEndIter(), false);\n\nconst currentText = (object: GObject.Object): string | null => {\n if (object instanceof Gtk.TextBuffer) {\n return bufferText(object);\n }\n\n if (object instanceof Gtk.Editable || object instanceof Gtk.EntryBuffer) {\n return object.getText();\n }\n\n return null;\n};\n\nconst hasSameText = (object: GObject.Object, prop: string, value: unknown): boolean =>\n prop === TEXT_PROP && typeof value === \"string\" && currentText(object) === value;\n\nconst contentTextLength = (node: ContentChild): number => {\n if (node.kind === TEXT_KIND) {\n return charLength(node.text);\n }\n\n if (node.contentKind === \"tag\") {\n return node.content.reduce((sum, child) => sum + contentTextLength(child), 0);\n }\n\n return node.contentKind === \"anchor\" ? 1 : 0;\n};\n\nconst isTagElement = (node: ContentChild): node is ElementNode =>\n node.kind === ELEMENT_KIND && node.contentKind === \"tag\";\n\nconst stepOffset = (node: ContentChild, target: TextNode, offset: number): OffsetResult => {\n if (node === target) {\n return { wasFound: true, offset };\n }\n\n if (isTagElement(node)) {\n return getOffset(node.content, target, offset);\n }\n\n return { wasFound: false, offset: offset + contentTextLength(node) };\n};\n\nconst getOffset = (nodes: ContentChild[], target: TextNode, start: number): OffsetResult => {\n let offset = start;\n\n for (const node of nodes) {\n const step = stepOffset(node, target, offset);\n\n if (step.wasFound) {\n return step;\n }\n\n offset = step.offset;\n }\n\n return { wasFound: false, offset };\n};\n\nconst enclosingTagNodes = (node: TextNode): ElementNode[] => {\n const nodes: ElementNode[] = [];\n let current: ParentNode | null = node.parent;\n\n while (current !== null && current.kind === ELEMENT_KIND) {\n if (current.contentKind === \"tag\") {\n nodes.push(current);\n }\n\n current = current.parent;\n }\n\n return nodes;\n};\n\nconst textRestrictionError = (text: string): Error =>\n new Error(\n \"Text strings must be rendered within a <GtkLabel> or <GtkTextBuffer> element; \" +\n `received ${JSON.stringify(text)}`,\n );\n\nconst canAcceptText = (host: ElementNode): boolean =>\n host.contentKind !== null && TEXT_CONTENT_KINDS.has(host.contentKind);\n\nconst isRootHost = (node: ElementNode): boolean => node.contentKind === \"label\" || node.contentKind === \"buffer\";\n\nconst mapElementParent = <T>(parent: ParentNode | null, map: (element: ElementNode) => T): T | null =>\n parent !== null && parent.kind === ELEMENT_KIND ? map(parent) : null;\n\nconst parentElement = (node: ElementNode): ElementNode | null => mapElementParent(node.parent, (parent) => parent);\n\nconst getRootHost = (node: ElementNode): ElementNode | null => {\n let current: ElementNode | null = node;\n\n while (current !== null) {\n if (isRootHost(current)) {\n return current;\n }\n\n current = parentElement(current);\n }\n\n return null;\n};\n\nconst markTextDirty = (host: ElementNode): void => {\n const root = getRootHost(host);\n\n if (root !== null) {\n dirtyHosts.add(root);\n }\n};\n\nconst enclosingHost = (node: TextNode): ElementNode | null => mapElementParent(node.parent, getRootHost);\n\nconst addContent = (host: ElementNode, child: ContentChild, before: ContentChild | null): void => {\n const content = host.content;\n const existing = content.indexOf(child);\n\n if (existing !== -1) {\n content.splice(existing, 1);\n }\n\n content.splice(\n indexBeforeOrEnd(content, before, (item, target) => item === target),\n 0,\n child,\n );\n\n child.parent = host;\n markTextDirty(host);\n};\n\nconst removeContent = (host: ElementNode, child: ContentChild): void => {\n const index = host.content.indexOf(child);\n\n if (index !== -1) {\n host.content.splice(index, 1);\n }\n\n markTextDirty(host);\n};\n\nconst validateContentMix = (node: ElementNode, props: Props): void => {\n if (node.content.length === 0) {\n return;\n }\n\n const violated = CONTENT_MIX_RULES.find(\n (rule) => rule.kind === node.contentKind && props[rule.prop] !== undefined,\n );\n\n if (violated !== undefined) {\n throw new Error(violated.message);\n }\n};\n\nconst detachTag = (tag: Gtk.TextTag, table: Gtk.TextTagTable, name: string | null): void => {\n const previous = tagTables.get(tag);\n\n if (previous !== undefined && previous !== table) {\n previous.remove(tag);\n }\n\n if (name === null) {\n return;\n }\n\n const existing = table.lookup(name);\n\n if (existing !== null && existing !== tag) {\n table.remove(existing);\n }\n};\n\nconst ensureTag = (table: Gtk.TextTagTable, node: ElementNode): void => {\n const tag = node.object;\n\n if (!(tag instanceof Gtk.TextTag) || tagTables.get(tag) === table) {\n return;\n }\n\n const name = typeof node.props.name === \"string\" ? node.props.name : null;\n detachTag(tag, table, name);\n\n if (name === null || table.lookup(name) !== tag) {\n table.add(tag);\n }\n\n tagTables.set(tag, table);\n};\n\nconst insertTag = (build: BufferBuild, node: ElementNode): void => {\n const start = build.buffer.getCharCount();\n insertContent(build, node.content);\n const tag = node.object;\n\n if (tag instanceof Gtk.TextTag) {\n ensureTag(build.buffer.getTagTable(), node);\n build.buffer.applyTag(tag, build.buffer.getIterAtOffset(start), build.buffer.getEndIter());\n }\n};\n\nconst contentPaintable = (node: ElementNode): Gdk.Paintable | null => {\n const value = node.props[PAINTABLE_PROP];\n\n return value instanceof Gdk.Paintable ? value : null;\n};\n\nconst isContentPaintableProp = (node: ElementNode, name: string): boolean =>\n name === PAINTABLE_PROP && node.contentKind === \"anchor\";\n\nconst insertAnchor = (build: BufferBuild, node: ElementNode): void => {\n const paintable = contentPaintable(node);\n\n if (paintable !== null) {\n build.buffer.insertPaintable(build.buffer.getEndIter(), paintable);\n\n return;\n }\n\n const anchor = node.object;\n\n if (!(anchor instanceof Gtk.TextChildAnchor)) {\n return;\n }\n\n build.buffer.insertChildAnchor(build.buffer.getEndIter(), anchor);\n const child = node.content[0];\n\n if (build.view !== null && child?.kind === ELEMENT_KIND && child.object instanceof Gtk.Widget) {\n build.view.addChildAtAnchor(child.object, anchor);\n }\n};\n\nconst insertElement = (build: BufferBuild, node: ElementNode): void => {\n if (node.contentKind === \"tag\") {\n insertTag(build, node);\n } else if (node.contentKind === \"anchor\") {\n insertAnchor(build, node);\n } else {\n build.marks.push({ node, offset: build.buffer.getCharCount() });\n }\n};\n\nconst insertContent = (build: BufferBuild, nodes: ContentChild[]): void => {\n for (const child of nodes) {\n if (child.kind === TEXT_KIND) {\n build.buffer.insert(build.buffer.getEndIter(), child.text, -1);\n } else {\n insertElement(build, child);\n }\n }\n};\n\nconst placeMark = (buffer: Gtk.TextBuffer, node: ElementNode, offset: number): void => {\n const mark = node.object;\n\n if (!(mark instanceof Gtk.TextMark)) {\n return;\n }\n\n const iter = buffer.getIterAtOffset(offset);\n\n if (mark.getBuffer() === null) {\n buffer.addMark(mark, iter);\n } else {\n buffer.moveMark(mark, iter);\n }\n};\n\nconst rebuildBuffer = (node: ElementNode): void => {\n const buffer = node.object;\n\n if (node.props.text !== undefined || !(buffer instanceof Gtk.TextBuffer)) {\n return;\n }\n\n applyWrite(() => {\n buffer.setText(\"\", -1);\n const build: BufferBuild = { buffer, view: node.bufferView, marks: [] };\n insertContent(build, node.content);\n\n for (const mark of build.marks) {\n placeMark(buffer, mark.node, mark.offset);\n }\n });\n};\n\nconst rebuildLabel = (node: ElementNode): void => {\n if (node.props.label !== undefined) {\n return;\n }\n\n const label = node.object;\n\n if (!(label instanceof Gtk.Label)) {\n return;\n }\n\n label.setLabel(node.content.map((child) => (child.kind === TEXT_KIND ? child.text : \"\")).join(\"\"));\n};\n\nconst flushTextHosts = (): void => {\n drain(dirtyHosts, (host) => {\n if (host.contentKind === \"label\") {\n rebuildLabel(host);\n } else if (host.contentKind === \"buffer\") {\n rebuildBuffer(host);\n }\n });\n};\n\nconst applyEnclosingTags = (\n buffer: Gtk.TextBuffer,\n node: TextNode,\n startIter: Gtk.TextIter,\n endIter: Gtk.TextIter,\n): void => {\n for (const tagNode of enclosingTagNodes(node)) {\n ensureTag(buffer.getTagTable(), tagNode);\n\n if (tagNode.object instanceof Gtk.TextTag) {\n buffer.applyTag(tagNode.object, startIter, endIter);\n }\n }\n};\n\nconst didUpdateTextSurgically = (host: ElementNode, node: TextNode, oldText: string, newText: string): boolean => {\n const buffer = host.object;\n\n if (host.contentKind !== \"buffer\" || !(buffer instanceof Gtk.TextBuffer)) {\n return false;\n }\n\n const located = getOffset(host.content, node, 0);\n\n if (!located.wasFound) {\n return false;\n }\n\n const start = located.offset;\n\n applyWrite(() => {\n buffer.delete(buffer.getIterAtOffset(start), buffer.getIterAtOffset(start + charLength(oldText)));\n buffer.insert(buffer.getIterAtOffset(start), newText, -1);\n });\n\n const startIter = buffer.getIterAtOffset(start);\n const endIter = buffer.getIterAtOffset(start + charLength(newText));\n applyEnclosingTags(buffer, node, startIter, endIter);\n\n return true;\n};\n\nexport {\n TEXT_PROP,\n textRestrictionError,\n bufferText,\n hasSameText,\n canAcceptText,\n isContentPaintableProp,\n markTextDirty,\n enclosingHost,\n addContent,\n removeContent,\n validateContentMix,\n flushTextHosts,\n didUpdateTextSurgically,\n};\n"]}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
declare const setAccessibleMetadata: (widget: object, name: string, value: unknown) => void;
|
|
2
2
|
declare const deleteAccessibleMetadata: (widget: object, name: string) => void;
|
|
3
|
-
/**
|
|
4
|
-
* Returns the last value applied for an accessible prop on a widget, or null when none was applied.
|
|
5
|
-
*
|
|
6
|
-
* @param widget The widget to read from.
|
|
7
|
-
* @param name The accessible prop name.
|
|
8
|
-
* @returns The last applied value, or null.
|
|
9
|
-
*/
|
|
10
3
|
declare const getAccessibleMetadata: (widget: object, name: string) => unknown;
|
|
11
4
|
export { setAccessibleMetadata, deleteAccessibleMetadata, getAccessibleMetadata };
|
|
12
5
|
//# sourceMappingURL=accessible-metadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessible-metadata.d.ts","sourceRoot":"","sources":["../../src/utils/accessible-metadata.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,qBAAqB,GAAI,QAAQ,MAAM,EAAE,MAAM,MAAM,EAAE,OAAO,OAAO,KAAG,IAS7E,CAAC;AAEF,QAAA,MAAM,wBAAwB,GAAI,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,IAEhE,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"accessible-metadata.d.ts","sourceRoot":"","sources":["../../src/utils/accessible-metadata.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,qBAAqB,GAAI,QAAQ,MAAM,EAAE,MAAM,MAAM,EAAE,OAAO,OAAO,KAAG,IAS7E,CAAC;AAEF,QAAA,MAAM,wBAAwB,GAAI,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,IAEhE,CAAC;AAEF,QAAA,MAAM,qBAAqB,GAAI,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,OAI7D,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -10,13 +10,6 @@ const setAccessibleMetadata = (widget, name, value) => {
|
|
|
10
10
|
const deleteAccessibleMetadata = (widget, name) => {
|
|
11
11
|
metadataStore.get(widget)?.delete(name);
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
14
|
-
* Returns the last value applied for an accessible prop on a widget, or null when none was applied.
|
|
15
|
-
*
|
|
16
|
-
* @param widget The widget to read from.
|
|
17
|
-
* @param name The accessible prop name.
|
|
18
|
-
* @returns The last applied value, or null.
|
|
19
|
-
*/
|
|
20
13
|
const getAccessibleMetadata = (widget, name) => {
|
|
21
14
|
const value = metadataStore.get(widget)?.get(name);
|
|
22
15
|
return value === undefined ? null : value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessible-metadata.js","sourceRoot":"","sources":["../../src/utils/accessible-metadata.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAA0C,IAAI,OAAO,EAAE,CAAC;AAE3E,MAAM,qBAAqB,GAAG,CAAC,MAAc,EAAE,IAAY,EAAE,KAAc,EAAQ,EAAE;IACjF,IAAI,OAAO,GAAG,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAExC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;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CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["const metadataStore: WeakMap<object, Map<string, unknown>> = new WeakMap();\n\nconst setAccessibleMetadata = (widget: object, name: string, value: unknown): void => {\n let entries = metadataStore.get(widget);\n\n if (entries === undefined) {\n entries = new Map();\n metadataStore.set(widget, entries);\n }\n\n entries.set(name, value);\n};\n\nconst deleteAccessibleMetadata = (widget: object, name: string): void => {\n metadataStore.get(widget)?.delete(name);\n};\n\nconst getAccessibleMetadata = (widget: object, name: string): unknown => {\n const value = metadataStore.get(widget)?.get(name);\n\n return value === undefined ? null : value;\n};\n\nexport { setAccessibleMetadata, deleteAccessibleMetadata, getAccessibleMetadata };\n"]}
|