@rxova/journey-react 0.4.0 → 0.6.0
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/README.md +47 -66
- package/dist/bindings/Provider.d.ts +8 -0
- package/dist/bindings/StepRenderer.d.ts +13 -0
- package/dist/bindings/index.d.ts +2 -0
- package/dist/bindings/useJourneyApi.d.ts +17 -0
- package/dist/bindings/useJourneyMachine.d.ts +4 -0
- package/dist/bindings/useJourneySnapshot.d.ts +5 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.cts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/types.d.ts +30 -27
- package/package.json +7 -6
- package/dist/JourneyStepRenderer.d.ts +0 -10
- package/dist/JourneyStepRenderer.d.ts.map +0 -1
- package/dist/context.d.ts +0 -7
- package/dist/context.d.ts.map +0 -1
- package/dist/hooks.d.ts +0 -32
- package/dist/hooks.d.ts.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,33 +1,6 @@
|
|
|
1
1
|
# @rxova/journey-react
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
<a href="https://www.npmjs.com/package/@rxova/journey-react">
|
|
5
|
-
<img src="https://img.shields.io/badge/npm-%40rxova%2Fjourney--react-CB3837?logo=npm&logoColor=white" alt="npm package @rxova/journey-react" />
|
|
6
|
-
</a>
|
|
7
|
-
<a href="https://rxova.org/docs/react/quickstart">
|
|
8
|
-
<img src="https://img.shields.io/badge/docs-react-0f8f6a" alt="React docs" />
|
|
9
|
-
</a>
|
|
10
|
-
<a href="https://github.com/rxova/journey/actions/workflows/ci.yml">
|
|
11
|
-
<img src="https://github.com/rxova/journey/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI" />
|
|
12
|
-
</a>
|
|
13
|
-
<img src="https://img.shields.io/badge/TypeScript-strict-3178C6?logo=typescript&logoColor=white" alt="TypeScript" />
|
|
14
|
-
<img src="https://img.shields.io/badge/coverage%20(react)-100%25-brightgreen" alt="React coverage" />
|
|
15
|
-
<a href="https://www.npmjs.com/package/@rxova/journey-react">
|
|
16
|
-
<img src="https://img.shields.io/npm/v/@rxova/journey-react" alt="npm version" />
|
|
17
|
-
</a>
|
|
18
|
-
<a href="https://www.npmjs.com/package/@rxova/journey-react">
|
|
19
|
-
<img src="https://img.shields.io/npm/dm/@rxova/journey-react" alt="npm downloads" />
|
|
20
|
-
</a>
|
|
21
|
-
<a href="https://bundlephobia.com/package/@rxova/journey-react">
|
|
22
|
-
<img src="https://img.shields.io/bundlephobia/minzip/%40rxova%2Fjourney-react" alt="Bundlephobia" />
|
|
23
|
-
</a>
|
|
24
|
-
</p>
|
|
25
|
-
|
|
26
|
-
React bindings for Journey (`JourneyProvider`, hooks, renderer).
|
|
27
|
-
|
|
28
|
-
Use this package when you want Journey flow logic directly inside React components.
|
|
29
|
-
|
|
30
|
-
`[OVERVIEW](https://rxova.org/docs/react/overview) | [QUICKSTART](https://rxova.org/docs/react/quickstart) | [PROVIDER + HOOKS](https://rxova.org/docs/react/provider-and-hooks) | [PATTERNS](https://rxova.org/docs/react/patterns) | [ASYNC UI](https://rxova.org/docs/react/async-ui) | [EXAMPLES](https://rxova.org/docs/react/examples) | [DEVTOOL](https://rxova.org/docs/devtool/overview)`
|
|
3
|
+
Typed React bindings for Rxova Journey.
|
|
31
4
|
|
|
32
5
|
## Install
|
|
33
6
|
|
|
@@ -35,40 +8,38 @@ Use this package when you want Journey flow logic directly inside React componen
|
|
|
35
8
|
npm i @rxova/journey-react
|
|
36
9
|
```
|
|
37
10
|
|
|
38
|
-
##
|
|
11
|
+
## API Style
|
|
39
12
|
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
- `
|
|
43
|
-
-
|
|
13
|
+
`@rxova/journey-react` is bindings-first:
|
|
14
|
+
|
|
15
|
+
- `createJourneyBindings(journey)` returns a typed bundle:
|
|
16
|
+
- `Provider`
|
|
17
|
+
- `StepRenderer`
|
|
18
|
+
- `useJourneyApi`, `useJourneySnapshot`, `useJourneyMachine`
|
|
19
|
+
|
|
20
|
+
No per-hook generic arguments are needed at callsites.
|
|
44
21
|
|
|
45
22
|
## Quickstart
|
|
46
23
|
|
|
47
24
|
```tsx
|
|
48
|
-
import
|
|
49
|
-
|
|
50
|
-
JourneyStepRenderer,
|
|
51
|
-
useJourney,
|
|
52
|
-
JOURNEY_TERMINAL,
|
|
53
|
-
type JourneyReactDefinition
|
|
54
|
-
} from "@rxova/journey-react";
|
|
25
|
+
import React from "react";
|
|
26
|
+
import { createJourneyBindings, type JourneyReactDefinition } from "@rxova/journey-react";
|
|
55
27
|
|
|
56
28
|
type StepId = "start" | "review";
|
|
57
|
-
|
|
58
29
|
type Ctx = { name: string };
|
|
59
30
|
|
|
60
|
-
|
|
31
|
+
let bindings: ReturnType<typeof createJourneyBindings<Ctx, StepId>>;
|
|
32
|
+
|
|
61
33
|
const Start = () => {
|
|
62
|
-
const
|
|
63
|
-
return <button onClick={() => void api.
|
|
34
|
+
const api = bindings.useJourneyApi();
|
|
35
|
+
return <button onClick={() => void api.goToNextStep()}>Next</button>;
|
|
64
36
|
};
|
|
65
37
|
|
|
66
38
|
const Review = () => {
|
|
67
|
-
const
|
|
68
|
-
return <button onClick={() => void api.
|
|
39
|
+
const api = bindings.useJourneyApi();
|
|
40
|
+
return <button onClick={() => void api.completeJourney()}>Submit</button>;
|
|
69
41
|
};
|
|
70
42
|
|
|
71
|
-
// 2) Journey definition stays declarative and typed.
|
|
72
43
|
const journey: JourneyReactDefinition<Ctx, StepId> = {
|
|
73
44
|
initial: "start",
|
|
74
45
|
context: { name: "" },
|
|
@@ -77,31 +48,41 @@ const journey: JourneyReactDefinition<Ctx, StepId> = {
|
|
|
77
48
|
review: { component: Review }
|
|
78
49
|
},
|
|
79
50
|
transitions: [
|
|
80
|
-
{ from: "start", event: "
|
|
81
|
-
{ from: "review", event: "
|
|
51
|
+
{ from: "start", event: "goToNextStep", to: "review" },
|
|
52
|
+
{ from: "review", event: "completeJourney" }
|
|
82
53
|
]
|
|
83
54
|
};
|
|
84
55
|
|
|
85
|
-
|
|
86
|
-
export const App = () => (
|
|
87
|
-
<JourneyProvider journey={journey}>
|
|
88
|
-
<JourneyStepRenderer<Ctx, StepId> />
|
|
89
|
-
</JourneyProvider>
|
|
90
|
-
);
|
|
91
|
-
```
|
|
56
|
+
bindings = createJourneyBindings(journey);
|
|
92
57
|
|
|
93
|
-
|
|
58
|
+
export const App = () => {
|
|
59
|
+
const Provider = bindings.Provider;
|
|
60
|
+
const StepRenderer = bindings.StepRenderer;
|
|
94
61
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const machine = useJourneyMachine();
|
|
101
|
-
return <pre>{machine.getSnapshot().current}</pre>;
|
|
62
|
+
return (
|
|
63
|
+
<Provider>
|
|
64
|
+
<StepRenderer />
|
|
65
|
+
</Provider>
|
|
66
|
+
);
|
|
102
67
|
};
|
|
103
68
|
```
|
|
104
69
|
|
|
105
|
-
##
|
|
70
|
+
## Journey API Helpers
|
|
71
|
+
|
|
72
|
+
From `bindings.useJourneyApi()`:
|
|
73
|
+
|
|
74
|
+
- `goToNextStep`
|
|
75
|
+
- `terminateJourney`
|
|
76
|
+
- `completeJourney`
|
|
77
|
+
- `send`
|
|
78
|
+
- `goToPreviousStep(steps?)`
|
|
79
|
+
- `goToLastVisitedStep()`
|
|
80
|
+
- `updateContext`
|
|
81
|
+
- `updateStepMetadata`
|
|
82
|
+
- `clearStepError`, `resetJourney`
|
|
106
83
|
|
|
107
|
-
|
|
84
|
+
Imperative jump is available through `send`:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
await api.send({ type: "goToStepById", stepId: "review" });
|
|
88
|
+
```
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { JourneyBindingsProviderProps, JourneyReactDefinition, JourneyReactEventPayloadMap, JourneyStoreValue } from "../types";
|
|
3
|
+
type ProviderFactoryProps<TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown> = {
|
|
4
|
+
JourneyContext: React.Context<JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta> | null>;
|
|
5
|
+
boundJourney: JourneyReactDefinition<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;
|
|
6
|
+
};
|
|
7
|
+
export declare const createProvider: <TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown>({ JourneyContext, boundJourney }: ProviderFactoryProps<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>) => ({ journey, machine, persistence, resetOnJourneyChange, children }: JourneyBindingsProviderProps<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { JourneySnapshot } from "@rxova/journey-core";
|
|
3
|
+
import type { JourneyReactEventPayloadMap, JourneyStoreValue } from "../types";
|
|
4
|
+
type UseJourneyStore<TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown> = (hookName?: string) => JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;
|
|
5
|
+
type UseJourneySnapshot<TContext, TStepId extends string, TStepMeta = unknown> = () => JourneySnapshot<TContext, TStepId, TStepMeta>;
|
|
6
|
+
type StepRendererFactoryProps<TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown> = {
|
|
7
|
+
useJourneySnapshot: UseJourneySnapshot<TContext, TStepId, TStepMeta>;
|
|
8
|
+
useJourneyStore: UseJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;
|
|
9
|
+
};
|
|
10
|
+
export declare const createStepRenderer: <TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown>({ useJourneySnapshot, useJourneyStore }: StepRendererFactoryProps<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>) => ({ fallback }: {
|
|
11
|
+
fallback?: React.ReactNode;
|
|
12
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { JourneyBindings, JourneyReactDefinition, JourneyReactEventPayloadMap } from "../types";
|
|
2
|
+
export declare const createJourneyBindings: <TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown>(boundJourney: JourneyReactDefinition<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>) => JourneyBindings<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { JourneyEvent, JourneyPayloadFor } from "@rxova/journey-core";
|
|
2
|
+
import type { JourneyEventType, JourneyReactEventPayloadMap, JourneyStoreValue } from "../types";
|
|
3
|
+
type UseJourneyStore<TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown> = (hookName?: string) => JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;
|
|
4
|
+
export declare const createUseJourneyApi: <TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown>(useJourneyStore: UseJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>) => () => {
|
|
5
|
+
send: (event: JourneyEvent<TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>) => Promise<void>;
|
|
6
|
+
goToNextStep: () => Promise<void>;
|
|
7
|
+
terminateJourney: (payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, "terminateJourney">) => Promise<void>;
|
|
8
|
+
completeJourney: (payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, "completeJourney">) => Promise<void>;
|
|
9
|
+
goToPreviousStep: (steps?: number) => Promise<void>;
|
|
10
|
+
goToLastVisitedStep: () => Promise<void>;
|
|
11
|
+
clearStepError: (stepId?: TStepId) => void;
|
|
12
|
+
updateContext: (updater: (context: TContext) => TContext) => void;
|
|
13
|
+
updateStepMetadata: (stepId: TStepId, updater: (metadata: TStepMeta) => TStepMeta) => void;
|
|
14
|
+
updateComponentMetadata: (stepId: TStepId, updater: (metadata: TStepMeta) => TStepMeta) => void;
|
|
15
|
+
resetJourney: () => void;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { JourneyReactEventPayloadMap, JourneyStoreValue } from "../types";
|
|
2
|
+
type UseJourneyStore<TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown> = (hookName?: string) => JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;
|
|
3
|
+
export declare const createUseJourneyMachine: <TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown>(useJourneyStore: UseJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>) => () => import("packages/core/dist").JourneyMachine<TContext, TStepId, import("..").JourneyEventType<TCustomEvent>, TEventPayloadMap, TStepMeta>;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { JourneySnapshot } from "@rxova/journey-core";
|
|
2
|
+
import type { JourneyReactEventPayloadMap, JourneyStoreValue } from "../types";
|
|
3
|
+
type UseJourneyStore<TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown> = (hookName?: string) => JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;
|
|
4
|
+
export declare const createUseJourneySnapshot: <TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown>(useJourneyStore: UseJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>) => () => JourneySnapshot<TContext, TStepId, TStepMeta>;
|
|
5
|
+
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var A=Object.create;var l=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var Y=(t,e)=>{for(var n in e)l(t,n,{get:e[n],enumerable:!0})},M=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of D(e))!j.call(t,o)&&o!==n&&l(t,o,{get:()=>e[o],enumerable:!(s=B(e,o))||s.enumerable});return t};var E=(t,e,n)=>(n=t!=null?A(F(t)):{},M(e||!t||!t.__esModule?l(n,"default",{value:t,enumerable:!0}):n,t)),_=t=>M(l({},"__esModule",{value:!0}),t);var O={};Y(O,{JOURNEY_ASYNC_PHASE:()=>a.JOURNEY_ASYNC_PHASE,JOURNEY_EVENT:()=>a.JOURNEY_EVENT,JOURNEY_STATUS:()=>a.JOURNEY_STATUS,JOURNEY_WILDCARD:()=>a.JOURNEY_WILDCARD,createJourneyBindings:()=>w,createTransitions:()=>a.createTransitions,tx:()=>a.tx});module.exports=_(O);var C=E(require("react"),1);var m=E(require("react"),1),x=require("@rxova/journey-core"),R=require("react/jsx-runtime"),P=({JourneyContext:t,boundJourney:e})=>({journey:s,machine:o,persistence:u,resetOnJourneyChange:d=!1,children:v})=>{let y=s??e,T=m.default.useRef(null),c=m.default.useRef(y),S=m.default.useRef(u),r=d&&c.current!==y,J=S.current!==u;if(!o&&(!T.current||r||J)){let N=u?{persistence:u}:void 0;T.current=(0,x.createJourneyMachine)(y,N),c.current=y,S.current=u}let U=o??T.current,V=o?y:c.current,b={machine:U,journey:V};return(0,R.jsx)(t.Provider,{value:b,children:v})};var i=require("react/jsx-runtime"),g=({useJourneySnapshot:t,useJourneyStore:e})=>({fallback:s=null})=>{let o=t(),{journey:u}=e("StepRenderer"),d=u.steps[o.currentStepId]?.component;return d?(0,i.jsx)(d,{}):(0,i.jsx)(i.Fragment,{children:s})};var p=E(require("react"),1),f=t=>()=>{let e=t("useJourneyApi").machine,n=p.default.useCallback(async r=>{await e.send(r)},[e]),s=p.default.useCallback(async()=>{await e.goToNextStep()},[e]),o=p.default.useCallback(async r=>{await e.terminateJourney(r)},[e]),u=p.default.useCallback(async r=>{await e.completeJourney(r)},[e]),d=p.default.useCallback(async r=>{await e.goToPreviousStep(r)},[e]),v=p.default.useCallback(async()=>{await e.goToLastVisitedStep()},[e]),y=p.default.useCallback(r=>{e.updateContext(r)},[e]),T=p.default.useCallback((r,J)=>{e.updateStepMetadata(r,J)},[e]),c=p.default.useCallback(r=>{e.clearStepError(r)},[e]),S=p.default.useCallback(()=>{e.resetMachine()},[e]);return{send:n,goToNextStep:s,terminateJourney:o,completeJourney:u,goToPreviousStep:d,goToLastVisitedStep:v,clearStepError:c,updateContext:y,updateStepMetadata:T,updateComponentMetadata:T,resetJourney:S}};var I=t=>()=>t("useJourneyMachine").machine;var h=E(require("react"),1),k=t=>()=>{let{machine:e}=t("useJourneySnapshot");return h.default.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)};var w=t=>{let e=C.default.createContext(null),n=(y="hook")=>{let T=C.default.useContext(e);if(!T)throw new Error(`${y} must be used within bindings.Provider.`);return T},s=k(n),o=I(n),u=f(n),d=P({JourneyContext:e,boundJourney:t}),v=g({useJourneySnapshot:s,useJourneyStore:n});return{Provider:d,StepRenderer:v,useJourneyApi:u,useJourneyMachine:o,useJourneySnapshot:s}};var a=require("@rxova/journey-core");0&&(module.exports={JOURNEY_ASYNC_PHASE,JOURNEY_EVENT,JOURNEY_STATUS,JOURNEY_WILDCARD,createJourneyBindings,createTransitions,tx});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts", "../src/
|
|
4
|
-
"sourcesContent": ["\"use client\";\n\nexport { JourneyProvider } from \"./context\";\nexport { JourneyStepRenderer } from \"./JourneyStepRenderer\";\nexport { useJourney, useJourneyApi, useJourneyMachine, useJourneySnapshot } from \"./hooks\";\nexport type {\n JourneyApi,\n JourneyReactEventPayloadMap,\n JourneyHookResult,\n JourneyProviderProps,\n JourneyReactDefinition,\n JourneyReactStep,\n JourneyStoreValue\n} from \"./types\";\n", "import React from \"react\";\n\nimport { createJourneyMachine } from \"@rxova/journey-core\";\nimport type { JourneyProviderProps, JourneyReactEventPayloadMap, JourneyStoreValue } from \"./types\";\n\nconst JourneyContext = React.createContext<JourneyStoreValue<\n unknown,\n string,\n string,\n Record<never, never>\n> | null>(null);\n\n/**\n * React provider that supplies the journey machine and definition to hooks.\n */\nexport const JourneyProvider = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>\n>({\n journey,\n machine,\n persistence,\n history,\n resetOnJourneyChange = false,\n children\n}: JourneyProviderProps<TContext, TStepId, TCustomEvent, TEventPayloadMap>) => {\n const internalMachineRef = React.useRef<\n JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap>[\"machine\"] | null\n >(null);\n const journeyRef = React.useRef(journey);\n const persistenceRef = React.useRef(persistence);\n const historyRef = React.useRef(history);\n\n const shouldResetInternal = resetOnJourneyChange && journeyRef.current !== journey;\n const shouldResetPersistence = persistenceRef.current !== persistence;\n const shouldResetHistory = historyRef.current !== history;\n\n if (\n !machine &&\n (!internalMachineRef.current ||\n shouldResetInternal ||\n shouldResetPersistence ||\n shouldResetHistory)\n ) {\n const options =\n persistence || history\n ? {\n ...(persistence ? { persistence } : {}),\n ...(history ? { history } : {})\n }\n : undefined;\n internalMachineRef.current = createJourneyMachine(journey, options);\n journeyRef.current = journey;\n persistenceRef.current = persistence;\n historyRef.current = history;\n }\n\n const resolvedMachine = machine ?? internalMachineRef.current!;\n const resolvedJourney = machine ? journey : journeyRef.current;\n\n return (\n <JourneyContext.Provider\n value={\n {\n machine: resolvedMachine,\n journey: resolvedJourney\n } as unknown as JourneyStoreValue<unknown, string, string>\n }\n >\n {children}\n </JourneyContext.Provider>\n );\n};\n\nexport const useJourneyStore = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>\n>(\n hookName = \"useJourney\"\n): JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap> => {\n const value = React.useContext(JourneyContext);\n if (!value) {\n throw new Error(`${hookName} must be used within <JourneyProvider>.`);\n }\n\n return value as unknown as JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap>;\n};\n", "import React from \"react\";\n\nimport { JOURNEY_EVENT } from \"@rxova/journey-core\";\nimport type {\n JourneyEvent,\n JourneyMachine,\n JourneyPayloadFor,\n JourneySnapshot\n} from \"@rxova/journey-core\";\nimport { useJourneyStore } from \"./context\";\nimport type {\n JourneyDefaultEvent,\n JourneyEventType,\n JourneyHookResult,\n JourneyReactEventPayloadMap\n} from \"./types\";\n\nconst useSnapshot = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>\n>(): JourneySnapshot<TContext, TStepId> => {\n const { machine } = useJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap>(\n \"useJourneySnapshot\"\n );\n\n return React.useSyncExternalStore(machine.subscribe, machine.getSnapshot, machine.getSnapshot);\n};\n\n/**\n * Reads the current journey snapshot and re-renders on changes.\n */\nexport const useJourneySnapshot = useSnapshot;\n\n/**\n * Returns the underlying journey machine from provider context.\n */\nexport const useJourneyMachine = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>\n>(): JourneyMachine<TContext, TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap> => {\n const { machine } = useJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap>(\n \"useJourneyMachine\"\n );\n return machine;\n};\n\n/**\n * Returns imperative journey actions (send, goTo, next, back, close, submit).\n */\nexport const useJourneyApi = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>\n>() => {\n const { machine } = useJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap>(\n \"useJourneyApi\"\n );\n\n const send = React.useCallback(\n async (event: JourneyEvent<TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>) => {\n await machine.send(event);\n },\n [machine]\n );\n\n const goTo = React.useCallback(\n async (\n stepId: TStepId,\n payload?: JourneyPayloadFor<\n JourneyEventType<TCustomEvent>,\n TEventPayloadMap,\n (typeof JOURNEY_EVENT)[\"GO_TO\"]\n >\n ) => {\n if (payload === undefined) {\n await machine.send({\n type: JOURNEY_EVENT.GO_TO,\n to: stepId\n } as JourneyEvent<TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>);\n return;\n }\n\n await machine.send({\n type: JOURNEY_EVENT.GO_TO,\n to: stepId,\n payload\n } as JourneyEvent<TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>);\n },\n [machine]\n );\n\n const sendDefault = React.useCallback(\n async <TType extends JourneyDefaultEvent>(\n type: TType,\n payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, TType>\n ) => {\n const event =\n payload === undefined\n ? ({ type } as unknown as JourneyEvent<\n TStepId,\n JourneyEventType<TCustomEvent>,\n TEventPayloadMap\n >)\n : ({\n type,\n payload\n } as unknown as JourneyEvent<\n TStepId,\n JourneyEventType<TCustomEvent>,\n TEventPayloadMap\n >);\n await machine.send(event);\n },\n [machine]\n );\n\n const next = React.useCallback(\n async (\n payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, \"next\">\n ) => {\n await sendDefault(\"next\", payload);\n },\n [sendDefault]\n );\n\n const back = React.useCallback(\n async (\n payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, \"back\">\n ) => {\n await sendDefault(\"back\", payload);\n },\n [sendDefault]\n );\n\n const close = React.useCallback(\n async (\n payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, \"close\">\n ) => {\n await sendDefault(\"close\", payload);\n },\n [sendDefault]\n );\n\n const submit = React.useCallback(\n async (\n payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, \"submit\">\n ) => {\n await sendDefault(\"submit\", payload);\n },\n [sendDefault]\n );\n\n const updateContext = React.useCallback(\n (updater: (context: TContext) => TContext) => {\n machine.updateContext(updater);\n },\n [machine]\n );\n\n const clearStepError = React.useCallback(\n (stepId?: TStepId) => {\n machine.clearStepError(stepId);\n },\n [machine]\n );\n\n const reset = React.useCallback(() => {\n machine.reset();\n }, [machine]);\n\n const trimHistory = React.useCallback(\n (maxHistory?: number | null) => {\n machine.trimHistory(maxHistory);\n },\n [machine]\n );\n\n const clearHistory = React.useCallback(() => {\n machine.clearHistory();\n }, [machine]);\n\n return {\n send,\n goTo,\n next,\n back,\n close,\n submit,\n clearStepError,\n updateContext,\n reset,\n trimHistory,\n clearHistory\n };\n};\n\n/**\n * Combined hook that returns both snapshot and API helpers.\n */\nexport const useJourney = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>\n>(): JourneyHookResult<TContext, TStepId, TCustomEvent, TEventPayloadMap> => {\n useJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap>(\"useJourney\");\n const snapshot = useJourneySnapshot<TContext, TStepId, TCustomEvent, TEventPayloadMap>();\n const api = useJourneyApi<TContext, TStepId, TCustomEvent, TEventPayloadMap>();\n\n return {\n snapshot,\n api\n };\n};\n", "import React from \"react\";\n\nimport { useJourneyStore } from \"./context\";\nimport { useJourneySnapshot } from \"./hooks\";\n\ntype JourneyStepRendererProps = {\n fallback?: React.ReactNode;\n};\n\n/**\n * Renders the active step component from the journey definition.\n */\nexport const JourneyStepRenderer = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never\n>({\n fallback = null\n}: JourneyStepRendererProps) => {\n const snapshot = useJourneySnapshot<TContext, TStepId, TCustomEvent>();\n const { journey } = useJourneyStore<TContext, TStepId, TCustomEvent>();\n\n const StepComponent = journey.steps[snapshot.current]?.component;\n\n if (!StepComponent) {\n return <>{fallback}</>;\n }\n\n return <StepComponent />;\n};\n"],
|
|
5
|
-
"mappings": "ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,
|
|
6
|
-
"names": ["index_exports", "__export", "
|
|
3
|
+
"sources": ["../src/index.ts", "../src/bindings/index.tsx", "../src/bindings/Provider.tsx", "../src/bindings/StepRenderer.tsx", "../src/bindings/useJourneyApi.ts", "../src/bindings/useJourneyMachine.ts", "../src/bindings/useJourneySnapshot.ts"],
|
|
4
|
+
"sourcesContent": ["\"use client\";\n\nexport { createJourneyBindings } from \"./bindings\";\nexport {\n createTransitions,\n tx,\n JOURNEY_STATUS,\n JOURNEY_EVENT,\n JOURNEY_ASYNC_PHASE,\n JOURNEY_WILDCARD\n} from \"@rxova/journey-core\";\nexport type { JourneyDefinition } from \"@rxova/journey-core\";\nexport type {\n JourneyApi,\n JourneyBindings,\n JourneyBindingsProviderProps,\n JourneyEventType,\n JourneyReactDefinition,\n JourneyReactEventPayloadMap,\n JourneyReactStep,\n JourneyStoreValue\n} from \"./types\";\n", "import React from \"react\";\n\nimport type {\n JourneyBindings,\n JourneyReactDefinition,\n JourneyReactEventPayloadMap,\n JourneyStoreValue\n} from \"../types\";\nimport { createProvider } from \"./Provider\";\nimport { createStepRenderer } from \"./StepRenderer\";\nimport { createUseJourneyApi } from \"./useJourneyApi\";\nimport { createUseJourneyMachine } from \"./useJourneyMachine\";\nimport { createUseJourneySnapshot } from \"./useJourneySnapshot\";\n\nexport const createJourneyBindings = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n>(\n boundJourney: JourneyReactDefinition<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>\n): JourneyBindings<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta> => {\n const JourneyContext = React.createContext<JourneyStoreValue<\n TContext,\n TStepId,\n TCustomEvent,\n TEventPayloadMap,\n TStepMeta\n > | null>(null);\n\n const useJourneyStore = (hookName = \"hook\") => {\n const value = React.useContext(JourneyContext);\n if (!value) {\n throw new Error(`${hookName} must be used within bindings.Provider.`);\n }\n return value;\n };\n\n const useJourneySnapshot = createUseJourneySnapshot(useJourneyStore);\n const useJourneyMachine = createUseJourneyMachine(useJourneyStore);\n const useJourneyApi = createUseJourneyApi(useJourneyStore);\n\n const Provider = createProvider({\n JourneyContext,\n boundJourney\n });\n\n const StepRenderer = createStepRenderer({\n useJourneySnapshot,\n useJourneyStore\n });\n\n return {\n Provider,\n StepRenderer,\n useJourneyApi,\n useJourneyMachine,\n useJourneySnapshot\n };\n};\n", "import React from \"react\";\n\nimport { createJourneyMachine } from \"@rxova/journey-core\";\nimport type {\n JourneyBindingsProviderProps,\n JourneyReactDefinition,\n JourneyReactEventPayloadMap,\n JourneyStoreValue\n} from \"../types\";\n\ntype ProviderFactoryProps<\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n> = {\n JourneyContext: React.Context<JourneyStoreValue<\n TContext,\n TStepId,\n TCustomEvent,\n TEventPayloadMap,\n TStepMeta\n > | null>;\n boundJourney: JourneyReactDefinition<\n TContext,\n TStepId,\n TCustomEvent,\n TEventPayloadMap,\n TStepMeta\n >;\n};\n\nexport const createProvider = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n>({\n JourneyContext,\n boundJourney\n}: ProviderFactoryProps<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>) => {\n const Provider = ({\n journey,\n machine,\n persistence,\n resetOnJourneyChange = false,\n children\n }: JourneyBindingsProviderProps<\n TContext,\n TStepId,\n TCustomEvent,\n TEventPayloadMap,\n TStepMeta\n >) => {\n const incomingJourney = journey ?? boundJourney;\n const internalMachineRef = React.useRef<\n | JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>[\"machine\"]\n | null\n >(null);\n const journeyRef = React.useRef(incomingJourney);\n const persistenceRef = React.useRef(persistence);\n\n const shouldResetInternal = resetOnJourneyChange && journeyRef.current !== incomingJourney;\n const shouldResetPersistence = persistenceRef.current !== persistence;\n\n if (\n !machine &&\n (!internalMachineRef.current || shouldResetInternal || shouldResetPersistence)\n ) {\n const options = persistence ? { persistence } : undefined;\n internalMachineRef.current = createJourneyMachine(incomingJourney, options);\n journeyRef.current = incomingJourney;\n persistenceRef.current = persistence;\n }\n\n const resolvedMachine = machine ?? internalMachineRef.current!;\n const resolvedJourney = machine ? incomingJourney : journeyRef.current;\n const value: JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta> = {\n machine: resolvedMachine,\n journey: resolvedJourney\n };\n\n return <JourneyContext.Provider value={value}>{children}</JourneyContext.Provider>;\n };\n\n return Provider;\n};\n", "import React from \"react\";\n\nimport type { JourneySnapshot } from \"@rxova/journey-core\";\nimport type { JourneyReactEventPayloadMap, JourneyStoreValue } from \"../types\";\n\ntype UseJourneyStore<\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n> = (\n hookName?: string\n) => JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;\n\ntype UseJourneySnapshot<\n TContext,\n TStepId extends string,\n TStepMeta = unknown\n> = () => JourneySnapshot<TContext, TStepId, TStepMeta>;\n\ntype StepRendererFactoryProps<\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n> = {\n useJourneySnapshot: UseJourneySnapshot<TContext, TStepId, TStepMeta>;\n useJourneyStore: UseJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;\n};\n\nexport const createStepRenderer = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n>({\n useJourneySnapshot,\n useJourneyStore\n}: StepRendererFactoryProps<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>) => {\n const StepRenderer = ({ fallback = null }: { fallback?: React.ReactNode }) => {\n const snapshot = useJourneySnapshot();\n const { journey } = useJourneyStore(\"StepRenderer\");\n\n const StepComponent = journey.steps[snapshot.currentStepId]?.component;\n\n if (!StepComponent) {\n return <>{fallback}</>;\n }\n\n return <StepComponent />;\n };\n\n return StepRenderer;\n};\n", "import React from \"react\";\n\nimport type { JourneyEvent, JourneyPayloadFor } from \"@rxova/journey-core\";\nimport type { JourneyEventType, JourneyReactEventPayloadMap, JourneyStoreValue } from \"../types\";\n\ntype UseJourneyStore<\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n> = (\n hookName?: string\n) => JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;\n\nexport const createUseJourneyApi = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n>(\n useJourneyStore: UseJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>\n) => {\n return () => {\n const machine = useJourneyStore(\"useJourneyApi\").machine;\n\n const send = React.useCallback(\n async (event: JourneyEvent<TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>) => {\n await machine.send(event);\n },\n [machine]\n );\n\n const goToNextStep = React.useCallback(async () => {\n await machine.goToNextStep();\n }, [machine]);\n\n const terminateJourney = React.useCallback(\n async (\n payload?: JourneyPayloadFor<\n JourneyEventType<TCustomEvent>,\n TEventPayloadMap,\n \"terminateJourney\"\n >\n ) => {\n await machine.terminateJourney(payload);\n },\n [machine]\n );\n\n const completeJourney = React.useCallback(\n async (\n payload?: JourneyPayloadFor<\n JourneyEventType<TCustomEvent>,\n TEventPayloadMap,\n \"completeJourney\"\n >\n ) => {\n await machine.completeJourney(payload);\n },\n [machine]\n );\n\n const goToPreviousStep = React.useCallback(\n async (steps?: number) => {\n await machine.goToPreviousStep(steps);\n },\n [machine]\n );\n\n const goToLastVisitedStep = React.useCallback(async () => {\n await machine.goToLastVisitedStep();\n }, [machine]);\n\n const updateContext = React.useCallback(\n (updater: (context: TContext) => TContext) => {\n machine.updateContext(updater);\n },\n [machine]\n );\n\n const updateStepMetadata = React.useCallback(\n (stepId: TStepId, updater: (metadata: TStepMeta) => TStepMeta) => {\n machine.updateStepMetadata(stepId, updater);\n },\n [machine]\n );\n\n const clearStepError = React.useCallback(\n (stepId?: TStepId) => {\n machine.clearStepError(stepId);\n },\n [machine]\n );\n\n const resetJourney = React.useCallback(() => {\n machine.resetMachine();\n }, [machine]);\n\n return {\n send,\n goToNextStep,\n terminateJourney,\n completeJourney,\n goToPreviousStep,\n goToLastVisitedStep,\n clearStepError,\n updateContext,\n updateStepMetadata,\n updateComponentMetadata: updateStepMetadata,\n resetJourney\n };\n };\n};\n", "import type { JourneyReactEventPayloadMap, JourneyStoreValue } from \"../types\";\n\ntype UseJourneyStore<\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n> = (\n hookName?: string\n) => JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;\n\nexport const createUseJourneyMachine = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n>(\n useJourneyStore: UseJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>\n) => {\n return () => {\n return useJourneyStore(\"useJourneyMachine\").machine;\n };\n};\n", "import React from \"react\";\n\nimport type { JourneySnapshot } from \"@rxova/journey-core\";\nimport type { JourneyReactEventPayloadMap, JourneyStoreValue } from \"../types\";\n\ntype UseJourneyStore<\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n> = (\n hookName?: string\n) => JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;\n\nexport const createUseJourneySnapshot = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n>(\n useJourneyStore: UseJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>\n) => {\n return (): JourneySnapshot<TContext, TStepId, TStepMeta> => {\n const { machine } = useJourneyStore(\"useJourneySnapshot\");\n return React.useSyncExternalStore(machine.subscribe, machine.getSnapshot, machine.getSnapshot);\n };\n};\n"],
|
|
5
|
+
"mappings": "ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uLAAAE,EAAA,uEAAAC,EAAAH,GCAA,IAAAI,EAAkB,sBCAlB,IAAAC,EAAkB,sBAElBC,EAAqC,+BAkF1BC,EAAA,6BAnDEC,EAAiB,CAM5B,CACA,eAAAC,EACA,aAAAC,CACF,IACmB,CAAC,CAChB,QAAAC,EACA,QAAAC,EACA,YAAAC,EACA,qBAAAC,EAAuB,GACvB,SAAAC,CACF,IAMM,CACJ,IAAMC,EAAkBL,GAAWD,EAC7BO,EAAqB,EAAAC,QAAM,OAG/B,IAAI,EACAC,EAAa,EAAAD,QAAM,OAAOF,CAAe,EACzCI,EAAiB,EAAAF,QAAM,OAAOL,CAAW,EAEzCQ,EAAsBP,GAAwBK,EAAW,UAAYH,EACrEM,EAAyBF,EAAe,UAAYP,EAE1D,GACE,CAACD,IACA,CAACK,EAAmB,SAAWI,GAAuBC,GACvD,CACA,IAAMC,EAAUV,EAAc,CAAE,YAAAA,CAAY,EAAI,OAChDI,EAAmB,WAAU,wBAAqBD,EAAiBO,CAAO,EAC1EJ,EAAW,QAAUH,EACrBI,EAAe,QAAUP,CAC3B,CAEA,IAAMW,EAAkBZ,GAAWK,EAA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gBAAAH,CACF,CAAC,EAED,MAAO,CACL,SAAAS,EACA,aAAAE,EACA,cAAAJ,EACA,kBAAAF,EACA,mBAAAF,CACF,CACF,EDzDA,IAAAU,EAOO",
|
|
6
|
+
"names": ["index_exports", "__export", "createJourneyBindings", "__toCommonJS", "import_react", "import_react", "import_journey_core", "import_jsx_runtime", "createProvider", "JourneyContext", "boundJourney", "journey", "machine", "persistence", "resetOnJourneyChange", "children", "incomingJourney", "internalMachineRef", "React", "journeyRef", "persistenceRef", "shouldResetInternal", "shouldResetPersistence", "options", "resolvedMachine", "resolvedJourney", "value", "import_jsx_runtime", "createStepRenderer", "useJourneySnapshot", "useJourneyStore", "fallback", "snapshot", "journey", "StepComponent", "import_react", "createUseJourneyApi", "useJourneyStore", "machine", "send", "React", "event", "goToNextStep", "terminateJourney", "payload", "completeJourney", "goToPreviousStep", "steps", "goToLastVisitedStep", "updateContext", "updater", "updateStepMetadata", "stepId", "clearStepError", "resetJourney", "createUseJourneyMachine", "useJourneyStore", "import_react", "createUseJourneySnapshot", "useJourneyStore", "machine", "React", "createJourneyBindings", "boundJourney", "JourneyContext", "React", "useJourneyStore", "hookName", "value", "useJourneySnapshot", "createUseJourneySnapshot", "useJourneyMachine", "createUseJourneyMachine", "useJourneyApi", "createUseJourneyApi", "Provider", "createProvider", "StepRenderer", "createStepRenderer", "import_journey_core"]
|
|
7
7
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export type { JourneyApi,
|
|
5
|
-
//# sourceMappingURL=index.d.cts.map
|
|
1
|
+
export { createJourneyBindings } from "./bindings";
|
|
2
|
+
export { createTransitions, tx, JOURNEY_STATUS, JOURNEY_EVENT, JOURNEY_ASYNC_PHASE, JOURNEY_WILDCARD } from "@rxova/journey-core";
|
|
3
|
+
export type { JourneyDefinition } from "@rxova/journey-core";
|
|
4
|
+
export type { JourneyApi, JourneyBindings, JourneyBindingsProviderProps, JourneyEventType, JourneyReactDefinition, JourneyReactEventPayloadMap, JourneyReactStep, JourneyStoreValue } from "./types";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export type { JourneyApi,
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export { createJourneyBindings } from "./bindings";
|
|
2
|
+
export { createTransitions, tx, JOURNEY_STATUS, JOURNEY_EVENT, JOURNEY_ASYNC_PHASE, JOURNEY_WILDCARD } from "@rxova/journey-core";
|
|
3
|
+
export type { JourneyDefinition } from "@rxova/journey-core";
|
|
4
|
+
export type { JourneyApi, JourneyBindings, JourneyBindingsProviderProps, JourneyEventType, JourneyReactDefinition, JourneyReactEventPayloadMap, JourneyReactStep, JourneyStoreValue } from "./types";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import
|
|
1
|
+
"use client";import x from"react";import S from"react";import{createJourneyMachine as I}from"@rxova/journey-core";import{jsx as h}from"react/jsx-runtime";var l=({JourneyContext:n,boundJourney:e})=>({journey:y,machine:a,persistence:o,resetOnJourneyChange:T=!1,children:d})=>{let s=y??e,u=S.useRef(null),v=S.useRef(s),c=S.useRef(o),t=T&&v.current!==s,i=c.current!==o;if(!a&&(!u.current||t||i)){let f=o?{persistence:o}:void 0;u.current=I(s,f),v.current=s,c.current=o}let P=a??u.current,R=a?s:v.current,g={machine:P,journey:R};return h(n.Provider,{value:g,children:d})};import{Fragment as k,jsx as E}from"react/jsx-runtime";var m=({useJourneySnapshot:n,useJourneyStore:e})=>({fallback:y=null})=>{let a=n(),{journey:o}=e("StepRenderer"),T=o.steps[a.currentStepId]?.component;return T?E(T,{}):E(k,{children:y})};import r from"react";var J=n=>()=>{let e=n("useJourneyApi").machine,p=r.useCallback(async t=>{await e.send(t)},[e]),y=r.useCallback(async()=>{await e.goToNextStep()},[e]),a=r.useCallback(async t=>{await e.terminateJourney(t)},[e]),o=r.useCallback(async t=>{await e.completeJourney(t)},[e]),T=r.useCallback(async t=>{await e.goToPreviousStep(t)},[e]),d=r.useCallback(async()=>{await e.goToLastVisitedStep()},[e]),s=r.useCallback(t=>{e.updateContext(t)},[e]),u=r.useCallback((t,i)=>{e.updateStepMetadata(t,i)},[e]),v=r.useCallback(t=>{e.clearStepError(t)},[e]),c=r.useCallback(()=>{e.resetMachine()},[e]);return{send:p,goToNextStep:y,terminateJourney:a,completeJourney:o,goToPreviousStep:T,goToLastVisitedStep:d,clearStepError:v,updateContext:s,updateStepMetadata:u,updateComponentMetadata:u,resetJourney:c}};var C=n=>()=>n("useJourneyMachine").machine;import w from"react";var M=n=>()=>{let{machine:e}=n("useJourneySnapshot");return w.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)};var U=n=>{let e=x.createContext(null),p=(s="hook")=>{let u=x.useContext(e);if(!u)throw new Error(`${s} must be used within bindings.Provider.`);return u},y=M(p),a=C(p),o=J(p),T=l({JourneyContext:e,boundJourney:n}),d=m({useJourneySnapshot:y,useJourneyStore:p});return{Provider:T,StepRenderer:d,useJourneyApi:o,useJourneyMachine:a,useJourneySnapshot:y}};import{createTransitions as Z,tx as ee,JOURNEY_STATUS as te,JOURNEY_EVENT as ne,JOURNEY_ASYNC_PHASE as oe,JOURNEY_WILDCARD as re}from"@rxova/journey-core";export{oe as JOURNEY_ASYNC_PHASE,ne as JOURNEY_EVENT,te as JOURNEY_STATUS,re as JOURNEY_WILDCARD,U as createJourneyBindings,Z as createTransitions,ee as tx};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/
|
|
4
|
-
"sourcesContent": ["import React from \"react\";\n\nimport { createJourneyMachine } from \"@rxova/journey-core\";\nimport type { JourneyProviderProps, JourneyReactEventPayloadMap, JourneyStoreValue } from \"./types\";\n\nconst JourneyContext = React.createContext<JourneyStoreValue<\n unknown,\n string,\n string,\n Record<never, never>\n> | null>(null);\n\n/**\n * React provider that supplies the journey machine and definition to hooks.\n */\nexport const JourneyProvider = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>\n>({\n journey,\n machine,\n persistence,\n history,\n resetOnJourneyChange = false,\n children\n}: JourneyProviderProps<TContext, TStepId, TCustomEvent, TEventPayloadMap>) => {\n const internalMachineRef = React.useRef<\n JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap>[\"machine\"] | null\n >(null);\n const journeyRef = React.useRef(journey);\n const persistenceRef = React.useRef(persistence);\n const historyRef = React.useRef(history);\n\n const shouldResetInternal = resetOnJourneyChange && journeyRef.current !== journey;\n const shouldResetPersistence = persistenceRef.current !== persistence;\n const shouldResetHistory = historyRef.current !== history;\n\n if (\n !machine &&\n (!internalMachineRef.current ||\n shouldResetInternal ||\n shouldResetPersistence ||\n shouldResetHistory)\n ) {\n const options =\n persistence || history\n ? {\n ...(persistence ? { persistence } : {}),\n ...(history ? { history } : {})\n }\n : undefined;\n internalMachineRef.current = createJourneyMachine(journey, options);\n journeyRef.current = journey;\n persistenceRef.current = persistence;\n historyRef.current = history;\n }\n\n const resolvedMachine = machine ?? internalMachineRef.current!;\n const resolvedJourney = machine ? journey : journeyRef.current;\n\n return (\n <JourneyContext.Provider\n value={\n {\n machine: resolvedMachine,\n journey: resolvedJourney\n } as unknown as JourneyStoreValue<unknown, string, string>\n }\n >\n {children}\n </JourneyContext.Provider>\n );\n};\n\nexport const useJourneyStore = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>\n>(\n hookName = \"useJourney\"\n): JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap> => {\n const value = React.useContext(JourneyContext);\n if (!value) {\n throw new Error(`${hookName} must be used within <JourneyProvider>.`);\n }\n\n return value as unknown as JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap>;\n};\n", "import React from \"react\";\n\nimport { JOURNEY_EVENT } from \"@rxova/journey-core\";\nimport type {\n JourneyEvent,\n JourneyMachine,\n JourneyPayloadFor,\n JourneySnapshot\n} from \"@rxova/journey-core\";\nimport { useJourneyStore } from \"./context\";\nimport type {\n JourneyDefaultEvent,\n JourneyEventType,\n JourneyHookResult,\n JourneyReactEventPayloadMap\n} from \"./types\";\n\nconst useSnapshot = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>\n>(): JourneySnapshot<TContext, TStepId> => {\n const { machine } = useJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap>(\n \"useJourneySnapshot\"\n );\n\n return React.useSyncExternalStore(machine.subscribe, machine.getSnapshot, machine.getSnapshot);\n};\n\n/**\n * Reads the current journey snapshot and re-renders on changes.\n */\nexport const useJourneySnapshot = useSnapshot;\n\n/**\n * Returns the underlying journey machine from provider context.\n */\nexport const useJourneyMachine = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>\n>(): JourneyMachine<TContext, TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap> => {\n const { machine } = useJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap>(\n \"useJourneyMachine\"\n );\n return machine;\n};\n\n/**\n * Returns imperative journey actions (send, goTo, next, back, close, submit).\n */\nexport const useJourneyApi = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>\n>() => {\n const { machine } = useJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap>(\n \"useJourneyApi\"\n );\n\n const send = React.useCallback(\n async (event: JourneyEvent<TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>) => {\n await machine.send(event);\n },\n [machine]\n );\n\n const goTo = React.useCallback(\n async (\n stepId: TStepId,\n payload?: JourneyPayloadFor<\n JourneyEventType<TCustomEvent>,\n TEventPayloadMap,\n (typeof JOURNEY_EVENT)[\"GO_TO\"]\n >\n ) => {\n if (payload === undefined) {\n await machine.send({\n type: JOURNEY_EVENT.GO_TO,\n to: stepId\n } as JourneyEvent<TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>);\n return;\n }\n\n await machine.send({\n type: JOURNEY_EVENT.GO_TO,\n to: stepId,\n payload\n } as JourneyEvent<TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>);\n },\n [machine]\n );\n\n const sendDefault = React.useCallback(\n async <TType extends JourneyDefaultEvent>(\n type: TType,\n payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, TType>\n ) => {\n const event =\n payload === undefined\n ? ({ type } as unknown as JourneyEvent<\n TStepId,\n JourneyEventType<TCustomEvent>,\n TEventPayloadMap\n >)\n : ({\n type,\n payload\n } as unknown as JourneyEvent<\n TStepId,\n JourneyEventType<TCustomEvent>,\n TEventPayloadMap\n >);\n await machine.send(event);\n },\n [machine]\n );\n\n const next = React.useCallback(\n async (\n payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, \"next\">\n ) => {\n await sendDefault(\"next\", payload);\n },\n [sendDefault]\n );\n\n const back = React.useCallback(\n async (\n payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, \"back\">\n ) => {\n await sendDefault(\"back\", payload);\n },\n [sendDefault]\n );\n\n const close = React.useCallback(\n async (\n payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, \"close\">\n ) => {\n await sendDefault(\"close\", payload);\n },\n [sendDefault]\n );\n\n const submit = React.useCallback(\n async (\n payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, \"submit\">\n ) => {\n await sendDefault(\"submit\", payload);\n },\n [sendDefault]\n );\n\n const updateContext = React.useCallback(\n (updater: (context: TContext) => TContext) => {\n machine.updateContext(updater);\n },\n [machine]\n );\n\n const clearStepError = React.useCallback(\n (stepId?: TStepId) => {\n machine.clearStepError(stepId);\n },\n [machine]\n );\n\n const reset = React.useCallback(() => {\n machine.reset();\n }, [machine]);\n\n const trimHistory = React.useCallback(\n (maxHistory?: number | null) => {\n machine.trimHistory(maxHistory);\n },\n [machine]\n );\n\n const clearHistory = React.useCallback(() => {\n machine.clearHistory();\n }, [machine]);\n\n return {\n send,\n goTo,\n next,\n back,\n close,\n submit,\n clearStepError,\n updateContext,\n reset,\n trimHistory,\n clearHistory\n };\n};\n\n/**\n * Combined hook that returns both snapshot and API helpers.\n */\nexport const useJourney = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>\n>(): JourneyHookResult<TContext, TStepId, TCustomEvent, TEventPayloadMap> => {\n useJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap>(\"useJourney\");\n const snapshot = useJourneySnapshot<TContext, TStepId, TCustomEvent, TEventPayloadMap>();\n const api = useJourneyApi<TContext, TStepId, TCustomEvent, TEventPayloadMap>();\n\n return {\n snapshot,\n api\n };\n};\n", "import React from \"react\";\n\nimport { useJourneyStore } from \"./context\";\nimport { useJourneySnapshot } from \"./hooks\";\n\ntype JourneyStepRendererProps = {\n fallback?: React.ReactNode;\n};\n\n/**\n * Renders the active step component from the journey definition.\n */\nexport const JourneyStepRenderer = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never\n>({\n fallback = null\n}: JourneyStepRendererProps) => {\n const snapshot = useJourneySnapshot<TContext, TStepId, TCustomEvent>();\n const { journey } = useJourneyStore<TContext, TStepId, TCustomEvent>();\n\n const StepComponent = journey.steps[snapshot.current]?.component;\n\n if (!StepComponent) {\n return <>{fallback}</>;\n }\n\n return <StepComponent />;\n};\n"],
|
|
5
|
-
"mappings": "aAAA,OAAOA,MAAW,QAElB,OAAS,wBAAAC,MAA4B,
|
|
6
|
-
"names": ["React", "createJourneyMachine", "jsx", "JourneyContext", "
|
|
3
|
+
"sources": ["../src/bindings/index.tsx", "../src/bindings/Provider.tsx", "../src/bindings/StepRenderer.tsx", "../src/bindings/useJourneyApi.ts", "../src/bindings/useJourneyMachine.ts", "../src/bindings/useJourneySnapshot.ts", "../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["import React from \"react\";\n\nimport type {\n JourneyBindings,\n JourneyReactDefinition,\n JourneyReactEventPayloadMap,\n JourneyStoreValue\n} from \"../types\";\nimport { createProvider } from \"./Provider\";\nimport { createStepRenderer } from \"./StepRenderer\";\nimport { createUseJourneyApi } from \"./useJourneyApi\";\nimport { createUseJourneyMachine } from \"./useJourneyMachine\";\nimport { createUseJourneySnapshot } from \"./useJourneySnapshot\";\n\nexport const createJourneyBindings = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n>(\n boundJourney: JourneyReactDefinition<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>\n): JourneyBindings<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta> => {\n const JourneyContext = React.createContext<JourneyStoreValue<\n TContext,\n TStepId,\n TCustomEvent,\n TEventPayloadMap,\n TStepMeta\n > | null>(null);\n\n const useJourneyStore = (hookName = \"hook\") => {\n const value = React.useContext(JourneyContext);\n if (!value) {\n throw new Error(`${hookName} must be used within bindings.Provider.`);\n }\n return value;\n };\n\n const useJourneySnapshot = createUseJourneySnapshot(useJourneyStore);\n const useJourneyMachine = createUseJourneyMachine(useJourneyStore);\n const useJourneyApi = createUseJourneyApi(useJourneyStore);\n\n const Provider = createProvider({\n JourneyContext,\n boundJourney\n });\n\n const StepRenderer = createStepRenderer({\n useJourneySnapshot,\n useJourneyStore\n });\n\n return {\n Provider,\n StepRenderer,\n useJourneyApi,\n useJourneyMachine,\n useJourneySnapshot\n };\n};\n", "import React from \"react\";\n\nimport { createJourneyMachine } from \"@rxova/journey-core\";\nimport type {\n JourneyBindingsProviderProps,\n JourneyReactDefinition,\n JourneyReactEventPayloadMap,\n JourneyStoreValue\n} from \"../types\";\n\ntype ProviderFactoryProps<\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n> = {\n JourneyContext: React.Context<JourneyStoreValue<\n TContext,\n TStepId,\n TCustomEvent,\n TEventPayloadMap,\n TStepMeta\n > | null>;\n boundJourney: JourneyReactDefinition<\n TContext,\n TStepId,\n TCustomEvent,\n TEventPayloadMap,\n TStepMeta\n >;\n};\n\nexport const createProvider = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n>({\n JourneyContext,\n boundJourney\n}: ProviderFactoryProps<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>) => {\n const Provider = ({\n journey,\n machine,\n persistence,\n resetOnJourneyChange = false,\n children\n }: JourneyBindingsProviderProps<\n TContext,\n TStepId,\n TCustomEvent,\n TEventPayloadMap,\n TStepMeta\n >) => {\n const incomingJourney = journey ?? boundJourney;\n const internalMachineRef = React.useRef<\n | JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>[\"machine\"]\n | null\n >(null);\n const journeyRef = React.useRef(incomingJourney);\n const persistenceRef = React.useRef(persistence);\n\n const shouldResetInternal = resetOnJourneyChange && journeyRef.current !== incomingJourney;\n const shouldResetPersistence = persistenceRef.current !== persistence;\n\n if (\n !machine &&\n (!internalMachineRef.current || shouldResetInternal || shouldResetPersistence)\n ) {\n const options = persistence ? { persistence } : undefined;\n internalMachineRef.current = createJourneyMachine(incomingJourney, options);\n journeyRef.current = incomingJourney;\n persistenceRef.current = persistence;\n }\n\n const resolvedMachine = machine ?? internalMachineRef.current!;\n const resolvedJourney = machine ? incomingJourney : journeyRef.current;\n const value: JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta> = {\n machine: resolvedMachine,\n journey: resolvedJourney\n };\n\n return <JourneyContext.Provider value={value}>{children}</JourneyContext.Provider>;\n };\n\n return Provider;\n};\n", "import React from \"react\";\n\nimport type { JourneySnapshot } from \"@rxova/journey-core\";\nimport type { JourneyReactEventPayloadMap, JourneyStoreValue } from \"../types\";\n\ntype UseJourneyStore<\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n> = (\n hookName?: string\n) => JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;\n\ntype UseJourneySnapshot<\n TContext,\n TStepId extends string,\n TStepMeta = unknown\n> = () => JourneySnapshot<TContext, TStepId, TStepMeta>;\n\ntype StepRendererFactoryProps<\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n> = {\n useJourneySnapshot: UseJourneySnapshot<TContext, TStepId, TStepMeta>;\n useJourneyStore: UseJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;\n};\n\nexport const createStepRenderer = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n>({\n useJourneySnapshot,\n useJourneyStore\n}: StepRendererFactoryProps<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>) => {\n const StepRenderer = ({ fallback = null }: { fallback?: React.ReactNode }) => {\n const snapshot = useJourneySnapshot();\n const { journey } = useJourneyStore(\"StepRenderer\");\n\n const StepComponent = journey.steps[snapshot.currentStepId]?.component;\n\n if (!StepComponent) {\n return <>{fallback}</>;\n }\n\n return <StepComponent />;\n };\n\n return StepRenderer;\n};\n", "import React from \"react\";\n\nimport type { JourneyEvent, JourneyPayloadFor } from \"@rxova/journey-core\";\nimport type { JourneyEventType, JourneyReactEventPayloadMap, JourneyStoreValue } from \"../types\";\n\ntype UseJourneyStore<\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n> = (\n hookName?: string\n) => JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;\n\nexport const createUseJourneyApi = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n>(\n useJourneyStore: UseJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>\n) => {\n return () => {\n const machine = useJourneyStore(\"useJourneyApi\").machine;\n\n const send = React.useCallback(\n async (event: JourneyEvent<TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>) => {\n await machine.send(event);\n },\n [machine]\n );\n\n const goToNextStep = React.useCallback(async () => {\n await machine.goToNextStep();\n }, [machine]);\n\n const terminateJourney = React.useCallback(\n async (\n payload?: JourneyPayloadFor<\n JourneyEventType<TCustomEvent>,\n TEventPayloadMap,\n \"terminateJourney\"\n >\n ) => {\n await machine.terminateJourney(payload);\n },\n [machine]\n );\n\n const completeJourney = React.useCallback(\n async (\n payload?: JourneyPayloadFor<\n JourneyEventType<TCustomEvent>,\n TEventPayloadMap,\n \"completeJourney\"\n >\n ) => {\n await machine.completeJourney(payload);\n },\n [machine]\n );\n\n const goToPreviousStep = React.useCallback(\n async (steps?: number) => {\n await machine.goToPreviousStep(steps);\n },\n [machine]\n );\n\n const goToLastVisitedStep = React.useCallback(async () => {\n await machine.goToLastVisitedStep();\n }, [machine]);\n\n const updateContext = React.useCallback(\n (updater: (context: TContext) => TContext) => {\n machine.updateContext(updater);\n },\n [machine]\n );\n\n const updateStepMetadata = React.useCallback(\n (stepId: TStepId, updater: (metadata: TStepMeta) => TStepMeta) => {\n machine.updateStepMetadata(stepId, updater);\n },\n [machine]\n );\n\n const clearStepError = React.useCallback(\n (stepId?: TStepId) => {\n machine.clearStepError(stepId);\n },\n [machine]\n );\n\n const resetJourney = React.useCallback(() => {\n machine.resetMachine();\n }, [machine]);\n\n return {\n send,\n goToNextStep,\n terminateJourney,\n completeJourney,\n goToPreviousStep,\n goToLastVisitedStep,\n clearStepError,\n updateContext,\n updateStepMetadata,\n updateComponentMetadata: updateStepMetadata,\n resetJourney\n };\n };\n};\n", "import type { JourneyReactEventPayloadMap, JourneyStoreValue } from \"../types\";\n\ntype UseJourneyStore<\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n> = (\n hookName?: string\n) => JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;\n\nexport const createUseJourneyMachine = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n>(\n useJourneyStore: UseJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>\n) => {\n return () => {\n return useJourneyStore(\"useJourneyMachine\").machine;\n };\n};\n", "import React from \"react\";\n\nimport type { JourneySnapshot } from \"@rxova/journey-core\";\nimport type { JourneyReactEventPayloadMap, JourneyStoreValue } from \"../types\";\n\ntype UseJourneyStore<\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n> = (\n hookName?: string\n) => JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;\n\nexport const createUseJourneySnapshot = <\n TContext,\n TStepId extends string,\n TCustomEvent extends string = never,\n TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>,\n TStepMeta = unknown\n>(\n useJourneyStore: UseJourneyStore<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>\n) => {\n return (): JourneySnapshot<TContext, TStepId, TStepMeta> => {\n const { machine } = useJourneyStore(\"useJourneySnapshot\");\n return React.useSyncExternalStore(machine.subscribe, machine.getSnapshot, machine.getSnapshot);\n };\n};\n", "\"use client\";\n\nexport { createJourneyBindings } from \"./bindings\";\nexport {\n createTransitions,\n tx,\n JOURNEY_STATUS,\n JOURNEY_EVENT,\n JOURNEY_ASYNC_PHASE,\n JOURNEY_WILDCARD\n} from \"@rxova/journey-core\";\nexport type { JourneyDefinition } from \"@rxova/journey-core\";\nexport type {\n JourneyApi,\n JourneyBindings,\n JourneyBindingsProviderProps,\n JourneyEventType,\n JourneyReactDefinition,\n JourneyReactEventPayloadMap,\n JourneyReactStep,\n JourneyStoreValue\n} from \"./types\";\n"],
|
|
5
|
+
"mappings": "aAAA,OAAOA,MAAW,QCAlB,OAAOC,MAAW,QAElB,OAAS,wBAAAC,MAA4B,sBAkF1B,cAAAC,MAAA,oBAnDJ,IAAMC,EAAiB,CAM5B,CACA,eAAAC,EACA,aAAAC,CACF,IACmB,CAAC,CAChB,QAAAC,EACA,QAAAC,EACA,YAAAC,EACA,qBAAAC,EAAuB,GACvB,SAAAC,CACF,IAMM,CACJ,IAAMC,EAAkBL,GAAWD,EAC7BO,EAAqBZ,EAAM,OAG/B,IAAI,EACAa,EAAab,EAAM,OAAOW,CAAe,EACzCG,EAAiBd,EAAM,OAAOQ,CAAW,EAEzCO,EAAsBN,GAAwBI,EAAW,UAAYF,EACrEK,EAAyBF,EAAe,UAAYN,EAE1D,GACE,CAACD,IACA,CAACK,EAAmB,SAAWG,GA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EAAoBC,EAAwBN,CAAe,EAC3DO,EAAgBC,EAAoBR,CAAe,EAEnDS,EAAWC,EAAe,CAC9B,eAAAZ,EACA,aAAAD,CACF,CAAC,EAEKc,EAAeC,EAAmB,CACtC,mBAAAT,EACA,gBAAAH,CACF,CAAC,EAED,MAAO,CACL,SAAAS,EACA,aAAAE,EACA,cAAAJ,EACA,kBAAAF,EACA,mBAAAF,CACF,CACF,EMzDA,OACE,qBAAAU,EACA,MAAAC,GACA,kBAAAC,GACA,iBAAAC,GACA,uBAAAC,GACA,oBAAAC,OACK",
|
|
6
|
+
"names": ["React", "React", "createJourneyMachine", "jsx", "createProvider", "JourneyContext", "boundJourney", "journey", "machine", "persistence", "resetOnJourneyChange", "children", "incomingJourney", "internalMachineRef", "journeyRef", "persistenceRef", "shouldResetInternal", "shouldResetPersistence", "options", "resolvedMachine", "resolvedJourney", "value", "Fragment", "jsx", "createStepRenderer", "useJourneySnapshot", "useJourneyStore", "fallback", "snapshot", "journey", "StepComponent", "React", "createUseJourneyApi", "useJourneyStore", "machine", "send", "event", "goToNextStep", "terminateJourney", "payload", "completeJourney", "goToPreviousStep", "steps", "goToLastVisitedStep", "updateContext", "updater", "updateStepMetadata", "stepId", "clearStepError", "resetJourney", "createUseJourneyMachine", "useJourneyStore", "React", "createUseJourneySnapshot", "useJourneyStore", "machine", "createJourneyBindings", "boundJourney", "JourneyContext", "React", "useJourneyStore", "hookName", "value", "useJourneySnapshot", "createUseJourneySnapshot", "useJourneyMachine", "createUseJourneyMachine", "useJourneyApi", "createUseJourneyApi", "Provider", "createProvider", "StepRenderer", "createStepRenderer", "createTransitions", "tx", "JOURNEY_STATUS", "JOURNEY_EVENT", "JOURNEY_ASYNC_PHASE", "JOURNEY_WILDCARD"]
|
|
7
7
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,41 +1,44 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
|
-
import type {
|
|
3
|
-
export type JourneyDefaultEvent = "
|
|
2
|
+
import type { JourneyDefinition, JourneyEvent, JourneyEventPayloadMap as JourneyCoreEventPayloadMap, JourneyMachine, JourneyPayloadFor, JourneyPersistenceOptions, JourneySnapshot, JourneyStepDefinition } from "@rxova/journey-core";
|
|
3
|
+
export type JourneyDefaultEvent = "goToNextStep" | "goToPreviousStep" | "terminateJourney" | "completeJourney";
|
|
4
4
|
export type JourneyEventType<TCustomEvent extends string = never> = JourneyDefaultEvent | TCustomEvent;
|
|
5
5
|
export type JourneyReactEventPayloadMap<TCustomEvent extends string = never> = JourneyCoreEventPayloadMap<JourneyEventType<TCustomEvent>>;
|
|
6
|
-
export type JourneyReactStep = {
|
|
6
|
+
export type JourneyReactStep<TStepMeta = unknown> = JourneyStepDefinition<TStepMeta> & {
|
|
7
7
|
component: React.ComponentType;
|
|
8
8
|
};
|
|
9
|
-
export type JourneyReactDefinition<TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never
|
|
10
|
-
steps: Record<TStepId, JourneyReactStep
|
|
9
|
+
export type JourneyReactDefinition<TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown> = Omit<JourneyDefinition<TContext, TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap, TStepMeta>, "steps"> & {
|
|
10
|
+
steps: Record<TStepId, JourneyReactStep<TStepMeta>>;
|
|
11
11
|
};
|
|
12
|
-
export type JourneyApi<TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never
|
|
12
|
+
export type JourneyApi<TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown> = {
|
|
13
13
|
send: (event: JourneyEvent<TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>) => Promise<void>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
goToNextStep: () => Promise<void>;
|
|
15
|
+
terminateJourney: (payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, "terminateJourney">) => Promise<void>;
|
|
16
|
+
completeJourney: (payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, "completeJourney">) => Promise<void>;
|
|
17
|
+
goToPreviousStep: (steps?: number) => Promise<void>;
|
|
18
|
+
goToLastVisitedStep: () => Promise<void>;
|
|
19
19
|
clearStepError: (stepId?: TStepId) => void;
|
|
20
20
|
updateContext: (updater: (context: TContext) => TContext) => void;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
updateComponentMetadata: (stepId: TStepId, updater: (metadata: TStepMeta) => TStepMeta) => void;
|
|
22
|
+
updateStepMetadata: (stepId: TStepId, updater: (metadata: TStepMeta) => TStepMeta) => void;
|
|
23
|
+
resetJourney: () => void;
|
|
24
24
|
};
|
|
25
|
-
export type
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
export type JourneyStoreValue<TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown> = {
|
|
26
|
+
machine: JourneyMachine<TContext, TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap, TStepMeta>;
|
|
27
|
+
journey: JourneyReactDefinition<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;
|
|
28
28
|
};
|
|
29
|
-
export type
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
export type JourneyProviderProps<TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>> = {
|
|
34
|
-
journey: JourneyReactDefinition<TContext, TStepId, TCustomEvent, TEventPayloadMap>;
|
|
35
|
-
machine?: JourneyMachine<TContext, TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>;
|
|
36
|
-
persistence?: JourneyPersistenceOptions<TContext, TStepId>;
|
|
37
|
-
history?: JourneyHistoryOptions<TStepId>;
|
|
29
|
+
export type JourneyBindingsProviderProps<TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown> = {
|
|
30
|
+
journey?: JourneyReactDefinition<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;
|
|
31
|
+
machine?: JourneyMachine<TContext, TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap, TStepMeta>;
|
|
32
|
+
persistence?: JourneyPersistenceOptions<TContext, TStepId, TStepMeta>;
|
|
38
33
|
resetOnJourneyChange?: boolean;
|
|
39
34
|
children: React.ReactNode;
|
|
40
35
|
};
|
|
41
|
-
|
|
36
|
+
export type JourneyBindings<TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown> = {
|
|
37
|
+
Provider: React.ComponentType<JourneyBindingsProviderProps<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>>;
|
|
38
|
+
StepRenderer: React.ComponentType<{
|
|
39
|
+
fallback?: React.ReactNode;
|
|
40
|
+
}>;
|
|
41
|
+
useJourneyApi: () => JourneyApi<TContext, TStepId, TCustomEvent, TEventPayloadMap, TStepMeta>;
|
|
42
|
+
useJourneyMachine: () => JourneyMachine<TContext, TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap, TStepMeta>;
|
|
43
|
+
useJourneySnapshot: () => JourneySnapshot<TContext, TStepId, TStepMeta>;
|
|
44
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxova/journey-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "React bindings for journey.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
],
|
|
48
48
|
"sideEffects": false,
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@rxova/journey-core": "^0.
|
|
50
|
+
"@rxova/journey-core": "^0.6.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": ">=18.2.0"
|
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
},
|
|
60
60
|
"size-limit": [
|
|
61
61
|
{
|
|
62
|
-
"name": "react/
|
|
62
|
+
"name": "react/createJourneyBindings",
|
|
63
63
|
"path": "dist/index.js",
|
|
64
|
-
"import": "{
|
|
65
|
-
"limit": "
|
|
64
|
+
"import": "{ createJourneyBindings }",
|
|
65
|
+
"limit": "5 kB"
|
|
66
66
|
}
|
|
67
67
|
],
|
|
68
68
|
"devDependencies": {
|
|
@@ -74,7 +74,8 @@
|
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"build": "pnpm run clean && node ./scripts/build.mjs && tsc -p tsconfig.build.json && node ../../scripts/copy-types.mjs dist",
|
|
77
|
-
"clean": "rm -rf dist",
|
|
77
|
+
"clean": "rm -rf dist tsconfig.build.tsbuildinfo",
|
|
78
|
+
"coverage": "pnpm --workspace-root vitest run --coverage --coverage.include=packages/react/src/** --coverage.reporter=text-summary",
|
|
78
79
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
79
80
|
"publint": "publint",
|
|
80
81
|
"attw": "attw --pack .",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
type JourneyStepRendererProps = {
|
|
3
|
-
fallback?: React.ReactNode;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* Renders the active step component from the journey definition.
|
|
7
|
-
*/
|
|
8
|
-
export declare const JourneyStepRenderer: <TContext, TStepId extends string, TCustomEvent extends string = never>({ fallback }: JourneyStepRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=JourneyStepRenderer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JourneyStepRenderer.d.ts","sourceRoot":"","sources":["../src/JourneyStepRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,KAAK,wBAAwB,GAAG;IAC9B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,EACR,OAAO,SAAS,MAAM,EACtB,YAAY,SAAS,MAAM,GAAG,KAAK,EACnC,cAEC,wBAAwB,4CAW1B,CAAC"}
|
package/dist/context.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { JourneyProviderProps, JourneyReactEventPayloadMap, JourneyStoreValue } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* React provider that supplies the journey machine and definition to hooks.
|
|
4
|
-
*/
|
|
5
|
-
export declare const JourneyProvider: <TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>>({ journey, machine, persistence, history, resetOnJourneyChange, children }: JourneyProviderProps<TContext, TStepId, TCustomEvent, TEventPayloadMap>) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
export declare const useJourneyStore: <TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>>(hookName?: string) => JourneyStoreValue<TContext, TStepId, TCustomEvent, TEventPayloadMap>;
|
|
7
|
-
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AASpG;;GAEG;AACH,eAAO,MAAM,eAAe,GAC1B,QAAQ,EACR,OAAO,SAAS,MAAM,EACtB,YAAY,SAAS,MAAM,GAAG,KAAK,EACnC,gBAAgB,SAAS,2BAA2B,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EACzF,4EAOC,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,CAAC,4CA+CzE,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,QAAQ,EACR,OAAO,SAAS,MAAM,EACtB,YAAY,SAAS,MAAM,GAAG,KAAK,EACnC,gBAAgB,SAAS,2BAA2B,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAEzF,iBAAuB,KACtB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,CAOrE,CAAC"}
|
package/dist/hooks.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { JOURNEY_EVENT } from "@rxova/journey-core";
|
|
2
|
-
import type { JourneyEvent, JourneyMachine, JourneyPayloadFor, JourneySnapshot } from "@rxova/journey-core";
|
|
3
|
-
import type { JourneyEventType, JourneyHookResult, JourneyReactEventPayloadMap } from "./types";
|
|
4
|
-
/**
|
|
5
|
-
* Reads the current journey snapshot and re-renders on changes.
|
|
6
|
-
*/
|
|
7
|
-
export declare const useJourneySnapshot: <TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>>() => JourneySnapshot<TContext, TStepId>;
|
|
8
|
-
/**
|
|
9
|
-
* Returns the underlying journey machine from provider context.
|
|
10
|
-
*/
|
|
11
|
-
export declare const useJourneyMachine: <TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>>() => JourneyMachine<TContext, TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>;
|
|
12
|
-
/**
|
|
13
|
-
* Returns imperative journey actions (send, goTo, next, back, close, submit).
|
|
14
|
-
*/
|
|
15
|
-
export declare const useJourneyApi: <TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>>() => {
|
|
16
|
-
send: (event: JourneyEvent<TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>) => Promise<void>;
|
|
17
|
-
goTo: (stepId: TStepId, payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, (typeof JOURNEY_EVENT)["GO_TO"]>) => Promise<void>;
|
|
18
|
-
next: (payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, "next">) => Promise<void>;
|
|
19
|
-
back: (payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, "back">) => Promise<void>;
|
|
20
|
-
close: (payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, "close">) => Promise<void>;
|
|
21
|
-
submit: (payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, "submit">) => Promise<void>;
|
|
22
|
-
clearStepError: (stepId?: TStepId) => void;
|
|
23
|
-
updateContext: (updater: (context: TContext) => TContext) => void;
|
|
24
|
-
reset: () => void;
|
|
25
|
-
trimHistory: (maxHistory?: number | null) => void;
|
|
26
|
-
clearHistory: () => void;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Combined hook that returns both snapshot and API helpers.
|
|
30
|
-
*/
|
|
31
|
-
export declare const useJourney: <TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>>() => JourneyHookResult<TContext, TStepId, TCustomEvent, TEventPayloadMap>;
|
|
32
|
-
//# sourceMappingURL=hooks.d.ts.map
|
package/dist/hooks.d.ts.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,CAChC;qBA8CS,iBAAiB,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAAE,gBAAgB,EAAE,MAAM,CAAC;qBAS3E,iBAAiB,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAAE,gBAAgB,EAAE,MAAM,CAAC;sBAS3E,iBAAiB,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAAE,gBAAgB,EAAE,OAAO,CAAC;uBAS5E,iBAAiB,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAAE,gBAAgB,EAAE,QAAQ,CAAC;8BAe/E,OAAO;6BAPP,CAAC,OAAO,EAAE,QAAQ,KAAK,QAAQ;;+BAkB3B,MAAM,GAAG,IAAI;;CAuB9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,GACrB,QAAQ,EACR,OAAO,SAAS,MAAM,EACtB,YAAY,SAAS,MAAM,GAAG,KAAK,EACnC,gBAAgB,SAAS,2BAA2B,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,OACtF,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,CASvE,CAAC"}
|
package/dist/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC3F,YAAY,EACV,UAAU,EACV,2BAA2B,EAC3B,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,SAAS,CAAC"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC3F,YAAY,EACV,UAAU,EACV,2BAA2B,EAC3B,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"fileNames":["../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.scripthost.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.full.d.ts","../../../node_modules/.pnpm/@types+react@19.2.13/node_modules/@types/react/global.d.ts","../../../node_modules/.pnpm/csstype@3.2.3/node_modules/csstype/index.d.ts","../../../node_modules/.pnpm/@types+react@19.2.13/node_modules/@types/react/index.d.ts","../../../node_modules/.pnpm/@types+react@19.2.13/node_modules/@types/react/jsx-runtime.d.ts","../../core/dist/types.d.ts","../../core/dist/machine.d.ts","../../core/dist/persistence.d.ts","../../core/dist/index.d.ts","../src/types.ts","../src/context.tsx","../src/hooks.ts","../src/JourneyStepRenderer.tsx","../src/index.ts","../../../node_modules/.pnpm/@types+react-dom@19.2.3_@types+react@19.2.13/node_modules/@types/react-dom/index.d.ts"],"fileIdsList":[[54],[52,53],[56,57,58],[56],[54,55,61,62],[54,55,59,60],[54,55,59,60,61],[55,60,61,62,63],[54,55,59]],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"080941d9f9ff9307f7e27a83bcd888b7c8270716c39af943532438932ec1d0b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2e80ee7a49e8ac312cc11b77f1475804bee36b3b2bc896bead8b6e1266befb43","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7a3c8b952931daebdfc7a2897c53c0a1c73624593fa070e46bd537e64dcd20a","affectsGlobalScope":true,"impliedFormat":1},{"version":"80e18897e5884b6723488d4f5652167e7bb5024f946743134ecc4aa4ee731f89","affectsGlobalScope":true,"impliedFormat":1},{"version":"cd034f499c6cdca722b60c04b5b1b78e058487a7085a8e0d6fb50809947ee573","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"1305d1e76ca44e30fb8b2b8075fa522b83f60c0bcf5d4326a9d2cf79b53724f8","impliedFormat":1},{"version":"7e29f41b158de217f94cb9676bf9cbd0cd9b5a46e1985141ed36e075c52bf6ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac51dd7d31333793807a6abaa5ae168512b6131bd41d9c5b98477fc3b7800f9f","impliedFormat":1},{"version":"f123246a7b6c04d80b9b57fadfc6c90959ec6d5c0d4c8e620e06e2811ae3a052","impliedFormat":1},{"version":"42c169fb8c2d42f4f668c624a9a11e719d5d07dacbebb63cbcf7ef365b0a75b3","impliedFormat":1},"b9dc4534a8b8abf7a231fdee9aeba909fe6a5d9d8ffc64336eb662c28164af1c","3d3e7b4efbe8891f0b0f37b832ce6adf587b32c4de869b557c2e2613d5363a65","64a4320c603b4e6640d2813fd4817ab65f14fe57327373634a10ddc0016b6435","bdd8041fa7979a7f7a52eea92f4ecafc4155db4f964e0339b57ea05ca57afb8d",{"version":"02d77dd5cbe24de5fe14c11b8ac04e0c1a9971bb71c06bdde8f83d54b5a5cfcd","signature":"8d90beed710123affb4c8fced6f39799e0d28ff83bb68af57dff520b25f0fc77"},{"version":"344e2c28c496e1e5193afc3a0c6116c5f5f36a2888fe5788f17aba4190ecf63a","signature":"7cea91d1e9cc0a78df5e40b10d5418b4098d34fc14f0c711062f4aa6d4bcca7f"},{"version":"9134bb070f6546e65582ddf80610c952cebe66c1db9b7f9878fb91fa19b6806e","signature":"dab9c7f8c541b34a8e7d9624d40c0d08b82e62c41cd2c296565688c211baa044"},{"version":"3caab3cdd389088dd876858500019c74a424b632349b7aaa61032fecb6a02cd1","signature":"65bcb36a7c71005b0c8966e21479acbb88b7ba8603679c507227572580d52602"},{"version":"daf2a4a8734f0acefd6a2f66d36c105f279be0077b572c077833f7e52312abe7","signature":"6c39012dc4a41a4d7a3bc3b2f1a80d3aa6320c6f576ada894b4668b3d10f777d"},{"version":"be1cc4d94ea60cbe567bc29ed479d42587bf1e6cba490f123d329976b0fe4ee5","impliedFormat":1}],"root":[[60,64]],"options":{"composite":true,"declaration":true,"declarationDir":"./","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"exactOptionalPropertyTypes":true,"jsx":4,"module":99,"noFallthroughCasesInSwitch":true,"noUncheckedIndexedAccess":true,"outDir":"./","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":7,"tsBuildInfoFile":"./tsconfig.build.tsbuildinfo"},"referencedMap":[[65,1],[54,2],[55,1],[59,3],[57,4],[58,4],[63,5],[61,6],[62,7],[64,8],[60,9]],"latestChangedDtsFile":"./index.d.ts","version":"5.9.3"}
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|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