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

0
node_modules/expo-updates/src/.gitkeep generated vendored Normal file
View File

2
node_modules/expo-updates/src/ExpoUpdates.ts generated vendored Normal file
View File

@ -0,0 +1,2 @@
import { NativeModulesProxy } from '@unimodules/core';
export default NativeModulesProxy.ExpoUpdates || ({} as any);

11
node_modules/expo-updates/src/ExpoUpdates.web.ts generated vendored Normal file
View File

@ -0,0 +1,11 @@
import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';
export default {
get name(): string {
return 'ExpoUpdates';
},
async reload(): Promise<void> {
if (!canUseDOM) return;
window.location.reload(true);
},
};

132
node_modules/expo-updates/src/Updates.ts generated vendored Normal file
View File

@ -0,0 +1,132 @@
import {
RCTDeviceEventEmitter,
CodedError,
NativeModulesProxy,
UnavailabilityError,
} from '@unimodules/core';
import { EventEmitter, EventSubscription } from 'fbemitter';
import ExpoUpdates from './ExpoUpdates';
import {
Listener,
LocalAssets,
Manifest,
UpdateCheckResult,
UpdateEvent,
UpdateFetchResult,
} from './Updates.types';
export * from './Updates.types';
export const updateId: string | null =
ExpoUpdates.updateId && typeof ExpoUpdates.updateId === 'string'
? ExpoUpdates.updateId.toLowerCase()
: null;
export const releaseChannel: string = ExpoUpdates.releaseChannel ?? 'default';
export const localAssets: LocalAssets = ExpoUpdates.localAssets ?? {};
export const isEmergencyLaunch: boolean = ExpoUpdates.isEmergencyLaunch || false;
export const isUsingEmbeddedAssets: boolean = ExpoUpdates.isUsingEmbeddedAssets || false;
let _manifest = ExpoUpdates.manifest;
if (ExpoUpdates.manifestString) {
_manifest = JSON.parse(ExpoUpdates.manifestString);
}
export const manifest: Manifest | object = _manifest ?? {};
const isUsingDeveloperTool = !!(manifest as any).developer?.tool;
const isUsingExpoDevelopmentClient = NativeModulesProxy.ExponentConstants?.appOwnership === 'expo';
const manualUpdatesInstructions = isUsingExpoDevelopmentClient
? 'To test manual updates, publish your project using `expo publish` and open the published ' +
'version in this development client.'
: 'To test manual updates, make a release build with `npm run ios --configuration Release` or ' +
'`npm run android --variant Release`.';
export async function reloadAsync(): Promise<void> {
if (!ExpoUpdates.reload) {
throw new UnavailabilityError('Updates', 'reloadAsync');
}
if (__DEV__ && !isUsingExpoDevelopmentClient) {
throw new CodedError(
'ERR_UPDATES_DISABLED',
`You cannot use the Updates module in development mode in a production app. ${manualUpdatesInstructions}`
);
}
await ExpoUpdates.reload();
}
export async function checkForUpdateAsync(): Promise<UpdateCheckResult> {
if (!ExpoUpdates.checkForUpdateAsync) {
throw new UnavailabilityError('Updates', 'checkForUpdateAsync');
}
if (__DEV__ || isUsingDeveloperTool) {
throw new CodedError(
'ERR_UPDATES_DISABLED',
`You cannot check for updates in development mode. ${manualUpdatesInstructions}`
);
}
const result = await ExpoUpdates.checkForUpdateAsync();
if (result.manifestString) {
result.manifest = JSON.parse(result.manifestString);
delete result.manifestString;
}
return result;
}
export async function fetchUpdateAsync(): Promise<UpdateFetchResult> {
if (!ExpoUpdates.fetchUpdateAsync) {
throw new UnavailabilityError('Updates', 'fetchUpdateAsync');
}
if (__DEV__ || isUsingDeveloperTool) {
throw new CodedError(
'ERR_UPDATES_DISABLED',
`You cannot fetch updates in development mode. ${manualUpdatesInstructions}`
);
}
const result = await ExpoUpdates.fetchUpdateAsync();
if (result.manifestString) {
result.manifest = JSON.parse(result.manifestString);
delete result.manifestString;
}
return result;
}
export function clearUpdateCacheExperimentalAsync(_sdkVersion?: string) {
console.warn(
"This method is no longer necessary. `expo-updates` now automatically deletes your app's old bundle files!"
);
}
let _emitter: EventEmitter | null;
function _getEmitter(): EventEmitter {
if (!_emitter) {
_emitter = new EventEmitter();
RCTDeviceEventEmitter.addListener('Expo.nativeUpdatesEvent', _emitEvent);
}
return _emitter;
}
function _emitEvent(params): void {
let newParams = params;
if (typeof params === 'string') {
newParams = JSON.parse(params);
}
if (newParams.manifestString) {
newParams.manifest = JSON.parse(newParams.manifestString);
delete newParams.manifestString;
}
if (!_emitter) {
throw new Error(`EventEmitter must be initialized to use from its listener`);
}
_emitter.emit('Expo.updatesEvent', newParams);
}
export function addListener(listener: Listener<UpdateEvent>): EventSubscription {
const emitter = _getEmitter();
return emitter.addListener('Expo.updatesEvent', listener);
}

23
node_modules/expo-updates/src/Updates.types.ts generated vendored Normal file
View File

@ -0,0 +1,23 @@
import Constants from 'expo-constants';
export enum UpdateEventType {
UPDATE_AVAILABLE = 'updateAvailable',
NO_UPDATE_AVAILABLE = 'noUpdateAvailable',
ERROR = 'error',
}
// TODO(eric): move source of truth for manifest type to this module
export type Manifest = typeof Constants.manifest;
export type UpdateCheckResult = { isAvailable: false } | { isAvailable: true; manifest: Manifest };
export type UpdateFetchResult = { isNew: false } | { isNew: true; manifest: Manifest };
export type Listener<E> = (event: E) => void;
export type UpdateEvent =
| { type: UpdateEventType.NO_UPDATE_AVAILABLE }
| { type: UpdateEventType.UPDATE_AVAILABLE; manifest: Manifest }
| { type: UpdateEventType.ERROR; message: string };
export type LocalAssets = { [remoteUrl: string]: string };

1
node_modules/expo-updates/src/index.ts generated vendored Normal file
View File

@ -0,0 +1 @@
export * from './Updates';