expo-font 11.7.0 → 11.9.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/CHANGELOG.md CHANGED
@@ -10,6 +10,28 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 11.9.0 — 2023-11-14
14
+
15
+ ### 🛠 Breaking changes
16
+
17
+ - Bumped iOS deployment target to 13.4. ([#25063](https://github.com/expo/expo/pull/25063) by [@gabrieldonadel](https://github.com/gabrieldonadel))
18
+ - On `Android` bump `compileSdkVersion` and `targetSdkVersion` to `34`. ([#24708](https://github.com/expo/expo/pull/24708) by [@alanjhughes](https://github.com/alanjhughes))
19
+
20
+ ### 🐛 Bug fixes
21
+
22
+ - Handle the case where no argument is passed to the plugin. ([#25138](https://github.com/expo/expo/pull/25138) by [@alanjhughes](https://github.com/alanjhughes))
23
+
24
+ ## 11.8.0 — 2023-10-17
25
+
26
+ ### 🛠 Breaking changes
27
+
28
+ - Dropped support for Android SDK 21 and 22. ([#24201](https://github.com/expo/expo/pull/24201) by [@behenate](https://github.com/behenate))
29
+
30
+ ### 🎉 New features
31
+
32
+ - Added config plugin to allow fonts to be linked at build time. ([#24772](https://github.com/expo/expo/pull/24772) by [@alanjhughes](https://github.com/alanjhughes))
33
+ - Remove `unimodule.json` in favour of `expo-module.config.json`. ([#25099](https://github.com/expo/expo/pull/25099) by [@reichhartd](https://github.com/reichhartd))
34
+
13
35
  ## 11.7.0 — 2023-09-15
14
36
 
15
37
  ### 🎉 New features
@@ -3,15 +3,20 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '11.7.0'
6
+ version = '11.9.0'
7
7
 
8
- buildscript {
9
- def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
10
- if (expoModulesCorePlugin.exists()) {
11
- apply from: expoModulesCorePlugin
12
- applyKotlinExpoModulesCorePlugin()
8
+ def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
9
+ if (expoModulesCorePlugin.exists()) {
10
+ apply from: expoModulesCorePlugin
11
+ applyKotlinExpoModulesCorePlugin()
12
+ // Remove this check, but keep the contents after SDK49 support is dropped
13
+ if (safeExtGet("expoProvidesDefaultConfig", false)) {
14
+ useExpoPublishing()
15
+ useCoreDependencies()
13
16
  }
17
+ }
14
18
 
19
+ buildscript {
15
20
  // Simple helper that allows the root project to override versions declared by this library.
16
21
  ext.safeExtGet = { prop, fallback ->
17
22
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
@@ -35,23 +40,44 @@ buildscript {
35
40
  }
36
41
  }
37
42
 
38
- afterEvaluate {
39
- publishing {
40
- publications {
41
- release(MavenPublication) {
42
- from components.release
43
+ // Remove this if and it's contents, when support for SDK49 is dropped
44
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
45
+ afterEvaluate {
46
+ publishing {
47
+ publications {
48
+ release(MavenPublication) {
49
+ from components.release
50
+ }
43
51
  }
44
- }
45
- repositories {
46
- maven {
47
- url = mavenLocal().url
52
+ repositories {
53
+ maven {
54
+ url = mavenLocal().url
55
+ }
48
56
  }
49
57
  }
50
58
  }
51
59
  }
52
60
 
53
61
  android {
54
- compileSdkVersion safeExtGet("compileSdkVersion", 33)
62
+ // Remove this if and it's contents, when support for SDK49 is dropped
63
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
64
+ compileSdkVersion safeExtGet("compileSdkVersion", 34)
65
+
66
+ defaultConfig {
67
+ minSdkVersion safeExtGet("minSdkVersion", 23)
68
+ targetSdkVersion safeExtGet("targetSdkVersion", 34)
69
+ }
70
+
71
+ publishing {
72
+ singleVariant("release") {
73
+ withSourcesJar()
74
+ }
75
+ }
76
+
77
+ lintOptions {
78
+ abortOnError false
79
+ }
80
+ }
55
81
 
56
82
  def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
57
83
  if (agpVersion.tokenize('.')[0].toInteger() < 8) {
@@ -67,23 +93,15 @@ android {
67
93
 
68
94
  namespace "expo.modules.font"
69
95
  defaultConfig {
70
- minSdkVersion safeExtGet("minSdkVersion", 21)
71
- targetSdkVersion safeExtGet("targetSdkVersion", 33)
72
96
  versionCode 29
73
- versionName "11.7.0"
74
- }
75
- lintOptions {
76
- abortOnError false
77
- }
78
- publishing {
79
- singleVariant("release") {
80
- withSourcesJar()
81
- }
97
+ versionName "11.9.0"
82
98
  }
83
99
  }
84
100
 
85
101
  dependencies {
86
- implementation project(':expo-modules-core')
87
-
88
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
102
+ // Remove this if and it's contents, when support for SDK49 is dropped
103
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
104
+ implementation project(':expo-modules-core')
105
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
106
+ }
89
107
  }
package/app.plugin.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./plugin/build/withFonts');
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
10
10
  s.license = package['license']
11
11
  s.author = package['author']
12
12
  s.homepage = package['homepage']
13
- s.platforms = { :ios => '13.0', :tvos => '13.0'}
13
+ s.platforms = { :ios => '13.4', :tvos => '13.4'}
14
14
  s.source = { git: 'https://github.com/expo/expo.git' }
15
15
  s.static_framework = true
16
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-font",
3
- "version": "11.7.0",
3
+ "version": "11.9.0",
4
4
  "description": "Load fonts at runtime and use them in React Native components.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -42,5 +42,5 @@
42
42
  "peerDependencies": {
43
43
  "expo": "*"
44
44
  },
45
- "gitHead": "ee2c866ba3c7fbc35ff2a3e896041cf15d3bd7c5"
45
+ "gitHead": "3142a086578deffd8704a8f1b6f0f661527d836c"
46
46
  }
@@ -0,0 +1 @@
1
+ export declare function resolveFontPaths(fonts: string[], projectRoot: string): Promise<string[]>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resolveFontPaths = void 0;
7
+ const promises_1 = __importDefault(require("fs/promises"));
8
+ const path_1 = __importDefault(require("path"));
9
+ async function resolveFontPaths(fonts, projectRoot) {
10
+ const promises = fonts.map(async (p) => {
11
+ const resolvedPath = path_1.default.resolve(projectRoot, p);
12
+ const stat = await promises_1.default.stat(resolvedPath);
13
+ if (stat.isDirectory()) {
14
+ const dir = await promises_1.default.readdir(resolvedPath);
15
+ return dir.map((file) => path_1.default.join(resolvedPath, file));
16
+ }
17
+ return [resolvedPath];
18
+ });
19
+ return (await Promise.all(promises)).flat();
20
+ }
21
+ exports.resolveFontPaths = resolveFontPaths;
@@ -0,0 +1,6 @@
1
+ import { ConfigPlugin } from 'expo/config-plugins';
2
+ export type FontProps = {
3
+ fonts?: string[];
4
+ };
5
+ declare const _default: ConfigPlugin<FontProps>;
6
+ export default _default;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const config_plugins_1 = require("expo/config-plugins");
4
+ const withFontsAndroid_1 = require("./withFontsAndroid");
5
+ const withFontsIos_1 = require("./withFontsIos");
6
+ const pkg = require('expo-font/package.json');
7
+ const withFonts = (config, props) => {
8
+ if (!props) {
9
+ return config;
10
+ }
11
+ if (props.fonts && props.fonts.length === 0) {
12
+ return config;
13
+ }
14
+ config = (0, withFontsIos_1.withFontsIos)(config, props.fonts ?? []);
15
+ config = (0, withFontsAndroid_1.withFontsAndroid)(config, props.fonts ?? []);
16
+ return config;
17
+ };
18
+ exports.default = (0, config_plugins_1.createRunOncePlugin)(withFonts, pkg.name, pkg.version);
@@ -0,0 +1,2 @@
1
+ import { ConfigPlugin } from 'expo/config-plugins';
2
+ export declare const withFontsAndroid: ConfigPlugin<string[]>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.withFontsAndroid = void 0;
7
+ const config_plugins_1 = require("expo/config-plugins");
8
+ const promises_1 = __importDefault(require("fs/promises"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const utils_1 = require("./utils");
11
+ const withFontsAndroid = (config, fonts) => {
12
+ return (0, config_plugins_1.withDangerousMod)(config, [
13
+ 'android',
14
+ async (config) => {
15
+ const resolvedFonts = await (0, utils_1.resolveFontPaths)(fonts, config.modRequest.projectRoot);
16
+ await Promise.all(resolvedFonts.map(async (asset) => {
17
+ const fontsDir = path_1.default.join(config.modRequest.platformProjectRoot, 'app/src/main/assets/fonts');
18
+ await promises_1.default.mkdir(fontsDir, { recursive: true });
19
+ const output = path_1.default.join(fontsDir, path_1.default.basename(asset));
20
+ await promises_1.default.copyFile(asset, output);
21
+ }));
22
+ return config;
23
+ },
24
+ ]);
25
+ };
26
+ exports.withFontsAndroid = withFontsAndroid;
@@ -0,0 +1,2 @@
1
+ import { ConfigPlugin } from 'expo/config-plugins';
2
+ export declare const withFontsIos: ConfigPlugin<string[]>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.withFontsIos = void 0;
7
+ const config_plugins_1 = require("expo/config-plugins");
8
+ const path_1 = __importDefault(require("path"));
9
+ const utils_1 = require("./utils");
10
+ const withFontsIos = (config, fonts) => {
11
+ config = addFontsToTarget(config, fonts);
12
+ config = addFontsToPlist(config, fonts);
13
+ return config;
14
+ };
15
+ exports.withFontsIos = withFontsIos;
16
+ function addFontsToTarget(config, fonts) {
17
+ return (0, config_plugins_1.withXcodeProject)(config, async (config) => {
18
+ const resolvedFonts = await (0, utils_1.resolveFontPaths)(fonts, config.modRequest.projectRoot);
19
+ const project = config.modResults;
20
+ const platformProjectRoot = config.modRequest.platformProjectRoot;
21
+ config_plugins_1.IOSConfig.XcodeUtils.ensureGroupRecursively(project, 'Resources');
22
+ addResourceFile(project, platformProjectRoot, resolvedFonts);
23
+ return config;
24
+ });
25
+ }
26
+ function addFontsToPlist(config, fonts) {
27
+ return (0, config_plugins_1.withInfoPlist)(config, async (config) => {
28
+ const resolvedFonts = await (0, utils_1.resolveFontPaths)(fonts, config.modRequest.projectRoot);
29
+ const existingFonts = getUIAppFonts(config.modResults);
30
+ const fontList = resolvedFonts.map((font) => path_1.default.basename(font)) ?? [];
31
+ const allFonts = [...existingFonts, ...fontList];
32
+ config.modResults.UIAppFonts = Array.from(new Set(allFonts));
33
+ return config;
34
+ });
35
+ }
36
+ function addResourceFile(project, platformRoot, f) {
37
+ for (const font of f) {
38
+ const fontPath = path_1.default.relative(platformRoot, font);
39
+ config_plugins_1.IOSConfig.XcodeUtils.addResourceFileToGroup({
40
+ filepath: fontPath,
41
+ groupName: 'Resources',
42
+ project,
43
+ isBuildFile: true,
44
+ verbose: true,
45
+ });
46
+ }
47
+ }
48
+ function getUIAppFonts(infoPlist) {
49
+ const fonts = infoPlist['UIAppFonts'];
50
+ if (fonts != null && Array.isArray(fonts) && fonts.every((font) => typeof font === 'string')) {
51
+ return fonts;
52
+ }
53
+ return [];
54
+ }
@@ -0,0 +1,16 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+
4
+ export async function resolveFontPaths(fonts: string[], projectRoot: string) {
5
+ const promises = fonts.map(async (p) => {
6
+ const resolvedPath = path.resolve(projectRoot, p);
7
+ const stat = await fs.stat(resolvedPath);
8
+
9
+ if (stat.isDirectory()) {
10
+ const dir = await fs.readdir(resolvedPath);
11
+ return dir.map((file) => path.join(resolvedPath, file));
12
+ }
13
+ return [resolvedPath];
14
+ });
15
+ return (await Promise.all(promises)).flat();
16
+ }
@@ -0,0 +1,27 @@
1
+ import { ConfigPlugin, createRunOncePlugin } from 'expo/config-plugins';
2
+
3
+ import { withFontsAndroid } from './withFontsAndroid';
4
+ import { withFontsIos } from './withFontsIos';
5
+
6
+ const pkg = require('expo-font/package.json');
7
+
8
+ export type FontProps = {
9
+ fonts?: string[];
10
+ };
11
+
12
+ const withFonts: ConfigPlugin<FontProps> = (config, props) => {
13
+ if (!props) {
14
+ return config;
15
+ }
16
+
17
+ if (props.fonts && props.fonts.length === 0) {
18
+ return config;
19
+ }
20
+
21
+ config = withFontsIos(config, props.fonts ?? []);
22
+ config = withFontsAndroid(config, props.fonts ?? []);
23
+
24
+ return config;
25
+ };
26
+
27
+ export default createRunOncePlugin(withFonts, pkg.name, pkg.version);
@@ -0,0 +1,26 @@
1
+ import { ConfigPlugin, withDangerousMod } from 'expo/config-plugins';
2
+ import fs from 'fs/promises';
3
+ import path from 'path';
4
+
5
+ import { resolveFontPaths } from './utils';
6
+
7
+ export const withFontsAndroid: ConfigPlugin<string[]> = (config, fonts) => {
8
+ return withDangerousMod(config, [
9
+ 'android',
10
+ async (config) => {
11
+ const resolvedFonts = await resolveFontPaths(fonts, config.modRequest.projectRoot);
12
+ await Promise.all(
13
+ resolvedFonts.map(async (asset) => {
14
+ const fontsDir = path.join(
15
+ config.modRequest.platformProjectRoot,
16
+ 'app/src/main/assets/fonts'
17
+ );
18
+ await fs.mkdir(fontsDir, { recursive: true });
19
+ const output = path.join(fontsDir, path.basename(asset));
20
+ await fs.copyFile(asset, output);
21
+ })
22
+ );
23
+ return config;
24
+ },
25
+ ]);
26
+ };
@@ -0,0 +1,63 @@
1
+ import { ExpoConfig } from '@expo/config-types';
2
+ import {
3
+ ConfigPlugin,
4
+ IOSConfig,
5
+ InfoPlist,
6
+ XcodeProject,
7
+ withInfoPlist,
8
+ withXcodeProject,
9
+ } from 'expo/config-plugins';
10
+ import path from 'path';
11
+
12
+ import { resolveFontPaths } from './utils';
13
+
14
+ export const withFontsIos: ConfigPlugin<string[]> = (config, fonts) => {
15
+ config = addFontsToTarget(config, fonts);
16
+ config = addFontsToPlist(config, fonts);
17
+ return config;
18
+ };
19
+
20
+ function addFontsToTarget(config: ExpoConfig, fonts: string[]) {
21
+ return withXcodeProject(config, async (config) => {
22
+ const resolvedFonts = await resolveFontPaths(fonts, config.modRequest.projectRoot);
23
+ const project = config.modResults;
24
+ const platformProjectRoot = config.modRequest.platformProjectRoot;
25
+ IOSConfig.XcodeUtils.ensureGroupRecursively(project, 'Resources');
26
+ addResourceFile(project, platformProjectRoot, resolvedFonts);
27
+ return config;
28
+ });
29
+ }
30
+
31
+ function addFontsToPlist(config: ExpoConfig, fonts: string[]) {
32
+ return withInfoPlist(config, async (config) => {
33
+ const resolvedFonts = await resolveFontPaths(fonts, config.modRequest.projectRoot);
34
+ const existingFonts = getUIAppFonts(config.modResults);
35
+
36
+ const fontList = resolvedFonts.map((font) => path.basename(font)) ?? [];
37
+ const allFonts = [...existingFonts, ...fontList];
38
+ config.modResults.UIAppFonts = Array.from(new Set(allFonts));
39
+
40
+ return config;
41
+ });
42
+ }
43
+
44
+ function addResourceFile(project: XcodeProject, platformRoot: string, f: string[]) {
45
+ for (const font of f) {
46
+ const fontPath = path.relative(platformRoot, font);
47
+ IOSConfig.XcodeUtils.addResourceFileToGroup({
48
+ filepath: fontPath,
49
+ groupName: 'Resources',
50
+ project,
51
+ isBuildFile: true,
52
+ verbose: true,
53
+ });
54
+ }
55
+ }
56
+
57
+ function getUIAppFonts(infoPlist: InfoPlist): string[] {
58
+ const fonts = infoPlist['UIAppFonts'];
59
+ if (fonts != null && Array.isArray(fonts) && fonts.every((font) => typeof font === 'string')) {
60
+ return fonts as string[];
61
+ }
62
+ return [];
63
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "expo-module-scripts/tsconfig.plugin",
3
+ "compilerOptions": {
4
+ "outDir": "build",
5
+ "rootDir": "src"
6
+ },
7
+ "include": ["./src"],
8
+ "exclude": ["**/__mocks__/*", "**/__tests__/*"]
9
+ }
package/unimodule.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "name": "expo-font",
3
- "platforms": ["ios", "android"]
4
- }