UNPKG

theta-client-react-native

Version:

This library provides a way to control RICOH THETA using.

713 lines (661 loc) 21.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.cancelVideoConvert = cancelVideoConvert; exports.convertVideoFormats = convertVideoFormats; exports.deleteAccessPoint = deleteAccessPoint; exports.deleteAllFiles = deleteAllFiles; exports.deleteAllImageFiles = deleteAllImageFiles; exports.deleteAllVideoFiles = deleteAllVideoFiles; exports.deleteFiles = deleteFiles; exports.deleteMySetting = deleteMySetting; exports.finishWlan = finishWlan; exports.getBurstCaptureBuilder = getBurstCaptureBuilder; exports.getCompositeIntervalCaptureBuilder = getCompositeIntervalCaptureBuilder; exports.getContinuousCaptureBuilder = getContinuousCaptureBuilder; exports.getEventWebSocket = getEventWebSocket; exports.getLimitlessIntervalCaptureBuilder = getLimitlessIntervalCaptureBuilder; exports.getLivePreview = getLivePreview; exports.getMetadata = getMetadata; exports.getMultiBracketCaptureBuilder = getMultiBracketCaptureBuilder; exports.getMySetting = getMySetting; exports.getMySettingFromOldModel = getMySettingFromOldModel; exports.getOptions = getOptions; exports.getPhotoCaptureBuilder = getPhotoCaptureBuilder; exports.getPluginLicense = getPluginLicense; exports.getPluginOrders = getPluginOrders; exports.getShotCountSpecifiedIntervalCaptureBuilder = getShotCountSpecifiedIntervalCaptureBuilder; exports.getThetaInfo = getThetaInfo; exports.getThetaLicense = getThetaLicense; exports.getThetaModel = getThetaModel; exports.getThetaState = getThetaState; exports.getTimeShiftCaptureBuilder = getTimeShiftCaptureBuilder; exports.getTimeShiftManualCaptureBuilder = getTimeShiftManualCaptureBuilder; exports.getVideoCaptureBuilder = getVideoCaptureBuilder; exports.initialize = initialize; exports.isInitialized = isInitialized; exports.listAccessPoints = listAccessPoints; exports.listFiles = listFiles; exports.listPlugins = listPlugins; exports.reboot = reboot; exports.reset = reset; exports.restoreSettings = restoreSettings; exports.setAccessPointConnectionPriority = setAccessPointConnectionPriority; exports.setAccessPointDynamically = setAccessPointDynamically; exports.setAccessPointStatically = setAccessPointStatically; exports.setApiLogListener = setApiLogListener; exports.setBluetoothDevice = setBluetoothDevice; exports.setMySetting = setMySetting; exports.setOptions = setOptions; exports.setPlugin = setPlugin; exports.setPluginOrders = setPluginOrders; exports.startPlugin = startPlugin; exports.stopLivePreview = stopLivePreview; exports.stopPlugin = stopPlugin; exports.stopSelfTimer = stopSelfTimer; var _reactNative = require("react-native"); var _capture = require("../capture"); var _notifyController = require("./notify-controller"); var _eventWebsocket = require("./event-websocket"); var _libs = require("./libs"); const ThetaClientReactNative = _reactNative.NativeModules.ThetaClientReactNative; const NOTIFY_API_LOG = 'API-LOG'; let apiLogListener; async function setNotifyApiLogListener(listener) { if (listener) { _notifyController.NotifyController.instance.addNotify(NOTIFY_API_LOG, event => { listener(event.params.message); }); } else { _notifyController.NotifyController.instance.removeNotify(NOTIFY_API_LOG); } await ThetaClientReactNative.setApiLogListener(listener != null); } /** * Set up a log listener for THETA API calls * * @param listener Called when there is a THETA API request and response; if undefined, unregister. */ async function setApiLogListener(listener) { if (!_notifyController.NotifyController.instance.isInit()) { _notifyController.NotifyController.instance.init(); } apiLogListener = listener; await setNotifyApiLogListener(apiLogListener); } /** * initialize theta client sdk * * @function initialize * @param {string} endPoint optional endpoint of camera * @param {ThetaConfig} config Configuration of initialize. If null, get from THETA. * @param {ThetaTimeout} timeout Timeout of HTTP call. * @return promise of boolean result **/ async function initialize(endPoint = 'http://192.168.1.1', config, timeout) { _notifyController.NotifyController.instance.init(); if (apiLogListener) { await setNotifyApiLogListener(apiLogListener); } return ThetaClientReactNative.initialize(endPoint, config, timeout); } /** * Returns whether it is initialized or not. * * @function isInitialized * @return promise of boolean result **/ function isInitialized() { return ThetaClientReactNative.isInitialized(); } /** * Turn off/on (reboot) the camera. * Supported models are THETA A1 only. * * Error when connecting in CL mode for Japan-bound models only * * @function reboot * @return promise */ function reboot() { return ThetaClientReactNative.reboot(); } /** * Reset all device settings and capture settings. * After reset, the camera will be restarted. * * @function reset * @return promise of boolean result */ function reset() { return ThetaClientReactNative.reset(); } /** * Get PhotoCaptureBuilder for take a picture. * * @function getPhotoCaptureBuilder * @return created PhotoCaptureBuilder */ function getPhotoCaptureBuilder() { return new _capture.PhotoCaptureBuilder(); } /** * Get TimeShiftCaptureBuilder for time-shift. * * @function getTimeShiftCaptureBuilder * @return created TimeShiftCaptureBuilder */ function getTimeShiftCaptureBuilder() { return new _capture.TimeShiftCaptureBuilder(); } /** * Get TimeShiftManualCaptureBuilder for manual time-shift. * * @function getTimeShiftManualCaptureBuilder * @return created TimeShiftManualCaptureBuilder */ function getTimeShiftManualCaptureBuilder() { return new _capture.TimeShiftManualCaptureBuilder(); } /** * Get VideoCapture.Builder for capture video. * * @function getVideoCaptureBuilder * @return created VideoCaptureBuilder instance */ function getVideoCaptureBuilder() { return new _capture.VideoCaptureBuilder(); } /** * Get LimitlessIntervalCapture.Builder for take limitless interval shooting. * * @function getLimitlessIntervalCaptureBuilder * @return created LimitlessIntervalCaptureBuilder instance */ function getLimitlessIntervalCaptureBuilder() { return new _capture.LimitlessIntervalCaptureBuilder(); } /** * Get ShotCountSpecifiedIntervalCapture.Builder for take interval shooting with the shot count specified. * * @function getShotCountSpecifiedIntervalCaptureBuilder * @param {shotCount} shot count specified * @return created ShotCountSpecifiedIntervalCaptureBuilder instance */ function getShotCountSpecifiedIntervalCaptureBuilder(shotCount) { return new _capture.ShotCountSpecifiedIntervalCaptureBuilder(shotCount); } /** * Get CompositeIntervalCapture.Builder for take interval composite shooting. * * @function getCompositeIntervalCaptureBuilder * @param {shootingTimeSec} Shooting time for interval composite shooting (sec) * @return created CompositeIntervalCaptureBuilder instance */ function getCompositeIntervalCaptureBuilder(shootingTimeSec) { return new _capture.CompositeIntervalCaptureBuilder(shootingTimeSec); } /** * Get BurstCapture.Builder for take burst shooting. * * @function getBurstCaptureBuilder * @param burstOption Burst shooting setting. * @return created BurstCaptureBuilder instance */ function getBurstCaptureBuilder(burstCaptureNum, burstBracketStep, burstCompensation, burstMaxExposureTime, burstEnableIsoControl, burstOrder) { return new _capture.BurstCaptureBuilder(burstCaptureNum, burstBracketStep, burstCompensation, burstMaxExposureTime, burstEnableIsoControl, burstOrder); } /** * Get MultiBracketCapture.Builder for take multi bracket shooting. * * @function getMultiBracketCaptureBuilder * @return created MultiBracketCaptureBuilder instance */ function getMultiBracketCaptureBuilder() { return new _capture.MultiBracketCaptureBuilder(); } /** * Get ContinuousCapture.Builder for take limitless interval shooting. * * @function getContinuousCaptureBuilder * @return created ContinuousCaptureBuilder instance */ function getContinuousCaptureBuilder() { return new _capture.ContinuousCaptureBuilder(); } /** * Start live preview. * preview frame (JPEG DataURL) send THETA_EVENT_NAME event as * { * "data": "DataURL of JPEG Frame" * } * * @function StartLivePreview * @return promise of boolean result */ function getLivePreview() { return ThetaClientReactNative.getLivePreview(); } /** * Stop live preview. * * @function StopLivePreview * @return promise of boolean result */ function stopLivePreview() { return ThetaClientReactNative.stopLivePreview(); } /** * Restore setting to THETA * * @function restoreSettings * @return promise of boolean result */ function restoreSettings() { return ThetaClientReactNative.restoreSettings(); } /** * Stop running self-timer. * * @function stopSelfTimer * @return promise of boolean result */ function stopSelfTimer() { return ThetaClientReactNative.stopSelfTimer(); } /** * Converts the movie format of a saved movie. * * @function convertVideoFormats * @param {string} fileUrl URL of a saved movie file to convert * @param {boolean} toLowResolution If true generates lower resolution * video, otherwise same resolution. * @param {boolean} applyTopBottomCorrection apply Top/bottom * correction. This parameter is ignored on Theta X. * @param onProgress the block for convertVideoFormats progress * @return promise of URL of a converted movie file. */ function convertVideoFormats(fileUrl, toLowResolution, applyTopBottomCorrection, onProgress) { return (0, _libs.convertVideoFormatsImpl)(fileUrl, toLowResolution, applyTopBottomCorrection, onProgress); } /** * Cancels the movie format conversion. * * @function cancelVideoConvert * @return promise of boolean result */ function cancelVideoConvert() { return ThetaClientReactNative.cancelVideoConvert(); } /** * Turns the wireless LAN off. * * @function finishWlan * @return promise of boolean result */ function finishWlan() { return ThetaClientReactNative.finishWlan(); } /** * Registers identification information (UUID) of a BLE device. * * @function setBluetoothDevice * @param {string} uuid UUID of the BLE device to set. * @return promise of String result */ function setBluetoothDevice(uuid) { return ThetaClientReactNative.setBluetoothDevice(uuid); } /** * Returns the connected THETA model. * * @function getThetaModel * @return promise of THETA model **/ function getThetaModel() { return new Promise(async (resolve, reject) => { await ThetaClientReactNative.getThetaModel().then(result => { resolve(result ?? undefined); }).catch(error => { reject(error); }); }); } /** * Get basic information about Theta. * * @function getThetaInfo * @return promise of ThetaInfo **/ function getThetaInfo() { return ThetaClientReactNative.getThetaInfo(); } /** * Acquires open source license information related to the camera. * * @function getThetaLicense * @return Promise of string result, HTML string of the license. */ function getThetaLicense() { return ThetaClientReactNative.getThetaLicense(); } /** * Get current state of Theta. * * @function getThetaState * @return promise of ThetaState **/ function getThetaState() { return ThetaClientReactNative.getThetaState(); } /** * Lists information of images and videos in Theta. * * @function listFiles * @param {FileTypeEnum} fileType Type of the files to be listed. * @param {number} startPosition The position of the first file to be * returned in the list. 0 represents the first file. If * startPosition is larger than the position of the last file, an * empty list is returned. * @param {number} entryCount Desired number of entries to return. If * entryCount is more than the number of remaining files, just * return entries of actual remaining files. * @param {StorageEnum} storage Desired storage. If omitted, return current storage. (RICOH THETA X Version 2.00.0 or later) * @return promise with a list of file information and number of totalEntries. * see [camera.listFiles](https://github.com/ricohapi/theta-api-specs/blob/main/theta-web-api-v2.1/commands/camera.list_files.md). */ function listFiles(fileTypeEnum, startPosition = 0, entryCount, storage) { return ThetaClientReactNative.listFiles(fileTypeEnum, startPosition, entryCount, storage); } /** * Delete files in Theta. * * @function deleteFiles * @param {string[]} fileUrls URLs of the file to be deleted. * @return promise of boolean result */ function deleteFiles(fileUrls) { return ThetaClientReactNative.deleteFiles(fileUrls); } /** * Delete all files in Theta. * * @function deleteAllFiles * @return promise of boolean result */ function deleteAllFiles() { return ThetaClientReactNative.deleteAllFiles(); } /** * Delete all image files in Theta. * * @function deleteAllImageFiles * @return promise of boolean result */ function deleteAllImageFiles() { return ThetaClientReactNative.deleteAllImageFiles(); } /** * Delete all video files in Theta. * * @function deleteAllVideoFiles * @return promise of boolean result */ function deleteAllVideoFiles() { return ThetaClientReactNative.deleteAllVideoFiles(); } /** * Acquires the properties and property support specifications for * shooting, the camera, etc. * * @function getOptions * @param {OptionNameEnum[]} optionNames List of OptionNameEnum. * @return promise of Options acquired */ async function getOptions(optionNames) { const response = await ThetaClientReactNative.getOptions(optionNames); const { options, json } = response; const result = (0, _libs.convertOptions)(options, json); return result; } /** * Property settings for shooting, the camera, etc. * * @function setOptions * @param {Options} options Camera setting options. * @return promise of boolean result */ function setOptions(options) { return ThetaClientReactNative.setOptions(options); } /** * Get metadata of a still image * * @function getMetadata * @param {string} fileUrl URL of a still image file to get metadata * @return promise of MetaInfo */ function getMetadata(fileUrl) { return ThetaClientReactNative.getMetadata(fileUrl); } /** * Acquires the access point list used in client mode. * * @function listAccessPoints * @return promise of AccessPoint list */ function listAccessPoints() { return ThetaClientReactNative.listAccessPoints(); } /** * Set access point. IP address is set dynamically. * * @function setAccessPointDynamically * @param {string} ssid SSID of the access point. * @param {} params - Optional parameters for additional configuration. * @param {boolean} params.ssidStealth true if SSID stealth is enabled. * @param {AuthModeEnum} params.authMode Authentication mode. * @param {string} params.password Password. Not set if authMode is “NONE”. * @param {number} params.connectionPriority Connection priority 1 to 5. * @param {Proxy} params.proxy Proxy information to be used for the access point. * @return promise of boolean result */ function setAccessPointDynamically(ssid, params) { const { ssidStealth, authMode, password, connectionPriority, proxy } = params ?? {}; return ThetaClientReactNative.setAccessPointDynamically({ ssid, ssidStealth, authMode, password, connectionPriority, proxy }); } /** * Set access point. IP address is set statically. * * @function setAccessPointStatically * @param {string} ssid SSID of the access point. * @param {string} ipAddress IP address assigns to Theta. * @param {string} subnetMask Subnet mask. * @param {string} defaultGateway Default gateway. * @param {} params - Optional parameters for additional configuration. * @param {boolean} params.ssidStealth True if SSID stealth is enabled. * @param {AuthModeEnum} params.authMode Authentication mode. * @param {string} params.password Password. Not set if authMode is “NONE”. * @param {number} params.connectionPriority Connection priority 1 to 5. * @param {string} params.dns1 Primary DNS server. * @param {string} params.dns2 Secondary DNS server. * @param {Proxy} params.proxy Proxy information to be used for the access point. * @return promise of boolean result */ function setAccessPointStatically(ssid, ipAddress, subnetMask, defaultGateway, params) { const { ssidStealth, authMode, password, connectionPriority, dns1, dns2, proxy } = params ?? {}; return ThetaClientReactNative.setAccessPointStatically({ ssid, ssidStealth, authMode, password, connectionPriority, ipAddress, subnetMask, defaultGateway, dns1, dns2, proxy }); } /** * Updates the connection priority of the access point. * * @function setAccessPointConnectionPriority * @param {string} ssid SSID of the access point. * @param {number} connectionPriority Connection priority 1 to 5. * @param {boolean} ssidStealth True if SSID stealth is enabled. * @return promise of boolean result */ function setAccessPointConnectionPriority(ssid, connectionPriority, ssidStealth) { return ThetaClientReactNative.setAccessPointConnectionPriority(ssid, connectionPriority, ssidStealth); } /** * Deletes access point information used in client mode. * * @function deleteAccessPoint * @param {string} ssid SSID of the access point to delete. * @return promise of boolean result */ function deleteAccessPoint(ssid) { return ThetaClientReactNative.deleteAccessPoint(ssid); } /** * Acquires the shooting properties set by the camera._setMySetting command. * Just for Theta V and later. * * @function getMySetting * @param captureMode The target shooting mode * @returns Options of my setting */ function getMySetting(captureMode) { return ThetaClientReactNative.getMySetting(captureMode); } /** * Acquires the shooting properties set by the camera._setMySetting command. * Just for Theta S and SC. * * @function getMySetting * @param optionNames List of option names to acquire * @returns Options of my setting */ function getMySettingFromOldModel(optionNames) { return ThetaClientReactNative.getMySettingFromOldModel(optionNames); } /** * Registers shooting conditions in My Settings * @function setMySetting * @param captureMode The target shooting mode. RICOH THETA S and SC do not support My Settings in video capture mode. * @param options registered to My Settings * @returns Promise of boolean result, always true */ function setMySetting(captureMode, options) { return ThetaClientReactNative.setMySetting(captureMode, options); } /** * Delete shooting conditions in My Settings. Supported just by Theta X and Z1. * @param captureMode The target shooting mode * @returns Promise of boolean result, always true */ function deleteMySetting(captureMode) { return ThetaClientReactNative.deleteMySetting(captureMode); } /** * Acquires a list of installed plugins * @function listPlugins * @return A list of the plugins installed in Theta. */ function listPlugins() { return ThetaClientReactNative.listPlugins(); } /** * Sets the installed plugin for boot. Supported just by Theta V. * @function setPlugin * @param packageName Package name of the target plugin. * @return Promise of boolean result, always true. */ function setPlugin(packageName) { return ThetaClientReactNative.setPlugin(packageName); } /** * Start the plugin specified by the [packageName]. * @function startPlugin * @param packageName Package name of the target plugin. * @return Promise of boolean result, always true. */ function startPlugin(packageName) { return ThetaClientReactNative.startPlugin(packageName); } /** * Stop the running plugin. * @function stopPlugin * @return Promise of boolean result, always true. */ function stopPlugin() { return ThetaClientReactNative.stopPlugin(); } /** * Acquires the license for the installed plugin. * @function getPluginLicense * @param packageName Package name of the target plugin. * @return Promise of string result, HTML string of the license. */ function getPluginLicense(packageName) { return ThetaClientReactNative.getPluginLicense(packageName); } /** * Return the plugin orders. Supported just by Theta X and Z1. * @function getPluginOrders * @return Promise of string[] result, list of package names of plugins. */ function getPluginOrders() { return ThetaClientReactNative.getPluginOrders(); } /** * Sets the plugin orders. Supported just by Theta X and Z1. * @function setPluginOrders * @param plugins list of package names of plugins. * For Z1, list size must be three. No restrictions for the size for X. * When not specifying, set an empty string. * If an empty string is placed mid-way, it will be moved to the front. * Specifying zero package name will result in an error * @return Promise of boolean result, always true. */ function setPluginOrders(plugins) { return ThetaClientReactNative.setPluginOrders(plugins); } function getEventWebSocket() { return new Promise(async (resolve, reject) => { ThetaClientReactNative.getEventWebSocket().then(() => { resolve(new _eventWebsocket.EventWebSocket(_notifyController.NotifyController.instance)); }).catch(error => { reject(error); }); }); } //# sourceMappingURL=theta-repository.js.map