@reactunity/renderer 0.14.1 → 0.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/helpers/dictionary-watcher.js +17 -7
- package/dist/src/helpers/hooks/use-watchable.js +12 -11
- package/dist/src/models/generated/react.d.ts +51 -0
- package/dist/src/models/generated/react.js +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import { createContext, createElement, useContext, useMemo,
|
|
12
|
+
import { createContext, createElement, useContext, useMemo, useState } from 'react';
|
|
13
13
|
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
14
14
|
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector';
|
|
15
15
|
/**
|
|
@@ -26,14 +26,13 @@ export function createDictionaryWatcher(dictionary, displayName) {
|
|
|
26
26
|
return {
|
|
27
27
|
subscribe: function (onStoreChange) {
|
|
28
28
|
snapshot = (__assign({}, dictionary));
|
|
29
|
-
var remove = dictionary === null || dictionary === void 0 ? void 0 : dictionary.AddListener(function (
|
|
29
|
+
var remove = dictionary === null || dictionary === void 0 ? void 0 : dictionary.AddListener(function () {
|
|
30
30
|
var prev = snapshot;
|
|
31
31
|
snapshot = (__assign({}, dictionary));
|
|
32
32
|
if (!fields)
|
|
33
33
|
onStoreChange();
|
|
34
34
|
else {
|
|
35
|
-
for (var
|
|
36
|
-
var field = fields_1[_i];
|
|
35
|
+
for (var it = fields.values(), field = null; field = it.next().value;) {
|
|
37
36
|
if (isEqual ? !isEqual(prev[field], snapshot[field]) : (prev[field] !== snapshot[field])) {
|
|
38
37
|
onStoreChange();
|
|
39
38
|
break;
|
|
@@ -70,14 +69,25 @@ export function createDictionaryWatcher(dictionary, displayName) {
|
|
|
70
69
|
}
|
|
71
70
|
function useValue(subscribeToAllFields, fieldEqual) {
|
|
72
71
|
if (subscribeToAllFields === void 0) { subscribeToAllFields = false; }
|
|
73
|
-
var fields =
|
|
74
|
-
var
|
|
72
|
+
var fields = useMemo(function () { return new Set(); }, []);
|
|
73
|
+
var _a = useState(false), allFieldsSubscribed = _a[0], setAllFieldsSubscribed = _a[1];
|
|
74
|
+
subscribeToAllFields || (subscribeToAllFields = allFieldsSubscribed);
|
|
75
|
+
var subscriber = useMemo(function () { return subscribeToAllFields ? defaultSubscriber : createSubscriber(fields, fieldEqual); }, [subscribeToAllFields, fieldEqual]);
|
|
75
76
|
var value = useSyncExternalStore(subscriber.subscribe, subscriber.getSnapshot, subscriber.getSnapshot);
|
|
76
77
|
var proxy = new Proxy(value, {
|
|
77
78
|
get: function (target, p, receiver) {
|
|
78
|
-
fields.
|
|
79
|
+
fields.add(p);
|
|
79
80
|
return value[p];
|
|
80
81
|
},
|
|
82
|
+
ownKeys: function (target) {
|
|
83
|
+
if (!allFieldsSubscribed)
|
|
84
|
+
setAllFieldsSubscribed(true);
|
|
85
|
+
return Reflect.ownKeys(target);
|
|
86
|
+
},
|
|
87
|
+
getOwnPropertyDescriptor: function (target, p) {
|
|
88
|
+
fields.add(p);
|
|
89
|
+
return __assign(__assign({}, Reflect.getOwnPropertyDescriptor(target, p)), { value: value[p] });
|
|
90
|
+
}
|
|
81
91
|
});
|
|
82
92
|
return proxy;
|
|
83
93
|
}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
3
|
-
|
|
3
|
+
function createSubscriber(obj, isEqual) {
|
|
4
4
|
var isWatchable = obj && typeof obj === 'object' && ('Value' in obj);
|
|
5
5
|
var snapshot = isWatchable ? obj.Value : undefined;
|
|
6
6
|
return {
|
|
7
7
|
subscribe: function (onStoreChange) {
|
|
8
8
|
snapshot = isWatchable ? obj.Value : undefined;
|
|
9
|
-
var remove =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
var remove = isWatchable && typeof obj.AddListener === 'function' &&
|
|
10
|
+
(obj === null || obj === void 0 ? void 0 : obj.AddListener(function () {
|
|
11
|
+
var prev = snapshot;
|
|
12
|
+
snapshot = isWatchable ? obj.Value : undefined;
|
|
13
|
+
if (typeof isEqual !== 'function' || !isEqual(prev, snapshot)) {
|
|
14
|
+
onStoreChange();
|
|
15
|
+
}
|
|
16
|
+
}));
|
|
17
|
+
if (isWatchable && typeof remove !== 'function')
|
|
17
18
|
console.warn("The watchable does not provide a change listener");
|
|
18
19
|
return function () { return remove === null || remove === void 0 ? void 0 : remove(); };
|
|
19
20
|
},
|
|
20
21
|
getSnapshot: function () { return snapshot; },
|
|
21
22
|
};
|
|
22
|
-
}
|
|
23
|
+
}
|
|
23
24
|
export function useWatchable(obj, isEqual) {
|
|
24
25
|
var sb = useMemo(function () { return createSubscriber(obj, isEqual); }, [obj, isEqual]);
|
|
25
|
-
return useSyncExternalStore(sb.subscribe, sb.getSnapshot);
|
|
26
|
+
return useSyncExternalStore(sb.subscribe, sb.getSnapshot, sb.getSnapshot);
|
|
26
27
|
}
|
|
@@ -2075,6 +2075,7 @@ export declare namespace ReactUnity {
|
|
|
2075
2075
|
Name: string;
|
|
2076
2076
|
Count: number;
|
|
2077
2077
|
IsReadOnly: boolean;
|
|
2078
|
+
Value: System.Collections.Generic.HashSet<string>;
|
|
2078
2079
|
ToString(): string;
|
|
2079
2080
|
GetArray(): string[];
|
|
2080
2081
|
Add(item: string): boolean;
|
|
@@ -2100,6 +2101,8 @@ export declare namespace ReactUnity {
|
|
|
2100
2101
|
SetEquals(other: System.Collections.Generic.IEnumerable<string>): boolean;
|
|
2101
2102
|
SymmetricExceptWith(other: System.Collections.Generic.IEnumerable<string>): void;
|
|
2102
2103
|
UnionWith(other: System.Collections.Generic.IEnumerable<string>): void;
|
|
2104
|
+
Change(): void;
|
|
2105
|
+
AddListener(cb: any): (() => void);
|
|
2103
2106
|
Equals(obj: any): boolean;
|
|
2104
2107
|
GetHashCode(): number;
|
|
2105
2108
|
GetType(): System.Type;
|
|
@@ -2153,6 +2156,7 @@ export declare namespace ReactUnity {
|
|
|
2153
2156
|
Values: System.Collections.Generic.ICollection<any>;
|
|
2154
2157
|
Count: number;
|
|
2155
2158
|
IsReadOnly: boolean;
|
|
2159
|
+
Value: ReactUnity.Helpers.WatchableDictionary<string, any>;
|
|
2156
2160
|
static BindSerializableDictionary(dict: ReactUnity.Helpers.SerializableDictionary, dispatcher: ReactUnity.Scheduling.IDispatcher, isSerializing: boolean): ReactUnity.Helpers.GlobalRecord;
|
|
2157
2161
|
BindSerializableDictionary(dict: ReactUnity.Helpers.SerializableDictionary, isSerializing: boolean): void;
|
|
2158
2162
|
UpdateStringObjectDictionary(dict: ReactUnity.Helpers.WatchableRecord<any>, isSerializing: boolean): void;
|
|
@@ -2171,6 +2175,7 @@ export declare namespace ReactUnity {
|
|
|
2171
2175
|
AddListener(listener: ((arg1: string, arg2: any, arg3: ReactUnity.Helpers.WatchableDictionary<string, any>) => void)): (() => void);
|
|
2172
2176
|
GetValueOrDefault(key: string): any;
|
|
2173
2177
|
Dispose(): void;
|
|
2178
|
+
Change(): void;
|
|
2174
2179
|
Equals(obj: any): boolean;
|
|
2175
2180
|
GetHashCode(): number;
|
|
2176
2181
|
GetType(): System.Type;
|
|
@@ -2230,6 +2235,7 @@ export declare namespace ReactUnity {
|
|
|
2230
2235
|
Values: System.Collections.Generic.ICollection<any>;
|
|
2231
2236
|
Count: number;
|
|
2232
2237
|
IsReadOnly: boolean;
|
|
2238
|
+
Value: ReactUnity.Helpers.WatchableDictionary<string, any>;
|
|
2233
2239
|
OnAfterDeserialize(): void;
|
|
2234
2240
|
OnBeforeSerialize(): void;
|
|
2235
2241
|
AddReserializeListener(callback: ((obj: ReactUnity.Helpers.SerializableDictionary) => void)): (() => void);
|
|
@@ -2248,6 +2254,7 @@ export declare namespace ReactUnity {
|
|
|
2248
2254
|
AddListener(listener: ((arg1: string, arg2: any, arg3: ReactUnity.Helpers.WatchableDictionary<string, any>) => void)): (() => void);
|
|
2249
2255
|
GetValueOrDefault(key: string): any;
|
|
2250
2256
|
Dispose(): void;
|
|
2257
|
+
Change(): void;
|
|
2251
2258
|
Equals(obj: any): boolean;
|
|
2252
2259
|
GetHashCode(): number;
|
|
2253
2260
|
GetType(): System.Type;
|
|
@@ -2269,6 +2276,32 @@ export declare namespace ReactUnity {
|
|
|
2269
2276
|
GetType(): System.Type;
|
|
2270
2277
|
ToString(): string;
|
|
2271
2278
|
}
|
|
2279
|
+
class WatchableList<T = any> {
|
|
2280
|
+
constructor();
|
|
2281
|
+
[key: string]: any;
|
|
2282
|
+
Count: number;
|
|
2283
|
+
IsReadOnly: boolean;
|
|
2284
|
+
Value: T[];
|
|
2285
|
+
GetArray(): T[];
|
|
2286
|
+
Add(item: T): void;
|
|
2287
|
+
AddWithoutNotify(item: T): void;
|
|
2288
|
+
Remove(item: T): boolean;
|
|
2289
|
+
RemoveWithoutNotify(item: T): boolean;
|
|
2290
|
+
Clear(): void;
|
|
2291
|
+
ClearWithoutNotify(): void;
|
|
2292
|
+
Contains(item: T): boolean;
|
|
2293
|
+
CopyTo(array: T[], arrayIndex: number): void;
|
|
2294
|
+
GetEnumerator(): System.Collections.Generic.IEnumerator<T>;
|
|
2295
|
+
Change(): void;
|
|
2296
|
+
AddListener(cb: any): (() => void);
|
|
2297
|
+
IndexOf(item: T): number;
|
|
2298
|
+
Insert(index: number, item: T): void;
|
|
2299
|
+
RemoveAt(index: number): void;
|
|
2300
|
+
Equals(obj: any): boolean;
|
|
2301
|
+
GetHashCode(): number;
|
|
2302
|
+
GetType(): System.Type;
|
|
2303
|
+
ToString(): string;
|
|
2304
|
+
}
|
|
2272
2305
|
class WatchableDictionary<TKey = any, T = any> {
|
|
2273
2306
|
constructor();
|
|
2274
2307
|
constructor(dict: System.Collections.Generic.IDictionary<TKey, T>);
|
|
@@ -2277,6 +2310,7 @@ export declare namespace ReactUnity {
|
|
|
2277
2310
|
Values: System.Collections.Generic.ICollection<T>;
|
|
2278
2311
|
Count: number;
|
|
2279
2312
|
IsReadOnly: boolean;
|
|
2313
|
+
Value: ReactUnity.Helpers.WatchableDictionary<TKey, T>;
|
|
2280
2314
|
Set(key: TKey, value: T): void;
|
|
2281
2315
|
SetWithoutNotify(key: TKey, value: T): void;
|
|
2282
2316
|
Add(key: TKey, value: T): void;
|
|
@@ -2291,6 +2325,7 @@ export declare namespace ReactUnity {
|
|
|
2291
2325
|
AddListener(listener: ((arg1: TKey, arg2: T, arg3: ReactUnity.Helpers.WatchableDictionary<TKey, T>) => void)): (() => void);
|
|
2292
2326
|
GetValueOrDefault(key: TKey): T;
|
|
2293
2327
|
Dispose(): void;
|
|
2328
|
+
Change(): void;
|
|
2294
2329
|
Equals(obj: any): boolean;
|
|
2295
2330
|
GetHashCode(): number;
|
|
2296
2331
|
GetType(): System.Type;
|
|
@@ -2302,6 +2337,7 @@ export declare namespace ReactUnity {
|
|
|
2302
2337
|
Values: System.Collections.Generic.ICollection<T>;
|
|
2303
2338
|
Count: number;
|
|
2304
2339
|
IsReadOnly: boolean;
|
|
2340
|
+
Value: ReactUnity.Helpers.WatchableDictionary<TKey, T>;
|
|
2305
2341
|
Add(key: string, value: any): void;
|
|
2306
2342
|
Add(item: System.Collections.Generic.KeyValuePair<string, any>): void;
|
|
2307
2343
|
Contains(item: System.Collections.Generic.KeyValuePair<string, any>): boolean;
|
|
@@ -2326,6 +2362,7 @@ export declare namespace ReactUnity {
|
|
|
2326
2362
|
AddListener(listener: ((arg1: TKey, arg2: T, arg3: ReactUnity.Helpers.WatchableDictionary<TKey, T>) => void)): (() => void);
|
|
2327
2363
|
GetValueOrDefault(key: TKey): T;
|
|
2328
2364
|
Dispose(): void;
|
|
2365
|
+
Change(): void;
|
|
2329
2366
|
Equals(obj: any): boolean;
|
|
2330
2367
|
GetHashCode(): number;
|
|
2331
2368
|
GetType(): System.Type;
|
|
@@ -2337,6 +2374,7 @@ export declare namespace ReactUnity {
|
|
|
2337
2374
|
Values: System.Collections.Generic.ICollection<T>;
|
|
2338
2375
|
Count: number;
|
|
2339
2376
|
IsReadOnly: boolean;
|
|
2377
|
+
Value: ReactUnity.Helpers.WatchableDictionary<TKey, T>;
|
|
2340
2378
|
OnExposedToScriptCode(engine: any): void;
|
|
2341
2379
|
Add(key: string, value: any): void;
|
|
2342
2380
|
Add(item: System.Collections.Generic.KeyValuePair<string, any>): void;
|
|
@@ -2362,6 +2400,7 @@ export declare namespace ReactUnity {
|
|
|
2362
2400
|
AddListener(listener: ((arg1: TKey, arg2: T, arg3: ReactUnity.Helpers.WatchableDictionary<TKey, T>) => void)): (() => void);
|
|
2363
2401
|
GetValueOrDefault(key: TKey): T;
|
|
2364
2402
|
Dispose(): void;
|
|
2403
|
+
Change(): void;
|
|
2365
2404
|
Equals(obj: any): boolean;
|
|
2366
2405
|
GetHashCode(): number;
|
|
2367
2406
|
GetType(): System.Type;
|
|
@@ -2374,6 +2413,7 @@ export declare namespace ReactUnity {
|
|
|
2374
2413
|
Values: System.Collections.Generic.ICollection<T>;
|
|
2375
2414
|
Count: number;
|
|
2376
2415
|
IsReadOnly: boolean;
|
|
2416
|
+
Value: ReactUnity.Helpers.WatchableDictionary<string, T>;
|
|
2377
2417
|
Set(key: string, value: T): void;
|
|
2378
2418
|
SetWithoutNotify(key: string, value: T): void;
|
|
2379
2419
|
Add(key: string, value: T): void;
|
|
@@ -2388,6 +2428,7 @@ export declare namespace ReactUnity {
|
|
|
2388
2428
|
AddListener(listener: ((arg1: string, arg2: T, arg3: ReactUnity.Helpers.WatchableDictionary<string, T>) => void)): (() => void);
|
|
2389
2429
|
GetValueOrDefault(key: string): T;
|
|
2390
2430
|
Dispose(): void;
|
|
2431
|
+
Change(): void;
|
|
2391
2432
|
Equals(obj: any): boolean;
|
|
2392
2433
|
GetHashCode(): number;
|
|
2393
2434
|
GetType(): System.Type;
|
|
@@ -2400,6 +2441,7 @@ export declare namespace ReactUnity {
|
|
|
2400
2441
|
Values: System.Collections.Generic.ICollection<any>;
|
|
2401
2442
|
Count: number;
|
|
2402
2443
|
IsReadOnly: boolean;
|
|
2444
|
+
Value: ReactUnity.Helpers.WatchableDictionary<string, any>;
|
|
2403
2445
|
OnExposedToScriptCode(engine: any): void;
|
|
2404
2446
|
Set(key: string, value: any): void;
|
|
2405
2447
|
SetWithoutNotify(key: string, value: any): void;
|
|
@@ -2415,6 +2457,7 @@ export declare namespace ReactUnity {
|
|
|
2415
2457
|
AddListener(listener: ((arg1: string, arg2: any, arg3: ReactUnity.Helpers.WatchableDictionary<string, any>) => void)): (() => void);
|
|
2416
2458
|
GetValueOrDefault(key: string): any;
|
|
2417
2459
|
Dispose(): void;
|
|
2460
|
+
Change(): void;
|
|
2418
2461
|
Equals(obj: any): boolean;
|
|
2419
2462
|
GetHashCode(): number;
|
|
2420
2463
|
GetType(): System.Type;
|
|
@@ -2424,6 +2467,7 @@ export declare namespace ReactUnity {
|
|
|
2424
2467
|
constructor();
|
|
2425
2468
|
Count: number;
|
|
2426
2469
|
IsReadOnly: boolean;
|
|
2470
|
+
Value: System.Collections.Generic.HashSet<T>;
|
|
2427
2471
|
GetArray(): T[];
|
|
2428
2472
|
Add(item: T): boolean;
|
|
2429
2473
|
Toggle(item: T): boolean;
|
|
@@ -2448,6 +2492,8 @@ export declare namespace ReactUnity {
|
|
|
2448
2492
|
SetEquals(other: System.Collections.Generic.IEnumerable<T>): boolean;
|
|
2449
2493
|
SymmetricExceptWith(other: System.Collections.Generic.IEnumerable<T>): void;
|
|
2450
2494
|
UnionWith(other: System.Collections.Generic.IEnumerable<T>): void;
|
|
2495
|
+
Change(): void;
|
|
2496
|
+
AddListener(cb: any): (() => void);
|
|
2451
2497
|
Equals(obj: any): boolean;
|
|
2452
2498
|
GetHashCode(): number;
|
|
2453
2499
|
GetType(): System.Type;
|
|
@@ -3777,6 +3823,7 @@ export declare namespace ReactUnity {
|
|
|
3777
3823
|
Values: System.Collections.Generic.ICollection<ReactUnity.Styling.CursorPair>;
|
|
3778
3824
|
Count: number;
|
|
3779
3825
|
IsReadOnly: boolean;
|
|
3826
|
+
Value: ReactUnity.Helpers.WatchableDictionary<string, ReactUnity.Styling.CursorPair>;
|
|
3780
3827
|
OnAfterDeserialize(): void;
|
|
3781
3828
|
OnBeforeSerialize(): void;
|
|
3782
3829
|
Set(key: string, value: ReactUnity.Styling.CursorPair): void;
|
|
@@ -3793,6 +3840,7 @@ export declare namespace ReactUnity {
|
|
|
3793
3840
|
AddListener(listener: ((arg1: string, arg2: ReactUnity.Styling.CursorPair, arg3: ReactUnity.Helpers.WatchableDictionary<string, ReactUnity.Styling.CursorPair>) => void)): (() => void);
|
|
3794
3841
|
GetValueOrDefault(key: string): ReactUnity.Styling.CursorPair;
|
|
3795
3842
|
Dispose(): void;
|
|
3843
|
+
Change(): void;
|
|
3796
3844
|
Equals(obj: any): boolean;
|
|
3797
3845
|
GetHashCode(): number;
|
|
3798
3846
|
GetType(): System.Type;
|
|
@@ -3821,6 +3869,7 @@ export declare namespace ReactUnity {
|
|
|
3821
3869
|
Values: System.Collections.Generic.ICollection<any>;
|
|
3822
3870
|
Count: number;
|
|
3823
3871
|
IsReadOnly: boolean;
|
|
3872
|
+
Value: ReactUnity.Helpers.WatchableDictionary<ReactUnity.Styling.IStyleProperty, any>;
|
|
3824
3873
|
OnExposedToScriptCode(engine: any): void;
|
|
3825
3874
|
Add(key: string, value: any): void;
|
|
3826
3875
|
Add(item: System.Collections.Generic.KeyValuePair<string, any>): void;
|
|
@@ -3846,6 +3895,7 @@ export declare namespace ReactUnity {
|
|
|
3846
3895
|
AddListener(listener: ((arg1: ReactUnity.Styling.IStyleProperty, arg2: any, arg3: ReactUnity.Helpers.WatchableDictionary<ReactUnity.Styling.IStyleProperty, any>) => void)): (() => void);
|
|
3847
3896
|
GetValueOrDefault(key: ReactUnity.Styling.IStyleProperty): any;
|
|
3848
3897
|
Dispose(): void;
|
|
3898
|
+
Change(): void;
|
|
3849
3899
|
Equals(obj: any): boolean;
|
|
3850
3900
|
GetHashCode(): number;
|
|
3851
3901
|
GetType(): System.Type;
|
|
@@ -4944,6 +4994,7 @@ export declare namespace ReactUnity {
|
|
|
4944
4994
|
EnumType: System.Type;
|
|
4945
4995
|
AllowFlags: boolean;
|
|
4946
4996
|
KeywordOnly: boolean;
|
|
4997
|
+
Mappings: Record<string, any>;
|
|
4947
4998
|
CanHandleKeyword(keyword: ReactUnity.Styling.CssKeyword): boolean;
|
|
4948
4999
|
Convert(value: any): ReactUnity.Styling.Computed.IComputedValue;
|
|
4949
5000
|
Stringify(value: any): string;
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.14.
|
|
1
|
+
export declare const version = "0.14.3";
|
package/dist/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var version = '0.14.
|
|
1
|
+
export var version = '0.14.3';
|