@founderhq/journeys 1.0.1 → 1.1.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 +9 -0
- package/dist/_tsup-dts-rollup.d.cts +16 -0
- package/dist/_tsup-dts-rollup.d.ts +16 -0
- package/dist/index.cjs +65 -26
- package/dist/index.js +65 -26
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -323,6 +323,15 @@ architecture and security model are documented in
|
|
|
323
323
|
|
|
324
324
|
## Release notes
|
|
325
325
|
|
|
326
|
+
### 1.1.0
|
|
327
|
+
|
|
328
|
+
- `JourneyProvider` takes `history` (default `true`). With `history={false}`, the journey's steps stay out of the browser history, so Back leaves the page instead of stepping back through the journey. Use it for a journey shown inside another page, for example a demo on a landing page.
|
|
329
|
+
|
|
330
|
+
### 1.0.2
|
|
331
|
+
|
|
332
|
+
- Icons show again in the timeline, callout, card, metric, table and before-after blocks. From 0.6.0 to 1.0.1 they rendered with no stroke and were invisible.
|
|
333
|
+
- A glow spot (`blobs`) with a percentage `size` stays round: the size is a share of the screen's longer side, as the default `60vmax`. Before, "60%" was 60% of the width and of the height, which cut the glow off at its sides on a phone.
|
|
334
|
+
|
|
326
335
|
### 1.0.1
|
|
327
336
|
|
|
328
337
|
- The package now ships its MIT licence: a `LICENSE` file and the `license` field.
|
|
@@ -218,6 +218,9 @@ declare type BlobConfig = {
|
|
|
218
218
|
b: number;
|
|
219
219
|
a: number;
|
|
220
220
|
};
|
|
221
|
+
/** One side of the blob's round glow, e.g. "60vmax" (the default). A
|
|
222
|
+
* percentage is a share of the screen's longer side, so "60%" equals
|
|
223
|
+
* "60vmax". */
|
|
221
224
|
size?: string;
|
|
222
225
|
};
|
|
223
226
|
export { BlobConfig }
|
|
@@ -1612,6 +1615,10 @@ declare type JourneyProviderProps = {
|
|
|
1612
1615
|
config: JourneyConfig;
|
|
1613
1616
|
/** False prepares the first screen without starting analytics or playback. */
|
|
1614
1617
|
active?: boolean;
|
|
1618
|
+
/** False keeps steps out of the browser history: Back leaves the page
|
|
1619
|
+
* instead of stepping through the journey. For a journey shown inside
|
|
1620
|
+
* another page (a demo on a landing page). Default true. */
|
|
1621
|
+
history?: boolean;
|
|
1615
1622
|
storageKey?: string;
|
|
1616
1623
|
/** Theme class override applied to the provider scope so global UI like dialogs inherits journey tokens. */
|
|
1617
1624
|
theme?: string;
|
|
@@ -2194,6 +2201,15 @@ declare function resolveJourneyBlobDefaultSize(viewport?: JourneyBlobViewport):
|
|
|
2194
2201
|
export { resolveJourneyBlobDefaultSize }
|
|
2195
2202
|
export { resolveJourneyBlobDefaultSize as resolveJourneyBlobDefaultSize_alias_1 }
|
|
2196
2203
|
|
|
2204
|
+
/**
|
|
2205
|
+
* The CSS size of one side of a blob's square box. A blob is a circle, so
|
|
2206
|
+
* a percentage means a share of the screen's longer side, as the default
|
|
2207
|
+
* `60vmax` does. As plain CSS, "60%" would be 60 % of the width AND 60 % of
|
|
2208
|
+
* the height: a tall narrow box on a phone that cuts the round glow off at
|
|
2209
|
+
* its left and right sides.
|
|
2210
|
+
*/
|
|
2211
|
+
export declare function resolveJourneyBlobSize(size: string | undefined, viewport?: JourneyBlobViewport): string;
|
|
2212
|
+
|
|
2197
2213
|
/** Resolve editor font labels to the self-hosted faces shipped by Journeys. */
|
|
2198
2214
|
declare function resolveJourneyFontFamily(fontFamily: string | undefined): string | undefined;
|
|
2199
2215
|
export { resolveJourneyFontFamily }
|
|
@@ -218,6 +218,9 @@ declare type BlobConfig = {
|
|
|
218
218
|
b: number;
|
|
219
219
|
a: number;
|
|
220
220
|
};
|
|
221
|
+
/** One side of the blob's round glow, e.g. "60vmax" (the default). A
|
|
222
|
+
* percentage is a share of the screen's longer side, so "60%" equals
|
|
223
|
+
* "60vmax". */
|
|
221
224
|
size?: string;
|
|
222
225
|
};
|
|
223
226
|
export { BlobConfig }
|
|
@@ -1612,6 +1615,10 @@ declare type JourneyProviderProps = {
|
|
|
1612
1615
|
config: JourneyConfig;
|
|
1613
1616
|
/** False prepares the first screen without starting analytics or playback. */
|
|
1614
1617
|
active?: boolean;
|
|
1618
|
+
/** False keeps steps out of the browser history: Back leaves the page
|
|
1619
|
+
* instead of stepping through the journey. For a journey shown inside
|
|
1620
|
+
* another page (a demo on a landing page). Default true. */
|
|
1621
|
+
history?: boolean;
|
|
1615
1622
|
storageKey?: string;
|
|
1616
1623
|
/** Theme class override applied to the provider scope so global UI like dialogs inherits journey tokens. */
|
|
1617
1624
|
theme?: string;
|
|
@@ -2194,6 +2201,15 @@ declare function resolveJourneyBlobDefaultSize(viewport?: JourneyBlobViewport):
|
|
|
2194
2201
|
export { resolveJourneyBlobDefaultSize }
|
|
2195
2202
|
export { resolveJourneyBlobDefaultSize as resolveJourneyBlobDefaultSize_alias_1 }
|
|
2196
2203
|
|
|
2204
|
+
/**
|
|
2205
|
+
* The CSS size of one side of a blob's square box. A blob is a circle, so
|
|
2206
|
+
* a percentage means a share of the screen's longer side, as the default
|
|
2207
|
+
* `60vmax` does. As plain CSS, "60%" would be 60 % of the width AND 60 % of
|
|
2208
|
+
* the height: a tall narrow box on a phone that cuts the round glow off at
|
|
2209
|
+
* its left and right sides.
|
|
2210
|
+
*/
|
|
2211
|
+
export declare function resolveJourneyBlobSize(size: string | undefined, viewport?: JourneyBlobViewport): string;
|
|
2212
|
+
|
|
2197
2213
|
/** Resolve editor font labels to the self-hosted faces shipped by Journeys. */
|
|
2198
2214
|
declare function resolveJourneyFontFamily(fontFamily: string | undefined): string | undefined;
|
|
2199
2215
|
export { resolveJourneyFontFamily }
|
package/dist/index.cjs
CHANGED
|
@@ -2811,6 +2811,7 @@ function stripOptionsFromEventStep(step) {
|
|
|
2811
2811
|
function useJourneyProviderRuntime({
|
|
2812
2812
|
config: rawConfig,
|
|
2813
2813
|
active = true,
|
|
2814
|
+
history = true,
|
|
2814
2815
|
storageKey = "journey",
|
|
2815
2816
|
onEvent,
|
|
2816
2817
|
onHaptic,
|
|
@@ -2975,12 +2976,14 @@ function useJourneyProviderRuntime({
|
|
|
2975
2976
|
}
|
|
2976
2977
|
setDirection("forward");
|
|
2977
2978
|
setCurrentStepIndex(nextIndex);
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2979
|
+
if (history) {
|
|
2980
|
+
window.history.pushState(
|
|
2981
|
+
__spreadProps(__spreadValues({}, window.history.state), { __journeyStep: nextIndex }),
|
|
2982
|
+
""
|
|
2983
|
+
);
|
|
2984
|
+
}
|
|
2982
2985
|
},
|
|
2983
|
-
[config.steps.length, trigger]
|
|
2986
|
+
[config.steps.length, history, trigger]
|
|
2984
2987
|
);
|
|
2985
2988
|
const goNext = React.useCallback(
|
|
2986
2989
|
(answer) => {
|
|
@@ -3062,7 +3065,7 @@ function useJourneyProviderRuntime({
|
|
|
3062
3065
|
]
|
|
3063
3066
|
);
|
|
3064
3067
|
const goBack = React.useCallback(() => {
|
|
3065
|
-
var _a;
|
|
3068
|
+
var _a, _b;
|
|
3066
3069
|
const step = config.steps[currentStepIndex];
|
|
3067
3070
|
const allowBack = (_a = step == null ? void 0 : step.allowBackNavigation) != null ? _a : config.allowBackNavigation;
|
|
3068
3071
|
if (allowBack === false) return;
|
|
@@ -3072,18 +3075,37 @@ function useJourneyProviderRuntime({
|
|
|
3072
3075
|
setTimeout(() => {
|
|
3073
3076
|
isTransitioning.current = false;
|
|
3074
3077
|
}, 400);
|
|
3075
|
-
|
|
3078
|
+
if (history) {
|
|
3079
|
+
window.history.back();
|
|
3080
|
+
return;
|
|
3081
|
+
}
|
|
3082
|
+
const prev = currentStepIndex - 1;
|
|
3083
|
+
setDirection("backward");
|
|
3084
|
+
setCurrentStepIndex(prev);
|
|
3085
|
+
(_b = onEventRef.current) == null ? void 0 : _b.call(onEventRef, __spreadValues({
|
|
3086
|
+
type: "navigate",
|
|
3087
|
+
from: stripOptionsFromEventStep(config.steps[currentStepIndex]),
|
|
3088
|
+
to: stripOptionsFromEventStep(config.steps[prev]),
|
|
3089
|
+
direction: "backward"
|
|
3090
|
+
}, getEventAnswers(config.computedVariables, rawAnswersRef.current)));
|
|
3076
3091
|
}
|
|
3077
|
-
}, [
|
|
3092
|
+
}, [
|
|
3093
|
+
active,
|
|
3094
|
+
config.allowBackNavigation,
|
|
3095
|
+
config.computedVariables,
|
|
3096
|
+
config.steps,
|
|
3097
|
+
currentStepIndex,
|
|
3098
|
+
history
|
|
3099
|
+
]);
|
|
3078
3100
|
React.useEffect(() => {
|
|
3079
|
-
if (!active) return;
|
|
3101
|
+
if (!active || !history) return;
|
|
3080
3102
|
window.history.replaceState(
|
|
3081
3103
|
__spreadProps(__spreadValues({}, window.history.state), { __journeyStep: 0 }),
|
|
3082
3104
|
""
|
|
3083
3105
|
);
|
|
3084
|
-
}, [active]);
|
|
3106
|
+
}, [active, history]);
|
|
3085
3107
|
React.useEffect(() => {
|
|
3086
|
-
if (!active) return;
|
|
3108
|
+
if (!active || !history) return;
|
|
3087
3109
|
const handlePopState = (event) => {
|
|
3088
3110
|
var _a, _b;
|
|
3089
3111
|
const step = (_b = (_a = event.state) == null ? void 0 : _a.__journeyStep) != null ? _b : 0;
|
|
@@ -3116,7 +3138,8 @@ function useJourneyProviderRuntime({
|
|
|
3116
3138
|
active,
|
|
3117
3139
|
config.allowBackNavigation,
|
|
3118
3140
|
config.computedVariables,
|
|
3119
|
-
config.steps
|
|
3141
|
+
config.steps,
|
|
3142
|
+
history
|
|
3120
3143
|
]);
|
|
3121
3144
|
const getStepAnswer = React.useCallback(
|
|
3122
3145
|
(stepId) => {
|
|
@@ -5823,7 +5846,16 @@ function DynamicIcon({
|
|
|
5823
5846
|
}) {
|
|
5824
5847
|
const Icon = lucideIcons5[name];
|
|
5825
5848
|
if (isLucideIcon(Icon)) {
|
|
5826
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5849
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5850
|
+
Icon,
|
|
5851
|
+
__spreadProps(__spreadValues({
|
|
5852
|
+
size,
|
|
5853
|
+
className,
|
|
5854
|
+
style
|
|
5855
|
+
}, stroke ? { stroke } : {}), {
|
|
5856
|
+
children
|
|
5857
|
+
})
|
|
5858
|
+
);
|
|
5827
5859
|
}
|
|
5828
5860
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5829
5861
|
"span",
|
|
@@ -12083,6 +12115,15 @@ function resolveJourneyBlobDefaultSize(viewport) {
|
|
|
12083
12115
|
if (!viewport) return "60vmax";
|
|
12084
12116
|
return `${Math.max(viewport.width, viewport.height) * 0.6}px`;
|
|
12085
12117
|
}
|
|
12118
|
+
var PERCENT_SIZE = /^\s*(\d+(?:\.\d+)?)\s*%\s*$/;
|
|
12119
|
+
function resolveJourneyBlobSize(size, viewport) {
|
|
12120
|
+
if (size === void 0) return resolveJourneyBlobDefaultSize(viewport);
|
|
12121
|
+
const percent = PERCENT_SIZE.exec(size);
|
|
12122
|
+
if (!percent) return size;
|
|
12123
|
+
const share = Number(percent[1]);
|
|
12124
|
+
if (!viewport) return `${share}vmax`;
|
|
12125
|
+
return `${Math.max(viewport.width, viewport.height) * share / 100}px`;
|
|
12126
|
+
}
|
|
12086
12127
|
var BLOB_POSITIONS = [
|
|
12087
12128
|
[
|
|
12088
12129
|
{ x: "-5%", y: "-10%" },
|
|
@@ -12132,12 +12173,12 @@ function themedBlobGradient(peakAlpha) {
|
|
|
12132
12173
|
function colorKey(c) {
|
|
12133
12174
|
return `${c.r}-${c.g}-${c.b}-${c.a}`;
|
|
12134
12175
|
}
|
|
12135
|
-
function resolveBlobVisual(config, index,
|
|
12136
|
-
var _a
|
|
12176
|
+
function resolveBlobVisual(config, index, viewport) {
|
|
12177
|
+
var _a;
|
|
12137
12178
|
const color = config == null ? void 0 : config.color;
|
|
12138
12179
|
return {
|
|
12139
12180
|
position: (_a = config == null ? void 0 : config.position) != null ? _a : { x: "50%", y: "50%" },
|
|
12140
|
-
size: (
|
|
12181
|
+
size: resolveJourneyBlobSize(config == null ? void 0 : config.size, viewport),
|
|
12141
12182
|
background: color ? blobGradient(color) : themedBlobGradient(BLOB_PEAK_ALPHAS[index % BLOB_PEAK_ALPHAS.length]),
|
|
12142
12183
|
fadeKey: color ? colorKey(color) : `themed-${index % BLOB_PEAK_ALPHAS.length}`
|
|
12143
12184
|
};
|
|
@@ -12146,12 +12187,12 @@ function AnimatedBlob({
|
|
|
12146
12187
|
config,
|
|
12147
12188
|
index,
|
|
12148
12189
|
visible,
|
|
12149
|
-
|
|
12190
|
+
viewport
|
|
12150
12191
|
}) {
|
|
12151
12192
|
const { position, size, background, fadeKey } = resolveBlobVisual(
|
|
12152
12193
|
config,
|
|
12153
12194
|
index,
|
|
12154
|
-
|
|
12195
|
+
viewport
|
|
12155
12196
|
);
|
|
12156
12197
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12157
12198
|
react.m.div,
|
|
@@ -12185,12 +12226,12 @@ function AnimatedBlob({
|
|
|
12185
12226
|
function StaticBlob({
|
|
12186
12227
|
config,
|
|
12187
12228
|
index,
|
|
12188
|
-
|
|
12229
|
+
viewport
|
|
12189
12230
|
}) {
|
|
12190
12231
|
const { position, size, background } = resolveBlobVisual(
|
|
12191
12232
|
config,
|
|
12192
12233
|
index,
|
|
12193
|
-
|
|
12234
|
+
viewport
|
|
12194
12235
|
);
|
|
12195
12236
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12196
12237
|
"div",
|
|
@@ -12224,10 +12265,8 @@ function JourneyBlobLayer({
|
|
|
12224
12265
|
theme,
|
|
12225
12266
|
themeVariables
|
|
12226
12267
|
}) {
|
|
12227
|
-
const defaultSize = resolveJourneyBlobDefaultSize(viewport);
|
|
12228
12268
|
const blobConfigs = blobs ? blobs : showRandomBlobs ? BLOB_POSITIONS[stepIndex % BLOB_POSITIONS.length].map((position) => ({
|
|
12229
|
-
position
|
|
12230
|
-
size: defaultSize
|
|
12269
|
+
position
|
|
12231
12270
|
})) : [];
|
|
12232
12271
|
const themeStyle = themeVariables ? Object.fromEntries(
|
|
12233
12272
|
Object.entries(themeVariables).filter(([key]) => key.startsWith("--"))
|
|
@@ -12243,7 +12282,7 @@ function JourneyBlobLayer({
|
|
|
12243
12282
|
{
|
|
12244
12283
|
config: blobConfigs[index],
|
|
12245
12284
|
index,
|
|
12246
|
-
|
|
12285
|
+
viewport
|
|
12247
12286
|
},
|
|
12248
12287
|
slot
|
|
12249
12288
|
)) : BLOB_SLOTS.map((slot, index) => {
|
|
@@ -12254,7 +12293,7 @@ function JourneyBlobLayer({
|
|
|
12254
12293
|
config: (_a = blobConfigs[index]) != null ? _a : null,
|
|
12255
12294
|
index,
|
|
12256
12295
|
visible: index < blobConfigs.length,
|
|
12257
|
-
|
|
12296
|
+
viewport
|
|
12258
12297
|
},
|
|
12259
12298
|
slot
|
|
12260
12299
|
);
|
|
@@ -12829,7 +12868,7 @@ function useJourneyConfig({
|
|
|
12829
12868
|
|
|
12830
12869
|
// src/engine/journey-capture.ts
|
|
12831
12870
|
var JOURNEY_LIBRARY_NAME = "@founderhq/journeys";
|
|
12832
|
-
var JOURNEY_LIBRARY_VERSION = "1.0
|
|
12871
|
+
var JOURNEY_LIBRARY_VERSION = "1.1.0";
|
|
12833
12872
|
var DEFAULT_QUEUE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
12834
12873
|
var MAX_QUEUED_CAPTURE_EVENTS = 100;
|
|
12835
12874
|
var MAX_BEACON_BYTES = 60 * 1024;
|
package/dist/index.js
CHANGED
|
@@ -699,6 +699,7 @@ function stripOptionsFromEventStep(step) {
|
|
|
699
699
|
function useJourneyProviderRuntime({
|
|
700
700
|
config: rawConfig,
|
|
701
701
|
active = true,
|
|
702
|
+
history = true,
|
|
702
703
|
storageKey = "journey",
|
|
703
704
|
onEvent,
|
|
704
705
|
onHaptic,
|
|
@@ -863,12 +864,14 @@ function useJourneyProviderRuntime({
|
|
|
863
864
|
}
|
|
864
865
|
setDirection("forward");
|
|
865
866
|
setCurrentStepIndex(nextIndex);
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
867
|
+
if (history) {
|
|
868
|
+
window.history.pushState(
|
|
869
|
+
__spreadProps(__spreadValues({}, window.history.state), { __journeyStep: nextIndex }),
|
|
870
|
+
""
|
|
871
|
+
);
|
|
872
|
+
}
|
|
870
873
|
},
|
|
871
|
-
[config.steps.length, trigger]
|
|
874
|
+
[config.steps.length, history, trigger]
|
|
872
875
|
);
|
|
873
876
|
const goNext = useCallback(
|
|
874
877
|
(answer) => {
|
|
@@ -950,7 +953,7 @@ function useJourneyProviderRuntime({
|
|
|
950
953
|
]
|
|
951
954
|
);
|
|
952
955
|
const goBack = useCallback(() => {
|
|
953
|
-
var _a;
|
|
956
|
+
var _a, _b;
|
|
954
957
|
const step = config.steps[currentStepIndex];
|
|
955
958
|
const allowBack = (_a = step == null ? void 0 : step.allowBackNavigation) != null ? _a : config.allowBackNavigation;
|
|
956
959
|
if (allowBack === false) return;
|
|
@@ -960,18 +963,37 @@ function useJourneyProviderRuntime({
|
|
|
960
963
|
setTimeout(() => {
|
|
961
964
|
isTransitioning.current = false;
|
|
962
965
|
}, 400);
|
|
963
|
-
|
|
966
|
+
if (history) {
|
|
967
|
+
window.history.back();
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
const prev = currentStepIndex - 1;
|
|
971
|
+
setDirection("backward");
|
|
972
|
+
setCurrentStepIndex(prev);
|
|
973
|
+
(_b = onEventRef.current) == null ? void 0 : _b.call(onEventRef, __spreadValues({
|
|
974
|
+
type: "navigate",
|
|
975
|
+
from: stripOptionsFromEventStep(config.steps[currentStepIndex]),
|
|
976
|
+
to: stripOptionsFromEventStep(config.steps[prev]),
|
|
977
|
+
direction: "backward"
|
|
978
|
+
}, getEventAnswers(config.computedVariables, rawAnswersRef.current)));
|
|
964
979
|
}
|
|
965
|
-
}, [
|
|
980
|
+
}, [
|
|
981
|
+
active,
|
|
982
|
+
config.allowBackNavigation,
|
|
983
|
+
config.computedVariables,
|
|
984
|
+
config.steps,
|
|
985
|
+
currentStepIndex,
|
|
986
|
+
history
|
|
987
|
+
]);
|
|
966
988
|
useEffect(() => {
|
|
967
|
-
if (!active) return;
|
|
989
|
+
if (!active || !history) return;
|
|
968
990
|
window.history.replaceState(
|
|
969
991
|
__spreadProps(__spreadValues({}, window.history.state), { __journeyStep: 0 }),
|
|
970
992
|
""
|
|
971
993
|
);
|
|
972
|
-
}, [active]);
|
|
994
|
+
}, [active, history]);
|
|
973
995
|
useEffect(() => {
|
|
974
|
-
if (!active) return;
|
|
996
|
+
if (!active || !history) return;
|
|
975
997
|
const handlePopState = (event) => {
|
|
976
998
|
var _a, _b;
|
|
977
999
|
const step = (_b = (_a = event.state) == null ? void 0 : _a.__journeyStep) != null ? _b : 0;
|
|
@@ -1004,7 +1026,8 @@ function useJourneyProviderRuntime({
|
|
|
1004
1026
|
active,
|
|
1005
1027
|
config.allowBackNavigation,
|
|
1006
1028
|
config.computedVariables,
|
|
1007
|
-
config.steps
|
|
1029
|
+
config.steps,
|
|
1030
|
+
history
|
|
1008
1031
|
]);
|
|
1009
1032
|
const getStepAnswer = useCallback(
|
|
1010
1033
|
(stepId) => {
|
|
@@ -3711,7 +3734,16 @@ function DynamicIcon({
|
|
|
3711
3734
|
}) {
|
|
3712
3735
|
const Icon = lucideIcons5[name];
|
|
3713
3736
|
if (isLucideIcon(Icon)) {
|
|
3714
|
-
return /* @__PURE__ */ jsx(
|
|
3737
|
+
return /* @__PURE__ */ jsx(
|
|
3738
|
+
Icon,
|
|
3739
|
+
__spreadProps(__spreadValues({
|
|
3740
|
+
size,
|
|
3741
|
+
className,
|
|
3742
|
+
style
|
|
3743
|
+
}, stroke ? { stroke } : {}), {
|
|
3744
|
+
children
|
|
3745
|
+
})
|
|
3746
|
+
);
|
|
3715
3747
|
}
|
|
3716
3748
|
return /* @__PURE__ */ jsx(
|
|
3717
3749
|
"span",
|
|
@@ -9971,6 +10003,15 @@ function resolveJourneyBlobDefaultSize(viewport) {
|
|
|
9971
10003
|
if (!viewport) return "60vmax";
|
|
9972
10004
|
return `${Math.max(viewport.width, viewport.height) * 0.6}px`;
|
|
9973
10005
|
}
|
|
10006
|
+
var PERCENT_SIZE = /^\s*(\d+(?:\.\d+)?)\s*%\s*$/;
|
|
10007
|
+
function resolveJourneyBlobSize(size, viewport) {
|
|
10008
|
+
if (size === void 0) return resolveJourneyBlobDefaultSize(viewport);
|
|
10009
|
+
const percent = PERCENT_SIZE.exec(size);
|
|
10010
|
+
if (!percent) return size;
|
|
10011
|
+
const share = Number(percent[1]);
|
|
10012
|
+
if (!viewport) return `${share}vmax`;
|
|
10013
|
+
return `${Math.max(viewport.width, viewport.height) * share / 100}px`;
|
|
10014
|
+
}
|
|
9974
10015
|
var BLOB_POSITIONS = [
|
|
9975
10016
|
[
|
|
9976
10017
|
{ x: "-5%", y: "-10%" },
|
|
@@ -10020,12 +10061,12 @@ function themedBlobGradient(peakAlpha) {
|
|
|
10020
10061
|
function colorKey(c) {
|
|
10021
10062
|
return `${c.r}-${c.g}-${c.b}-${c.a}`;
|
|
10022
10063
|
}
|
|
10023
|
-
function resolveBlobVisual(config, index,
|
|
10024
|
-
var _a
|
|
10064
|
+
function resolveBlobVisual(config, index, viewport) {
|
|
10065
|
+
var _a;
|
|
10025
10066
|
const color = config == null ? void 0 : config.color;
|
|
10026
10067
|
return {
|
|
10027
10068
|
position: (_a = config == null ? void 0 : config.position) != null ? _a : { x: "50%", y: "50%" },
|
|
10028
|
-
size: (
|
|
10069
|
+
size: resolveJourneyBlobSize(config == null ? void 0 : config.size, viewport),
|
|
10029
10070
|
background: color ? blobGradient(color) : themedBlobGradient(BLOB_PEAK_ALPHAS[index % BLOB_PEAK_ALPHAS.length]),
|
|
10030
10071
|
fadeKey: color ? colorKey(color) : `themed-${index % BLOB_PEAK_ALPHAS.length}`
|
|
10031
10072
|
};
|
|
@@ -10034,12 +10075,12 @@ function AnimatedBlob({
|
|
|
10034
10075
|
config,
|
|
10035
10076
|
index,
|
|
10036
10077
|
visible,
|
|
10037
|
-
|
|
10078
|
+
viewport
|
|
10038
10079
|
}) {
|
|
10039
10080
|
const { position, size, background, fadeKey } = resolveBlobVisual(
|
|
10040
10081
|
config,
|
|
10041
10082
|
index,
|
|
10042
|
-
|
|
10083
|
+
viewport
|
|
10043
10084
|
);
|
|
10044
10085
|
return /* @__PURE__ */ jsx(
|
|
10045
10086
|
m.div,
|
|
@@ -10073,12 +10114,12 @@ function AnimatedBlob({
|
|
|
10073
10114
|
function StaticBlob({
|
|
10074
10115
|
config,
|
|
10075
10116
|
index,
|
|
10076
|
-
|
|
10117
|
+
viewport
|
|
10077
10118
|
}) {
|
|
10078
10119
|
const { position, size, background } = resolveBlobVisual(
|
|
10079
10120
|
config,
|
|
10080
10121
|
index,
|
|
10081
|
-
|
|
10122
|
+
viewport
|
|
10082
10123
|
);
|
|
10083
10124
|
return /* @__PURE__ */ jsx(
|
|
10084
10125
|
"div",
|
|
@@ -10112,10 +10153,8 @@ function JourneyBlobLayer({
|
|
|
10112
10153
|
theme,
|
|
10113
10154
|
themeVariables
|
|
10114
10155
|
}) {
|
|
10115
|
-
const defaultSize = resolveJourneyBlobDefaultSize(viewport);
|
|
10116
10156
|
const blobConfigs = blobs ? blobs : showRandomBlobs ? BLOB_POSITIONS[stepIndex % BLOB_POSITIONS.length].map((position) => ({
|
|
10117
|
-
position
|
|
10118
|
-
size: defaultSize
|
|
10157
|
+
position
|
|
10119
10158
|
})) : [];
|
|
10120
10159
|
const themeStyle = themeVariables ? Object.fromEntries(
|
|
10121
10160
|
Object.entries(themeVariables).filter(([key]) => key.startsWith("--"))
|
|
@@ -10131,7 +10170,7 @@ function JourneyBlobLayer({
|
|
|
10131
10170
|
{
|
|
10132
10171
|
config: blobConfigs[index],
|
|
10133
10172
|
index,
|
|
10134
|
-
|
|
10173
|
+
viewport
|
|
10135
10174
|
},
|
|
10136
10175
|
slot
|
|
10137
10176
|
)) : BLOB_SLOTS.map((slot, index) => {
|
|
@@ -10142,7 +10181,7 @@ function JourneyBlobLayer({
|
|
|
10142
10181
|
config: (_a = blobConfigs[index]) != null ? _a : null,
|
|
10143
10182
|
index,
|
|
10144
10183
|
visible: index < blobConfigs.length,
|
|
10145
|
-
|
|
10184
|
+
viewport
|
|
10146
10185
|
},
|
|
10147
10186
|
slot
|
|
10148
10187
|
);
|
|
@@ -10717,7 +10756,7 @@ function useJourneyConfig({
|
|
|
10717
10756
|
|
|
10718
10757
|
// src/engine/journey-capture.ts
|
|
10719
10758
|
var JOURNEY_LIBRARY_NAME = "@founderhq/journeys";
|
|
10720
|
-
var JOURNEY_LIBRARY_VERSION = "1.0
|
|
10759
|
+
var JOURNEY_LIBRARY_VERSION = "1.1.0";
|
|
10721
10760
|
var DEFAULT_QUEUE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
10722
10761
|
var MAX_QUEUED_CAPTURE_EVENTS = 100;
|
|
10723
10762
|
var MAX_BEACON_BYTES = 60 * 1024;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@founderhq/journeys",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Config-driven interactive journey/questionnaire engine for React",
|
|
6
6
|
"type": "module",
|
|
@@ -86,4 +86,4 @@
|
|
|
86
86
|
"dev:ts": "tsup --watch",
|
|
87
87
|
"typecheck": "node ../../scripts/run-tsc.mjs -p tsconfig.json --noEmit"
|
|
88
88
|
}
|
|
89
|
-
}
|
|
89
|
+
}
|