@vxrn/vite-plugin-metro 1.25.5 → 1.25.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/babel-plugins/import-meta-env-plugin.cjs +130 -0
- package/dist/cjs/babel-plugins/import-meta-env-plugin.native.js +138 -0
- package/dist/cjs/babel-plugins/import-meta-env-plugin.native.js.map +1 -0
- package/dist/cjs/env/platformEnv.cjs +76 -0
- package/dist/cjs/env/platformEnv.native.js +98 -0
- package/dist/cjs/env/platformEnv.native.js.map +1 -0
- package/dist/cjs/index.cjs +41 -0
- package/dist/cjs/index.native.js +44 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/metro-config/getMetroBabelConfigFromViteConfig.cjs +62 -0
- package/dist/cjs/metro-config/getMetroBabelConfigFromViteConfig.native.js +109 -0
- package/dist/cjs/metro-config/getMetroBabelConfigFromViteConfig.native.js.map +1 -0
- package/dist/cjs/metro-config/getMetroConfigFromViteConfig.cjs +270 -0
- package/dist/cjs/metro-config/getMetroConfigFromViteConfig.native.js +284 -0
- package/dist/cjs/metro-config/getMetroConfigFromViteConfig.native.js.map +1 -0
- package/dist/cjs/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.cjs +55 -0
- package/dist/cjs/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.native.js +59 -0
- package/dist/cjs/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.native.js.map +1 -0
- package/dist/cjs/metro-config/types.cjs +18 -0
- package/dist/cjs/metro-config/types.native.js +21 -0
- package/dist/cjs/metro-config/types.native.js.map +1 -0
- package/dist/cjs/plugins/expoManifestRequestHandlerPlugin.cjs +71 -0
- package/dist/cjs/plugins/expoManifestRequestHandlerPlugin.native.js +82 -0
- package/dist/cjs/plugins/expoManifestRequestHandlerPlugin.native.js.map +1 -0
- package/dist/cjs/plugins/metroPlugin.cjs +272 -0
- package/dist/cjs/plugins/metroPlugin.native.js +281 -0
- package/dist/cjs/plugins/metroPlugin.native.js.map +1 -0
- package/dist/cjs/rn-commands/bundle/assetCatalogIOS.cjs +90 -0
- package/dist/cjs/rn-commands/bundle/assetCatalogIOS.native.js +135 -0
- package/dist/cjs/rn-commands/bundle/assetCatalogIOS.native.js.map +1 -0
- package/dist/cjs/rn-commands/bundle/assetPathUtils.cjs +74 -0
- package/dist/cjs/rn-commands/bundle/assetPathUtils.native.js +77 -0
- package/dist/cjs/rn-commands/bundle/assetPathUtils.native.js.map +1 -0
- package/dist/cjs/rn-commands/bundle/buildBundle.cjs +62 -0
- package/dist/cjs/rn-commands/bundle/buildBundle.native.js +67 -0
- package/dist/cjs/rn-commands/bundle/buildBundle.native.js.map +1 -0
- package/dist/cjs/rn-commands/bundle/buildBundleWithConfig.cjs +87 -0
- package/dist/cjs/rn-commands/bundle/buildBundleWithConfig.native.js +94 -0
- package/dist/cjs/rn-commands/bundle/buildBundleWithConfig.native.js.map +1 -0
- package/dist/cjs/rn-commands/bundle/filterPlatformAssetScales.cjs +51 -0
- package/dist/cjs/rn-commands/bundle/filterPlatformAssetScales.native.js +75 -0
- package/dist/cjs/rn-commands/bundle/filterPlatformAssetScales.native.js.map +1 -0
- package/dist/cjs/rn-commands/bundle/getAssetDestPathAndroid.cjs +46 -0
- package/dist/cjs/rn-commands/bundle/getAssetDestPathAndroid.native.js +49 -0
- package/dist/cjs/rn-commands/bundle/getAssetDestPathAndroid.native.js.map +1 -0
- package/dist/cjs/rn-commands/bundle/getAssetDestPathIOS.cjs +49 -0
- package/dist/cjs/rn-commands/bundle/getAssetDestPathIOS.native.js +52 -0
- package/dist/cjs/rn-commands/bundle/getAssetDestPathIOS.native.js.map +1 -0
- package/dist/cjs/rn-commands/bundle/getBuildBundleFn.cjs +45 -0
- package/dist/cjs/rn-commands/bundle/getBuildBundleFn.native.js +48 -0
- package/dist/cjs/rn-commands/bundle/getBuildBundleFn.native.js.map +1 -0
- package/dist/cjs/rn-commands/bundle/index.cjs +30 -0
- package/dist/cjs/rn-commands/bundle/index.native.js +33 -0
- package/dist/cjs/rn-commands/bundle/index.native.js.map +1 -0
- package/dist/cjs/rn-commands/bundle/saveAssets.cjs +121 -0
- package/dist/cjs/rn-commands/bundle/saveAssets.native.js +143 -0
- package/dist/cjs/rn-commands/bundle/saveAssets.native.js.map +1 -0
- package/dist/cjs/rn-commands/bundle/types.cjs +18 -0
- package/dist/cjs/rn-commands/bundle/types.native.js +21 -0
- package/dist/cjs/rn-commands/bundle/types.native.js.map +1 -0
- package/dist/cjs/rn-commands/index.cjs +39 -0
- package/dist/cjs/rn-commands/index.native.js +42 -0
- package/dist/cjs/rn-commands/index.native.js.map +1 -0
- package/dist/cjs/transformer/babel-core.cjs +30 -0
- package/dist/cjs/transformer/babel-core.native.js +33 -0
- package/dist/cjs/transformer/babel-core.native.js.map +1 -0
- package/dist/cjs/transformer/babel-transformer.cjs +176 -0
- package/dist/cjs/transformer/babel-transformer.native.js +186 -0
- package/dist/cjs/transformer/babel-transformer.native.js.map +1 -0
- package/dist/cjs/transformer/loadBabelConfig.cjs +64 -0
- package/dist/cjs/transformer/loadBabelConfig.native.js +70 -0
- package/dist/cjs/transformer/loadBabelConfig.native.js.map +1 -0
- package/dist/cjs/transformer/transformSync.cjs +85 -0
- package/dist/cjs/transformer/transformSync.native.js +91 -0
- package/dist/cjs/transformer/transformSync.native.js.map +1 -0
- package/dist/cjs/transformer/transformSync.test.cjs +36 -0
- package/dist/cjs/transformer/transformSync.test.native.js +49 -0
- package/dist/cjs/transformer/transformSync.test.native.js.map +1 -0
- package/dist/cjs/transformer/types.cjs +18 -0
- package/dist/cjs/transformer/types.native.js +21 -0
- package/dist/cjs/transformer/types.native.js.map +1 -0
- package/dist/cjs/utils/exit.cjs +174 -0
- package/dist/cjs/utils/exit.native.js +281 -0
- package/dist/cjs/utils/exit.native.js.map +1 -0
- package/dist/cjs/utils/getTerminalReporter.cjs +64 -0
- package/dist/cjs/utils/getTerminalReporter.native.js +70 -0
- package/dist/cjs/utils/getTerminalReporter.native.js.map +1 -0
- package/dist/cjs/utils/metroCacheManager.cjs +125 -0
- package/dist/cjs/utils/metroCacheManager.native.js +148 -0
- package/dist/cjs/utils/metroCacheManager.native.js.map +1 -0
- package/dist/cjs/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.cjs +39 -0
- package/dist/cjs/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.native.js +42 -0
- package/dist/cjs/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.native.js.map +1 -0
- package/dist/cjs/utils/projectImport.cjs +72 -0
- package/dist/cjs/utils/projectImport.native.js +83 -0
- package/dist/cjs/utils/projectImport.native.js.map +1 -0
- package/dist/esm/babel-plugins/import-meta-env-plugin.mjs +93 -0
- package/dist/esm/babel-plugins/import-meta-env-plugin.mjs.map +1 -0
- package/dist/esm/babel-plugins/import-meta-env-plugin.native.js +98 -0
- package/dist/esm/babel-plugins/import-meta-env-plugin.native.js.map +1 -0
- package/dist/esm/env/platformEnv.mjs +49 -0
- package/dist/esm/env/platformEnv.mjs.map +1 -0
- package/dist/esm/env/platformEnv.native.js +68 -0
- package/dist/esm/env/platformEnv.native.js.map +1 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +8 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +8 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/metro-config/getMetroBabelConfigFromViteConfig.mjs +37 -0
- package/dist/esm/metro-config/getMetroBabelConfigFromViteConfig.mjs.map +1 -0
- package/dist/esm/metro-config/getMetroBabelConfigFromViteConfig.native.js +81 -0
- package/dist/esm/metro-config/getMetroBabelConfigFromViteConfig.native.js.map +1 -0
- package/dist/esm/metro-config/getMetroConfigFromViteConfig.mjs +233 -0
- package/dist/esm/metro-config/getMetroConfigFromViteConfig.mjs.map +1 -0
- package/dist/esm/metro-config/getMetroConfigFromViteConfig.native.js +244 -0
- package/dist/esm/metro-config/getMetroConfigFromViteConfig.native.js.map +1 -0
- package/dist/esm/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.mjs +30 -0
- package/dist/esm/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.mjs.map +1 -0
- package/dist/esm/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.native.js +31 -0
- package/dist/esm/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.native.js.map +1 -0
- package/dist/esm/metro-config/types.mjs +2 -0
- package/dist/esm/metro-config/types.mjs.map +1 -0
- package/dist/esm/metro-config/types.native.js +2 -0
- package/dist/esm/metro-config/types.native.js.map +1 -0
- package/dist/esm/plugins/expoManifestRequestHandlerPlugin.mjs +46 -0
- package/dist/esm/plugins/expoManifestRequestHandlerPlugin.mjs.map +1 -0
- package/dist/esm/plugins/expoManifestRequestHandlerPlugin.native.js +54 -0
- package/dist/esm/plugins/expoManifestRequestHandlerPlugin.native.js.map +1 -0
- package/dist/esm/plugins/metroPlugin.mjs +236 -0
- package/dist/esm/plugins/metroPlugin.mjs.map +1 -0
- package/dist/esm/plugins/metroPlugin.native.js +242 -0
- package/dist/esm/plugins/metroPlugin.native.js.map +1 -0
- package/dist/esm/rn-commands/bundle/assetCatalogIOS.mjs +51 -0
- package/dist/esm/rn-commands/bundle/assetCatalogIOS.mjs.map +1 -0
- package/dist/esm/rn-commands/bundle/assetCatalogIOS.native.js +93 -0
- package/dist/esm/rn-commands/bundle/assetCatalogIOS.native.js.map +1 -0
- package/dist/esm/rn-commands/bundle/assetPathUtils.mjs +49 -0
- package/dist/esm/rn-commands/bundle/assetPathUtils.mjs.map +1 -0
- package/dist/esm/rn-commands/bundle/assetPathUtils.native.js +49 -0
- package/dist/esm/rn-commands/bundle/assetPathUtils.native.js.map +1 -0
- package/dist/esm/rn-commands/bundle/buildBundle.mjs +37 -0
- package/dist/esm/rn-commands/bundle/buildBundle.mjs.map +1 -0
- package/dist/esm/rn-commands/bundle/buildBundle.native.js +39 -0
- package/dist/esm/rn-commands/bundle/buildBundle.native.js.map +1 -0
- package/dist/esm/rn-commands/bundle/buildBundleWithConfig.mjs +51 -0
- package/dist/esm/rn-commands/bundle/buildBundleWithConfig.mjs.map +1 -0
- package/dist/esm/rn-commands/bundle/buildBundleWithConfig.native.js +55 -0
- package/dist/esm/rn-commands/bundle/buildBundleWithConfig.native.js.map +1 -0
- package/dist/esm/rn-commands/bundle/filterPlatformAssetScales.mjs +26 -0
- package/dist/esm/rn-commands/bundle/filterPlatformAssetScales.mjs.map +1 -0
- package/dist/esm/rn-commands/bundle/filterPlatformAssetScales.native.js +47 -0
- package/dist/esm/rn-commands/bundle/filterPlatformAssetScales.native.js.map +1 -0
- package/dist/esm/rn-commands/bundle/getAssetDestPathAndroid.mjs +10 -0
- package/dist/esm/rn-commands/bundle/getAssetDestPathAndroid.mjs.map +1 -0
- package/dist/esm/rn-commands/bundle/getAssetDestPathAndroid.native.js +10 -0
- package/dist/esm/rn-commands/bundle/getAssetDestPathAndroid.native.js.map +1 -0
- package/dist/esm/rn-commands/bundle/getAssetDestPathIOS.mjs +13 -0
- package/dist/esm/rn-commands/bundle/getAssetDestPathIOS.mjs.map +1 -0
- package/dist/esm/rn-commands/bundle/getAssetDestPathIOS.native.js +13 -0
- package/dist/esm/rn-commands/bundle/getAssetDestPathIOS.native.js.map +1 -0
- package/dist/esm/rn-commands/bundle/getBuildBundleFn.mjs +20 -0
- package/dist/esm/rn-commands/bundle/getBuildBundleFn.mjs.map +1 -0
- package/dist/esm/rn-commands/bundle/getBuildBundleFn.native.js +20 -0
- package/dist/esm/rn-commands/bundle/getBuildBundleFn.native.js.map +1 -0
- package/dist/esm/rn-commands/bundle/index.mjs +4 -0
- package/dist/esm/rn-commands/bundle/index.mjs.map +1 -0
- package/dist/esm/rn-commands/bundle/index.native.js +4 -0
- package/dist/esm/rn-commands/bundle/index.native.js.map +1 -0
- package/dist/esm/rn-commands/bundle/saveAssets.mjs +85 -0
- package/dist/esm/rn-commands/bundle/saveAssets.mjs.map +1 -0
- package/dist/esm/rn-commands/bundle/saveAssets.native.js +104 -0
- package/dist/esm/rn-commands/bundle/saveAssets.native.js.map +1 -0
- package/dist/esm/rn-commands/bundle/types.mjs +2 -0
- package/dist/esm/rn-commands/bundle/types.mjs.map +1 -0
- package/dist/esm/rn-commands/bundle/types.native.js +2 -0
- package/dist/esm/rn-commands/bundle/types.native.js.map +1 -0
- package/dist/esm/rn-commands/index.mjs +3 -0
- package/dist/esm/rn-commands/index.mjs.map +1 -0
- package/dist/esm/rn-commands/index.native.js +3 -0
- package/dist/esm/rn-commands/index.native.js.map +1 -0
- package/dist/esm/transformer/babel-core.mjs +3 -0
- package/dist/esm/transformer/babel-core.mjs.map +1 -0
- package/dist/esm/transformer/babel-core.native.js +3 -0
- package/dist/esm/transformer/babel-core.native.js.map +1 -0
- package/dist/esm/transformer/babel-transformer.mjs +148 -0
- package/dist/esm/transformer/babel-transformer.mjs.map +1 -0
- package/dist/esm/transformer/babel-transformer.native.js +160 -0
- package/dist/esm/transformer/babel-transformer.native.js.map +1 -0
- package/dist/esm/transformer/loadBabelConfig.mjs +28 -0
- package/dist/esm/transformer/loadBabelConfig.mjs.map +1 -0
- package/dist/esm/transformer/loadBabelConfig.native.js +31 -0
- package/dist/esm/transformer/loadBabelConfig.native.js.map +1 -0
- package/dist/esm/transformer/transformSync.mjs +49 -0
- package/dist/esm/transformer/transformSync.mjs.map +1 -0
- package/dist/esm/transformer/transformSync.native.js +52 -0
- package/dist/esm/transformer/transformSync.native.js.map +1 -0
- package/dist/esm/transformer/transformSync.test.mjs +37 -0
- package/dist/esm/transformer/transformSync.test.mjs.map +1 -0
- package/dist/esm/transformer/transformSync.test.native.js +47 -0
- package/dist/esm/transformer/transformSync.test.native.js.map +1 -0
- package/dist/esm/transformer/types.mjs +2 -0
- package/dist/esm/transformer/types.mjs.map +1 -0
- package/dist/esm/transformer/types.native.js +2 -0
- package/dist/esm/transformer/types.native.js.map +1 -0
- package/dist/esm/utils/exit.mjs +135 -0
- package/dist/esm/utils/exit.mjs.map +1 -0
- package/dist/esm/utils/exit.native.js +239 -0
- package/dist/esm/utils/exit.native.js.map +1 -0
- package/dist/esm/utils/getTerminalReporter.mjs +28 -0
- package/dist/esm/utils/getTerminalReporter.mjs.map +1 -0
- package/dist/esm/utils/getTerminalReporter.native.js +31 -0
- package/dist/esm/utils/getTerminalReporter.native.js.map +1 -0
- package/dist/esm/utils/metroCacheManager.mjs +100 -0
- package/dist/esm/utils/metroCacheManager.mjs.map +1 -0
- package/dist/esm/utils/metroCacheManager.native.js +120 -0
- package/dist/esm/utils/metroCacheManager.native.js.map +1 -0
- package/dist/esm/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.mjs +14 -0
- package/dist/esm/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.mjs.map +1 -0
- package/dist/esm/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.native.js +14 -0
- package/dist/esm/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.native.js.map +1 -0
- package/dist/esm/utils/projectImport.mjs +34 -0
- package/dist/esm/utils/projectImport.mjs.map +1 -0
- package/dist/esm/utils/projectImport.native.js +42 -0
- package/dist/esm/utils/projectImport.native.js.map +1 -0
- package/package.json +3 -3
- package/types/babel-plugins/import-meta-env-plugin.d.ts.map +1 -0
- package/types/env/platformEnv.d.ts.map +1 -0
- package/types/index.d.ts.map +1 -0
- package/types/metro-config/getMetroBabelConfigFromViteConfig.d.ts.map +1 -0
- package/types/metro-config/getMetroConfigFromViteConfig.d.ts.map +1 -0
- package/types/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.d.ts.map +1 -0
- package/types/metro-config/types.d.ts.map +1 -0
- package/types/plugins/expoManifestRequestHandlerPlugin.d.ts.map +1 -0
- package/types/plugins/metroPlugin.d.ts.map +1 -0
- package/types/rn-commands/bundle/assetCatalogIOS.d.ts.map +1 -0
- package/types/rn-commands/bundle/assetPathUtils.d.ts.map +1 -0
- package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -0
- package/types/rn-commands/bundle/buildBundleWithConfig.d.ts.map +1 -0
- package/types/rn-commands/bundle/filterPlatformAssetScales.d.ts.map +1 -0
- package/types/rn-commands/bundle/getAssetDestPathAndroid.d.ts.map +1 -0
- package/types/rn-commands/bundle/getAssetDestPathIOS.d.ts.map +1 -0
- package/types/rn-commands/bundle/getBuildBundleFn.d.ts.map +1 -0
- package/types/rn-commands/bundle/index.d.ts.map +1 -0
- package/types/rn-commands/bundle/saveAssets.d.ts.map +1 -0
- package/types/rn-commands/bundle/types.d.ts.map +1 -0
- package/types/rn-commands/index.d.ts.map +1 -0
- package/types/transformer/babel-core.d.ts.map +1 -0
- package/types/transformer/babel-transformer.d.ts.map +1 -0
- package/types/transformer/loadBabelConfig.d.ts.map +1 -0
- package/types/transformer/transformSync.d.ts.map +1 -0
- package/types/transformer/transformSync.test.d.ts.map +1 -0
- package/types/transformer/types.d.ts.map +1 -0
- package/types/utils/exit.d.ts.map +1 -0
- package/types/utils/getTerminalReporter.d.ts.map +1 -0
- package/types/utils/metroCacheManager.d.ts.map +1 -0
- package/types/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.d.ts.map +1 -0
- package/types/utils/projectImport.d.ts.map +1 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
34
|
+
var transformSync_exports = {};
|
|
35
|
+
__export(transformSync_exports, {
|
|
36
|
+
transformSync: () => transformSync
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(transformSync_exports);
|
|
39
|
+
var babel = __toESM(require("./babel-core.cjs"), 1);
|
|
40
|
+
function isTypeScriptSource(fileName) {
|
|
41
|
+
return fileName?.endsWith(".ts");
|
|
42
|
+
}
|
|
43
|
+
function isTSXSource(fileName) {
|
|
44
|
+
return fileName?.endsWith(".tsx");
|
|
45
|
+
}
|
|
46
|
+
function transformSync(src, babelConfig, {
|
|
47
|
+
hermesParser
|
|
48
|
+
}) {
|
|
49
|
+
const loadedBabelConfig = babel.loadOptions(babelConfig);
|
|
50
|
+
if (!loadedBabelConfig) return null;
|
|
51
|
+
let hasWorkletsPlugin = false;
|
|
52
|
+
loadedBabelConfig.plugins = loadedBabelConfig.plugins?.filter(plugin => {
|
|
53
|
+
const workletsPlugin = plugin;
|
|
54
|
+
if (workletsPlugin.key !== "worklets") return true;
|
|
55
|
+
if (workletsPlugin.options && "workletizableModules" in workletsPlugin.options) {
|
|
56
|
+
throw new Error("[vxrn] `workletizableModules` was removed from react-native-worklets. use `importForwarding.moduleNames`.");
|
|
57
|
+
}
|
|
58
|
+
if (hasWorkletsPlugin) return false;
|
|
59
|
+
hasWorkletsPlugin = true;
|
|
60
|
+
return true;
|
|
61
|
+
});
|
|
62
|
+
const isTypeScript = isTypeScriptSource(loadedBabelConfig.filename ?? "") || isTSXSource(loadedBabelConfig.filename ?? "");
|
|
63
|
+
if (isTypeScript) {
|
|
64
|
+
return parseWithBabel(src, loadedBabelConfig);
|
|
65
|
+
}
|
|
66
|
+
if (!isTypeScript && (
|
|
67
|
+
// The Hermes parser doesn't support comments or babel proposals such as export default from, meaning it has lower compatibility with larger parts
|
|
68
|
+
// of the ecosystem.
|
|
69
|
+
// However, React Native ships with flow syntax that isn't supported in Babel so we need to use Hermes for those files.
|
|
70
|
+
// We can try to quickly detect if the file uses flow syntax by checking for the @flow pragma which is present in every React Native file.
|
|
71
|
+
hermesParser || src.includes(" @flow"))) {
|
|
72
|
+
return parseWithHermes(src, loadedBabelConfig);
|
|
73
|
+
}
|
|
74
|
+
return parseWithBabel(src, loadedBabelConfig);
|
|
75
|
+
}
|
|
76
|
+
function parseWithHermes(src, babelConfig) {
|
|
77
|
+
const sourceAst = require("hermes-parser").parse(src, {
|
|
78
|
+
babel: true,
|
|
79
|
+
sourceType: babelConfig.sourceType
|
|
80
|
+
});
|
|
81
|
+
return babel.transformFromAstSync(sourceAst, src, babelConfig);
|
|
82
|
+
}
|
|
83
|
+
function parseWithBabel(src, babelConfig) {
|
|
84
|
+
return babel.transformSync(src, babelConfig);
|
|
85
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: () => from[key],
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
36
|
+
var transformSync_exports = {};
|
|
37
|
+
__export(transformSync_exports, {
|
|
38
|
+
transformSync: () => transformSync
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(transformSync_exports);
|
|
41
|
+
var babel = __toESM(require("./babel-core.native.js"), 1);
|
|
42
|
+
function isTypeScriptSource(fileName) {
|
|
43
|
+
return fileName === null || fileName === void 0 ? void 0 : fileName.endsWith(".ts");
|
|
44
|
+
}
|
|
45
|
+
function isTSXSource(fileName) {
|
|
46
|
+
return fileName === null || fileName === void 0 ? void 0 : fileName.endsWith(".tsx");
|
|
47
|
+
}
|
|
48
|
+
function transformSync(src, babelConfig, param) {
|
|
49
|
+
var {
|
|
50
|
+
hermesParser
|
|
51
|
+
} = param;
|
|
52
|
+
var _loadedBabelConfig_filename, _loadedBabelConfig_filename1;
|
|
53
|
+
var _loadedBabelConfig_plugins;
|
|
54
|
+
var loadedBabelConfig = babel.loadOptions(babelConfig);
|
|
55
|
+
if (!loadedBabelConfig) return null;
|
|
56
|
+
var hasWorkletsPlugin = false;
|
|
57
|
+
loadedBabelConfig.plugins = (_loadedBabelConfig_plugins = loadedBabelConfig.plugins) === null || _loadedBabelConfig_plugins === void 0 ? void 0 : _loadedBabelConfig_plugins.filter(function (plugin) {
|
|
58
|
+
var workletsPlugin = plugin;
|
|
59
|
+
if (workletsPlugin.key !== "worklets") return true;
|
|
60
|
+
if (workletsPlugin.options && "workletizableModules" in workletsPlugin.options) {
|
|
61
|
+
throw new Error("[vxrn] `workletizableModules` was removed from react-native-worklets. use `importForwarding.moduleNames`.");
|
|
62
|
+
}
|
|
63
|
+
if (hasWorkletsPlugin) return false;
|
|
64
|
+
hasWorkletsPlugin = true;
|
|
65
|
+
return true;
|
|
66
|
+
});
|
|
67
|
+
var isTypeScript = isTypeScriptSource((_loadedBabelConfig_filename = loadedBabelConfig.filename) !== null && _loadedBabelConfig_filename !== void 0 ? _loadedBabelConfig_filename : "") || isTSXSource((_loadedBabelConfig_filename1 = loadedBabelConfig.filename) !== null && _loadedBabelConfig_filename1 !== void 0 ? _loadedBabelConfig_filename1 : "");
|
|
68
|
+
if (isTypeScript) {
|
|
69
|
+
return parseWithBabel(src, loadedBabelConfig);
|
|
70
|
+
}
|
|
71
|
+
if (!isTypeScript && (
|
|
72
|
+
// The Hermes parser doesn't support comments or babel proposals such as export default from, meaning it has lower compatibility with larger parts
|
|
73
|
+
// of the ecosystem.
|
|
74
|
+
// However, React Native ships with flow syntax that isn't supported in Babel so we need to use Hermes for those files.
|
|
75
|
+
// We can try to quickly detect if the file uses flow syntax by checking for the @flow pragma which is present in every React Native file.
|
|
76
|
+
hermesParser || src.includes(" @flow"))) {
|
|
77
|
+
return parseWithHermes(src, loadedBabelConfig);
|
|
78
|
+
}
|
|
79
|
+
return parseWithBabel(src, loadedBabelConfig);
|
|
80
|
+
}
|
|
81
|
+
function parseWithHermes(src, babelConfig) {
|
|
82
|
+
var sourceAst = require("hermes-parser").parse(src, {
|
|
83
|
+
babel: true,
|
|
84
|
+
sourceType: babelConfig.sourceType
|
|
85
|
+
});
|
|
86
|
+
return babel.transformFromAstSync(sourceAst, src, babelConfig);
|
|
87
|
+
}
|
|
88
|
+
function parseWithBabel(src, babelConfig) {
|
|
89
|
+
return babel.transformSync(src, babelConfig);
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=transformSync.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","transformSync_exports","__export","transformSync","module","exports","babel","__toESM","require","isTypeScriptSource","fileName","endsWith","isTSXSource","src","babelConfig","param","hermesParser","_loadedBabelConfig_filename","_loadedBabelConfig_filename1","_loadedBabelConfig_plugins","loadedBabelConfig","loadOptions","hasWorkletsPlugin","plugins","filter","plugin","workletsPlugin","key","options","Error","isTypeScript","filename","parseWithBabel","includes","parseWithHermes","sourceAst","parse","sourceType","transformFromAstSync"],"sources":["../../../src/transformer/transformSync.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,qBAAA;AAAAC,QAAA,CAAAD,qBAAA;EAAAE,aAAA,EAAAA,CAAA,KAAAA;AAAA;AAMAC,MAAA,CAAAC,OAAuB,GAAAT,YAAA,CAAAK,qBAAA;AAGvB,IAAAK,KAAS,GAAAC,OAAA,CAAAC,OAAA,CAAmB,wBAA2B;AACrD,SAAOC,kBAAUA,CAASC,QAAK;EACjC,OAAAA,QAAA,aAAAA,QAAA,uBAAAA,QAAA,CAAAC,QAAA;AAEA;AACE,SAAOC,WAAUA,CAAAF,QAAS;EAC5B,OAAAA,QAAA,aAAAA,QAAA,uBAAAA,QAAA,CAAAC,QAAA;AAEO;AAKL,SAAMR,cAAAU,GAAA,EAAoBC,WAAM,EAAAC,KAAA;EAAA,IAC9B;IAAAC;EAAA,IAAAD,KAAA;EACF,IAAAE,2BAAA,EAAAC,4BAAA;EACA,IAAIC,0BAAoB;EAIxB,IAAIC,iBAAA,GAAoBd,KAAA,CAAAe,WAAA,CAAAP,WAAA;EACxB,KAAAM,iBAAkB,SAAU;EAC1B,IAAAE,iBAAM,QAAiB;EAIvBF,iBAAI,CAAAG,OAAe,IAAQJ,0BAAmB,GAAAC,iBAAA,CAAAG,OAAA,cAAAJ,0BAAA,uBAAAA,0BAAA,CAAAK,MAAA,WAAAC,MAAA;IAC9C,IAAIC,cAAA,GAAeD,MAAA;IACjB,IAAAC,cAAU,CAAAC,GAAA;IAAA,IACRD,cAAA,CAAAE,OAAA,8BAAAF,cAAA,CAAAE,OAAA;MACF,UAAAC,KAAA;IACF;IACA,IAAIP,iBAAA,EAAmB,OAAO;IAC9BA,iBAAA,GAAoB;IACpB,OAAO;EACT,CAAC;EAED,IAAAQ,YAAM,GAAArB,kBACJ,EAAAQ,2BAAqC,GAAAG,iBACrC,CAAAW,QAAY,cAAkBd,2BAAc,cAAAA,2BAAA,UAAAL,WAAA,EAAAM,4BAAA,GAAAE,iBAAA,CAAAW,QAAA,cAAAb,4BAAA,cAAAA,4BAAA;EAE9C,IAAIY,YAAA,EAAc;IAChB,OAAOE,cAAA,CAAenB,GAAA,EAAKO,iBAAiB;EAC9C;EAEA,IACE,CAACU,YAAA;EAAA;EAAA;EAAA;EAAA;EAKAd,YAAA,IAAgBH,GAAA,CAAIoB,QAAA,CAAS,QAAQ,IACtC;IACA,OAAOC,eAAA,CAAgBrB,GAAA,EAAKO,iBAAiB;EAC/C;EAEA,OAAOY,cAAA,CAAenB,GAAA,EAAKO,iBAAiB;AAC9C;AAEA,SAASc,gBAAgBrB,GAAA,EAAaC,WAAA,EAAqC;EACzE,IAAAqB,SAAM,GAAA3B,OAAY,gBAAQ,EAAe4B,KAAE,CAAAvB,GAAM;IAC/CP,KAAA,EAAO;IACP+B,UAAA,EAAYvB,WAAA,CAAYuB;EAC1B,CAAC;EACD,OAAO/B,KAAA,CAAMgC,oBAAA,CAAqBH,SAAA,EAAWtB,GAAA,EAAKC,WAAW;AAC/D;AAEA,SAASkB,eAAenB,GAAA,EAAaC,WAAA,EAAqC;EACxE,OAAOR,KAAA,CAAMH,aAAA,CAAcU,GAAA,EAAKC,WAAW;AAC7C","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var import_vitest = require("vitest");
|
|
2
|
+
var import_transformSync = require("./transformSync.cjs");
|
|
3
|
+
const workletsPlugin = marker => () => ({
|
|
4
|
+
name: "worklets",
|
|
5
|
+
visitor: {
|
|
6
|
+
Program(_, state) {
|
|
7
|
+
const passes = state.file.metadata.workletsPasses ?? [];
|
|
8
|
+
state.file.metadata.workletsPasses = passes;
|
|
9
|
+
passes.push(marker);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
(0, import_vitest.describe)("transformSync", () => {
|
|
14
|
+
(0, import_vitest.it)("runs an app-configured Worklets plugin only once when a preset adds another", () => {
|
|
15
|
+
const result = (0, import_transformSync.transformSync)("export const value = 1", {
|
|
16
|
+
filename: "/project/input.ts",
|
|
17
|
+
babelrc: false,
|
|
18
|
+
configFile: false,
|
|
19
|
+
plugins: [workletsPlugin("app")],
|
|
20
|
+
presets: [() => ({
|
|
21
|
+
plugins: [workletsPlugin("preset")]
|
|
22
|
+
})]
|
|
23
|
+
}, {});
|
|
24
|
+
(0, import_vitest.expect)(result?.metadata?.workletsPasses).toEqual(["app"]);
|
|
25
|
+
});
|
|
26
|
+
(0, import_vitest.it)("rejects the removed workletizableModules option before transforming", () => {
|
|
27
|
+
(0, import_vitest.expect)(() => (0, import_transformSync.transformSync)("export const value = 1", {
|
|
28
|
+
filename: "/project/input.ts",
|
|
29
|
+
babelrc: false,
|
|
30
|
+
configFile: false,
|
|
31
|
+
plugins: [[workletsPlugin("app"), {
|
|
32
|
+
workletizableModules: ["remend"]
|
|
33
|
+
}]]
|
|
34
|
+
}, {})).toThrow("use `importForwarding.moduleNames`");
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var import_vitest = require("vitest");
|
|
4
|
+
var import_transformSync = require("./transformSync.native.js");
|
|
5
|
+
var workletsPlugin = function (marker) {
|
|
6
|
+
return function () {
|
|
7
|
+
return {
|
|
8
|
+
name: "worklets",
|
|
9
|
+
visitor: {
|
|
10
|
+
Program(_, state) {
|
|
11
|
+
var _state_file_metadata_workletsPasses;
|
|
12
|
+
var passes = (_state_file_metadata_workletsPasses = state.file.metadata.workletsPasses) !== null && _state_file_metadata_workletsPasses !== void 0 ? _state_file_metadata_workletsPasses : [];
|
|
13
|
+
state.file.metadata.workletsPasses = passes;
|
|
14
|
+
passes.push(marker);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
(0, import_vitest.describe)("transformSync", function () {
|
|
21
|
+
(0, import_vitest.it)("runs an app-configured Worklets plugin only once when a preset adds another", function () {
|
|
22
|
+
var _result_metadata;
|
|
23
|
+
var result = (0, import_transformSync.transformSync)("export const value = 1", {
|
|
24
|
+
filename: "/project/input.ts",
|
|
25
|
+
babelrc: false,
|
|
26
|
+
configFile: false,
|
|
27
|
+
plugins: [workletsPlugin("app")],
|
|
28
|
+
presets: [function () {
|
|
29
|
+
return {
|
|
30
|
+
plugins: [workletsPlugin("preset")]
|
|
31
|
+
};
|
|
32
|
+
}]
|
|
33
|
+
}, {});
|
|
34
|
+
(0, import_vitest.expect)(result === null || result === void 0 ? void 0 : (_result_metadata = result.metadata) === null || _result_metadata === void 0 ? void 0 : _result_metadata.workletsPasses).toEqual(["app"]);
|
|
35
|
+
});
|
|
36
|
+
(0, import_vitest.it)("rejects the removed workletizableModules option before transforming", function () {
|
|
37
|
+
(0, import_vitest.expect)(function () {
|
|
38
|
+
return (0, import_transformSync.transformSync)("export const value = 1", {
|
|
39
|
+
filename: "/project/input.ts",
|
|
40
|
+
babelrc: false,
|
|
41
|
+
configFile: false,
|
|
42
|
+
plugins: [[workletsPlugin("app"), {
|
|
43
|
+
workletizableModules: ["remend"]
|
|
44
|
+
}]]
|
|
45
|
+
}, {});
|
|
46
|
+
}).toThrow("use `importForwarding.moduleNames`");
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=transformSync.test.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["import_vitest","require","import_transformSync","workletsPlugin","marker","name","visitor","Program","_","state","_state_file_metadata_workletsPasses","passes","file","metadata","workletsPasses","push","describe","it","_result_metadata","result","transformSync","filename","babelrc","configFile","plugins","presets","expect","toEqual"],"sources":["../../../src/transformer/transformSync.test.ts"],"sourcesContent":[null],"mappings":"AAAA;;AACA,IAAAA,aAAA,GAAAC,OAA8B;AAI9B,IAAAC,oBAAwB,GAAAD,OAAA,CAAmB,2BAAO;AAAA,IAChDE,cAAM,YAAAA,CAAAC,MAAA;EACN,mBAAS;IACP;MACEC,IAAA,EAAM,UAAS;MACfC,OAAM;QACNC,OAAOA,CAAAC,CAAA,EAAKC,KAAM;UACpB,IAAAC,mCAAA;UACF,IAAAC,MAAA,IAAAD,mCAAA,GAAAD,KAAA,CAAAG,IAAA,CAAAC,QAAA,CAAAC,cAAA,cAAAJ,mCAAA,cAAAA,mCAAA;UACFD,KAAA,CAAAG,IAAA,CAAAC,QAAA,CAAAC,cAAA,GAAAH,MAAA;UAEAA,MAAA,CAAAI,IAAA,CAAAX,MAAS;QACP;MACE;IAAe;EACb;AACA;AACY,IAAAJ,aACD,CAAAgB,QAAA;EAAA,IAAAhB,aACT,CAAYiB,EAAA;IAAA,IACZC,gBAAU;IAAqB,IAC/BC,MAAA,GAAS,CAAC,GAAAjB,oBAAmB,CAAAkB,aAAe,0BAAa;MAC3DC,QAAA;MACAC,OAAC;MACHC,UAAA;MAEAC,OAAA,GACErB,cAAA,QACD;MACFsB,OAAA,GAED;QACE;UAAOD,OACL,GACErB,cAAA;QAEE;MAAU;IAEE,MACZ;IAAuE,IACzEH,aAAA,CAAA0B,MAAA,EAAAP,MAAA,aAAAA,MAAA,wBAAAD,gBAAA,GAAAC,MAAA,CAAAN,QAAA,cAAAK,gBAAA,uBAAAA,gBAAA,CAAAJ,cAAA,EAAAa,OAAA,OACC,EACH;EAAA,EACF;EACF,CAAC,GAAA3B,aAAA,CAAAiB,EAAA;IACF,IAAAjB,aAAA,CAAA0B,MAAA","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
8
|
+
get: () => from[key],
|
|
9
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
}), mod);
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
+
get: () => from[key],
|
|
11
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
17
|
+
value: true
|
|
18
|
+
}), mod);
|
|
19
|
+
var types_exports = {};
|
|
20
|
+
module.exports = __toCommonJS(types_exports);
|
|
21
|
+
//# sourceMappingURL=types.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","types_exports"],"sources":["../../../src/transformer/types.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
34
|
+
var exit_exports = {};
|
|
35
|
+
__export(exit_exports, {
|
|
36
|
+
ensureProcessExitsAfterDelay: () => ensureProcessExitsAfterDelay,
|
|
37
|
+
guardAsync: () => guardAsync,
|
|
38
|
+
installExitHooks: () => installExitHooks,
|
|
39
|
+
warn: () => warn
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(exit_exports);
|
|
42
|
+
var import_node_child_process = require("node:child_process");
|
|
43
|
+
var import_node_process = __toESM(require("node:process"), 1);
|
|
44
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
45
|
+
const debug = (..._) => {};
|
|
46
|
+
const PRE_EXIT_SIGNALS = ["SIGHUP", "SIGINT", "SIGTERM", "SIGBREAK"];
|
|
47
|
+
const queue = [];
|
|
48
|
+
let unsubscribe = null;
|
|
49
|
+
function installExitHooks(asyncExitHook) {
|
|
50
|
+
if (!queue.length) {
|
|
51
|
+
unsubscribe = attachMasterListener();
|
|
52
|
+
}
|
|
53
|
+
queue.push(asyncExitHook);
|
|
54
|
+
return () => {
|
|
55
|
+
const index = queue.indexOf(asyncExitHook);
|
|
56
|
+
if (index >= 0) {
|
|
57
|
+
queue.splice(index, 1);
|
|
58
|
+
}
|
|
59
|
+
if (!queue.length) {
|
|
60
|
+
unsubscribe?.();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function createExitHook(signal) {
|
|
65
|
+
return guardAsync(async () => {
|
|
66
|
+
debug(`pre-exit (signal: ${signal}, queue length: ${queue.length})`);
|
|
67
|
+
for (const [index, hookAsync] of Object.entries(queue)) {
|
|
68
|
+
try {
|
|
69
|
+
await hookAsync(signal);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
debug(`Error in exit hook: %O (queue: ${index})`, error);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
debug(`post-exit (code: ${import_node_process.default.exitCode ?? 0})`);
|
|
75
|
+
import_node_process.default.exit();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function attachMasterListener() {
|
|
79
|
+
const hooks = [];
|
|
80
|
+
for (const signal of PRE_EXIT_SIGNALS) {
|
|
81
|
+
const hook = createExitHook(signal);
|
|
82
|
+
hooks.push([signal, hook]);
|
|
83
|
+
import_node_process.default.on(signal, hook);
|
|
84
|
+
}
|
|
85
|
+
return () => {
|
|
86
|
+
for (const [signal, hook] of hooks) {
|
|
87
|
+
import_node_process.default.removeListener(signal, hook);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function ensureProcessExitsAfterDelay(waitUntilExitMs = 1e4, startedAtMs = Date.now()) {
|
|
92
|
+
const expectedResources = [import_node_process.default.stdout.isTTY ? "TTYWrap" : "PipeWrap", import_node_process.default.stderr.isTTY ? "TTYWrap" : "PipeWrap", import_node_process.default.stdin.isTTY ? "TTYWrap" : "PipeWrap"];
|
|
93
|
+
const activeResources = import_node_process.default.getActiveResourcesInfo();
|
|
94
|
+
const unexpectedActiveResources = activeResources.filter(activeResource => {
|
|
95
|
+
const index = expectedResources.indexOf(activeResource);
|
|
96
|
+
if (index >= 0) {
|
|
97
|
+
expectedResources.splice(index, 1);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
});
|
|
102
|
+
const canExitProcess = !unexpectedActiveResources.length;
|
|
103
|
+
if (canExitProcess) {
|
|
104
|
+
return debug("no active resources detected, process can safely exit");
|
|
105
|
+
}
|
|
106
|
+
debug(`process is trying to exit, but is stuck on unexpected active resources:`, unexpectedActiveResources);
|
|
107
|
+
const elapsedTime = Date.now() - startedAtMs;
|
|
108
|
+
const killedChildren = killActiveChildProcesses(elapsedTime < 200 ? "SIGTERM" : "SIGKILL");
|
|
109
|
+
if (killedChildren > 0) {
|
|
110
|
+
const recheck = setTimeout(() => {
|
|
111
|
+
clearTimeout(recheck);
|
|
112
|
+
ensureProcessExitsAfterDelay(waitUntilExitMs, startedAtMs);
|
|
113
|
+
}, 50);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (elapsedTime > waitUntilExitMs) {
|
|
117
|
+
debug("active handles detected past the exit delay, forcefully exiting:", activeResources);
|
|
118
|
+
tryWarnActiveProcesses();
|
|
119
|
+
return import_node_process.default.exit(0);
|
|
120
|
+
}
|
|
121
|
+
const timeoutId = setTimeout(() => {
|
|
122
|
+
clearTimeout(timeoutId);
|
|
123
|
+
ensureProcessExitsAfterDelay(waitUntilExitMs, startedAtMs);
|
|
124
|
+
}, 100);
|
|
125
|
+
}
|
|
126
|
+
function killActiveChildProcesses(signal) {
|
|
127
|
+
try {
|
|
128
|
+
const children = import_node_process.default._getActiveHandles().filter(handle => handle instanceof import_node_child_process.ChildProcess);
|
|
129
|
+
for (const child of children) {
|
|
130
|
+
try {
|
|
131
|
+
child.kill(signal);
|
|
132
|
+
} catch (err) {
|
|
133
|
+
debug("failed to kill child process:", err);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return children.length;
|
|
137
|
+
} catch (err) {
|
|
138
|
+
debug("failed to enumerate active child processes:", err);
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function tryWarnActiveProcesses() {
|
|
143
|
+
let activeProcesses = [];
|
|
144
|
+
try {
|
|
145
|
+
const children = import_node_process.default._getActiveHandles().filter(handle => handle instanceof import_node_child_process.ChildProcess);
|
|
146
|
+
if (children.length) {
|
|
147
|
+
activeProcesses = children.map(child => child.spawnargs.join(" "));
|
|
148
|
+
}
|
|
149
|
+
} catch (error) {
|
|
150
|
+
debug("failed to get active process information:", error);
|
|
151
|
+
}
|
|
152
|
+
if (!activeProcesses.length) {
|
|
153
|
+
warn("Something prevented Expo from exiting, forcefully exiting now.");
|
|
154
|
+
} else {
|
|
155
|
+
const singularOrPlural = activeProcesses.length === 1 ? "1 process" : `${activeProcesses.length} processes`;
|
|
156
|
+
warn(`Detected ${singularOrPlural} preventing process from exiting, forcefully exiting now.`);
|
|
157
|
+
warn(" - " + activeProcesses.join("\n - "));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function guardAsync(fn) {
|
|
161
|
+
let invoked = false;
|
|
162
|
+
let returnValue;
|
|
163
|
+
const guard = async (...args) => {
|
|
164
|
+
if (!invoked) {
|
|
165
|
+
invoked = true;
|
|
166
|
+
returnValue = await fn(...args);
|
|
167
|
+
}
|
|
168
|
+
return returnValue;
|
|
169
|
+
};
|
|
170
|
+
return guard;
|
|
171
|
+
}
|
|
172
|
+
function warn(...message) {
|
|
173
|
+
console.warn(...message.map(value => import_picocolors.default.yellow(value)));
|
|
174
|
+
}
|