How to use @unimodules/core - 10 common examples

To help you get started, we’ve selected a few @unimodules/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo / packages / expo-app-auth / build / AppAuth.js View on Github external
function parseRetryTime(value) {
    // In accordance with RFC2616, Section 14.37. Timout may be of format seconds or future date time value
    if (/^\d+$/.test(value)) {
        return parseInt(value, 10) * 1000;
    }
    const retry = Date.parse(value);
    if (isNaN(retry)) {
        throw new CodedError('ERR_APP_AUTH_FETCH_RETRY_TIME', 'Cannot parse the Retry-After header value returned by the server: ' + value);
    }
    const now = Date.now();
    const parsedDate = new Date(retry);
    return parsedDate.getTime() - now;
}
export const { OAuthRedirect, URLSchemes } = ExpoAppAuth;
github expo / expo / packages / expo-file-system / build / FileSystem.js View on Github external
import UUID from 'uuid-js';
import { Platform } from 'react-native';
import { EventEmitter, UnavailabilityError } from '@unimodules/core';
import ExponentFileSystem from './ExponentFileSystem';
import { EncodingType, } from './FileSystem.types';
if (!ExponentFileSystem) {
    console.warn("No native ExponentFileSystem module found, are you sure the expo-file-system's module is linked properly?");
}
// Prevent webpack from pruning this.
const _unused = new EventEmitter(ExponentFileSystem); // eslint-disable-line
export { EncodingType, };
function normalizeEndingSlash(p) {
    if (p != null) {
        return p.replace(/\/*$/, '') + '/';
    }
    return null;
}
export const documentDirectory = normalizeEndingSlash(ExponentFileSystem.documentDirectory);
export const cacheDirectory = normalizeEndingSlash(ExponentFileSystem.cacheDirectory);
export const { bundledAssets, bundleDirectory } = ExponentFileSystem;
export async function getInfoAsync(fileUri, options = {}) {
    if (!ExponentFileSystem.getInfoAsync) {
        throw new UnavailabilityError('expo-file-system', 'getInfoAsync');
    }
    return await ExponentFileSystem.getInfoAsync(fileUri, options);
}
github expo / expo / packages / expo-sensors / src / ExponentDeviceMotion.web.ts View on Github external
_handleMotion(motion) {
    // TODO: Bacon: Can rotation be calculated?
    SyntheticPlatformEmitter.emit('deviceMotionDidUpdate', {
      acceleration: motion.acceleration,
      accelerationIncludingGravity: motion.accelerationIncludingGravity,
      interval: motion.interval,
      rotationRate: motion.rotationRate,
      orientation: window.orientation,
    });
  },
  startObserving() {
github expo / expo / packages / expo-font / src / Font.ts View on Github external
async function loadFontInNamespaceAsync(
  fontFamily: string,
  source?: FontSource | null
): Promise {
  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
github expo / expo / packages / expo-app-auth / build / AppAuth.js View on Github external
}
    const encodedClientID = encodeURIComponent(clientId);
    const encodedToken = encodeURIComponent(token);
    const body = `token=${encodedToken}${isClientIdProvided ? `&client_id=${encodedClientID}` : ''}`;
    const headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
    try {
        // https://tools.ietf.org/html/rfc7009#section-2.2
        const results = await fetch(revocationEndpoint, {
            method: 'POST',
            headers,
            body,
        });
        return results;
    }
    catch (error) {
        throw new CodedError('ERR_APP_AUTH_REVOKE_FAILED', error.message);
    }
}
// NOTE: This function is unused; delete it if we don't need it
github expo / expo / packages / expo-font / build / Font.js View on Github external
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 };
github expo / expo / packages / expo-firebase-notifications / src / IOSNotification.ts View on Github external
import { Platform } from '@unimodules/core';
import { BackgroundFetchResultValue } from './IOSNotifications';

import Notification from './Notification';
import { Notifications, IOSAttachment, IOSAttachmentOptions, NativeIOSNotification } from './types';

type CompletionHandler = (results: BackgroundFetchResultValue) => void;

const isIOS = Platform.OS === 'ios';
export default class IOSNotification {
  _alertAction?: string;

  // alertAction | N/A
  _attachments: IOSAttachment[] = [];

  // N/A | attachments
  _badge?: number;

  // applicationIconBadgeNumber | badge
  _category?: string;

  _hasAction?: boolean;

  // hasAction | N/A
  _launchImage?: string;
github expo / expo / packages / expo-av / src / Audio / Recording.ts View on Github external
},
};

// TODO: For consistency with PlaybackStatus, should we include progressUpdateIntervalMillis here as
// well?
export type RecordingStatus = {
  canRecord: boolean;
  isRecording: boolean;
  isDoneRecording: boolean;
  durationMillis: number;
};

export { PermissionResponse, PermissionStatus };

let _recorderExists: boolean = false;
const eventEmitter = Platform.OS === 'android' ? new EventEmitter(ExponentAV) : null;

export async function getPermissionsAsync(): Promise {
  return ExponentAV.getPermissionsAsync();
}

export async function requestPermissionsAsync(): Promise {
  return ExponentAV.requestPermissionsAsync();
}

export class Recording {
  _subscription: Subscription | null = null;
  _canRecord: boolean = false;
  _isDoneRecording: boolean = false;
  _finalDurationMillis: number = 0;
  _uri: string | null = null;
  _onRecordingStatusUpdate: ((status: RecordingStatus) => void) | null = null;
github expo / expo / packages / expo-ads-facebook / src / AdIconView.tsx View on Github external
export default class AdIconView extends React.Component {
  render() {
    return (
      
        {(contextValue: AdIconViewContextValue | null) => {
          let context = nullthrows(contextValue);
          return ;
        }}
      
    );
  }
}

// The native AdIconView has the same props as regular View
export type NativeAdIconView = React.Component;
export const NativeAdIconView = requireNativeViewManager('AdIconView');
github expo / expo / packages / expo-firebase-database / build / SyncTree.js View on Github external
return false;
        }
        const { path, eventType, once } = this._reverseLookup[registration];
        if (!this._tree[path]) {
            delete this._reverseLookup[registration];
            return false;
        }
        if (!this._tree[path][eventType]) {
            delete this._reverseLookup[registration];
            return false;
        }
        // we don't want `once` events to notify native as they're already
        // automatically unsubscribed on native when the first event is sent
        const registrationObj = this._reverseLookup[registration];
        if (registrationObj && !once) {
            NativeModulesProxy.ExpoFirebaseDatabase.off(registrationObj.key, registration);
        }
        delete this._tree[path][eventType][registration];
        delete this._reverseLookup[registration];
        return !!registrationObj;
    }
    /**