@reactunity/renderer 0.13.0 → 0.13.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.
@@ -51,6 +51,7 @@ export interface DictionaryWatcher<T = Record<string, any>> {
51
51
  export declare function createDictionaryWatcher<ValueType = any, RecordType = Record<string, ValueType>>(dictionary: ReactUnity.Helpers.WatchableRecord<ValueType>, displayName?: string): DictionaryWatcher<RecordType>;
52
52
  export declare const globalsWatcher: DictionaryWatcher<DefaultGlobals>;
53
53
  export declare const useGlobals: () => DefaultGlobals;
54
+ export declare const useGlobalsSelector: <Res>(selector: (store: DefaultGlobals) => Res) => Res;
54
55
  export declare const GlobalsProvider: (props: {
55
56
  children?: React.ReactNode;
56
57
  }) => import("react").FunctionComponentElement<import("react").ProviderProps<DefaultGlobals>>;
@@ -42,8 +42,8 @@ export function createDictionaryWatcher(dictionary, displayName) {
42
42
  var value = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
43
43
  return createElement(ctx.Provider, { value: value }, children);
44
44
  };
45
- function useSelector(selector) {
46
- return useSyncExternalStoreWithSelector(subscribe, getSnapshot, getSnapshot, selector);
45
+ function useSelector(selector, isEqual) {
46
+ return useSyncExternalStoreWithSelector(subscribe, getSnapshot, getSnapshot, selector, isEqual);
47
47
  }
48
48
  function useDictionaryContext() {
49
49
  var context = useContext(ctx);
@@ -59,4 +59,5 @@ export function createDictionaryWatcher(dictionary, displayName) {
59
59
  }
60
60
  export var globalsWatcher = createDictionaryWatcher(Globals, 'globalsContext');
61
61
  export var useGlobals = globalsWatcher.useContext;
62
+ export var useGlobalsSelector = globalsWatcher.useSelector;
62
63
  export var GlobalsProvider = globalsWatcher.Provider;
@@ -1,6 +1,6 @@
1
1
  import { RefAttributes } from 'react';
2
2
  import { ReactUnity } from './generated';
3
- import { AssetReferenceOrHttp } from './properties';
3
+ import { AssetReferenceOrHttp, Style } from './properties';
4
4
  import { RichTextElements, RichTextTags } from './richtext';
5
5
  import { SVGElements } from './svg';
6
6
  declare type BaseCmp = ReactUnity.IReactComponent;
@@ -17,12 +17,17 @@ export interface BaseEvents<T = BaseCmp> {
17
17
  onTransitionCancel?: TransitionCallback<T>;
18
18
  onTransitionEnd?: TransitionCallback<T>;
19
19
  }
20
+ export declare type PoolKey = string | number | boolean | null | undefined;
20
21
  export declare type Textable = string | number | boolean | null | undefined;
21
22
  export interface BaseCmpProps {
22
23
  id?: string;
23
24
  name?: string;
24
25
  class?: string;
25
26
  className?: string;
27
+ style?: Style | string;
28
+ data?: Record<string, any>;
29
+ custom?: Record<string, any>;
30
+ pool?: PoolKey;
26
31
  }
27
32
  export interface ContentSrcProps extends BaseCmpProps {
28
33
  content?: string;
@@ -0,0 +1,85 @@
1
+ export declare type URLSearchParams = string;
2
+ export declare type BufferSource = string;
3
+ export declare type BlobPart = ArrayBuffer | ArrayBufferView | Blob | string;
4
+ export declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
5
+ export interface EventListenerOptions {
6
+ capture?: boolean;
7
+ }
8
+ export interface EventInit {
9
+ bubbles?: boolean;
10
+ cancelable?: boolean;
11
+ composed?: boolean;
12
+ }
13
+ export interface AbortSignal {
14
+ aborted: boolean;
15
+ addEventListener: (type: "abort", listener: ((this: AbortSignal, event: any) => any), options?: boolean | {
16
+ capture?: boolean | undefined;
17
+ once?: boolean | undefined;
18
+ passive?: boolean | undefined;
19
+ }) => void;
20
+ removeEventListener: (type: "abort", listener: ((this: AbortSignal, event: any) => any), options?: boolean | {
21
+ capture?: boolean | undefined;
22
+ }) => void;
23
+ dispatchEvent: (event: any) => boolean;
24
+ onabort: null | ((this: AbortSignal, event: any) => any);
25
+ }
26
+ export interface AddEventListenerOptions extends EventListenerOptions {
27
+ once?: boolean;
28
+ passive?: boolean;
29
+ signal?: AbortSignal;
30
+ }
31
+ export interface EventListener {
32
+ (evt: Event): void;
33
+ }
34
+ export interface EventListenerObject {
35
+ handleEvent(object: Event): void;
36
+ }
37
+ export interface BlobOptions {
38
+ type?: string | undefined;
39
+ endings?: "transparent" | "native" | undefined;
40
+ }
41
+ export declare class Blob {
42
+ constructor(blobParts?: BlobPart[], options?: BlobOptions);
43
+ readonly type: string;
44
+ readonly size: number;
45
+ slice(start?: number, end?: number): Blob;
46
+ text(): Promise<string>;
47
+ }
48
+ declare type FormDataEntryValue = string;
49
+ /** Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data". */
50
+ export interface FormData {
51
+ append(name: string, value: string | Blob, fileName?: string): void;
52
+ delete(name: string): void;
53
+ get(name: string): FormDataEntryValue | null;
54
+ getAll(name: string): FormDataEntryValue[];
55
+ has(name: string): boolean;
56
+ set(name: string, value: string | Blob, fileName?: string): void;
57
+ }
58
+ export declare var FormData: {
59
+ prototype: FormData;
60
+ new (form?: HTMLFormElement): FormData;
61
+ };
62
+ /** The URL interface represents an object providing static methods used for creating object URLs. */
63
+ export interface URL {
64
+ hash: string;
65
+ host: string;
66
+ hostname: string;
67
+ href: string;
68
+ toString(): string;
69
+ readonly origin: string;
70
+ password: string;
71
+ pathname: string;
72
+ port: string;
73
+ protocol: string;
74
+ search: string;
75
+ readonly searchParams: URLSearchParams;
76
+ username: string;
77
+ toJSON(): string;
78
+ }
79
+ export declare var URL: {
80
+ prototype: URL;
81
+ new (url: string | URL, base?: string | URL): URL;
82
+ createObjectURL(obj: Blob): string;
83
+ revokeObjectURL(url: string): void;
84
+ };
85
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,111 @@
1
+ import { AbortSignal, Blob, FormData, URLSearchParams } from './common';
2
+ export declare class Body {
3
+ constructor(body?: any, opts?: {
4
+ size?: number | undefined;
5
+ timeout?: number | undefined;
6
+ });
7
+ arrayBuffer(): Promise<ArrayBuffer>;
8
+ blob(): Promise<Blob>;
9
+ bodyUsed: boolean;
10
+ json(): Promise<any>;
11
+ size: number;
12
+ text(): Promise<string>;
13
+ textConverted(): Promise<string>;
14
+ timeout: number;
15
+ }
16
+ export declare class Request extends Body {
17
+ constructor(input: RequestInfo, init?: RequestInit);
18
+ clone(): Request;
19
+ context: RequestContext;
20
+ headers: Headers;
21
+ method: string;
22
+ redirect: RequestRedirect;
23
+ referrer: string;
24
+ url: string;
25
+ compress: boolean;
26
+ counter: number;
27
+ follow: number;
28
+ hostname: string;
29
+ port?: number | undefined;
30
+ protocol: string;
31
+ size: number;
32
+ timeout: number;
33
+ }
34
+ export interface RequestInit {
35
+ body?: BodyInit | undefined;
36
+ headers?: HeadersInit | undefined;
37
+ method?: string | undefined;
38
+ redirect?: RequestRedirect | undefined;
39
+ signal?: AbortSignal | null | undefined;
40
+ compress?: boolean | undefined;
41
+ follow?: number | undefined;
42
+ size?: number | undefined;
43
+ timeout?: number | undefined;
44
+ }
45
+ export declare type RequestContext = "audio" | "beacon" | "cspreport" | "download" | "embed" | "eventsource" | "favicon" | "fetch" | "font" | "form" | "frame" | "hyperlink" | "iframe" | "image" | "imageset" | "import" | "internal" | "location" | "manifest" | "object" | "ping" | "plugin" | "prefetch" | "script" | "serviceworker" | "sharedworker" | "style" | "subresource" | "track" | "video" | "worker" | "xmlhttprequest" | "xslt";
46
+ export declare type RequestMode = "cors" | "no-cors" | "same-origin";
47
+ export declare type RequestRedirect = "error" | "follow" | "manual";
48
+ export declare type RequestCredentials = "omit" | "include" | "same-origin";
49
+ export declare type RequestCache = "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload";
50
+ export declare class Headers implements Iterable<[string, string]> {
51
+ constructor(init?: HeadersInit);
52
+ forEach(callback: (value: string, name: string) => void): void;
53
+ append(name: string, value: string): void;
54
+ delete(name: string): void;
55
+ get(name: string): string | null;
56
+ has(name: string): boolean;
57
+ raw(): {
58
+ [k: string]: string[];
59
+ };
60
+ set(name: string, value: string): void;
61
+ entries(): IterableIterator<[string, string]>;
62
+ keys(): IterableIterator<string>;
63
+ values(): IterableIterator<string>;
64
+ [Symbol.iterator](): Iterator<[string, string]>;
65
+ }
66
+ interface SystemError extends Error {
67
+ code?: string | undefined;
68
+ }
69
+ export declare class FetchError extends Error {
70
+ name: "FetchError";
71
+ constructor(message: string, type: string, systemError?: SystemError);
72
+ type: string;
73
+ code?: string | undefined;
74
+ errno?: string | undefined;
75
+ }
76
+ export declare class Response extends Body {
77
+ constructor(body?: BodyInit, init?: ResponseInit);
78
+ static error(): Response;
79
+ static redirect(url: string, status: number): Response;
80
+ clone(): Response;
81
+ headers: Headers;
82
+ ok: boolean;
83
+ redirected: boolean;
84
+ status: number;
85
+ statusText: string;
86
+ type: ResponseType;
87
+ url: string;
88
+ }
89
+ export declare type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect";
90
+ export interface ResponseInit {
91
+ headers?: HeadersInit | undefined;
92
+ size?: number | undefined;
93
+ status?: number | undefined;
94
+ statusText?: string | undefined;
95
+ timeout?: number | undefined;
96
+ url?: string | undefined;
97
+ }
98
+ interface URLLike {
99
+ href: string;
100
+ }
101
+ export declare type HeadersInit = Headers | string[][] | {
102
+ [key: string]: string;
103
+ };
104
+ export declare type HeaderInit = HeadersInit;
105
+ export declare type BodyInit = ArrayBuffer | ArrayBufferView | string | URLSearchParams | FormData;
106
+ export declare type RequestInfo = string | URLLike | Request;
107
+ export declare function fetch(url: RequestInfo, init?: RequestInit): Promise<Response>;
108
+ export declare namespace fetch {
109
+ function isRedirect(code: number): boolean;
110
+ }
111
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { FormData as TFormData, URL as TURL } from './common';
2
+ import { fetch as Tfetch } from './fetch';
3
+ import { XMLHttpRequest as TXHR } from './xhr';
4
+ declare global {
5
+ var FormData: typeof TFormData;
6
+ var URL: typeof TURL;
7
+ var fetch: typeof Tfetch;
8
+ var XMLHttpRequest: typeof TXHR;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,161 @@
1
+ import { AddEventListenerOptions, Blob, BufferSource, EventInit, EventListenerOptions, EventListenerOrEventListenerObject, FormData, URL, URLSearchParams } from "./common";
2
+ declare type XMLHttpRequestBodyInit = Blob | BufferSource | FormData | URLSearchParams | string;
3
+ declare type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";
4
+ /** Use XMLHttpRequest (XHR) objects to interact with servers. You can retrieve data from a URL without having to do a full page refresh. This enables a Web page to update just part of a page without disrupting what the user is doing. */
5
+ export interface XMLHttpRequest extends XMLHttpRequestEventTarget {
6
+ onreadystatechange: ((this: XMLHttpRequest, ev: Event) => any) | null;
7
+ /** Returns client's state. */
8
+ readonly readyState: number;
9
+ /** Returns the response body. */
10
+ readonly response: any;
11
+ /**
12
+ * Returns response as text.
13
+ *
14
+ * Throws an "InvalidStateError" DOMException if responseType is not the empty string or "text".
15
+ */
16
+ readonly responseText: string;
17
+ /**
18
+ * Returns the response type.
19
+ *
20
+ * Can be set to change the response type. Values are: the empty string (default), "arraybuffer", "blob", "document", "json", and "text".
21
+ *
22
+ * When set: setting to "document" is ignored if current global object is not a Window object.
23
+ *
24
+ * When set: throws an "InvalidStateError" DOMException if state is loading or done.
25
+ *
26
+ * When set: throws an "InvalidAccessError" DOMException if the synchronous flag is set and current global object is a Window object.
27
+ */
28
+ responseType: XMLHttpRequestResponseType;
29
+ readonly responseURL: string;
30
+ /**
31
+ * Returns the response as document.
32
+ *
33
+ * Throws an "InvalidStateError" DOMException if responseType is not the empty string or "document".
34
+ */
35
+ readonly responseXML: Document | null;
36
+ readonly status: number;
37
+ readonly statusText: string;
38
+ /**
39
+ * Can be set to a time in milliseconds. When set to a non-zero value will cause fetching to terminate after the given time has passed. When the time has passed, the request has not yet completed, and this's synchronous flag is unset, a timeout event will then be dispatched, or a "TimeoutError" DOMException will be thrown otherwise (for the send() method).
40
+ *
41
+ * When set: throws an "InvalidAccessError" DOMException if the synchronous flag is set and current global object is a Window object.
42
+ */
43
+ timeout: number;
44
+ /** Returns the associated XMLHttpRequestUpload object. It can be used to gather transmission information when data is transferred to a server. */
45
+ readonly upload: XMLHttpRequestUpload;
46
+ /**
47
+ * True when credentials are to be included in a cross-origin request. False when they are to be excluded in a cross-origin request and when cookies are to be ignored in its response. Initially false.
48
+ *
49
+ * When set: throws an "InvalidStateError" DOMException if state is not unsent or opened, or if the send() flag is set.
50
+ */
51
+ withCredentials: boolean;
52
+ /** Cancels any network activity. */
53
+ abort(): void;
54
+ getAllResponseHeaders(): string;
55
+ getResponseHeader(name: string): string | null;
56
+ /**
57
+ * Sets the request method, request URL, and synchronous flag.
58
+ *
59
+ * Throws a "SyntaxError" DOMException if either method is not a valid method or url cannot be parsed.
60
+ *
61
+ * Throws a "SecurityError" DOMException if method is a case-insensitive match for `CONNECT`, `TRACE`, or `TRACK`.
62
+ *
63
+ * Throws an "InvalidAccessError" DOMException if async is false, current global object is a Window object, and the timeout attribute is not zero or the responseType attribute is not the empty string.
64
+ */
65
+ open(method: string, url: string | URL): void;
66
+ open(method: string, url: string | URL, async: boolean, username?: string | null, password?: string | null): void;
67
+ /**
68
+ * Acts as if the `Content-Type` header value for a response is mime. (It does not change the header.)
69
+ *
70
+ * Throws an "InvalidStateError" DOMException if state is loading or done.
71
+ */
72
+ overrideMimeType(mime: string): void;
73
+ /**
74
+ * Initiates the request. The body argument provides the request body, if any, and is ignored if the request method is GET or HEAD.
75
+ *
76
+ * Throws an "InvalidStateError" DOMException if either state is not opened or the send() flag is set.
77
+ */
78
+ send(body?: Document | XMLHttpRequestBodyInit | null): void;
79
+ /**
80
+ * Combines a header in author request headers.
81
+ *
82
+ * Throws an "InvalidStateError" DOMException if either state is not opened or the send() flag is set.
83
+ *
84
+ * Throws a "SyntaxError" DOMException if name is not a header name or if value is not a header value.
85
+ */
86
+ setRequestHeader(name: string, value: string): void;
87
+ readonly DONE: number;
88
+ readonly HEADERS_RECEIVED: number;
89
+ readonly LOADING: number;
90
+ readonly OPENED: number;
91
+ readonly UNSENT: number;
92
+ addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
93
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
94
+ removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
95
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
96
+ }
97
+ export declare var XMLHttpRequest: {
98
+ prototype: XMLHttpRequest;
99
+ new (): XMLHttpRequest;
100
+ readonly DONE: number;
101
+ readonly HEADERS_RECEIVED: number;
102
+ readonly LOADING: number;
103
+ readonly OPENED: number;
104
+ readonly UNSENT: number;
105
+ };
106
+ interface XMLHttpRequestEventTargetEventMap {
107
+ "abort": ProgressEvent<XMLHttpRequestEventTarget>;
108
+ "error": ProgressEvent<XMLHttpRequestEventTarget>;
109
+ "load": ProgressEvent<XMLHttpRequestEventTarget>;
110
+ "loadend": ProgressEvent<XMLHttpRequestEventTarget>;
111
+ "loadstart": ProgressEvent<XMLHttpRequestEventTarget>;
112
+ "progress": ProgressEvent<XMLHttpRequestEventTarget>;
113
+ "timeout": ProgressEvent<XMLHttpRequestEventTarget>;
114
+ }
115
+ interface XMLHttpRequestEventMap extends XMLHttpRequestEventTargetEventMap {
116
+ "readystatechange": Event;
117
+ }
118
+ interface XMLHttpRequestEventTarget extends EventTarget {
119
+ onabort: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
120
+ onerror: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
121
+ onload: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
122
+ onloadend: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
123
+ onloadstart: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
124
+ onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
125
+ ontimeout: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
126
+ addEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
127
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
128
+ removeEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
129
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
130
+ }
131
+ declare var XMLHttpRequestEventTarget: {
132
+ prototype: XMLHttpRequestEventTarget;
133
+ new (): XMLHttpRequestEventTarget;
134
+ };
135
+ interface XMLHttpRequestUpload extends XMLHttpRequestEventTarget {
136
+ addEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
137
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
138
+ removeEventListener<K extends keyof XMLHttpRequestEventTargetEventMap>(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
139
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
140
+ }
141
+ declare var XMLHttpRequestUpload: {
142
+ prototype: XMLHttpRequestUpload;
143
+ new (): XMLHttpRequestUpload;
144
+ };
145
+ /** Events measuring progress of an underlying process, like an HTTP request (for an XMLHttpRequest, or the loading of the underlying resource of an <img>, <audio>, <video>, <style> or <link>). */
146
+ interface ProgressEvent<T extends EventTarget = EventTarget> extends Event {
147
+ readonly lengthComputable: boolean;
148
+ readonly loaded: number;
149
+ readonly target: T | null;
150
+ readonly total: number;
151
+ }
152
+ declare var ProgressEvent: {
153
+ prototype: ProgressEvent;
154
+ new (type: string, eventInitDict?: ProgressEventInit): ProgressEvent;
155
+ };
156
+ interface ProgressEventInit extends EventInit {
157
+ lengthComputable?: boolean;
158
+ loaded?: number;
159
+ total?: number;
160
+ }
161
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  import { ReactUnity } from '../generated';
2
+ import './dom/global';
2
3
  export * from './interop';
3
4
  interface Console {
4
5
  assert(condition?: boolean, ...data: any[]): void;
@@ -1 +1,2 @@
1
+ import './dom/global';
1
2
  export * from './interop';