@vxrn/vite-plugin-metro 1.1.529 → 1.1.531

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.
@@ -26,7 +26,8 @@ module.exports = __toCommonJS(buildBundle_exports);
26
26
  var import_getMetroConfigFromViteConfig = require("../../metro-config/getMetroConfigFromViteConfig.cjs"),
27
27
  import_buildBundleWithConfig = require("./buildBundleWithConfig.cjs"),
28
28
  import_patchMetroServerWithViteConfigAndMetroPluginOptions = require("../../metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.cjs"),
29
- import_projectImport = require("../../utils/projectImport.cjs");
29
+ import_projectImport = require("../../utils/projectImport.cjs"),
30
+ import_exit = require("../../utils/exit.cjs");
30
31
  async function buildBundle(_argv, ctx, argsIn, bundleImpl = null) {
31
32
  const {
32
33
  viteConfig,
@@ -44,7 +45,5 @@ async function buildBundle(_argv, ctx, argsIn, bundleImpl = null) {
44
45
  patchServer: server => {
45
46
  (0, import_patchMetroServerWithViteConfigAndMetroPluginOptions.patchMetroServerWithViteConfigAndMetroPluginOptions)(server, viteConfig, metroPluginOptions);
46
47
  }
47
- }), console.info("Done."), setTimeout(() => {
48
- console.info("Exiting process to prevent hanging."), process.exit();
49
- }, 3e3);
48
+ }), console.info("Done."), (0, import_exit.ensureProcessExitsAfterDelay)();
50
49
  }
@@ -17,7 +17,7 @@ __export(buildBundle_exports, {
17
17
  buildBundle: () => buildBundle
18
18
  });
19
19
  module.exports = __toCommonJS(buildBundle_exports);
20
- var import_getMetroConfigFromViteConfig = require("../../metro-config/getMetroConfigFromViteConfig"), import_buildBundleWithConfig = require("./buildBundleWithConfig"), import_patchMetroServerWithViteConfigAndMetroPluginOptions = require("../../metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions"), import_projectImport = require("../../utils/projectImport");
20
+ var import_getMetroConfigFromViteConfig = require("../../metro-config/getMetroConfigFromViteConfig"), import_buildBundleWithConfig = require("./buildBundleWithConfig"), import_patchMetroServerWithViteConfigAndMetroPluginOptions = require("../../metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions"), import_projectImport = require("../../utils/projectImport"), import_exit = require("../../utils/exit");
21
21
  async function buildBundle(_argv, ctx, argsIn, bundleImpl = null) {
22
22
  const { viteConfig, metroPluginOptions } = this || {};
23
23
  if (!viteConfig)
@@ -40,8 +40,6 @@ async function buildBundle(_argv, ctx, argsIn, bundleImpl = null) {
40
40
  patchServer: (server) => {
41
41
  (0, import_patchMetroServerWithViteConfigAndMetroPluginOptions.patchMetroServerWithViteConfigAndMetroPluginOptions)(server, viteConfig, metroPluginOptions);
42
42
  }
43
- }), console.info("Done."), setTimeout(() => {
44
- console.info("Exiting process to prevent hanging."), process.exit();
45
- }, 3e3);
43
+ }), console.info("Done."), (0, import_exit.ensureProcessExitsAfterDelay)();
46
44
  }
47
45
  //# sourceMappingURL=buildBundle.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/rn-commands/bundle/buildBundle.ts"],
4
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0CAA6C,4DAC7C,+BAAsC,oCACtC,6DAAoE,mFACpE,uBAA+B;AAG/B,eAAsB,YAEpB,OACA,KACA,QACA,aAAkB,MACH;AACf,QAAM,EAAE,YAAY,mBAAmB,IAAI,QAAQ,CAAC;AACpD,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAEF,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAGF,MAAI,QAAQ,IAAI;AACd,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAGF,QAAM,cAAc,UAAM,kEAA6B,YAAY,kBAAkB,GAE/E,OAAO;AAAA,IACX,GAAG;AAAA,IACH,WAAW,mBAAmB,qBAC1B,qCAAe,WAAW,MAAM,mBAAmB,cAAc,IACjE,OAAO;AAAA,EACb;AAEA,YAAM,oDAAsB,MAAM,aAAa,QAAW;AAAA,IACxD,aAAa,CAAC,WAAW;AACvB,0HAAoD,QAAQ,YAAY,kBAAkB;AAAA,IAC5F;AAAA,EACF,CAAC,GAED,QAAQ,KAAK,OAAO,GAIpB,WAAW,MAAM;AACf,YAAQ,KAAK,qCAAqC,GAClD,QAAQ,KAAK;AAAA,EACf,GAAG,GAAI;AACT;",
4
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0CAA6C,4DAC7C,+BAAsC,oCACtC,6DAAoE,mFACpE,uBAA+B,sCAE/B,cAA6C;AAE7C,eAAsB,YAEpB,OACA,KACA,QACA,aAAkB,MACH;AACf,QAAM,EAAE,YAAY,mBAAmB,IAAI,QAAQ,CAAC;AACpD,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAEF,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAGF,MAAI,QAAQ,IAAI;AACd,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAGF,QAAM,cAAc,UAAM,kEAA6B,YAAY,kBAAkB,GAE/E,OAAO;AAAA,IACX,GAAG;AAAA,IACH,WAAW,mBAAmB,qBAC1B,qCAAe,WAAW,MAAM,mBAAmB,cAAc,IACjE,OAAO;AAAA,EACb;AAEA,YAAM,oDAAsB,MAAM,aAAa,QAAW;AAAA,IACxD,aAAa,CAAC,WAAW;AACvB,0HAAoD,QAAQ,YAAY,kBAAkB;AAAA,IAC5F;AAAA,EACF,CAAC,GAED,QAAQ,KAAK,OAAO,OAEpB,0CAA6B;AAC/B;",
5
5
  "names": []
6
6
  }
@@ -18,7 +18,7 @@ __export(buildBundle_exports, {
18
18
  buildBundle: () => buildBundle
19
19
  });
20
20
  module.exports = __toCommonJS(buildBundle_exports);
21
- var import_getMetroConfigFromViteConfig = require("../../metro-config/getMetroConfigFromViteConfig"), import_buildBundleWithConfig = require("./buildBundleWithConfig"), import_patchMetroServerWithViteConfigAndMetroPluginOptions = require("../../metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions"), import_projectImport = require("../../utils/projectImport");
21
+ var import_getMetroConfigFromViteConfig = require("../../metro-config/getMetroConfigFromViteConfig"), import_buildBundleWithConfig = require("./buildBundleWithConfig"), import_patchMetroServerWithViteConfigAndMetroPluginOptions = require("../../metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions"), import_projectImport = require("../../utils/projectImport"), import_exit = require("../../utils/exit");
22
22
  async function buildBundle(_argv, ctx, argsIn) {
23
23
  var bundleImpl = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null, { viteConfig, metroPluginOptions } = this || {};
24
24
  if (!viteConfig)
@@ -35,9 +35,7 @@ async function buildBundle(_argv, ctx, argsIn) {
35
35
  patchServer: function(server) {
36
36
  (0, import_patchMetroServerWithViteConfigAndMetroPluginOptions.patchMetroServerWithViteConfigAndMetroPluginOptions)(server, viteConfig, metroPluginOptions);
37
37
  }
38
- }), console.info("Done."), setTimeout(function() {
39
- console.info("Exiting process to prevent hanging."), process.exit();
40
- }, 3e3);
38
+ }), console.info("Done."), (0, import_exit.ensureProcessExitsAfterDelay)();
41
39
  }
42
40
  // Annotate the CommonJS export names for ESM import in node:
43
41
  0 && (module.exports = {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/rn-commands/bundle/buildBundle.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;AAEA;;;;;0CAA6C,4DAC7C,+BAAsC,oCACtC,6DAAoE,mFACpE,uBAA+B;AAG/B,eAAsBA,YAEpBC,OACAC,KACAC,QAAyB;MACzBC,aAAAA,UAAAA,SAAAA,KAAAA,UAAAA,CAAAA,MAAAA,SAAAA,UAAAA,CAAAA,IAAkB,MAEZ,EAAEC,YAAYC,mBAAkB,IAAK,QAAQ,CAAC;AACpD,MAAI,CAACD;AACH,UAAM,IAAIE,MACR,kHAAA;AAGJ,MAAI,CAACD;AACH,UAAM,IAAIC,MACR,0HAAA;AAIJ,MAAIC,QAAQC,IAAIC;AACd,UAAM,IAAIH,MACR,oGAAA;AAIJ,MAAMI,cAAc,UAAMC,kEAA6BP,YAAYC,kBAAAA,GAE7DO,OAAO;IACX,GAAGV;IACHW,WAAWR,mBAAmBS,qBAC1BC,qCAAeX,WAAWY,MAAMX,mBAAmBS,cAAc,IACjEZ,OAAOW;EACb;AAEA,YAAMI,oDAAsBL,MAAMF,aAAaQ,QAAW;IACxDC,aAAa,SAACC,QAAAA;AACZC,0HAAoDD,QAAQhB,YAAYC,kBAAAA;IAC1E;EACF,CAAA,GAEAiB,QAAQC,KAAK,OAAA,GAIbC,WAAW,WAAA;AACTF,YAAQC,KAAK,qCAAA,GACbhB,QAAQkB,KAAI;EACd,GAAG,GAAA;AACL;",
5
- "names": ["buildBundle", "_argv", "ctx", "argsIn", "bundleImpl", "viteConfig", "metroPluginOptions", "Error", "process", "env", "IS_VXRN_CLI", "metroConfig", "getMetroConfigFromViteConfig", "args", "entryFile", "mainModuleName", "projectResolve", "root", "buildBundleWithConfig", "undefined", "patchServer", "server", "patchMetroServerWithViteConfigAndMetroPluginOptions", "console", "info", "setTimeout", "exit"]
4
+ "mappings": ";;;;;;;;;;;;;;;AAEA;;;;;0CAA6C,4DAC7C,+BAAsC,oCACtC,6DAAoE,mFACpE,uBAA+B,sCAE/B,cAA6C;AAE7C,eAAsBA,YAEpBC,OACAC,KACAC,QAAyB;MACzBC,aAAAA,UAAAA,SAAAA,KAAAA,UAAAA,CAAAA,MAAAA,SAAAA,UAAAA,CAAAA,IAAkB,MAEZ,EAAEC,YAAYC,mBAAkB,IAAK,QAAQ,CAAC;AACpD,MAAI,CAACD;AACH,UAAM,IAAIE,MACR,kHAAA;AAGJ,MAAI,CAACD;AACH,UAAM,IAAIC,MACR,0HAAA;AAIJ,MAAIC,QAAQC,IAAIC;AACd,UAAM,IAAIH,MACR,oGAAA;AAIJ,MAAMI,cAAc,UAAMC,kEAA6BP,YAAYC,kBAAAA,GAE7DO,OAAO;IACX,GAAGV;IACHW,WAAWR,mBAAmBS,qBAC1BC,qCAAeX,WAAWY,MAAMX,mBAAmBS,cAAc,IACjEZ,OAAOW;EACb;AAEA,YAAMI,oDAAsBL,MAAMF,aAAaQ,QAAW;IACxDC,aAAa,SAACC,QAAAA;AACZC,0HAAoDD,QAAQhB,YAAYC,kBAAAA;IAC1E;EACF,CAAA,GAEAiB,QAAQC,KAAK,OAAA,OAEbC,0CAAAA;AACF;",
5
+ "names": ["buildBundle", "_argv", "ctx", "argsIn", "bundleImpl", "viteConfig", "metroPluginOptions", "Error", "process", "env", "IS_VXRN_CLI", "metroConfig", "getMetroConfigFromViteConfig", "args", "entryFile", "mainModuleName", "projectResolve", "root", "buildBundleWithConfig", "undefined", "patchServer", "server", "patchMetroServerWithViteConfigAndMetroPluginOptions", "console", "info", "ensureProcessExitsAfterDelay"]
6
6
  }
@@ -0,0 +1,108 @@
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
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var exit_exports = {};
33
+ __export(exit_exports, {
34
+ ensureProcessExitsAfterDelay: () => ensureProcessExitsAfterDelay,
35
+ guardAsync: () => guardAsync,
36
+ installExitHooks: () => installExitHooks,
37
+ warn: () => warn
38
+ });
39
+ module.exports = __toCommonJS(exit_exports);
40
+ var import_node_child_process = require("node:child_process"),
41
+ import_node_process = __toESM(require("node:process"), 1),
42
+ import_picocolors = __toESM(require("picocolors"), 1);
43
+ const debug = (..._) => {},
44
+ PRE_EXIT_SIGNALS = ["SIGHUP", "SIGINT", "SIGTERM", "SIGBREAK"],
45
+ queue = [];
46
+ let unsubscribe = null;
47
+ function installExitHooks(asyncExitHook) {
48
+ return queue.length || (unsubscribe = attachMasterListener()), queue.push(asyncExitHook), () => {
49
+ const index = queue.indexOf(asyncExitHook);
50
+ index >= 0 && queue.splice(index, 1), queue.length || unsubscribe?.();
51
+ };
52
+ }
53
+ function createExitHook(signal) {
54
+ return guardAsync(async () => {
55
+ debug(`pre-exit (signal: ${signal}, queue length: ${queue.length})`);
56
+ for (const [index, hookAsync] of Object.entries(queue)) try {
57
+ await hookAsync(signal);
58
+ } catch (error) {
59
+ debug(`Error in exit hook: %O (queue: ${index})`, error);
60
+ }
61
+ debug(`post-exit (code: ${import_node_process.default.exitCode ?? 0})`), import_node_process.default.exit();
62
+ });
63
+ }
64
+ function attachMasterListener() {
65
+ const hooks = [];
66
+ for (const signal of PRE_EXIT_SIGNALS) {
67
+ const hook = createExitHook(signal);
68
+ hooks.push([signal, hook]), import_node_process.default.on(signal, hook);
69
+ }
70
+ return () => {
71
+ for (const [signal, hook] of hooks) import_node_process.default.removeListener(signal, hook);
72
+ };
73
+ }
74
+ function ensureProcessExitsAfterDelay(waitUntilExitMs = 1e4, startedAtMs = Date.now()) {
75
+ 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"],
76
+ activeResources = import_node_process.default.getActiveResourcesInfo(),
77
+ unexpectedActiveResources = activeResources.filter(activeResource => {
78
+ const index = expectedResources.indexOf(activeResource);
79
+ return index >= 0 ? (expectedResources.splice(index, 1), !1) : !0;
80
+ });
81
+ if (!unexpectedActiveResources.length) return debug("no active resources detected, process can safely exit");
82
+ if (debug("process is trying to exit, but is stuck on unexpected active resources:", unexpectedActiveResources), Date.now() - startedAtMs > waitUntilExitMs) return debug("active handles detected past the exit delay, forcefully exiting:", activeResources), tryWarnActiveProcesses(), import_node_process.default.exit(0);
83
+ const timeoutId = setTimeout(() => {
84
+ clearTimeout(timeoutId), ensureProcessExitsAfterDelay(waitUntilExitMs, startedAtMs);
85
+ }, 100);
86
+ }
87
+ function tryWarnActiveProcesses() {
88
+ let activeProcesses = [];
89
+ try {
90
+ const children = import_node_process.default._getActiveHandles().filter(handle => handle instanceof import_node_child_process.ChildProcess);
91
+ children.length && (activeProcesses = children.map(child => child.spawnargs.join(" ")));
92
+ } catch (error) {
93
+ debug("failed to get active process information:", error);
94
+ }
95
+ if (!activeProcesses.length) warn("Something prevented Expo from exiting, forcefully exiting now.");else {
96
+ const singularOrPlural = activeProcesses.length === 1 ? "1 process" : `${activeProcesses.length} processes`;
97
+ warn(`Detected ${singularOrPlural} preventing process from exiting, forcefully exiting now.`), warn(" - " + activeProcesses.join(`
98
+ - `));
99
+ }
100
+ }
101
+ function guardAsync(fn) {
102
+ let invoked = !1,
103
+ returnValue;
104
+ return async (...args) => (invoked || (invoked = !0, returnValue = await fn(...args)), returnValue);
105
+ }
106
+ function warn(...message) {
107
+ console.warn(...message.map(value => import_picocolors.default.yellow(value)));
108
+ }
@@ -0,0 +1,107 @@
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, __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
+ mod
22
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
+ var exit_exports = {};
24
+ __export(exit_exports, {
25
+ ensureProcessExitsAfterDelay: () => ensureProcessExitsAfterDelay,
26
+ guardAsync: () => guardAsync,
27
+ installExitHooks: () => installExitHooks,
28
+ warn: () => warn
29
+ });
30
+ module.exports = __toCommonJS(exit_exports);
31
+ var import_node_child_process = require("node:child_process"), import_node_process = __toESM(require("node:process"), 1), import_picocolors = __toESM(require("picocolors"), 1);
32
+ const debug = (..._) => {
33
+ }, PRE_EXIT_SIGNALS = ["SIGHUP", "SIGINT", "SIGTERM", "SIGBREAK"], queue = [];
34
+ let unsubscribe = null;
35
+ function installExitHooks(asyncExitHook) {
36
+ return queue.length || (unsubscribe = attachMasterListener()), queue.push(asyncExitHook), () => {
37
+ const index = queue.indexOf(asyncExitHook);
38
+ index >= 0 && queue.splice(index, 1), queue.length || unsubscribe?.();
39
+ };
40
+ }
41
+ function createExitHook(signal) {
42
+ return guardAsync(async () => {
43
+ debug(`pre-exit (signal: ${signal}, queue length: ${queue.length})`);
44
+ for (const [index, hookAsync] of Object.entries(queue))
45
+ try {
46
+ await hookAsync(signal);
47
+ } catch (error) {
48
+ debug(`Error in exit hook: %O (queue: ${index})`, error);
49
+ }
50
+ debug(`post-exit (code: ${import_node_process.default.exitCode ?? 0})`), import_node_process.default.exit();
51
+ });
52
+ }
53
+ function attachMasterListener() {
54
+ const hooks = [];
55
+ for (const signal of PRE_EXIT_SIGNALS) {
56
+ const hook = createExitHook(signal);
57
+ hooks.push([signal, hook]), import_node_process.default.on(signal, hook);
58
+ }
59
+ return () => {
60
+ for (const [signal, hook] of hooks)
61
+ import_node_process.default.removeListener(signal, hook);
62
+ };
63
+ }
64
+ function ensureProcessExitsAfterDelay(waitUntilExitMs = 1e4, startedAtMs = Date.now()) {
65
+ const expectedResources = [
66
+ import_node_process.default.stdout.isTTY ? "TTYWrap" : "PipeWrap",
67
+ import_node_process.default.stderr.isTTY ? "TTYWrap" : "PipeWrap",
68
+ import_node_process.default.stdin.isTTY ? "TTYWrap" : "PipeWrap"
69
+ ], activeResources = import_node_process.default.getActiveResourcesInfo(), unexpectedActiveResources = activeResources.filter((activeResource) => {
70
+ const index = expectedResources.indexOf(activeResource);
71
+ return index >= 0 ? (expectedResources.splice(index, 1), !1) : !0;
72
+ });
73
+ if (!unexpectedActiveResources.length)
74
+ return debug("no active resources detected, process can safely exit");
75
+ if (debug(
76
+ "process is trying to exit, but is stuck on unexpected active resources:",
77
+ unexpectedActiveResources
78
+ ), Date.now() - startedAtMs > waitUntilExitMs)
79
+ return debug("active handles detected past the exit delay, forcefully exiting:", activeResources), tryWarnActiveProcesses(), import_node_process.default.exit(0);
80
+ const timeoutId = setTimeout(() => {
81
+ clearTimeout(timeoutId), ensureProcessExitsAfterDelay(waitUntilExitMs, startedAtMs);
82
+ }, 100);
83
+ }
84
+ function tryWarnActiveProcesses() {
85
+ let activeProcesses = [];
86
+ try {
87
+ const children = import_node_process.default._getActiveHandles().filter((handle) => handle instanceof import_node_child_process.ChildProcess);
88
+ children.length && (activeProcesses = children.map((child) => child.spawnargs.join(" ")));
89
+ } catch (error) {
90
+ debug("failed to get active process information:", error);
91
+ }
92
+ if (!activeProcesses.length)
93
+ warn("Something prevented Expo from exiting, forcefully exiting now.");
94
+ else {
95
+ const singularOrPlural = activeProcesses.length === 1 ? "1 process" : `${activeProcesses.length} processes`;
96
+ warn(`Detected ${singularOrPlural} preventing process from exiting, forcefully exiting now.`), warn(" - " + activeProcesses.join(`
97
+ - `));
98
+ }
99
+ }
100
+ function guardAsync(fn) {
101
+ let invoked = !1, returnValue;
102
+ return async (...args) => (invoked || (invoked = !0, returnValue = await fn(...args)), returnValue);
103
+ }
104
+ function warn(...message) {
105
+ console.warn(...message.map((value) => import_picocolors.default.yellow(value)));
106
+ }
107
+ //# sourceMappingURL=exit.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utils/exit.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,gCAA6B,+BAC7B,sBAAoB,qCAEpB,oBAAmB;AAEnB,MAAM,QAAS,IAAI,MAAW;AAAC,GAIzB,mBAAqC,CAAC,UAAU,UAAU,WAAW,UAAU,GAI/E,QAAyB,CAAC;AAEhC,IAAI,cAAmC;AAGhC,SAAS,iBAAiB,eAA0C;AAEzE,SAAK,MAAM,WAET,cAAc,qBAAqB,IAGrC,MAAM,KAAK,aAAa,GAEjB,MAAM;AACX,UAAM,QAAQ,MAAM,QAAQ,aAAa;AACzC,IAAI,SAAS,KACX,MAAM,OAAO,OAAO,CAAC,GAGlB,MAAM,UACT,cAAc;AAAA,EAElB;AACF;AAGA,SAAS,e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AAI,cACf;AAChB,iBAAM,oEAAoE,eAAe,GACzF,uBAAuB,GAChB,oBAAAA,QAAQ,KAAK,CAAC;AAGvB,QAAM,YAAY,WAAW,MAAM;AAEjC,iBAAa,SAAS,GAEtB,6BAA6B,iBAAiB,WAAW;AAAA,EAC3D,GAAG,GAAG;AACR;AAcA,SAAS,yBAAyB;AAChC,MAAI,kBAA4B,CAAC;AAEjC,MAAI;AACF,UAAM,WAA2B,oBAAAA,QAE9B,kBAAkB,EAClB,OAAO,CAAC,WAAgB,kBAAkB,sCAAY;AAEzD,IAAI,SAAS,WACX,kBAAkB,SAAS,IAAI,CAAC,UAAU,MAAM,UAAU,KAAK,GAAG,CAAC;AAAA,EAEvE,SAAS,OAAO;AACd,UAAM,6CAA6C,KAAK;AAAA,EAC1D;AAEA,MAAI,CAAC,gBAAgB;AACnB,SAAK,gEAAgE;AAAA,OAChE;AACL,UAAM,mBACJ,gBAAgB,WAAW,IAAI,cAAc,GAAG,gBAAgB,MAAM;AAExE,SAAK,YAAY,gBAAgB,2DAA2D,GAC5F,KAAK,SAAS,gBAAgB,KAAK;AAAA,KAAQ,CAAC;AAAA,EAC9C;AACF;AAGO,SAAS,WAAwD,IAAU;AAChF,MAAI,UAAU,IACV;AAWJ,SATmB,UAAU,UACtB,YACH,UAAU,IACV,cAAc,MAAM,GAAG,GAAG,IAAI,IAGzB;AAIX;AACO,SAAS,QAAQ,SAAyB;AAC/C,UAAQ,KAAK,GAAG,QAAQ,IAAI,CAAC,UAAU,kBAAAC,QAAO,OAAO,KAAK,CAAC,CAAC;AAC9D;",
5
+ "names": ["process", "colors"]
6
+ }
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: !0 });
10
+ }, __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from == "object" || typeof from == "function")
12
+ for (let key of __getOwnPropNames(from))
13
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
22
+ mod
23
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
24
+ var exit_exports = {};
25
+ __export(exit_exports, {
26
+ ensureProcessExitsAfterDelay: () => ensureProcessExitsAfterDelay,
27
+ guardAsync: () => guardAsync,
28
+ installExitHooks: () => installExitHooks,
29
+ warn: () => warn
30
+ });
31
+ module.exports = __toCommonJS(exit_exports);
32
+ var import_node_child_process = require("node:child_process"), import_node_process = __toESM(require("node:process"), 1), import_picocolors = __toESM(require("picocolors"), 1), debug = function() {
33
+ for (var _len = arguments.length, _ = new Array(_len), _key = 0; _key < _len; _key++)
34
+ _[_key] = arguments[_key];
35
+ }, PRE_EXIT_SIGNALS = [
36
+ "SIGHUP",
37
+ "SIGINT",
38
+ "SIGTERM",
39
+ "SIGBREAK"
40
+ ], queue = [], unsubscribe = null;
41
+ function installExitHooks(asyncExitHook) {
42
+ return queue.length || (unsubscribe = attachMasterListener()), queue.push(asyncExitHook), function() {
43
+ var index = queue.indexOf(asyncExitHook);
44
+ index >= 0 && queue.splice(index, 1), queue.length || unsubscribe == null || unsubscribe();
45
+ };
46
+ }
47
+ function createExitHook(signal) {
48
+ return guardAsync(async function() {
49
+ debug(`pre-exit (signal: ${signal}, queue length: ${queue.length})`);
50
+ var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
51
+ try {
52
+ for (var _iterator = Object.entries(queue)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
53
+ var [index, hookAsync] = _step.value;
54
+ try {
55
+ await hookAsync(signal);
56
+ } catch (error) {
57
+ debug(`Error in exit hook: %O (queue: ${index})`, error);
58
+ }
59
+ }
60
+ } catch (err) {
61
+ _didIteratorError = !0, _iteratorError = err;
62
+ } finally {
63
+ try {
64
+ !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
65
+ } finally {
66
+ if (_didIteratorError)
67
+ throw _iteratorError;
68
+ }
69
+ }
70
+ var _process_exitCode;
71
+ debug(`post-exit (code: ${(_process_exitCode = import_node_process.default.exitCode) !== null && _process_exitCode !== void 0 ? _process_exitCode : 0})`), import_node_process.default.exit();
72
+ });
73
+ }
74
+ function attachMasterListener() {
75
+ var hooks = [], _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
76
+ try {
77
+ for (var _iterator = PRE_EXIT_SIGNALS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
78
+ var signal = _step.value, hook = createExitHook(signal);
79
+ hooks.push([
80
+ signal,
81
+ hook
82
+ ]), import_node_process.default.on(signal, hook);
83
+ }
84
+ } catch (err) {
85
+ _didIteratorError = !0, _iteratorError = err;
86
+ } finally {
87
+ try {
88
+ !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
89
+ } finally {
90
+ if (_didIteratorError)
91
+ throw _iteratorError;
92
+ }
93
+ }
94
+ return function() {
95
+ var _iteratorNormalCompletion2 = !0, _didIteratorError2 = !1, _iteratorError2 = void 0;
96
+ try {
97
+ for (var _iterator2 = hooks[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
98
+ var [signal2, hook2] = _step2.value;
99
+ import_node_process.default.removeListener(signal2, hook2);
100
+ }
101
+ } catch (err) {
102
+ _didIteratorError2 = !0, _iteratorError2 = err;
103
+ } finally {
104
+ try {
105
+ !_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
106
+ } finally {
107
+ if (_didIteratorError2)
108
+ throw _iteratorError2;
109
+ }
110
+ }
111
+ };
112
+ }
113
+ function ensureProcessExitsAfterDelay() {
114
+ var waitUntilExitMs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1e4, startedAtMs = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Date.now(), expectedResources = [
115
+ import_node_process.default.stdout.isTTY ? "TTYWrap" : "PipeWrap",
116
+ import_node_process.default.stderr.isTTY ? "TTYWrap" : "PipeWrap",
117
+ import_node_process.default.stdin.isTTY ? "TTYWrap" : "PipeWrap"
118
+ ], activeResources = import_node_process.default.getActiveResourcesInfo(), unexpectedActiveResources = activeResources.filter(function(activeResource) {
119
+ var index = expectedResources.indexOf(activeResource);
120
+ return index >= 0 ? (expectedResources.splice(index, 1), !1) : !0;
121
+ }), canExitProcess = !unexpectedActiveResources.length;
122
+ if (canExitProcess)
123
+ return debug("no active resources detected, process can safely exit");
124
+ debug("process is trying to exit, but is stuck on unexpected active resources:", unexpectedActiveResources);
125
+ var elapsedTime = Date.now() - startedAtMs;
126
+ if (elapsedTime > waitUntilExitMs)
127
+ return debug("active handles detected past the exit delay, forcefully exiting:", activeResources), tryWarnActiveProcesses(), import_node_process.default.exit(0);
128
+ var timeoutId = setTimeout(function() {
129
+ clearTimeout(timeoutId), ensureProcessExitsAfterDelay(waitUntilExitMs, startedAtMs);
130
+ }, 100);
131
+ }
132
+ function tryWarnActiveProcesses() {
133
+ var activeProcesses = [];
134
+ try {
135
+ var children = import_node_process.default._getActiveHandles().filter(function(handle) {
136
+ return handle instanceof import_node_child_process.ChildProcess;
137
+ });
138
+ children.length && (activeProcesses = children.map(function(child) {
139
+ return child.spawnargs.join(" ");
140
+ }));
141
+ } catch (error) {
142
+ debug("failed to get active process information:", error);
143
+ }
144
+ if (!activeProcesses.length)
145
+ warn("Something prevented Expo from exiting, forcefully exiting now.");
146
+ else {
147
+ var singularOrPlural = activeProcesses.length === 1 ? "1 process" : `${activeProcesses.length} processes`;
148
+ warn(`Detected ${singularOrPlural} preventing process from exiting, forcefully exiting now.`), warn(" - " + activeProcesses.join(`
149
+ - `));
150
+ }
151
+ }
152
+ function guardAsync(fn) {
153
+ var invoked = !1, returnValue, guard = async function() {
154
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++)
155
+ args[_key] = arguments[_key];
156
+ return invoked || (invoked = !0, returnValue = await fn(...args)), returnValue;
157
+ };
158
+ return guard;
159
+ }
160
+ function warn() {
161
+ for (var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++)
162
+ message[_key] = arguments[_key];
163
+ console.warn(...message.map(function(value) {
164
+ return import_picocolors.default.yellow(value);
165
+ }));
166
+ }
167
+ // Annotate the CommonJS export names for ESM import in node:
168
+ 0 && (module.exports = {
169
+ ensureProcessExitsAfterDelay,
170
+ guardAsync,
171
+ installExitHooks,
172
+ warn
173
+ });
174
+ //# sourceMappingURL=exit.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utils/exit.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;AAMA,gCAA6B,+BAC7B,sBAAoB,qCAEpB,oBAAmB,mCAEbA,QAAS,WAAA;oCAAIC,IAAAA,IAAAA,MAAAA,IAAAA,GAAAA,OAAAA,GAAAA,OAAAA,MAAAA;AAAAA,MAAAA,IAAAA,IAAAA,UAAAA,IAAAA;AAAY,GAIzBC,mBAAqC;EAAC;EAAU;EAAU;EAAW;GAIrEC,QAAyB,CAAA,GAE3BC,cAAm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,OAAA,MAAA;AAAGA,YAAH,IAAA,IAAA,UAAA,IAAA;AACnBC,UAAQR,KAAI,GAAIO,QAAQX,IAAI,SAACa,OAAAA;WAAUC,kBAAAA,QAAOC,OAAOF,KAAAA;;AACvD;",
5
+ "names": ["debug", "_", "PRE_EXIT_SIGNALS", "queue", "unsubscribe", "installExitHooks", "asyncExitHook", "length", "attachMasterListener", "push", "index", "indexOf", "splice", "createExitHook", "signal", "guardAsync", "Object", "entries", "hookAsync", "error", "process", "exitCode", "exit", "hooks", "hook", "on", "_iteratorNormalCompletion", "_didIteratorError", "_iteratorError", "_iterator", "_step", "removeListener", "ensureProcessExitsAfterDelay", "waitUntilExitMs", "startedAtMs", "Date", "now", "expectedResources", "stdout", "isTTY", "stderr", "stdin", "activeResources", "getActiveResourcesInfo", "unexpectedActiveResources", "filter", "activeResource", "canExitProcess", "elapsedTime", "tryWarnActiveProcesses", "timeoutId", "setTimeout", "clearTimeout", "activeProcesses", "children", "_getActiveHandles", "handle", "ChildProcess", "map", "child", "spawnargs", "join", "warn", "singularOrPlural", "fn", "invoked", "returnValue", "guard", "args", "message", "console", "value", "colors", "yellow"]
6
+ }
@@ -2,6 +2,7 @@ import { getMetroConfigFromViteConfig } from "../../metro-config/getMetroConfigF
2
2
  import { buildBundleWithConfig } from "./buildBundleWithConfig";
3
3
  import { patchMetroServerWithViteConfigAndMetroPluginOptions } from "../../metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions";
4
4
  import { projectResolve } from "../../utils/projectImport";
5
+ import { ensureProcessExitsAfterDelay } from "../../utils/exit";
5
6
  async function buildBundle(_argv, ctx, argsIn, bundleImpl = null) {
6
7
  const { viteConfig, metroPluginOptions } = this || {};
7
8
  if (!viteConfig)
@@ -24,9 +25,7 @@ async function buildBundle(_argv, ctx, argsIn, bundleImpl = null) {
24
25
  patchServer: (server) => {
25
26
  patchMetroServerWithViteConfigAndMetroPluginOptions(server, viteConfig, metroPluginOptions);
26
27
  }
27
- }), console.info("Done."), setTimeout(() => {
28
- console.info("Exiting process to prevent hanging."), process.exit();
29
- }, 3e3);
28
+ }), console.info("Done."), ensureProcessExitsAfterDelay();
30
29
  }
31
30
  export {
32
31
  buildBundle
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/rn-commands/bundle/buildBundle.ts"],
4
- "mappings": "AAEA,SAAS,oCAAoC;AAC7C,SAAS,6BAA6B;AACtC,SAAS,2DAA2D;AACpE,SAAS,sBAAsB;AAG/B,eAAsB,YAEpB,OACA,KACA,QACA,aAAkB,MACH;AACf,QAAM,EAAE,YAAY,mBAAmB,IAAI,QAAQ,CAAC;AACpD,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAEF,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAGF,MAAI,QAAQ,IAAI;AACd,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAGF,QAAM,cAAc,MAAM,6BAA6B,YAAY,kBAAkB,GAE/E,OAAO;AAAA,IACX,GAAG;AAAA,IACH,WAAW,mBAAmB,iBAC1B,eAAe,WAAW,MAAM,mBAAmB,cAAc,IACjE,OAAO;AAAA,EACb;AAEA,QAAM,sBAAsB,MAAM,aAAa,QAAW;AAAA,IACxD,aAAa,CAAC,WAAW;AACvB,0DAAoD,QAAQ,YAAY,kBAAkB;AAAA,IAC5F;AAAA,EACF,CAAC,GAED,QAAQ,KAAK,OAAO,GAIpB,WAAW,MAAM;AACf,YAAQ,KAAK,qCAAqC,GAClD,QAAQ,KAAK;AAAA,EACf,GAAG,GAAI;AACT;",
4
+ "mappings": "AAEA,SAAS,oCAAoC;AAC7C,SAAS,6BAA6B;AACtC,SAAS,2DAA2D;AACpE,SAAS,sBAAsB;AAE/B,SAAS,oCAAoC;AAE7C,eAAsB,YAEpB,OACA,KACA,QACA,aAAkB,MACH;AACf,QAAM,EAAE,YAAY,mBAAmB,IAAI,QAAQ,CAAC;AACpD,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAEF,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAGF,MAAI,QAAQ,IAAI;AACd,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAGF,QAAM,cAAc,MAAM,6BAA6B,YAAY,kBAAkB,GAE/E,OAAO;AAAA,IACX,GAAG;AAAA,IACH,WAAW,mBAAmB,iBAC1B,eAAe,WAAW,MAAM,mBAAmB,cAAc,IACjE,OAAO;AAAA,EACb;AAEA,QAAM,sBAAsB,MAAM,aAAa,QAAW;AAAA,IACxD,aAAa,CAAC,WAAW;AACvB,0DAAoD,QAAQ,YAAY,kBAAkB;AAAA,IAC5F;AAAA,EACF,CAAC,GAED,QAAQ,KAAK,OAAO,GAEpB,6BAA6B;AAC/B;",
5
5
  "names": []
6
6
  }
@@ -2,6 +2,7 @@ import { getMetroConfigFromViteConfig } from "../../metro-config/getMetroConfigF
2
2
  import { buildBundleWithConfig } from "./buildBundleWithConfig.mjs";
3
3
  import { patchMetroServerWithViteConfigAndMetroPluginOptions } from "../../metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.mjs";
4
4
  import { projectResolve } from "../../utils/projectImport.mjs";
5
+ import { ensureProcessExitsAfterDelay } from "../../utils/exit.mjs";
5
6
  async function buildBundle(_argv, ctx, argsIn, bundleImpl = null) {
6
7
  const {
7
8
  viteConfig,
@@ -19,9 +20,7 @@ async function buildBundle(_argv, ctx, argsIn, bundleImpl = null) {
19
20
  patchServer: server => {
20
21
  patchMetroServerWithViteConfigAndMetroPluginOptions(server, viteConfig, metroPluginOptions);
21
22
  }
22
- }), console.info("Done."), setTimeout(() => {
23
- console.info("Exiting process to prevent hanging."), process.exit();
24
- }, 3e3);
23
+ }), console.info("Done."), ensureProcessExitsAfterDelay();
25
24
  }
26
25
  export { buildBundle };
27
26
  //# sourceMappingURL=buildBundle.mjs.map
@@ -1 +1 @@
1
- {"version":3,"names":["getMetroConfigFromViteConfig","buildBundleWithConfig","patchMetroServerWithViteConfigAndMetroPluginOptions","projectResolve","buildBundle","_argv","ctx","argsIn","bundleImpl","viteConfig","metroPluginOptions","Error","process","env","IS_VXRN_CLI","metroConfig","args","entryFile","mainModuleName","root","patchServer","server","console","info","setTimeout","exit"],"sources":["../../../../src/rn-commands/bundle/buildBundle.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,4BAAA,QAAoC;AAC7C,SAASC,qBAAA,QAA6B;AACtC,SAASC,mDAAA,QAA2D;AACpE,SAASC,cAAA,QAAsB;AAG/B,eAAsBC,YAEpBC,KAAA,EACAC,GAAA,EACAC,MAAA,EACAC,UAAA,GAAkB,MACH;EACf,MAAM;IAAEC,UAAA;IAAYC;EAAmB,IAAI,QAAQ,CAAC;EACpD,IAAI,CAACD,UAAA,EACH,MAAM,IAAIE,KAAA,CACR,kHACF;EAEF,IAAI,CAACD,kBAAA,EACH,MAAM,IAAIC,KAAA,CACR,0HACF;EAGF,IAAIC,OAAA,CAAQC,GAAA,CAAIC,WAAA,EACd,MAAM,IAAIH,KAAA,CACR,oGACF;EAGF,MAAMI,WAAA,GAAc,MAAMf,4BAAA,CAA6BS,UAAA,EAAYC,kBAAkB;IAE/EM,IAAA,GAAO;MACX,GAAGT,MAAA;MACHU,SAAA,EAAWP,kBAAA,CAAmBQ,cAAA,GAC1Bf,cAAA,CAAeM,UAAA,CAAWU,IAAA,EAAMT,kBAAA,CAAmBQ,cAAc,IACjEX,MAAA,CAAOU;IACb;EAEA,MAAMhB,qBAAA,CAAsBe,IAAA,EAAMD,WAAA,EAAa,QAAW;IACxDK,WAAA,EAAcC,MAAA,IAAW;MACvBnB,mDAAA,CAAoDmB,MAAA,EAAQZ,UAAA,EAAYC,kBAAkB;IAC5F;EACF,CAAC,GAEDY,OAAA,CAAQC,IAAA,CAAK,OAAO,GAIpBC,UAAA,CAAW,MAAM;IACfF,OAAA,CAAQC,IAAA,CAAK,qCAAqC,GAClDX,OAAA,CAAQa,IAAA,CAAK;EACf,GAAG,GAAI;AACT","ignoreList":[]}
1
+ {"version":3,"names":["getMetroConfigFromViteConfig","buildBundleWithConfig","patchMetroServerWithViteConfigAndMetroPluginOptions","projectResolve","ensureProcessExitsAfterDelay","buildBundle","_argv","ctx","argsIn","bundleImpl","viteConfig","metroPluginOptions","Error","process","env","IS_VXRN_CLI","metroConfig","args","entryFile","mainModuleName","root","patchServer","server","console","info"],"sources":["../../../../src/rn-commands/bundle/buildBundle.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,4BAAA,QAAoC;AAC7C,SAASC,qBAAA,QAA6B;AACtC,SAASC,mDAAA,QAA2D;AACpE,SAASC,cAAA,QAAsB;AAE/B,SAASC,4BAAA,QAAoC;AAE7C,eAAsBC,YAEpBC,KAAA,EACAC,GAAA,EACAC,MAAA,EACAC,UAAA,GAAkB,MACH;EACf,MAAM;IAAEC,UAAA;IAAYC;EAAmB,IAAI,QAAQ,CAAC;EACpD,IAAI,CAACD,UAAA,EACH,MAAM,IAAIE,KAAA,CACR,kHACF;EAEF,IAAI,CAACD,kBAAA,EACH,MAAM,IAAIC,KAAA,CACR,0HACF;EAGF,IAAIC,OAAA,CAAQC,GAAA,CAAIC,WAAA,EACd,MAAM,IAAIH,KAAA,CACR,oGACF;EAGF,MAAMI,WAAA,GAAc,MAAMhB,4BAAA,CAA6BU,UAAA,EAAYC,kBAAkB;IAE/EM,IAAA,GAAO;MACX,GAAGT,MAAA;MACHU,SAAA,EAAWP,kBAAA,CAAmBQ,cAAA,GAC1BhB,cAAA,CAAeO,UAAA,CAAWU,IAAA,EAAMT,kBAAA,CAAmBQ,cAAc,IACjEX,MAAA,CAAOU;IACb;EAEA,MAAMjB,qBAAA,CAAsBgB,IAAA,EAAMD,WAAA,EAAa,QAAW;IACxDK,WAAA,EAAcC,MAAA,IAAW;MACvBpB,mDAAA,CAAoDoB,MAAA,EAAQZ,UAAA,EAAYC,kBAAkB;IAC5F;EACF,CAAC,GAEDY,OAAA,CAAQC,IAAA,CAAK,OAAO,GAEpBpB,4BAAA,CAA6B;AAC/B","ignoreList":[]}
@@ -2,6 +2,7 @@ import { getMetroConfigFromViteConfig } from "../../metro-config/getMetroConfigF
2
2
  import { buildBundleWithConfig } from "./buildBundleWithConfig.native.js";
3
3
  import { patchMetroServerWithViteConfigAndMetroPluginOptions } from "../../metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.native.js";
4
4
  import { projectResolve } from "../../utils/projectImport.native.js";
5
+ import { ensureProcessExitsAfterDelay } from "../../utils/exit.native.js";
5
6
  async function buildBundle(_argv, ctx, argsIn) {
6
7
  var bundleImpl = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null,
7
8
  {
@@ -20,9 +21,7 @@ async function buildBundle(_argv, ctx, argsIn) {
20
21
  patchServer: function (server) {
21
22
  patchMetroServerWithViteConfigAndMetroPluginOptions(server, viteConfig, metroPluginOptions);
22
23
  }
23
- }), console.info("Done."), setTimeout(function () {
24
- console.info("Exiting process to prevent hanging."), process.exit();
25
- }, 3e3);
24
+ }), console.info("Done."), ensureProcessExitsAfterDelay();
26
25
  }
27
26
  export { buildBundle };
28
27
  //# sourceMappingURL=buildBundle.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getMetroConfigFromViteConfig","buildBundleWithConfig","patchMetroServerWithViteConfigAndMetroPluginOptions","projectResolve","buildBundle","_argv","ctx","argsIn","bundleImpl","arguments","length","viteConfig","metroPluginOptions","Error","process","env","IS_VXRN_CLI","metroConfig","args","entryFile","mainModuleName","root","patchServer","server","console","info","setTimeout","exit"],"sources":["../../../../src/rn-commands/bundle/buildBundle.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,4BAAA,QAAoC;AAC7C,SAASC,qBAAA,QAA6B;AACtC,SAASC,mDAAA,QAA2D;AACpE,SAASC,cAAA,QAAsB;AAG/B,eAAsBC,YAEpBC,KAAA,EACAC,GAAA,EACAC,MAAA,EACA;EAEA,IAAAC,UAAQ,GAAAC,SAAY,CAAAC,MAAA,QAAmBD,SAAI,CAAQ,CAAC,eAAAA,SAAA;IAAA;MAAAE,UAAA;MAAAC;IAAA;EACpD,IAAI,CAACD,UAAA,EACH,MAAM,IAAIE,KAAA;EAAA,IACR,CAAAD,kBAAA,EACF,UAAAC,KAAA;EAEF,IAAIC,OAAC,CAAAC,GAAA,CAAAC,WAAA,EACH,MAAM,IAAIH,KAAA;EAAA,IACRI,WAAA,SAAAjB,4BAAA,CAAAW,UAAA,EAAAC,kBAAA;IAAAM,IAAA;MACF,GAAAX,MAAA;MAGFY,SAAI,EAAQP,kBAAI,CAAAQ,cAAA,GAAAjB,cAAA,CAAAQ,UAAA,CAAAU,IAAA,EAAAT,kBAAA,CAAAQ,cAAA,IAAAb,MAAA,CAAAY;IACd;EAAU,MACRlB,qBAAA,CAAAiB,IAAA,EAAAD,WAAA;IACFK,WAAA,WAAAA,CAAAC,MAAA;MAGFrB,mDAAuD,CAAAqB,MAAA,EAAAZ,UAAY,EAAAC,kBAE7D,CAAO;IACX;EAAG,EACH,EAAAY,OAAA,CAAAC,IAAW,WAAAC,UAAmB,aAC1B;IAENF,OAAA,CAAAC,IAAA,yCAAAX,OAAA,CAAAa,IAAA;EAEA,MAAM;AAAoD;AAEtD,SAA0FvB,WAC5F","ignoreList":[]}
1
+ {"version":3,"names":["getMetroConfigFromViteConfig","buildBundleWithConfig","patchMetroServerWithViteConfigAndMetroPluginOptions","projectResolve","ensureProcessExitsAfterDelay","buildBundle","_argv","ctx","argsIn","bundleImpl","arguments","length","viteConfig","metroPluginOptions","Error","process","env","IS_VXRN_CLI","metroConfig","args","entryFile","mainModuleName","root","patchServer","server","console","info"],"sources":["../../../../src/rn-commands/bundle/buildBundle.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,4BAAA,QAAoC;AAC7C,SAASC,qBAAA,QAA6B;AACtC,SAASC,mDAAA,QAA2D;AACpE,SAASC,cAAA,QAAsB;AAE/B,SAASC,4BAAA,QAAoC;AAE7C,eAAsBC,YAEpBC,KAAA,EACAC,GAAA,EACAC,MAAA,EACA;EAEA,IAAAC,UAAQ,GAAAC,SAAY,CAAAC,MAAA,QAAmBD,SAAI,CAAQ,CAAC,eAAAA,SAAA;IAAA;MAAAE,UAAA;MAAAC;IAAA;EACpD,IAAI,CAACD,UAAA,EACH,MAAM,IAAIE,KAAA;EAAA,IACR,CAAAD,kBAAA,EACF,UAAAC,KAAA;EAEF,IAAIC,OAAC,CAAAC,GAAA,CAAAC,WAAA,EACH,MAAM,IAAIH,KAAA;EAAA,IACRI,WAAA,SAAAlB,4BAAA,CAAAY,UAAA,EAAAC,kBAAA;IAAAM,IAAA;MACF,GAAAX,MAAA;MAGFY,SAAI,EAAQP,kBAAI,CAAAQ,cAAA,GAAAlB,cAAA,CAAAS,UAAA,CAAAU,IAAA,EAAAT,kBAAA,CAAAQ,cAAA,IAAAb,MAAA,CAAAY;IACd;EAAU,MACRnB,qBAAA,CAAAkB,IAAA,EAAAD,WAAA;IACFK,WAAA,WAAAA,CAAAC,MAAA;MAGFtB,mDAAuD,CAAAsB,MAAA,EAAAZ,UAAY,EAAAC,kBAE7D,CAAO;IACX;EAAG,EACH,EAAAY,OAAA,CAAAC,IAAW,WAAAtB,4BACP;AACO;AAGb,SAA0DC,WACxD","ignoreList":[]}
@@ -0,0 +1,85 @@
1
+ import { ChildProcess } from "node:child_process";
2
+ import process from "node:process";
3
+ import colors from "picocolors";
4
+ const debug = (..._) => {
5
+ }, PRE_EXIT_SIGNALS = ["SIGHUP", "SIGINT", "SIGTERM", "SIGBREAK"], queue = [];
6
+ let unsubscribe = null;
7
+ function installExitHooks(asyncExitHook) {
8
+ return queue.length || (unsubscribe = attachMasterListener()), queue.push(asyncExitHook), () => {
9
+ const index = queue.indexOf(asyncExitHook);
10
+ index >= 0 && queue.splice(index, 1), queue.length || unsubscribe?.();
11
+ };
12
+ }
13
+ function createExitHook(signal) {
14
+ return guardAsync(async () => {
15
+ debug(`pre-exit (signal: ${signal}, queue length: ${queue.length})`);
16
+ for (const [index, hookAsync] of Object.entries(queue))
17
+ try {
18
+ await hookAsync(signal);
19
+ } catch (error) {
20
+ debug(`Error in exit hook: %O (queue: ${index})`, error);
21
+ }
22
+ debug(`post-exit (code: ${process.exitCode ?? 0})`), process.exit();
23
+ });
24
+ }
25
+ function attachMasterListener() {
26
+ const hooks = [];
27
+ for (const signal of PRE_EXIT_SIGNALS) {
28
+ const hook = createExitHook(signal);
29
+ hooks.push([signal, hook]), process.on(signal, hook);
30
+ }
31
+ return () => {
32
+ for (const [signal, hook] of hooks)
33
+ process.removeListener(signal, hook);
34
+ };
35
+ }
36
+ function ensureProcessExitsAfterDelay(waitUntilExitMs = 1e4, startedAtMs = Date.now()) {
37
+ const expectedResources = [
38
+ process.stdout.isTTY ? "TTYWrap" : "PipeWrap",
39
+ process.stderr.isTTY ? "TTYWrap" : "PipeWrap",
40
+ process.stdin.isTTY ? "TTYWrap" : "PipeWrap"
41
+ ], activeResources = process.getActiveResourcesInfo(), unexpectedActiveResources = activeResources.filter((activeResource) => {
42
+ const index = expectedResources.indexOf(activeResource);
43
+ return index >= 0 ? (expectedResources.splice(index, 1), !1) : !0;
44
+ });
45
+ if (!unexpectedActiveResources.length)
46
+ return debug("no active resources detected, process can safely exit");
47
+ if (debug(
48
+ "process is trying to exit, but is stuck on unexpected active resources:",
49
+ unexpectedActiveResources
50
+ ), Date.now() - startedAtMs > waitUntilExitMs)
51
+ return debug("active handles detected past the exit delay, forcefully exiting:", activeResources), tryWarnActiveProcesses(), process.exit(0);
52
+ const timeoutId = setTimeout(() => {
53
+ clearTimeout(timeoutId), ensureProcessExitsAfterDelay(waitUntilExitMs, startedAtMs);
54
+ }, 100);
55
+ }
56
+ function tryWarnActiveProcesses() {
57
+ let activeProcesses = [];
58
+ try {
59
+ const children = process._getActiveHandles().filter((handle) => handle instanceof ChildProcess);
60
+ children.length && (activeProcesses = children.map((child) => child.spawnargs.join(" ")));
61
+ } catch (error) {
62
+ debug("failed to get active process information:", error);
63
+ }
64
+ if (!activeProcesses.length)
65
+ warn("Something prevented Expo from exiting, forcefully exiting now.");
66
+ else {
67
+ const singularOrPlural = activeProcesses.length === 1 ? "1 process" : `${activeProcesses.length} processes`;
68
+ warn(`Detected ${singularOrPlural} preventing process from exiting, forcefully exiting now.`), warn(" - " + activeProcesses.join(`
69
+ - `));
70
+ }
71
+ }
72
+ function guardAsync(fn) {
73
+ let invoked = !1, returnValue;
74
+ return async (...args) => (invoked || (invoked = !0, returnValue = await fn(...args)), returnValue);
75
+ }
76
+ function warn(...message) {
77
+ console.warn(...message.map((value) => colors.yellow(value)));
78
+ }
79
+ export {
80
+ ensureProcessExitsAfterDelay,
81
+ guardAsync,
82
+ installExitHooks,
83
+ warn
84
+ };
85
+ //# sourceMappingURL=exit.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utils/exit.ts"],
4
+ "mappings": "AAMA,SAAS,oBAAoB;AAC7B,OAAO,aAAa;AAEpB,OAAO,YAAY;AAEnB,MAAM,QAAS,IAAI,MAAW;AAAC,GAIzB,mBAAqC,CAAC,UAAU,UAAU,WAAW,UAAU,GAI/E,QAAyB,CAAC;AAEhC,IAAI,cAAmC;AAGhC,SAAS,iBAAiB,eAA0C;AAEzE,SAAK,MAAM,WAET,cAAc,qBAAqB,IAGrC,MAAM,KAAK,aAAa,GAEjB,MAAM;AACX,UAAM,QAAQ,MAAM,QAAQ,aAAa;AACzC,IAAI,SAAS,KACX,MAAM,OAAO,OAAO,CAAC,GAGlB,MAAM,UACT,cAAc;AAAA,EAElB;AACF;AAGA,SAAS,eAAe,QAAwB;AAC9C,SAAO,WAAW,YAAY;AAC5B,UAAM,qBAAqB,MAAM,mBAAmB,MAAM,MAAM,GAAG;AAEnE,eAAW,CAAC,OAAO,SAAS,KAAK,OAAO,QAAQ,KAAK;AACnD,UAAI;AACF,cAAM,UAAU,MAAM;AAAA,MACxB,SAAS,OAAY;AACnB,cAAM,kCAAkC,KAAK,KAAK,KAAK;AA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,YAAY;AAEzD,IAAI,SAAS,WACX,kBAAkB,SAAS,IAAI,CAAC,UAAU,MAAM,UAAU,KAAK,GAAG,CAAC;AAAA,EAEvE,SAAS,OAAO;AACd,UAAM,6CAA6C,KAAK;AAAA,EAC1D;AAEA,MAAI,CAAC,gBAAgB;AACnB,SAAK,gEAAgE;AAAA,OAChE;AACL,UAAM,mBACJ,gBAAgB,WAAW,IAAI,cAAc,GAAG,gBAAgB,MAAM;AAExE,SAAK,YAAY,gBAAgB,2DAA2D,GAC5F,KAAK,SAAS,gBAAgB,KAAK;AAAA,KAAQ,CAAC;AAAA,EAC9C;AACF;AAGO,SAAS,WAAwD,IAAU;AAChF,MAAI,UAAU,IACV;AAWJ,SATmB,UAAU,UACtB,YACH,UAAU,IACV,cAAc,MAAM,GAAG,GAAG,IAAI,IAGzB;AAIX;AACO,SAAS,QAAQ,SAAyB;AAC/C,UAAQ,KAAK,GAAG,QAAQ,IAAI,CAAC,UAAU,OAAO,OAAO,KAAK,CAAC,CAAC;AAC9D;",
5
+ "names": []
6
+ }
@@ -0,0 +1,71 @@
1
+ import { ChildProcess } from "node:child_process";
2
+ import process from "node:process";
3
+ import colors from "picocolors";
4
+ const debug = (..._) => {},
5
+ PRE_EXIT_SIGNALS = ["SIGHUP", "SIGINT", "SIGTERM", "SIGBREAK"],
6
+ queue = [];
7
+ let unsubscribe = null;
8
+ function installExitHooks(asyncExitHook) {
9
+ return queue.length || (unsubscribe = attachMasterListener()), queue.push(asyncExitHook), () => {
10
+ const index = queue.indexOf(asyncExitHook);
11
+ index >= 0 && queue.splice(index, 1), queue.length || unsubscribe?.();
12
+ };
13
+ }
14
+ function createExitHook(signal) {
15
+ return guardAsync(async () => {
16
+ debug(`pre-exit (signal: ${signal}, queue length: ${queue.length})`);
17
+ for (const [index, hookAsync] of Object.entries(queue)) try {
18
+ await hookAsync(signal);
19
+ } catch (error) {
20
+ debug(`Error in exit hook: %O (queue: ${index})`, error);
21
+ }
22
+ debug(`post-exit (code: ${process.exitCode ?? 0})`), process.exit();
23
+ });
24
+ }
25
+ function attachMasterListener() {
26
+ const hooks = [];
27
+ for (const signal of PRE_EXIT_SIGNALS) {
28
+ const hook = createExitHook(signal);
29
+ hooks.push([signal, hook]), process.on(signal, hook);
30
+ }
31
+ return () => {
32
+ for (const [signal, hook] of hooks) process.removeListener(signal, hook);
33
+ };
34
+ }
35
+ function ensureProcessExitsAfterDelay(waitUntilExitMs = 1e4, startedAtMs = Date.now()) {
36
+ const expectedResources = [process.stdout.isTTY ? "TTYWrap" : "PipeWrap", process.stderr.isTTY ? "TTYWrap" : "PipeWrap", process.stdin.isTTY ? "TTYWrap" : "PipeWrap"],
37
+ activeResources = process.getActiveResourcesInfo(),
38
+ unexpectedActiveResources = activeResources.filter(activeResource => {
39
+ const index = expectedResources.indexOf(activeResource);
40
+ return index >= 0 ? (expectedResources.splice(index, 1), !1) : !0;
41
+ });
42
+ if (!unexpectedActiveResources.length) return debug("no active resources detected, process can safely exit");
43
+ if (debug("process is trying to exit, but is stuck on unexpected active resources:", unexpectedActiveResources), Date.now() - startedAtMs > waitUntilExitMs) return debug("active handles detected past the exit delay, forcefully exiting:", activeResources), tryWarnActiveProcesses(), process.exit(0);
44
+ const timeoutId = setTimeout(() => {
45
+ clearTimeout(timeoutId), ensureProcessExitsAfterDelay(waitUntilExitMs, startedAtMs);
46
+ }, 100);
47
+ }
48
+ function tryWarnActiveProcesses() {
49
+ let activeProcesses = [];
50
+ try {
51
+ const children = process._getActiveHandles().filter(handle => handle instanceof ChildProcess);
52
+ children.length && (activeProcesses = children.map(child => child.spawnargs.join(" ")));
53
+ } catch (error) {
54
+ debug("failed to get active process information:", error);
55
+ }
56
+ if (!activeProcesses.length) warn("Something prevented Expo from exiting, forcefully exiting now.");else {
57
+ const singularOrPlural = activeProcesses.length === 1 ? "1 process" : `${activeProcesses.length} processes`;
58
+ warn(`Detected ${singularOrPlural} preventing process from exiting, forcefully exiting now.`), warn(" - " + activeProcesses.join(`
59
+ - `));
60
+ }
61
+ }
62
+ function guardAsync(fn) {
63
+ let invoked = !1,
64
+ returnValue;
65
+ return async (...args) => (invoked || (invoked = !0, returnValue = await fn(...args)), returnValue);
66
+ }
67
+ function warn(...message) {
68
+ console.warn(...message.map(value => colors.yellow(value)));
69
+ }
70
+ export { ensureProcessExitsAfterDelay, guardAsync, installExitHooks, warn };
71
+ //# sourceMappingURL=exit.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ChildProcess","process","colors","debug","_","PRE_EXIT_SIGNALS","queue","unsubscribe","installExitHooks","asyncExitHook","length","attachMasterListener","push","index","indexOf","splice","createExitHook","signal","guardAsync","hookAsync","Object","entries","error","exitCode","exit","hooks","hook","on","removeListener","ensureProcessExitsAfterDelay","waitUntilExitMs","startedAtMs","Date","now","expectedResources","stdout","isTTY","stderr","stdin","activeResources","getActiveResourcesInfo","unexpectedActiveResources","filter","activeResource","tryWarnActiveProcesses","timeoutId","setTimeout","clearTimeout","activeProcesses","children","_getActiveHandles","handle","map","child","spawnargs","join","warn","singularOrPlural","fn","invoked","returnValue","args","message","console","value","yellow"],"sources":["../../../src/utils/exit.ts"],"sourcesContent":[null],"mappings":"AAMA,SAASA,YAAA,QAAoB;AAC7B,OAAOC,OAAA,MAAa;AAEpB,OAAOC,MAAA,MAAY;AAEnB,MAAMC,KAAA,GAASA,CAAA,GAAIC,CAAA,KAAW,CAAC;EAIzBC,gBAAA,GAAqC,CAAC,UAAU,UAAU,WAAW,UAAU;EAI/EC,KAAA,GAAyB,EAAC;AAEhC,IAAIC,WAAA,GAAmC;AAGhC,SAASC,iBAAiBC,aAAA,EAA0C;EAEzE,OAAKH,KAAA,CAAMI,MAAA,KAETH,WAAA,GAAcI,oBAAA,CAAqB,IAGrCL,KAAA,CAAMM,IAAA,CAAKH,aAAa,GAEjB,MAAM;IACX,MAAMI,KAAA,GAAQP,KAAA,CAAMQ,OAAA,CAAQL,aAAa;IACrCI,KAAA,IAAS,KACXP,KAAA,CAAMS,MAAA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gBtC,MAAA,KAAW,IAAI,cAAc,GAAGsC,eAAA,CAAgBtC,MAAM;IAExE8C,IAAA,CAAK,YAAYC,gBAAgB,2DAA2D,GAC5FD,IAAA,CAAK,SAASR,eAAA,CAAgBO,IAAA,CAAK;AAAA,KAAQ,CAAC;EAC9C;AACF;AAGO,SAASrC,WAAwDwC,EAAA,EAAU;EAChF,IAAIC,OAAA,GAAU;IACVC,WAAA;EAWJ,OATmB,UAAUC,IAAA,MACtBF,OAAA,KACHA,OAAA,GAAU,IACVC,WAAA,GAAc,MAAMF,EAAA,CAAG,GAAGG,IAAI,IAGzBD,WAAA;AAIX;AACO,SAASJ,KAAA,GAAQM,OAAA,EAAyB;EAC/CC,OAAA,CAAQP,IAAA,CAAK,GAAGM,OAAA,CAAQV,GAAA,CAAKY,KAAA,IAAU9D,MAAA,CAAO+D,MAAA,CAAOD,KAAK,CAAC,CAAC;AAC9D","ignoreList":[]}
@@ -0,0 +1,136 @@
1
+ import { ChildProcess } from "node:child_process";
2
+ import process from "node:process";
3
+ import colors from "picocolors";
4
+ var debug = function () {
5
+ for (var _len = arguments.length, _ = new Array(_len), _key = 0; _key < _len; _key++) _[_key] = arguments[_key];
6
+ },
7
+ PRE_EXIT_SIGNALS = ["SIGHUP", "SIGINT", "SIGTERM", "SIGBREAK"],
8
+ queue = [],
9
+ unsubscribe = null;
10
+ function installExitHooks(asyncExitHook) {
11
+ return queue.length || (unsubscribe = attachMasterListener()), queue.push(asyncExitHook), function () {
12
+ var index = queue.indexOf(asyncExitHook);
13
+ index >= 0 && queue.splice(index, 1), queue.length || unsubscribe?.();
14
+ };
15
+ }
16
+ function createExitHook(signal) {
17
+ return guardAsync(async function () {
18
+ debug(`pre-exit (signal: ${signal}, queue length: ${queue.length})`);
19
+ var _iteratorNormalCompletion = !0,
20
+ _didIteratorError = !1,
21
+ _iteratorError = void 0;
22
+ try {
23
+ for (var _iterator = Object.entries(queue)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
24
+ var [index, hookAsync] = _step.value;
25
+ try {
26
+ await hookAsync(signal);
27
+ } catch (error) {
28
+ debug(`Error in exit hook: %O (queue: ${index})`, error);
29
+ }
30
+ }
31
+ } catch (err) {
32
+ _didIteratorError = !0, _iteratorError = err;
33
+ } finally {
34
+ try {
35
+ !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
36
+ } finally {
37
+ if (_didIteratorError) throw _iteratorError;
38
+ }
39
+ }
40
+ var _process_exitCode;
41
+ debug(`post-exit (code: ${(_process_exitCode = process.exitCode) !== null && _process_exitCode !== void 0 ? _process_exitCode : 0})`), process.exit();
42
+ });
43
+ }
44
+ function attachMasterListener() {
45
+ var hooks = [],
46
+ _iteratorNormalCompletion = !0,
47
+ _didIteratorError = !1,
48
+ _iteratorError = void 0;
49
+ try {
50
+ for (var _iterator = PRE_EXIT_SIGNALS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
51
+ var signal = _step.value,
52
+ hook = createExitHook(signal);
53
+ hooks.push([signal, hook]), process.on(signal, hook);
54
+ }
55
+ } catch (err) {
56
+ _didIteratorError = !0, _iteratorError = err;
57
+ } finally {
58
+ try {
59
+ !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
60
+ } finally {
61
+ if (_didIteratorError) throw _iteratorError;
62
+ }
63
+ }
64
+ return function () {
65
+ var _iteratorNormalCompletion2 = !0,
66
+ _didIteratorError2 = !1,
67
+ _iteratorError2 = void 0;
68
+ try {
69
+ for (var _iterator2 = hooks[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
70
+ var [signal2, hook2] = _step2.value;
71
+ process.removeListener(signal2, hook2);
72
+ }
73
+ } catch (err) {
74
+ _didIteratorError2 = !0, _iteratorError2 = err;
75
+ } finally {
76
+ try {
77
+ !_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
78
+ } finally {
79
+ if (_didIteratorError2) throw _iteratorError2;
80
+ }
81
+ }
82
+ };
83
+ }
84
+ function ensureProcessExitsAfterDelay() {
85
+ var waitUntilExitMs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1e4,
86
+ startedAtMs = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Date.now(),
87
+ expectedResources = [process.stdout.isTTY ? "TTYWrap" : "PipeWrap", process.stderr.isTTY ? "TTYWrap" : "PipeWrap", process.stdin.isTTY ? "TTYWrap" : "PipeWrap"],
88
+ activeResources = process.getActiveResourcesInfo(),
89
+ unexpectedActiveResources = activeResources.filter(function (activeResource) {
90
+ var index = expectedResources.indexOf(activeResource);
91
+ return index >= 0 ? (expectedResources.splice(index, 1), !1) : !0;
92
+ }),
93
+ canExitProcess = !unexpectedActiveResources.length;
94
+ if (canExitProcess) return debug("no active resources detected, process can safely exit");
95
+ debug("process is trying to exit, but is stuck on unexpected active resources:", unexpectedActiveResources);
96
+ var elapsedTime = Date.now() - startedAtMs;
97
+ if (elapsedTime > waitUntilExitMs) return debug("active handles detected past the exit delay, forcefully exiting:", activeResources), tryWarnActiveProcesses(), process.exit(0);
98
+ var timeoutId = setTimeout(function () {
99
+ clearTimeout(timeoutId), ensureProcessExitsAfterDelay(waitUntilExitMs, startedAtMs);
100
+ }, 100);
101
+ }
102
+ function tryWarnActiveProcesses() {
103
+ var activeProcesses = [];
104
+ try {
105
+ var children = process._getActiveHandles().filter(function (handle) {
106
+ return handle instanceof ChildProcess;
107
+ });
108
+ children.length && (activeProcesses = children.map(function (child) {
109
+ return child.spawnargs.join(" ");
110
+ }));
111
+ } catch (error) {
112
+ debug("failed to get active process information:", error);
113
+ }
114
+ if (!activeProcesses.length) warn("Something prevented Expo from exiting, forcefully exiting now.");else {
115
+ var singularOrPlural = activeProcesses.length === 1 ? "1 process" : `${activeProcesses.length} processes`;
116
+ warn(`Detected ${singularOrPlural} preventing process from exiting, forcefully exiting now.`), warn(" - " + activeProcesses.join(`
117
+ - `));
118
+ }
119
+ }
120
+ function guardAsync(fn) {
121
+ var invoked = !1,
122
+ returnValue,
123
+ guard = async function () {
124
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
125
+ return invoked || (invoked = !0, returnValue = await fn(...args)), returnValue;
126
+ };
127
+ return guard;
128
+ }
129
+ function warn() {
130
+ for (var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++) message[_key] = arguments[_key];
131
+ console.warn(...message.map(function (value) {
132
+ return colors.yellow(value);
133
+ }));
134
+ }
135
+ export { ensureProcessExitsAfterDelay, guardAsync, installExitHooks, warn };
136
+ //# sourceMappingURL=exit.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ChildProcess","process","colors","debug","_len","arguments","length","_","Array","_key","PRE_EXIT_SIGNALS","queue","unsubscribe","installExitHooks","asyncExitHook","attachMasterListener","push","index","indexOf","splice","createExitHook","signal","guardAsync","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Object","entries","Symbol","iterator","_step","next","done","hookAsync","value","error","err","return","_process_exitCode","exitCode","exit","hooks","hook","on","_iteratorNormalCompletion2","_didIteratorError2","_iteratorError2","_iterator2","_step2","signal2","hook2","removeListener"],"sources":["../../../src/utils/exit.ts"],"sourcesContent":[null],"mappings":"AAMA,SAASA,YAAA,QAAoB;AAC7B,OAAOC,OAAA,MAAa;AAEpB,OAAOC,MAAA,MAAY;AAEnB,IAAAC,KAAM,YAAAA,CAAA,EAAa;IAAY,KAIzB,IAAAC,IAAA,GAAAC,SAAsC,CAAAC,MAAU,EAAAC,CAAA,OAAUC,KAAA,CAAAJ,IAAW,GAAAK,IAAA,GAAU,GAI/EA,IAAA,GAAAL,IAA0B,EAAAK,IAAA,IAE5BF,CAAA,CAAAE,IAAA,IAAAJ,SAAmC,CAAAI,IAAA;EAGhC;EAAAC,gBAAS,IAEd,QAAK,EAQH,QAAM,EACN,SAAI,EAON,WAC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6B,IAAAG,UAAiB,CAAAV,MAAO,IAAK,IAAE,IAAAU,UAAA,CAAAV,MAAA;MAC9D","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vxrn/vite-plugin-metro",
3
- "version": "1.1.529",
3
+ "version": "1.1.531",
4
4
  "sideEffects": false,
5
5
  "type": "module",
6
6
  "main": "dist/cjs",
@@ -60,7 +60,7 @@
60
60
  "@babel/core": "^7.26.8",
61
61
  "@babel/helper-plugin-utils": "^7.26.8",
62
62
  "@babel/types": "^7.26.8",
63
- "@vxrn/debug": "1.1.529",
63
+ "@vxrn/debug": "1.1.531",
64
64
  "babel-preset-expo": "*",
65
65
  "launch-editor": "^2.10.0",
66
66
  "picocolors": "^1.0.0"
@@ -69,7 +69,7 @@
69
69
  "@biomejs/biome": "1.9.4",
70
70
  "@expo/metro-config": "^0.19.8",
71
71
  "@react-native/dev-middleware": "~0.79.2",
72
- "@tamagui/build": "^1.132.19",
72
+ "@tamagui/build": "^1.132.23",
73
73
  "@types/babel__helper-plugin-utils": "^7",
74
74
  "@types/node": "^22.1.0",
75
75
  "depcheck": "^1.4.7",
@@ -5,6 +5,7 @@ import { buildBundleWithConfig } from './buildBundleWithConfig'
5
5
  import { patchMetroServerWithViteConfigAndMetroPluginOptions } from '../../metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions'
6
6
  import { projectResolve } from '../../utils/projectImport'
7
7
  import type { BundleCommandArgs } from './types'
8
+ import { ensureProcessExitsAfterDelay } from '../../utils/exit'
8
9
 
9
10
  export async function buildBundle(
10
11
  this: { viteConfig: ResolvedConfig; metroPluginOptions: MetroPluginOptions },
@@ -48,10 +49,5 @@ export async function buildBundle(
48
49
 
49
50
  console.info('Done.')
50
51
 
51
- // Prevent the process not getting exited for some unknown reason.
52
- // If the process is not exited, it might hang the native build process.
53
- setTimeout(() => {
54
- console.info('Exiting process to prevent hanging.')
55
- process.exit()
56
- }, 3000)
52
+ ensureProcessExitsAfterDelay()
57
53
  }
@@ -0,0 +1,188 @@
1
+ /*
2
+ * Portions of this file are based on code from Expo CLI
3
+ * Copyright (c) 2015-present 650 Industries, Inc. (aka Expo)
4
+ * Licensed under the MIT License
5
+ */
6
+
7
+ import { ChildProcess } from 'node:child_process'
8
+ import process from 'node:process'
9
+
10
+ import colors from 'picocolors'
11
+
12
+ const debug = ((..._: any) => {}) as typeof console.debug
13
+
14
+ type AsyncExitHook = (signal: NodeJS.Signals) => void | Promise<void>
15
+
16
+ const PRE_EXIT_SIGNALS: NodeJS.Signals[] = ['SIGHUP', 'SIGINT', 'SIGTERM', 'SIGBREAK']
17
+
18
+ // We create a queue since Node.js throws an error if we try to append too many listeners:
19
+ // (node:4405) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added to [process]. Use emitter.setMaxListeners() to increase limit
20
+ const queue: AsyncExitHook[] = []
21
+
22
+ let unsubscribe: (() => void) | null = null
23
+
24
+ /** Add functions that run before the process exits. Returns a function for removing the listeners. */
25
+ export function installExitHooks(asyncExitHook: AsyncExitHook): () => void {
26
+ // We need to instantiate the master listener the first time the queue is used.
27
+ if (!queue.length) {
28
+ // Track the master listener so we can remove it later.
29
+ unsubscribe = attachMasterListener()
30
+ }
31
+
32
+ queue.push(asyncExitHook)
33
+
34
+ return () => {
35
+ const index = queue.indexOf(asyncExitHook)
36
+ if (index >= 0) {
37
+ queue.splice(index, 1)
38
+ }
39
+ // Clean up the master listener if we don't need it anymore.
40
+ if (!queue.length) {
41
+ unsubscribe?.()
42
+ }
43
+ }
44
+ }
45
+
46
+ // Create a function that runs before the process exits and guards against running multiple times.
47
+ function createExitHook(signal: NodeJS.Signals) {
48
+ return guardAsync(async () => {
49
+ debug(`pre-exit (signal: ${signal}, queue length: ${queue.length})`)
50
+
51
+ for (const [index, hookAsync] of Object.entries(queue)) {
52
+ try {
53
+ await hookAsync(signal)
54
+ } catch (error: any) {
55
+ debug(`Error in exit hook: %O (queue: ${index})`, error)
56
+ }
57
+ }
58
+
59
+ debug(`post-exit (code: ${process.exitCode ?? 0})`)
60
+
61
+ process.exit()
62
+ })
63
+ }
64
+
65
+ function attachMasterListener() {
66
+ const hooks: [NodeJS.Signals, () => any][] = []
67
+ for (const signal of PRE_EXIT_SIGNALS) {
68
+ const hook = createExitHook(signal)
69
+ hooks.push([signal, hook])
70
+ process.on(signal, hook)
71
+ }
72
+ return () => {
73
+ for (const [signal, hook] of hooks) {
74
+ process.removeListener(signal, hook)
75
+ }
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Monitor if the current process is exiting before the delay is reached.
81
+ * If there are active resources, the process will be forced to exit after the delay is reached.
82
+ *
83
+ * @see https://nodejs.org/docs/latest-v18.x/api/process.html#processgetactiveresourcesinfo
84
+ */
85
+ export function ensureProcessExitsAfterDelay(waitUntilExitMs = 10000, startedAtMs = Date.now()) {
86
+ // Create a list of the expected active resources before exiting.
87
+ // Note, the order is undeterministic
88
+ const expectedResources = [
89
+ process.stdout.isTTY ? 'TTYWrap' : 'PipeWrap',
90
+ process.stderr.isTTY ? 'TTYWrap' : 'PipeWrap',
91
+ process.stdin.isTTY ? 'TTYWrap' : 'PipeWrap',
92
+ ]
93
+ // Check active resources, besides the TTYWrap/PipeWrap (process.stdin, process.stdout, process.stderr)
94
+ const activeResources = process.getActiveResourcesInfo() as string[]
95
+ // Filter the active resource list by subtracting the expected resources, in undeterministic order
96
+ const unexpectedActiveResources = activeResources.filter((activeResource) => {
97
+ const index = expectedResources.indexOf(activeResource)
98
+ if (index >= 0) {
99
+ expectedResources.splice(index, 1)
100
+ return false
101
+ }
102
+
103
+ return true
104
+ })
105
+
106
+ const canExitProcess = !unexpectedActiveResources.length
107
+ if (canExitProcess) {
108
+ return debug('no active resources detected, process can safely exit')
109
+ }
110
+ debug(
111
+ `process is trying to exit, but is stuck on unexpected active resources:`,
112
+ unexpectedActiveResources
113
+ )
114
+
115
+ // Check if the process needs to be force-closed
116
+ const elapsedTime = Date.now() - startedAtMs
117
+ if (elapsedTime > waitUntilExitMs) {
118
+ debug('active handles detected past the exit delay, forcefully exiting:', activeResources)
119
+ tryWarnActiveProcesses()
120
+ return process.exit(0)
121
+ }
122
+
123
+ const timeoutId = setTimeout(() => {
124
+ // Ensure the timeout is cleared before checking the active resources
125
+ clearTimeout(timeoutId)
126
+ // Check if the process can exit
127
+ ensureProcessExitsAfterDelay(waitUntilExitMs, startedAtMs)
128
+ }, 100)
129
+ }
130
+
131
+ /**
132
+ * Try to warn the user about unexpected active processes running in the background.
133
+ * This uses the internal `process._getActiveHandles` method, within a try-catch block.
134
+ * If active child processes are detected, the commands of these processes are logged.
135
+ *
136
+ * @example ```bash
137
+ * Done writing bundle output
138
+ * Detected 2 processes preventing Expo from exiting, forcefully exiting now.
139
+ * - node /Users/cedric/../node_modules/nativewind/dist/metro/tailwind/v3/child.js
140
+ * - node /Users/cedric/../node_modules/nativewind/dist/metro/tailwind/v3/child.js
141
+ * ```
142
+ */
143
+ function tryWarnActiveProcesses() {
144
+ let activeProcesses: string[] = []
145
+
146
+ try {
147
+ const children: ChildProcess[] = process
148
+ // @ts-expect-error - This is an internal method, not designed to be exposed. It's also our only way to get this info
149
+ ._getActiveHandles()
150
+ .filter((handle: any) => handle instanceof ChildProcess)
151
+
152
+ if (children.length) {
153
+ activeProcesses = children.map((child) => child.spawnargs.join(' '))
154
+ }
155
+ } catch (error) {
156
+ debug('failed to get active process information:', error)
157
+ }
158
+
159
+ if (!activeProcesses.length) {
160
+ warn('Something prevented Expo from exiting, forcefully exiting now.')
161
+ } else {
162
+ const singularOrPlural =
163
+ activeProcesses.length === 1 ? '1 process' : `${activeProcesses.length} processes`
164
+
165
+ warn(`Detected ${singularOrPlural} preventing process from exiting, forcefully exiting now.`)
166
+ warn(' - ' + activeProcesses.join('\n - '))
167
+ }
168
+ }
169
+
170
+ /** memoizes an async function to prevent subsequent calls that might be invoked before the function has finished resolving. */
171
+ export function guardAsync<V, T extends (...args: any[]) => Promise<V>>(fn: T): T {
172
+ let invoked = false
173
+ let returnValue: V
174
+
175
+ const guard: any = async (...args: any[]): Promise<V> => {
176
+ if (!invoked) {
177
+ invoked = true
178
+ returnValue = await fn(...args)
179
+ }
180
+
181
+ return returnValue
182
+ }
183
+
184
+ return guard
185
+ }
186
+ export function warn(...message: string[]): void {
187
+ console.warn(...message.map((value) => colors.yellow(value)))
188
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"buildBundle.d.ts","sourceRoot":"","sources":["../../../src/rn-commands/bundle/buildBundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAA;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAKnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,wBAAsB,WAAW,CAC/B,IAAI,EAAE;IAAE,UAAU,EAAE,cAAc,CAAC;IAAC,kBAAkB,EAAE,kBAAkB,CAAA;CAAE,EAC5E,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EACpB,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,iBAAiB,EACzB,UAAU,GAAE,GAAU,GACrB,OAAO,CAAC,IAAI,CAAC,CA0Cf"}
1
+ {"version":3,"file":"buildBundle.d.ts","sourceRoot":"","sources":["../../../src/rn-commands/bundle/buildBundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAA;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAKnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAGhD,wBAAsB,WAAW,CAC/B,IAAI,EAAE;IAAE,UAAU,EAAE,cAAc,CAAC;IAAC,kBAAkB,EAAE,kBAAkB,CAAA;CAAE,EAC5E,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EACpB,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,iBAAiB,EACzB,UAAU,GAAE,GAAU,GACrB,OAAO,CAAC,IAAI,CAAC,CAqCf"}
@@ -0,0 +1,15 @@
1
+ type AsyncExitHook = (signal: NodeJS.Signals) => void | Promise<void>;
2
+ /** Add functions that run before the process exits. Returns a function for removing the listeners. */
3
+ export declare function installExitHooks(asyncExitHook: AsyncExitHook): () => void;
4
+ /**
5
+ * Monitor if the current process is exiting before the delay is reached.
6
+ * If there are active resources, the process will be forced to exit after the delay is reached.
7
+ *
8
+ * @see https://nodejs.org/docs/latest-v18.x/api/process.html#processgetactiveresourcesinfo
9
+ */
10
+ export declare function ensureProcessExitsAfterDelay(waitUntilExitMs?: number, startedAtMs?: number): void;
11
+ /** memoizes an async function to prevent subsequent calls that might be invoked before the function has finished resolving. */
12
+ export declare function guardAsync<V, T extends (...args: any[]) => Promise<V>>(fn: T): T;
13
+ export declare function warn(...message: string[]): void;
14
+ export {};
15
+ //# sourceMappingURL=exit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit.d.ts","sourceRoot":"","sources":["../../src/utils/exit.ts"],"names":[],"mappings":"AAaA,KAAK,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAUrE,sGAAsG;AACtG,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,aAAa,GAAG,MAAM,IAAI,CAmBzE;AAmCD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,eAAe,SAAQ,EAAE,WAAW,SAAa,QA4C7F;AAyCD,+HAA+H;AAC/H,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAchF;AACD,wBAAgB,IAAI,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAE/C"}