@oxyhq/bloom 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/error-boundary/ErrorBoundary.js +27 -7
- package/lib/commonjs/error-boundary/ErrorBoundary.js.map +1 -1
- package/lib/commonjs/fonts/FontLoader.js +6 -5
- package/lib/commonjs/fonts/FontLoader.js.map +1 -1
- package/lib/commonjs/fonts/apply-font-faces.js +4 -4
- package/lib/commonjs/fonts/apply-font-faces.web.js +13 -12
- package/lib/commonjs/fonts/apply-font-faces.web.js.map +1 -1
- package/lib/commonjs/fonts/font-assets.js +2 -2
- package/lib/commonjs/fonts/font-data.web.js +22 -0
- package/lib/commonjs/fonts/font-data.web.js.map +1 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/skeleton/index.js +30 -0
- package/lib/commonjs/skeleton/index.js.map +1 -1
- package/lib/module/error-boundary/ErrorBoundary.js +27 -7
- package/lib/module/error-boundary/ErrorBoundary.js.map +1 -1
- package/lib/module/fonts/FontLoader.js +6 -5
- package/lib/module/fonts/FontLoader.js.map +1 -1
- package/lib/module/fonts/apply-font-faces.js +4 -4
- package/lib/module/fonts/apply-font-faces.web.js +13 -10
- package/lib/module/fonts/apply-font-faces.web.js.map +1 -1
- package/lib/module/fonts/font-assets.js +2 -2
- package/lib/module/fonts/font-data.web.js +18 -0
- package/lib/module/fonts/font-data.web.js.map +1 -0
- package/lib/module/fonts/index.web.js +4 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/skeleton/index.js +29 -0
- package/lib/module/skeleton/index.js.map +1 -1
- package/lib/typescript/commonjs/error-boundary/ErrorBoundary.d.ts +3 -1
- package/lib/typescript/commonjs/error-boundary/ErrorBoundary.d.ts.map +1 -1
- package/lib/typescript/commonjs/error-boundary/index.d.ts +1 -1
- package/lib/typescript/commonjs/error-boundary/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/error-boundary/types.d.ts +41 -2
- package/lib/typescript/commonjs/error-boundary/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/fonts/FontLoader.d.ts.map +1 -1
- package/lib/typescript/commonjs/fonts/apply-font-faces.web.d.ts +8 -1
- package/lib/typescript/commonjs/fonts/apply-font-faces.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/fonts/font-data.web.d.ts +5 -0
- package/lib/typescript/commonjs/fonts/font-data.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +1 -1
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.web.d.ts +1 -1
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/skeleton/index.d.ts +24 -1
- package/lib/typescript/commonjs/skeleton/index.d.ts.map +1 -1
- package/lib/typescript/module/error-boundary/ErrorBoundary.d.ts +3 -1
- package/lib/typescript/module/error-boundary/ErrorBoundary.d.ts.map +1 -1
- package/lib/typescript/module/error-boundary/index.d.ts +1 -1
- package/lib/typescript/module/error-boundary/index.d.ts.map +1 -1
- package/lib/typescript/module/error-boundary/types.d.ts +41 -2
- package/lib/typescript/module/error-boundary/types.d.ts.map +1 -1
- package/lib/typescript/module/fonts/FontLoader.d.ts.map +1 -1
- package/lib/typescript/module/fonts/apply-font-faces.web.d.ts +8 -1
- package/lib/typescript/module/fonts/apply-font-faces.web.d.ts.map +1 -1
- package/lib/typescript/module/fonts/font-data.web.d.ts +5 -0
- package/lib/typescript/module/fonts/font-data.web.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +1 -1
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/index.web.d.ts +1 -1
- package/lib/typescript/module/index.web.d.ts.map +1 -1
- package/lib/typescript/module/skeleton/index.d.ts +24 -1
- package/lib/typescript/module/skeleton/index.d.ts.map +1 -1
- package/package.json +36 -5
- package/src/__tests__/ErrorBoundary.test.tsx +217 -0
- package/src/__tests__/Skeleton.test.tsx +63 -0
- package/src/avatar/Avatar.stories.tsx +69 -0
- package/src/bottom-sheet/BottomSheet.stories.tsx +92 -0
- package/src/button/Button.stories.tsx +94 -0
- package/src/context-menu/ContextMenu.stories.tsx +71 -0
- package/src/dialog/Dialog.stories.tsx +112 -0
- package/src/error-boundary/ErrorBoundary.tsx +28 -5
- package/src/error-boundary/index.ts +5 -1
- package/src/error-boundary/types.ts +45 -2
- package/src/fonts/FontLoader.tsx +6 -5
- package/src/fonts/apply-font-faces.ts +4 -4
- package/src/fonts/apply-font-faces.web.ts +18 -10
- package/src/fonts/font-assets.ts +2 -2
- package/src/fonts/font-data.web.ts +15 -0
- package/src/fonts/index.web.ts +4 -4
- package/src/index.ts +5 -1
- package/src/index.web.ts +5 -1
- package/src/loading/Loading.stories.tsx +60 -0
- package/src/menu/Menu.stories.tsx +79 -0
- package/src/prompt-input/PromptInput.stories.tsx +82 -0
- package/src/select/Select.stories.tsx +84 -0
- package/src/settings-list/SettingsList.stories.tsx +106 -0
- package/src/skeleton/index.tsx +54 -1
- package/src/text-field/TextField.stories.tsx +90 -0
- package/src/toast/Toast.stories.tsx +109 -0
- package/lib/commonjs/fonts/assets/BlomusModernus-Bold.woff2 +0 -0
- package/lib/commonjs/fonts/assets/BlomusModernus-Regular.woff2 +0 -0
- package/lib/commonjs/fonts/assets/GeistMono-Variable.woff2 +0 -0
- package/lib/commonjs/fonts/assets/InterVariable.woff2 +0 -0
- package/lib/module/fonts/assets/BlomusModernus-Bold.woff2 +0 -0
- package/lib/module/fonts/assets/BlomusModernus-Regular.woff2 +0 -0
- package/lib/module/fonts/assets/GeistMono-Variable.woff2 +0 -0
- package/lib/module/fonts/assets/InterVariable.woff2 +0 -0
- package/lib/typescript/commonjs/__tests__/BloomThemeProvider.fonts-web.test.d.ts +0 -5
- package/lib/typescript/commonjs/__tests__/BloomThemeProvider.fonts-web.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/BloomThemeProvider.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/BloomThemeProvider.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/BottomSheet.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/BottomSheet.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/Button.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/Button.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/Code.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/Code.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/Dialog.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/Dialog.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/FontLoader.native.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/FontLoader.native.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/Pre.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/Pre.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/SettingsList.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/SettingsList.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/apply-font-faces.test.d.ts +0 -5
- package/lib/typescript/commonjs/__tests__/apply-font-faces.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/theme.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/theme.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/BloomThemeProvider.fonts-web.test.d.ts +0 -5
- package/lib/typescript/module/__tests__/BloomThemeProvider.fonts-web.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/BloomThemeProvider.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/BloomThemeProvider.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/BottomSheet.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/BottomSheet.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/Button.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/Button.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/Code.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/Code.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/Dialog.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/Dialog.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/FontLoader.native.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/FontLoader.native.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/Pre.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/Pre.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/SettingsList.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/SettingsList.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/apply-font-faces.test.d.ts +0 -5
- package/lib/typescript/module/__tests__/apply-font-faces.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/theme.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/theme.test.d.ts.map +0 -1
|
@@ -49,7 +49,9 @@ class ErrorBoundary extends _react.Component {
|
|
|
49
49
|
static displayName = 'ErrorBoundary';
|
|
50
50
|
state = {
|
|
51
51
|
hasError: false,
|
|
52
|
-
error: null
|
|
52
|
+
error: null,
|
|
53
|
+
errorInfo: null,
|
|
54
|
+
retryCount: 0
|
|
53
55
|
};
|
|
54
56
|
static getDerivedStateFromError(error) {
|
|
55
57
|
return {
|
|
@@ -58,18 +60,36 @@ class ErrorBoundary extends _react.Component {
|
|
|
58
60
|
};
|
|
59
61
|
}
|
|
60
62
|
componentDidCatch(error, errorInfo) {
|
|
63
|
+
this.setState({
|
|
64
|
+
errorInfo
|
|
65
|
+
});
|
|
61
66
|
this.props.onError?.(error, errorInfo);
|
|
62
67
|
}
|
|
63
68
|
handleRetry = () => {
|
|
64
|
-
this.setState({
|
|
69
|
+
this.setState(prev => ({
|
|
65
70
|
hasError: false,
|
|
66
|
-
error: null
|
|
67
|
-
|
|
71
|
+
error: null,
|
|
72
|
+
errorInfo: null,
|
|
73
|
+
retryCount: prev.retryCount + 1
|
|
74
|
+
}));
|
|
68
75
|
};
|
|
69
76
|
render() {
|
|
70
|
-
if (this.state.hasError) {
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
if (this.state.hasError && this.state.error) {
|
|
78
|
+
const {
|
|
79
|
+
fallback
|
|
80
|
+
} = this.props;
|
|
81
|
+
if (typeof fallback === 'function') {
|
|
82
|
+
// Render-prop variant — invoke with error context.
|
|
83
|
+
return fallback({
|
|
84
|
+
error: this.state.error,
|
|
85
|
+
errorInfo: this.state.errorInfo,
|
|
86
|
+
retry: this.handleRetry,
|
|
87
|
+
retryCount: this.state.retryCount
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (fallback !== undefined) {
|
|
91
|
+
// Static ReactNode variant (backward-compatible).
|
|
92
|
+
return fallback;
|
|
73
93
|
}
|
|
74
94
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(DefaultFallback, {
|
|
75
95
|
title: this.props.title ?? 'Something went wrong',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DefaultFallback","title","message","retryLabel","onRetry","jsxs","View","style","styles","container","children","jsx","Text","TouchableOpacity","retryButton","onPress","activeOpacity","retryText","ErrorBoundary","Component","displayName","state","hasError","error","getDerivedStateFromError","componentDidCatch","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DefaultFallback","title","message","retryLabel","onRetry","jsxs","View","style","styles","container","children","jsx","Text","TouchableOpacity","retryButton","onPress","activeOpacity","retryText","ErrorBoundary","Component","displayName","state","hasError","error","errorInfo","retryCount","getDerivedStateFromError","componentDidCatch","setState","props","onError","handleRetry","prev","render","fallback","retry","undefined","exports","StyleSheet","create","flex","alignItems","justifyContent","padding","backgroundColor","fontSize","fontWeight","marginBottom","textAlign","color","lineHeight","paddingHorizontal","paddingVertical","borderRadius","minWidth"],"sourceRoot":"../../../src","sources":["error-boundary/ErrorBoundary.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAwE,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,CA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,WAAY;QACjDC,OAAO,EAAE,IAAI,CAAC2B;MAAY,CAC3B,CAAC;IAEN;IAEA,OAAO,IAAI,CAACF,KAAK,CAACnB,QAAQ;EAC5B;AACF;;AAEA;AACA;AAAA2B,OAAA,CAAAnB,aAAA,GAAAA,aAAA;AACA,MAAMV,MAAM,GAAG8B,uBAAU,CAACC,MAAM,CAAC;EAC/B9B,SAAS,EAAE;IACT+B,IAAI,EAAE,CAAC;IACPC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,QAAQ;IACxBC,OAAO,EAAE,EAAE;IACXC,eAAe,EAAE;EACnB,CAAC;EACD3C,KAAK,EAAE;IACL4C,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,MAAM;IAClBC,YAAY,EAAE,EAAE;IAChBC,SAAS,EAAE,QAAQ;IACnBC,KAAK,EAAE;EACT,CAAC;EACD/C,OAAO,EAAE;IACP2C,QAAQ,EAAE,EAAE;IACZG,SAAS,EAAE,QAAQ;IACnBD,YAAY,EAAE,EAAE;IAChBG,UAAU,EAAE,EAAE;IACdC,iBAAiB,EAAE,EAAE;IACrBF,KAAK,EAAE;EACT,CAAC;EACDnC,WAAW,EAAE;IACXqC,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,YAAY,EAAE,EAAE;IAChBC,QAAQ,EAAE,GAAG;IACbb,UAAU,EAAE,QAAQ;IACpBG,eAAe,EAAE;EACnB,CAAC;EACD3B,SAAS,EAAE;IACTgC,KAAK,EAAE,SAAS;IAChBJ,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -9,11 +9,12 @@ 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
11
|
// Reach for the web variant explicitly. The default `./apply-font-faces`
|
|
12
|
-
// is a no-op stub
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
// bundlers — Metro selects `FontLoader.native.tsx` on iOS/Android
|
|
16
|
-
// is safe to take a direct dependency on the web implementation
|
|
12
|
+
// is a no-op stub on native — native loads its fonts via
|
|
13
|
+
// `useFonts(FONT_ASSETS)` in `FontLoader.native.tsx` and has no use for
|
|
14
|
+
// CSS `@font-face` injection. This file (`FontLoader.tsx`) is only picked
|
|
15
|
+
// up by web bundlers — Metro selects `FontLoader.native.tsx` on iOS/Android
|
|
16
|
+
// — so it is safe to take a direct dependency on the web implementation
|
|
17
|
+
// here.
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Web font loader. Applies the Bloom `@font-face` rules and CSS variables
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAQA,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;AAPxD;AACA;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":[]}
|
|
@@ -8,10 +8,10 @@ exports.applyFontFaces = applyFontFaces;
|
|
|
8
8
|
// is selected by bundlers via the package.json conditions. RN consumers
|
|
9
9
|
// never need font-face injection — useFonts handles loading on native.
|
|
10
10
|
//
|
|
11
|
-
//
|
|
12
|
-
// imports
|
|
13
|
-
//
|
|
14
|
-
//
|
|
11
|
+
// The web variant does NOT pull in any `.woff2` files via asset imports —
|
|
12
|
+
// it imports base64 data URLs from `font-data.web.ts`. This stub stays
|
|
13
|
+
// here so the file split (`*.ts` vs `*.web.ts`) makes the platform
|
|
14
|
+
// intent explicit and so the runtime API surface matches across platforms.
|
|
15
15
|
function applyFontFaces() {
|
|
16
16
|
// intentionally empty
|
|
17
17
|
}
|
|
@@ -4,14 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.applyFontFaces = applyFontFaces;
|
|
7
|
-
var
|
|
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"));
|
|
7
|
+
var _fontDataWeb = require("./font-data.web.js");
|
|
11
8
|
var _tokens = require("./tokens.js");
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
/// <reference path="../assets.d.ts" />
|
|
14
|
-
|
|
15
9
|
const STYLE_ID = 'bloom-fonts';
|
|
16
10
|
|
|
17
11
|
/**
|
|
@@ -19,10 +13,17 @@ const STYLE_ID = 'bloom-fonts';
|
|
|
19
13
|
*
|
|
20
14
|
* Web-only. The native counterpart in `apply-font-faces.ts` is a no-op
|
|
21
15
|
* stub — Metro cannot parse `.woff2` imports, so the file split keeps
|
|
22
|
-
*
|
|
16
|
+
* the font payload out of the native bundle entirely. Idempotent: safe to
|
|
23
17
|
* call multiple times; subsequent calls early-return after the
|
|
24
18
|
* `<style id="bloom-fonts">` tag has been mounted. SSR-safe via the
|
|
25
19
|
* `typeof document === 'undefined'` guard.
|
|
20
|
+
*
|
|
21
|
+
* The font URLs come from `./font-data.web`, a generated module that
|
|
22
|
+
* embeds the woff2 bytes as base64 data URLs. Inlining (rather than
|
|
23
|
+
* relying on bundler asset loaders for `.woff2`) means consumers do not
|
|
24
|
+
* have to extend Metro's `assetExts` or add a webpack/Vite asset rule —
|
|
25
|
+
* the published JS is self-contained. See `scripts/generate-font-data.mjs`
|
|
26
|
+
* for the rationale and trade-offs.
|
|
26
27
|
*/
|
|
27
28
|
function applyFontFaces() {
|
|
28
29
|
if (typeof document === 'undefined') return;
|
|
@@ -30,10 +31,10 @@ function applyFontFaces() {
|
|
|
30
31
|
const style = document.createElement('style');
|
|
31
32
|
style.id = STYLE_ID;
|
|
32
33
|
style.textContent = `
|
|
33
|
-
@font-face { font-family: 'BlomusModernus'; src: url(${
|
|
34
|
-
@font-face { font-family: 'BlomusModernus'; src: url(${
|
|
35
|
-
@font-face { font-family: 'Inter'; src: url(${
|
|
36
|
-
@font-face { font-family: 'Geist Mono'; src: url(${
|
|
34
|
+
@font-face { font-family: 'BlomusModernus'; src: url(${_fontDataWeb.blomusModernusRegular}) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
|
|
35
|
+
@font-face { font-family: 'BlomusModernus'; src: url(${_fontDataWeb.blomusModernusBold}) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
|
|
36
|
+
@font-face { font-family: 'Inter'; src: url(${_fontDataWeb.interVariable}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
37
|
+
@font-face { font-family: 'Geist Mono'; src: url(${_fontDataWeb.geistMonoVariable}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
37
38
|
:root {
|
|
38
39
|
--bloom-font-display: ${_tokens.fontFamilies.display};
|
|
39
40
|
--bloom-font-sans: ${_tokens.fontFamilies.sans};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_fontDataWeb","require","_tokens","STYLE_ID","applyFontFaces","document","getElementById","style","createElement","id","textContent","blomusModernusRegular","blomusModernusBold","interVariable","geistMonoVariable","fontFamilies","display","sans","mono","head","appendChild"],"sourceRoot":"../../../src","sources":["fonts/apply-font-faces.web.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,QAAQ,GAAG,aAAa;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,kCAAqB;AAChF,2DAA2DC,+BAAkB;AAC7E,kDAAkDC,0BAAa;AAC/D,uDAAuDC,8BAAiB;AACxE;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.web.ts`
|
|
15
|
-
// file is never imported.
|
|
14
|
+
// `apply-font-faces.web.ts` inlines the .woff2 variants as base64 data URLs
|
|
15
|
+
// (see `font-data.web.ts`) and this file is never imported.
|
|
16
16
|
|
|
17
17
|
const FONT_ASSETS = exports.FONT_ASSETS = {
|
|
18
18
|
BlomusModernus: require('./assets/BlomusModernus-Regular.ttf'),
|