UNPKG

repoweaver

Version:

A GitHub App that skillfully weaves multiple templates together to create and update repositories with intelligent merge strategies

1 lines 15.9 kB
{"ast":null,"code":"import { CodedError, Platform, UnavailabilityError } from 'expo-modules-core';\nimport ExpoFontLoader from \"./ExpoFontLoader\";\nimport { FontDisplay } from \"./Font.types\";\nimport { getAssetForSource, loadSingleFontAsync } from \"./FontLoader\";\nimport { isLoadedInCache, isLoadedNative, loadPromises, markLoaded, purgeCache, purgeFontFamilyFromCache } from \"./memory\";\nimport { registerStaticFont } from \"./server\";\nexport function isLoaded(fontFamily) {\n if (Platform.OS === 'web') {\n return isLoadedInCache(fontFamily) || !!ExpoFontLoader.isLoaded(fontFamily);\n }\n return isLoadedNative(fontFamily);\n}\nexport function getLoadedFonts() {\n return ExpoFontLoader.getLoadedFonts();\n}\nexport function isLoading(fontFamily) {\n return fontFamily in loadPromises;\n}\nexport function loadAsync(fontFamilyOrFontMap, source) {\n const isServer = Platform.OS === 'web' && typeof window === 'undefined';\n if (typeof fontFamilyOrFontMap === 'object') {\n if (source) {\n return Promise.reject(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.`));\n }\n const fontMap = fontFamilyOrFontMap;\n const names = Object.keys(fontMap);\n if (isServer) {\n names.map(name => registerStaticFont(name, fontMap[name]));\n return Promise.resolve();\n }\n return Promise.all(names.map(name => loadFontInNamespaceAsync(name, fontMap[name]))).then(() => {});\n }\n if (isServer) {\n registerStaticFont(fontFamilyOrFontMap, source);\n return Promise.resolve();\n }\n return loadFontInNamespaceAsync(fontFamilyOrFontMap, source);\n}\nasync function loadFontInNamespaceAsync(fontFamily, source) {\n if (!source) {\n 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}\"`);\n }\n if (isLoaded(fontFamily)) {\n return;\n }\n if (loadPromises.hasOwnProperty(fontFamily)) {\n return loadPromises[fontFamily];\n }\n const asset = getAssetForSource(source);\n loadPromises[fontFamily] = (async () => {\n try {\n await loadSingleFontAsync(fontFamily, asset);\n markLoaded(fontFamily);\n } finally {\n delete loadPromises[fontFamily];\n }\n })();\n await loadPromises[fontFamily];\n}\nexport async function unloadAllAsync() {\n if (!ExpoFontLoader.unloadAllAsync) {\n throw new UnavailabilityError('expo-font', 'unloadAllAsync');\n }\n if (Object.keys(loadPromises).length) {\n throw new CodedError(`ERR_UNLOAD`, `Cannot unload fonts while they're still loading: ${Object.keys(loadPromises).join(', ')}`);\n }\n purgeCache();\n await ExpoFontLoader.unloadAllAsync();\n}\nexport async function unloadAsync(fontFamilyOrFontMap, options) {\n if (!ExpoFontLoader.unloadAsync) {\n throw new UnavailabilityError('expo-font', 'unloadAsync');\n }\n if (typeof fontFamilyOrFontMap === 'object') {\n if (options) {\n 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.`);\n }\n const fontMap = fontFamilyOrFontMap;\n const names = Object.keys(fontMap);\n await Promise.all(names.map(name => unloadFontInNamespaceAsync(name, fontMap[name])));\n return;\n }\n return await unloadFontInNamespaceAsync(fontFamilyOrFontMap, options);\n}\nasync function unloadFontInNamespaceAsync(fontFamily, options) {\n if (!isLoaded(fontFamily)) {\n return;\n } else {\n purgeFontFamilyFromCache(fontFamily);\n }\n if (!fontFamily) {\n throw new CodedError(`ERR_FONT_FAMILY`, `Cannot unload an empty name`);\n }\n await ExpoFontLoader.unloadAsync(fontFamily, options);\n}\nexport { FontDisplay };","map":{"version":3,"names":["CodedError","Platform","UnavailabilityError","ExpoFontLoader","FontDisplay","getAssetForSource","loadSingleFontAsync","isLoadedInCache","isLoadedNative","loadPromises","markLoaded","purgeCache","purgeFontFamilyFromCache","registerStaticFont","isLoaded","fontFamily","OS","getLoadedFonts","isLoading","loadAsync","fontFamilyOrFontMap","source","isServer","window","Promise","reject","fontMap","names","Object","keys","map","name","resolve","all","loadFontInNamespaceAsync","then","hasOwnProperty","asset","unloadAllAsync","length","join","unloadAsync","options","unloadFontInNamespaceAsync"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/expo-font/src/Font.ts"],"sourcesContent":["import { CodedError, Platform, UnavailabilityError } from 'expo-modules-core';\n\nimport ExpoFontLoader from './ExpoFontLoader';\nimport { FontDisplay, FontSource, FontResource, UnloadFontOptions } from './Font.types';\nimport { getAssetForSource, loadSingleFontAsync } from './FontLoader';\nimport {\n isLoadedInCache,\n isLoadedNative,\n loadPromises,\n markLoaded,\n purgeCache,\n purgeFontFamilyFromCache,\n} from './memory';\nimport { registerStaticFont } from './server';\n\n// @needsAudit\n/**\n * Synchronously detect if the font for `fontFamily` has finished loading.\n *\n * @param fontFamily The name used to load the `FontResource`.\n * @return Returns `true` if the font has fully loaded.\n */\nexport function isLoaded(fontFamily: string): boolean {\n if (Platform.OS === 'web') {\n return isLoadedInCache(fontFamily) || !!ExpoFontLoader.isLoaded(fontFamily);\n }\n return isLoadedNative(fontFamily);\n}\n\n/**\n * Synchronously get all the fonts that have been loaded.\n * This includes fonts that were bundled at build time using the config plugin, as well as those loaded at runtime using `loadAsync`.\n *\n * @returns Returns array of strings which you can use as `fontFamily` [style prop](https://reactnative.dev/docs/text#style).\n */\nexport function getLoadedFonts(): string[] {\n return ExpoFontLoader.getLoadedFonts();\n}\n\n// @needsAudit\n/**\n * Synchronously detect if the font for `fontFamily` is still being loaded.\n *\n * @param fontFamily The name used to load the `FontResource`.\n * @returns Returns `true` if the font is still loading.\n */\nexport function isLoading(fontFamily: string): boolean {\n return fontFamily in loadPromises;\n}\n\n// @needsAudit\n/**\n * An efficient method for loading fonts from static or remote resources which can then be used\n * with the platform's native text elements. In the browser, this generates a `@font-face` block in\n * a shared style sheet for fonts. No CSS is needed to use this method.\n *\n * > **Note**: We recommend using the [config plugin](#configuration-in-appjsonappconfigjs) instead whenever possible.\n *\n * @param fontFamilyOrFontMap String or map of values that can be used as the `fontFamily` [style prop](https://reactnative.dev/docs/text#style)\n * with React Native `Text` elements.\n * @param source The font asset that should be loaded into the `fontFamily` namespace.\n *\n * @return Returns a promise that fulfils when the font has loaded. Often you may want to wrap the\n * method in a `try/catch/finally` to ensure the app continues if the font fails to load.\n */\nexport function loadAsync(\n fontFamilyOrFontMap: string | Record<string, FontSource>,\n source?: FontSource\n): Promise<void> {\n // NOTE(EvanBacon): Static render pass on web must be synchronous to collect all fonts.\n // Because of this, `loadAsync` doesn't use the `async` keyword and deviates from the\n // standard Expo SDK style guide.\n const isServer = Platform.OS === 'web' && typeof window === 'undefined';\n\n if (typeof fontFamilyOrFontMap === 'object') {\n if (source) {\n return Promise.reject(\n new CodedError(\n `ERR_FONT_API`,\n `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.`\n )\n );\n }\n const fontMap = fontFamilyOrFontMap;\n const names = Object.keys(fontMap);\n\n if (isServer) {\n names.map((name) => registerStaticFont(name, fontMap[name]));\n return Promise.resolve();\n }\n\n return Promise.all(names.map((name) => loadFontInNamespaceAsync(name, fontMap[name]))).then(\n () => {}\n );\n }\n\n if (isServer) {\n registerStaticFont(fontFamilyOrFontMap, source);\n return Promise.resolve();\n }\n\n return loadFontInNamespaceAsync(fontFamilyOrFontMap, source);\n}\n\nasync function loadFontInNamespaceAsync(\n fontFamily: string,\n source?: FontSource | null\n): Promise<void> {\n if (!source) {\n throw new CodedError(\n `ERR_FONT_SOURCE`,\n `Cannot load null or undefined font source: { \"${fontFamily}\": ${source} }. Expected asset of type \\`FontSource\\` for fontFamily of name: \"${fontFamily}\"`\n );\n }\n\n // we consult the native module to see if the font is already loaded\n // this is slower than checking the cache but can help avoid loading the same font n times\n if (isLoaded(fontFamily)) {\n return;\n }\n\n if (loadPromises.hasOwnProperty(fontFamily)) {\n return loadPromises[fontFamily];\n }\n\n // Important: we want all callers that concurrently try to load the same font to await the same\n // promise. If we're here, we haven't created the promise yet. To ensure we create only one\n // promise in the program, we need to create the promise synchronously without yielding the event\n // loop from this point.\n\n const asset = getAssetForSource(source);\n loadPromises[fontFamily] = (async () => {\n try {\n await loadSingleFontAsync(fontFamily, asset);\n markLoaded(fontFamily);\n } finally {\n delete loadPromises[fontFamily];\n }\n })();\n\n await loadPromises[fontFamily];\n}\n\n// @needsAudit\n/**\n * Unloads all the custom fonts. This is used for testing.\n * @hidden\n */\nexport async function unloadAllAsync(): Promise<void> {\n if (!ExpoFontLoader.unloadAllAsync) {\n throw new UnavailabilityError('expo-font', 'unloadAllAsync');\n }\n\n if (Object.keys(loadPromises).length) {\n throw new CodedError(\n `ERR_UNLOAD`,\n `Cannot unload fonts while they're still loading: ${Object.keys(loadPromises).join(', ')}`\n );\n }\n purgeCache();\n await ExpoFontLoader.unloadAllAsync();\n}\n\n// @needsAudit\n/**\n * Unload custom fonts matching the `fontFamily`s and display values provided.\n * This is used for testing.\n *\n * @param fontFamilyOrFontMap The name or names of the custom fonts that will be unloaded.\n * @param options When `fontFamilyOrFontMap` is a string, this should be the font source used to load\n * the custom font originally.\n * @hidden\n */\nexport async function unloadAsync(\n fontFamilyOrFontMap: string | Record<string, UnloadFontOptions>,\n options?: UnloadFontOptions\n): Promise<void> {\n if (!ExpoFontLoader.unloadAsync) {\n throw new UnavailabilityError('expo-font', 'unloadAsync');\n }\n if (typeof fontFamilyOrFontMap === 'object') {\n if (options) {\n throw new CodedError(\n `ERR_FONT_API`,\n `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.`\n );\n }\n const fontMap = fontFamilyOrFontMap;\n const names = Object.keys(fontMap);\n await Promise.all(names.map((name) => unloadFontInNamespaceAsync(name, fontMap[name])));\n return;\n }\n\n return await unloadFontInNamespaceAsync(fontFamilyOrFontMap, options);\n}\n\nasync function unloadFontInNamespaceAsync(\n fontFamily: string,\n options?: UnloadFontOptions | null\n): Promise<void> {\n if (!isLoaded(fontFamily)) {\n return;\n } else {\n purgeFontFamilyFromCache(fontFamily);\n }\n\n // Important: we want all callers that concurrently try to load the same font to await the same\n // promise. If we're here, we haven't created the promise yet. To ensure we create only one\n // promise in the program, we need to create the promise synchronously without yielding the event\n // loop from this point.\n\n if (!fontFamily) {\n throw new CodedError(`ERR_FONT_FAMILY`, `Cannot unload an empty name`);\n }\n\n await ExpoFontLoader.unloadAsync(fontFamily, options);\n}\n\nexport { FontDisplay, FontSource, FontResource, UnloadFontOptions };\n"],"mappings":"AAAA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,mBAAmB,QAAQ,mBAAmB;AAE7E,OAAOC,cAAc;AACrB,SAASC,WAAW;AACpB,SAASC,iBAAiB,EAAEC,mBAAmB;AAC/C,SACEC,eAAe,EACfC,cAAc,EACdC,YAAY,EACZC,UAAU,EACVC,UAAU,EACVC,wBAAwB;AAE1B,SAASC,kBAAkB;AAS3B,OAAM,SAAUC,QAAQA,CAACC,UAAkB;EACzC,IAAId,QAAQ,CAACe,EAAE,KAAK,KAAK,EAAE;IACzB,OAAOT,eAAe,CAACQ,UAAU,CAAC,IAAI,CAAC,CAACZ,cAAc,CAACW,QAAQ,CAACC,UAAU,CAAC;EAC7E;EACA,OAAOP,cAAc,CAACO,UAAU,CAAC;AACnC;AAQA,OAAM,SAAUE,cAAcA,CAAA;EAC5B,OAAOd,cAAc,CAACc,cAAc,EAAE;AACxC;AASA,OAAM,SAAUC,SAASA,CAACH,UAAkB;EAC1C,OAAOA,UAAU,IAAIN,YAAY;AACnC;AAiBA,OAAM,SAAUU,SAASA,CACvBC,mBAAwD,EACxDC,MAAmB;EAKnB,MAAMC,QAAQ,GAAGrB,QAAQ,CAACe,EAAE,KAAK,KAAK,IAAI,OAAOO,MAAM,KAAK,WAAW;EAEvE,IAAI,OAAOH,mBAAmB,KAAK,QAAQ,EAAE;IAC3C,IAAIC,MAAM,EAAE;MACV,OAAOG,OAAO,CAACC,MAAM,CACn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