@rocapine/react-native-onboarding 1.44.0 → 1.44.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.
@@ -1,14 +1,15 @@
1
- import type { FontRegistry } from "./registry";
1
+ import type { FontRegistry, FontStyleKey } from "./registry";
2
2
  export declare const FontRegistryProvider: import("react").Provider<FontRegistry>;
3
3
  export declare const useFontRegistry: () => FontRegistry;
4
- export declare const useResolvedFontFamily: (family: string | null | undefined, weight: string | number | null | undefined) => string | undefined;
4
+ export declare const useResolvedFontFamily: (family: string | null | undefined, weight: string | number | null | undefined, fontStyle?: FontStyleKey | string | null) => string | undefined;
5
5
  /**
6
- * Resolves a `family + weight` request to a registered font name. Returns
7
- * `resolvedToVariant: true` when the registry matched a concrete weighted
8
- * variant — callers should then suppress `fontWeight` on the rendered Text to
9
- * avoid synthetic emboldening on top of an already-weighted font file.
6
+ * Resolves a `family + weight + style` request to a registered font name.
7
+ * Returns `resolvedToVariant: true` when the registry matched a concrete
8
+ * weighted variant — callers should then suppress `fontWeight` on the rendered
9
+ * Text to avoid synthetic emboldening on top of an already-weighted font file.
10
+ * Pass `fontStyle: "italic"` to select the italic face when one is registered.
10
11
  */
11
- export declare const useResolvedFontStyle: (family: string | null | undefined, weight: string | number | null | undefined) => {
12
+ export declare const useResolvedFontStyle: (family: string | null | undefined, weight: string | number | null | undefined, fontStyle?: FontStyleKey | string | null) => {
12
13
  fontFamily: string | undefined;
13
14
  fontWeight: string | number | undefined;
14
15
  resolvedToVariant: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"FontRegistryContext.d.ts","sourceRoot":"","sources":["../../../src/infra/fonts/FontRegistryContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAK/C,eAAO,MAAM,oBAAoB,wCAA+B,CAAC;AAEjE,eAAO,MAAM,eAAe,QAAO,YAA+C,CAAC;AAEnF,eAAO,MAAM,qBAAqB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Context = (0, react_1.createContext)({});
7
7
  exports.FontRegistryProvider = FontRegistryContext.Provider;
8
8
  const useFontRegistry = () => (0, react_1.useContext)(FontRegistryContext);
9
9
  exports.useFontRegistry = useFontRegistry;
10
- const useResolvedFontFamily = (family, weight) => {
10
+ const useResolvedFontFamily = (family, weight, fontStyle) => {
11
11
  const registry = (0, exports.useFontRegistry)();
12
- return (0, react_1.useMemo)(() => (0, registry_1.resolveFontFamily)(registry, family, weight), [registry, family, weight]);
12
+ return (0, react_1.useMemo)(() => (0, registry_1.resolveFontFamily)(registry, family, weight, fontStyle), [registry, family, weight, fontStyle]);
13
13
  };
14
14
  exports.useResolvedFontFamily = useResolvedFontFamily;
15
15
  /**
16
- * Resolves a `family + weight` request to a registered font name. Returns
17
- * `resolvedToVariant: true` when the registry matched a concrete weighted
18
- * variant — callers should then suppress `fontWeight` on the rendered Text to
19
- * avoid synthetic emboldening on top of an already-weighted font file.
16
+ * Resolves a `family + weight + style` request to a registered font name.
17
+ * Returns `resolvedToVariant: true` when the registry matched a concrete
18
+ * weighted variant — callers should then suppress `fontWeight` on the rendered
19
+ * Text to avoid synthetic emboldening on top of an already-weighted font file.
20
+ * Pass `fontStyle: "italic"` to select the italic face when one is registered.
20
21
  */
21
- const useResolvedFontStyle = (family, weight) => {
22
+ const useResolvedFontStyle = (family, weight, fontStyle) => {
22
23
  const registry = (0, exports.useFontRegistry)();
23
24
  return (0, react_1.useMemo)(() => {
24
- const fontFamily = (0, registry_1.resolveFontFamily)(registry, family, weight);
25
+ const fontFamily = (0, registry_1.resolveFontFamily)(registry, family, weight, fontStyle);
25
26
  const variants = family ? registry === null || registry === void 0 ? void 0 : registry[family] : undefined;
26
27
  const resolvedToVariant = !!variants && fontFamily !== undefined && fontFamily !== family;
27
28
  return {
@@ -29,7 +30,7 @@ const useResolvedFontStyle = (family, weight) => {
29
30
  fontWeight: resolvedToVariant ? undefined : (weight !== null && weight !== void 0 ? weight : undefined),
30
31
  resolvedToVariant,
31
32
  };
32
- }, [registry, family, weight]);
33
+ }, [registry, family, weight, fontStyle]);
33
34
  };
34
35
  exports.useResolvedFontStyle = useResolvedFontStyle;
35
36
  //# sourceMappingURL=FontRegistryContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FontRegistryContext.js","sourceRoot":"","sources":["../../../src/infra/fonts/FontRegistryContext.tsx"],"names":[],"mappings":";;;AAAA,iCAA2D;AAE3D,yCAA+C;AAE/C,MAAM,mBAAmB,GAAG,IAAA,qBAAa,EAAe,EAAE,CAAC,CAAC;AAE/C,QAAA,oBAAoB,GAAG,mBAAmB,CAAC,QAAQ,CAAC;AAE1D,MAAM,eAAe,GAAG,GAAiB,EAAE,CAAC,IAAA,kBAAU,EAAC,mBAAmB,CAAC,CAAC;AAAtE,QAAA,eAAe,mBAAuD;AAE5E,MAAM,qBAAqB,GAAG,CACnC,MAAiC,EACjC,MAA0C,EACtB,EAAE;IACtB,MAAM,QAAQ,GAAG,IAAA,uBAAe,GAAE,CAAC;IACnC,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAA,4BAAiB,EAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAChG,CAAC,CAAC;AANW,QAAA,qBAAqB,yBAMhC;AAEF;;;;;GAKG;AACI,MAAM,oBAAoB,GAAG,CAClC,MAAiC,EACjC,MAA0C,EAK1C,EAAE;IACF,MAAM,QAAQ,GAAG,IAAA,uBAAe,GAAE,CAAC;IACnC,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;QAClB,MAAM,UAAU,GAAG,IAAA,4BAAiB,EAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/D,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACzD,MAAM,i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A,uBAAe,GAAE,CAAC;IACnC,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;QAClB,MAAM,UAAU,GAAG,IAAA,4BAAiB,EAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QAC1E,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACzD,MAAM,iBAAiB,GACrB,CAAC,CAAC,QAAQ,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,MAAM,CAAC;QAClE,OAAO;YACL,UAAU;YACV,UAAU,EAAE,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,SAAS,CAAC;YACjE,iBAAiB;SAClB,CAAC;IACJ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAC5C,CAAC,CAAC;AArBW,QAAA,oBAAoB,wBAqB/B"}
@@ -1,3 +1,3 @@
1
- export { registerFonts, resolveFontFamily, normalizeWeight, type FontRegistry, } from "./registry";
1
+ export { registerFonts, resolveFontFamily, normalizeWeight, normalizeStyle, isSystemFontFamily, type FontRegistry, type RegisteredFace, type FontStyleKey, } from "./registry";
2
2
  export { FontRegistryProvider, useFontRegistry, useResolvedFontFamily, useResolvedFontStyle, } from "./FontRegistryContext";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infra/fonts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infra/fonts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC"}
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useResolvedFontStyle = exports.useResolvedFontFamily = exports.useFontRegistry = exports.FontRegistryProvider = exports.normalizeWeight = exports.resolveFontFamily = exports.registerFonts = void 0;
3
+ exports.useResolvedFontStyle = exports.useResolvedFontFamily = exports.useFontRegistry = exports.FontRegistryProvider = exports.isSystemFontFamily = exports.normalizeStyle = exports.normalizeWeight = exports.resolveFontFamily = exports.registerFonts = void 0;
4
4
  var registry_1 = require("./registry");
5
5
  Object.defineProperty(exports, "registerFonts", { enumerable: true, get: function () { return registry_1.registerFonts; } });
6
6
  Object.defineProperty(exports, "resolveFontFamily", { enumerable: true, get: function () { return registry_1.resolveFontFamily; } });
7
7
  Object.defineProperty(exports, "normalizeWeight", { enumerable: true, get: function () { return registry_1.normalizeWeight; } });
8
+ Object.defineProperty(exports, "normalizeStyle", { enumerable: true, get: function () { return registry_1.normalizeStyle; } });
9
+ Object.defineProperty(exports, "isSystemFontFamily", { enumerable: true, get: function () { return registry_1.isSystemFontFamily; } });
8
10
  var FontRegistryContext_1 = require("./FontRegistryContext");
9
11
  Object.defineProperty(exports, "FontRegistryProvider", { enumerable: true, get: function () { return FontRegistryContext_1.FontRegistryProvider; } });
10
12
  Object.defineProperty(exports, "useFontRegistry", { enumerable: true, get: function () { return FontRegistryContext_1.useFontRegistry; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infra/fonts/index.ts"],"names":[],"mappings":";;;AAAA,uCAKoB;AAJlB,yGAAA,aAAa,OAAA;AACb,6GAAA,iBAAiB,OAAA;AACjB,2GAAA,eAAe,OAAA;AAGjB,6DAK+B;AAJ7B,2HAAA,oBAAoB,OAAA;AACpB,sHAAA,eAAe,OAAA;AACf,4HAAA,qBAAqB,OAAA;AACrB,2HAAA,oBAAoB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infra/fonts/index.ts"],"names":[],"mappings":";;;AAAA,uCASoB;AARlB,yGAAA,aAAa,OAAA;AACb,6GAAA,iBAAiB,OAAA;AACjB,2GAAA,eAAe,OAAA;AACf,0GAAA,cAAc,OAAA;AACd,8GAAA,kBAAkB,OAAA;AAKpB,6DAK+B;AAJ7B,2HAAA,oBAAoB,OAAA;AACpB,sHAAA,eAAe,OAAA;AACf,4HAAA,qBAAqB,OAAA;AACrB,2HAAA,oBAAoB,OAAA"}
@@ -1,6 +1,10 @@
1
1
  import type { FontsManifest, FontWeightKey } from "../../types";
2
- export type FontRegistry = Record<string, Record<number, string>>;
2
+ export type FontStyleKey = "normal" | "italic";
3
+ export type RegisteredFace = Partial<Record<FontStyleKey, string>>;
4
+ export type FontRegistry = Record<string, Record<number, RegisteredFace>>;
3
5
  export declare const normalizeWeight: (key: FontWeightKey | string | number | undefined) => number;
6
+ export declare const normalizeStyle: (style: string | undefined | null) => FontStyleKey;
7
+ export declare const isSystemFontFamily: (family: string | null | undefined) => boolean;
4
8
  export declare const registerFonts: (manifest: FontsManifest | undefined) => Promise<FontRegistry>;
5
- export declare const resolveFontFamily: (registry: FontRegistry | null | undefined, family: string | null | undefined, weight: string | number | null | undefined) => string | undefined;
9
+ export declare const resolveFontFamily: (registry: FontRegistry | null | undefined, family: string | null | undefined, weight: string | number | null | undefined, fontStyle?: FontStyleKey | string | null) => string | undefined;
6
10
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/infra/fonts/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,aAAa,EAEb,aAAa,EACd,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAUlE,eAAO,MAAM,eAAe,GAAI,KAAK,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,KAAG,MAOlF,CAAC;AA8CF,eAAO,MAAM,aAAa,GAAU,UAAU,aAAa,GAAG,SAAS,KAAG,OAAO,CAAC,YAAY,CAgC7F,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,UAAU,YAAY,GAAG,IAAI,GAAG,SAAS,EACzC,QAAQ,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,QAAQ,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,KACzC,MAAM,GAAG,SA0BX,CAAC"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/infra/fonts/registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,aAAa,EAEb,aAAa,EACd,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAG/C,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;AAGnE,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;AAU1E,eAAO,MAAM,eAAe,GAAI,KAAK,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,KAAG,MAOlF,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,GAAG,SAAS,GAAG,IAAI,KAAG,YACxB,CAAC;AAwB3C,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,OAGtE,CAAC;AAoDF,eAAO,MAAM,aAAa,GAAU,UAAU,aAAa,GAAG,SAAS,KAAG,OAAO,CAAC,YAAY,CAyC7F,CAAC;AASF,eAAO,MAAM,iBAAiB,GAC5B,UAAU,YAAY,GAAG,IAAI,GAAG,SAAS,EACzC,QAAQ,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,QAAQ,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EAC1C,YAAY,YAAY,GAAG,MAAM,GAAG,IAAI,KACvC,MAAM,GAAG,SA8BX,CAAC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveFontFamily = exports.registerFonts = exports.normalizeWeight = void 0;
3
+ exports.resolveFontFamily = exports.registerFonts = exports.isSystemFontFamily = exports.normalizeStyle = exports.normalizeWeight = void 0;
4
+ const react_native_1 = require("react-native");
4
5
  const WEIGHT_NAME_TO_NUM = {
5
6
  regular: 400,
6
7
  medium: 500,
@@ -20,7 +21,42 @@ const normalizeWeight = (key) => {
20
21
  return Number.isFinite(parsed) ? parsed : 400;
21
22
  };
22
23
  exports.normalizeWeight = normalizeWeight;
23
- const buildRegisteredName = (family, weight) => `${family}-${weight}`;
24
+ const normalizeStyle = (style) => style === "italic" ? "italic" : "normal";
25
+ exports.normalizeStyle = normalizeStyle;
26
+ // Font families whose internal name collides with the iOS system font (SF Pro).
27
+ // Registering custom faces under one of these names makes iOS give the system
28
+ // font precedence, so only Regular resolves — every other weight renders tofu.
29
+ // On iOS we skip registering them and resolve to `fontFamily: undefined` so RN
30
+ // uses the real system font (which *is* SF Pro) honoring `fontWeight`. On
31
+ // Android (no SF Pro system font) the bundled faces register normally.
32
+ const SYSTEM_FONT_FAMILIES = new Set([
33
+ "system",
34
+ "sfpro",
35
+ "sfprodisplay",
36
+ "sfprotext",
37
+ "sfprorounded",
38
+ "sfuidisplay",
39
+ "sfuitext",
40
+ ]);
41
+ const normalizeFamilyKey = (family) => family.toLowerCase().replace(/[\s_.-]+/g, "");
42
+ // True when `family` names a platform system font that must NOT be registered as
43
+ // a bundled face on iOS (see SYSTEM_FONT_FAMILIES). Always false on other
44
+ // platforms — only iOS has the SF Pro collision.
45
+ const isSystemFontFamily = (family) => {
46
+ if (!family || react_native_1.Platform.OS !== "ios")
47
+ return false;
48
+ return SYSTEM_FONT_FAMILIES.has(normalizeFamilyKey(family));
49
+ };
50
+ exports.isSystemFontFamily = isSystemFontFamily;
51
+ // The registered (PostScript) name is the font file's base name, without
52
+ // directory, query string, or extension — e.g. ".../Inter-SemiBold.ttf?v=2"
53
+ // registers as "Inter-SemiBold".
54
+ const buildRegisteredName = (url) => {
55
+ var _a;
56
+ const path = url.split(/[?#]/)[0];
57
+ const file = (_a = path.split("/").pop()) !== null && _a !== void 0 ? _a : path;
58
+ return file.replace(/\.[^.]+$/, "");
59
+ };
24
60
  let expoFontWarned = false;
25
61
  const loadExpoFont = () => {
26
62
  try {
@@ -38,29 +74,28 @@ const normalizeFamilyVariants = (input) => {
38
74
  if (!input)
39
75
  return [];
40
76
  if (Array.isArray(input)) {
41
- const byWeight = new Map();
77
+ // Key by weight+style so an italic face is never overwritten by the upright
78
+ // face at the same weight (and vice-versa). Last entry wins on exact dup.
79
+ const byKey = new Map();
42
80
  for (const entry of input) {
43
81
  if (!entry || typeof entry.url !== "string" || !entry.url)
44
82
  continue;
45
83
  const weight = (0, exports.normalizeWeight)(entry.weight);
46
- const existing = byWeight.get(weight);
47
- const isNormalStyle = !entry.style || entry.style === "normal";
48
- if (!existing || isNormalStyle) {
49
- byWeight.set(weight, { weight, url: entry.url });
50
- }
84
+ const style = (0, exports.normalizeStyle)(entry.style);
85
+ byKey.set(`${weight}-${style}`, { weight, style, url: entry.url });
51
86
  }
52
- return Array.from(byWeight.values());
87
+ return Array.from(byKey.values());
53
88
  }
54
89
  const out = [];
55
90
  for (const [weightKey, url] of Object.entries(input)) {
56
91
  if (typeof url !== "string" || !url)
57
92
  continue;
58
- out.push({ weight: (0, exports.normalizeWeight)(weightKey), url });
93
+ out.push({ weight: (0, exports.normalizeWeight)(weightKey), style: "normal", url });
59
94
  }
60
95
  return out;
61
96
  };
62
97
  const registerFonts = async (manifest) => {
63
- var _a;
98
+ var _a, _b;
64
99
  const registry = {};
65
100
  if (!manifest || Object.keys(manifest).length === 0)
66
101
  return registry;
@@ -69,16 +104,27 @@ const registerFonts = async (manifest) => {
69
104
  return registry;
70
105
  const loads = [];
71
106
  for (const [family, variantsInput] of Object.entries(manifest)) {
107
+ // Don't register a system-font family's bundled faces on iOS — resolution
108
+ // returns `fontFamily: undefined` for it so the real system font is used.
109
+ if ((0, exports.isSystemFontFamily)(family))
110
+ continue;
72
111
  const variants = normalizeFamilyVariants(variantsInput);
73
112
  if (variants.length === 0)
74
113
  continue;
75
114
  registry[family] = (_a = registry[family]) !== null && _a !== void 0 ? _a : {};
76
- for (const { weight, url } of variants) {
77
- const registeredName = buildRegisteredName(family, weight);
78
- registry[family][weight] = registeredName;
115
+ for (const { weight, style, url } of variants) {
116
+ const registeredName = buildRegisteredName(url);
117
+ const bucket = (registry[family][weight] = (_b = registry[family][weight]) !== null && _b !== void 0 ? _b : {});
118
+ bucket[style] = registeredName;
79
119
  loads.push(Font.loadAsync({ [registeredName]: { uri: url } }).catch((error) => {
80
- console.warn(`[onboarding] Failed to load font "${family}" weight ${weight} from ${url}:`, error);
81
- delete registry[family][weight];
120
+ var _a;
121
+ console.warn(`[onboarding] Failed to load font "${family}" weight ${weight} (${style}) from ${url}:`, error);
122
+ const b = (_a = registry[family]) === null || _a === void 0 ? void 0 : _a[weight];
123
+ if (b) {
124
+ delete b[style];
125
+ if (Object.keys(b).length === 0)
126
+ delete registry[family][weight];
127
+ }
82
128
  }));
83
129
  }
84
130
  }
@@ -86,16 +132,24 @@ const registerFonts = async (manifest) => {
86
132
  return registry;
87
133
  };
88
134
  exports.registerFonts = registerFonts;
89
- const resolveFontFamily = (registry, family, weight) => {
135
+ // Picks the requested style from a weight bucket, falling back to the other
136
+ // style when the requested one isn't available at that weight.
137
+ const pickFace = (face, style) => { var _a, _b; return (face ? ((_b = (_a = face[style]) !== null && _a !== void 0 ? _a : face.normal) !== null && _b !== void 0 ? _b : face.italic) : undefined); };
138
+ const resolveFontFamily = (registry, family, weight, fontStyle) => {
139
+ var _a;
90
140
  if (!family)
91
141
  return undefined;
142
+ // System font on iOS: let RN resolve the real system font from fontWeight.
143
+ if ((0, exports.isSystemFontFamily)(family))
144
+ return undefined;
92
145
  if (!registry)
93
146
  return family;
94
147
  const variants = registry[family];
95
148
  if (!variants)
96
149
  return family;
150
+ const style = (0, exports.normalizeStyle)(fontStyle);
97
151
  const requested = (0, exports.normalizeWeight)(weight);
98
- const exact = variants[requested];
152
+ const exact = pickFace(variants[requested], style);
99
153
  if (exact)
100
154
  return exact;
101
155
  const available = Object.keys(variants)
@@ -113,7 +167,7 @@ const resolveFontFamily = (registry, family, weight) => {
113
167
  bestDelta = delta;
114
168
  }
115
169
  }
116
- return variants[best];
170
+ return (_a = pickFace(variants[best], style)) !== null && _a !== void 0 ? _a : family;
117
171
  };
118
172
  exports.resolveFontFamily = resolveFontFamily;
119
173
  //# sourceMappingURL=registry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/infra/fonts/registry.ts"],"names":[],"mappings":";;;AAUA,MAAM,kBAAkB,GAA2B;IACjD,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;IACX,QAAQ,EAAE,GAAG;IACb,IAAI,EAAE,GAAG;IACT,SAAS,EAAE,GAAG;CACf,CAAC;AAEK,MAAM,eAAe,GAAG,CAAC,GAAgD,EAAU,EAAE;IAC1F,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,GAAG,CAAC;IAClD,IAAI,OAAO,GAAG,KAAK,QAAQ;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CAAC,CAAC,CAAC,CAAC;SACjC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IAE1C,IAAI,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IACxB,IAAI,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;IAC3C,KAAK,MAAM,SAAS,IAAI,SAAS,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;QAC9C,IAAI,KAAK,GAAG,SAAS,EAAE,CAAC;YACtB,IAAI,GAAG,SAAS,CAAC;YACjB,SAAS,GAAG,KAAK,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,MAAA,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,mCAAI,MAAM,CAAC;AACnD,CAAC,CAAC;AAnCW,QAAA,iBAAiB,qBAmC5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rocapine/react-native-onboarding",
3
- "version": "1.44.0",
3
+ "version": "1.44.2",
4
4
  "description": "Headless React Native SDK for Rocapine Onboarding Studio - Data fetching, state management, and hooks",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,89 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+
3
+ // Mutable Platform mock — isSystemFontFamily reads Platform.OS at call time.
4
+ const { Platform } = vi.hoisted(() => ({
5
+ Platform: { OS: "android" as "ios" | "android" },
6
+ }));
7
+ vi.mock("react-native", () => ({ Platform }));
8
+
9
+ import {
10
+ resolveFontFamily,
11
+ isSystemFontFamily,
12
+ type FontRegistry,
13
+ } from "../infra/fonts/registry";
14
+
15
+ describe("resolveFontFamily", () => {
16
+ beforeEach(() => {
17
+ Platform.OS = "android";
18
+ });
19
+
20
+ // Playfair Display: bold has both upright + italic faces at weight 700.
21
+ const registry: FontRegistry = {
22
+ "playfair-display": {
23
+ 400: { normal: "PlayfairDisplay-Regular", italic: "PlayfairDisplay-Italic" },
24
+ 700: { normal: "PlayfairDisplay-Bold", italic: "PlayfairDisplay-BoldItalic" },
25
+ },
26
+ };
27
+
28
+ it("selects the italic face when fontStyle: italic is requested", () => {
29
+ expect(resolveFontFamily(registry, "playfair-display", 700, "italic")).toBe(
30
+ "PlayfairDisplay-BoldItalic"
31
+ );
32
+ expect(resolveFontFamily(registry, "playfair-display", 700, "normal")).toBe(
33
+ "PlayfairDisplay-Bold"
34
+ );
35
+ });
36
+
37
+ it("defaults to the upright face when no style is given", () => {
38
+ expect(resolveFontFamily(registry, "playfair-display", 700)).toBe(
39
+ "PlayfairDisplay-Bold"
40
+ );
41
+ });
42
+
43
+ it("falls back to the other style when the requested one is absent at that weight", () => {
44
+ const onlyNormal: FontRegistry = {
45
+ fam: { 700: { normal: "Fam-Bold" } },
46
+ };
47
+ expect(resolveFontFamily(onlyNormal, "fam", 700, "italic")).toBe("Fam-Bold");
48
+ });
49
+
50
+ it("matches the nearest weight when exact weight is missing", () => {
51
+ expect(resolveFontFamily(registry, "playfair-display", 600, "italic")).toBe(
52
+ "PlayfairDisplay-BoldItalic"
53
+ );
54
+ });
55
+
56
+ it("returns the raw family name for an unregistered family", () => {
57
+ expect(resolveFontFamily(registry, "unknown", 400)).toBe("unknown");
58
+ });
59
+ });
60
+
61
+ describe("system font collision (iOS)", () => {
62
+ beforeEach(() => {
63
+ Platform.OS = "android";
64
+ });
65
+
66
+ it("treats SF Pro family names as system fonts only on iOS", () => {
67
+ Platform.OS = "ios";
68
+ expect(isSystemFontFamily("sf-pro-display")).toBe(true);
69
+ expect(isSystemFontFamily("SF Pro Display")).toBe(true);
70
+ expect(isSystemFontFamily("system")).toBe(true);
71
+ expect(isSystemFontFamily("playfair-display")).toBe(false);
72
+
73
+ Platform.OS = "android";
74
+ expect(isSystemFontFamily("sf-pro-display")).toBe(false);
75
+ });
76
+
77
+ it("resolves a system family to undefined on iOS (use the real system font)", () => {
78
+ const registry: FontRegistry = {
79
+ "sf-pro-display": { 500: { normal: "SFProDisplay-Medium" } },
80
+ };
81
+ Platform.OS = "ios";
82
+ expect(resolveFontFamily(registry, "sf-pro-display", 500)).toBeUndefined();
83
+
84
+ Platform.OS = "android";
85
+ expect(resolveFontFamily(registry, "sf-pro-display", 500)).toBe(
86
+ "SFProDisplay-Medium"
87
+ );
88
+ });
89
+ });
@@ -1,5 +1,5 @@
1
1
  import { createContext, useContext, useMemo } from "react";
2
- import type { FontRegistry } from "./registry";
2
+ import type { FontRegistry, FontStyleKey } from "./registry";
3
3
  import { resolveFontFamily } from "./registry";
4
4
 
5
5
  const FontRegistryContext = createContext<FontRegistry>({});
@@ -10,21 +10,27 @@ export const useFontRegistry = (): FontRegistry => useContext(FontRegistryContex
10
10
 
11
11
  export const useResolvedFontFamily = (
12
12
  family: string | null | undefined,
13
- weight: string | number | null | undefined
13
+ weight: string | number | null | undefined,
14
+ fontStyle?: FontStyleKey | string | null
14
15
  ): string | undefined => {
15
16
  const registry = useFontRegistry();
16
- return useMemo(() => resolveFontFamily(registry, family, weight), [registry, family, weight]);
17
+ return useMemo(
18
+ () => resolveFontFamily(registry, family, weight, fontStyle),
19
+ [registry, family, weight, fontStyle]
20
+ );
17
21
  };
18
22
 
19
23
  /**
20
- * Resolves a `family + weight` request to a registered font name. Returns
21
- * `resolvedToVariant: true` when the registry matched a concrete weighted
22
- * variant — callers should then suppress `fontWeight` on the rendered Text to
23
- * avoid synthetic emboldening on top of an already-weighted font file.
24
+ * Resolves a `family + weight + style` request to a registered font name.
25
+ * Returns `resolvedToVariant: true` when the registry matched a concrete
26
+ * weighted variant — callers should then suppress `fontWeight` on the rendered
27
+ * Text to avoid synthetic emboldening on top of an already-weighted font file.
28
+ * Pass `fontStyle: "italic"` to select the italic face when one is registered.
24
29
  */
25
30
  export const useResolvedFontStyle = (
26
31
  family: string | null | undefined,
27
- weight: string | number | null | undefined
32
+ weight: string | number | null | undefined,
33
+ fontStyle?: FontStyleKey | string | null
28
34
  ): {
29
35
  fontFamily: string | undefined;
30
36
  fontWeight: string | number | undefined;
@@ -32,7 +38,7 @@ export const useResolvedFontStyle = (
32
38
  } => {
33
39
  const registry = useFontRegistry();
34
40
  return useMemo(() => {
35
- const fontFamily = resolveFontFamily(registry, family, weight);
41
+ const fontFamily = resolveFontFamily(registry, family, weight, fontStyle);
36
42
  const variants = family ? registry?.[family] : undefined;
37
43
  const resolvedToVariant =
38
44
  !!variants && fontFamily !== undefined && fontFamily !== family;
@@ -41,5 +47,5 @@ export const useResolvedFontStyle = (
41
47
  fontWeight: resolvedToVariant ? undefined : (weight ?? undefined),
42
48
  resolvedToVariant,
43
49
  };
44
- }, [registry, family, weight]);
50
+ }, [registry, family, weight, fontStyle]);
45
51
  };
@@ -2,7 +2,11 @@ export {
2
2
  registerFonts,
3
3
  resolveFontFamily,
4
4
  normalizeWeight,
5
+ normalizeStyle,
6
+ isSystemFontFamily,
5
7
  type FontRegistry,
8
+ type RegisteredFace,
9
+ type FontStyleKey,
6
10
  } from "./registry";
7
11
  export {
8
12
  FontRegistryProvider,
@@ -1,3 +1,4 @@
1
+ import { Platform } from "react-native";
1
2
  import type {
2
3
  FontFamilyManifest,
3
4
  FontFamilyManifestInput,
@@ -6,7 +7,13 @@ import type {
6
7
  FontWeightKey,
7
8
  } from "../../types";
8
9
 
9
- export type FontRegistry = Record<string, Record<number, string>>;
10
+ export type FontStyleKey = "normal" | "italic";
11
+
12
+ // One weight bucket can hold both an upright and an italic face.
13
+ export type RegisteredFace = Partial<Record<FontStyleKey, string>>;
14
+
15
+ // family -> weight -> { normal?, italic? } registered (PostScript) names.
16
+ export type FontRegistry = Record<string, Record<number, RegisteredFace>>;
10
17
 
11
18
  const WEIGHT_NAME_TO_NUM: Record<string, number> = {
12
19
  regular: 400,
@@ -25,7 +32,44 @@ export const normalizeWeight = (key: FontWeightKey | string | number | undefined
25
32
  return Number.isFinite(parsed) ? parsed : 400;
26
33
  };
27
34
 
28
- const buildRegisteredName = (family: string, weight: number) => `${family}-${weight}`;
35
+ export const normalizeStyle = (style: string | undefined | null): FontStyleKey =>
36
+ style === "italic" ? "italic" : "normal";
37
+
38
+ // Font families whose internal name collides with the iOS system font (SF Pro).
39
+ // Registering custom faces under one of these names makes iOS give the system
40
+ // font precedence, so only Regular resolves — every other weight renders tofu.
41
+ // On iOS we skip registering them and resolve to `fontFamily: undefined` so RN
42
+ // uses the real system font (which *is* SF Pro) honoring `fontWeight`. On
43
+ // Android (no SF Pro system font) the bundled faces register normally.
44
+ const SYSTEM_FONT_FAMILIES = new Set<string>([
45
+ "system",
46
+ "sfpro",
47
+ "sfprodisplay",
48
+ "sfprotext",
49
+ "sfprorounded",
50
+ "sfuidisplay",
51
+ "sfuitext",
52
+ ]);
53
+
54
+ const normalizeFamilyKey = (family: string): string =>
55
+ family.toLowerCase().replace(/[\s_.-]+/g, "");
56
+
57
+ // True when `family` names a platform system font that must NOT be registered as
58
+ // a bundled face on iOS (see SYSTEM_FONT_FAMILIES). Always false on other
59
+ // platforms — only iOS has the SF Pro collision.
60
+ export const isSystemFontFamily = (family: string | null | undefined): boolean => {
61
+ if (!family || Platform.OS !== "ios") return false;
62
+ return SYSTEM_FONT_FAMILIES.has(normalizeFamilyKey(family));
63
+ };
64
+
65
+ // The registered (PostScript) name is the font file's base name, without
66
+ // directory, query string, or extension — e.g. ".../Inter-SemiBold.ttf?v=2"
67
+ // registers as "Inter-SemiBold".
68
+ const buildRegisteredName = (url: string): string => {
69
+ const path = url.split(/[?#]/)[0];
70
+ const file = path.split("/").pop() ?? path;
71
+ return file.replace(/\.[^.]+$/, "");
72
+ };
29
73
 
30
74
  let expoFontWarned = false;
31
75
  const loadExpoFont = (): typeof import("expo-font") | null => {
@@ -42,29 +86,28 @@ const loadExpoFont = (): typeof import("expo-font") | null => {
42
86
  }
43
87
  };
44
88
 
45
- type NormalizedVariant = { weight: number; url: string };
89
+ type NormalizedVariant = { weight: number; style: FontStyleKey; url: string };
46
90
 
47
91
  const normalizeFamilyVariants = (input: FontFamilyManifestInput | undefined): NormalizedVariant[] => {
48
92
  if (!input) return [];
49
93
 
50
94
  if (Array.isArray(input)) {
51
- const byWeight = new Map<number, NormalizedVariant>();
95
+ // Key by weight+style so an italic face is never overwritten by the upright
96
+ // face at the same weight (and vice-versa). Last entry wins on exact dup.
97
+ const byKey = new Map<string, NormalizedVariant>();
52
98
  for (const entry of input as FontVariantEntry[]) {
53
99
  if (!entry || typeof entry.url !== "string" || !entry.url) continue;
54
100
  const weight = normalizeWeight(entry.weight as FontWeightKey | number);
55
- const existing = byWeight.get(weight);
56
- const isNormalStyle = !entry.style || entry.style === "normal";
57
- if (!existing || isNormalStyle) {
58
- byWeight.set(weight, { weight, url: entry.url });
59
- }
101
+ const style = normalizeStyle(entry.style);
102
+ byKey.set(`${weight}-${style}`, { weight, style, url: entry.url });
60
103
  }
61
- return Array.from(byWeight.values());
104
+ return Array.from(byKey.values());
62
105
  }
63
106
 
64
107
  const out: NormalizedVariant[] = [];
65
108
  for (const [weightKey, url] of Object.entries(input as FontFamilyManifest)) {
66
109
  if (typeof url !== "string" || !url) continue;
67
- out.push({ weight: normalizeWeight(weightKey as FontWeightKey), url });
110
+ out.push({ weight: normalizeWeight(weightKey as FontWeightKey), style: "normal", url });
68
111
  }
69
112
  return out;
70
113
  };
@@ -79,21 +122,30 @@ export const registerFonts = async (manifest: FontsManifest | undefined): Promis
79
122
  const loads: Array<Promise<void>> = [];
80
123
 
81
124
  for (const [family, variantsInput] of Object.entries(manifest)) {
125
+ // Don't register a system-font family's bundled faces on iOS — resolution
126
+ // returns `fontFamily: undefined` for it so the real system font is used.
127
+ if (isSystemFontFamily(family)) continue;
128
+
82
129
  const variants = normalizeFamilyVariants(variantsInput);
83
130
  if (variants.length === 0) continue;
84
131
  registry[family] = registry[family] ?? {};
85
132
 
86
- for (const { weight, url } of variants) {
87
- const registeredName = buildRegisteredName(family, weight);
88
- registry[family][weight] = registeredName;
133
+ for (const { weight, style, url } of variants) {
134
+ const registeredName = buildRegisteredName(url);
135
+ const bucket = (registry[family][weight] = registry[family][weight] ?? {});
136
+ bucket[style] = registeredName;
89
137
 
90
138
  loads.push(
91
139
  Font.loadAsync({ [registeredName]: { uri: url } as any }).catch((error: unknown) => {
92
140
  console.warn(
93
- `[onboarding] Failed to load font "${family}" weight ${weight} from ${url}:`,
141
+ `[onboarding] Failed to load font "${family}" weight ${weight} (${style}) from ${url}:`,
94
142
  error
95
143
  );
96
- delete registry[family][weight];
144
+ const b = registry[family]?.[weight];
145
+ if (b) {
146
+ delete b[style];
147
+ if (Object.keys(b).length === 0) delete registry[family][weight];
148
+ }
97
149
  })
98
150
  );
99
151
  }
@@ -103,18 +155,30 @@ export const registerFonts = async (manifest: FontsManifest | undefined): Promis
103
155
  return registry;
104
156
  };
105
157
 
158
+ // Picks the requested style from a weight bucket, falling back to the other
159
+ // style when the requested one isn't available at that weight.
160
+ const pickFace = (
161
+ face: RegisteredFace | undefined,
162
+ style: FontStyleKey
163
+ ): string | undefined => (face ? (face[style] ?? face.normal ?? face.italic) : undefined);
164
+
106
165
  export const resolveFontFamily = (
107
166
  registry: FontRegistry | null | undefined,
108
167
  family: string | null | undefined,
109
- weight: string | number | null | undefined
168
+ weight: string | number | null | undefined,
169
+ fontStyle?: FontStyleKey | string | null
110
170
  ): string | undefined => {
111
171
  if (!family) return undefined;
172
+ // System font on iOS: let RN resolve the real system font from fontWeight.
173
+ if (isSystemFontFamily(family)) return undefined;
112
174
  if (!registry) return family;
113
175
  const variants = registry[family];
114
176
  if (!variants) return family;
115
177
 
178
+ const style = normalizeStyle(fontStyle);
116
179
  const requested = normalizeWeight(weight as FontWeightKey | undefined);
117
- const exact = variants[requested];
180
+
181
+ const exact = pickFace(variants[requested], style);
118
182
  if (exact) return exact;
119
183
 
120
184
  const available = Object.keys(variants)
@@ -132,5 +196,5 @@ export const resolveFontFamily = (
132
196
  bestDelta = delta;
133
197
  }
134
198
  }
135
- return variants[best];
199
+ return pickFace(variants[best], style) ?? family;
136
200
  };