diff --git a/README.md b/README.md index d8715f0..239ca2a 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,8 @@ npm install @rbnd/flows ### Via CDN ```html - - + + ``` ### Usage diff --git a/examples/vanilla-js/cloud/index.html b/examples/vanilla-js/cloud/index.html index 1102fcd..2c6696b 100644 --- a/examples/vanilla-js/cloud/index.html +++ b/examples/vanilla-js/cloud/index.html @@ -6,10 +6,10 @@ Cloud - diff --git a/examples/vanilla-js/index.html b/examples/vanilla-js/index.html index f8982a0..d1fb181 100644 --- a/examples/vanilla-js/index.html +++ b/examples/vanilla-js/index.html @@ -6,10 +6,10 @@ Vanilla JS example - Flows JS - diff --git a/package.json b/package.json index 7a4eee6..65bb316 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rbnd/flows", - "version": "0.0.26", + "version": "0.0.27", "description": "A better way to onboard users and drive product adoption.", "repository": { "type": "git", diff --git a/src/index.ts b/src/index.ts index 9baafad..d549f6d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,6 +7,9 @@ import type { FlowsOptions, StartFlowOptions, TrackingEvent, + FlowTooltipStep, + FlowModalStep, + FlowWaitStep, } from "./types"; import { isValidFlow, isValidFlowsOptions, validateFlow, validateFlowsOptions } from "./validation"; import { init as _init } from "./init"; @@ -14,4 +17,14 @@ import { init as _init } from "./init"; export * from "./public-methods"; export const init: (options: FlowsOptions) => void = _init; export { isValidFlow, isValidFlowsOptions, validateFlow, validateFlowsOptions }; -export type { Flow, FlowStep, FlowSteps, FlowsOptions, StartFlowOptions, TrackingEvent }; +export type { + Flow, + FlowStep, + FlowSteps, + FlowsOptions, + StartFlowOptions, + TrackingEvent, + FlowTooltipStep, + FlowModalStep, + FlowWaitStep, +}; diff --git a/src/init.ts b/src/init.ts index 38cd06c..6b2f5fc 100644 --- a/src/init.ts +++ b/src/init.ts @@ -9,11 +9,6 @@ import { validateFlowsOptions } from "./validation"; let observer: MutationObserver | null = null; export const init = (options: FlowsInitOptions): void => { - setTimeout(() => { - _init(options); - }, 0); -}; -const _init = (options: FlowsInitOptions): void => { const validationResult = validateFlowsOptions(options); if (validationResult.error) log.error( @@ -146,11 +141,6 @@ const _init = (options: FlowsInitOptions): void => { if (locationChanged) { options.onLocationChange?.(pathname, FlowsContext.getInstance()); - Object.values(context.flowsById ?? {}).forEach((flow) => { - if (!flow.location) return; - if (locationMatch({ location: flow.location, pathname })) startFlow(flow.id); - }); - FlowsContext.getInstance().instances.forEach((state) => { const step = state.currentStep; if (!step) return; @@ -173,6 +163,11 @@ const _init = (options: FlowsInitOptions): void => { } } }); + + Object.values(context.flowsById ?? {}).forEach((flow) => { + if (!flow.location) return; + if (locationMatch({ location: flow.location, pathname })) startFlow(flow.id); + }); } prevPathname = pathname;