UNPKG

react-native-nitro-screen-recorder

Version:

A library to capture screen recordings with react-native powered by NitroModules.

54 lines (53 loc) 3.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.withBroadcastExtensionFiles = void 0; var _configPlugins = require("@expo/config-plugins"); var fs = _interopRequireWildcard(require("fs")); var path = _interopRequireWildcard(require("path")); var _iosConstants = require("../support/iosConstants"); var _FileManager = require("../support/FileManager"); var _BEUpdateManager = _interopRequireDefault(require("../support/BEUpdateManager")); var _ScreenRecorderLog = require("../support/ScreenRecorderLog"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); } const SAMPLE_HANDLER_FILE = 'SampleHandler.swift'; /** * Copies the ReplayKit Broadcast Upload Extension templates into the iOS * project and patches them so their App Group + bundle versions match the * host app. Mirrors OneSignal's NSE flow for consistency. */ const withBroadcastExtensionFiles = (config, props) => { return (0, _configPlugins.withDangerousMod)(config, ['ios', async mod => { const iosPath = path.join(mod.modRequest.projectRoot, 'ios'); const sourceDir = path.join(__dirname, '..', 'support', 'broadcastExtensionFiles'); fs.mkdirSync(`${iosPath}/${_iosConstants.BROADCAST_EXT_TARGET_NAME}`, { recursive: true }); for (const extFile of _iosConstants.BROADCAST_EXT_ALL_FILES) { const targetFile = `${iosPath}/${_iosConstants.BROADCAST_EXT_TARGET_NAME}/${extFile}`; await _FileManager.FileManager.copyFile(`${sourceDir}/${extFile}`, targetFile); } const sourceSamplePath = `${sourceDir}/${SAMPLE_HANDLER_FILE}`; const targetSamplePath = `${iosPath}/${_iosConstants.BROADCAST_EXT_TARGET_NAME}/${SAMPLE_HANDLER_FILE}`; await _FileManager.FileManager.copyFile(sourceSamplePath, targetSamplePath); _ScreenRecorderLog.ScreenRecorderLog.log(`Copied broadcast extension files to ${iosPath}/${_iosConstants.BROADCAST_EXT_TARGET_NAME}`); /* ------------------------------------------------------------ */ /* 2️⃣ Patch entitlements & Info.plist placeholders */ /* ------------------------------------------------------------ */ const updater = new _BEUpdateManager.default(iosPath); const mainAppBundleId = mod.ios?.bundleIdentifier; if (!mainAppBundleId) { throw new Error('Failed to find main app bundle id!'); } const groupIdentifier = (0, _iosConstants.getAppGroup)(mainAppBundleId, props); await updater.updateEntitlements(groupIdentifier); await updater.updateInfoPlist(mod.ios?.buildNumber ?? _iosConstants.DEFAULT_BUNDLE_VERSION, groupIdentifier); await updater.updateBundleShortVersion(mod.version ?? _iosConstants.DEFAULT_BUNDLE_SHORT_VERSION); _ScreenRecorderLog.ScreenRecorderLog.log('Patched broadcast extension entitlements and Info.plist with app group and version values.'); return mod; }]); }; exports.withBroadcastExtensionFiles = withBroadcastExtensionFiles; //# sourceMappingURL=withBroadcastExtensionFiles.js.map