@xstate/react 4.0.0-beta.3 → 4.0.0-beta.5
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/declarations/src/createActorContext.d.ts +6 -6
- package/dist/declarations/src/index.d.ts +6 -7
- package/dist/declarations/src/useActor.d.ts +6 -3
- package/dist/declarations/src/useActorRef.d.ts +14 -0
- package/dist/declarations/src/useMachine.d.ts +9 -9
- package/dist/useConstant-2ee82f84.cjs.js +35 -0
- package/dist/useConstant-ae6dceac.development.cjs.js +35 -0
- package/dist/{useConstant-c09b427a.cjs.prod.js → useConstant-bac83df4.development.esm.js} +3 -5
- package/dist/useConstant-c7ec0fdd.esm.js +13 -0
- package/dist/xstate-react.cjs.d.mts +2 -0
- package/dist/xstate-react.cjs.d.mts.map +1 -0
- package/dist/xstate-react.cjs.d.ts +1 -0
- package/dist/xstate-react.cjs.d.ts.map +1 -0
- package/dist/xstate-react.cjs.js +178 -4
- package/dist/xstate-react.cjs.mjs +8 -0
- package/dist/xstate-react.development.cjs.js +190 -0
- package/dist/xstate-react.development.esm.js +159 -0
- package/dist/xstate-react.esm.js +74 -245
- package/fsm/dist/xstate-react-fsm.cjs.d.mts +2 -0
- package/fsm/dist/xstate-react-fsm.cjs.d.mts.map +1 -0
- package/fsm/dist/xstate-react-fsm.cjs.d.ts +1 -0
- package/fsm/dist/xstate-react-fsm.cjs.d.ts.map +1 -0
- package/fsm/dist/xstate-react-fsm.cjs.js +65 -4
- package/fsm/dist/xstate-react-fsm.cjs.mjs +4 -0
- package/fsm/dist/xstate-react-fsm.development.cjs.js +74 -0
- package/fsm/dist/xstate-react-fsm.development.esm.js +65 -0
- package/fsm/dist/xstate-react-fsm.esm.js +30 -42
- package/package.json +30 -4
- package/dist/declarations/src/types.d.ts +0 -15
- package/dist/declarations/src/useConstant.d.ts +0 -1
- package/dist/declarations/src/useInterpret.d.ts +0 -12
- package/dist/declarations/src/useSpawn.d.ts +0 -9
- package/dist/useConstant-0013a606.esm.js +0 -68
- package/dist/useConstant-ff65b597.cjs.dev.js +0 -71
- package/dist/xstate-react.cjs.dev.js +0 -335
- package/dist/xstate-react.cjs.prod.js +0 -327
- package/fsm/dist/xstate-react-fsm.cjs.dev.js +0 -80
- package/fsm/dist/xstate-react-fsm.cjs.prod.js +0 -127
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var fsm = require('@xstate/fsm');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var useIsomorphicLayoutEffect = require('use-isomorphic-layout-effect');
|
|
8
|
+
var withSelector = require('use-sync-external-store/shim/with-selector');
|
|
9
|
+
var useConstant = require('../../dist/useConstant-ae6dceac.development.cjs.js');
|
|
10
|
+
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
12
|
+
|
|
13
|
+
var useIsomorphicLayoutEffect__default = /*#__PURE__*/_interopDefault(useIsomorphicLayoutEffect);
|
|
14
|
+
|
|
15
|
+
function identity(a) {
|
|
16
|
+
return a;
|
|
17
|
+
}
|
|
18
|
+
function useMachine(stateMachine, options) {
|
|
19
|
+
const persistedStateRef = React.useRef();
|
|
20
|
+
{
|
|
21
|
+
const [initialMachine] = React.useState(stateMachine);
|
|
22
|
+
if (stateMachine !== initialMachine) {
|
|
23
|
+
console.warn('Machine given to `useMachine` has changed between renders. This is not supported and might lead to unexpected results.\n' + 'Please make sure that you pass the same Machine as argument each time.');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const [service, queue] = useConstant.useConstant(() => {
|
|
27
|
+
const queue = [];
|
|
28
|
+
const service = fsm.interpret(fsm.createMachine(stateMachine.config, options ? options : stateMachine._options));
|
|
29
|
+
const {
|
|
30
|
+
send
|
|
31
|
+
} = service;
|
|
32
|
+
service.send = event => {
|
|
33
|
+
if (service.status === fsm.InterpreterStatus.NotStarted) {
|
|
34
|
+
queue.push(event);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
send(event);
|
|
38
|
+
persistedStateRef.current = service.state;
|
|
39
|
+
};
|
|
40
|
+
return [service, queue];
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// TODO: consider using `useInsertionEffect` if available
|
|
44
|
+
useIsomorphicLayoutEffect__default["default"](() => {
|
|
45
|
+
if (options) {
|
|
46
|
+
service._machine._options = options;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const useServiceResult = useService(service);
|
|
50
|
+
React.useEffect(() => {
|
|
51
|
+
service.start(persistedStateRef.current);
|
|
52
|
+
queue.forEach(service.send);
|
|
53
|
+
persistedStateRef.current = service.state;
|
|
54
|
+
return () => {
|
|
55
|
+
service.stop();
|
|
56
|
+
};
|
|
57
|
+
}, []);
|
|
58
|
+
return useServiceResult;
|
|
59
|
+
}
|
|
60
|
+
const isEqual = (_prevState, nextState) => nextState.changed === false;
|
|
61
|
+
function useService(service) {
|
|
62
|
+
const getSnapshot = React.useCallback(() => service.state, [service]);
|
|
63
|
+
const subscribe = React.useCallback(handleStoreChange => {
|
|
64
|
+
const {
|
|
65
|
+
unsubscribe
|
|
66
|
+
} = service.subscribe(handleStoreChange);
|
|
67
|
+
return unsubscribe;
|
|
68
|
+
}, [service]);
|
|
69
|
+
const storeSnapshot = withSelector.useSyncExternalStoreWithSelector(subscribe, getSnapshot, getSnapshot, identity, isEqual);
|
|
70
|
+
return [storeSnapshot, service.send, service];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
exports.useMachine = useMachine;
|
|
74
|
+
exports.useService = useService;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { interpret, createMachine, InterpreterStatus } from '@xstate/fsm';
|
|
2
|
+
import { useRef, useState, useEffect, useCallback } from 'react';
|
|
3
|
+
import useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect';
|
|
4
|
+
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector';
|
|
5
|
+
import { u as useConstant } from '../../dist/useConstant-bac83df4.development.esm.js';
|
|
6
|
+
|
|
7
|
+
function identity(a) {
|
|
8
|
+
return a;
|
|
9
|
+
}
|
|
10
|
+
function useMachine(stateMachine, options) {
|
|
11
|
+
const persistedStateRef = useRef();
|
|
12
|
+
{
|
|
13
|
+
const [initialMachine] = useState(stateMachine);
|
|
14
|
+
if (stateMachine !== initialMachine) {
|
|
15
|
+
console.warn('Machine given to `useMachine` has changed between renders. This is not supported and might lead to unexpected results.\n' + 'Please make sure that you pass the same Machine as argument each time.');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const [service, queue] = useConstant(() => {
|
|
19
|
+
const queue = [];
|
|
20
|
+
const service = interpret(createMachine(stateMachine.config, options ? options : stateMachine._options));
|
|
21
|
+
const {
|
|
22
|
+
send
|
|
23
|
+
} = service;
|
|
24
|
+
service.send = event => {
|
|
25
|
+
if (service.status === InterpreterStatus.NotStarted) {
|
|
26
|
+
queue.push(event);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
send(event);
|
|
30
|
+
persistedStateRef.current = service.state;
|
|
31
|
+
};
|
|
32
|
+
return [service, queue];
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// TODO: consider using `useInsertionEffect` if available
|
|
36
|
+
useIsomorphicLayoutEffect(() => {
|
|
37
|
+
if (options) {
|
|
38
|
+
service._machine._options = options;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const useServiceResult = useService(service);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
service.start(persistedStateRef.current);
|
|
44
|
+
queue.forEach(service.send);
|
|
45
|
+
persistedStateRef.current = service.state;
|
|
46
|
+
return () => {
|
|
47
|
+
service.stop();
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
50
|
+
return useServiceResult;
|
|
51
|
+
}
|
|
52
|
+
const isEqual = (_prevState, nextState) => nextState.changed === false;
|
|
53
|
+
function useService(service) {
|
|
54
|
+
const getSnapshot = useCallback(() => service.state, [service]);
|
|
55
|
+
const subscribe = useCallback(handleStoreChange => {
|
|
56
|
+
const {
|
|
57
|
+
unsubscribe
|
|
58
|
+
} = service.subscribe(handleStoreChange);
|
|
59
|
+
return unsubscribe;
|
|
60
|
+
}, [service]);
|
|
61
|
+
const storeSnapshot = useSyncExternalStoreWithSelector(subscribe, getSnapshot, getSnapshot, identity, isEqual);
|
|
62
|
+
return [storeSnapshot, service.send, service];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { useMachine, useService };
|
|
@@ -1,70 +1,58 @@
|
|
|
1
|
-
import { _ as _slicedToArray, u as useConstant } from '../../dist/useConstant-0013a606.esm.js';
|
|
2
1
|
import { interpret, createMachine, InterpreterStatus } from '@xstate/fsm';
|
|
3
|
-
import { useRef,
|
|
2
|
+
import { useRef, useEffect, useCallback } from 'react';
|
|
4
3
|
import useIsomorphicLayoutEffect from 'use-isomorphic-layout-effect';
|
|
5
4
|
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector';
|
|
5
|
+
import { u as useConstant } from '../../dist/useConstant-c7ec0fdd.esm.js';
|
|
6
6
|
|
|
7
7
|
function identity(a) {
|
|
8
8
|
return a;
|
|
9
9
|
}
|
|
10
10
|
function useMachine(stateMachine, options) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
send(event);
|
|
30
|
-
persistedStateRef.current = service.state;
|
|
31
|
-
};
|
|
32
|
-
return [service, queue];
|
|
33
|
-
}),
|
|
34
|
-
_useConstant2 = _slicedToArray(_useConstant, 2),
|
|
35
|
-
service = _useConstant2[0],
|
|
36
|
-
queue = _useConstant2[1];
|
|
11
|
+
const persistedStateRef = useRef();
|
|
12
|
+
const [service, queue] = useConstant(() => {
|
|
13
|
+
const queue = [];
|
|
14
|
+
const service = interpret(createMachine(stateMachine.config, options ? options : stateMachine._options));
|
|
15
|
+
const {
|
|
16
|
+
send
|
|
17
|
+
} = service;
|
|
18
|
+
service.send = event => {
|
|
19
|
+
if (service.status === InterpreterStatus.NotStarted) {
|
|
20
|
+
queue.push(event);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
send(event);
|
|
24
|
+
persistedStateRef.current = service.state;
|
|
25
|
+
};
|
|
26
|
+
return [service, queue];
|
|
27
|
+
});
|
|
37
28
|
|
|
38
29
|
// TODO: consider using `useInsertionEffect` if available
|
|
39
|
-
useIsomorphicLayoutEffect(
|
|
30
|
+
useIsomorphicLayoutEffect(() => {
|
|
40
31
|
if (options) {
|
|
41
32
|
service._machine._options = options;
|
|
42
33
|
}
|
|
43
34
|
});
|
|
44
|
-
|
|
45
|
-
useEffect(
|
|
35
|
+
const useServiceResult = useService(service);
|
|
36
|
+
useEffect(() => {
|
|
46
37
|
service.start(persistedStateRef.current);
|
|
47
38
|
queue.forEach(service.send);
|
|
48
39
|
persistedStateRef.current = service.state;
|
|
49
|
-
return
|
|
40
|
+
return () => {
|
|
50
41
|
service.stop();
|
|
51
42
|
};
|
|
52
43
|
}, []);
|
|
53
44
|
return useServiceResult;
|
|
54
45
|
}
|
|
55
|
-
|
|
56
|
-
return nextState.changed === false;
|
|
57
|
-
};
|
|
46
|
+
const isEqual = (_prevState, nextState) => nextState.changed === false;
|
|
58
47
|
function useService(service) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
unsubscribe = _service$subscribe.unsubscribe;
|
|
48
|
+
const getSnapshot = useCallback(() => service.state, [service]);
|
|
49
|
+
const subscribe = useCallback(handleStoreChange => {
|
|
50
|
+
const {
|
|
51
|
+
unsubscribe
|
|
52
|
+
} = service.subscribe(handleStoreChange);
|
|
65
53
|
return unsubscribe;
|
|
66
54
|
}, [service]);
|
|
67
|
-
|
|
55
|
+
const storeSnapshot = useSyncExternalStoreWithSelector(subscribe, getSnapshot, getSnapshot, identity, isEqual);
|
|
68
56
|
return [storeSnapshot, service.send, service];
|
|
69
57
|
}
|
|
70
58
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xstate/react",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.5",
|
|
4
4
|
"description": "XState tools for React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"state",
|
|
@@ -19,15 +19,41 @@
|
|
|
19
19
|
"module": "dist/xstate-react.esm.js",
|
|
20
20
|
"exports": {
|
|
21
21
|
"./fsm": {
|
|
22
|
+
"types": {
|
|
23
|
+
"import": "./fsm/dist/xstate-react-fsm.cjs.mjs",
|
|
24
|
+
"default": "./fsm/dist/xstate-react-fsm.cjs.js"
|
|
25
|
+
},
|
|
26
|
+
"development": {
|
|
27
|
+
"module": "./fsm/dist/xstate-react-fsm.development.esm.js",
|
|
28
|
+
"import": "./fsm/dist/xstate-react-fsm.development.cjs.mjs",
|
|
29
|
+
"default": "./fsm/dist/xstate-react-fsm.development.cjs.js"
|
|
30
|
+
},
|
|
22
31
|
"module": "./fsm/dist/xstate-react-fsm.esm.js",
|
|
32
|
+
"import": "./fsm/dist/xstate-react-fsm.cjs.mjs",
|
|
23
33
|
"default": "./fsm/dist/xstate-react-fsm.cjs.js"
|
|
24
34
|
},
|
|
25
35
|
".": {
|
|
36
|
+
"types": {
|
|
37
|
+
"import": "./dist/xstate-react.cjs.mjs",
|
|
38
|
+
"default": "./dist/xstate-react.cjs.js"
|
|
39
|
+
},
|
|
40
|
+
"development": {
|
|
41
|
+
"module": "./dist/xstate-react.development.esm.js",
|
|
42
|
+
"import": "./dist/xstate-react.development.cjs.mjs",
|
|
43
|
+
"default": "./dist/xstate-react.development.cjs.js"
|
|
44
|
+
},
|
|
26
45
|
"module": "./dist/xstate-react.esm.js",
|
|
46
|
+
"import": "./dist/xstate-react.cjs.mjs",
|
|
27
47
|
"default": "./dist/xstate-react.cjs.js"
|
|
28
48
|
},
|
|
29
49
|
"./package.json": "./package.json"
|
|
30
50
|
},
|
|
51
|
+
"imports": {
|
|
52
|
+
"#is-development": {
|
|
53
|
+
"development": "./src/true.ts",
|
|
54
|
+
"default": "./src/false.ts"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
31
57
|
"types": "dist/xstate-react.cjs.d.ts",
|
|
32
58
|
"sideEffects": false,
|
|
33
59
|
"files": [
|
|
@@ -45,7 +71,7 @@
|
|
|
45
71
|
"peerDependencies": {
|
|
46
72
|
"@xstate/fsm": "^3.0.0-beta.2",
|
|
47
73
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
48
|
-
"xstate": "^5.0.0-beta.
|
|
74
|
+
"xstate": "^5.0.0-beta.13"
|
|
49
75
|
},
|
|
50
76
|
"peerDependenciesMeta": {
|
|
51
77
|
"@xstate/fsm": {
|
|
@@ -56,7 +82,7 @@
|
|
|
56
82
|
}
|
|
57
83
|
},
|
|
58
84
|
"dependencies": {
|
|
59
|
-
"use-isomorphic-layout-effect": "^1.
|
|
85
|
+
"use-isomorphic-layout-effect": "^1.1.2",
|
|
60
86
|
"use-sync-external-store": "^1.0.0"
|
|
61
87
|
},
|
|
62
88
|
"devDependencies": {
|
|
@@ -70,7 +96,7 @@
|
|
|
70
96
|
"jsdom-global": "^3.0.2",
|
|
71
97
|
"react": "^18.0.0",
|
|
72
98
|
"react-dom": "^18.0.0",
|
|
73
|
-
"xstate": "5.0.0-beta.
|
|
99
|
+
"xstate": "5.0.0-beta.13"
|
|
74
100
|
},
|
|
75
101
|
"preconstruct": {
|
|
76
102
|
"entrypoints": [
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { EventObject, MachineContext, StateConfig } from 'xstate';
|
|
2
|
-
export type MaybeLazy<T> = T | (() => T);
|
|
3
|
-
export type NoInfer<T> = [T][T extends any ? 0 : any];
|
|
4
|
-
export type Prop<T, K> = K extends keyof T ? T[K] : never;
|
|
5
|
-
export interface UseMachineOptions<TContext extends MachineContext, TEvent extends EventObject> {
|
|
6
|
-
/**
|
|
7
|
-
* If provided, will be merged with machine's `context`.
|
|
8
|
-
*/
|
|
9
|
-
context?: Partial<TContext>;
|
|
10
|
-
/**
|
|
11
|
-
* The state to rehydrate the machine to. The machine will
|
|
12
|
-
* start at this state instead of its `initialState`.
|
|
13
|
-
*/
|
|
14
|
-
state?: StateConfig<TContext, TEvent>;
|
|
15
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function useConstant<T>(fn: () => T): T;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AnyInterpreter, AnyStateMachine, AreAllImplementationsAssumedToBeProvided, InternalMachineImplementations, InterpreterFrom, InterpreterOptions, MachineImplementations, Observer, StateFrom } from 'xstate';
|
|
2
|
-
import { MaybeLazy } from './types.ts';
|
|
3
|
-
export declare function useIdleInterpreter(getMachine: MaybeLazy<AnyStateMachine>, options: Partial<InterpreterOptions<AnyStateMachine>> & Partial<MachineImplementations<any, never>>): AnyInterpreter;
|
|
4
|
-
type RestParams<TMachine extends AnyStateMachine> = AreAllImplementationsAssumedToBeProvided<TMachine['__TResolvedTypesMeta']> extends false ? [
|
|
5
|
-
options: InterpreterOptions<TMachine> & InternalMachineImplementations<TMachine['__TContext'], TMachine['__TEvent'], TMachine['__TResolvedTypesMeta'], true>,
|
|
6
|
-
observerOrListener?: Observer<StateFrom<TMachine>> | ((value: StateFrom<TMachine>) => void)
|
|
7
|
-
] : [
|
|
8
|
-
options?: InterpreterOptions<TMachine> & InternalMachineImplementations<TMachine['__TContext'], TMachine['__TEvent'], TMachine['__TResolvedTypesMeta']>,
|
|
9
|
-
observerOrListener?: Observer<StateFrom<TMachine>> | ((value: StateFrom<TMachine>) => void)
|
|
10
|
-
];
|
|
11
|
-
export declare function useInterpret<TMachine extends AnyStateMachine>(getMachine: MaybeLazy<TMachine>, ...[options, observerOrListener]: RestParams<TMachine>): InterpreterFrom<TMachine>;
|
|
12
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ActorRef, ActorBehavior, EventObject } from 'xstate';
|
|
2
|
-
/**
|
|
3
|
-
* React hook that spawns an `ActorRef` with the specified `behavior`.
|
|
4
|
-
* The returned `ActorRef` can be used with the `useActor(actorRef)` hook.
|
|
5
|
-
*
|
|
6
|
-
* @param behavior The actor behavior to spawn
|
|
7
|
-
* @returns An ActorRef with the specified `behavior`
|
|
8
|
-
*/
|
|
9
|
-
export declare function useSpawn<TState, TEvent extends EventObject>(behavior: ActorBehavior<TEvent, TState>): ActorRef<TEvent, TState>;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
function _arrayWithHoles(arr) {
|
|
4
|
-
if (Array.isArray(arr)) return arr;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function _iterableToArrayLimit(arr, i) {
|
|
8
|
-
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
9
|
-
if (null != _i) {
|
|
10
|
-
var _s,
|
|
11
|
-
_e,
|
|
12
|
-
_x,
|
|
13
|
-
_r,
|
|
14
|
-
_arr = [],
|
|
15
|
-
_n = !0,
|
|
16
|
-
_d = !1;
|
|
17
|
-
try {
|
|
18
|
-
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
19
|
-
if (Object(_i) !== _i) return;
|
|
20
|
-
_n = !1;
|
|
21
|
-
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
22
|
-
} catch (err) {
|
|
23
|
-
_d = !0, _e = err;
|
|
24
|
-
} finally {
|
|
25
|
-
try {
|
|
26
|
-
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
27
|
-
} finally {
|
|
28
|
-
if (_d) throw _e;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return _arr;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function _arrayLikeToArray(arr, len) {
|
|
36
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
37
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
38
|
-
return arr2;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
42
|
-
if (!o) return;
|
|
43
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
44
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
45
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
46
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
47
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _nonIterableRest() {
|
|
51
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function _slicedToArray(arr, i) {
|
|
55
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function useConstant(fn) {
|
|
59
|
-
var ref = useRef();
|
|
60
|
-
if (!ref.current) {
|
|
61
|
-
ref.current = {
|
|
62
|
-
v: fn()
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
return ref.current.v;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export { _slicedToArray as _, useConstant as u };
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
|
|
5
|
-
function _arrayWithHoles(arr) {
|
|
6
|
-
if (Array.isArray(arr)) return arr;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function _iterableToArrayLimit(arr, i) {
|
|
10
|
-
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
11
|
-
if (null != _i) {
|
|
12
|
-
var _s,
|
|
13
|
-
_e,
|
|
14
|
-
_x,
|
|
15
|
-
_r,
|
|
16
|
-
_arr = [],
|
|
17
|
-
_n = !0,
|
|
18
|
-
_d = !1;
|
|
19
|
-
try {
|
|
20
|
-
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
21
|
-
if (Object(_i) !== _i) return;
|
|
22
|
-
_n = !1;
|
|
23
|
-
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
24
|
-
} catch (err) {
|
|
25
|
-
_d = !0, _e = err;
|
|
26
|
-
} finally {
|
|
27
|
-
try {
|
|
28
|
-
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
29
|
-
} finally {
|
|
30
|
-
if (_d) throw _e;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return _arr;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function _arrayLikeToArray(arr, len) {
|
|
38
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
39
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
40
|
-
return arr2;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
44
|
-
if (!o) return;
|
|
45
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
46
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
47
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
48
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
49
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function _nonIterableRest() {
|
|
53
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function _slicedToArray(arr, i) {
|
|
57
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function useConstant(fn) {
|
|
61
|
-
var ref = React.useRef();
|
|
62
|
-
if (!ref.current) {
|
|
63
|
-
ref.current = {
|
|
64
|
-
v: fn()
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
return ref.current.v;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
exports._slicedToArray = _slicedToArray;
|
|
71
|
-
exports.useConstant = useConstant;
|