yeet
This commit is contained in:
103
node_modules/expo-constants/src/Constants.ts
generated
vendored
Normal file
103
node_modules/expo-constants/src/Constants.ts
generated
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
import { CodedError, NativeModulesProxy } from '@unimodules/core';
|
||||
import { Platform } from 'react-native';
|
||||
|
||||
import {
|
||||
AndroidManifest,
|
||||
AppOwnership,
|
||||
Constants,
|
||||
ExecutionEnvironment,
|
||||
IOSManifest,
|
||||
NativeConstants,
|
||||
PlatformManifest,
|
||||
UserInterfaceIdiom,
|
||||
WebManifest,
|
||||
} from './Constants.types';
|
||||
import ExponentConstants from './ExponentConstants';
|
||||
|
||||
export {
|
||||
AndroidManifest,
|
||||
AppOwnership,
|
||||
Constants,
|
||||
ExecutionEnvironment,
|
||||
IOSManifest,
|
||||
NativeConstants,
|
||||
PlatformManifest,
|
||||
UserInterfaceIdiom,
|
||||
WebManifest,
|
||||
};
|
||||
|
||||
if (!ExponentConstants) {
|
||||
console.warn(
|
||||
"No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?"
|
||||
);
|
||||
}
|
||||
|
||||
let manifest = null;
|
||||
// If expo-updates defines a non-empty manifest, prefer that one
|
||||
if (NativeModulesProxy.ExpoUpdates) {
|
||||
let updatesManifest;
|
||||
if (NativeModulesProxy.ExpoUpdates.manifest) {
|
||||
updatesManifest = NativeModulesProxy.ExpoUpdates.manifest;
|
||||
} else if (NativeModulesProxy.ExpoUpdates.manifestString) {
|
||||
updatesManifest = JSON.parse(NativeModulesProxy.ExpoUpdates.manifestString);
|
||||
}
|
||||
if (updatesManifest && Object.keys(updatesManifest).length > 0) {
|
||||
manifest = updatesManifest;
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to ExponentConstants.manifest if we don't have one from Updates
|
||||
if (!manifest && ExponentConstants && ExponentConstants.manifest) {
|
||||
manifest = ExponentConstants.manifest;
|
||||
// On Android we pass the manifest in JSON form so this step is necessary
|
||||
if (typeof manifest === 'string') {
|
||||
manifest = JSON.parse(manifest);
|
||||
}
|
||||
}
|
||||
|
||||
const { name, appOwnership, ...nativeConstants } = (ExponentConstants || {}) as any;
|
||||
|
||||
const constants = {
|
||||
...nativeConstants,
|
||||
// Ensure this is null in bare workflow
|
||||
appOwnership: appOwnership ?? null,
|
||||
// Legacy aliases
|
||||
deviceId: nativeConstants.installationId,
|
||||
linkingUrl: nativeConstants.linkingUri,
|
||||
};
|
||||
|
||||
Object.defineProperties(constants, {
|
||||
manifest: {
|
||||
enumerable: true,
|
||||
get() {
|
||||
if (!manifest) {
|
||||
const invalidManifestType = manifest === null ? 'null' : 'undefined';
|
||||
if (
|
||||
nativeConstants.executionEnvironment === ExecutionEnvironment.Bare &&
|
||||
Platform.OS !== 'web'
|
||||
) {
|
||||
console.warn(
|
||||
`Constants.manifest is ${invalidManifestType} because the embedded app.config could not be read. Ensure that you have installed the expo-constants build scripts if you need to read from Constants.manifest.`
|
||||
);
|
||||
} else if (
|
||||
nativeConstants.executionEnvironment === ExecutionEnvironment.StoreClient ||
|
||||
nativeConstants.executionEnvironment === ExecutionEnvironment.Standalone
|
||||
) {
|
||||
// If we somehow get here, this is a truly exceptional state to be in.
|
||||
// Constants.manifest should *always* be defined in those contexts.
|
||||
throw new CodedError(
|
||||
'ERR_CONSTANTS_MANIFEST_UNAVAILABLE',
|
||||
`Constants.manifest is ${invalidManifestType}, must be an object.`
|
||||
);
|
||||
}
|
||||
}
|
||||
return manifest;
|
||||
},
|
||||
// This setter is only useful to mock the value for tests
|
||||
set(value) {
|
||||
manifest = value;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default constants as Constants;
|
134
node_modules/expo-constants/src/Constants.types.ts
generated
vendored
Normal file
134
node_modules/expo-constants/src/Constants.types.ts
generated
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
export enum AppOwnership {
|
||||
Standalone = 'standalone',
|
||||
Expo = 'expo',
|
||||
Guest = 'guest',
|
||||
}
|
||||
|
||||
export enum ExecutionEnvironment {
|
||||
Bare = 'bare',
|
||||
Standalone = 'standalone',
|
||||
StoreClient = 'storeClient',
|
||||
}
|
||||
|
||||
export enum UserInterfaceIdiom {
|
||||
Handset = 'handset',
|
||||
Tablet = 'tablet',
|
||||
Unsupported = 'unsupported',
|
||||
}
|
||||
|
||||
export interface IOSManifest {
|
||||
buildNumber: string;
|
||||
platform: string;
|
||||
model: string;
|
||||
userInterfaceIdiom: UserInterfaceIdiom;
|
||||
systemVersion: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface AndroidManifest {
|
||||
versionCode: number;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface WebManifest {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface AppManifest {
|
||||
name?: string;
|
||||
description?: string;
|
||||
slug?: string;
|
||||
sdkVersion?: string;
|
||||
version?: string;
|
||||
/** Published Apps Only */
|
||||
releaseId?: string;
|
||||
revisionId?: string;
|
||||
releaseChannel?: string;
|
||||
orientation?: string;
|
||||
primaryColor?: string;
|
||||
icon?: string;
|
||||
notification?: {
|
||||
icon?: string;
|
||||
color?: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
loading?: {
|
||||
icon?: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
entryPoint?: string;
|
||||
packagerOpts?: {
|
||||
hostType?: string;
|
||||
dev?: boolean;
|
||||
strict?: boolean;
|
||||
minify?: boolean;
|
||||
urlType?: string;
|
||||
urlRandomness?: string;
|
||||
lanType?: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
xde?: boolean;
|
||||
developer?: {
|
||||
tool?: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
bundleUrl: string;
|
||||
debuggerHost?: string;
|
||||
mainModuleName?: string;
|
||||
logUrl?: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface PlatformManifest {
|
||||
ios?: IOSManifest;
|
||||
android?: AndroidManifest;
|
||||
web?: WebManifest;
|
||||
detach?: {
|
||||
scheme?: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
logUrl?: string;
|
||||
scheme?: string;
|
||||
hostUri?: string;
|
||||
developer?: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface NativeConstants {
|
||||
name: 'ExponentConstants';
|
||||
appOwnership: AppOwnership | null;
|
||||
debugMode: boolean;
|
||||
deviceName?: string;
|
||||
deviceYearClass: number | null;
|
||||
executionEnvironment: ExecutionEnvironment;
|
||||
experienceUrl: string;
|
||||
// only nullable on web
|
||||
expoRuntimeVersion: string | null;
|
||||
/**
|
||||
* The version string of the Expo client currently running.
|
||||
* Returns `null` on and bare workflow and web.
|
||||
*/
|
||||
expoVersion: string | null;
|
||||
isDetached?: boolean;
|
||||
intentUri?: string;
|
||||
installationId: string;
|
||||
isDevice: boolean;
|
||||
isHeadless: boolean;
|
||||
linkingUri: string;
|
||||
nativeAppVersion: string | null;
|
||||
nativeBuildVersion: string | null;
|
||||
manifest: AppManifest;
|
||||
sessionId: string;
|
||||
statusBarHeight: number;
|
||||
systemFonts: string[];
|
||||
systemVersion?: number;
|
||||
platform?: PlatformManifest;
|
||||
[key: string]: any;
|
||||
|
||||
getWebViewUserAgentAsync: () => Promise<string | null>;
|
||||
}
|
||||
|
||||
export interface Constants extends NativeConstants {
|
||||
deviceId?: string;
|
||||
linkingUrl?: string;
|
||||
}
|
2
node_modules/expo-constants/src/ExponentConstants.ts
generated
vendored
Normal file
2
node_modules/expo-constants/src/ExponentConstants.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import { NativeModulesProxy } from '@unimodules/core';
|
||||
export default NativeModulesProxy.ExponentConstants;
|
140
node_modules/expo-constants/src/ExponentConstants.web.ts
generated
vendored
Normal file
140
node_modules/expo-constants/src/ExponentConstants.web.ts
generated
vendored
Normal file
@ -0,0 +1,140 @@
|
||||
import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import {
|
||||
ExecutionEnvironment,
|
||||
NativeConstants,
|
||||
PlatformManifest,
|
||||
WebManifest,
|
||||
} from './Constants.types';
|
||||
|
||||
const ID_KEY = 'EXPO_CONSTANTS_INSTALLATION_ID';
|
||||
|
||||
declare var __DEV__: boolean;
|
||||
declare var process: { env: any };
|
||||
declare var navigator: Navigator;
|
||||
declare var location: Location;
|
||||
declare var localStorage: Storage;
|
||||
|
||||
const _sessionId = uuidv4();
|
||||
|
||||
function getBrowserName(): string | undefined {
|
||||
if (canUseDOM) {
|
||||
const agent = navigator.userAgent.toLowerCase();
|
||||
if (agent.includes('edge')) {
|
||||
return 'Edge';
|
||||
} else if (agent.includes('edg')) {
|
||||
return 'Chromium Edge';
|
||||
} else if (agent.includes('opr') && !!window['opr']) {
|
||||
return 'Opera';
|
||||
} else if (agent.includes('chrome') && !!window['chrome']) {
|
||||
return 'Chrome';
|
||||
} else if (agent.includes('trident')) {
|
||||
return 'IE';
|
||||
} else if (agent.includes('firefox')) {
|
||||
return 'Firefox';
|
||||
} else if (agent.includes('safari')) {
|
||||
return 'Safari';
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export default {
|
||||
get name(): string {
|
||||
return 'ExponentConstants';
|
||||
},
|
||||
get appOwnership() {
|
||||
return null;
|
||||
},
|
||||
get executionEnvironment() {
|
||||
return ExecutionEnvironment.Bare;
|
||||
},
|
||||
get installationId(): string {
|
||||
let installationId;
|
||||
try {
|
||||
installationId = localStorage.getItem(ID_KEY);
|
||||
if (installationId == null || typeof installationId !== 'string') {
|
||||
installationId = uuidv4();
|
||||
localStorage.setItem(ID_KEY, installationId as string);
|
||||
}
|
||||
} catch (error) {
|
||||
installationId = _sessionId;
|
||||
} finally {
|
||||
return installationId;
|
||||
}
|
||||
},
|
||||
get sessionId(): string {
|
||||
return _sessionId;
|
||||
},
|
||||
get platform(): PlatformManifest {
|
||||
return { web: canUseDOM ? { ua: navigator.userAgent } : undefined };
|
||||
},
|
||||
get isHeadless(): boolean {
|
||||
if (!canUseDOM) return true;
|
||||
|
||||
return /\bHeadlessChrome\//.test(navigator.userAgent);
|
||||
},
|
||||
get isDevice(): true {
|
||||
// TODO: Bacon: Possibly want to add information regarding simulators
|
||||
return true;
|
||||
},
|
||||
get expoVersion(): string | null {
|
||||
return this.manifest.sdkVersion || null;
|
||||
},
|
||||
get linkingUri(): string {
|
||||
if (canUseDOM) {
|
||||
// On native this is `exp://`
|
||||
// On web we should use the protocol and hostname (location.origin)
|
||||
return location.origin;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
get expoRuntimeVersion(): string | null {
|
||||
return this.expoVersion;
|
||||
},
|
||||
get deviceName(): string | undefined {
|
||||
return getBrowserName();
|
||||
},
|
||||
get nativeAppVersion(): null {
|
||||
return null;
|
||||
},
|
||||
get nativeBuildVersion(): null {
|
||||
return null;
|
||||
},
|
||||
get systemFonts(): string[] {
|
||||
// TODO: Bacon: Maybe possible.
|
||||
return [];
|
||||
},
|
||||
get statusBarHeight(): number {
|
||||
return 0;
|
||||
},
|
||||
get deviceYearClass(): number | null {
|
||||
// TODO: Bacon: The android version isn't very accurate either, maybe we could try and guess this value.
|
||||
return null;
|
||||
},
|
||||
get manifest(): WebManifest {
|
||||
// This is defined by @expo/webpack-config.
|
||||
// If your site is bundled with a different config then you may not have access to the app.json automatically.
|
||||
return process.env.APP_MANIFEST || {};
|
||||
},
|
||||
get experienceUrl(): string {
|
||||
if (canUseDOM) {
|
||||
return location.origin;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
get debugMode(): boolean {
|
||||
return __DEV__;
|
||||
},
|
||||
async getWebViewUserAgentAsync(): Promise<string | null> {
|
||||
if (canUseDOM) {
|
||||
return navigator.userAgent;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
} as NativeConstants;
|
Reference in New Issue
Block a user