This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

2
node_modules/expo-font/.eslintrc.js generated vendored Normal file
View File

@ -0,0 +1,2 @@
// @generated by expo-module-scripts
module.exports = require('expo-module-scripts/eslintrc.base.js');

36
node_modules/expo-font/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,36 @@
# Changelog
## Unpublished
### 🛠 Breaking changes
### 🎉 New features
### 🐛 Bug fixes
## 8.4.0 — 2020-11-17
_This version does not introduce any user-facing changes._
## 8.3.0 — 2020-08-18
_This version does not introduce any user-facing changes._
## 8.2.2 — 2020-07-27
### 🐛 Bug fixes
- Fixed fonts not being loaded in Internet Explorer. ([#8652](https://github.com/expo/expo/pull/8652) by [@d4rky-pl](https://github.com/d4rky-pl))
## 8.2.1 — 2020-05-29
*This version does not introduce any user-facing changes.*
## 8.2.0 — 2020-05-27
*This version does not introduce any user-facing changes.*
## 8.1.1 - 4/07/2020
### 🐛 Bug fixes
- Fixed timeout on Firefox [#7420](https://github.com/expo/expo/pull/7420)

34
node_modules/expo-font/README.md generated vendored Normal file
View File

@ -0,0 +1,34 @@
# expo-font
Load fonts at runtime and use them in React Native components.
# API documentation
- [Documentation for the master branch](https://github.com/expo/expo/blob/master/docs/pages/versions/unversioned/sdk/font.md)
- [Documentation for the latest stable release](https://docs.expo.io/versions/latest/sdk/font/)
# Installation in managed Expo projects
For managed [managed](https://docs.expo.io/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.io/versions/latest/sdk/font/).
# Installation in bare React Native projects
For bare React Native projects, you must ensure that you have [installed and configured the `react-native-unimodules` package](https://github.com/expo/expo/tree/master/packages/react-native-unimodules) before continuing.
### Add the package to your npm dependencies
```
expo install expo-font
```
### Configure for iOS
Run `npx pod-install` after installing the npm package.
### Configure for Android
No additional set up necessary.
# Contributing
Contributions are very welcome! Please refer to guidelines described in the [contributing guide](https://github.com/expo/expo#contributing).

63
node_modules/expo-font/android/build.gradle generated vendored Normal file
View File

@ -0,0 +1,63 @@
apply plugin: 'com.android.library'
apply plugin: 'maven'
group = 'host.exp.exponent'
version = '8.4.0'
// Simple helper that allows the root project to override versions declared by this library.
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
// Upload android library to maven with javadoc and android sources
configurations {
deployerJars
}
// Creating sources with comments
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
// Put the androidSources and javadoc to the artifacts
artifacts {
archives androidSourcesJar
}
uploadArchives {
repositories {
mavenDeployer {
configuration = configurations.deployerJars
repository(url: mavenLocal().url)
}
}
}
android {
compileSdkVersion safeExtGet("compileSdkVersion", 29)
defaultConfig {
minSdkVersion safeExtGet("minSdkVersion", 21)
targetSdkVersion safeExtGet("targetSdkVersion", 29)
versionCode 28
versionName "8.4.0"
}
lintOptions {
abortOnError false
}
}
if (new File(rootProject.projectDir.parentFile, 'package.json').exists()) {
apply from: project(":unimodules-core").file("../unimodules-core.gradle")
} else {
throw new GradleException(
"'unimodules-core.gradle' was not found in the usual React Native dependency location. " +
"This package can only be used in such projects. Are you sure you've installed the dependencies properly?")
}
dependencies {
unimodule "unimodules-core"
unimodule "unimodules-font-interface"
unimodule "unimodules-constants-interface"
}

View File

@ -0,0 +1,5 @@
<manifest package="expo.modules.font">
</manifest>

View File

@ -0,0 +1,76 @@
// Copyright 2015-present 650 Industries. All rights reserved.
package expo.modules.font;
import android.content.Context;
import android.graphics.Typeface;
import android.net.Uri;
import java.io.File;
import org.unimodules.core.ExportedModule;
import org.unimodules.core.ModuleRegistry;
import org.unimodules.core.Promise;
import org.unimodules.core.interfaces.ExpoMethod;
import org.unimodules.interfaces.constants.ConstantsInterface;
import org.unimodules.interfaces.font.FontManager;
public class FontLoaderModule extends ExportedModule {
private static final String ASSET_SCHEME = "asset://";
private static final String EXPORTED_NAME = "ExpoFontLoader";
private ModuleRegistry mModuleRegistry;
public FontLoaderModule(Context context) {
super(context);
}
@Override
public String getName() {
return EXPORTED_NAME;
}
@ExpoMethod
public void loadAsync(final String fontFamilyName, final String localUri, final Promise promise) {
try {
// TODO(nikki): make sure path is in experience's scope
Typeface typeface;
// TODO: remove Expo references
// https://github.com/expo/expo/pull/4652#discussion_r296630843
String prefix = "";
if (isScoped()) {
prefix = "ExpoFont-";
}
if (localUri.startsWith(ASSET_SCHEME)) {
typeface = Typeface.createFromAsset(
getContext().getAssets(),
// Also remove the leading slash.
localUri.substring(ASSET_SCHEME.length() + 1));
} else {
typeface = Typeface.createFromFile(new File(Uri.parse(localUri).getPath()));
}
FontManager fontManager = mModuleRegistry.getModule(FontManager.class);
if (fontManager == null) {
promise.reject("E_NO_FONT_MANAGER", "There is no FontManager in module registry. Are you sure all the dependencies of expo-font are installed and linked?");
return;
}
fontManager.setTypeface(prefix + fontFamilyName, Typeface.NORMAL, typeface);
promise.resolve(null);
} catch (Exception e) {
promise.reject("E_UNEXPECTED", "Font.loadAsync unexpected exception: " + e.getMessage(), e);
}
}
@Override
public void onCreate(ModuleRegistry moduleRegistry) {
mModuleRegistry = moduleRegistry;
}
private boolean isScoped() {
ConstantsInterface constantsModule = mModuleRegistry.getModule(ConstantsInterface.class);
// If there's no constants module, or app ownership isn't "expo", we're not in Expo Client.
return constantsModule != null && "expo".equals(constantsModule.getAppOwnership());
}
}

View File

@ -0,0 +1,16 @@
package expo.modules.font;
import android.content.Context;
import java.util.Collections;
import java.util.List;
import org.unimodules.core.BasePackage;
import org.unimodules.core.ExportedModule;
public class FontLoaderPackage extends BasePackage {
@Override
public List<ExportedModule> createExportedModules(Context context) {
return Collections.<ExportedModule>singletonList(new FontLoaderModule(context));
}
}

2
node_modules/expo-font/build/ExpoFontLoader.d.ts generated vendored Normal file
View File

@ -0,0 +1,2 @@
declare const _default: import("@unimodules/core").ProxyNativeModule;
export default _default;

3
node_modules/expo-font/build/ExpoFontLoader.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
import { NativeModulesProxy } from '@unimodules/core';
export default NativeModulesProxy.ExpoFontLoader;
//# sourceMappingURL=ExpoFontLoader.js.map

1
node_modules/expo-font/build/ExpoFontLoader.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"ExpoFontLoader.js","sourceRoot":"","sources":["../src/ExpoFontLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,eAAe,kBAAkB,CAAC,cAAc,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\nexport default NativeModulesProxy.ExpoFontLoader;\n"]}

8
node_modules/expo-font/build/ExpoFontLoader.web.d.ts generated vendored Normal file
View File

@ -0,0 +1,8 @@
import { FontResource } from './Font.types';
declare const _default: {
readonly name: string;
unloadAllAsync(): Promise<void>;
unloadAsync(fontFamilyName: string, options?: Pick<FontResource, "display"> | undefined): Promise<void>;
loadAsync(fontFamilyName: string, resource: FontResource): Promise<void>;
};
export default _default;

117
node_modules/expo-font/build/ExpoFontLoader.web.js generated vendored Normal file
View File

@ -0,0 +1,117 @@
import { CodedError } from '@unimodules/core';
import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';
import FontObserver from 'fontfaceobserver';
import { FontDisplay } from './Font.types';
function getFontFaceStyleSheet() {
if (!canUseDOM) {
return null;
}
const styleSheet = getStyleElement();
return styleSheet.sheet ? styleSheet.sheet : null;
}
function getFontFaceRules() {
const sheet = getFontFaceStyleSheet();
if (sheet) {
// @ts-ignore: rule iterator
const rules = [...sheet.cssRules];
const items = [];
for (let i = 0; i < rules.length; i++) {
const rule = rules[i];
if (rule instanceof CSSFontFaceRule) {
items.push({ rule, index: i });
}
}
return items;
}
return [];
}
function getFontFaceRulesMatchingResource(fontFamilyName, options) {
const rules = getFontFaceRules();
return rules.filter(({ rule }) => {
return (rule.style.fontFamily === fontFamilyName &&
(options && options.display ? options.display === rule.style.fontDisplay : true));
});
}
export default {
get name() {
return 'ExpoFontLoader';
},
async unloadAllAsync() {
if (!canUseDOM)
return;
const element = document.getElementById(ID);
if (element && element instanceof HTMLStyleElement) {
document.removeChild(element);
}
},
async unloadAsync(fontFamilyName, options) {
const sheet = getFontFaceStyleSheet();
if (!sheet)
return;
const items = getFontFaceRulesMatchingResource(fontFamilyName, options);
for (const item of items) {
sheet.deleteRule(item.index);
}
},
async loadAsync(fontFamilyName, resource) {
if (!canUseDOM) {
return;
}
const canInjectStyle = document.head && typeof document.head.appendChild === 'function';
if (!canInjectStyle) {
throw new CodedError('ERR_WEB_ENVIRONMENT', `The browser's \`document.head\` element doesn't support injecting fonts.`);
}
const style = _createWebStyle(fontFamilyName, resource);
document.head.appendChild(style);
if (!isFontLoadingListenerSupported()) {
return;
}
return new FontObserver(fontFamilyName, { display: resource.display }).load();
},
};
const ID = 'expo-generated-fonts';
function getStyleElement() {
const element = document.getElementById(ID);
if (element && element instanceof HTMLStyleElement) {
return element;
}
const styleElement = document.createElement('style');
styleElement.id = ID;
styleElement.type = 'text/css';
return styleElement;
}
function _createWebStyle(fontFamily, resource) {
const fontStyle = `@font-face {
font-family: ${fontFamily};
src: url(${resource.uri});
font-display: ${resource.display || FontDisplay.AUTO};
}`;
const styleElement = getStyleElement();
// @ts-ignore: TypeScript does not define HTMLStyleElement::styleSheet. This is just for IE and
// possibly can be removed if it's unnecessary on IE 11.
if (styleElement.styleSheet) {
const styleElementIE = styleElement;
styleElementIE.styleSheet.cssText = styleElementIE.styleSheet.cssText
? styleElementIE.styleSheet.cssText + fontStyle
: fontStyle;
}
else {
const textNode = document.createTextNode(fontStyle);
styleElement.appendChild(textNode);
}
return styleElement;
}
function isFontLoadingListenerSupported() {
const { userAgent } = window.navigator;
// WebKit is broken https://github.com/bramstein/fontfaceobserver/issues/95
const isIOS = !!userAgent.match(/iPad|iPhone/i);
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
// Edge is broken https://github.com/bramstein/fontfaceobserver/issues/109#issuecomment-333356795
const isEdge = userAgent.includes('Edge');
// Internet Explorer
const isIE = userAgent.includes('Trident');
// Firefox
const isFirefox = userAgent.includes('Firefox');
return !isSafari && !isIOS && !isEdge && !isIE && !isFirefox;
}
//# sourceMappingURL=ExpoFontLoader.web.js.map

File diff suppressed because one or more lines are too long

49
node_modules/expo-font/build/Font.d.ts generated vendored Normal file
View File

@ -0,0 +1,49 @@
import { FontDisplay, FontSource, FontResource, UnloadFontOptions } from './Font.types';
/**
* Used to transform font family names to the scoped name. This does not need to
* be called in standalone or bare apps but it will return unscoped font family
* names if it is called in those contexts.
* note(brentvatne): at some point we may want to warn if this is called
* outside of a managed app.
*
* @param fontFamily name to process
* @returns a name processed for use with the [current workflow](https://docs.expo.io/versions/latest/introduction/managed-vs-bare/)
*/
export declare function processFontFamily(fontFamily: string | null): string | null;
/**
* Synchronously detect if the font for `fontFamily` has finished loading
*
* @param fontFamily the name used to load the `FontResource`.
* @returns `true` if the the font has fully loaded.
*/
export declare function isLoaded(fontFamily: string): boolean;
/**
* Synchronously detect if the font for `fontFamily` is still being loaded
*
* @param fontFamily the name used to load the `FontResource`.
* @returns `true` if the the font is still loading.
*/
export declare function isLoading(fontFamily: string): boolean;
/**
* Natively load a font for use with Text elements.
* @param fontFamilyOrFontMap string or map of values that can be used as the [`fontFamily`](https://reactnative.dev/docs/text#style) style prop with React Native Text elements.
* @param source the font asset that should be loaded into the `fontFamily` namespace.
*/
export declare function loadAsync(fontFamilyOrFontMap: string | {
[fontFamily: string]: FontSource;
}, source?: FontSource): Promise<void>;
/**
* Unloads all of the custom fonts. This is used for testing.
*/
export declare function unloadAllAsync(): Promise<void>;
/**
* Unload custom fonts matching the `fontFamily`s and display values provided.
* Because fonts are automatically unloaded on every platform this is mostly used for testing.
*
* @param fontFamilyOrFontMap the names of the custom fonts that will be unloaded.
* @param source when `fontFamilyOrFontMap` is a string, this should be the font source used to load the custom font originally.
*/
export declare function unloadAsync(fontFamilyOrFontMap: string | {
[fontFamily: string]: UnloadFontOptions;
}, options?: UnloadFontOptions): Promise<void>;
export { FontDisplay, FontSource, FontResource, UnloadFontOptions };

154
node_modules/expo-font/build/Font.js generated vendored Normal file
View File

@ -0,0 +1,154 @@
import { CodedError, UnavailabilityError } from '@unimodules/core';
import ExpoFontLoader from './ExpoFontLoader';
import { FontDisplay } from './Font.types';
import { getAssetForSource, loadSingleFontAsync, fontFamilyNeedsScoping, getNativeFontName, } from './FontLoader';
const loaded = {};
const loadPromises = {};
/**
* Used to transform font family names to the scoped name. This does not need to
* be called in standalone or bare apps but it will return unscoped font family
* names if it is called in those contexts.
* note(brentvatne): at some point we may want to warn if this is called
* outside of a managed app.
*
* @param fontFamily name to process
* @returns a name processed for use with the [current workflow](https://docs.expo.io/versions/latest/introduction/managed-vs-bare/)
*/
export function processFontFamily(fontFamily) {
if (!fontFamily || !fontFamilyNeedsScoping(fontFamily)) {
return fontFamily;
}
if (!isLoaded(fontFamily)) {
if (__DEV__) {
if (isLoading(fontFamily)) {
console.error(`You started loading the font "${fontFamily}", but used it before it finished loading.\n
- You need to wait for Font.loadAsync to complete before using the font.\n
- We recommend loading all fonts before rendering the app, and rendering only Expo.AppLoading while waiting for loading to complete.`);
}
else {
console.error(`fontFamily "${fontFamily}" is not a system font and has not been loaded through Font.loadAsync.\n
- If you intended to use a system font, make sure you typed the name correctly and that it is supported by your device operating system.\n
- If this is a custom font, be sure to load it with Font.loadAsync.`);
}
}
return 'System';
}
return `ExpoFont-${getNativeFontName(fontFamily)}`;
}
/**
* Synchronously detect if the font for `fontFamily` has finished loading
*
* @param fontFamily the name used to load the `FontResource`.
* @returns `true` if the the font has fully loaded.
*/
export function isLoaded(fontFamily) {
return fontFamily in loaded;
}
/**
* Synchronously detect if the font for `fontFamily` is still being loaded
*
* @param fontFamily the name used to load the `FontResource`.
* @returns `true` if the the font is still loading.
*/
export function isLoading(fontFamily) {
return fontFamily in loadPromises;
}
/**
* Natively load a font for use with Text elements.
* @param fontFamilyOrFontMap string or map of values that can be used as the [`fontFamily`](https://reactnative.dev/docs/text#style) style prop with React Native Text elements.
* @param source the font asset that should be loaded into the `fontFamily` namespace.
*/
export async function loadAsync(fontFamilyOrFontMap, source) {
if (typeof fontFamilyOrFontMap === 'object') {
if (source) {
throw new CodedError(`ERR_FONT_API`, `No fontFamily can be used for the provided source: ${source}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`);
}
const fontMap = fontFamilyOrFontMap;
const names = Object.keys(fontMap);
await Promise.all(names.map(name => loadFontInNamespaceAsync(name, fontMap[name])));
return;
}
return await loadFontInNamespaceAsync(fontFamilyOrFontMap, source);
}
async function loadFontInNamespaceAsync(fontFamily, source) {
if (!source) {
throw new CodedError(`ERR_FONT_SOURCE`, `Cannot load null or undefined font source: { "${fontFamily}": ${source} }. Expected asset of type \`FontSource\` for fontFamily of name: "${fontFamily}"`);
}
if (loaded[fontFamily]) {
return;
}
if (loadPromises[fontFamily]) {
return loadPromises[fontFamily];
}
// Important: we want all callers that concurrently try to load the same font to await the same
// promise. If we're here, we haven't created the promise yet. To ensure we create only one
// promise in the program, we need to create the promise synchronously without yielding the event
// loop from this point.
const asset = getAssetForSource(source);
loadPromises[fontFamily] = (async () => {
try {
await loadSingleFontAsync(fontFamily, asset);
loaded[fontFamily] = true;
}
finally {
delete loadPromises[fontFamily];
}
})();
await loadPromises[fontFamily];
}
/**
* Unloads all of the custom fonts. This is used for testing.
*/
export async function unloadAllAsync() {
if (!ExpoFontLoader.unloadAllAsync) {
throw new UnavailabilityError('expo-font', 'unloadAllAsync');
}
if (Object.keys(loadPromises).length) {
throw new CodedError(`ERR_UNLOAD`, `Cannot unload fonts while they're still loading: ${Object.keys(loadPromises).join(', ')}`);
}
for (const fontFamily of Object.keys(loaded)) {
delete loaded[fontFamily];
}
await ExpoFontLoader.unloadAllAsync();
}
/**
* Unload custom fonts matching the `fontFamily`s and display values provided.
* Because fonts are automatically unloaded on every platform this is mostly used for testing.
*
* @param fontFamilyOrFontMap the names of the custom fonts that will be unloaded.
* @param source when `fontFamilyOrFontMap` is a string, this should be the font source used to load the custom font originally.
*/
export async function unloadAsync(fontFamilyOrFontMap, options) {
if (!ExpoFontLoader.unloadAsync) {
throw new UnavailabilityError('expo-font', 'unloadAsync');
}
if (typeof fontFamilyOrFontMap === 'object') {
if (options) {
throw new CodedError(`ERR_FONT_API`, `No fontFamily can be used for the provided options: ${options}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);
}
const fontMap = fontFamilyOrFontMap;
const names = Object.keys(fontMap);
await Promise.all(names.map(name => unloadFontInNamespaceAsync(name, fontMap[name])));
return;
}
return await unloadFontInNamespaceAsync(fontFamilyOrFontMap, options);
}
async function unloadFontInNamespaceAsync(fontFamily, options) {
if (!loaded[fontFamily]) {
return;
}
else {
delete loaded[fontFamily];
}
// Important: we want all callers that concurrently try to load the same font to await the same
// promise. If we're here, we haven't created the promise yet. To ensure we create only one
// promise in the program, we need to create the promise synchronously without yielding the event
// loop from this point.
const nativeFontName = getNativeFontName(fontFamily);
if (!nativeFontName) {
throw new CodedError(`ERR_FONT_FAMILY`, `Cannot unload an empty name`);
}
await ExpoFontLoader.unloadAsync(nativeFontName, options);
}
export { FontDisplay };
//# sourceMappingURL=Font.js.map

1
node_modules/expo-font/build/Font.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

56
node_modules/expo-font/build/Font.types.d.ts generated vendored Normal file
View File

@ -0,0 +1,56 @@
import { Asset } from 'expo-asset';
/**
* The different types of assets you can provide to the [`loadAsync()`](#loadAsync) function.
* A font source can be a URI, a module ID, or an Expo Asset.
*/
export declare type FontSource = string | number | Asset | FontResource;
/**
* Used to dictate the resource that is loaded into the provided font namespace when used with [`loadAsync`](#loadasync).
* Optionally on web you can define a `display` value which sets the [`font-display`](#FontDisplay) property for a given typeface in the browser.
*/
export declare type FontResource = {
uri: string | number;
display?: FontDisplay;
};
/**
* Sets the [font-display](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display) for a given typeface.
* This currently **only works on web**. The default font value on web is `FontDisplay.AUTO`.
* Even though setting the `fontDisplay` does nothing on native platforms, the default behavior emulates `FontDisplay.SWAP`
* on flagship devices like iOS, Samsung, Pixel, etc. Default functionality varies on One Plus devices.
* In the browser this value is set in the generated `@font-face` CSS block and not as a style property meaning you cannot dynamically
* change this value based on the element it's used in.
*/
export declare enum FontDisplay {
/**
* (Default on web) The font display strategy is defined by the user agent or platform.
* This generally defaults to the text being invisible until the font is loaded.
* Good for buttons or banners that require a specific treatment.
*/
AUTO = "auto",
/**
* Fallback text is rendered immediately with a default font while the desired font is loaded.
* This is good for making the content appear to load instantly and is usally preferred.
*/
SWAP = "swap",
/**
* The text will be invisible until the font has loaded.
* If the font fails to load, nothing will appear.
*/
BLOCK = "block",
/**
* Splits the behavior between `SWAP` and `BLOCK`.
* There will be a [100ms timeout](https://developers.google.com/web/updates/2016/02/font-display?hl=en) where the text with a custom font is invisible,
* after that the text will either swap to the styled text or it'll show the unstyled text and continue to load the custom font.
* This is good for buttons that need a custom font but should also be quickly available to screen-readers.
*/
FALLBACK = "fallback",
/**
* This works almost identically to `FALLBACK`,
* the only difference is that the browser will decide to load the font based on slow connection speed or critical resource demand.
*/
OPTIONAL = "optional"
}
/**
* Used to query fonts for unloading
*/
export declare type UnloadFontOptions = Pick<FontResource, 'display'>;

40
node_modules/expo-font/build/Font.types.js generated vendored Normal file
View File

@ -0,0 +1,40 @@
/**
* Sets the [font-display](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display) for a given typeface.
* This currently **only works on web**. The default font value on web is `FontDisplay.AUTO`.
* Even though setting the `fontDisplay` does nothing on native platforms, the default behavior emulates `FontDisplay.SWAP`
* on flagship devices like iOS, Samsung, Pixel, etc. Default functionality varies on One Plus devices.
* In the browser this value is set in the generated `@font-face` CSS block and not as a style property meaning you cannot dynamically
* change this value based on the element it's used in.
*/
export var FontDisplay;
(function (FontDisplay) {
/**
* (Default on web) The font display strategy is defined by the user agent or platform.
* This generally defaults to the text being invisible until the font is loaded.
* Good for buttons or banners that require a specific treatment.
*/
FontDisplay["AUTO"] = "auto";
/**
* Fallback text is rendered immediately with a default font while the desired font is loaded.
* This is good for making the content appear to load instantly and is usally preferred.
*/
FontDisplay["SWAP"] = "swap";
/**
* The text will be invisible until the font has loaded.
* If the font fails to load, nothing will appear.
*/
FontDisplay["BLOCK"] = "block";
/**
* Splits the behavior between `SWAP` and `BLOCK`.
* There will be a [100ms timeout](https://developers.google.com/web/updates/2016/02/font-display?hl=en) where the text with a custom font is invisible,
* after that the text will either swap to the styled text or it'll show the unstyled text and continue to load the custom font.
* This is good for buttons that need a custom font but should also be quickly available to screen-readers.
*/
FontDisplay["FALLBACK"] = "fallback";
/**
* This works almost identically to `FALLBACK`,
* the only difference is that the browser will decide to load the font based on slow connection speed or critical resource demand.
*/
FontDisplay["OPTIONAL"] = "optional";
})(FontDisplay || (FontDisplay = {}));
//# sourceMappingURL=Font.types.js.map

1
node_modules/expo-font/build/Font.types.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"Font.types.js","sourceRoot":"","sources":["../src/Font.types.ts"],"names":[],"mappings":"AAiBA;;;;;;;GAOG;AACH,MAAM,CAAN,IAAY,WA6BX;AA7BD,WAAY,WAAW;IACrB;;;;OAIG;IACH,4BAAa,CAAA;IACb;;;OAGG;IACH,4BAAa,CAAA;IACb;;;OAGG;IACH,8BAAe,CAAA;IACf;;;;;OAKG;IACH,oCAAqB,CAAA;IACrB;;;OAGG;IACH,oCAAqB,CAAA;AACvB,CAAC,EA7BW,WAAW,KAAX,WAAW,QA6BtB","sourcesContent":["import { Asset } from 'expo-asset';\n\n/**\n * The different types of assets you can provide to the [`loadAsync()`](#loadAsync) function.\n * A font source can be a URI, a module ID, or an Expo Asset.\n */\nexport type FontSource = string | number | Asset | FontResource;\n\n/**\n * Used to dictate the resource that is loaded into the provided font namespace when used with [`loadAsync`](#loadasync).\n * Optionally on web you can define a `display` value which sets the [`font-display`](#FontDisplay) property for a given typeface in the browser.\n */\nexport type FontResource = {\n uri: string | number;\n display?: FontDisplay;\n};\n\n/**\n * Sets the [font-display](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display) for a given typeface.\n * This currently **only works on web**. The default font value on web is `FontDisplay.AUTO`.\n * Even though setting the `fontDisplay` does nothing on native platforms, the default behavior emulates `FontDisplay.SWAP`\n * on flagship devices like iOS, Samsung, Pixel, etc. Default functionality varies on One Plus devices.\n * In the browser this value is set in the generated `@font-face` CSS block and not as a style property meaning you cannot dynamically\n * change this value based on the element it's used in.\n */\nexport enum FontDisplay {\n /**\n * (Default on web) The font display strategy is defined by the user agent or platform.\n * This generally defaults to the text being invisible until the font is loaded.\n * Good for buttons or banners that require a specific treatment.\n */\n AUTO = 'auto',\n /**\n * Fallback text is rendered immediately with a default font while the desired font is loaded.\n * This is good for making the content appear to load instantly and is usally preferred.\n */\n SWAP = 'swap',\n /**\n * The text will be invisible until the font has loaded.\n * If the font fails to load, nothing will appear.\n */\n BLOCK = 'block',\n /**\n * Splits the behavior between `SWAP` and `BLOCK`.\n * There will be a [100ms timeout](https://developers.google.com/web/updates/2016/02/font-display?hl=en) where the text with a custom font is invisible,\n * after that the text will either swap to the styled text or it'll show the unstyled text and continue to load the custom font.\n * This is good for buttons that need a custom font but should also be quickly available to screen-readers.\n */\n FALLBACK = 'fallback',\n /**\n * This works almost identically to `FALLBACK`,\n * the only difference is that the browser will decide to load the font based on slow connection speed or critical resource demand.\n */\n OPTIONAL = 'optional',\n}\n\n/**\n * Used to query fonts for unloading\n */\nexport type UnloadFontOptions = Pick<FontResource, 'display'>;\n"]}

14
node_modules/expo-font/build/FontHooks.d.ts generated vendored Normal file
View File

@ -0,0 +1,14 @@
import { FontSource } from './Font.types';
/**
* Load a map of custom fonts to use in textual elements.
* The map keys are used as font names, and can be used with `fontFamily: <name>;`.
* It returns a boolean describing if all fonts are loaded.
*
* Note, the fonts are not "reloaded" when you dynamically change the font map.
*
* @see https://docs.expo.io/versions/latest/sdk/font/
* @example const [loaded, error] = useFonts(...);
*/
export declare function useFonts(map: string | {
[fontFamily: string]: FontSource;
}): [boolean, Error | null];

23
node_modules/expo-font/build/FontHooks.js generated vendored Normal file
View File

@ -0,0 +1,23 @@
import { useEffect, useState } from 'react';
import { loadAsync } from './Font';
/**
* Load a map of custom fonts to use in textual elements.
* The map keys are used as font names, and can be used with `fontFamily: <name>;`.
* It returns a boolean describing if all fonts are loaded.
*
* Note, the fonts are not "reloaded" when you dynamically change the font map.
*
* @see https://docs.expo.io/versions/latest/sdk/font/
* @example const [loaded, error] = useFonts(...);
*/
export function useFonts(map) {
const [loaded, setLoaded] = useState(false);
const [error, setError] = useState(null);
useEffect(() => {
loadAsync(map)
.then(() => setLoaded(true))
.catch(setError);
}, []);
return [loaded, error];
}
//# sourceMappingURL=FontHooks.js.map

1
node_modules/expo-font/build/FontHooks.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"FontHooks.js","sourceRoot":"","sources":["../src/FontHooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGnC;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CACtB,GAAkD;IAElD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IAEvD,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,CAAC,GAAG,CAAC;aACX,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;aAC3B,KAAK,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACzB,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { loadAsync } from './Font';\nimport { FontSource } from './Font.types';\n\n/**\n * Load a map of custom fonts to use in textual elements.\n * The map keys are used as font names, and can be used with `fontFamily: <name>;`.\n * It returns a boolean describing if all fonts are loaded.\n *\n * Note, the fonts are not \"reloaded\" when you dynamically change the font map.\n *\n * @see https://docs.expo.io/versions/latest/sdk/font/\n * @example const [loaded, error] = useFonts(...);\n */\nexport function useFonts(\n map: string | { [fontFamily: string]: FontSource }\n): [boolean, Error | null] {\n const [loaded, setLoaded] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n loadAsync(map)\n .then(() => setLoaded(true))\n .catch(setError);\n }, []);\n\n return [loaded, error];\n}\n"]}

6
node_modules/expo-font/build/FontLoader.d.ts generated vendored Normal file
View File

@ -0,0 +1,6 @@
import { Asset } from 'expo-asset';
import { FontResource, FontSource } from './Font.types';
export declare function fontFamilyNeedsScoping(name: string): boolean;
export declare function getAssetForSource(source: FontSource): Asset | FontResource;
export declare function loadSingleFontAsync(name: string, input: Asset | FontResource): Promise<void>;
export declare function getNativeFontName(name: string): string;

51
node_modules/expo-font/build/FontLoader.js generated vendored Normal file
View File

@ -0,0 +1,51 @@
import { CodedError } from '@unimodules/core';
import { Asset } from 'expo-asset';
import Constants from 'expo-constants';
import { Platform } from 'react-native';
import ExpoFontLoader from './ExpoFontLoader';
const isInClient = Constants.appOwnership === 'expo';
const isInIOSStandalone = Constants.appOwnership === 'standalone' && Platform.OS === 'ios';
export function fontFamilyNeedsScoping(name) {
return ((isInClient || isInIOSStandalone) &&
!Constants.systemFonts.includes(name) &&
name !== 'System' &&
!name.includes(Constants.sessionId));
}
export function getAssetForSource(source) {
if (source instanceof Asset) {
return source;
}
if (typeof source === 'string') {
return Asset.fromURI(source);
}
else if (typeof source === 'number') {
return Asset.fromModule(source);
}
else if (typeof source === 'object' && typeof source.uri !== 'undefined') {
return getAssetForSource(source.uri);
}
// @ts-ignore Error: Type 'string' is not assignable to type 'Asset'
// We can't have a string here, we would have thrown an error if !isWeb
// or returned Asset.fromModule if isWeb.
return source;
}
export async function loadSingleFontAsync(name, input) {
const asset = input;
if (!asset.downloadAsync) {
throw new CodedError(`ERR_FONT_SOURCE`, '`loadSingleFontAsync` expected resource of type `Asset` from expo-asset on native');
}
await asset.downloadAsync();
if (!asset.downloaded) {
throw new CodedError(`ERR_DOWNLOAD`, `Failed to download asset for font "${name}"`);
}
await ExpoFontLoader.loadAsync(getNativeFontName(name), asset.localUri);
}
export function getNativeFontName(name) {
if (fontFamilyNeedsScoping(name)) {
return `${Constants.sessionId}-${name}`;
}
else {
return name;
}
}
//# sourceMappingURL=FontLoader.js.map

1
node_modules/expo-font/build/FontLoader.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"FontLoader.js","sourceRoot":"","sources":["../src/FontLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAG9C,MAAM,UAAU,GAAG,SAAS,CAAC,YAAY,KAAK,MAAM,CAAC;AACrD,MAAM,iBAAiB,GAAG,SAAS,CAAC,YAAY,KAAK,YAAY,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AAE3F,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,OAAO,CACL,CAAC,UAAU,IAAI,iBAAiB,CAAC;QACjC,CAAC,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC;QACrC,IAAI,KAAK,QAAQ;QACjB,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CACpC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAkB;IAClD,IAAI,MAAM,YAAY,KAAK,EAAE;QAC3B,OAAO,MAAM,CAAC;KACf;IAED,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;KAC9B;SAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QACrC,OAAO,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;KACjC;SAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,WAAW,EAAE;QAC1E,OAAO,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;KACtC;IAED,oEAAoE;IACpE,uEAAuE;IACvE,yCAAyC;IACzC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,IAAY,EACZ,KAA2B;IAE3B,MAAM,KAAK,GAAG,KAAc,CAAC;IAC7B,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE;QACxB,MAAM,IAAI,UAAU,CAClB,iBAAiB,EACjB,mFAAmF,CACpF,CAAC;KACH;IAED,MAAM,KAAK,CAAC,aAAa,EAAE,CAAC;IAC5B,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;QACrB,MAAM,IAAI,UAAU,CAAC,cAAc,EAAE,sCAAsC,IAAI,GAAG,CAAC,CAAC;KACrF;IACD,MAAM,cAAc,CAAC,SAAS,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,IAAI,sBAAsB,CAAC,IAAI,CAAC,EAAE;QAChC,OAAO,GAAG,SAAS,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;KACzC;SAAM;QACL,OAAO,IAAI,CAAC;KACb;AACH,CAAC","sourcesContent":["import { CodedError } from '@unimodules/core';\nimport { Asset } from 'expo-asset';\nimport Constants from 'expo-constants';\nimport { Platform } from 'react-native';\n\nimport ExpoFontLoader from './ExpoFontLoader';\nimport { FontResource, FontSource } from './Font.types';\n\nconst isInClient = Constants.appOwnership === 'expo';\nconst isInIOSStandalone = Constants.appOwnership === 'standalone' && Platform.OS === 'ios';\n\nexport function fontFamilyNeedsScoping(name: string): boolean {\n return (\n (isInClient || isInIOSStandalone) &&\n !Constants.systemFonts.includes(name) &&\n name !== 'System' &&\n !name.includes(Constants.sessionId)\n );\n}\n\nexport function getAssetForSource(source: FontSource): Asset | FontResource {\n if (source instanceof Asset) {\n return source;\n }\n\n if (typeof source === 'string') {\n return Asset.fromURI(source);\n } else if (typeof source === 'number') {\n return Asset.fromModule(source);\n } else if (typeof source === 'object' && typeof source.uri !== 'undefined') {\n return getAssetForSource(source.uri);\n }\n\n // @ts-ignore Error: Type 'string' is not assignable to type 'Asset'\n // We can't have a string here, we would have thrown an error if !isWeb\n // or returned Asset.fromModule if isWeb.\n return source;\n}\n\nexport async function loadSingleFontAsync(\n name: string,\n input: Asset | FontResource\n): Promise<void> {\n const asset = input as Asset;\n if (!asset.downloadAsync) {\n throw new CodedError(\n `ERR_FONT_SOURCE`,\n '`loadSingleFontAsync` expected resource of type `Asset` from expo-asset on native'\n );\n }\n\n await asset.downloadAsync();\n if (!asset.downloaded) {\n throw new CodedError(`ERR_DOWNLOAD`, `Failed to download asset for font \"${name}\"`);\n }\n await ExpoFontLoader.loadAsync(getNativeFontName(name), asset.localUri);\n}\n\nexport function getNativeFontName(name: string): string {\n if (fontFamilyNeedsScoping(name)) {\n return `${Constants.sessionId}-${name}`;\n } else {\n return name;\n }\n}\n"]}

6
node_modules/expo-font/build/FontLoader.web.d.ts generated vendored Normal file
View File

@ -0,0 +1,6 @@
import { Asset } from 'expo-asset';
import { FontResource, FontSource } from './Font.types';
export declare function fontFamilyNeedsScoping(name: string): boolean;
export declare function getAssetForSource(source: FontSource): Asset | FontResource;
export declare function loadSingleFontAsync(name: string, input: Asset | FontResource): Promise<void>;
export declare function getNativeFontName(name: string): string;

45
node_modules/expo-font/build/FontLoader.web.js generated vendored Normal file
View File

@ -0,0 +1,45 @@
import { CodedError } from '@unimodules/core';
import ExpoFontLoader from './ExpoFontLoader';
import { FontDisplay } from './Font';
function uriFromFontSource(asset) {
if (typeof asset === 'string') {
return asset || null;
}
else if (typeof asset === 'object') {
return asset.uri || asset.localUri || null;
}
return null;
}
function displayFromFontSource(asset) {
return asset.display || FontDisplay.AUTO;
}
export function fontFamilyNeedsScoping(name) {
return false;
}
export function getAssetForSource(source) {
const uri = uriFromFontSource(source);
const display = displayFromFontSource(source);
if (!uri || typeof uri !== 'string') {
throwInvalidSourceError(uri);
}
return {
uri: uri,
display,
};
}
function throwInvalidSourceError(source) {
let type = typeof source;
if (type === 'object')
type = JSON.stringify(source, null, 2);
throw new CodedError(`ERR_FONT_SOURCE`, `Expected font asset of type \`string | FontResource | Asset\` (number is not supported on web) instead got: ${type}`);
}
export async function loadSingleFontAsync(name, input) {
if (typeof input !== 'object' || typeof input.uri !== 'string' || input.downloadAsync) {
throwInvalidSourceError(input);
}
await ExpoFontLoader.loadAsync(name, input);
}
export function getNativeFontName(name) {
return name;
}
//# sourceMappingURL=FontLoader.web.js.map

1
node_modules/expo-font/build/FontLoader.web.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"FontLoader.web.js","sourceRoot":"","sources":["../src/FontLoader.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGrC,SAAS,iBAAiB,CAAC,KAAU;IACnC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,KAAK,IAAI,IAAI,CAAC;KACtB;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACpC,OAAO,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC;KAC5C;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAU;IACvC,OAAO,KAAK,CAAC,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAkB;IAClD,MAAM,GAAG,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAE9C,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QACnC,uBAAuB,CAAC,GAAG,CAAC,CAAC;KAC9B;IAED,OAAO;QACL,GAAG,EAAE,GAAI;QACT,OAAO;KACR,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,MAAW;IAC1C,IAAI,IAAI,GAAW,OAAO,MAAM,CAAC;IACjC,IAAI,IAAI,KAAK,QAAQ;QAAE,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9D,MAAM,IAAI,UAAU,CAClB,iBAAiB,EACjB,+GAA+G,IAAI,EAAE,CACtH,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,IAAY,EACZ,KAA2B;IAE3B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,IAAK,KAAa,CAAC,aAAa,EAAE;QAC9F,uBAAuB,CAAC,KAAK,CAAC,CAAC;KAChC;IAED,MAAM,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { CodedError } from '@unimodules/core';\nimport { Asset } from 'expo-asset';\n\nimport ExpoFontLoader from './ExpoFontLoader';\nimport { FontDisplay } from './Font';\nimport { FontResource, FontSource } from './Font.types';\n\nfunction uriFromFontSource(asset: any): string | null {\n if (typeof asset === 'string') {\n return asset || null;\n } else if (typeof asset === 'object') {\n return asset.uri || asset.localUri || null;\n }\n return null;\n}\n\nfunction displayFromFontSource(asset: any): FontDisplay | undefined {\n return asset.display || FontDisplay.AUTO;\n}\n\nexport function fontFamilyNeedsScoping(name: string): boolean {\n return false;\n}\n\nexport function getAssetForSource(source: FontSource): Asset | FontResource {\n const uri = uriFromFontSource(source);\n const display = displayFromFontSource(source);\n\n if (!uri || typeof uri !== 'string') {\n throwInvalidSourceError(uri);\n }\n\n return {\n uri: uri!,\n display,\n };\n}\n\nfunction throwInvalidSourceError(source: any): never {\n let type: string = typeof source;\n if (type === 'object') type = JSON.stringify(source, null, 2);\n throw new CodedError(\n `ERR_FONT_SOURCE`,\n `Expected font asset of type \\`string | FontResource | Asset\\` (number is not supported on web) instead got: ${type}`\n );\n}\n\nexport async function loadSingleFontAsync(\n name: string,\n input: Asset | FontResource\n): Promise<void> {\n if (typeof input !== 'object' || typeof input.uri !== 'string' || (input as any).downloadAsync) {\n throwInvalidSourceError(input);\n }\n\n await ExpoFontLoader.loadAsync(name, input);\n}\n\nexport function getNativeFontName(name: string): string {\n return name;\n}\n"]}

2
node_modules/expo-font/build/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,2 @@
export * from './Font';
export { useFonts } from './FontHooks';

3
node_modules/expo-font/build/index.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
export * from './Font';
export { useFonts } from './FontHooks';
//# sourceMappingURL=index.js.map

1
node_modules/expo-font/build/index.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export * from './Font';\nexport { useFonts } from './FontHooks';\n"]}

24
node_modules/expo-font/ios/EXFont.podspec generated vendored Normal file
View File

@ -0,0 +1,24 @@
require 'json'
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
Pod::Spec.new do |s|
s.name = 'EXFont'
s.version = package['version']
s.summary = package['description']
s.description = package['description']
s.license = package['license']
s.author = package['author']
s.homepage = package['homepage']
s.platform = :ios, '10.0'
s.source = { git: 'https://github.com/expo/expo.git' }
s.source_files = 'EXFont/**/*.{h,m}'
s.preserve_paths = 'EXFont/**/*.{h,m}'
s.requires_arc = true
s.dependency 'UMCore'
s.dependency 'UMFontInterface'
end

12
node_modules/expo-font/ios/EXFont/EXFont.h generated vendored Normal file
View File

@ -0,0 +1,12 @@
// Copyright 2015-present 650 Industries. All rights reserved.
#import <Foundation/Foundation.h>
static const char *EXFontAssocKey = "EXFont";
@interface EXFont : NSObject
- (instancetype)initWithCGFont:(CGFontRef)cgFont;
- (UIFont *)UIFontWithSize:(CGFloat)fsize;
@end

43
node_modules/expo-font/ios/EXFont/EXFont.m generated vendored Normal file
View File

@ -0,0 +1,43 @@
// Copyright 2015-present 650 Industries. All rights reserved.
#import <EXFont/EXFont.h>
#import <objc/runtime.h>
#import <CoreText/CoreText.h>
@interface EXFont ()
@property (nonatomic, assign) CGFontRef cgFont;
@property (nonatomic, strong) NSMutableDictionary *sizes;
@end
@implementation EXFont
- (instancetype)initWithCGFont:(CGFontRef)cgFont
{
if (self = [super init]) {
_cgFont = cgFont;
_sizes = [NSMutableDictionary dictionary];
}
return self;
}
- (UIFont *)UIFontWithSize:(CGFloat)fsize
{
NSNumber *size = @(fsize);
UIFont *uiFont = _sizes[size];
if (uiFont) {
return uiFont;
}
uiFont = (__bridge_transfer UIFont *)CTFontCreateWithGraphicsFont(_cgFont, fsize, NULL, NULL);
_sizes[size] = uiFont;
objc_setAssociatedObject(uiFont, EXFontAssocKey, self, OBJC_ASSOCIATION_ASSIGN);
return uiFont;
}
- (void)dealloc
{
CGFontRelease(_cgFont);
}
@end

10
node_modules/expo-font/ios/EXFont/EXFontLoader.h generated vendored Normal file
View File

@ -0,0 +1,10 @@
// Copyright 2015-present 650 Industries. All rights reserved.
#import <UMCore/UMExportedModule.h>
#import <UMCore/UMModuleRegistryConsumer.h>
@interface EXFontLoader : UMExportedModule <UMModuleRegistryConsumer>
- (instancetype)initWithFontFamilyPrefix:(NSString *)prefix;
@end

93
node_modules/expo-font/ios/EXFont/EXFontLoader.m generated vendored Normal file
View File

@ -0,0 +1,93 @@
// Copyright 2015-present 650 Industries. All rights reserved.
#import <EXFont/EXFontLoader.h>
#import <EXFont/EXFontLoaderProcessor.h>
#import <UMFontInterface/UMFontManagerInterface.h>
#import <EXFont/EXFontScaler.h>
#import <EXFont/EXFont.h>
#import <objc/runtime.h>
#import <EXFont/EXFontManager.h>
#import <EXFont/EXFontScalersManager.h>
@interface EXFontLoader ()
@property (nonatomic, strong) EXFontScaler *scaler;
@property (nonatomic, strong) EXFontLoaderProcessor *processor;
@property (nonatomic, strong) EXFontManager *manager;
@end
@implementation EXFontLoader
UM_EXPORT_MODULE(ExpoFontLoader);
- (instancetype)init
{
if (self = [super init]) {
_scaler = [[EXFontScaler alloc] init];
_manager = [[EXFontManager alloc] init];
_processor = [[EXFontLoaderProcessor alloc] initWithManager:_manager];
}
return self;
}
- (instancetype)initWithFontFamilyPrefix:(NSString *)prefix
{
if (self = [super init]) {
_scaler = [[EXFontScaler alloc] init];
_manager = [[EXFontManager alloc] init];
_processor = [[EXFontLoaderProcessor alloc] initWithFontFamilyPrefix:prefix manager:_manager];
}
return self;
}
- (void)setModuleRegistry:(UMModuleRegistry *)moduleRegistry
{
if (moduleRegistry) {
id<UMFontManagerInterface> manager = [moduleRegistry getModuleImplementingProtocol:@protocol(UMFontManagerInterface)];
[manager addFontProcessor:_processor];
id<UMFontScalersManagerInterface> scalersManager = [moduleRegistry getSingletonModuleForName:@"FontScalersManager"];
[scalersManager registerFontScaler:_scaler];
}
}
UM_EXPORT_METHOD_AS(loadAsync,
loadAsyncWithFontFamilyName:(NSString *)fontFamilyName
withLocalUri:(NSString *)path
resolver:(UMPromiseResolveBlock)resolve
rejecter:(UMPromiseRejectBlock)reject)
{
if ([_manager fontForName:fontFamilyName]) {
reject(@"E_FONT_ALREADY_EXISTS",
[NSString stringWithFormat:@"Font with family name '%@' already loaded", fontFamilyName],
nil);
return;
}
// TODO(nikki): make sure path is in experience's scope
NSURL *uriString = [[NSURL alloc] initWithString:path];
NSData *data = [[NSFileManager defaultManager] contentsAtPath:[uriString path]];
if (!data) {
reject(@"E_FONT_FILE_NOT_FOUND",
[NSString stringWithFormat:@"File '%@' for font '%@' doesn't exist", path, fontFamilyName],
nil);
return;
}
CGDataProviderRef provider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data);
CGFontRef font = CGFontCreateWithDataProvider(provider);
CGDataProviderRelease(provider);
if (!font) {
reject(@"E_FONT_CREATION_FAILED",
[NSString stringWithFormat:@"Could not create font from loaded data for '%@'", fontFamilyName],
nil);
return;
}
[_manager setFont:[[EXFont alloc] initWithCGFont:font] forName:fontFamilyName];
resolve(nil);
}
@end

View File

@ -0,0 +1,14 @@
// Copyright 2015-present 650 Industries. All rights reserved.
#import <Foundation/Foundation.h>
#import <UMFontInterface/UMFontProcessorInterface.h>
#import <EXFont/EXFontManager.h>
@interface EXFontLoaderProcessor : NSObject <UMFontProcessorInterface>
- (instancetype)initWithFontFamilyPrefix:(NSString *)prefix
manager:(EXFontManager *)manager;
- (instancetype)initWithManager:(EXFontManager *)manager;
@end

View File

@ -0,0 +1,69 @@
// Copyright 2015-present 650 Industries. All rights reserved.
#import <EXFont/EXFontLoaderProcessor.h>
#import <EXFont/EXFontLoader.h>
#import <EXFont/EXFont.h>
#import <EXFont/EXFontManager.h>
#import <objc/runtime.h>
@interface EXFontLoaderProcessor ()
@property (nonatomic, copy) NSString *fontFamilyPrefix;
@property (nonatomic, strong) EXFontManager *manager;
@end
@implementation EXFontLoaderProcessor
- (instancetype)initWithFontFamilyPrefix:(NSString *)prefix
manager:(EXFontManager *)manager
{
if (self = [super init]) {
_fontFamilyPrefix = prefix;
_manager = manager;
}
return self;
}
- (instancetype)initWithManager:(EXFontManager *)manager
{
return [self initWithFontFamilyPrefix:nil manager:manager];
}
- (UIFont *)updateFont:(UIFont *)uiFont
withFamily:(NSString *)family
size:(NSNumber *)size
weight:(NSString *)weight
style:(NSString *)style
variant:(NSArray<NSDictionary *> *)variant
scaleMultiplier:(CGFloat)scaleMultiplier
{
const CGFloat defaultFontSize = 14;
EXFont *exFont = nil;
// Did we get a new family, and if so, is it associated with an EXFont?
if (_fontFamilyPrefix && [family hasPrefix:_fontFamilyPrefix]) {
NSString *suffix = [family substringFromIndex:_fontFamilyPrefix.length];
exFont = [_manager fontForName:suffix];
} else if (!_fontFamilyPrefix) {
exFont = [_manager fontForName:family];
}
// Did the passed-in UIFont come from an EXFont?
if (!exFont && uiFont) {
exFont = objc_getAssociatedObject(uiFont, EXFontAssocKey);
}
// If it's an EXFont, generate the corresponding UIFont, else fallback to React Native's built-in method
if (exFont) {
CGFloat computedSize = [size doubleValue] ?: uiFont.pointSize ?: defaultFontSize;
if (scaleMultiplier > 0.0 && scaleMultiplier != 1.0) {
computedSize = round(computedSize * scaleMultiplier);
}
return [exFont UIFontWithSize:computedSize];
}
return nil;
}
@end

12
node_modules/expo-font/ios/EXFont/EXFontManager.h generated vendored Normal file
View File

@ -0,0 +1,12 @@
// Copyright 2015-present 650 Industries. All rights reserved.
#import <Foundation/Foundation.h>
#import <EXFont/EXFont.h>
@interface EXFontManager : NSObject
- (instancetype)init;
- (EXFont *)fontForName:(NSString *)name;
- (void)setFont:(EXFont *)font forName:(NSString *)name;
@end

31
node_modules/expo-font/ios/EXFont/EXFontManager.m generated vendored Normal file
View File

@ -0,0 +1,31 @@
// Copyright 2015-present 650 Industries. All rights reserved.
#import <EXFont/EXFontManager.h>
@interface EXFontManager ()
@property (nonatomic, strong, readonly) NSMutableDictionary *registry;
@end
@implementation EXFontManager
- (instancetype)init
{
if (self = [super init]) {
_registry = [NSMutableDictionary dictionary];
}
return self;
}
- (EXFont *)fontForName:(NSString *)name
{
return _registry[name];
}
- (void)setFont:(EXFont *)font forName:(NSString *)name
{
_registry[name] = font;
}
@end

8
node_modules/expo-font/ios/EXFont/EXFontScaler.h generated vendored Normal file
View File

@ -0,0 +1,8 @@
// Copyright 2015-present 650 Industries. All rights reserved.
#import <Foundation/Foundation.h>
#import <UMFontInterface/UMFontScalerInterface.h>
@interface EXFontScaler : NSObject <UMFontScalerInterface>
@end

16
node_modules/expo-font/ios/EXFont/EXFontScaler.m generated vendored Normal file
View File

@ -0,0 +1,16 @@
// Copyright 2015-present 650 Industries. All rights reserved.
#import <EXFont/EXFontScaler.h>
#import <EXFont/EXFont.h>
#import <objc/runtime.h>
@implementation EXFontScaler
- (UIFont *)scaledFont:(UIFont *)font toSize:(CGFloat)fontSize
{
EXFont *exFont = objc_getAssociatedObject(font, EXFontAssocKey);
return [exFont UIFontWithSize:fontSize];
}
@end

View File

@ -0,0 +1,8 @@
// Copyright 2018-present 650 Industries. All rights reserved.
#import <UMCore/UMSingletonModule.h>
#import <UMFontInterface/UMFontScalersManagerInterface.h>
@interface EXFontScalersManager : UMSingletonModule <UMFontScalersManagerInterface>
@end

View File

@ -0,0 +1,61 @@
// Copyright 2018-present 650 Industries. All rights reserved.
#import <EXFont/EXFontScalersManager.h>
#import <UMCore/UMDefines.h>
#import <EXFont/EXFont.h>
#import <objc/runtime.h>
static NSPointerArray *currentFontScalers;
@implementation UIFont (EXFontLoader)
- (UIFont *)EXFontWithSize:(CGFloat)fontSize
{
for (id<UMFontScalerInterface> fontScaler in currentFontScalers) {
UIFont *scaledFont = [fontScaler scaledFont:self toSize:fontSize];
if (scaledFont) {
return scaledFont;
}
}
return [self EXFontWithSize:fontSize];
}
@end
/**
* A singleton module responsible for overriding UIFont's
* fontWithSize: method which is used for scaling fonts.
* We need this one, central place to store the scalers
* as for now to get rid of timing problems when backgrounding/
* foregrounding apps.
*/
@implementation EXFontScalersManager
UM_REGISTER_SINGLETON_MODULE(FontScalersManager);
+ (void)initialize
{
static dispatch_once_t initializeCurrentFontScalersOnce;
dispatch_once(&initializeCurrentFontScalersOnce, ^{
currentFontScalers = [NSPointerArray weakObjectsPointerArray];
Class uiFont = [UIFont class];
SEL uiUpdate = @selector(fontWithSize:);
SEL exUpdate = @selector(EXFontWithSize:);
method_exchangeImplementations(class_getInstanceMethod(uiFont, uiUpdate),
class_getInstanceMethod(uiFont, exUpdate));
});
}
- (void)registerFontScaler:(id<UMFontScalerInterface>)fontScaler
{
[currentFontScalers compact];
[currentFontScalers addPointer:(__bridge void * _Nullable)(fontScaler)];
}
@end

54
node_modules/expo-font/package.json generated vendored Normal file
View File

@ -0,0 +1,54 @@
{
"name": "expo-font",
"version": "8.4.0",
"description": "Load fonts at runtime and use them in React Native components.",
"main": "build/index.js",
"types": "build/index.d.ts",
"sideEffects": false,
"scripts": {
"build": "expo-module build",
"clean": "expo-module clean",
"lint": "expo-module lint",
"test": "expo-module test",
"prepare": "expo-module prepare",
"prepublishOnly": "expo-module prepublishOnly",
"expo-module": "expo-module"
},
"keywords": [
"react-native",
"expo",
"font"
],
"repository": {
"type": "git",
"url": "https://github.com/expo/expo.git",
"directory": "packages/expo-font"
},
"bugs": {
"url": "https://github.com/expo/expo/issues"
},
"author": "650 Industries, Inc.",
"license": "MIT",
"homepage": "https://docs.expo.io/versions/latest/sdk/font/",
"jest": {
"preset": "expo-module-scripts"
},
"unimodulePeerDependencies": {
"@unimodules/core": "*",
"expo-asset": "*",
"expo-constants": "*",
"unimodules-font-interface": "*"
},
"peerDependencies": {
"react": "*",
"react-native": "*"
},
"dependencies": {
"fbjs": "1.0.0",
"fontfaceobserver": "^2.1.0"
},
"devDependencies": {
"expo-module-scripts": "~1.2.0"
},
"gitHead": "bc6b4b3bc3cb5e44e477f145c72c07ed09588651"
}

2
node_modules/expo-font/src/ExpoFontLoader.ts generated vendored Normal file
View File

@ -0,0 +1,2 @@
import { NativeModulesProxy } from '@unimodules/core';
export default NativeModulesProxy.ExpoFontLoader;

144
node_modules/expo-font/src/ExpoFontLoader.web.ts generated vendored Normal file
View File

@ -0,0 +1,144 @@
import { CodedError } from '@unimodules/core';
import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';
import FontObserver from 'fontfaceobserver';
import { UnloadFontOptions } from './Font';
import { FontDisplay, FontResource } from './Font.types';
function getFontFaceStyleSheet(): CSSStyleSheet | null {
if (!canUseDOM) {
return null;
}
const styleSheet = getStyleElement();
return styleSheet.sheet ? (styleSheet.sheet as CSSStyleSheet) : null;
}
type RuleItem = { rule: CSSFontFaceRule; index: number };
function getFontFaceRules(): RuleItem[] {
const sheet = getFontFaceStyleSheet();
if (sheet) {
// @ts-ignore: rule iterator
const rules = [...sheet.cssRules];
const items: RuleItem[] = [];
for (let i = 0; i < rules.length; i++) {
const rule = rules[i];
if (rule instanceof CSSFontFaceRule) {
items.push({ rule, index: i });
}
}
return items;
}
return [];
}
function getFontFaceRulesMatchingResource(
fontFamilyName: string,
options?: UnloadFontOptions
): RuleItem[] {
const rules = getFontFaceRules();
return rules.filter(({ rule }) => {
return (
rule.style.fontFamily === fontFamilyName &&
(options && options.display ? options.display === (rule.style as any).fontDisplay : true)
);
});
}
export default {
get name(): string {
return 'ExpoFontLoader';
},
async unloadAllAsync(): Promise<void> {
if (!canUseDOM) return;
const element = document.getElementById(ID);
if (element && element instanceof HTMLStyleElement) {
document.removeChild(element);
}
},
async unloadAsync(fontFamilyName: string, options?: UnloadFontOptions): Promise<void> {
const sheet = getFontFaceStyleSheet();
if (!sheet) return;
const items = getFontFaceRulesMatchingResource(fontFamilyName, options);
for (const item of items) {
sheet.deleteRule(item.index);
}
},
async loadAsync(fontFamilyName: string, resource: FontResource): Promise<void> {
if (!canUseDOM) {
return;
}
const canInjectStyle = document.head && typeof document.head.appendChild === 'function';
if (!canInjectStyle) {
throw new CodedError(
'ERR_WEB_ENVIRONMENT',
`The browser's \`document.head\` element doesn't support injecting fonts.`
);
}
const style = _createWebStyle(fontFamilyName, resource);
document.head!.appendChild(style);
if (!isFontLoadingListenerSupported()) {
return;
}
return new FontObserver(fontFamilyName, { display: resource.display }).load();
},
};
const ID = 'expo-generated-fonts';
function getStyleElement(): HTMLStyleElement {
const element = document.getElementById(ID);
if (element && element instanceof HTMLStyleElement) {
return element;
}
const styleElement = document.createElement('style');
styleElement.id = ID;
styleElement.type = 'text/css';
return styleElement;
}
function _createWebStyle(fontFamily: string, resource: FontResource): HTMLStyleElement {
const fontStyle = `@font-face {
font-family: ${fontFamily};
src: url(${resource.uri});
font-display: ${resource.display || FontDisplay.AUTO};
}`;
const styleElement = getStyleElement();
// @ts-ignore: TypeScript does not define HTMLStyleElement::styleSheet. This is just for IE and
// possibly can be removed if it's unnecessary on IE 11.
if (styleElement.styleSheet) {
const styleElementIE = styleElement as any;
styleElementIE.styleSheet.cssText = styleElementIE.styleSheet.cssText
? styleElementIE.styleSheet.cssText + fontStyle
: fontStyle;
} else {
const textNode = document.createTextNode(fontStyle);
styleElement.appendChild(textNode);
}
return styleElement;
}
function isFontLoadingListenerSupported(): boolean {
const { userAgent } = window.navigator;
// WebKit is broken https://github.com/bramstein/fontfaceobserver/issues/95
const isIOS = !!userAgent.match(/iPad|iPhone/i);
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
// Edge is broken https://github.com/bramstein/fontfaceobserver/issues/109#issuecomment-333356795
const isEdge = userAgent.includes('Edge');
// Internet Explorer
const isIE = userAgent.includes('Trident');
// Firefox
const isFirefox = userAgent.includes('Firefox');
return !isSafari && !isIOS && !isEdge && !isIE && !isFirefox;
}

211
node_modules/expo-font/src/Font.ts generated vendored Normal file
View File

@ -0,0 +1,211 @@
import { CodedError, UnavailabilityError } from '@unimodules/core';
import ExpoFontLoader from './ExpoFontLoader';
import { FontDisplay, FontSource, FontResource, UnloadFontOptions } from './Font.types';
import {
getAssetForSource,
loadSingleFontAsync,
fontFamilyNeedsScoping,
getNativeFontName,
} from './FontLoader';
const loaded: { [name: string]: boolean } = {};
const loadPromises: { [name: string]: Promise<void> } = {};
/**
* Used to transform font family names to the scoped name. This does not need to
* be called in standalone or bare apps but it will return unscoped font family
* names if it is called in those contexts.
* note(brentvatne): at some point we may want to warn if this is called
* outside of a managed app.
*
* @param fontFamily name to process
* @returns a name processed for use with the [current workflow](https://docs.expo.io/versions/latest/introduction/managed-vs-bare/)
*/
export function processFontFamily(fontFamily: string | null): string | null {
if (!fontFamily || !fontFamilyNeedsScoping(fontFamily)) {
return fontFamily;
}
if (!isLoaded(fontFamily)) {
if (__DEV__) {
if (isLoading(fontFamily)) {
console.error(
`You started loading the font "${fontFamily}", but used it before it finished loading.\n
- You need to wait for Font.loadAsync to complete before using the font.\n
- We recommend loading all fonts before rendering the app, and rendering only Expo.AppLoading while waiting for loading to complete.`
);
} else {
console.error(
`fontFamily "${fontFamily}" is not a system font and has not been loaded through Font.loadAsync.\n
- If you intended to use a system font, make sure you typed the name correctly and that it is supported by your device operating system.\n
- If this is a custom font, be sure to load it with Font.loadAsync.`
);
}
}
return 'System';
}
return `ExpoFont-${getNativeFontName(fontFamily)}`;
}
/**
* Synchronously detect if the font for `fontFamily` has finished loading
*
* @param fontFamily the name used to load the `FontResource`.
* @returns `true` if the the font has fully loaded.
*/
export function isLoaded(fontFamily: string): boolean {
return fontFamily in loaded;
}
/**
* Synchronously detect if the font for `fontFamily` is still being loaded
*
* @param fontFamily the name used to load the `FontResource`.
* @returns `true` if the the font is still loading.
*/
export function isLoading(fontFamily: string): boolean {
return fontFamily in loadPromises;
}
/**
* Natively load a font for use with Text elements.
* @param fontFamilyOrFontMap string or map of values that can be used as the [`fontFamily`](https://reactnative.dev/docs/text#style) style prop with React Native Text elements.
* @param source the font asset that should be loaded into the `fontFamily` namespace.
*/
export async function loadAsync(
fontFamilyOrFontMap: string | { [fontFamily: string]: FontSource },
source?: FontSource
): Promise<void> {
if (typeof fontFamilyOrFontMap === 'object') {
if (source) {
throw new CodedError(
`ERR_FONT_API`,
`No fontFamily can be used for the provided source: ${source}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`
);
}
const fontMap = fontFamilyOrFontMap;
const names = Object.keys(fontMap);
await Promise.all(names.map(name => loadFontInNamespaceAsync(name, fontMap[name])));
return;
}
return await loadFontInNamespaceAsync(fontFamilyOrFontMap, source);
}
async function loadFontInNamespaceAsync(
fontFamily: string,
source?: FontSource | null
): Promise<void> {
if (!source) {
throw new CodedError(
`ERR_FONT_SOURCE`,
`Cannot load null or undefined font source: { "${fontFamily}": ${source} }. Expected asset of type \`FontSource\` for fontFamily of name: "${fontFamily}"`
);
}
if (loaded[fontFamily]) {
return;
}
if (loadPromises[fontFamily]) {
return loadPromises[fontFamily];
}
// Important: we want all callers that concurrently try to load the same font to await the same
// promise. If we're here, we haven't created the promise yet. To ensure we create only one
// promise in the program, we need to create the promise synchronously without yielding the event
// loop from this point.
const asset = getAssetForSource(source);
loadPromises[fontFamily] = (async () => {
try {
await loadSingleFontAsync(fontFamily, asset);
loaded[fontFamily] = true;
} finally {
delete loadPromises[fontFamily];
}
})();
await loadPromises[fontFamily];
}
/**
* Unloads all of the custom fonts. This is used for testing.
*/
export async function unloadAllAsync(): Promise<void> {
if (!ExpoFontLoader.unloadAllAsync) {
throw new UnavailabilityError('expo-font', 'unloadAllAsync');
}
if (Object.keys(loadPromises).length) {
throw new CodedError(
`ERR_UNLOAD`,
`Cannot unload fonts while they're still loading: ${Object.keys(loadPromises).join(', ')}`
);
}
for (const fontFamily of Object.keys(loaded)) {
delete loaded[fontFamily];
}
await ExpoFontLoader.unloadAllAsync();
}
/**
* Unload custom fonts matching the `fontFamily`s and display values provided.
* Because fonts are automatically unloaded on every platform this is mostly used for testing.
*
* @param fontFamilyOrFontMap the names of the custom fonts that will be unloaded.
* @param source when `fontFamilyOrFontMap` is a string, this should be the font source used to load the custom font originally.
*/
export async function unloadAsync(
fontFamilyOrFontMap: string | { [fontFamily: string]: UnloadFontOptions },
options?: UnloadFontOptions
): Promise<void> {
if (!ExpoFontLoader.unloadAsync) {
throw new UnavailabilityError('expo-font', 'unloadAsync');
}
if (typeof fontFamilyOrFontMap === 'object') {
if (options) {
throw new CodedError(
`ERR_FONT_API`,
`No fontFamily can be used for the provided options: ${options}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`
);
}
const fontMap = fontFamilyOrFontMap;
const names = Object.keys(fontMap);
await Promise.all(names.map(name => unloadFontInNamespaceAsync(name, fontMap[name])));
return;
}
return await unloadFontInNamespaceAsync(fontFamilyOrFontMap, options);
}
async function unloadFontInNamespaceAsync(
fontFamily: string,
options?: UnloadFontOptions | null
): Promise<void> {
if (!loaded[fontFamily]) {
return;
} else {
delete loaded[fontFamily];
}
// Important: we want all callers that concurrently try to load the same font to await the same
// promise. If we're here, we haven't created the promise yet. To ensure we create only one
// promise in the program, we need to create the promise synchronously without yielding the event
// loop from this point.
const nativeFontName = getNativeFontName(fontFamily);
if (!nativeFontName) {
throw new CodedError(`ERR_FONT_FAMILY`, `Cannot unload an empty name`);
}
await ExpoFontLoader.unloadAsync(nativeFontName, options);
}
export { FontDisplay, FontSource, FontResource, UnloadFontOptions };

60
node_modules/expo-font/src/Font.types.ts generated vendored Normal file
View File

@ -0,0 +1,60 @@
import { Asset } from 'expo-asset';
/**
* The different types of assets you can provide to the [`loadAsync()`](#loadAsync) function.
* A font source can be a URI, a module ID, or an Expo Asset.
*/
export type FontSource = string | number | Asset | FontResource;
/**
* Used to dictate the resource that is loaded into the provided font namespace when used with [`loadAsync`](#loadasync).
* Optionally on web you can define a `display` value which sets the [`font-display`](#FontDisplay) property for a given typeface in the browser.
*/
export type FontResource = {
uri: string | number;
display?: FontDisplay;
};
/**
* Sets the [font-display](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display) for a given typeface.
* This currently **only works on web**. The default font value on web is `FontDisplay.AUTO`.
* Even though setting the `fontDisplay` does nothing on native platforms, the default behavior emulates `FontDisplay.SWAP`
* on flagship devices like iOS, Samsung, Pixel, etc. Default functionality varies on One Plus devices.
* In the browser this value is set in the generated `@font-face` CSS block and not as a style property meaning you cannot dynamically
* change this value based on the element it's used in.
*/
export enum FontDisplay {
/**
* (Default on web) The font display strategy is defined by the user agent or platform.
* This generally defaults to the text being invisible until the font is loaded.
* Good for buttons or banners that require a specific treatment.
*/
AUTO = 'auto',
/**
* Fallback text is rendered immediately with a default font while the desired font is loaded.
* This is good for making the content appear to load instantly and is usally preferred.
*/
SWAP = 'swap',
/**
* The text will be invisible until the font has loaded.
* If the font fails to load, nothing will appear.
*/
BLOCK = 'block',
/**
* Splits the behavior between `SWAP` and `BLOCK`.
* There will be a [100ms timeout](https://developers.google.com/web/updates/2016/02/font-display?hl=en) where the text with a custom font is invisible,
* after that the text will either swap to the styled text or it'll show the unstyled text and continue to load the custom font.
* This is good for buttons that need a custom font but should also be quickly available to screen-readers.
*/
FALLBACK = 'fallback',
/**
* This works almost identically to `FALLBACK`,
* the only difference is that the browser will decide to load the font based on slow connection speed or critical resource demand.
*/
OPTIONAL = 'optional',
}
/**
* Used to query fonts for unloading
*/
export type UnloadFontOptions = Pick<FontResource, 'display'>;

29
node_modules/expo-font/src/FontHooks.ts generated vendored Normal file
View File

@ -0,0 +1,29 @@
import { useEffect, useState } from 'react';
import { loadAsync } from './Font';
import { FontSource } from './Font.types';
/**
* Load a map of custom fonts to use in textual elements.
* The map keys are used as font names, and can be used with `fontFamily: <name>;`.
* It returns a boolean describing if all fonts are loaded.
*
* Note, the fonts are not "reloaded" when you dynamically change the font map.
*
* @see https://docs.expo.io/versions/latest/sdk/font/
* @example const [loaded, error] = useFonts(...);
*/
export function useFonts(
map: string | { [fontFamily: string]: FontSource }
): [boolean, Error | null] {
const [loaded, setLoaded] = useState(false);
const [error, setError] = useState<Error | null>(null);
useEffect(() => {
loadAsync(map)
.then(() => setLoaded(true))
.catch(setError);
}, []);
return [loaded, error];
}

65
node_modules/expo-font/src/FontLoader.ts generated vendored Normal file
View File

@ -0,0 +1,65 @@
import { CodedError } from '@unimodules/core';
import { Asset } from 'expo-asset';
import Constants from 'expo-constants';
import { Platform } from 'react-native';
import ExpoFontLoader from './ExpoFontLoader';
import { FontResource, FontSource } from './Font.types';
const isInClient = Constants.appOwnership === 'expo';
const isInIOSStandalone = Constants.appOwnership === 'standalone' && Platform.OS === 'ios';
export function fontFamilyNeedsScoping(name: string): boolean {
return (
(isInClient || isInIOSStandalone) &&
!Constants.systemFonts.includes(name) &&
name !== 'System' &&
!name.includes(Constants.sessionId)
);
}
export function getAssetForSource(source: FontSource): Asset | FontResource {
if (source instanceof Asset) {
return source;
}
if (typeof source === 'string') {
return Asset.fromURI(source);
} else if (typeof source === 'number') {
return Asset.fromModule(source);
} else if (typeof source === 'object' && typeof source.uri !== 'undefined') {
return getAssetForSource(source.uri);
}
// @ts-ignore Error: Type 'string' is not assignable to type 'Asset'
// We can't have a string here, we would have thrown an error if !isWeb
// or returned Asset.fromModule if isWeb.
return source;
}
export async function loadSingleFontAsync(
name: string,
input: Asset | FontResource
): Promise<void> {
const asset = input as Asset;
if (!asset.downloadAsync) {
throw new CodedError(
`ERR_FONT_SOURCE`,
'`loadSingleFontAsync` expected resource of type `Asset` from expo-asset on native'
);
}
await asset.downloadAsync();
if (!asset.downloaded) {
throw new CodedError(`ERR_DOWNLOAD`, `Failed to download asset for font "${name}"`);
}
await ExpoFontLoader.loadAsync(getNativeFontName(name), asset.localUri);
}
export function getNativeFontName(name: string): string {
if (fontFamilyNeedsScoping(name)) {
return `${Constants.sessionId}-${name}`;
} else {
return name;
}
}

61
node_modules/expo-font/src/FontLoader.web.ts generated vendored Normal file
View File

@ -0,0 +1,61 @@
import { CodedError } from '@unimodules/core';
import { Asset } from 'expo-asset';
import ExpoFontLoader from './ExpoFontLoader';
import { FontDisplay } from './Font';
import { FontResource, FontSource } from './Font.types';
function uriFromFontSource(asset: any): string | null {
if (typeof asset === 'string') {
return asset || null;
} else if (typeof asset === 'object') {
return asset.uri || asset.localUri || null;
}
return null;
}
function displayFromFontSource(asset: any): FontDisplay | undefined {
return asset.display || FontDisplay.AUTO;
}
export function fontFamilyNeedsScoping(name: string): boolean {
return false;
}
export function getAssetForSource(source: FontSource): Asset | FontResource {
const uri = uriFromFontSource(source);
const display = displayFromFontSource(source);
if (!uri || typeof uri !== 'string') {
throwInvalidSourceError(uri);
}
return {
uri: uri!,
display,
};
}
function throwInvalidSourceError(source: any): never {
let type: string = typeof source;
if (type === 'object') type = JSON.stringify(source, null, 2);
throw new CodedError(
`ERR_FONT_SOURCE`,
`Expected font asset of type \`string | FontResource | Asset\` (number is not supported on web) instead got: ${type}`
);
}
export async function loadSingleFontAsync(
name: string,
input: Asset | FontResource
): Promise<void> {
if (typeof input !== 'object' || typeof input.uri !== 'string' || (input as any).downloadAsync) {
throwInvalidSourceError(input);
}
await ExpoFontLoader.loadAsync(name, input);
}
export function getNativeFontName(name: string): string {
return name;
}

2
node_modules/expo-font/src/index.ts generated vendored Normal file
View File

@ -0,0 +1,2 @@
export * from './Font';
export { useFonts } from './FontHooks';

9
node_modules/expo-font/tsconfig.json generated vendored Normal file
View File

@ -0,0 +1,9 @@
// @generated by expo-module-scripts
{
"extends": "expo-module-scripts/tsconfig.base",
"compilerOptions": {
"outDir": "./build"
},
"include": ["./src"],
"exclude": ["**/__mocks__/*", "**/__tests__/*"]
}

4
node_modules/expo-font/unimodule.json generated vendored Normal file
View File

@ -0,0 +1,4 @@
{
"name": "expo-font",
"platforms": ["ios", "android"]
}