@gtkx/react 1.4.0 → 1.6.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 +1 -1
- package/dist/adw/element-behaviors.js +35 -120
- package/dist/adw/element-behaviors.js.map +1 -1
- package/dist/components/element.d.ts +6 -1
- package/dist/components/element.d.ts.map +1 -1
- package/dist/components/element.js +6 -3
- package/dist/components/element.js.map +1 -1
- package/dist/element-behaviors.js +29 -124
- package/dist/element-behaviors.js.map +1 -1
- package/dist/reconciler/behaviors.d.ts +27 -8
- package/dist/reconciler/behaviors.d.ts.map +1 -1
- package/dist/reconciler/behaviors.js +60 -31
- package/dist/reconciler/behaviors.js.map +1 -1
- package/dist/reconciler/instance.d.ts.map +1 -1
- package/dist/reconciler/instance.js +5 -4
- package/dist/reconciler/instance.js.map +1 -1
- package/dist/reconciler/metadata.d.ts.map +1 -1
- package/dist/reconciler/metadata.js +17 -3
- package/dist/reconciler/metadata.js.map +1 -1
- package/package.json +5 -5
- package/src/adw/element-behaviors.ts +40 -177
- package/src/components/element.tsx +11 -3
- package/src/element-behaviors.ts +35 -175
- package/src/reconciler/behaviors.ts +114 -56
- package/src/reconciler/instance.ts +5 -4
- package/src/reconciler/metadata.ts +25 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
|
-
import {
|
|
2
|
+
import { TYPE_INVALID, typeFromName, typeIsA } from "@gtkx/runtime";
|
|
3
|
+
import { getExactWrapperClass } from "@gtkx/runtime/internal";
|
|
3
4
|
import { getOrInsert, pickBy } from "@gtkx/utils";
|
|
4
5
|
import type { Props } from "./registry.js";
|
|
5
6
|
import { type TypeInfo, typeInfoFor } from "./metadata.js";
|
|
@@ -57,8 +58,8 @@ const constructInput = (info: TypeInfo, props: Props): Props =>
|
|
|
57
58
|
(info.constructOnly.has(name) || info.construct.has(name)),
|
|
58
59
|
);
|
|
59
60
|
|
|
60
|
-
const instantiate = (type: bigint, input: Props): GObject.Object => {
|
|
61
|
-
const cls =
|
|
61
|
+
const instantiate = (typeName: string, type: bigint, input: Props): GObject.Object => {
|
|
62
|
+
const cls = getExactWrapperClass(type, typeName) as WidgetConstructor;
|
|
62
63
|
|
|
63
64
|
return new cls(input);
|
|
64
65
|
};
|
|
@@ -66,7 +67,7 @@ const instantiate = (type: bigint, input: Props): GObject.Object => {
|
|
|
66
67
|
const createObject = (typeName: string, type: bigint, input: Props): GObject.Object => {
|
|
67
68
|
const create = ELEMENTS[typeName]?.behaviors?.find((behavior) => behavior.create !== undefined)?.create;
|
|
68
69
|
|
|
69
|
-
return create === undefined ? instantiate(type, input) : create(input);
|
|
70
|
+
return create === undefined ? instantiate(typeName, type, input) : create(input);
|
|
70
71
|
};
|
|
71
72
|
|
|
72
73
|
const resolveElementNode = (typeName: string, props: Props, dispatch: Dispatch): ElementNode | LazyNode => {
|
|
@@ -9,6 +9,11 @@ import {
|
|
|
9
9
|
typeName,
|
|
10
10
|
typeParent,
|
|
11
11
|
} from "@gtkx/runtime";
|
|
12
|
+
import {
|
|
13
|
+
elementMetadataVersion,
|
|
14
|
+
registeredElementProperties,
|
|
15
|
+
registeredElementSignals,
|
|
16
|
+
} from "@gtkx/runtime/internal";
|
|
12
17
|
import { getOrInsert } from "@gtkx/utils";
|
|
13
18
|
import { properties, type PropertyEntry, signals, userEventSignals } from "virtual:gtkx-config";
|
|
14
19
|
import { deferredProps, type ElementBehavior, ELEMENTS } from "./registry.js";
|
|
@@ -36,6 +41,19 @@ const FLAGS = 1;
|
|
|
36
41
|
const DEFAULT_VALUE = 2;
|
|
37
42
|
const ancestryCache: Map<string, string[]> = new Map();
|
|
38
43
|
const typeInfoCache: Map<string, TypeInfo> = new Map();
|
|
44
|
+
const metadataCacheState = { seenVersion: elementMetadataVersion() };
|
|
45
|
+
|
|
46
|
+
const dropStaleCaches = (): void => {
|
|
47
|
+
const current = elementMetadataVersion();
|
|
48
|
+
|
|
49
|
+
if (metadataCacheState.seenVersion === current) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
metadataCacheState.seenVersion = current;
|
|
54
|
+
ancestryCache.clear();
|
|
55
|
+
typeInfoCache.clear();
|
|
56
|
+
};
|
|
39
57
|
|
|
40
58
|
const addAncestor = (names: string[], seen: Set<string>, name: string | null): void => {
|
|
41
59
|
if (name === null || seen.has(name)) {
|
|
@@ -75,7 +93,7 @@ const addAll = <T>(target: Set<T>, source: Iterable<T> | undefined): void => {
|
|
|
75
93
|
};
|
|
76
94
|
|
|
77
95
|
const accumulateAncestor = (info: TypeInfo, ancestor: string): void => {
|
|
78
|
-
Object.assign(info.signals, signals[ancestor] ?? {});
|
|
96
|
+
Object.assign(info.signals, registeredElementSignals[ancestor] ?? signals[ancestor] ?? {});
|
|
79
97
|
addAll(info.userEventSignals, userEventSignals[ancestor]);
|
|
80
98
|
info.behaviors.push(...(ELEMENTS[ancestor]?.behaviors ?? []));
|
|
81
99
|
};
|
|
@@ -141,7 +159,7 @@ const buildTypeInfo = (name: string): TypeInfo => {
|
|
|
141
159
|
info.isLazy = chain.some((ancestor) => ELEMENTS[ancestor]?.isLazy === true);
|
|
142
160
|
|
|
143
161
|
for (const ancestor of chain.toReversed()) {
|
|
144
|
-
Object.assign(info.properties, properties[ancestor] ?? {});
|
|
162
|
+
Object.assign(info.properties, registeredElementProperties[ancestor] ?? properties[ancestor] ?? {});
|
|
145
163
|
}
|
|
146
164
|
|
|
147
165
|
resolveProperties(info);
|
|
@@ -149,7 +167,11 @@ const buildTypeInfo = (name: string): TypeInfo => {
|
|
|
149
167
|
return info;
|
|
150
168
|
};
|
|
151
169
|
|
|
152
|
-
const typeInfoFor = (name: string): TypeInfo =>
|
|
170
|
+
const typeInfoFor = (name: string): TypeInfo => {
|
|
171
|
+
dropStaleCaches();
|
|
172
|
+
|
|
173
|
+
return getOrInsert(typeInfoCache, name, buildTypeInfo);
|
|
174
|
+
};
|
|
153
175
|
|
|
154
176
|
const getTypeInfo = (object: GObject.Object): TypeInfo | undefined => {
|
|
155
177
|
const name = typeName(getClassType(object.constructor as AnyClass));
|