@founderhq/journeys 0.9.0 → 1.0.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/dist/_tsup-dts-rollup.d.cts +39 -0
- package/dist/_tsup-dts-rollup.d.ts +39 -0
- package/dist/index.cjs +113 -2
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +108 -3
- package/package.json +1 -1
|
@@ -1032,6 +1032,11 @@ export { FetchState as FetchState_alias_1 }
|
|
|
1032
1032
|
/** The hosted events snippet publishes its client as `globalThis.founderhq`. */
|
|
1033
1033
|
export declare function findGlobalEventsClient(): JourneyEventsClient | null;
|
|
1034
1034
|
|
|
1035
|
+
/** The first family of a CSS font stack, without quotes. */
|
|
1036
|
+
declare function firstFontFamily(stack: string | undefined): string | undefined;
|
|
1037
|
+
export { firstFontFamily }
|
|
1038
|
+
export { firstFontFamily as firstFontFamily_alias_1 }
|
|
1039
|
+
|
|
1035
1040
|
export declare function FloatingLabelBlock({ text, variant, color, gradient, className, }: FloatingLabelBlockProps): JSX.Element;
|
|
1036
1041
|
|
|
1037
1042
|
declare type FloatingLabelBlockProps = {
|
|
@@ -1049,6 +1054,14 @@ export declare const FOUNDERHQ_BASE_URL = "https://app.getfounderhq.com";
|
|
|
1049
1054
|
|
|
1050
1055
|
export declare function getGravityBinShape(id: string): GravityBinShape;
|
|
1051
1056
|
|
|
1057
|
+
/**
|
|
1058
|
+
* The web fonts a journey uses: the font of the whole journey, and the font
|
|
1059
|
+
* of any block or text segment that sets its own. Sorted, without repeats.
|
|
1060
|
+
*/
|
|
1061
|
+
declare function getJourneyWebFontFamilies(config: JourneyConfig): string[];
|
|
1062
|
+
export { getJourneyWebFontFamilies }
|
|
1063
|
+
export { getJourneyWebFontFamilies as getJourneyWebFontFamilies_alias_1 }
|
|
1064
|
+
|
|
1052
1065
|
declare function getScreenNameError(value: string): string | null;
|
|
1053
1066
|
export { getScreenNameError }
|
|
1054
1067
|
export { getScreenNameError as getScreenNameError_alias_1 }
|
|
@@ -1080,6 +1093,17 @@ export { getVariableNameError }
|
|
|
1080
1093
|
export { getVariableNameError as getVariableNameError_alias_1 }
|
|
1081
1094
|
export { getVariableNameError as getVariableNameError_alias_2 }
|
|
1082
1095
|
|
|
1096
|
+
/**
|
|
1097
|
+
* The stylesheet of a web font. Bunny Fonts carries the Google Fonts
|
|
1098
|
+
* catalog under the same names and does not track the visitor, so a
|
|
1099
|
+
* journey can use those fonts without a call to Google. A weight the
|
|
1100
|
+
* family does not have is left out of the answer, and an unknown name
|
|
1101
|
+
* gives an empty stylesheet, so the request never fails the page.
|
|
1102
|
+
*/
|
|
1103
|
+
declare function getWebFontStylesheetUrl(family: string): string;
|
|
1104
|
+
export { getWebFontStylesheetUrl }
|
|
1105
|
+
export { getWebFontStylesheetUrl as getWebFontStylesheetUrl_alias_1 }
|
|
1106
|
+
|
|
1083
1107
|
declare type GradientValue = string | {
|
|
1084
1108
|
from: string;
|
|
1085
1109
|
to: string;
|
|
@@ -1229,6 +1253,11 @@ export { isValidVariableName }
|
|
|
1229
1253
|
export { isValidVariableName as isValidVariableName_alias_1 }
|
|
1230
1254
|
export { isValidVariableName as isValidVariableName_alias_2 }
|
|
1231
1255
|
|
|
1256
|
+
/** If this family is one a journey must load from the web to show it. */
|
|
1257
|
+
declare function isWebFontFamily(family: string | undefined): family is string;
|
|
1258
|
+
export { isWebFontFamily }
|
|
1259
|
+
export { isWebFontFamily as isWebFontFamily_alias_1 }
|
|
1260
|
+
|
|
1232
1261
|
declare type ItemRecord = Record<string, unknown>;
|
|
1233
1262
|
|
|
1234
1263
|
declare function Journey({ apiKey, journeyId, config, baseUrl, storageKey, onEvent, onOpenURL, className, presentation, theme, initialAnswers, initialOptions, onDiscountCodeApply, loadingComponent, errorComponent, capture, identity, }: JourneyProps): JSX.Element;
|
|
@@ -2931,6 +2960,16 @@ export { useJourneyState as useJourneyState_alias_1 }
|
|
|
2931
2960
|
/** Media playback is a presentation side effect; preloading only fetches assets. */
|
|
2932
2961
|
export declare function useJourneyVideo(autoplay: boolean, source?: string): RefObject<HTMLVideoElement | null>;
|
|
2933
2962
|
|
|
2963
|
+
/**
|
|
2964
|
+
* Loads the web fonts a journey uses, by one stylesheet link for each in
|
|
2965
|
+
* the document head. A link stays for the life of the page: another journey
|
|
2966
|
+
* on it, or the same one after an edit, can use the font at once, and a
|
|
2967
|
+
* font is never asked for twice.
|
|
2968
|
+
*/
|
|
2969
|
+
declare function useJourneyWebFonts(config: JourneyConfig): void;
|
|
2970
|
+
export { useJourneyWebFonts }
|
|
2971
|
+
export { useJourneyWebFonts as useJourneyWebFonts_alias_1 }
|
|
2972
|
+
|
|
2934
2973
|
export declare function VideoBlock({ src, previewImage, captions, autoplay, loop, muted, controls, aspectRatio, youtubeId, vimeoId, className, }: VideoBlockProps): JSX.Element;
|
|
2935
2974
|
|
|
2936
2975
|
declare type VideoBlockProps = {
|
|
@@ -1032,6 +1032,11 @@ export { FetchState as FetchState_alias_1 }
|
|
|
1032
1032
|
/** The hosted events snippet publishes its client as `globalThis.founderhq`. */
|
|
1033
1033
|
export declare function findGlobalEventsClient(): JourneyEventsClient | null;
|
|
1034
1034
|
|
|
1035
|
+
/** The first family of a CSS font stack, without quotes. */
|
|
1036
|
+
declare function firstFontFamily(stack: string | undefined): string | undefined;
|
|
1037
|
+
export { firstFontFamily }
|
|
1038
|
+
export { firstFontFamily as firstFontFamily_alias_1 }
|
|
1039
|
+
|
|
1035
1040
|
export declare function FloatingLabelBlock({ text, variant, color, gradient, className, }: FloatingLabelBlockProps): JSX.Element;
|
|
1036
1041
|
|
|
1037
1042
|
declare type FloatingLabelBlockProps = {
|
|
@@ -1049,6 +1054,14 @@ export declare const FOUNDERHQ_BASE_URL = "https://app.getfounderhq.com";
|
|
|
1049
1054
|
|
|
1050
1055
|
export declare function getGravityBinShape(id: string): GravityBinShape;
|
|
1051
1056
|
|
|
1057
|
+
/**
|
|
1058
|
+
* The web fonts a journey uses: the font of the whole journey, and the font
|
|
1059
|
+
* of any block or text segment that sets its own. Sorted, without repeats.
|
|
1060
|
+
*/
|
|
1061
|
+
declare function getJourneyWebFontFamilies(config: JourneyConfig): string[];
|
|
1062
|
+
export { getJourneyWebFontFamilies }
|
|
1063
|
+
export { getJourneyWebFontFamilies as getJourneyWebFontFamilies_alias_1 }
|
|
1064
|
+
|
|
1052
1065
|
declare function getScreenNameError(value: string): string | null;
|
|
1053
1066
|
export { getScreenNameError }
|
|
1054
1067
|
export { getScreenNameError as getScreenNameError_alias_1 }
|
|
@@ -1080,6 +1093,17 @@ export { getVariableNameError }
|
|
|
1080
1093
|
export { getVariableNameError as getVariableNameError_alias_1 }
|
|
1081
1094
|
export { getVariableNameError as getVariableNameError_alias_2 }
|
|
1082
1095
|
|
|
1096
|
+
/**
|
|
1097
|
+
* The stylesheet of a web font. Bunny Fonts carries the Google Fonts
|
|
1098
|
+
* catalog under the same names and does not track the visitor, so a
|
|
1099
|
+
* journey can use those fonts without a call to Google. A weight the
|
|
1100
|
+
* family does not have is left out of the answer, and an unknown name
|
|
1101
|
+
* gives an empty stylesheet, so the request never fails the page.
|
|
1102
|
+
*/
|
|
1103
|
+
declare function getWebFontStylesheetUrl(family: string): string;
|
|
1104
|
+
export { getWebFontStylesheetUrl }
|
|
1105
|
+
export { getWebFontStylesheetUrl as getWebFontStylesheetUrl_alias_1 }
|
|
1106
|
+
|
|
1083
1107
|
declare type GradientValue = string | {
|
|
1084
1108
|
from: string;
|
|
1085
1109
|
to: string;
|
|
@@ -1229,6 +1253,11 @@ export { isValidVariableName }
|
|
|
1229
1253
|
export { isValidVariableName as isValidVariableName_alias_1 }
|
|
1230
1254
|
export { isValidVariableName as isValidVariableName_alias_2 }
|
|
1231
1255
|
|
|
1256
|
+
/** If this family is one a journey must load from the web to show it. */
|
|
1257
|
+
declare function isWebFontFamily(family: string | undefined): family is string;
|
|
1258
|
+
export { isWebFontFamily }
|
|
1259
|
+
export { isWebFontFamily as isWebFontFamily_alias_1 }
|
|
1260
|
+
|
|
1232
1261
|
declare type ItemRecord = Record<string, unknown>;
|
|
1233
1262
|
|
|
1234
1263
|
declare function Journey({ apiKey, journeyId, config, baseUrl, storageKey, onEvent, onOpenURL, className, presentation, theme, initialAnswers, initialOptions, onDiscountCodeApply, loadingComponent, errorComponent, capture, identity, }: JourneyProps): JSX.Element;
|
|
@@ -2931,6 +2960,16 @@ export { useJourneyState as useJourneyState_alias_1 }
|
|
|
2931
2960
|
/** Media playback is a presentation side effect; preloading only fetches assets. */
|
|
2932
2961
|
export declare function useJourneyVideo(autoplay: boolean, source?: string): RefObject<HTMLVideoElement | null>;
|
|
2933
2962
|
|
|
2963
|
+
/**
|
|
2964
|
+
* Loads the web fonts a journey uses, by one stylesheet link for each in
|
|
2965
|
+
* the document head. A link stays for the life of the page: another journey
|
|
2966
|
+
* on it, or the same one after an edit, can use the font at once, and a
|
|
2967
|
+
* font is never asked for twice.
|
|
2968
|
+
*/
|
|
2969
|
+
declare function useJourneyWebFonts(config: JourneyConfig): void;
|
|
2970
|
+
export { useJourneyWebFonts }
|
|
2971
|
+
export { useJourneyWebFonts as useJourneyWebFonts_alias_1 }
|
|
2972
|
+
|
|
2934
2973
|
export declare function VideoBlock({ src, previewImage, captions, autoplay, loop, muted, controls, aspectRatio, youtubeId, vimeoId, className, }: VideoBlockProps): JSX.Element;
|
|
2935
2974
|
|
|
2936
2975
|
declare type VideoBlockProps = {
|
package/dist/index.cjs
CHANGED
|
@@ -90,6 +90,111 @@ var init_motion_features = __esm({
|
|
|
90
90
|
motion_features_default = react.domMax;
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
|
+
|
|
94
|
+
// src/lib/web-fonts.ts
|
|
95
|
+
var FONT_VARIABLE = "--jy-font-family";
|
|
96
|
+
var BUILT_IN_FAMILIES = /* @__PURE__ */ new Set([
|
|
97
|
+
"inter",
|
|
98
|
+
"inter variable",
|
|
99
|
+
"lora",
|
|
100
|
+
"lora variable",
|
|
101
|
+
"google sans",
|
|
102
|
+
"product sans",
|
|
103
|
+
"serif",
|
|
104
|
+
"sans-serif",
|
|
105
|
+
"monospace",
|
|
106
|
+
"cursive",
|
|
107
|
+
"fantasy",
|
|
108
|
+
"system-ui",
|
|
109
|
+
"ui-serif",
|
|
110
|
+
"ui-sans-serif",
|
|
111
|
+
"ui-monospace",
|
|
112
|
+
"ui-rounded",
|
|
113
|
+
"math",
|
|
114
|
+
"emoji",
|
|
115
|
+
"inherit",
|
|
116
|
+
"initial",
|
|
117
|
+
"unset",
|
|
118
|
+
"georgia",
|
|
119
|
+
"times new roman",
|
|
120
|
+
"arial",
|
|
121
|
+
"helvetica",
|
|
122
|
+
"helvetica neue",
|
|
123
|
+
"courier new",
|
|
124
|
+
"segoe ui",
|
|
125
|
+
"sf pro text",
|
|
126
|
+
"blinkmacsystemfont",
|
|
127
|
+
"-apple-system"
|
|
128
|
+
]);
|
|
129
|
+
var FAMILY_NAME = /^[A-Za-z0-9][A-Za-z0-9 ]{0,62}$/;
|
|
130
|
+
function firstFontFamily(stack) {
|
|
131
|
+
var _a;
|
|
132
|
+
const first = (_a = stack == null ? void 0 : stack.split(",", 1)[0]) == null ? void 0 : _a.trim();
|
|
133
|
+
if (!first) return void 0;
|
|
134
|
+
const name = first.replace(/^(['"])(.*)\1$/, "$2").trim();
|
|
135
|
+
return name || void 0;
|
|
136
|
+
}
|
|
137
|
+
function isWebFontFamily(family) {
|
|
138
|
+
if (!family) return false;
|
|
139
|
+
if (!FAMILY_NAME.test(family)) return false;
|
|
140
|
+
return !BUILT_IN_FAMILIES.has(family.toLowerCase());
|
|
141
|
+
}
|
|
142
|
+
function collectFontFamilies(value, found) {
|
|
143
|
+
if (Array.isArray(value)) {
|
|
144
|
+
for (const item of value) collectFontFamilies(item, found);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (!value || typeof value !== "object") return;
|
|
148
|
+
for (const [key, child] of Object.entries(value)) {
|
|
149
|
+
if (key === "fontFamily" && typeof child === "string") {
|
|
150
|
+
const family = firstFontFamily(child);
|
|
151
|
+
if (isWebFontFamily(family)) found.add(family);
|
|
152
|
+
} else {
|
|
153
|
+
collectFontFamilies(child, found);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function getJourneyWebFontFamilies(config) {
|
|
158
|
+
var _a;
|
|
159
|
+
const found = /* @__PURE__ */ new Set();
|
|
160
|
+
const journeyFont = firstFontFamily((_a = config.themeVariables) == null ? void 0 : _a[FONT_VARIABLE]);
|
|
161
|
+
if (isWebFontFamily(journeyFont)) found.add(journeyFont);
|
|
162
|
+
collectFontFamilies(config.steps, found);
|
|
163
|
+
const byName = /* @__PURE__ */ new Map();
|
|
164
|
+
for (const family of found) {
|
|
165
|
+
const key = family.toLowerCase();
|
|
166
|
+
if (!byName.has(key)) byName.set(key, family);
|
|
167
|
+
}
|
|
168
|
+
return [...byName.values()].sort((a, b) => a.localeCompare(b));
|
|
169
|
+
}
|
|
170
|
+
function getWebFontStylesheetUrl(family) {
|
|
171
|
+
const name = family.trim().toLowerCase().replace(/\s+/g, "-");
|
|
172
|
+
return `https://fonts.bunny.net/css?family=${encodeURIComponent(name)}:300,300i,400,400i,500,500i,600,600i,700,700i,800,900&display=swap`;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/engine/use-journey-web-fonts.ts
|
|
176
|
+
var LINK_MARK = "data-journey-web-font";
|
|
177
|
+
function useJourneyWebFonts(config) {
|
|
178
|
+
const families = React.useMemo(() => getJourneyWebFontFamilies(config), [config]);
|
|
179
|
+
const signature = families.join("|");
|
|
180
|
+
React.useEffect(() => {
|
|
181
|
+
var _a;
|
|
182
|
+
if (typeof document === "undefined" || !signature) return;
|
|
183
|
+
for (const family of signature.split("|")) {
|
|
184
|
+
const key = family.toLowerCase();
|
|
185
|
+
if (document.head.querySelector(`link[${LINK_MARK}="${key}"]`)) continue;
|
|
186
|
+
const onPage = [...(_a = document.fonts) != null ? _a : []].some(
|
|
187
|
+
(face) => face.family.replace(/^(['"])(.*)\1$/, "$2").toLowerCase() === key
|
|
188
|
+
);
|
|
189
|
+
if (onPage) continue;
|
|
190
|
+
const link = document.createElement("link");
|
|
191
|
+
link.rel = "stylesheet";
|
|
192
|
+
link.href = getWebFontStylesheetUrl(family);
|
|
193
|
+
link.setAttribute(LINK_MARK, key);
|
|
194
|
+
document.head.append(link);
|
|
195
|
+
}
|
|
196
|
+
}, [signature]);
|
|
197
|
+
}
|
|
93
198
|
var JourneyPresentationContext = React.createContext(true);
|
|
94
199
|
function useJourneyPresented() {
|
|
95
200
|
return React.useContext(JourneyPresentationContext);
|
|
@@ -2739,6 +2844,7 @@ function useJourneyProviderRuntime({
|
|
|
2739
2844
|
() => getComputedVariableIds(config.computedVariables),
|
|
2740
2845
|
[config.computedVariables]
|
|
2741
2846
|
);
|
|
2847
|
+
useJourneyWebFonts(config);
|
|
2742
2848
|
const providerThemeStyle = React.useMemo(() => {
|
|
2743
2849
|
const themeVariables = config.themeVariables ? Object.fromEntries(
|
|
2744
2850
|
Object.entries(config.themeVariables).filter(
|
|
@@ -4715,7 +4821,7 @@ function resolveJourneyFontFamily(fontFamily) {
|
|
|
4715
4821
|
case "google sans":
|
|
4716
4822
|
return GOOGLE_SANS_STACK;
|
|
4717
4823
|
default:
|
|
4718
|
-
return value
|
|
4824
|
+
return value.includes(",") ? value : `"${value.replace(/^(['"])(.*)\1$/, "$2")}", ${INTER_STACK}`;
|
|
4719
4825
|
}
|
|
4720
4826
|
}
|
|
4721
4827
|
|
|
@@ -12718,7 +12824,7 @@ function useJourneyConfig({
|
|
|
12718
12824
|
|
|
12719
12825
|
// src/engine/journey-capture.ts
|
|
12720
12826
|
var JOURNEY_LIBRARY_NAME = "@founderhq/journeys";
|
|
12721
|
-
var JOURNEY_LIBRARY_VERSION = "0.
|
|
12827
|
+
var JOURNEY_LIBRARY_VERSION = "1.0.0";
|
|
12722
12828
|
var DEFAULT_QUEUE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
12723
12829
|
var MAX_QUEUED_CAPTURE_EVENTS = 100;
|
|
12724
12830
|
var MAX_BEACON_BYTES = 60 * 1024;
|
|
@@ -13463,13 +13569,17 @@ exports.createStepTypeDefaults = createStepTypeDefaults;
|
|
|
13463
13569
|
exports.createVariableName = createVariableName;
|
|
13464
13570
|
exports.evaluateCondition = evaluateCondition;
|
|
13465
13571
|
exports.eventsStorageKey = eventsStorageKey;
|
|
13572
|
+
exports.firstFontFamily = firstFontFamily;
|
|
13573
|
+
exports.getJourneyWebFontFamilies = getJourneyWebFontFamilies;
|
|
13466
13574
|
exports.getScreenNameError = getScreenNameError;
|
|
13467
13575
|
exports.getStableItemEntries = getStableItemEntries;
|
|
13468
13576
|
exports.getStepVariable = getStepVariable;
|
|
13469
13577
|
exports.getVariableNameError = getVariableNameError;
|
|
13578
|
+
exports.getWebFontStylesheetUrl = getWebFontStylesheetUrl;
|
|
13470
13579
|
exports.hasVisibleProgress = hasVisibleProgress;
|
|
13471
13580
|
exports.isValidScreenName = isValidScreenName;
|
|
13472
13581
|
exports.isValidVariableName = isValidVariableName;
|
|
13582
|
+
exports.isWebFontFamily = isWebFontFamily;
|
|
13473
13583
|
exports.normalizeBlockConfig = normalizeBlockConfig;
|
|
13474
13584
|
exports.normalizeBlockConfigs = normalizeBlockConfigs;
|
|
13475
13585
|
exports.normalizeJourneyConfig = normalizeJourneyConfig;
|
|
@@ -13488,4 +13598,5 @@ exports.useJourneyActions = useJourneyActions;
|
|
|
13488
13598
|
exports.useJourneyCaptureRuntime = useJourneyCaptureRuntime;
|
|
13489
13599
|
exports.useJourneyConfig = useJourneyConfig;
|
|
13490
13600
|
exports.useJourneyState = useJourneyState;
|
|
13601
|
+
exports.useJourneyWebFonts = useJourneyWebFonts;
|
|
13491
13602
|
exports.withDeterministicItemIds = withDeterministicItemIds;
|
package/dist/index.d.cts
CHANGED
|
@@ -63,6 +63,11 @@ export { isValidVariableName } from './_tsup-dts-rollup.cjs';
|
|
|
63
63
|
export { normalizeScreenName } from './_tsup-dts-rollup.cjs';
|
|
64
64
|
export { renameAnswerVariableReferences } from './_tsup-dts-rollup.cjs';
|
|
65
65
|
export { renameVariableInExpression } from './_tsup-dts-rollup.cjs';
|
|
66
|
+
export { useJourneyWebFonts } from './_tsup-dts-rollup.cjs';
|
|
67
|
+
export { firstFontFamily } from './_tsup-dts-rollup.cjs';
|
|
68
|
+
export { getJourneyWebFontFamilies } from './_tsup-dts-rollup.cjs';
|
|
69
|
+
export { getWebFontStylesheetUrl } from './_tsup-dts-rollup.cjs';
|
|
70
|
+
export { isWebFontFamily } from './_tsup-dts-rollup.cjs';
|
|
66
71
|
export { resolveComputedVariables } from './_tsup-dts-rollup.cjs';
|
|
67
72
|
export { resolveComputedVariableValues } from './_tsup-dts-rollup.cjs';
|
|
68
73
|
export { GravityBin } from './_tsup-dts-rollup.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -63,6 +63,11 @@ export { isValidVariableName } from './_tsup-dts-rollup.js';
|
|
|
63
63
|
export { normalizeScreenName } from './_tsup-dts-rollup.js';
|
|
64
64
|
export { renameAnswerVariableReferences } from './_tsup-dts-rollup.js';
|
|
65
65
|
export { renameVariableInExpression } from './_tsup-dts-rollup.js';
|
|
66
|
+
export { useJourneyWebFonts } from './_tsup-dts-rollup.js';
|
|
67
|
+
export { firstFontFamily } from './_tsup-dts-rollup.js';
|
|
68
|
+
export { getJourneyWebFontFamilies } from './_tsup-dts-rollup.js';
|
|
69
|
+
export { getWebFontStylesheetUrl } from './_tsup-dts-rollup.js';
|
|
70
|
+
export { isWebFontFamily } from './_tsup-dts-rollup.js';
|
|
66
71
|
export { resolveComputedVariables } from './_tsup-dts-rollup.js';
|
|
67
72
|
export { resolveComputedVariableValues } from './_tsup-dts-rollup.js';
|
|
68
73
|
export { GravityBin } from './_tsup-dts-rollup.js';
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,110 @@ import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
|
17
17
|
import { DotLottieReact } from '@lottiefiles/dotlottie-react';
|
|
18
18
|
import useEmblaCarousel from 'embla-carousel-react';
|
|
19
19
|
|
|
20
|
+
// src/lib/web-fonts.ts
|
|
21
|
+
var FONT_VARIABLE = "--jy-font-family";
|
|
22
|
+
var BUILT_IN_FAMILIES = /* @__PURE__ */ new Set([
|
|
23
|
+
"inter",
|
|
24
|
+
"inter variable",
|
|
25
|
+
"lora",
|
|
26
|
+
"lora variable",
|
|
27
|
+
"google sans",
|
|
28
|
+
"product sans",
|
|
29
|
+
"serif",
|
|
30
|
+
"sans-serif",
|
|
31
|
+
"monospace",
|
|
32
|
+
"cursive",
|
|
33
|
+
"fantasy",
|
|
34
|
+
"system-ui",
|
|
35
|
+
"ui-serif",
|
|
36
|
+
"ui-sans-serif",
|
|
37
|
+
"ui-monospace",
|
|
38
|
+
"ui-rounded",
|
|
39
|
+
"math",
|
|
40
|
+
"emoji",
|
|
41
|
+
"inherit",
|
|
42
|
+
"initial",
|
|
43
|
+
"unset",
|
|
44
|
+
"georgia",
|
|
45
|
+
"times new roman",
|
|
46
|
+
"arial",
|
|
47
|
+
"helvetica",
|
|
48
|
+
"helvetica neue",
|
|
49
|
+
"courier new",
|
|
50
|
+
"segoe ui",
|
|
51
|
+
"sf pro text",
|
|
52
|
+
"blinkmacsystemfont",
|
|
53
|
+
"-apple-system"
|
|
54
|
+
]);
|
|
55
|
+
var FAMILY_NAME = /^[A-Za-z0-9][A-Za-z0-9 ]{0,62}$/;
|
|
56
|
+
function firstFontFamily(stack) {
|
|
57
|
+
var _a;
|
|
58
|
+
const first = (_a = stack == null ? void 0 : stack.split(",", 1)[0]) == null ? void 0 : _a.trim();
|
|
59
|
+
if (!first) return void 0;
|
|
60
|
+
const name = first.replace(/^(['"])(.*)\1$/, "$2").trim();
|
|
61
|
+
return name || void 0;
|
|
62
|
+
}
|
|
63
|
+
function isWebFontFamily(family) {
|
|
64
|
+
if (!family) return false;
|
|
65
|
+
if (!FAMILY_NAME.test(family)) return false;
|
|
66
|
+
return !BUILT_IN_FAMILIES.has(family.toLowerCase());
|
|
67
|
+
}
|
|
68
|
+
function collectFontFamilies(value, found) {
|
|
69
|
+
if (Array.isArray(value)) {
|
|
70
|
+
for (const item of value) collectFontFamilies(item, found);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!value || typeof value !== "object") return;
|
|
74
|
+
for (const [key, child] of Object.entries(value)) {
|
|
75
|
+
if (key === "fontFamily" && typeof child === "string") {
|
|
76
|
+
const family = firstFontFamily(child);
|
|
77
|
+
if (isWebFontFamily(family)) found.add(family);
|
|
78
|
+
} else {
|
|
79
|
+
collectFontFamilies(child, found);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function getJourneyWebFontFamilies(config) {
|
|
84
|
+
var _a;
|
|
85
|
+
const found = /* @__PURE__ */ new Set();
|
|
86
|
+
const journeyFont = firstFontFamily((_a = config.themeVariables) == null ? void 0 : _a[FONT_VARIABLE]);
|
|
87
|
+
if (isWebFontFamily(journeyFont)) found.add(journeyFont);
|
|
88
|
+
collectFontFamilies(config.steps, found);
|
|
89
|
+
const byName = /* @__PURE__ */ new Map();
|
|
90
|
+
for (const family of found) {
|
|
91
|
+
const key = family.toLowerCase();
|
|
92
|
+
if (!byName.has(key)) byName.set(key, family);
|
|
93
|
+
}
|
|
94
|
+
return [...byName.values()].sort((a, b) => a.localeCompare(b));
|
|
95
|
+
}
|
|
96
|
+
function getWebFontStylesheetUrl(family) {
|
|
97
|
+
const name = family.trim().toLowerCase().replace(/\s+/g, "-");
|
|
98
|
+
return `https://fonts.bunny.net/css?family=${encodeURIComponent(name)}:300,300i,400,400i,500,500i,600,600i,700,700i,800,900&display=swap`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/engine/use-journey-web-fonts.ts
|
|
102
|
+
var LINK_MARK = "data-journey-web-font";
|
|
103
|
+
function useJourneyWebFonts(config) {
|
|
104
|
+
const families = useMemo(() => getJourneyWebFontFamilies(config), [config]);
|
|
105
|
+
const signature = families.join("|");
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
var _a;
|
|
108
|
+
if (typeof document === "undefined" || !signature) return;
|
|
109
|
+
for (const family of signature.split("|")) {
|
|
110
|
+
const key = family.toLowerCase();
|
|
111
|
+
if (document.head.querySelector(`link[${LINK_MARK}="${key}"]`)) continue;
|
|
112
|
+
const onPage = [...(_a = document.fonts) != null ? _a : []].some(
|
|
113
|
+
(face) => face.family.replace(/^(['"])(.*)\1$/, "$2").toLowerCase() === key
|
|
114
|
+
);
|
|
115
|
+
if (onPage) continue;
|
|
116
|
+
const link = document.createElement("link");
|
|
117
|
+
link.rel = "stylesheet";
|
|
118
|
+
link.href = getWebFontStylesheetUrl(family);
|
|
119
|
+
link.setAttribute(LINK_MARK, key);
|
|
120
|
+
document.head.append(link);
|
|
121
|
+
}
|
|
122
|
+
}, [signature]);
|
|
123
|
+
}
|
|
20
124
|
var JourneyPresentationContext = createContext(true);
|
|
21
125
|
function useJourneyPresented() {
|
|
22
126
|
return useContext(JourneyPresentationContext);
|
|
@@ -633,6 +737,7 @@ function useJourneyProviderRuntime({
|
|
|
633
737
|
() => getComputedVariableIds(config.computedVariables),
|
|
634
738
|
[config.computedVariables]
|
|
635
739
|
);
|
|
740
|
+
useJourneyWebFonts(config);
|
|
636
741
|
const providerThemeStyle = useMemo(() => {
|
|
637
742
|
const themeVariables = config.themeVariables ? Object.fromEntries(
|
|
638
743
|
Object.entries(config.themeVariables).filter(
|
|
@@ -2609,7 +2714,7 @@ function resolveJourneyFontFamily(fontFamily) {
|
|
|
2609
2714
|
case "google sans":
|
|
2610
2715
|
return GOOGLE_SANS_STACK;
|
|
2611
2716
|
default:
|
|
2612
|
-
return value
|
|
2717
|
+
return value.includes(",") ? value : `"${value.replace(/^(['"])(.*)\1$/, "$2")}", ${INTER_STACK}`;
|
|
2613
2718
|
}
|
|
2614
2719
|
}
|
|
2615
2720
|
|
|
@@ -10612,7 +10717,7 @@ function useJourneyConfig({
|
|
|
10612
10717
|
|
|
10613
10718
|
// src/engine/journey-capture.ts
|
|
10614
10719
|
var JOURNEY_LIBRARY_NAME = "@founderhq/journeys";
|
|
10615
|
-
var JOURNEY_LIBRARY_VERSION = "0.
|
|
10720
|
+
var JOURNEY_LIBRARY_VERSION = "1.0.0";
|
|
10616
10721
|
var DEFAULT_QUEUE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
10617
10722
|
var MAX_QUEUED_CAPTURE_EVENTS = 100;
|
|
10618
10723
|
var MAX_BEACON_BYTES = 60 * 1024;
|
|
@@ -11332,4 +11437,4 @@ function Journey({
|
|
|
11332
11437
|
);
|
|
11333
11438
|
}
|
|
11334
11439
|
|
|
11335
|
-
export { BLOCK_META, DiscountCodeDialog, GravityBin, Journey, JourneyBlobLayer, JourneyContext, JourneyHapticContext, JourneyProvider, JourneyShell, SegmentedProgress, StepRenderer, TimelineBlock, arePageInputsValid, evaluateCondition, eventsStorageKey, hasVisibleProgress, resolveJourneyBlobDefaultSize, resolveJourneyFontFamily, resolveJourneyIdentity, resolveStepBackgroundMode, useJourneyActions, useJourneyCaptureRuntime, useJourneyConfig, useJourneyState };
|
|
11440
|
+
export { BLOCK_META, DiscountCodeDialog, GravityBin, Journey, JourneyBlobLayer, JourneyContext, JourneyHapticContext, JourneyProvider, JourneyShell, SegmentedProgress, StepRenderer, TimelineBlock, arePageInputsValid, evaluateCondition, eventsStorageKey, firstFontFamily, getJourneyWebFontFamilies, getWebFontStylesheetUrl, hasVisibleProgress, isWebFontFamily, resolveJourneyBlobDefaultSize, resolveJourneyFontFamily, resolveJourneyIdentity, resolveStepBackgroundMode, useJourneyActions, useJourneyCaptureRuntime, useJourneyConfig, useJourneyState, useJourneyWebFonts };
|