@founderhq/journeys 0.9.0 → 1.0.1
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/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/_tsup-dts-rollup.d.cts +39 -0
- package/dist/_tsup-dts-rollup.d.ts +39 -0
- package/dist/index.cjs +120 -4
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +108 -3
- package/dist/styles.css +2 -2
- package/package.json +22 -20
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Astrophage Labs (FounderHQ)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -323,6 +323,11 @@ architecture and security model are documented in
|
|
|
323
323
|
|
|
324
324
|
## Release notes
|
|
325
325
|
|
|
326
|
+
### 1.0.1
|
|
327
|
+
|
|
328
|
+
- The package now ships its MIT licence: a `LICENSE` file and the `license` field.
|
|
329
|
+
- Updated dependencies, among them `motion` 14 and `@lottiefiles/dotlottie-react` 0.21.
|
|
330
|
+
|
|
326
331
|
### 0.8.1
|
|
327
332
|
|
|
328
333
|
Native Android hosts can provide measured safe-area insets. The renderer keeps progress, navigation, and overlays clear of system bars on older WebViews while preserving edge-to-edge backgrounds and the existing iOS CSS inset behavior.
|
|
@@ -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
|
@@ -71,8 +71,13 @@ var __objRest = (source, exclude) => {
|
|
|
71
71
|
}
|
|
72
72
|
return target;
|
|
73
73
|
};
|
|
74
|
-
var __esm = (fn, res) => function __init() {
|
|
75
|
-
|
|
74
|
+
var __esm = (fn, res, err) => function __init() {
|
|
75
|
+
if (err) throw err[0];
|
|
76
|
+
try {
|
|
77
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
78
|
+
} catch (e) {
|
|
79
|
+
throw err = [e], e;
|
|
80
|
+
}
|
|
76
81
|
};
|
|
77
82
|
var __export = (target, all) => {
|
|
78
83
|
for (var name in all)
|
|
@@ -90,6 +95,111 @@ var init_motion_features = __esm({
|
|
|
90
95
|
motion_features_default = react.domMax;
|
|
91
96
|
}
|
|
92
97
|
});
|
|
98
|
+
|
|
99
|
+
// src/lib/web-fonts.ts
|
|
100
|
+
var FONT_VARIABLE = "--jy-font-family";
|
|
101
|
+
var BUILT_IN_FAMILIES = /* @__PURE__ */ new Set([
|
|
102
|
+
"inter",
|
|
103
|
+
"inter variable",
|
|
104
|
+
"lora",
|
|
105
|
+
"lora variable",
|
|
106
|
+
"google sans",
|
|
107
|
+
"product sans",
|
|
108
|
+
"serif",
|
|
109
|
+
"sans-serif",
|
|
110
|
+
"monospace",
|
|
111
|
+
"cursive",
|
|
112
|
+
"fantasy",
|
|
113
|
+
"system-ui",
|
|
114
|
+
"ui-serif",
|
|
115
|
+
"ui-sans-serif",
|
|
116
|
+
"ui-monospace",
|
|
117
|
+
"ui-rounded",
|
|
118
|
+
"math",
|
|
119
|
+
"emoji",
|
|
120
|
+
"inherit",
|
|
121
|
+
"initial",
|
|
122
|
+
"unset",
|
|
123
|
+
"georgia",
|
|
124
|
+
"times new roman",
|
|
125
|
+
"arial",
|
|
126
|
+
"helvetica",
|
|
127
|
+
"helvetica neue",
|
|
128
|
+
"courier new",
|
|
129
|
+
"segoe ui",
|
|
130
|
+
"sf pro text",
|
|
131
|
+
"blinkmacsystemfont",
|
|
132
|
+
"-apple-system"
|
|
133
|
+
]);
|
|
134
|
+
var FAMILY_NAME = /^[A-Za-z0-9][A-Za-z0-9 ]{0,62}$/;
|
|
135
|
+
function firstFontFamily(stack) {
|
|
136
|
+
var _a;
|
|
137
|
+
const first = (_a = stack == null ? void 0 : stack.split(",", 1)[0]) == null ? void 0 : _a.trim();
|
|
138
|
+
if (!first) return void 0;
|
|
139
|
+
const name = first.replace(/^(['"])(.*)\1$/, "$2").trim();
|
|
140
|
+
return name || void 0;
|
|
141
|
+
}
|
|
142
|
+
function isWebFontFamily(family) {
|
|
143
|
+
if (!family) return false;
|
|
144
|
+
if (!FAMILY_NAME.test(family)) return false;
|
|
145
|
+
return !BUILT_IN_FAMILIES.has(family.toLowerCase());
|
|
146
|
+
}
|
|
147
|
+
function collectFontFamilies(value, found) {
|
|
148
|
+
if (Array.isArray(value)) {
|
|
149
|
+
for (const item of value) collectFontFamilies(item, found);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (!value || typeof value !== "object") return;
|
|
153
|
+
for (const [key, child] of Object.entries(value)) {
|
|
154
|
+
if (key === "fontFamily" && typeof child === "string") {
|
|
155
|
+
const family = firstFontFamily(child);
|
|
156
|
+
if (isWebFontFamily(family)) found.add(family);
|
|
157
|
+
} else {
|
|
158
|
+
collectFontFamilies(child, found);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function getJourneyWebFontFamilies(config) {
|
|
163
|
+
var _a;
|
|
164
|
+
const found = /* @__PURE__ */ new Set();
|
|
165
|
+
const journeyFont = firstFontFamily((_a = config.themeVariables) == null ? void 0 : _a[FONT_VARIABLE]);
|
|
166
|
+
if (isWebFontFamily(journeyFont)) found.add(journeyFont);
|
|
167
|
+
collectFontFamilies(config.steps, found);
|
|
168
|
+
const byName = /* @__PURE__ */ new Map();
|
|
169
|
+
for (const family of found) {
|
|
170
|
+
const key = family.toLowerCase();
|
|
171
|
+
if (!byName.has(key)) byName.set(key, family);
|
|
172
|
+
}
|
|
173
|
+
return [...byName.values()].sort((a, b) => a.localeCompare(b));
|
|
174
|
+
}
|
|
175
|
+
function getWebFontStylesheetUrl(family) {
|
|
176
|
+
const name = family.trim().toLowerCase().replace(/\s+/g, "-");
|
|
177
|
+
return `https://fonts.bunny.net/css?family=${encodeURIComponent(name)}:300,300i,400,400i,500,500i,600,600i,700,700i,800,900&display=swap`;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// src/engine/use-journey-web-fonts.ts
|
|
181
|
+
var LINK_MARK = "data-journey-web-font";
|
|
182
|
+
function useJourneyWebFonts(config) {
|
|
183
|
+
const families = React.useMemo(() => getJourneyWebFontFamilies(config), [config]);
|
|
184
|
+
const signature = families.join("|");
|
|
185
|
+
React.useEffect(() => {
|
|
186
|
+
var _a;
|
|
187
|
+
if (typeof document === "undefined" || !signature) return;
|
|
188
|
+
for (const family of signature.split("|")) {
|
|
189
|
+
const key = family.toLowerCase();
|
|
190
|
+
if (document.head.querySelector(`link[${LINK_MARK}="${key}"]`)) continue;
|
|
191
|
+
const onPage = [...(_a = document.fonts) != null ? _a : []].some(
|
|
192
|
+
(face) => face.family.replace(/^(['"])(.*)\1$/, "$2").toLowerCase() === key
|
|
193
|
+
);
|
|
194
|
+
if (onPage) continue;
|
|
195
|
+
const link = document.createElement("link");
|
|
196
|
+
link.rel = "stylesheet";
|
|
197
|
+
link.href = getWebFontStylesheetUrl(family);
|
|
198
|
+
link.setAttribute(LINK_MARK, key);
|
|
199
|
+
document.head.append(link);
|
|
200
|
+
}
|
|
201
|
+
}, [signature]);
|
|
202
|
+
}
|
|
93
203
|
var JourneyPresentationContext = React.createContext(true);
|
|
94
204
|
function useJourneyPresented() {
|
|
95
205
|
return React.useContext(JourneyPresentationContext);
|
|
@@ -2739,6 +2849,7 @@ function useJourneyProviderRuntime({
|
|
|
2739
2849
|
() => getComputedVariableIds(config.computedVariables),
|
|
2740
2850
|
[config.computedVariables]
|
|
2741
2851
|
);
|
|
2852
|
+
useJourneyWebFonts(config);
|
|
2742
2853
|
const providerThemeStyle = React.useMemo(() => {
|
|
2743
2854
|
const themeVariables = config.themeVariables ? Object.fromEntries(
|
|
2744
2855
|
Object.entries(config.themeVariables).filter(
|
|
@@ -4715,7 +4826,7 @@ function resolveJourneyFontFamily(fontFamily) {
|
|
|
4715
4826
|
case "google sans":
|
|
4716
4827
|
return GOOGLE_SANS_STACK;
|
|
4717
4828
|
default:
|
|
4718
|
-
return value
|
|
4829
|
+
return value.includes(",") ? value : `"${value.replace(/^(['"])(.*)\1$/, "$2")}", ${INTER_STACK}`;
|
|
4719
4830
|
}
|
|
4720
4831
|
}
|
|
4721
4832
|
|
|
@@ -12718,7 +12829,7 @@ function useJourneyConfig({
|
|
|
12718
12829
|
|
|
12719
12830
|
// src/engine/journey-capture.ts
|
|
12720
12831
|
var JOURNEY_LIBRARY_NAME = "@founderhq/journeys";
|
|
12721
|
-
var JOURNEY_LIBRARY_VERSION = "0.
|
|
12832
|
+
var JOURNEY_LIBRARY_VERSION = "1.0.1";
|
|
12722
12833
|
var DEFAULT_QUEUE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
12723
12834
|
var MAX_QUEUED_CAPTURE_EVENTS = 100;
|
|
12724
12835
|
var MAX_BEACON_BYTES = 60 * 1024;
|
|
@@ -13463,13 +13574,17 @@ exports.createStepTypeDefaults = createStepTypeDefaults;
|
|
|
13463
13574
|
exports.createVariableName = createVariableName;
|
|
13464
13575
|
exports.evaluateCondition = evaluateCondition;
|
|
13465
13576
|
exports.eventsStorageKey = eventsStorageKey;
|
|
13577
|
+
exports.firstFontFamily = firstFontFamily;
|
|
13578
|
+
exports.getJourneyWebFontFamilies = getJourneyWebFontFamilies;
|
|
13466
13579
|
exports.getScreenNameError = getScreenNameError;
|
|
13467
13580
|
exports.getStableItemEntries = getStableItemEntries;
|
|
13468
13581
|
exports.getStepVariable = getStepVariable;
|
|
13469
13582
|
exports.getVariableNameError = getVariableNameError;
|
|
13583
|
+
exports.getWebFontStylesheetUrl = getWebFontStylesheetUrl;
|
|
13470
13584
|
exports.hasVisibleProgress = hasVisibleProgress;
|
|
13471
13585
|
exports.isValidScreenName = isValidScreenName;
|
|
13472
13586
|
exports.isValidVariableName = isValidVariableName;
|
|
13587
|
+
exports.isWebFontFamily = isWebFontFamily;
|
|
13473
13588
|
exports.normalizeBlockConfig = normalizeBlockConfig;
|
|
13474
13589
|
exports.normalizeBlockConfigs = normalizeBlockConfigs;
|
|
13475
13590
|
exports.normalizeJourneyConfig = normalizeJourneyConfig;
|
|
@@ -13488,4 +13603,5 @@ exports.useJourneyActions = useJourneyActions;
|
|
|
13488
13603
|
exports.useJourneyCaptureRuntime = useJourneyCaptureRuntime;
|
|
13489
13604
|
exports.useJourneyConfig = useJourneyConfig;
|
|
13490
13605
|
exports.useJourneyState = useJourneyState;
|
|
13606
|
+
exports.useJourneyWebFonts = useJourneyWebFonts;
|
|
13491
13607
|
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.1";
|
|
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 };
|