@rxova/journey-react 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bindings/useJourneyApi.d.ts +2 -2
- package/dist/index.cjs.map +2 -2
- package/dist/index.js.map +2 -2
- package/dist/types.d.ts +2 -2
- package/package.json +3 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { JourneyPayloadFor, JourneySendEvent } from "@rxova/journey-core";
|
|
2
2
|
import type { JourneyEventType, JourneyReactEventPayloadMap, JourneyStoreValue } from "../types";
|
|
3
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
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:
|
|
5
|
+
send: (event: JourneySendEvent<TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>) => Promise<void>;
|
|
6
6
|
goToNextStep: () => Promise<void>;
|
|
7
7
|
terminateJourney: (payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, "terminateJourney">) => Promise<void>;
|
|
8
8
|
completeJourney: (payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, "completeJourney">) => Promise<void>;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
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": ["// Mark this entry point as a Next.js App Router client module so it can be used in client components.\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", "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,EAAmB,QAChDQ,EAAkBb,EAAUI,EAAkBG,EAAW,QACzDO,EAAyF,CAC7F,QAASF,EACT,QAASC,CACX,EAEA,SAAO,OAAChB,EAAe,SAAf,CAAwB,MAAOiB,EAAQ,SAAAX,EAAS,CAC1D,ECpCW,IAAAY,EAAA,6BAjBAC,EAAqB,CAMhC,CACA,mBAAAC,EACA,gBAAAC,CACF,IACuB,CAAC,CAAE,SAAAC,EAAW,IAAK,IAAsC,CAC5E,IAAMC,EAAWH,EAAmB,EAC9B,CAAE,QAAAI,CAAQ,EAAIH,EAAgB,cAAc,EAE5CI,EAAgBD,EAAQ,MAAMD,EAAS,aAAa,GAAG,UAE7D,OAAKE,KAIE,OAACA,EAAA,EAAc,KAHb,mBAAG,SAAAH,EAAS,CAIvB,ECrDF,IAAAI,EAAkB,sBAeLC,EAOXC,GAEO,IAAM,CACX,IAAMC,EAAUD,EAAgB,eAAe,EAAE,QAE3CE,EAAO,EAAAC,QAAM,YACjB,
|
|
4
|
+
"sourcesContent": ["// Mark this entry point as a Next.js App Router client module so it can be used in client components.\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", "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 { JourneyPayloadFor, JourneySendEvent } 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 (\n event: JourneySendEvent<TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>\n ) => {\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": "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",
|
|
6
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.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
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", "// Mark this entry point as a Next.js App Router client module so it can be used in client components.\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,GAAuBC,GACvD,CACA,IAAMC,EAAUT,EAAc,CAAE,YAAAA,CAAY,EAAI,OAChDI,EAAmB,QAAUX,EAAqBU,EAAiBM,CAAO,EAC1EJ,EAAW,QAAUF,EACrBG,EAAe,QAAUN,CAC3B,CAEA,IAAMU,EAAkBX,GAAWK,EAAmB,QAChDO,EAAkBZ,EAAUI,EAAkBE,EAAW,QACzDO,EAAyF,CAC7F,QAASF,EACT,QAASC,CACX,EAEA,OAAOjB,EAACE,EAAe,SAAf,CAAwB,MAAOgB,EAAQ,SAAAV,EAAS,CAC1D,ECpCW,mBAAAW,EAAA,OAAAC,MAAA,oBAjBN,IAAMC,EAAqB,CAMhC,CACA,mBAAAC,EACA,gBAAAC,CACF,IACuB,CAAC,CAAE,SAAAC,EAAW,IAAK,IAAsC,CAC5E,IAAMC,EAAWH,EAAmB,EAC9B,CAAE,QAAAI,CAAQ,EAAIH,EAAgB,cAAc,EAE5CI,EAAgBD,EAAQ,MAAMD,EAAS,aAAa,GAAG,UAE7D,OAAKE,EAIEP,EAACO,EAAA,EAAc,EAHbP,EAAAD,EAAA,CAAG,SAAAK,EAAS,CAIvB,ECrDF,OAAOI,MAAW,QAeX,IAAMC,EAOXC,GAEO,IAAM,CACX,IAAMC,EAAUD,EAAgB,eAAe,EAAE,QAE3CE,EAAOJ,EAAM,YACjB,
|
|
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 { JourneyPayloadFor, JourneySendEvent } 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 (\n event: JourneySendEvent<TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>\n ) => {\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", "// Mark this entry point as a Next.js App Router client module so it can be used in client components.\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": "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",
|
|
6
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,5 +1,5 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
|
-
import type { JourneyDefinition,
|
|
2
|
+
import type { JourneyDefinition, JourneyEventPayloadMap as JourneyCoreEventPayloadMap, JourneyMachine, JourneyPayloadFor, JourneyPersistenceOptions, JourneySendEvent, JourneySnapshot, JourneyStepDefinition } from "@rxova/journey-core";
|
|
3
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>>;
|
|
@@ -10,7 +10,7 @@ export type JourneyReactDefinition<TContext, TStepId extends string, TCustomEven
|
|
|
10
10
|
steps: Record<TStepId, JourneyReactStep<TStepMeta>>;
|
|
11
11
|
};
|
|
12
12
|
export type JourneyApi<TContext, TStepId extends string, TCustomEvent extends string = never, TEventPayloadMap extends JourneyReactEventPayloadMap<TCustomEvent> = Record<never, never>, TStepMeta = unknown> = {
|
|
13
|
-
send: (event:
|
|
13
|
+
send: (event: JourneySendEvent<TStepId, JourneyEventType<TCustomEvent>, TEventPayloadMap>) => Promise<void>;
|
|
14
14
|
goToNextStep: () => Promise<void>;
|
|
15
15
|
terminateJourney: (payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, "terminateJourney">) => Promise<void>;
|
|
16
16
|
completeJourney: (payload?: JourneyPayloadFor<JourneyEventType<TCustomEvent>, TEventPayloadMap, "completeJourney">) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxova/journey-react",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
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.6.
|
|
50
|
+
"@rxova/journey-core": "^0.6.2"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": ">=18.2.0"
|
|
@@ -74,7 +74,7 @@
|
|
|
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": "
|
|
77
|
+
"clean": "node ../../scripts/clean-paths.mjs dist tsconfig.build.tsbuildinfo",
|
|
78
78
|
"coverage": "pnpm --workspace-root vitest run --coverage --coverage.include=packages/react/src/** --coverage.reporter=text-summary",
|
|
79
79
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
80
80
|
"publint": "publint",
|