@reactunity/renderer 0.14.0 → 0.14.2
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/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/src/helpers/dictionary-watcher.d.ts +17 -8
- package/dist/src/helpers/dictionary-watcher.js +50 -25
- package/dist/src/helpers/hooks/use-globals.d.ts +6 -0
- package/dist/src/helpers/hooks/use-globals.js +6 -0
- package/dist/src/helpers/hooks/use-watchable.d.ts +4 -0
- package/dist/src/helpers/hooks/use-watchable.js +27 -0
- package/dist/src/models/generated/react.d.ts +51 -0
- package/dist/src/models/generated/react.js +1 -1
- package/dist/src/models/richtext.d.ts +4 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/views/default-view.js +1 -2
- package/package.json +3 -3
- package/dist/src/helpers/watcher.d.ts +0 -2
- package/dist/src/helpers/watcher.js +0 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './src/helpers/dictionary-watcher';
|
|
2
|
+
export * from './src/helpers/hooks/use-globals';
|
|
3
|
+
export * from './src/helpers/hooks/use-watchable';
|
|
2
4
|
export * from './src/helpers/icons';
|
|
3
|
-
export * from './src/helpers/watcher';
|
|
4
5
|
export * from './src/models/environment';
|
|
5
6
|
export * from './src/models/generated';
|
|
6
7
|
export * from './src/models/properties';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './src/helpers/dictionary-watcher';
|
|
2
|
+
export * from './src/helpers/hooks/use-globals';
|
|
3
|
+
export * from './src/helpers/hooks/use-watchable';
|
|
2
4
|
export * from './src/helpers/icons';
|
|
3
|
-
export * from './src/helpers/watcher';
|
|
4
5
|
export * from './src/models/environment';
|
|
5
6
|
export * from './src/models/generated';
|
|
6
7
|
export * from './src/models/properties';
|
|
@@ -29,6 +29,19 @@ export interface DictionaryWatcher<T = Record<string, any>> {
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
useContext: () => T;
|
|
32
|
+
/**
|
|
33
|
+
* React Hook for getting the value of this Dictionary. This one will subscribe only to the properties that are accessed.
|
|
34
|
+
*
|
|
35
|
+
* Usage:
|
|
36
|
+
*
|
|
37
|
+
* ```tsx
|
|
38
|
+
* function App() {
|
|
39
|
+
* const { a, b } = watcher.useValue();
|
|
40
|
+
* ...
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
useValue: (subscribeToAllFields?: boolean, isEqual?: IsEqual) => T;
|
|
32
45
|
/**
|
|
33
46
|
* React Hook for getting a partial value from Context
|
|
34
47
|
*
|
|
@@ -36,22 +49,18 @@ export interface DictionaryWatcher<T = Record<string, any>> {
|
|
|
36
49
|
*
|
|
37
50
|
* ```tsx
|
|
38
51
|
* function App() {
|
|
39
|
-
* const
|
|
52
|
+
* const count = watcher.useSelector(st => st.count);
|
|
40
53
|
* ...
|
|
41
54
|
* }
|
|
42
55
|
* ```
|
|
43
56
|
*/
|
|
44
|
-
useSelector<Res>(selector: (store: T) => Res): Res;
|
|
57
|
+
useSelector<Res>(selector: (store: T) => Res, isEqual?: IsEqual<Res>): Res;
|
|
45
58
|
}
|
|
59
|
+
type IsEqual<T = any> = (a: T, b: T) => boolean;
|
|
46
60
|
/**
|
|
47
61
|
* Creates a context that updates its value when the values in the dictionary change
|
|
48
62
|
* @param dictionary The dictionary to be watched. Must implement the EventDictionary type in the C#
|
|
49
63
|
* @param displayName A displayName to identify this context easier in case of problems
|
|
50
64
|
*/
|
|
51
65
|
export declare function createDictionaryWatcher<ValueType = any, RecordType = Record<string, ValueType>>(dictionary: ReactUnity.Helpers.WatchableRecord<ValueType>, displayName?: string): DictionaryWatcher<RecordType>;
|
|
52
|
-
export
|
|
53
|
-
export declare const useGlobals: () => DefaultGlobals;
|
|
54
|
-
export declare const useGlobalsSelector: <Res>(selector: (store: DefaultGlobals) => Res) => Res;
|
|
55
|
-
export declare const GlobalsProvider: (props: {
|
|
56
|
-
children?: React.ReactNode;
|
|
57
|
-
}) => import("react").FunctionComponentElement<import("react").ProviderProps<DefaultGlobals>>;
|
|
66
|
+
export {};
|
|
@@ -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 } from 'react';
|
|
12
|
+
import { createContext, createElement, useContext, useMemo, useRef } 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
|
/**
|
|
@@ -21,30 +21,43 @@ export function createDictionaryWatcher(dictionary, displayName) {
|
|
|
21
21
|
var ctx = createContext(undefined);
|
|
22
22
|
if (displayName)
|
|
23
23
|
ctx.displayName = displayName;
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
var createSubscriber = function (fields, isEqual) {
|
|
25
|
+
var snapshot = (__assign({}, dictionary));
|
|
26
|
+
return {
|
|
27
|
+
subscribe: function (onStoreChange) {
|
|
28
|
+
snapshot = (__assign({}, dictionary));
|
|
29
|
+
var remove = dictionary === null || dictionary === void 0 ? void 0 : dictionary.AddListener(function (key, value, dic) {
|
|
30
|
+
var prev = snapshot;
|
|
31
|
+
snapshot = (__assign({}, dictionary));
|
|
32
|
+
if (!fields)
|
|
33
|
+
onStoreChange();
|
|
34
|
+
else {
|
|
35
|
+
for (var _i = 0, fields_1 = fields; _i < fields_1.length; _i++) {
|
|
36
|
+
var field = fields_1[_i];
|
|
37
|
+
if (isEqual ? !isEqual(prev[field], snapshot[field]) : (prev[field] !== snapshot[field])) {
|
|
38
|
+
onStoreChange();
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (!remove) {
|
|
45
|
+
if (displayName)
|
|
46
|
+
console.warn("".concat(displayName, " dictionary does not provide a change listener"));
|
|
47
|
+
else
|
|
48
|
+
console.warn('The dictionary does not provide a change listener');
|
|
49
|
+
}
|
|
50
|
+
return function () { return remove === null || remove === void 0 ? void 0 : remove(); };
|
|
51
|
+
},
|
|
52
|
+
getSnapshot: function () { return snapshot; },
|
|
53
|
+
};
|
|
38
54
|
};
|
|
39
|
-
var
|
|
55
|
+
var defaultSubscriber = createSubscriber();
|
|
40
56
|
var Provider = function GlobalsProvider(_a) {
|
|
41
57
|
var children = _a.children;
|
|
42
|
-
var value = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
58
|
+
var value = useSyncExternalStore(defaultSubscriber.subscribe, defaultSubscriber.getSnapshot, defaultSubscriber.getSnapshot);
|
|
43
59
|
return createElement(ctx.Provider, { value: value }, children);
|
|
44
60
|
};
|
|
45
|
-
function useSelector(selector, isEqual) {
|
|
46
|
-
return useSyncExternalStoreWithSelector(subscribe, getSnapshot, getSnapshot, selector, isEqual);
|
|
47
|
-
}
|
|
48
61
|
function useDictionaryContext() {
|
|
49
62
|
var context = useContext(ctx);
|
|
50
63
|
if (context === undefined) {
|
|
@@ -55,9 +68,21 @@ export function createDictionaryWatcher(dictionary, displayName) {
|
|
|
55
68
|
}
|
|
56
69
|
return context;
|
|
57
70
|
}
|
|
58
|
-
|
|
71
|
+
function useValue(subscribeToAllFields, fieldEqual) {
|
|
72
|
+
if (subscribeToAllFields === void 0) { subscribeToAllFields = false; }
|
|
73
|
+
var fields = useRef([]);
|
|
74
|
+
var subscriber = useMemo(function () { return subscribeToAllFields ? defaultSubscriber : createSubscriber(fields.current, fieldEqual); }, [subscribeToAllFields, fieldEqual]);
|
|
75
|
+
var value = useSyncExternalStore(subscriber.subscribe, subscriber.getSnapshot, subscriber.getSnapshot);
|
|
76
|
+
var proxy = new Proxy(value, {
|
|
77
|
+
get: function (target, p, receiver) {
|
|
78
|
+
fields.current.push(p);
|
|
79
|
+
return value[p];
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
return proxy;
|
|
83
|
+
}
|
|
84
|
+
function useSelector(selector, isEqual) {
|
|
85
|
+
return useSyncExternalStoreWithSelector(defaultSubscriber.subscribe, defaultSubscriber.getSnapshot, defaultSubscriber.getSnapshot, selector, isEqual);
|
|
86
|
+
}
|
|
87
|
+
return { context: ctx, Provider: Provider, useValue: useValue, useContext: useDictionaryContext, useSelector: useSelector };
|
|
59
88
|
}
|
|
60
|
-
export var globalsWatcher = createDictionaryWatcher(Globals, 'globalsContext');
|
|
61
|
-
export var useGlobals = globalsWatcher.useContext;
|
|
62
|
-
export var useGlobalsSelector = globalsWatcher.useSelector;
|
|
63
|
-
export var GlobalsProvider = globalsWatcher.Provider;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const useGlobals: (subscribeToAllFields?: boolean, isEqual?: (a: any, b: any) => boolean) => DefaultGlobals;
|
|
2
|
+
export declare const useGlobalsContext: () => DefaultGlobals;
|
|
3
|
+
export declare const useGlobalsSelector: <Res>(selector: (store: DefaultGlobals) => Res, isEqual?: (a: Res, b: Res) => boolean) => Res;
|
|
4
|
+
export declare const GlobalsProvider: (props: {
|
|
5
|
+
children?: import("react").ReactNode;
|
|
6
|
+
}) => import("react").FunctionComponentElement<import("react").ProviderProps<DefaultGlobals>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createDictionaryWatcher } from "../dictionary-watcher";
|
|
2
|
+
var globalsWatcher = createDictionaryWatcher(Globals, 'globalsContext');
|
|
3
|
+
export var useGlobals = globalsWatcher.useValue;
|
|
4
|
+
export var useGlobalsContext = globalsWatcher.useContext;
|
|
5
|
+
export var useGlobalsSelector = globalsWatcher.useSelector;
|
|
6
|
+
export var GlobalsProvider = globalsWatcher.Provider;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
3
|
+
function createSubscriber(obj, isEqual) {
|
|
4
|
+
var isWatchable = obj && typeof obj === 'object' && ('Value' in obj);
|
|
5
|
+
var snapshot = isWatchable ? obj.Value : undefined;
|
|
6
|
+
return {
|
|
7
|
+
subscribe: function (onStoreChange) {
|
|
8
|
+
snapshot = isWatchable ? obj.Value : undefined;
|
|
9
|
+
var remove = isWatchable && typeof obj.AddListener === 'function' &&
|
|
10
|
+
(obj === null || obj === void 0 ? void 0 : obj.AddListener(function (key, value, dic) {
|
|
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')
|
|
18
|
+
console.warn("The watchable does not provide a change listener");
|
|
19
|
+
return function () { return remove === null || remove === void 0 ? void 0 : remove(); };
|
|
20
|
+
},
|
|
21
|
+
getSnapshot: function () { return snapshot; },
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function useWatchable(obj, isEqual) {
|
|
25
|
+
var sb = useMemo(function () { return createSubscriber(obj, isEqual); }, [obj, isEqual]);
|
|
26
|
+
return useSyncExternalStore(sb.subscribe, sb.getSnapshot, sb.getSnapshot);
|
|
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;
|
|
@@ -28,6 +28,9 @@ export interface RichTextElements {
|
|
|
28
28
|
'nbsp': RichTextVoidTag;
|
|
29
29
|
'zwsp': RichTextVoidTag;
|
|
30
30
|
'br': RichTextVoidTag;
|
|
31
|
+
'shy': RichTextVoidTag;
|
|
32
|
+
'cr': RichTextVoidTag;
|
|
33
|
+
'lf': RichTextVoidTag;
|
|
31
34
|
'align': RichTextValueTag<'right' | 'center' | 'left'>;
|
|
32
35
|
'alpha': RichTextValueTag<string>;
|
|
33
36
|
'color': RichTextColorTag;
|
|
@@ -52,6 +55,7 @@ export interface RichTextElements {
|
|
|
52
55
|
'nobr': RichTextVoidTag;
|
|
53
56
|
'page': RichTextVoidTag;
|
|
54
57
|
'pos': RichTextValueTag<number>;
|
|
58
|
+
'scale': RichTextValueTag<number>;
|
|
55
59
|
'size': RichTextValueTag<number>;
|
|
56
60
|
'space': RichTextValueTag<number>;
|
|
57
61
|
'sprite': RichTextSpriteTag;
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.14.
|
|
1
|
+
export declare const version = "0.14.2";
|
package/dist/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var version = '0.14.
|
|
1
|
+
export var version = '0.14.2';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { GlobalsProvider } from '../helpers/dictionary-watcher';
|
|
3
2
|
import { ErrorBoundary } from './error-boundary';
|
|
4
3
|
export function DefaultView(_a) {
|
|
5
4
|
var children = _a.children, withHelpers = _a.withHelpers;
|
|
6
5
|
return _jsx(_Fragment, { children: !withHelpers ? children :
|
|
7
|
-
_jsx(ErrorBoundary, { children:
|
|
6
|
+
_jsx(ErrorBoundary, { children: children }) });
|
|
8
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactunity/renderer",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.2",
|
|
4
4
|
"description": "React renderer for Unity3D",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@reactunity/scripts": "^0.14.0",
|
|
65
65
|
"@types/react-reconciler": "^0.28.2",
|
|
66
|
-
"rimraf": "^4.
|
|
67
|
-
"typescript": "^4.9.
|
|
66
|
+
"rimraf": "^4.1.2",
|
|
67
|
+
"typescript": "^4.9.5"
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo } from 'react';
|
|
2
|
-
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
3
|
-
export function useWatchable(obj) {
|
|
4
|
-
var isWatchable = useMemo(function () { return obj && typeof obj === 'object' && ('Value' in obj); }, [obj]);
|
|
5
|
-
var subscribe = useCallback(function (onStoreChange) {
|
|
6
|
-
if (isWatchable && 'AddListener' in obj) {
|
|
7
|
-
var unsub_1 = obj.AddListener(function () { return onStoreChange(); });
|
|
8
|
-
return function () { return unsub_1 === null || unsub_1 === void 0 ? void 0 : unsub_1(); };
|
|
9
|
-
}
|
|
10
|
-
return function () { };
|
|
11
|
-
}, [obj, isWatchable]);
|
|
12
|
-
var getSnapshot = useCallback(function () { return isWatchable ? obj.Value : undefined; }, [obj, isWatchable]);
|
|
13
|
-
return useSyncExternalStore(subscribe, getSnapshot);
|
|
14
|
-
}
|