@koordinates/xstate-tree 4.5.0 → 5.1.0-next.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/lib/useService.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useService = exports.loggingMetaOptions = void 0;
4
4
  const react_1 = require("react");
5
- const utils_1 = require("./utils");
6
5
  /**
7
6
  * @public
8
7
  */
@@ -23,9 +22,9 @@ exports.loggingMetaOptions = loggingMetaOptions;
23
22
  * @internal
24
23
  */
25
24
  function useService(service) {
26
- const [current, setCurrent] = (0, react_1.useState)(service.state);
27
- const [children, setChildren] = (0, react_1.useState)(service.children);
28
- const childrenRef = (0, react_1.useRef)(new Map());
25
+ const [current, setCurrent] = (0, react_1.useState)(service.getSnapshot());
26
+ const [children, setChildren] = (0, react_1.useState)(service.getSnapshot().children);
27
+ const childrenRef = (0, react_1.useRef)({});
29
28
  (0, react_1.useEffect)(() => {
30
29
  childrenRef.current = children;
31
30
  }, [children]);
@@ -33,56 +32,17 @@ function useService(service) {
33
32
  // Set to current service state as there is a possibility
34
33
  // of a transition occurring between the initial useState()
35
34
  // initialization and useEffect() commit.
36
- setCurrent(service.state);
37
- setChildren(service.children);
38
- const listener = function (state) {
39
- if (state.changed) {
40
- setCurrent(state);
41
- if (!(0, utils_1.isEqual)(childrenRef.current, service.children)) {
42
- setChildren(new Map(service.children));
43
- }
44
- }
35
+ setCurrent(service.getSnapshot());
36
+ setChildren(service.getSnapshot().children);
37
+ const listener = function (snapshot) {
38
+ setCurrent(snapshot);
39
+ setChildren(service.getSnapshot().children);
45
40
  };
46
41
  const sub = service.subscribe(listener);
47
42
  return function () {
48
43
  sub.unsubscribe();
49
44
  };
50
45
  }, [service, setChildren]);
51
- (0, react_1.useEffect)(() => {
52
- function handler(event) {
53
- var _a, _b, _c;
54
- if (event.type.includes("done")) {
55
- const idOfFinishedChild = event.type.split(".")[2];
56
- childrenRef.current.delete(idOfFinishedChild);
57
- setChildren(new Map(childrenRef.current));
58
- }
59
- console.debug(`[xstate-tree] ${service.id} handling event`, ((_c = (_b = (_a = service.machine.meta) === null || _a === void 0 ? void 0 : _a.xstateTree) === null || _b === void 0 ? void 0 : _b.ignoredEvents) === null || _c === void 0 ? void 0 : _c.has(event.type))
60
- ? event.type
61
- : event);
62
- }
63
- let prevState = undefined;
64
- function transitionHandler(state) {
65
- var _a, _b;
66
- const ignoreContext = (_b = (_a = service.machine.meta) === null || _a === void 0 ? void 0 : _a.xstateTree) === null || _b === void 0 ? void 0 : _b.ignoreContext;
67
- const context = ignoreContext ? "[context omitted]" : state.context;
68
- if (prevState) {
69
- console.debug(`[xstate-tree] ${service.id} transitioning from`, prevState.value, "to", state.value, context);
70
- }
71
- else {
72
- console.debug(`[xstate-tree] ${service.id} transitioning to ${state.value}`, context);
73
- }
74
- prevState = state;
75
- }
76
- service.onEvent(handler);
77
- service.onTransition(transitionHandler);
78
- return () => {
79
- service.off(handler);
80
- service.off(transitionHandler);
81
- };
82
- }, [service, setChildren]);
83
- return [
84
- current,
85
- children,
86
- ];
46
+ return [current, children];
87
47
  }
88
48
  exports.useService = useService;
package/lib/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeMeta = exports.isNil = exports.isEqual = exports.difference = exports.isLikelyPageLoad = exports.assert = exports.assertIsDefined = exports.delay = void 0;
3
+ exports.toJSON = exports.mergeMeta = exports.isNil = exports.isEqual = exports.difference = exports.isLikelyPageLoad = exports.assert = exports.assertIsDefined = exports.delay = void 0;
4
4
  function delay(ms = 0) {
5
5
  return new Promise((resolve) => setTimeout(resolve, ms));
6
6
  }
@@ -130,3 +130,21 @@ function mergeMeta(meta) {
130
130
  }, {});
131
131
  }
132
132
  exports.mergeMeta = mergeMeta;
133
+ function getCircularReplacer() {
134
+ const seen = new WeakSet();
135
+ return (key, value) => {
136
+ if (typeof value === "object" && value !== null) {
137
+ if (seen.has(value)) {
138
+ // Circular reference found, discard key
139
+ return;
140
+ }
141
+ // Store value in our set
142
+ seen.add(value);
143
+ }
144
+ return value;
145
+ };
146
+ }
147
+ function toJSON(value) {
148
+ return JSON.parse(JSON.stringify(value, getCircularReplacer()));
149
+ }
150
+ exports.toJSON = toJSON;
@@ -1,28 +1,22 @@
1
- import { AnyEventObject } from 'xstate';
2
- import { AnyFunction } from 'xstate';
1
+ import type { ActorRefFrom } from 'xstate';
3
2
  import { AnyStateMachine } from 'xstate';
4
- import { BaseActionObject } from 'xstate';
5
- import { ComponentPropsWithRef } from 'react';
6
3
  import { ContextFrom } from 'xstate';
7
- import { EventFrom } from 'xstate';
4
+ import type { EventFrom } from 'xstate';
8
5
  import { EventObject } from 'xstate';
9
6
  import { History as History_2 } from 'history';
10
- import { InterpreterFrom } from 'xstate';
11
- import { JSXElementConstructor } from 'react';
7
+ import { InputFrom } from 'xstate';
8
+ import type { IsNever } from 'xstate';
12
9
  import { ParsedQuery } from 'query-string';
13
10
  import { default as React_2 } from 'react';
14
- import { ResolveTypegenMeta } from 'xstate';
15
- import { ServiceMap } from 'xstate';
16
- import type { StateFrom } from 'xstate';
17
- import { StateMachine } from 'xstate';
18
- import { TypegenDisabled } from 'xstate';
11
+ import type { SnapshotFrom } from 'xstate';
12
+ import type { StateValue } from 'xstate';
19
13
  import * as Z from 'zod';
20
14
 
21
15
  /**
22
16
  * @public
23
17
  */
24
18
  export declare type Actions<TMachine extends AnyStateMachine, TSelectorsOutput, TOut> = (args: {
25
- send: InterpreterFrom<TMachine>["send"];
19
+ send: ActorRefFrom<TMachine>["send"];
26
20
  selectors: TSelectorsOutput;
27
21
  }) => TOut;
28
22
 
@@ -31,16 +25,7 @@ export declare type Actions<TMachine extends AnyStateMachine, TSelectorsOutput,
31
25
  *
32
26
  * Retrieves the actions return type from the xstate-tree machine
33
27
  */
34
- export declare type ActionsFrom<TMachine extends AnyXstateTreeMachine> = TMachine extends StateMachine<any, infer TMeta, any> ? TMeta extends {
35
- meta: {
36
- actions: infer TOut;
37
- };
38
- } ? TOut extends (...args: any) => any ? ReturnType<TOut> : never : never : never;
39
-
40
- /**
41
- * @public
42
- */
43
- export declare type AnyActions = (send: any, selectors: any) => any;
28
+ export declare type ActionsFrom<TMachine extends AnyXstateTreeMachine> = TMachine["_xstateTree"] extends XstateTreeMachineStateSchemaV2<any, any, infer TOut, any> ? TOut : never;
44
29
 
45
30
  /**
46
31
  * @public
@@ -65,12 +50,7 @@ export declare type AnyRoute = {
65
50
  /**
66
51
  * @public
67
52
  */
68
- export declare type AnySelector = V1Selectors<any, any, any, any>;
69
-
70
- /**
71
- * @public
72
- */
73
- export declare type AnyXstateTreeMachine = StateMachine<any, XstateTreeMachineStateSchemaV1<AnyStateMachine, AnySelector, AnyActions> | XstateTreeMachineStateSchemaV2<AnyStateMachine, any, any>, any>;
53
+ export declare type AnyXstateTreeMachine = XstateTreeMachine<AnyStateMachine>;
74
54
 
75
55
  /**
76
56
  * @public
@@ -86,24 +66,6 @@ export declare type ArgumentsForRoute<T> = T extends Route<infer TParams, infer
86
66
  */
87
67
  export declare function broadcast(event: GlobalEvents): void;
88
68
 
89
- /**
90
- * @public
91
- *
92
- * Factory function for actions. The actions function is passed two arguments:
93
- * - `send` - the interpreters send function, which can be used to send events to the machine
94
- * - `selectors` - the output of the selectors function from {@link buildSelectors}
95
- *
96
- * The resulting action function will only be called once per invocation of a machine.
97
- * The selectors are passed in as a proxy to always read the latest selector value
98
- *
99
- * @param machine - The machine to create the actions for
100
- * @param selectors - The selectors function
101
- * @param actions - The action function
102
- * @returns The actions function - ready to be passed to {@link buildView}
103
- * @deprecated use {@link createXStateTreeMachine} instead
104
- * */
105
- export declare function buildActions<TMachine extends AnyStateMachine, TActions, TSelectors, TSend = InterpreterFrom<TMachine>["send"]>(__machine: TMachine, __selectors: TSelectors, actions: (send: TSend, selectors: OutputFromSelector<TSelectors>) => TActions): (send: TSend, selectors: OutputFromSelector<TSelectors>) => TActions;
106
-
107
69
  /**
108
70
  * @public
109
71
  *
@@ -178,7 +140,7 @@ export declare function buildRootComponent(machine: AnyXstateTreeMachine, routin
178
140
  getPathName?: () => string;
179
141
  getQueryString?: () => string;
180
142
  }): {
181
- (): JSX.Element | null;
143
+ (): JSX.Element;
182
144
  rootMachine: AnyXstateTreeMachine;
183
145
  };
184
146
 
@@ -196,97 +158,11 @@ export declare function buildRootComponent(machine: AnyXstateTreeMachine, routin
196
158
  */
197
159
  export declare function buildRoutingMachine<TRoutes extends AnyRoute[]>(_routes: TRoutes, mappings: Record<TRoutes[number]["event"], AnyXstateTreeMachine>): AnyXstateTreeMachine;
198
160
 
199
- /**
200
- * @public
201
- *
202
- * Factory function for selectors. The selectors function is passed three arguments:
203
- * - `ctx` - the current context of the machines state
204
- * - `canHandleEvent` - a function that can be used to determine if the machine can handle a
205
- * given event, by simulating sending the event and seeing if a stat change would happen.
206
- * Handles guards
207
- * - `inState` - equivalent to xstates `state.matches`, allows checking if the machine is in a given state
208
- *
209
- * The resulting selector function has memoization. It will return the same value until the
210
- * machine's state changes or the machine's context changes
211
- * @param machine - The machine to create the selectors for
212
- * @param selectors - The selector function
213
- * @returns The selectors - ready to be passed to {@link buildActions}
214
- * @deprecated use {@link createXStateTreeMachine} instead
215
- */
216
- export declare function buildSelectors<TMachine extends AnyStateMachine, TSelectors, TContext = ContextFrom<TMachine>>(__machine: TMachine, selectors: (ctx: TContext, canHandleEvent: CanHandleEvent<TMachine>, inState: MatchesFrom<TMachine>, __currentState: never) => TSelectors): V1Selectors<TContext, EventFrom<TMachine>, TSelectors, MatchesFrom<TMachine>>;
217
-
218
- /**
219
- * @public
220
- *
221
- * Sets up a root component for use in an \@xstate/test model backed by \@testing-library/react for the component
222
- *
223
- * The logger argument should just be a simple function which forwards the arguments to console.log,
224
- * this is needed because Wallaby.js only displays console logs in tests that come from source code, not library code,
225
- * so any logs from inside this file don't show up in the test explorer
226
- *
227
- * The returned object has a `rootComponent` property and a function, `awaitTransition`, that returns a Promise
228
- * when called that is resolved the next time the underlying machine transitions. This can be used in the \@xstate/test
229
- * model to ensure after an event action is executed the test in the next state doesn't run until after the machine transitions
230
- *
231
- * It also delays for 5ms to ensure any React re-rendering happens in response to the state transition
232
- */
233
- export declare function buildTestRootComponent<TMachine extends AnyStateMachine, TSelectors extends AnySelector, TActions extends AnyActions, TContext = ContextFrom<TMachine>>(machine: StateMachine<TContext, XstateTreeMachineStateSchemaV1<TMachine, TSelectors, TActions> | XstateTreeMachineStateSchemaV2<TMachine, TSelectors, TActions>, EventFrom<TMachine>>, logger: typeof console.log): {
234
- rootComponent: () => JSX.Element | null;
235
- addTransitionListener: (listener: () => void) => void;
236
- awaitTransition(): Promise<void>;
237
- };
238
-
239
- /**
240
- * @public
241
- *
242
- * Factory function for views. The view is passed four props:
243
- * - `slots` - the slots object, which can be used to render the children of the view invoked by the machine
244
- * - `actions` - the output of the actions function from {@link buildActions}
245
- * - `selectors` - the output of the selectors function from {@link buildSelectors}
246
- * - `inState` - equivalent to xstates `state.matches`, allows checking if the machine is in a given state
247
- *
248
- * The resulting view is wrapped in React.memo, it will re-render when the actions or selectors reference changes
249
- *
250
- * @param machine - The machine to create the view for
251
- * @param selectors - The selectors function from {@link buildSelectors}
252
- * @param actions - The actions function from {@link buildActions}
253
- * @param slots - The array of slots that can be rendered by the view
254
- * @param view - The view function
255
- * @returns The React view
256
- * @deprecated use {@link createXStateTreeMachine} instead
257
- */
258
- export declare function buildView<TMachine extends AnyStateMachine, TEvent extends EventObject, TActions, TSelectors extends AnySelector, TSlots extends readonly Slot[] = [], TMatches extends AnyFunction = MatchesFrom<TMachine>, TViewProps = ViewProps<OutputFromSelector<TSelectors>, TActions, TSlots, TMatches>, TSend = (send: TEvent) => void>(__machine: TMachine, __selectors: TSelectors, __actions: (send: TSend, selectors: OutputFromSelector<TSelectors>) => TActions, __slots: TSlots, view: React_2.ComponentType<TViewProps>): React_2.ComponentType<TViewProps>;
259
-
260
- /**
261
- * @public
262
- *
263
- * Aids in type inference for creating props objects for xstate-tree views.
264
- *
265
- * @param view - The view to create props for
266
- * @param props - The actions/selectors props to pass to the view
267
- * @returns An object with the view's selectors, actions, and inState function props
268
- */
269
- export declare function buildViewProps<C extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>>(_view: C, props: Pick<InferViewProps<PropsOf<C>>, "actions" | "selectors">): InferViewProps<PropsOf<C>>;
270
-
271
- /**
272
- * @public
273
- *
274
- * staples xstate machine and xstate-tree metadata together into an xstate-tree machine
275
- *
276
- * @param machine - The machine to staple the selectors/actions/slots/view to
277
- * @param metadata - The xstate-tree metadata to staple to the machine
278
- * @returns The xstate-tree machine, ready to be invoked by other xstate-machines or used with `buildRootComponent`
279
- * @deprecated use {@link createXStateTreeMachine} instead
280
- */
281
- export declare function buildXStateTreeMachine<TMachine extends AnyStateMachine, TSelectors extends AnySelector, TActions extends AnyActions>(machine: TMachine, meta: XStateTreeMachineMetaV1<TMachine, TSelectors, TActions>): StateMachine<ContextFrom<TMachine>, XstateTreeMachineStateSchemaV1<TMachine, TSelectors, TActions>, EventFrom<TMachine>, any, any, any, any>;
282
-
283
161
  /**
284
162
  * @internal
285
163
  */
286
164
  export declare type CanHandleEvent<TMachine extends AnyStateMachine> = (e: EventFrom<TMachine>) => boolean;
287
165
 
288
- declare type Context = {};
289
-
290
166
  /**
291
167
  * @public
292
168
  * Creates an xstate-tree machine from an xstate-machine
@@ -301,7 +177,7 @@ declare type Context = {};
301
177
  * @param machine - The xstate machine to create the xstate-tree machine from
302
178
  * @param options - the xstate-tree options
303
179
  */
304
- export declare function createXStateTreeMachine<TMachine extends AnyStateMachine, TSelectorsOutput = ContextFrom<TMachine>, TActionsOutput = Record<never, string>, TSlots extends readonly Slot[] = []>(machine: TMachine, options: V2BuilderMeta<TMachine, TSelectorsOutput, TActionsOutput, TSlots>): StateMachine<ContextFrom<TMachine>, XstateTreeMachineStateSchemaV2<TMachine, TSelectorsOutput, TActionsOutput, TSlots>, EventFrom<TMachine>, any, any, any, any>;
180
+ export declare function createXStateTreeMachine<TMachine extends AnyStateMachine, TSelectorsOutput = ContextFrom<TMachine>, TActionsOutput = Record<never, string>, TSlots extends readonly Slot[] = []>(machine: TMachine, options: V2BuilderMeta<TMachine, TSelectorsOutput, TActionsOutput, TSlots>): XstateTreeMachine<TMachine>;
305
181
 
306
182
  declare type EmptyKeys<T> = keyof {
307
183
  [K in keyof T as IsEmptyObject<T[K], true> extends true ? K : never]: T[K];
@@ -309,8 +185,6 @@ declare type EmptyKeys<T> = keyof {
309
185
 
310
186
  declare type EmptyRouteArguments<TParams, TQuery> = IsEmptyObject<TParams, true> extends true ? IsEmptyObject<TQuery, true> extends true ? true : false : false;
311
187
 
312
- declare type Events = any;
313
-
314
188
  /**
315
189
  * @public
316
190
  *
@@ -339,12 +213,6 @@ export declare type GlobalEvents = {
339
213
  };
340
214
  }[keyof XstateTreeEvents];
341
215
 
342
- declare type InferViewProps<T> = T extends ViewProps<infer TSelectors, infer TActions, never, infer TMatches> ? {
343
- selectors: TSelectors;
344
- actions: TActions;
345
- inState: (state: Parameters<TMatches>[0]) => TMatches;
346
- } : never;
347
-
348
216
  declare type IsEmptyObject<Obj, ExcludeOptional extends boolean = false> = undefined extends Obj ? true : [keyof (ExcludeOptional extends true ? OmitOptional<Obj> : Obj)] extends [
349
217
  never
350
218
  ] ? true : false;
@@ -359,7 +227,7 @@ never
359
227
  * @param options - configure loading component and context to invoke machine with
360
228
  * @returns an xstate-tree machine that wraps the promise, invoking the resulting machine when it resolves
361
229
  */
362
- export declare function lazy<TMachine extends AnyStateMachine>(factory: () => Promise<TMachine>, { Loader, withContext, }?: Options<TMachine["context"]>): StateMachine<Context, any, Events, States, any, any, any>;
230
+ export declare function lazy<TMachine extends AnyXstateTreeMachine>(factory: () => Promise<TMachine>, { Loader, input }?: Options<TMachine>): AnyXstateTreeMachine;
363
231
 
364
232
  /**
365
233
  * @public
@@ -415,7 +283,7 @@ declare type MakeEmptyObjectPropertiesOptional<T> = Omit<T, EmptyKeys<T>> & Part
415
283
  /**
416
284
  * @internal
417
285
  */
418
- export declare type MatchesFrom<T extends AnyStateMachine> = StateFrom<T>["matches"];
286
+ export declare type MatchesFrom<T extends AnyStateMachine> = (value: ToStatePaths<SnapshotFrom<T>["value"]>) => boolean;
419
287
 
420
288
  /**
421
289
  * @public
@@ -460,7 +328,7 @@ declare type OmitOptional<T> = {
460
328
  */
461
329
  export declare function onBroadcast(handler: (event: GlobalEvents) => void): () => void;
462
330
 
463
- declare type Options<TContext> = {
331
+ declare type Options<TStateMachine extends AnyStateMachine> = {
464
332
  /**
465
333
  * Displayed while the promise is resolving, defaults to returning null
466
334
  */
@@ -469,14 +337,9 @@ declare type Options<TContext> = {
469
337
  * Allows you to specify an overriden context when the machine is invoked
470
338
  * Automatically supplies the machines default context so only requires a partial of overrides
471
339
  */
472
- withContext?: () => Partial<TContext>;
340
+ input?: InputFrom<TStateMachine>;
473
341
  };
474
342
 
475
- /**
476
- * @public
477
- */
478
- export declare type OutputFromSelector<T> = T extends V1Selectors<any, any, infer O, any> ? O : never;
479
-
480
343
  /**
481
344
  * @public
482
345
  *
@@ -497,8 +360,6 @@ export declare type PickEvent<T extends Extract<GlobalEvents, {
497
360
  type: T;
498
361
  }>;
499
362
 
500
- declare type PropsOf<C extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> = JSX.LibraryManagedAttributes<C, ComponentPropsWithRef<C>>;
501
-
502
363
  /**
503
364
  * @public
504
365
  *
@@ -680,11 +541,7 @@ export declare type Selectors<TMachine extends AnyStateMachine, TOut> = (args: {
680
541
  *
681
542
  * Retrieves the selector return type from the xstate-tree machine
682
543
  */
683
- export declare type SelectorsFrom<TMachine extends AnyXstateTreeMachine> = TMachine extends StateMachine<any, infer TMeta, any> ? TMeta extends {
684
- meta: {
685
- selectors: infer TOut;
686
- };
687
- } ? TOut extends (...args: any) => any ? ReturnType<TOut> : never : never : never;
544
+ export declare type SelectorsFrom<TMachine extends AnyXstateTreeMachine> = TMachine["_xstateTree"] extends XstateTreeMachineStateSchemaV2<any, infer TOut, any, any> ? TOut : never;
688
545
 
689
546
  /**
690
547
  * @public
@@ -730,19 +587,6 @@ export declare function singleSlot<T extends string>(name: T): SingleSlot<T>;
730
587
  */
731
588
  export declare type Slot = SingleSlot<any> | MultiSlot<any>;
732
589
 
733
- /**
734
- * @public
735
- *
736
- * Creates a dummy machine that just renders the supplied string - useful for rendering xstate-tree views in isolation
737
- *
738
- * @param name - the string to render in the machines view
739
- * @returns a dummy machine that renders a div containing the supplied string
740
- */
741
- export declare function slotTestingDummyFactory(name: string): StateMachine<unknown, XstateTreeMachineStateSchemaV1<StateMachine<unknown, any, AnyEventObject, {
742
- value: any;
743
- context: unknown;
744
- }, BaseActionObject, ServiceMap, ResolveTypegenMeta<TypegenDisabled, AnyEventObject, BaseActionObject, ServiceMap>>, () => {}, () => {}>, AnyEventObject, any, any, any, any>;
745
-
746
590
  /**
747
591
  * @public
748
592
  */
@@ -751,14 +595,6 @@ export declare enum SlotType {
751
595
  MultiSlot = 1
752
596
  }
753
597
 
754
- declare type States = {
755
- value: "loading";
756
- context: Context;
757
- } | {
758
- value: "rendering";
759
- context: Context;
760
- };
761
-
762
598
  /**
763
599
  * @public
764
600
  */
@@ -773,17 +609,21 @@ export declare type StyledLink<TStyleProps = {}> = <TRoute extends AnyRoute>(pro
773
609
  * @param activeRouteEvents - The active route events to use in the context
774
610
  */
775
611
  export declare function TestRoutingContext({ activeRouteEvents, children, }: {
776
- activeRouteEvents: RoutingEvent<any>[];
612
+ activeRouteEvents: RoutingEvent<AnyRoute>[];
777
613
  children: React_2.ReactNode;
778
614
  }): JSX.Element;
779
615
 
616
+ declare type ToStatePaths<TStateValue extends StateValue, TParentPath extends string = ""> = TStateValue extends string ? WithParentPath<TStateValue, TParentPath> : IsNever<keyof TStateValue> extends true ? never : WithParentPath<keyof TStateValue & string, TParentPath> | Values<{
617
+ [K in keyof TStateValue & string]?: ToStatePaths<NonNullable<TStateValue[K]>, WithParentPath<K, TParentPath>>;
618
+ }>;
619
+
780
620
  /**
781
621
  * @public
782
622
  *
783
623
  * Returns the list of active routing events, or undefined if there are none / used outside of an xstate-tree routing context
784
624
  */
785
625
  export declare function useActiveRouteEvents(): {
786
- type: unknown;
626
+ type: string;
787
627
  originalUrl: string;
788
628
  params: unknown;
789
629
  query: unknown;
@@ -812,11 +652,6 @@ export declare function useIsRouteActive(...routes: AnyRoute[]): boolean;
812
652
  */
813
653
  export declare function useRouteArgsIfActive<TRoute extends AnyRoute>(route: TRoute): ArgumentsForRoute<TRoute> | undefined;
814
654
 
815
- /**
816
- * @public
817
- */
818
- export declare type V1Selectors<TContext, TEvent, TSelectors, TMatches> = (ctx: TContext, canHandleEvent: (e: TEvent) => boolean, inState: TMatches, __currentState: never) => TSelectors;
819
-
820
655
  /**
821
656
  * @public
822
657
  */
@@ -827,6 +662,8 @@ export declare type V2BuilderMeta<TMachine extends AnyStateMachine, TSelectorsOu
827
662
  View: View<TActionsOutput, TSelectorsOutput, TSlots>;
828
663
  };
829
664
 
665
+ declare type Values<T> = T[keyof T];
666
+
830
667
  /**
831
668
  * @public
832
669
  */
@@ -836,19 +673,6 @@ export declare type View<TActionsOutput, TSelectorsOutput, TSlots extends readon
836
673
  selectors: TSelectorsOutput;
837
674
  }>;
838
675
 
839
- /**
840
- * @public
841
- */
842
- export declare type ViewProps<TSelectors, TActions, TSlots extends readonly Slot[], TMatches extends AnyFunction> = {
843
- slots: Record<GetSlotNames<TSlots>, React_2.ComponentType>;
844
- actions: TActions;
845
- selectors: TSelectors;
846
- /**
847
- * @deprecated see https://github.com/koordinates/xstate-tree/issues/33 use `inState` in the selector function instead
848
- */
849
- inState: TMatches;
850
- };
851
-
852
676
  /**
853
677
  * @public
854
678
  *
@@ -859,6 +683,8 @@ export declare type ViewProps<TSelectors, TActions, TSlots extends readonly Slot
859
683
  */
860
684
  export declare function viewToMachine(view: () => JSX.Element): AnyXstateTreeMachine;
861
685
 
686
+ declare type WithParentPath<TCurrent extends string, TParentPath extends string> = `${TParentPath extends "" ? "" : `${TParentPath}.`}${TCurrent}`;
687
+
862
688
  /**
863
689
  * @public
864
690
  */
@@ -870,30 +696,18 @@ export declare type XstateTreeHistory<T = unknown> = History_2<{
870
696
  /**
871
697
  * @public
872
698
  */
873
- export declare type XStateTreeMachineMetaV1<TMachine extends AnyStateMachine, TSelectors, TActions extends AnyActions, TSlots extends readonly Slot[] = Slot[]> = {
874
- slots: TSlots;
875
- view: React_2.ComponentType<ViewProps<OutputFromSelector<TSelectors>, ReturnType<TActions>, TSlots, MatchesFrom<TMachine>>>;
876
- selectors: TSelectors;
877
- actions: TActions;
878
- xstateTreeMachine?: true;
879
- };
699
+ export declare type XstateTreeMachine<TMachine extends AnyStateMachine> = TMachine & XstateTreeMachineInjection<TMachine>;
880
700
 
881
701
  /**
882
- * @public
702
+ * @internal
883
703
  */
884
- export declare type XstateTreeMachineStateSchemaV1<TMachine extends AnyStateMachine, TSelectors extends AnySelector, TActions extends AnyActions> = {
885
- meta: XStateTreeMachineMetaV1<TMachine, TSelectors, TActions> & {
886
- builderVersion: 1;
887
- };
704
+ export declare type XstateTreeMachineInjection<TMachine extends AnyStateMachine> = {
705
+ _xstateTree: XstateTreeMachineStateSchemaV2<TMachine>;
888
706
  };
889
707
 
890
708
  /**
891
709
  * @public
892
710
  */
893
- export declare type XstateTreeMachineStateSchemaV2<TMachine extends AnyStateMachine, TSelectorsOutput = ContextFrom<TMachine>, TActionsOutput = Record<never, string>, TSlots extends readonly Slot[] = Slot[]> = {
894
- meta: Required<V2BuilderMeta<TMachine, TSelectorsOutput, TActionsOutput, TSlots> & {
895
- builderVersion: 2;
896
- }>;
897
- };
711
+ export declare type XstateTreeMachineStateSchemaV2<TMachine extends AnyStateMachine, TSelectorsOutput = ContextFrom<TMachine>, TActionsOutput = Record<never, string>, TSlots extends readonly Slot[] = Slot[]> = Required<V2BuilderMeta<TMachine, TSelectorsOutput, TActionsOutput, TSlots>>;
898
712
 
899
713
  export { }