@oxyhq/bloom 0.71.0 → 0.72.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/fonts/FontLoader.node.js +34 -0
- package/lib/commonjs/fonts/FontLoader.node.js.map +1 -0
- package/lib/commonjs/fonts/apply-font-faces.js +5 -4
- package/lib/commonjs/fonts/apply-font-faces.js.map +1 -1
- package/lib/commonjs/fonts/apply-font-faces.web.js +14 -16
- package/lib/commonjs/fonts/apply-font-faces.web.js.map +1 -1
- 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/commonjs/fonts/font-assets.web.js +3 -2
- package/lib/commonjs/fonts/font-assets.web.js.map +1 -1
- package/lib/commonjs/fonts/font-urls.web.js +35 -0
- package/lib/commonjs/fonts/font-urls.web.js.map +1 -0
- package/lib/commonjs/fonts/index.node.js +40 -0
- package/lib/commonjs/fonts/index.node.js.map +1 -0
- package/lib/module/fonts/FontLoader.node.js +29 -0
- package/lib/module/fonts/FontLoader.node.js.map +1 -0
- package/lib/module/fonts/apply-font-faces.js +5 -4
- package/lib/module/fonts/apply-font-faces.js.map +1 -1
- package/lib/module/fonts/apply-font-faces.web.js +14 -16
- package/lib/module/fonts/apply-font-faces.web.js.map +1 -1
- 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/module/fonts/font-assets.web.js +3 -2
- package/lib/module/fonts/font-assets.web.js.map +1 -1
- package/lib/module/fonts/font-urls.web.js +32 -0
- package/lib/module/fonts/font-urls.web.js.map +1 -0
- package/lib/module/fonts/index.node.js +22 -0
- package/lib/module/fonts/index.node.js.map +1 -0
- package/lib/module/fonts/index.web.js +3 -3
- package/lib/typescript/commonjs/fonts/FontLoader.node.d.ts +27 -0
- package/lib/typescript/commonjs/fonts/FontLoader.node.d.ts.map +1 -0
- package/lib/typescript/commonjs/fonts/apply-font-faces.d.ts.map +1 -1
- package/lib/typescript/commonjs/fonts/apply-font-faces.web.d.ts +9 -11
- package/lib/typescript/commonjs/fonts/apply-font-faces.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/fonts/font-assets.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/fonts/font-urls.web.d.ts +6 -0
- package/lib/typescript/commonjs/fonts/font-urls.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/fonts/index.node.d.ts +7 -0
- package/lib/typescript/commonjs/fonts/index.node.d.ts.map +1 -0
- package/lib/typescript/module/fonts/FontLoader.node.d.ts +27 -0
- package/lib/typescript/module/fonts/FontLoader.node.d.ts.map +1 -0
- package/lib/typescript/module/fonts/apply-font-faces.d.ts.map +1 -1
- package/lib/typescript/module/fonts/apply-font-faces.web.d.ts +9 -11
- package/lib/typescript/module/fonts/apply-font-faces.web.d.ts.map +1 -1
- package/lib/typescript/module/fonts/font-assets.web.d.ts.map +1 -1
- package/lib/typescript/module/fonts/font-urls.web.d.ts +6 -0
- package/lib/typescript/module/fonts/font-urls.web.d.ts.map +1 -0
- package/lib/typescript/module/fonts/index.node.d.ts +7 -0
- package/lib/typescript/module/fonts/index.node.d.ts.map +1 -0
- package/package.json +9 -7
- package/src/__tests__/apply-font-faces.test.ts +32 -0
- package/src/fonts/FontLoader.node.tsx +30 -0
- package/src/fonts/apply-font-faces.ts +5 -4
- package/src/fonts/apply-font-faces.web.ts +14 -16
- package/src/fonts/font-assets.web.ts +3 -2
- package/src/fonts/font-urls.web.ts +30 -0
- package/src/fonts/index.node.ts +21 -0
- package/src/fonts/index.web.ts +3 -3
- package/lib/commonjs/fonts/font-data.web.js +0 -22
- package/lib/commonjs/fonts/font-data.web.js.map +0 -1
- package/lib/module/fonts/font-data.web.js +0 -18
- package/lib/module/fonts/font-data.web.js.map +0 -1
- package/lib/typescript/commonjs/fonts/font-data.web.d.ts +0 -5
- package/lib/typescript/commonjs/fonts/font-data.web.d.ts.map +0 -1
- package/lib/typescript/module/fonts/font-data.web.d.ts +0 -5
- package/lib/typescript/module/fonts/font-data.web.d.ts.map +0 -1
- package/src/fonts/font-data.web.ts +0 -15
|
@@ -2,18 +2,16 @@
|
|
|
2
2
|
* Inject @font-face rules and font CSS variables onto :root.
|
|
3
3
|
*
|
|
4
4
|
* Web-only. The native counterpart in `apply-font-faces.ts` is a no-op
|
|
5
|
-
* stub —
|
|
6
|
-
* the font payload out of the native bundle entirely.
|
|
7
|
-
* call multiple times; subsequent calls early-return
|
|
8
|
-
* `<style id="bloom-fonts">` tag has been mounted. SSR-safe via
|
|
9
|
-
* `typeof document === 'undefined'` guard.
|
|
5
|
+
* stub — native loads its fonts through `useFonts(FONT_ASSETS)`, so the file
|
|
6
|
+
* split keeps the web font payload out of the native bundle entirely.
|
|
7
|
+
* Idempotent: safe to call multiple times; subsequent calls early-return
|
|
8
|
+
* after the `<style id="bloom-fonts">` tag has been mounted. SSR-safe via
|
|
9
|
+
* the `typeof document === 'undefined'` guard.
|
|
10
10
|
*
|
|
11
|
-
* The
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* the published JS is self-contained. See `scripts/generate-font-data.mjs`
|
|
16
|
-
* for the rationale and trade-offs.
|
|
11
|
+
* The URLs come from `./font-urls.web`, which imports the `.woff2` files so
|
|
12
|
+
* the consuming bundler emits them as separate, cacheable assets. See that
|
|
13
|
+
* module for the per-bundler details and for the one thing a consumer has to
|
|
14
|
+
* provide (Metro needs `woff2` in `assetExts`).
|
|
17
15
|
*/
|
|
18
16
|
export declare function applyFontFaces(): void;
|
|
19
17
|
//# sourceMappingURL=apply-font-faces.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-font-faces.web.d.ts","sourceRoot":"","sources":["../../../../src/fonts/apply-font-faces.web.ts"],"names":[],"mappings":"AAUA
|
|
1
|
+
{"version":3,"file":"apply-font-faces.web.d.ts","sourceRoot":"","sources":["../../../../src/fonts/apply-font-faces.web.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAkBrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font-assets.web.d.ts","sourceRoot":"","sources":["../../../../src/fonts/font-assets.web.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"font-assets.web.d.ts","sourceRoot":"","sources":["../../../../src/fonts/font-assets.web.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,WAAW,EAAE,YAAiB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import blomusModernusBold from './assets/BlomusModernus-Bold.woff2';
|
|
2
|
+
import blomusModernusRegular from './assets/BlomusModernus-Regular.woff2';
|
|
3
|
+
import geistMonoVariable from './assets/GeistMono-Variable.woff2';
|
|
4
|
+
import interVariable from './assets/InterVariable.woff2';
|
|
5
|
+
export { blomusModernusRegular, blomusModernusBold, interVariable, geistMonoVariable };
|
|
6
|
+
//# sourceMappingURL=font-urls.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font-urls.web.d.ts","sourceRoot":"","sources":["../../../../src/fonts/font-urls.web.ts"],"names":[],"mappings":"AAwBA,OAAO,kBAAkB,MAAM,oCAAoC,CAAC;AACpE,OAAO,qBAAqB,MAAM,uCAAuC,CAAC;AAC1E,OAAO,iBAAiB,MAAM,mCAAmC,CAAC;AAClE,OAAO,aAAa,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { fontFamilies, fontCssVars } from './tokens';
|
|
2
|
+
export type { FontFamilyName } from './tokens';
|
|
3
|
+
export { applyFontFaces } from './apply-font-faces';
|
|
4
|
+
export { FONT_ASSETS } from './font-assets';
|
|
5
|
+
export { FontLoader } from './FontLoader.node';
|
|
6
|
+
export type { FontLoaderProps } from './FontLoader.node';
|
|
7
|
+
//# sourceMappingURL=index.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../../../../src/fonts/index.node.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACrD,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxyhq/bloom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.72.1",
|
|
4
4
|
"description": "Bloom UI — Oxy ecosystem component library for React Native + Expo + Web",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -1233,6 +1233,11 @@
|
|
|
1233
1233
|
"import": "./lib/module/fonts/index.web.js",
|
|
1234
1234
|
"require": "./lib/commonjs/fonts/index.web.js"
|
|
1235
1235
|
},
|
|
1236
|
+
"node": {
|
|
1237
|
+
"types": "./lib/typescript/module/fonts/index.node.d.ts",
|
|
1238
|
+
"import": "./lib/module/fonts/index.node.js",
|
|
1239
|
+
"require": "./lib/commonjs/fonts/index.node.js"
|
|
1240
|
+
},
|
|
1236
1241
|
"import": {
|
|
1237
1242
|
"types": "./lib/typescript/module/fonts/index.d.ts",
|
|
1238
1243
|
"default": "./lib/module/fonts/index.js"
|
|
@@ -1419,19 +1424,16 @@
|
|
|
1419
1424
|
"license": "AGPL-3.0-only",
|
|
1420
1425
|
"scripts": {
|
|
1421
1426
|
"generate:exports": "node scripts/generate-platform-exports.mjs",
|
|
1422
|
-
"generate:font-data": "node scripts/generate-font-data.mjs",
|
|
1423
1427
|
"generate:theme-css": "bun scripts/generate-theme-css.ts",
|
|
1424
|
-
"prebuild": "node scripts/generate-platform-exports.mjs &&
|
|
1428
|
+
"prebuild": "node scripts/generate-platform-exports.mjs && bun scripts/generate-theme-css.ts",
|
|
1425
1429
|
"build": "bob build",
|
|
1426
1430
|
"postbuild": "node scripts/verify-package.mjs",
|
|
1427
1431
|
"verify:package": "node scripts/verify-package.mjs",
|
|
1428
1432
|
"test": "jest",
|
|
1429
|
-
"pretest": "node scripts/generate-font-data.mjs",
|
|
1430
1433
|
"typescript": "tsc --noEmit",
|
|
1431
|
-
"pretypescript": "node scripts/generate-font-data.mjs",
|
|
1432
1434
|
"clean": "rm -rf lib",
|
|
1433
1435
|
"prepack": "bun run clean && bun run build",
|
|
1434
|
-
"prepare": "bun run build || true",
|
|
1436
|
+
"prepare": "[ -n \"$BLOOM_VERIFY_PACKAGE_RUNNING\" ] || bun run build || true",
|
|
1435
1437
|
"release": "rm -rf lib && bun run build && release-it",
|
|
1436
1438
|
"storybook": "storybook dev -p 6006 --no-open",
|
|
1437
1439
|
"storybook:build": "storybook build -o storybook-static"
|
|
@@ -1539,7 +1541,7 @@
|
|
|
1539
1541
|
"react-native-builder-bob": {
|
|
1540
1542
|
"source": "src",
|
|
1541
1543
|
"output": "lib",
|
|
1542
|
-
"exclude": "{**/{__tests__,__fixtures__,__mocks__}/**,**/*.stories.{ts,tsx},**/*.{test,spec}.{ts,tsx}
|
|
1544
|
+
"exclude": "{**/{__tests__,__fixtures__,__mocks__}/**,**/*.stories.{ts,tsx},**/*.{test,spec}.{ts,tsx}}",
|
|
1543
1545
|
"targets": [
|
|
1544
1546
|
[
|
|
1545
1547
|
"commonjs",
|
|
@@ -54,4 +54,36 @@ describe('applyFontFaces (web)', () => {
|
|
|
54
54
|
expect(cssText).toMatch(/font-family: 'Inter'/);
|
|
55
55
|
expect(cssText).toMatch(/font-family: 'Geist Mono'/);
|
|
56
56
|
});
|
|
57
|
+
|
|
58
|
+
// The whole point of `font-urls.web.ts` is that the browser fetches and
|
|
59
|
+
// caches the four families on their own. Re-inlining them as `data:` URLs
|
|
60
|
+
// would still render correctly in every test above, so this is the only
|
|
61
|
+
// assertion that would notice.
|
|
62
|
+
it('points every src at a bundler-emitted URL, never an inlined data: URL', () => {
|
|
63
|
+
applyFontFaces();
|
|
64
|
+
const cssText = document.getElementById('bloom-fonts')?.textContent ?? '';
|
|
65
|
+
const sources = [...cssText.matchAll(/src: url\("([^"]*)"\)/g)].map((m) => m[1]);
|
|
66
|
+
expect(sources).toHaveLength(4);
|
|
67
|
+
for (const source of sources) {
|
|
68
|
+
expect(source).not.toMatch(/^data:/);
|
|
69
|
+
expect(source).toBeTruthy();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe('applyFontFaces (native stub)', () => {
|
|
75
|
+
beforeEach(() => {
|
|
76
|
+
document.head.innerHTML = '';
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Native loads `.ttf` through `useFonts`, so the default export must stay
|
|
80
|
+
// inert. If it ever forwarded to the web implementation, Metro would follow
|
|
81
|
+
// `font-urls.web.ts` and bundle a second, unusable copy of all four fonts
|
|
82
|
+
// into every iOS and Android build.
|
|
83
|
+
it('injects nothing', async () => {
|
|
84
|
+
const native = await import('../fonts/apply-font-faces');
|
|
85
|
+
native.applyFontFaces();
|
|
86
|
+
expect(document.getElementById('bloom-fonts')).toBeNull();
|
|
87
|
+
expect(document.head.innerHTML).toBe('');
|
|
88
|
+
});
|
|
57
89
|
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface FontLoaderProps {
|
|
4
|
+
/** Ignored — there is nothing to load. Kept so the API matches every platform. */
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
/** Ignored — nothing is ever pending, so children render immediately. */
|
|
7
|
+
fallback?: React.ReactNode;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Node font loader: a pass-through.
|
|
13
|
+
*
|
|
14
|
+
* There is no font registry to load into and no document to inject
|
|
15
|
+
* `@font-face` rules on, so the correct behaviour is to render children and
|
|
16
|
+
* stay out of the way — the same thing `FontLoader.tsx` ends up doing under
|
|
17
|
+
* Node once `applyFontFaces()` hits its `typeof document === 'undefined'`
|
|
18
|
+
* guard.
|
|
19
|
+
*
|
|
20
|
+
* It exists as a separate file rather than reusing that one because
|
|
21
|
+
* `FontLoader.tsx` imports `./apply-font-faces.web` outright, which reaches
|
|
22
|
+
* `font-urls.web`'s `.woff2` imports. Node hands a `.woff2` to the JS parser,
|
|
23
|
+
* so merely LOADING that module is fatal — the guard inside the function never
|
|
24
|
+
* gets a chance to run. Reached only through the `node` export condition on
|
|
25
|
+
* `./fonts`; see `scripts/generate-platform-exports.mjs` for why conditions
|
|
26
|
+
* are the only lever available here.
|
|
27
|
+
*/
|
|
28
|
+
export function FontLoader({ children }: FontLoaderProps) {
|
|
29
|
+
return <>{children}</>;
|
|
30
|
+
}
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// is selected by bundlers via the package.json conditions. RN consumers
|
|
3
3
|
// never need font-face injection — useFonts handles loading on native.
|
|
4
4
|
//
|
|
5
|
-
// The
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
5
|
+
// The split is load-bearing, not decorative: the web variant reaches
|
|
6
|
+
// `font-urls.web.ts`, whose module-level `.woff2` imports would otherwise
|
|
7
|
+
// drag a second, unusable copy of every font into the native bundle
|
|
8
|
+
// (Metro resolves an asset import on native to a registry id, not a URL).
|
|
9
|
+
// Keeping this stub empty is what guarantees native pays nothing for them.
|
|
9
10
|
export function applyFontFaces(): void {
|
|
10
11
|
// intentionally empty
|
|
11
12
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
blomusModernusBold,
|
|
4
4
|
interVariable,
|
|
5
5
|
geistMonoVariable,
|
|
6
|
-
} from './font-
|
|
6
|
+
} from './font-urls.web';
|
|
7
7
|
import { fontFamilies } from './tokens';
|
|
8
8
|
|
|
9
9
|
const STYLE_ID = 'bloom-fonts';
|
|
@@ -12,18 +12,16 @@ const STYLE_ID = 'bloom-fonts';
|
|
|
12
12
|
* Inject @font-face rules and font CSS variables onto :root.
|
|
13
13
|
*
|
|
14
14
|
* Web-only. The native counterpart in `apply-font-faces.ts` is a no-op
|
|
15
|
-
* stub —
|
|
16
|
-
* the font payload out of the native bundle entirely.
|
|
17
|
-
* call multiple times; subsequent calls early-return
|
|
18
|
-
* `<style id="bloom-fonts">` tag has been mounted. SSR-safe via
|
|
19
|
-
* `typeof document === 'undefined'` guard.
|
|
15
|
+
* stub — native loads its fonts through `useFonts(FONT_ASSETS)`, so the file
|
|
16
|
+
* split keeps the web font payload out of the native bundle entirely.
|
|
17
|
+
* Idempotent: safe to call multiple times; subsequent calls early-return
|
|
18
|
+
* after the `<style id="bloom-fonts">` tag has been mounted. SSR-safe via
|
|
19
|
+
* the `typeof document === 'undefined'` guard.
|
|
20
20
|
*
|
|
21
|
-
* The
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* the published JS is self-contained. See `scripts/generate-font-data.mjs`
|
|
26
|
-
* for the rationale and trade-offs.
|
|
21
|
+
* The URLs come from `./font-urls.web`, which imports the `.woff2` files so
|
|
22
|
+
* the consuming bundler emits them as separate, cacheable assets. See that
|
|
23
|
+
* module for the per-bundler details and for the one thing a consumer has to
|
|
24
|
+
* provide (Metro needs `woff2` in `assetExts`).
|
|
27
25
|
*/
|
|
28
26
|
export function applyFontFaces(): void {
|
|
29
27
|
if (typeof document === 'undefined') return;
|
|
@@ -32,10 +30,10 @@ export function applyFontFaces(): void {
|
|
|
32
30
|
const style = document.createElement('style');
|
|
33
31
|
style.id = STYLE_ID;
|
|
34
32
|
style.textContent = `
|
|
35
|
-
@font-face { font-family: 'BlomusModernus'; src: url(${blomusModernusRegular}) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
|
|
36
|
-
@font-face { font-family: 'BlomusModernus'; src: url(${blomusModernusBold}) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
|
|
37
|
-
@font-face { font-family: 'Inter'; src: url(${interVariable}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
38
|
-
@font-face { font-family: 'Geist Mono'; src: url(${geistMonoVariable}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
33
|
+
@font-face { font-family: 'BlomusModernus'; src: url("${blomusModernusRegular}") format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
|
|
34
|
+
@font-face { font-family: 'BlomusModernus'; src: url("${blomusModernusBold}") format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
|
|
35
|
+
@font-face { font-family: 'Inter'; src: url("${interVariable}") format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
36
|
+
@font-face { font-family: 'Geist Mono'; src: url("${geistMonoVariable}") format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
39
37
|
:root {
|
|
40
38
|
--bloom-font-display: ${fontFamilies.display};
|
|
41
39
|
--bloom-font-sans: ${fontFamilies.sans};
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
//
|
|
3
3
|
// `useFonts()` is native-only — the web `FontLoader` (`FontLoader.tsx`) calls
|
|
4
4
|
// `applyFontFaces()` instead, which injects the same four families as
|
|
5
|
-
// `@font-face` rules
|
|
6
|
-
// `font-
|
|
5
|
+
// `@font-face` rules pointing at bundler-emitted `.woff2` URLs
|
|
6
|
+
// (`apply-font-faces.web.ts` / `font-urls.web.ts`). So the map is empty by
|
|
7
|
+
// design, not by omission.
|
|
7
8
|
//
|
|
8
9
|
// This file exists so `index.web.ts` can name its font-asset source
|
|
9
10
|
// explicitly, exactly as it already does for `./apply-font-faces.web`. The
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Web font URLs, resolved by whatever bundler is building the consuming app.
|
|
2
|
+
//
|
|
3
|
+
// WEB-ONLY. Each import below hands the `.woff2` to the app's asset pipeline,
|
|
4
|
+
// which emits it as a standalone file and gives us back its URL:
|
|
5
|
+
//
|
|
6
|
+
// - Metro (Expo web) rewrites the import to the exported asset path — its
|
|
7
|
+
// asset transformer emits a bare string module whenever the platform is
|
|
8
|
+
// `web`, so the imported value is the URL itself, not an asset id.
|
|
9
|
+
// - Vite, Rollup and webpack 5 resolve it through their own asset handling
|
|
10
|
+
// and return a content-hashed URL.
|
|
11
|
+
//
|
|
12
|
+
// Either way the browser fetches the four families alongside the JS and caches
|
|
13
|
+
// them under their own URLs, instead of re-parsing ~310 KB of base64 out of the
|
|
14
|
+
// entry bundle on every cold load. No consumer ever writes an asset filename
|
|
15
|
+
// down, so a font swap here cannot leave a downstream app pointing at a file
|
|
16
|
+
// that no longer exists.
|
|
17
|
+
//
|
|
18
|
+
// Metro does not carry `woff2` in its default `assetExts`, so a consumer
|
|
19
|
+
// bundling for web with Metro has to register it; `@oxyhq/app-preset`'s Metro
|
|
20
|
+
// base already does that for every Oxy app.
|
|
21
|
+
//
|
|
22
|
+
// Native never reaches this module. The default `apply-font-faces.ts` is a
|
|
23
|
+
// no-op stub and `FontLoader.native.tsx` loads the `.ttf` variants through
|
|
24
|
+
// `useFonts` instead, so no web font bytes enter a native bundle.
|
|
25
|
+
import blomusModernusBold from './assets/BlomusModernus-Bold.woff2';
|
|
26
|
+
import blomusModernusRegular from './assets/BlomusModernus-Regular.woff2';
|
|
27
|
+
import geistMonoVariable from './assets/GeistMono-Variable.woff2';
|
|
28
|
+
import interVariable from './assets/InterVariable.woff2';
|
|
29
|
+
|
|
30
|
+
export { blomusModernusRegular, blomusModernusBold, interVariable, geistMonoVariable };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Node variant of the `./fonts` barrel, selected by the `node` export
|
|
2
|
+
// condition. Same surface as `./index.ts`, with every member resolved to the
|
|
3
|
+
// inert implementation:
|
|
4
|
+
//
|
|
5
|
+
// - `./apply-font-faces` is the no-op stub. The web one is unreachable here on
|
|
6
|
+
// purpose: it imports `font-urls.web`, whose `.woff2` imports Node feeds to
|
|
7
|
+
// the JS parser, so loading it throws `SyntaxError` before any runtime guard
|
|
8
|
+
// can help.
|
|
9
|
+
// - `./font-assets` is the empty map — there is no native font registry.
|
|
10
|
+
// - `./FontLoader.node` renders children and nothing else.
|
|
11
|
+
//
|
|
12
|
+
// Both platform-forked members are named OUTRIGHT rather than left
|
|
13
|
+
// extensionless, for the same reason `index.web.ts` does it: Node performs no
|
|
14
|
+
// platform-extension resolution, so a bare specifier would fall through to
|
|
15
|
+
// whichever file happens to sit at that path.
|
|
16
|
+
export { fontFamilies, fontCssVars } from './tokens';
|
|
17
|
+
export type { FontFamilyName } from './tokens';
|
|
18
|
+
export { applyFontFaces } from './apply-font-faces';
|
|
19
|
+
export { FONT_ASSETS } from './font-assets';
|
|
20
|
+
export { FontLoader } from './FontLoader.node';
|
|
21
|
+
export type { FontLoaderProps } from './FontLoader.node';
|
package/src/fonts/index.web.ts
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
// of the box), so an extensionless specifier here would quietly fall through
|
|
7
7
|
// to the default file.
|
|
8
8
|
//
|
|
9
|
-
// - `./apply-font-faces.web` performs the real `@font-face` injection
|
|
10
|
-
//
|
|
11
|
-
// `./apply-font-faces` is a no-op stub for native.
|
|
9
|
+
// - `./apply-font-faces.web` performs the real `@font-face` injection against
|
|
10
|
+
// the `.woff2` URLs the consuming bundler emits (see `font-urls.web.ts`);
|
|
11
|
+
// the default `./apply-font-faces` is a no-op stub for native.
|
|
12
12
|
// - `./font-assets.web` is an empty map. The native map is built from Metro
|
|
13
13
|
// asset `require()` calls, and importing it from an ES module throws
|
|
14
14
|
// `ReferenceError: require is not defined` during module evaluation — which
|