@oxyhq/bloom 0.3.2 → 0.3.4
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/lib/commonjs/fonts/FontLoader.js +9 -2
- package/lib/commonjs/fonts/FontLoader.js.map +1 -1
- package/lib/commonjs/fonts/FontLoader.native.js +60 -2
- package/lib/commonjs/fonts/FontLoader.native.js.map +1 -1
- package/lib/commonjs/fonts/apply-font-faces.js +9 -38
- package/lib/commonjs/fonts/apply-font-faces.js.map +1 -1
- package/lib/commonjs/fonts/apply-font-faces.web.js +45 -0
- package/lib/commonjs/fonts/apply-font-faces.web.js.map +1 -0
- package/lib/commonjs/fonts/font-assets.js +2 -2
- package/lib/commonjs/fonts/index.js +1 -1
- package/lib/commonjs/fonts/index.web.js +40 -0
- package/lib/commonjs/fonts/index.web.js.map +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.web.js +1 -1
- package/lib/module/fonts/FontLoader.js +7 -1
- package/lib/module/fonts/FontLoader.js.map +1 -1
- package/lib/module/fonts/FontLoader.native.js +59 -1
- package/lib/module/fonts/FontLoader.native.js.map +1 -1
- package/lib/module/fonts/apply-font-faces.js +9 -37
- package/lib/module/fonts/apply-font-faces.js.map +1 -1
- package/lib/module/fonts/apply-font-faces.web.js +39 -0
- package/lib/module/fonts/apply-font-faces.web.js.map +1 -0
- package/lib/module/fonts/font-assets.js +2 -2
- package/lib/module/fonts/index.js +1 -1
- package/lib/module/fonts/index.js.map +1 -1
- package/lib/module/fonts/index.web.js +18 -0
- package/lib/module/fonts/index.web.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +1 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/typescript/commonjs/fonts/FontLoader.d.ts.map +1 -1
- package/lib/typescript/commonjs/fonts/FontLoader.native.d.ts +10 -0
- package/lib/typescript/commonjs/fonts/FontLoader.native.d.ts.map +1 -1
- package/lib/typescript/commonjs/fonts/apply-font-faces.d.ts +0 -13
- package/lib/typescript/commonjs/fonts/apply-font-faces.d.ts.map +1 -1
- package/lib/typescript/commonjs/fonts/apply-font-faces.web.d.ts +12 -0
- package/lib/typescript/commonjs/fonts/apply-font-faces.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/fonts/index.web.d.ts +7 -0
- package/lib/typescript/commonjs/fonts/index.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.web.d.ts +1 -1
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
- package/lib/typescript/module/fonts/FontLoader.d.ts.map +1 -1
- package/lib/typescript/module/fonts/FontLoader.native.d.ts +10 -0
- package/lib/typescript/module/fonts/FontLoader.native.d.ts.map +1 -1
- package/lib/typescript/module/fonts/apply-font-faces.d.ts +0 -13
- package/lib/typescript/module/fonts/apply-font-faces.d.ts.map +1 -1
- package/lib/typescript/module/fonts/apply-font-faces.web.d.ts +12 -0
- package/lib/typescript/module/fonts/apply-font-faces.web.d.ts.map +1 -0
- package/lib/typescript/module/fonts/index.web.d.ts +7 -0
- package/lib/typescript/module/fonts/index.web.d.ts.map +1 -0
- package/lib/typescript/module/index.web.d.ts +1 -1
- package/lib/typescript/module/index.web.d.ts.map +1 -1
- package/package.json +6 -1
- package/src/__tests__/FontLoader.native.test.tsx +72 -1
- package/src/__tests__/apply-font-faces.test.ts +9 -11
- package/src/fonts/FontLoader.native.tsx +74 -1
- package/src/fonts/FontLoader.tsx +7 -1
- package/src/fonts/apply-font-faces.ts +9 -39
- package/src/fonts/apply-font-faces.web.ts +38 -0
- package/src/fonts/font-assets.ts +2 -2
- package/src/fonts/index.web.ts +17 -0
- package/src/index.web.ts +1 -1
|
@@ -5,9 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.FontLoader = FontLoader;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var
|
|
8
|
+
var _applyFontFacesWeb = require("./apply-font-faces.web.js");
|
|
9
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
10
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
|
+
// Reach for the web variant explicitly. The default `./apply-font-faces`
|
|
12
|
+
// is a no-op stub that exists so Metro never sees the module-level
|
|
13
|
+
// `.woff2` imports on native (Metro's default `assetExts` does not include
|
|
14
|
+
// `.woff2`). This file (`FontLoader.tsx`) is only picked up by web
|
|
15
|
+
// bundlers — Metro selects `FontLoader.native.tsx` on iOS/Android — so it
|
|
16
|
+
// is safe to take a direct dependency on the web implementation here.
|
|
17
|
+
|
|
11
18
|
/**
|
|
12
19
|
* Web font loader. Applies the Bloom `@font-face` rules and CSS variables
|
|
13
20
|
* to `:root` on first render, before the first paint, using the same
|
|
@@ -26,7 +33,7 @@ function FontLoader({
|
|
|
26
33
|
const applied = (0, _react.useRef)(false);
|
|
27
34
|
if (enabled && !applied.current) {
|
|
28
35
|
applied.current = true;
|
|
29
|
-
(0,
|
|
36
|
+
(0, _applyFontFacesWeb.applyFontFaces)();
|
|
30
37
|
}
|
|
31
38
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
32
39
|
children: children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_applyFontFacesWeb","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","FontLoader","enabled","children","applied","useRef","current","applyFontFaces","jsx","Fragment"],"sourceRoot":"../../../src","sources":["fonts/FontLoader.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,kBAAA,GAAAD,OAAA;AAAwD,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AANxD;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASkB,UAAUA,CAAC;EAAEC,OAAO;EAAEC;AAA0B,CAAC,EAAE;EACjE,MAAMC,OAAO,GAAG,IAAAC,aAAM,EAAC,KAAK,CAAC;EAC7B,IAAIH,OAAO,IAAI,CAACE,OAAO,CAACE,OAAO,EAAE;IAC/BF,OAAO,CAACE,OAAO,GAAG,IAAI;IACtB,IAAAC,iCAAc,EAAC,CAAC;EAClB;EACA,oBAAO,IAAA1B,WAAA,CAAA2B,GAAA,EAAA3B,WAAA,CAAA4B,QAAA;IAAAN,QAAA,EAAGA;EAAQ,CAAG,CAAC;AACxB","ignoreList":[]}
|
|
@@ -4,11 +4,54 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.FontLoader = FontLoader;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
8
9
|
var _expoFont = require("expo-font");
|
|
9
10
|
var _fontAssets = require("./font-assets.js");
|
|
10
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
-
function
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
/**
|
|
14
|
+
* React Native's `Text` exposes a static `defaultProps` for app-wide prop
|
|
15
|
+
* defaults. The public type definition omits it (it's an implementation
|
|
16
|
+
* detail, not part of the stable API), so we describe it locally rather
|
|
17
|
+
* than casting to `any`.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Mutates `Text.defaultProps.style` so every native `<Text>` in the consuming
|
|
22
|
+
* app inherits Bloom's sans font (Inter). The Bloom family name is prepended
|
|
23
|
+
* to any existing default style so caller-provided `style` (which React
|
|
24
|
+
* applies AFTER `defaultProps.style`) still wins for overrides.
|
|
25
|
+
*
|
|
26
|
+
* Idempotent: re-invoking it after the first apply is a no-op because the
|
|
27
|
+
* first style entry will already be the Bloom default we added.
|
|
28
|
+
*/
|
|
29
|
+
function applyDefaultTextFont() {
|
|
30
|
+
const TextWithDefaults = _reactNative.Text;
|
|
31
|
+
const existing = TextWithDefaults.defaultProps?.style;
|
|
32
|
+
const bloomDefault = {
|
|
33
|
+
fontFamily: 'Inter'
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Detect whether we've already prepended ourselves. `existing` may be an
|
|
37
|
+
// array (multiple style fragments), a single object, a registered style
|
|
38
|
+
// number, or undefined. Only the array/object cases need inspection — if
|
|
39
|
+
// it's a number, we can't read the contents so we just prepend.
|
|
40
|
+
if (Array.isArray(existing)) {
|
|
41
|
+
const first = existing[0];
|
|
42
|
+
if (first && typeof first === 'object' && !Array.isArray(first) && first.fontFamily === bloomDefault.fontFamily) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
} else if (existing && typeof existing === 'object' && existing.fontFamily === bloomDefault.fontFamily) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const nextStyle = existing == null ? bloomDefault : [bloomDefault, existing];
|
|
49
|
+
TextWithDefaults.defaultProps = {
|
|
50
|
+
...TextWithDefaults.defaultProps,
|
|
51
|
+
style: nextStyle
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
12
55
|
/**
|
|
13
56
|
* Native font loader. Calls `expo-font`'s `useFonts` with the Bloom font
|
|
14
57
|
* asset map and gates `children` on the load result. The hook is invoked
|
|
@@ -16,6 +59,16 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
16
59
|
* fonts get loaded. This keeps Hook order stable across renders and means
|
|
17
60
|
* `<BloomThemeProvider fonts={false}>` still gets fonts pre-loaded if the
|
|
18
61
|
* provider tree ever flips `fonts` back on.
|
|
62
|
+
*
|
|
63
|
+
* Once the bundled fonts report `loaded === true`, this component also
|
|
64
|
+
* mutates `Text.defaultProps.style` to prepend `{ fontFamily: 'Inter' }`
|
|
65
|
+
* so every native `<Text>` in the consuming app inherits Bloom's sans
|
|
66
|
+
* family without callers needing to import `<Text>` from `@oxyhq/bloom`.
|
|
67
|
+
* The mutation is gated by a `useRef` so it runs at most once per
|
|
68
|
+
* FontLoader instance, and the underlying apply is idempotent — the
|
|
69
|
+
* Bloom default is prepended to any caller `defaultProps.style`, so
|
|
70
|
+
* per-call `style` overrides (which React applies after `defaultProps`)
|
|
71
|
+
* still take precedence.
|
|
19
72
|
*/
|
|
20
73
|
function FontLoader({
|
|
21
74
|
enabled,
|
|
@@ -23,6 +76,11 @@ function FontLoader({
|
|
|
23
76
|
children
|
|
24
77
|
}) {
|
|
25
78
|
const [loaded] = (0, _expoFont.useFonts)(_fontAssets.FONT_ASSETS);
|
|
79
|
+
const defaultsApplied = (0, _react.useRef)(false);
|
|
80
|
+
if (loaded && !defaultsApplied.current) {
|
|
81
|
+
defaultsApplied.current = true;
|
|
82
|
+
applyDefaultTextFont();
|
|
83
|
+
}
|
|
26
84
|
if (!enabled) return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
27
85
|
children: children
|
|
28
86
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_expoFont","_fontAssets","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","applyDefaultTextFont","TextWithDefaults","Text","existing","defaultProps","style","bloomDefault","fontFamily","Array","isArray","first","nextStyle","FontLoader","enabled","fallback","children","loaded","useFonts","FONT_ASSETS","defaultsApplied","useRef","current","jsx","Fragment"],"sourceRoot":"../../../src","sources":["fonts/FontLoader.native.tsx"],"mappings":"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","ignoreList":[]}
|
|
@@ -4,44 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.applyFontFaces = applyFontFaces;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Inject @font-face rules and font CSS variables onto :root.
|
|
18
|
-
*
|
|
19
|
-
* No-op on native and when `document` is unavailable (SSR). Idempotent —
|
|
20
|
-
* safe to call multiple times; subsequent calls early-return after the
|
|
21
|
-
* `<style id="bloom-fonts">` tag has been mounted.
|
|
22
|
-
*
|
|
23
|
-
* Follows the same shape as `applyDarkClass` / `applyColorPresetVars`: a
|
|
24
|
-
* single file with an internal `Platform.OS` check rather than a `.web.ts` /
|
|
25
|
-
* `.native.ts` split. Bundlers strip the unreachable web import code path
|
|
26
|
-
* on native because the function body short-circuits before referencing the
|
|
27
|
-
* woff2 URLs.
|
|
28
|
-
*/
|
|
7
|
+
// No-op on native. The web variant lives in apply-font-faces.web.ts and
|
|
8
|
+
// is selected by bundlers via the package.json conditions. RN consumers
|
|
9
|
+
// never need font-face injection — useFonts handles loading on native.
|
|
10
|
+
//
|
|
11
|
+
// This file MUST have zero `.woff2` imports. Metro parses module-level
|
|
12
|
+
// imports at bundle time and would otherwise fail to resolve the `.woff2`
|
|
13
|
+
// assets (not in Metro's default `assetExts`). See
|
|
14
|
+
// `apply-font-faces.web.ts` for the real implementation.
|
|
29
15
|
function applyFontFaces() {
|
|
30
|
-
|
|
31
|
-
if (document.getElementById(STYLE_ID)) return;
|
|
32
|
-
const style = document.createElement('style');
|
|
33
|
-
style.id = STYLE_ID;
|
|
34
|
-
style.textContent = `
|
|
35
|
-
@font-face { font-family: 'BlomusModernus'; src: url(${_BlomusModernusRegular.default}) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
|
|
36
|
-
@font-face { font-family: 'BlomusModernus'; src: url(${_BlomusModernusBold.default}) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
|
|
37
|
-
@font-face { font-family: 'Inter'; src: url(${_InterVariable.default}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
38
|
-
@font-face { font-family: 'Geist Mono'; src: url(${_GeistMonoVariable.default}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
39
|
-
:root {
|
|
40
|
-
--bloom-font-display: ${_tokens.fontFamilies.display};
|
|
41
|
-
--bloom-font-sans: ${_tokens.fontFamilies.sans};
|
|
42
|
-
--bloom-font-mono: ${_tokens.fontFamilies.mono};
|
|
43
|
-
}
|
|
44
|
-
`;
|
|
45
|
-
document.head.appendChild(style);
|
|
16
|
+
// intentionally empty
|
|
46
17
|
}
|
|
47
18
|
//# sourceMappingURL=apply-font-faces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["applyFontFaces"],"sourceRoot":"../../../src","sources":["fonts/apply-font-faces.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAcA,CAAA,EAAS;EACrC;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.applyFontFaces = applyFontFaces;
|
|
7
|
+
var _BlomusModernusRegular = _interopRequireDefault(require("./assets/BlomusModernus-Regular.woff2"));
|
|
8
|
+
var _BlomusModernusBold = _interopRequireDefault(require("./assets/BlomusModernus-Bold.woff2"));
|
|
9
|
+
var _InterVariable = _interopRequireDefault(require("./assets/InterVariable.woff2"));
|
|
10
|
+
var _GeistMonoVariable = _interopRequireDefault(require("./assets/GeistMono-Variable.woff2"));
|
|
11
|
+
var _tokens = require("./tokens.js");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
/// <reference path="../assets.d.ts" />
|
|
14
|
+
|
|
15
|
+
const STYLE_ID = 'bloom-fonts';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Inject @font-face rules and font CSS variables onto :root.
|
|
19
|
+
*
|
|
20
|
+
* Web-only. The native counterpart in `apply-font-faces.ts` is a no-op
|
|
21
|
+
* stub — Metro cannot parse `.woff2` imports, so the file split keeps
|
|
22
|
+
* those imports out of the native bundle entirely. Idempotent: safe to
|
|
23
|
+
* call multiple times; subsequent calls early-return after the
|
|
24
|
+
* `<style id="bloom-fonts">` tag has been mounted. SSR-safe via the
|
|
25
|
+
* `typeof document === 'undefined'` guard.
|
|
26
|
+
*/
|
|
27
|
+
function applyFontFaces() {
|
|
28
|
+
if (typeof document === 'undefined') return;
|
|
29
|
+
if (document.getElementById(STYLE_ID)) return;
|
|
30
|
+
const style = document.createElement('style');
|
|
31
|
+
style.id = STYLE_ID;
|
|
32
|
+
style.textContent = `
|
|
33
|
+
@font-face { font-family: 'BlomusModernus'; src: url(${_BlomusModernusRegular.default}) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
|
|
34
|
+
@font-face { font-family: 'BlomusModernus'; src: url(${_BlomusModernusBold.default}) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
|
|
35
|
+
@font-face { font-family: 'Inter'; src: url(${_InterVariable.default}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
36
|
+
@font-face { font-family: 'Geist Mono'; src: url(${_GeistMonoVariable.default}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
37
|
+
:root {
|
|
38
|
+
--bloom-font-display: ${_tokens.fontFamilies.display};
|
|
39
|
+
--bloom-font-sans: ${_tokens.fontFamilies.sans};
|
|
40
|
+
--bloom-font-mono: ${_tokens.fontFamilies.mono};
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
document.head.appendChild(style);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=apply-font-faces.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_BlomusModernusRegular","_interopRequireDefault","require","_BlomusModernusBold","_InterVariable","_GeistMonoVariable","_tokens","e","__esModule","default","STYLE_ID","applyFontFaces","document","getElementById","style","createElement","id","textContent","blomusReg","blomusBold","interVar","geistMono","fontFamilies","display","sans","mono","head","appendChild"],"sourceRoot":"../../../src","sources":["fonts/apply-font-faces.web.ts"],"mappings":";;;;;;AACA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,cAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,kBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAAwC,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AALxC;;AAOA,MAAMG,QAAQ,GAAG,aAAa;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAAA,EAAS;EACrC,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;EACrC,IAAIA,QAAQ,CAACC,cAAc,CAACH,QAAQ,CAAC,EAAE;EAEvC,MAAMI,KAAK,GAAGF,QAAQ,CAACG,aAAa,CAAC,OAAO,CAAC;EAC7CD,KAAK,CAACE,EAAE,GAAGN,QAAQ;EACnBI,KAAK,CAACG,WAAW,GAAG;AACtB,2DAA2DC,8BAAS;AACpE,2DAA2DC,2BAAU;AACrE,kDAAkDC,sBAAQ;AAC1D,uDAAuDC,0BAAS;AAChE;AACA,8BAA8BC,oBAAY,CAACC,OAAO;AAClD,2BAA2BD,oBAAY,CAACE,IAAI;AAC5C,2BAA2BF,oBAAY,CAACG,IAAI;AAC5C;AACA,GAAG;EACDb,QAAQ,CAACc,IAAI,CAACC,WAAW,CAACb,KAAK,CAAC;AAClC","ignoreList":[]}
|
|
@@ -11,8 +11,8 @@ exports.FONT_ASSETS = void 0;
|
|
|
11
11
|
// covers all weights at runtime. `@fontsource(-variable)?/*` packages only
|
|
12
12
|
// publish .woff2 for their variable axes — modern react-native font loading
|
|
13
13
|
// requires .ttf, so we use the upstream variable TTFs instead. On web,
|
|
14
|
-
// `apply-font-faces.ts` references the .woff2 variants directly and this
|
|
15
|
-
// is never imported.
|
|
14
|
+
// `apply-font-faces.web.ts` references the .woff2 variants directly and this
|
|
15
|
+
// file is never imported.
|
|
16
16
|
|
|
17
17
|
const FONT_ASSETS = exports.FONT_ASSETS = {
|
|
18
18
|
BlomusModernus: require('./assets/BlomusModernus-Regular.ttf'),
|
|
@@ -34,7 +34,7 @@ Object.defineProperty(exports, "fontFamilies", {
|
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
var _tokens = require("./tokens.js");
|
|
37
|
-
var _applyFontFaces = require("./apply-font-faces
|
|
37
|
+
var _applyFontFaces = require("./apply-font-faces");
|
|
38
38
|
var _fontAssets = require("./font-assets.js");
|
|
39
39
|
var _FontLoader = require("./FontLoader");
|
|
40
40
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "FONT_ASSETS", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _fontAssets.FONT_ASSETS;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "FontLoader", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _FontLoader.FontLoader;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "applyFontFaces", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _applyFontFacesWeb.applyFontFaces;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "fontCssVars", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _tokens.fontCssVars;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "fontFamilies", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _tokens.fontFamilies;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
var _tokens = require("./tokens.js");
|
|
37
|
+
var _applyFontFacesWeb = require("./apply-font-faces.web.js");
|
|
38
|
+
var _fontAssets = require("./font-assets.js");
|
|
39
|
+
var _FontLoader = require("./FontLoader");
|
|
40
|
+
//# sourceMappingURL=index.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_tokens","require","_applyFontFacesWeb","_fontAssets","_FontLoader"],"sourceRoot":"../../../src","sources":["fonts/index.web.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -386,7 +386,7 @@ var _ContextMenu = _interopRequireWildcard(require("./context-menu"));
|
|
|
386
386
|
exports.ContextMenu = _ContextMenu;
|
|
387
387
|
var _Code = _interopRequireWildcard(require("./code/index.js"));
|
|
388
388
|
exports.Code = _Code;
|
|
389
|
-
var _Fonts = _interopRequireWildcard(require("./fonts
|
|
389
|
+
var _Fonts = _interopRequireWildcard(require("./fonts"));
|
|
390
390
|
exports.Fonts = _Fonts;
|
|
391
391
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
392
392
|
//# sourceMappingURL=index.js.map
|
|
@@ -386,7 +386,7 @@ var _ContextMenu = _interopRequireWildcard(require("./context-menu/index.web.js"
|
|
|
386
386
|
exports.ContextMenu = _ContextMenu;
|
|
387
387
|
var _Code = _interopRequireWildcard(require("./code/index.js"));
|
|
388
388
|
exports.Code = _Code;
|
|
389
|
-
var _Fonts = _interopRequireWildcard(require("./fonts/index.js"));
|
|
389
|
+
var _Fonts = _interopRequireWildcard(require("./fonts/index.web.js"));
|
|
390
390
|
exports.Fonts = _Fonts;
|
|
391
391
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
392
392
|
//# sourceMappingURL=index.web.js.map
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React, { useRef } from 'react';
|
|
4
|
-
|
|
4
|
+
// Reach for the web variant explicitly. The default `./apply-font-faces`
|
|
5
|
+
// is a no-op stub that exists so Metro never sees the module-level
|
|
6
|
+
// `.woff2` imports on native (Metro's default `assetExts` does not include
|
|
7
|
+
// `.woff2`). This file (`FontLoader.tsx`) is only picked up by web
|
|
8
|
+
// bundlers — Metro selects `FontLoader.native.tsx` on iOS/Android — so it
|
|
9
|
+
// is safe to take a direct dependency on the web implementation here.
|
|
10
|
+
import { applyFontFaces } from "./apply-font-faces.web.js";
|
|
5
11
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
6
12
|
/**
|
|
7
13
|
* Web font loader. Applies the Bloom `@font-face` rules and CSS variables
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useRef","applyFontFaces","Fragment","_Fragment","jsx","_jsx","FontLoader","enabled","children","applied","current"],"sourceRoot":"../../../src","sources":["fonts/FontLoader.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,MAAM,QAAQ,OAAO;AACrC,SAASC,cAAc,QAAQ,
|
|
1
|
+
{"version":3,"names":["React","useRef","applyFontFaces","Fragment","_Fragment","jsx","_jsx","FontLoader","enabled","children","applied","current"],"sourceRoot":"../../../src","sources":["fonts/FontLoader.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,MAAM,QAAQ,OAAO;AACrC;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,cAAc,QAAQ,2BAAwB;AAAC,SAAAC,QAAA,IAAAC,SAAA,EAAAC,GAAA,IAAAC,IAAA;AAiBxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAAC;EAAEC,OAAO;EAAEC;AAA0B,CAAC,EAAE;EACjE,MAAMC,OAAO,GAAGT,MAAM,CAAC,KAAK,CAAC;EAC7B,IAAIO,OAAO,IAAI,CAACE,OAAO,CAACC,OAAO,EAAE;IAC/BD,OAAO,CAACC,OAAO,GAAG,IAAI;IACtBT,cAAc,CAAC,CAAC;EAClB;EACA,oBAAOI,IAAA,CAAAF,SAAA;IAAAK,QAAA,EAAGA;EAAQ,CAAG,CAAC;AACxB","ignoreList":[]}
|
|
@@ -1,9 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useRef } from 'react';
|
|
4
|
+
import { Text } from 'react-native';
|
|
4
5
|
import { useFonts } from 'expo-font';
|
|
5
6
|
import { FONT_ASSETS } from "./font-assets.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* React Native's `Text` exposes a static `defaultProps` for app-wide prop
|
|
10
|
+
* defaults. The public type definition omits it (it's an implementation
|
|
11
|
+
* detail, not part of the stable API), so we describe it locally rather
|
|
12
|
+
* than casting to `any`.
|
|
13
|
+
*/
|
|
6
14
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
/**
|
|
16
|
+
* Mutates `Text.defaultProps.style` so every native `<Text>` in the consuming
|
|
17
|
+
* app inherits Bloom's sans font (Inter). The Bloom family name is prepended
|
|
18
|
+
* to any existing default style so caller-provided `style` (which React
|
|
19
|
+
* applies AFTER `defaultProps.style`) still wins for overrides.
|
|
20
|
+
*
|
|
21
|
+
* Idempotent: re-invoking it after the first apply is a no-op because the
|
|
22
|
+
* first style entry will already be the Bloom default we added.
|
|
23
|
+
*/
|
|
24
|
+
function applyDefaultTextFont() {
|
|
25
|
+
const TextWithDefaults = Text;
|
|
26
|
+
const existing = TextWithDefaults.defaultProps?.style;
|
|
27
|
+
const bloomDefault = {
|
|
28
|
+
fontFamily: 'Inter'
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Detect whether we've already prepended ourselves. `existing` may be an
|
|
32
|
+
// array (multiple style fragments), a single object, a registered style
|
|
33
|
+
// number, or undefined. Only the array/object cases need inspection — if
|
|
34
|
+
// it's a number, we can't read the contents so we just prepend.
|
|
35
|
+
if (Array.isArray(existing)) {
|
|
36
|
+
const first = existing[0];
|
|
37
|
+
if (first && typeof first === 'object' && !Array.isArray(first) && first.fontFamily === bloomDefault.fontFamily) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
} else if (existing && typeof existing === 'object' && existing.fontFamily === bloomDefault.fontFamily) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const nextStyle = existing == null ? bloomDefault : [bloomDefault, existing];
|
|
44
|
+
TextWithDefaults.defaultProps = {
|
|
45
|
+
...TextWithDefaults.defaultProps,
|
|
46
|
+
style: nextStyle
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
7
50
|
/**
|
|
8
51
|
* Native font loader. Calls `expo-font`'s `useFonts` with the Bloom font
|
|
9
52
|
* asset map and gates `children` on the load result. The hook is invoked
|
|
@@ -11,6 +54,16 @@ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
|
11
54
|
* fonts get loaded. This keeps Hook order stable across renders and means
|
|
12
55
|
* `<BloomThemeProvider fonts={false}>` still gets fonts pre-loaded if the
|
|
13
56
|
* provider tree ever flips `fonts` back on.
|
|
57
|
+
*
|
|
58
|
+
* Once the bundled fonts report `loaded === true`, this component also
|
|
59
|
+
* mutates `Text.defaultProps.style` to prepend `{ fontFamily: 'Inter' }`
|
|
60
|
+
* so every native `<Text>` in the consuming app inherits Bloom's sans
|
|
61
|
+
* family without callers needing to import `<Text>` from `@oxyhq/bloom`.
|
|
62
|
+
* The mutation is gated by a `useRef` so it runs at most once per
|
|
63
|
+
* FontLoader instance, and the underlying apply is idempotent — the
|
|
64
|
+
* Bloom default is prepended to any caller `defaultProps.style`, so
|
|
65
|
+
* per-call `style` overrides (which React applies after `defaultProps`)
|
|
66
|
+
* still take precedence.
|
|
14
67
|
*/
|
|
15
68
|
export function FontLoader({
|
|
16
69
|
enabled,
|
|
@@ -18,6 +71,11 @@ export function FontLoader({
|
|
|
18
71
|
children
|
|
19
72
|
}) {
|
|
20
73
|
const [loaded] = useFonts(FONT_ASSETS);
|
|
74
|
+
const defaultsApplied = useRef(false);
|
|
75
|
+
if (loaded && !defaultsApplied.current) {
|
|
76
|
+
defaultsApplied.current = true;
|
|
77
|
+
applyDefaultTextFont();
|
|
78
|
+
}
|
|
21
79
|
if (!enabled) return /*#__PURE__*/_jsx(_Fragment, {
|
|
22
80
|
children: children
|
|
23
81
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useFonts","FONT_ASSETS","Fragment","_Fragment","jsx","_jsx","FontLoader","enabled","fallback","children","loaded"],"sourceRoot":"../../../src","sources":["fonts/FontLoader.native.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;
|
|
1
|
+
{"version":3,"names":["React","useRef","Text","useFonts","FONT_ASSETS","Fragment","_Fragment","jsx","_jsx","applyDefaultTextFont","TextWithDefaults","existing","defaultProps","style","bloomDefault","fontFamily","Array","isArray","first","nextStyle","FontLoader","enabled","fallback","children","loaded","defaultsApplied","current"],"sourceRoot":"../../../src","sources":["fonts/FontLoader.native.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,MAAM,QAAQ,OAAO;AACrC,SAASC,IAAI,QAAwD,cAAc;AACnF,SAASC,QAAQ,QAAQ,WAAW;AACpC,SAASC,WAAW,QAAQ,kBAAe;;AAc3C;AACA;AACA;AACA;AACA;AACA;AALA,SAAAC,QAAA,IAAAC,SAAA,EAAAC,GAAA,IAAAC,IAAA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,oBAAoBA,CAAA,EAAS;EACpC,MAAMC,gBAAgB,GAAGR,IAAwB;EACjD,MAAMS,QAAQ,GAAGD,gBAAgB,CAACE,YAAY,EAAEC,KAAK;EACrD,MAAMC,YAAuB,GAAG;IAAEC,UAAU,EAAE;EAAQ,CAAC;;EAEvD;EACA;EACA;EACA;EACA,IAAIC,KAAK,CAACC,OAAO,CAACN,QAAQ,CAAC,EAAE;IAC3B,MAAMO,KAAK,GAAGP,QAAQ,CAAC,CAAC,CAAC;IACzB,IACEO,KAAK,IACL,OAAOA,KAAK,KAAK,QAAQ,IACzB,CAACF,KAAK,CAACC,OAAO,CAACC,KAAK,CAAC,IACpBA,KAAK,CAAeH,UAAU,KAAKD,YAAY,CAACC,UAAU,EAC3D;MACA;IACF;EACF,CAAC,MAAM,IACLJ,QAAQ,IACR,OAAOA,QAAQ,KAAK,QAAQ,IAC3BA,QAAQ,CAAeI,UAAU,KAAKD,YAAY,CAACC,UAAU,EAC9D;IACA;EACF;EAEA,MAAMI,SAA+B,GACnCR,QAAQ,IAAI,IAAI,GAAGG,YAAY,GAAG,CAACA,YAAY,EAAEH,QAAQ,CAAC;EAE5DD,gBAAgB,CAACE,YAAY,GAAG;IAC9B,GAAGF,gBAAgB,CAACE,YAAY;IAChCC,KAAK,EAAEM;EACT,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAAC;EAAEC,OAAO;EAAEC,QAAQ;EAAEC;AAA0B,CAAC,EAAE;EAC3E,MAAM,CAACC,MAAM,CAAC,GAAGrB,QAAQ,CAACC,WAAW,CAAC;EACtC,MAAMqB,eAAe,GAAGxB,MAAM,CAAC,KAAK,CAAC;EAErC,IAAIuB,MAAM,IAAI,CAACC,eAAe,CAACC,OAAO,EAAE;IACtCD,eAAe,CAACC,OAAO,GAAG,IAAI;IAC9BjB,oBAAoB,CAAC,CAAC;EACxB;EAEA,IAAI,CAACY,OAAO,EAAE,oBAAOb,IAAA,CAAAF,SAAA;IAAAiB,QAAA,EAAGA;EAAQ,CAAG,CAAC;EACpC,IAAI,CAACC,MAAM,EAAE,oBAAOhB,IAAA,CAAAF,SAAA;IAAAiB,QAAA,EAAGD,QAAQ,IAAI;EAAI,CAAG,CAAC;EAC3C,oBAAOd,IAAA,CAAAF,SAAA;IAAAiB,QAAA,EAAGA;EAAQ,CAAG,CAAC;AACxB","ignoreList":[]}
|
|
@@ -1,42 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Inject @font-face rules and font CSS variables onto :root.
|
|
13
|
-
*
|
|
14
|
-
* No-op on native and when `document` is unavailable (SSR). Idempotent —
|
|
15
|
-
* safe to call multiple times; subsequent calls early-return after the
|
|
16
|
-
* `<style id="bloom-fonts">` tag has been mounted.
|
|
17
|
-
*
|
|
18
|
-
* Follows the same shape as `applyDarkClass` / `applyColorPresetVars`: a
|
|
19
|
-
* single file with an internal `Platform.OS` check rather than a `.web.ts` /
|
|
20
|
-
* `.native.ts` split. Bundlers strip the unreachable web import code path
|
|
21
|
-
* on native because the function body short-circuits before referencing the
|
|
22
|
-
* woff2 URLs.
|
|
23
|
-
*/
|
|
3
|
+
// No-op on native. The web variant lives in apply-font-faces.web.ts and
|
|
4
|
+
// is selected by bundlers via the package.json conditions. RN consumers
|
|
5
|
+
// never need font-face injection — useFonts handles loading on native.
|
|
6
|
+
//
|
|
7
|
+
// This file MUST have zero `.woff2` imports. Metro parses module-level
|
|
8
|
+
// imports at bundle time and would otherwise fail to resolve the `.woff2`
|
|
9
|
+
// assets (not in Metro's default `assetExts`). See
|
|
10
|
+
// `apply-font-faces.web.ts` for the real implementation.
|
|
24
11
|
export function applyFontFaces() {
|
|
25
|
-
|
|
26
|
-
if (document.getElementById(STYLE_ID)) return;
|
|
27
|
-
const style = document.createElement('style');
|
|
28
|
-
style.id = STYLE_ID;
|
|
29
|
-
style.textContent = `
|
|
30
|
-
@font-face { font-family: 'BlomusModernus'; src: url(${blomusReg}) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
|
|
31
|
-
@font-face { font-family: 'BlomusModernus'; src: url(${blomusBold}) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
|
|
32
|
-
@font-face { font-family: 'Inter'; src: url(${interVar}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
33
|
-
@font-face { font-family: 'Geist Mono'; src: url(${geistMono}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
34
|
-
:root {
|
|
35
|
-
--bloom-font-display: ${fontFamilies.display};
|
|
36
|
-
--bloom-font-sans: ${fontFamilies.sans};
|
|
37
|
-
--bloom-font-mono: ${fontFamilies.mono};
|
|
38
|
-
}
|
|
39
|
-
`;
|
|
40
|
-
document.head.appendChild(style);
|
|
12
|
+
// intentionally empty
|
|
41
13
|
}
|
|
42
14
|
//# sourceMappingURL=apply-font-faces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["applyFontFaces"],"sourceRoot":"../../../src","sources":["fonts/apply-font-faces.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,cAAcA,CAAA,EAAS;EACrC;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/// <reference path="../assets.d.ts" />
|
|
4
|
+
import blomusReg from './assets/BlomusModernus-Regular.woff2';
|
|
5
|
+
import blomusBold from './assets/BlomusModernus-Bold.woff2';
|
|
6
|
+
import interVar from './assets/InterVariable.woff2';
|
|
7
|
+
import geistMono from './assets/GeistMono-Variable.woff2';
|
|
8
|
+
import { fontFamilies } from "./tokens.js";
|
|
9
|
+
const STYLE_ID = 'bloom-fonts';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Inject @font-face rules and font CSS variables onto :root.
|
|
13
|
+
*
|
|
14
|
+
* Web-only. The native counterpart in `apply-font-faces.ts` is a no-op
|
|
15
|
+
* stub — Metro cannot parse `.woff2` imports, so the file split keeps
|
|
16
|
+
* those imports out of the native bundle entirely. Idempotent: safe to
|
|
17
|
+
* call multiple times; subsequent calls early-return after the
|
|
18
|
+
* `<style id="bloom-fonts">` tag has been mounted. SSR-safe via the
|
|
19
|
+
* `typeof document === 'undefined'` guard.
|
|
20
|
+
*/
|
|
21
|
+
export function applyFontFaces() {
|
|
22
|
+
if (typeof document === 'undefined') return;
|
|
23
|
+
if (document.getElementById(STYLE_ID)) return;
|
|
24
|
+
const style = document.createElement('style');
|
|
25
|
+
style.id = STYLE_ID;
|
|
26
|
+
style.textContent = `
|
|
27
|
+
@font-face { font-family: 'BlomusModernus'; src: url(${blomusReg}) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
|
|
28
|
+
@font-face { font-family: 'BlomusModernus'; src: url(${blomusBold}) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
|
|
29
|
+
@font-face { font-family: 'Inter'; src: url(${interVar}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
30
|
+
@font-face { font-family: 'Geist Mono'; src: url(${geistMono}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
31
|
+
:root {
|
|
32
|
+
--bloom-font-display: ${fontFamilies.display};
|
|
33
|
+
--bloom-font-sans: ${fontFamilies.sans};
|
|
34
|
+
--bloom-font-mono: ${fontFamilies.mono};
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
document.head.appendChild(style);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=apply-font-faces.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["blomusReg","blomusBold","interVar","geistMono","fontFamilies","STYLE_ID","applyFontFaces","document","getElementById","style","createElement","id","textContent","display","sans","mono","head","appendChild"],"sourceRoot":"../../../src","sources":["fonts/apply-font-faces.web.ts"],"mappings":";;AAAA;AACA,OAAOA,SAAS,MAAM,uCAAuC;AAC7D,OAAOC,UAAU,MAAM,oCAAoC;AAC3D,OAAOC,QAAQ,MAAM,8BAA8B;AACnD,OAAOC,SAAS,MAAM,mCAAmC;AACzD,SAASC,YAAY,QAAQ,aAAU;AAEvC,MAAMC,QAAQ,GAAG,aAAa;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAA,EAAS;EACrC,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;EACrC,IAAIA,QAAQ,CAACC,cAAc,CAACH,QAAQ,CAAC,EAAE;EAEvC,MAAMI,KAAK,GAAGF,QAAQ,CAACG,aAAa,CAAC,OAAO,CAAC;EAC7CD,KAAK,CAACE,EAAE,GAAGN,QAAQ;EACnBI,KAAK,CAACG,WAAW,GAAG;AACtB,2DAA2DZ,SAAS;AACpE,2DAA2DC,UAAU;AACrE,kDAAkDC,QAAQ;AAC1D,uDAAuDC,SAAS;AAChE;AACA,8BAA8BC,YAAY,CAACS,OAAO;AAClD,2BAA2BT,YAAY,CAACU,IAAI;AAC5C,2BAA2BV,YAAY,CAACW,IAAI;AAC5C;AACA,GAAG;EACDR,QAAQ,CAACS,IAAI,CAACC,WAAW,CAACR,KAAK,CAAC;AAClC","ignoreList":[]}
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
// covers all weights at runtime. `@fontsource(-variable)?/*` packages only
|
|
8
8
|
// publish .woff2 for their variable axes — modern react-native font loading
|
|
9
9
|
// requires .ttf, so we use the upstream variable TTFs instead. On web,
|
|
10
|
-
// `apply-font-faces.ts` references the .woff2 variants directly and this
|
|
11
|
-
// is never imported.
|
|
10
|
+
// `apply-font-faces.web.ts` references the .woff2 variants directly and this
|
|
11
|
+
// file is never imported.
|
|
12
12
|
|
|
13
13
|
export const FONT_ASSETS = {
|
|
14
14
|
BlomusModernus: require('./assets/BlomusModernus-Regular.ttf'),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export { fontFamilies, fontCssVars } from "./tokens.js";
|
|
4
|
-
export { applyFontFaces } from
|
|
4
|
+
export { applyFontFaces } from './apply-font-faces';
|
|
5
5
|
export { FONT_ASSETS } from "./font-assets.js";
|
|
6
6
|
export { FontLoader } from './FontLoader';
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fontFamilies","fontCssVars","applyFontFaces","FONT_ASSETS","FontLoader"],"sourceRoot":"../../../src","sources":["fonts/index.ts"],"mappings":";;AAAA,SAASA,YAAY,EAAEC,WAAW,QAAQ,aAAU;AAEpD,SAASC,cAAc,QAAQ,
|
|
1
|
+
{"version":3,"names":["fontFamilies","fontCssVars","applyFontFaces","FONT_ASSETS","FontLoader"],"sourceRoot":"../../../src","sources":["fonts/index.ts"],"mappings":";;AAAA,SAASA,YAAY,EAAEC,WAAW,QAAQ,aAAU;AAEpD,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,WAAW,QAAQ,kBAAe;AAC3C,SAASC,UAAU,QAAQ,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Web variant of the `./fonts` barrel.
|
|
4
|
+
//
|
|
5
|
+
// The default barrel (`./index.ts`) re-exports `applyFontFaces` from
|
|
6
|
+
// `./apply-font-faces`, which on native resolves to a no-op stub — Metro
|
|
7
|
+
// cannot parse `.woff2` module-level imports. The web fork explicitly
|
|
8
|
+
// reaches for `./apply-font-faces.web`, which performs the real `@font-face`
|
|
9
|
+
// injection.
|
|
10
|
+
//
|
|
11
|
+
// Web bundlers select this file via the `"browser"` condition in
|
|
12
|
+
// `package.json`'s `exports['./fonts']`; native bundlers fall through to
|
|
13
|
+
// `./index.ts` via the `"react-native"` condition.
|
|
14
|
+
export { fontFamilies, fontCssVars } from "./tokens.js";
|
|
15
|
+
export { applyFontFaces } from "./apply-font-faces.web.js";
|
|
16
|
+
export { FONT_ASSETS } from "./font-assets.js";
|
|
17
|
+
export { FontLoader } from './FontLoader';
|
|
18
|
+
//# sourceMappingURL=index.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fontFamilies","fontCssVars","applyFontFaces","FONT_ASSETS","FontLoader"],"sourceRoot":"../../../src","sources":["fonts/index.web.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAY,EAAEC,WAAW,QAAQ,aAAU;AAEpD,SAASC,cAAc,QAAQ,2BAAwB;AACvD,SAASC,WAAW,QAAQ,kBAAe;AAC3C,SAASC,UAAU,QAAQ,cAAc","ignoreList":[]}
|