vxrn 2.13.8 → 2.13.9

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.
Files changed (118) hide show
  1. package/dist/cli.mjs +3 -2
  2. package/dist/cli.mjs.map +1 -1
  3. package/dist/cli.native.js +5 -2
  4. package/dist/cli.native.js.map +1 -1
  5. package/dist/config/getBaseViteConfigOnly.mjs +3 -3
  6. package/dist/config/getBaseViteConfigOnly.mjs.map +1 -1
  7. package/dist/config/getBaseViteConfigOnly.native.js +3 -3
  8. package/dist/config/getBaseViteConfigOnly.native.js.map +1 -1
  9. package/dist/config/getOptionsFilled.mjs +24 -2
  10. package/dist/config/getOptionsFilled.mjs.map +1 -1
  11. package/dist/config/getOptionsFilled.native.js +25 -2
  12. package/dist/config/getOptionsFilled.native.js.map +1 -1
  13. package/dist/config/getServerOptionsFilled.mjs +119 -1
  14. package/dist/config/getServerOptionsFilled.mjs.map +1 -1
  15. package/dist/config/getServerOptionsFilled.native.js +137 -1
  16. package/dist/config/getServerOptionsFilled.native.js.map +1 -1
  17. package/dist/exports/build.mjs +5 -5
  18. package/dist/exports/build.mjs.map +1 -1
  19. package/dist/exports/build.native.js +5 -5
  20. package/dist/exports/build.native.js.map +1 -1
  21. package/dist/exports/dev.mjs +4 -6
  22. package/dist/exports/dev.mjs.map +1 -1
  23. package/dist/exports/dev.native.js +6 -6
  24. package/dist/exports/dev.native.js.map +1 -1
  25. package/dist/exports/prebuild.mjs +4 -4
  26. package/dist/exports/prebuild.mjs.map +1 -1
  27. package/dist/exports/prebuild.native.js +4 -4
  28. package/dist/exports/prebuild.native.js.map +1 -1
  29. package/dist/exports/prebuildWithoutExpo.mjs +95 -88
  30. package/dist/exports/prebuildWithoutExpo.mjs.map +1 -1
  31. package/dist/exports/prebuildWithoutExpo.native.js +95 -88
  32. package/dist/exports/prebuildWithoutExpo.native.js.map +1 -1
  33. package/dist/plugins/autoDepOptimizePlugin.mjs +3 -3
  34. package/dist/plugins/autoDepOptimizePlugin.mjs.map +1 -1
  35. package/dist/plugins/autoDepOptimizePlugin.native.js +3 -3
  36. package/dist/plugins/autoDepOptimizePlugin.native.js.map +1 -1
  37. package/dist/plugins/reactNativeDevAssetPlugin.mjs +4 -4
  38. package/dist/plugins/reactNativeDevAssetPlugin.mjs.map +1 -1
  39. package/dist/plugins/reactNativeDevAssetPlugin.native.js +4 -4
  40. package/dist/plugins/reactNativeDevAssetPlugin.native.js.map +1 -1
  41. package/dist/rn-commands/bundle/buildBundle.mjs +18 -5
  42. package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
  43. package/dist/rn-commands/bundle/buildBundle.native.js +18 -5
  44. package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
  45. package/dist/user-interface/index.mjs +1 -1
  46. package/dist/user-interface/index.mjs.map +1 -1
  47. package/dist/user-interface/index.native.js +1 -1
  48. package/dist/user-interface/index.native.js.map +1 -1
  49. package/dist/utils/env-editor.mjs +198 -0
  50. package/dist/utils/env-editor.mjs.map +1 -0
  51. package/dist/utils/env-editor.native.js +266 -0
  52. package/dist/utils/env-editor.native.js.map +1 -0
  53. package/dist/utils/fs.mjs +48 -0
  54. package/dist/utils/fs.mjs.map +1 -0
  55. package/dist/utils/fs.native.js +48 -0
  56. package/dist/utils/fs.native.js.map +1 -0
  57. package/dist/utils/getVitePath.mjs +2 -2
  58. package/dist/utils/getVitePath.mjs.map +1 -1
  59. package/dist/utils/getVitePath.native.js +2 -2
  60. package/dist/utils/getVitePath.native.js.map +1 -1
  61. package/dist/utils/patches.mjs +38 -29
  62. package/dist/utils/patches.mjs.map +1 -1
  63. package/dist/utils/patches.native.js +38 -29
  64. package/dist/utils/patches.native.js.map +1 -1
  65. package/dist/utils/scanDepsToOptimize.mjs +12 -11
  66. package/dist/utils/scanDepsToOptimize.mjs.map +1 -1
  67. package/dist/utils/scanDepsToOptimize.native.js +12 -11
  68. package/dist/utils/scanDepsToOptimize.native.js.map +1 -1
  69. package/dist/utils/state.mjs +5 -5
  70. package/dist/utils/state.mjs.map +1 -1
  71. package/dist/utils/state.native.js +5 -5
  72. package/dist/utils/state.native.js.map +1 -1
  73. package/dist/utils/utils.mjs +4 -3
  74. package/dist/utils/utils.mjs.map +1 -1
  75. package/dist/utils/utils.native.js +4 -3
  76. package/dist/utils/utils.native.js.map +1 -1
  77. package/package.json +12 -18
  78. package/src/cli.ts +5 -4
  79. package/src/config/getBaseViteConfigOnly.ts +3 -3
  80. package/src/config/getOptionsFilled.ts +35 -2
  81. package/src/config/getServerOptionsFilled.test.ts +37 -0
  82. package/src/config/getServerOptionsFilled.ts +57 -1
  83. package/src/exports/build.ts +5 -5
  84. package/src/exports/clean.test.ts +1 -1
  85. package/src/exports/dev.ts +5 -6
  86. package/src/exports/prebuild.ts +4 -4
  87. package/src/exports/prebuildWithoutExpo.ts +102 -89
  88. package/src/plugins/autoDepOptimizePlugin.ts +3 -3
  89. package/src/plugins/reactNativeDevAssetPlugin.ts +4 -4
  90. package/src/rn-commands/bundle/buildBundle.ts +15 -5
  91. package/src/user-interface/index.ts +1 -1
  92. package/src/utils/env-editor.LICENSE +9 -0
  93. package/src/utils/env-editor.ts +214 -0
  94. package/src/utils/fs.ts +59 -0
  95. package/src/utils/getVitePath.ts +2 -2
  96. package/src/utils/patches.test.ts +36 -36
  97. package/src/utils/patches.ts +39 -27
  98. package/src/utils/scanDepsToOptimize.test.ts +2 -2
  99. package/src/utils/scanDepsToOptimize.ts +6 -5
  100. package/src/utils/state.ts +5 -7
  101. package/src/utils/utils.ts +5 -5
  102. package/types/config/getOptionsFilled.d.ts +9 -2
  103. package/types/config/getOptionsFilled.d.ts.map +1 -1
  104. package/types/config/getServerOptionsFilled.d.ts.map +1 -1
  105. package/types/exports/build.d.ts +1 -1
  106. package/types/exports/dev.d.ts.map +1 -1
  107. package/types/exports/prebuildWithoutExpo.d.ts.map +1 -1
  108. package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
  109. package/types/user-interface/index.d.ts.map +1 -1
  110. package/types/utils/env-editor.d.ts +9 -0
  111. package/types/utils/env-editor.d.ts.map +1 -0
  112. package/types/utils/fs.d.ts +9 -0
  113. package/types/utils/fs.d.ts.map +1 -0
  114. package/types/utils/patches.d.ts.map +1 -1
  115. package/types/utils/scanDepsToOptimize.d.ts.map +1 -1
  116. package/types/utils/state.d.ts.map +1 -1
  117. package/types/utils/utils.d.ts +2 -2
  118. package/types/utils/utils.d.ts.map +1 -1
@@ -1,6 +1,6 @@
1
1
  import { createDebugger } from "@vxrn/debug";
2
- import FSExtra from "fs-extra";
3
2
  import path from "node:path";
3
+ import { outputJSON, readJSON } from "../utils/fs.mjs";
4
4
  import { createFilter } from "vite";
5
5
  import { EXCLUDE_LIST, scanDepsToOptimize } from "../utils/scanDepsToOptimize.mjs";
6
6
  import { getFileHash, lookupFile } from "../utils/utils.mjs";
@@ -77,7 +77,7 @@ async function findDepsToOptimize({ root, mode, exclude, include }) {
77
77
  let value;
78
78
  if (lockFileHash && !noCache) {
79
79
  try {
80
- const { lockFileHash: cachedLockFileHash, depsToPreBundleForSsr: cachedDepsToPreBundle } = await FSExtra.readJSON(cacheFilePath);
80
+ const { lockFileHash: cachedLockFileHash, depsToPreBundleForSsr: cachedDepsToPreBundle } = await readJSON(cacheFilePath);
81
81
  if (lockFileHash === cachedLockFileHash && !!cachedDepsToPreBundle && "prebundleDeps" in cachedDepsToPreBundle && Array.isArray(cachedDepsToPreBundle.noExternalDeps)) {
82
82
  value = cachedDepsToPreBundle;
83
83
  debug?.(`Using cached scan results from ${cacheFilePath}`);
@@ -93,7 +93,7 @@ async function findDepsToOptimize({ root, mode, exclude, include }) {
93
93
  sessionCacheVal = value;
94
94
  }
95
95
  if (!noCache) {
96
- void FSExtra.outputJSON(cacheFilePath, {
96
+ void outputJSON(cacheFilePath, {
97
97
  lockFileHash,
98
98
  depsToPreBundleForSsr: value
99
99
  });
@@ -1 +1 @@
1
- {"version":3,"file":"autoDepOptimizePlugin.js","names":[],"sources":["plugins/autoDepOptimizePlugin.js"],"sourcesContent":["import { createDebugger } from \"@vxrn/debug\";\nimport FSExtra from \"fs-extra\";\nimport path from \"node:path\";\nimport { createFilter } from \"vite\";\nimport {\n EXCLUDE_LIST,\n scanDepsToOptimize\n} from \"../utils/scanDepsToOptimize\";\nimport { getFileHash, lookupFile } from \"../utils/utils\";\nimport { getCacheDir } from \"../utils/getCacheDir\";\nconst name = \"vxrn:auto-dep-optimize\";\nconst { debug, debugDetails } = createDebugger(name);\nfunction autoDepOptimizePlugin(props) {\n return {\n name,\n enforce: \"pre\",\n async config(cfg, env) {\n debug?.(\"Config hook called\");\n const userOptions = globalThis.__oneOptions;\n const depsConfig = userOptions?.deps;\n const exclude = depsConfig ? Object.entries(depsConfig).filter(([_, value]) => value === false).map(([k]) => k) : [];\n const userExcludes = Array.isArray(props.exclude) ? props.exclude : [props.exclude];\n const userViteExcludes = cfg.optimizeDeps?.exclude || [];\n const userSsrExcludes = cfg.ssr?.optimizeDeps?.exclude || [];\n const finalConfig = await getScannedOptimizeDepsConfig({\n ...props,\n mode: env.mode,\n external: cfg.ssr?.external,\n exclude: [\n ...exclude,\n ...userExcludes,\n ...userViteExcludes,\n ...userSsrExcludes\n ].filter(Boolean)\n });\n debugDetails?.(\n `Final auto-dep-optimize config: ${JSON.stringify(finalConfig, null, 2)}\nfrom props: ${JSON.stringify(props)}`\n );\n return finalConfig;\n }\n };\n}\nconst getSSRExternalsCachePath = (root) => {\n return path.join(getCacheDir(root), \"deps-to-pre-bundle-for-ssr-cache.json\");\n};\nasync function getScannedOptimizeDepsConfig(props) {\n const result = await findDepsToOptimize(props);\n props.onScannedDeps?.(result);\n const excludeArray = Array.isArray(props.exclude) ? props.exclude : [props.exclude];\n const excludeStrings = excludeArray.filter((e) => typeof e === \"string\");\n const excludeSet = new Set(excludeStrings);\n const external = props.external;\n const shouldOptimize = (dep) => !excludeSet.has(dep) && external !== true && !external?.some((name2) => dep === name2 || dep.startsWith(`${name2}/`));\n const filteredDeps = result.prebundleDeps.filter(shouldOptimize);\n return {\n ssr: {\n optimizeDeps: {\n include: filteredDeps,\n exclude: EXCLUDE_LIST\n },\n noExternal: [...filteredDeps, ...result.noExternalDeps.filter(shouldOptimize)]\n }\n };\n}\nlet sessionCacheVal = null;\nasync function findDepsToOptimize({\n root,\n mode,\n exclude,\n include\n}) {\n const cacheFilePath = getSSRExternalsCachePath(root);\n const startedAt = debug ? Date.now() : 0;\n const noCache = mode === \"production\";\n const sessionCache = mode === \"production\";\n if (sessionCache && sessionCacheVal) {\n return sessionCacheVal;\n }\n const lockFile = await lookupFile(root, [\n \"yarn.lock\",\n \"package-lock.json\",\n \"pnpm-lock.yaml\",\n \"bun.lock\",\n \"bun.lockb\"\n ]);\n const lockFileHash = lockFile ? await getFileHash(lockFile) : void 0;\n let value;\n if (lockFileHash && !noCache) {\n try {\n const {\n lockFileHash: cachedLockFileHash,\n depsToPreBundleForSsr: cachedDepsToPreBundle\n } = await FSExtra.readJSON(cacheFilePath);\n if (lockFileHash === cachedLockFileHash && !!cachedDepsToPreBundle && \"prebundleDeps\" in cachedDepsToPreBundle && Array.isArray(cachedDepsToPreBundle.noExternalDeps)) {\n value = cachedDepsToPreBundle;\n debug?.(`Using cached scan results from ${cacheFilePath}`);\n }\n } catch (err) {\n debug?.(`${err}`);\n }\n }\n const filter = createFilter(include, exclude);\n if (!value) {\n value = await scanDepsToOptimize(`${root}/package.json`, { filter });\n if (sessionCache) {\n sessionCacheVal = value;\n }\n if (!noCache) {\n void FSExtra.outputJSON(cacheFilePath, {\n lockFileHash,\n depsToPreBundleForSsr: value\n });\n }\n }\n debug?.(`Scanning completed in ${Date.now() - startedAt}ms`);\n debug?.(\n `${value.prebundleDeps.length} deps are discovered and will be pre-bundled for SSR.` + (debugDetails ? \"\" : ` (Focus on this debug scope, \"DEBUG=${debug.namespace}\", to see more details.)`)\n );\n debugDetails?.(\n `Deps discovered to be pre-bundled for SSR: ${value.prebundleDeps.join(\", \")}`\n );\n return value;\n}\nexport {\n autoDepOptimizePlugin,\n findDepsToOptimize,\n getSSRExternalsCachePath,\n getScannedOptimizeDepsConfig\n};\n//# sourceMappingURL=autoDepOptimizePlugin.js.map\n"],"mappings":";;;;;;;;;AAUA,MAAM,OAAO;AACb,MAAM,EAAE,OAAO,iBAAiB,eAAe,IAAI;AACnD,SAAS,sBAAsB,OAAO;CACpC,OAAO;EACL;EACA,SAAS;EACT,MAAM,OAAO,KAAK,KAAK;GACrB,QAAQ,oBAAoB;GAC5B,MAAM,cAAc,WAAW;GAC/B,MAAM,aAAa,aAAa;GAChC,MAAM,UAAU,aAAa,OAAO,QAAQ,UAAU,CAAC,CAAC,QAAQ,CAAC,GAAG,WAAW,UAAU,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;GACnH,MAAM,eAAe,MAAM,QAAQ,MAAM,OAAO,IAAI,MAAM,UAAU,CAAC,MAAM,OAAO;GAClF,MAAM,mBAAmB,IAAI,cAAc,WAAW,CAAC;GACvD,MAAM,kBAAkB,IAAI,KAAK,cAAc,WAAW,CAAC;GAC3D,MAAM,cAAc,MAAM,6BAA6B;IACrD,GAAG;IACH,MAAM,IAAI;IACV,UAAU,IAAI,KAAK;IACnB,SAAS;KACP,GAAG;KACH,GAAG;KACH,GAAG;KACH,GAAG;IACL,CAAC,CAAC,OAAO,OAAO;GAClB,CAAC;GACD,eACE,mCAAmC,KAAK,UAAU,aAAa,MAAM,CAAC,EAAE;cAClE,KAAK,UAAU,KAAK,GAC5B;GACA,OAAO;EACT;CACF;AACF;AACA,MAAM,4BAA4B,SAAS;CACzC,OAAO,KAAK,KAAK,YAAY,IAAI,GAAG,uCAAuC;AAC7E;AACA,eAAe,6BAA6B,OAAO;CACjD,MAAM,SAAS,MAAM,mBAAmB,KAAK;CAC7C,MAAM,gBAAgB,MAAM;CAC5B,MAAM,eAAe,MAAM,QAAQ,MAAM,OAAO,IAAI,MAAM,UAAU,CAAC,MAAM,OAAO;CAClF,MAAM,iBAAiB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E,OAAO,CAAC;EACnE,IAAI,cAAc;GAChB,kBAAkB;EACpB;EACA,IAAI,CAAC,SAAS;GACZ,KAAK,QAAQ,WAAW,eAAe;IACrC;IACA,uBAAuB;GACzB,CAAC;EACH;CACF;CACA,QAAQ,yBAAyB,KAAK,IAAI,IAAI,UAAU,GAAG;CAC3D,QACE,GAAG,MAAM,cAAc,OAAO,0DAA0D,eAAe,KAAK,uCAAuC,MAAM,UAAU,0BACrK;CACA,eACE,8CAA8C,MAAM,cAAc,KAAK,IAAI,GAC7E;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"autoDepOptimizePlugin.js","names":[],"sources":["plugins/autoDepOptimizePlugin.js"],"sourcesContent":["import { createDebugger } from \"@vxrn/debug\";\nimport path from \"node:path\";\nimport { outputJSON, readJSON } from \"../utils/fs\";\nimport { createFilter } from \"vite\";\nimport {\n EXCLUDE_LIST,\n scanDepsToOptimize\n} from \"../utils/scanDepsToOptimize\";\nimport { getFileHash, lookupFile } from \"../utils/utils\";\nimport { getCacheDir } from \"../utils/getCacheDir\";\nconst name = \"vxrn:auto-dep-optimize\";\nconst { debug, debugDetails } = createDebugger(name);\nfunction autoDepOptimizePlugin(props) {\n return {\n name,\n enforce: \"pre\",\n async config(cfg, env) {\n debug?.(\"Config hook called\");\n const userOptions = globalThis.__oneOptions;\n const depsConfig = userOptions?.deps;\n const exclude = depsConfig ? Object.entries(depsConfig).filter(([_, value]) => value === false).map(([k]) => k) : [];\n const userExcludes = Array.isArray(props.exclude) ? props.exclude : [props.exclude];\n const userViteExcludes = cfg.optimizeDeps?.exclude || [];\n const userSsrExcludes = cfg.ssr?.optimizeDeps?.exclude || [];\n const finalConfig = await getScannedOptimizeDepsConfig({\n ...props,\n mode: env.mode,\n external: cfg.ssr?.external,\n exclude: [\n ...exclude,\n ...userExcludes,\n ...userViteExcludes,\n ...userSsrExcludes\n ].filter(Boolean)\n });\n debugDetails?.(\n `Final auto-dep-optimize config: ${JSON.stringify(finalConfig, null, 2)}\nfrom props: ${JSON.stringify(props)}`\n );\n return finalConfig;\n }\n };\n}\nconst getSSRExternalsCachePath = (root) => {\n return path.join(getCacheDir(root), \"deps-to-pre-bundle-for-ssr-cache.json\");\n};\nasync function getScannedOptimizeDepsConfig(props) {\n const result = await findDepsToOptimize(props);\n props.onScannedDeps?.(result);\n const excludeArray = Array.isArray(props.exclude) ? props.exclude : [props.exclude];\n const excludeStrings = excludeArray.filter((e) => typeof e === \"string\");\n const excludeSet = new Set(excludeStrings);\n const external = props.external;\n const shouldOptimize = (dep) => !excludeSet.has(dep) && external !== true && !external?.some((name2) => dep === name2 || dep.startsWith(`${name2}/`));\n const filteredDeps = result.prebundleDeps.filter(shouldOptimize);\n return {\n ssr: {\n optimizeDeps: {\n include: filteredDeps,\n exclude: EXCLUDE_LIST\n },\n noExternal: [...filteredDeps, ...result.noExternalDeps.filter(shouldOptimize)]\n }\n };\n}\nlet sessionCacheVal = null;\nasync function findDepsToOptimize({\n root,\n mode,\n exclude,\n include\n}) {\n const cacheFilePath = getSSRExternalsCachePath(root);\n const startedAt = debug ? Date.now() : 0;\n const noCache = mode === \"production\";\n const sessionCache = mode === \"production\";\n if (sessionCache && sessionCacheVal) {\n return sessionCacheVal;\n }\n const lockFile = await lookupFile(root, [\n \"yarn.lock\",\n \"package-lock.json\",\n \"pnpm-lock.yaml\",\n \"bun.lock\",\n \"bun.lockb\"\n ]);\n const lockFileHash = lockFile ? await getFileHash(lockFile) : void 0;\n let value;\n if (lockFileHash && !noCache) {\n try {\n const {\n lockFileHash: cachedLockFileHash,\n depsToPreBundleForSsr: cachedDepsToPreBundle\n } = await readJSON(cacheFilePath);\n if (lockFileHash === cachedLockFileHash && !!cachedDepsToPreBundle && \"prebundleDeps\" in cachedDepsToPreBundle && Array.isArray(cachedDepsToPreBundle.noExternalDeps)) {\n value = cachedDepsToPreBundle;\n debug?.(`Using cached scan results from ${cacheFilePath}`);\n }\n } catch (err) {\n debug?.(`${err}`);\n }\n }\n const filter = createFilter(include, exclude);\n if (!value) {\n value = await scanDepsToOptimize(`${root}/package.json`, { filter });\n if (sessionCache) {\n sessionCacheVal = value;\n }\n if (!noCache) {\n void outputJSON(cacheFilePath, {\n lockFileHash,\n depsToPreBundleForSsr: value\n });\n }\n }\n debug?.(`Scanning completed in ${Date.now() - startedAt}ms`);\n debug?.(\n `${value.prebundleDeps.length} deps are discovered and will be pre-bundled for SSR.` + (debugDetails ? \"\" : ` (Focus on this debug scope, \"DEBUG=${debug.namespace}\", to see more details.)`)\n );\n debugDetails?.(\n `Deps discovered to be pre-bundled for SSR: ${value.prebundleDeps.join(\", \")}`\n );\n return value;\n}\nexport {\n autoDepOptimizePlugin,\n findDepsToOptimize,\n getSSRExternalsCachePath,\n getScannedOptimizeDepsConfig\n};\n//# sourceMappingURL=autoDepOptimizePlugin.js.map\n"],"mappings":";;;;;;;;;AAUA,MAAM,OAAO;AACb,MAAM,EAAE,OAAO,iBAAiB,eAAe,IAAI;AACnD,SAAS,sBAAsB,OAAO;CACpC,OAAO;EACL;EACA,SAAS;EACT,MAAM,OAAO,KAAK,KAAK;GACrB,QAAQ,oBAAoB;GAC5B,MAAM,cAAc,WAAW;GAC/B,MAAM,aAAa,aAAa;GAChC,MAAM,UAAU,aAAa,OAAO,QAAQ,UAAU,CAAC,CAAC,QAAQ,CAAC,GAAG,WAAW,UAAU,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;GACnH,MAAM,eAAe,MAAM,QAAQ,MAAM,OAAO,IAAI,MAAM,UAAU,CAAC,MAAM,OAAO;GAClF,MAAM,mBAAmB,IAAI,cAAc,WAAW,CAAC;GACvD,MAAM,kBAAkB,IAAI,KAAK,cAAc,WAAW,CAAC;GAC3D,MAAM,cAAc,MAAM,6BAA6B;IACrD,GAAG;IACH,MAAM,IAAI;IACV,UAAU,IAAI,KAAK;IACnB,SAAS;KACP,GAAG;KACH,GAAG;KACH,GAAG;KACH,GAAG;IACL,CAAC,CAAC,OAAO,OAAO;G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S;EAC5B,IAAI;GACF,MAAM,EACJ,cAAc,oBACd,uBAAuB,0BACrB,MAAM,SAAS,aAAa;GAChC,IAAI,iBAAiB,sBAAsB,CAAC,CAAC,yBAAyB,mBAAmB,yBAAyB,MAAM,QAAQ,sBAAsB,cAAc,GAAG;IACrK,QAAQ;IACR,QAAQ,kCAAkC,eAAe;GAC3D;EACF,SAAS,KAAK;GACZ,QAAQ,GAAG,KAAK;EAClB;CACF;CACA,MAAM,SAAS,aAAa,SAAS,OAAO;CAC5C,IAAI,CAAC,OAAO;EACV,QAAQ,MAAM,mBAAmB,GAAG,KAAK,gBAAgB,EAAE,OAAO,CAAC;EACnE,IAAI,cAAc;GAChB,kBAAkB;EACpB;EACA,IAAI,CAAC,SAAS;GACZ,KAAK,WAAW,eAAe;IAC7B;IACA,uBAAuB;GACzB,CAAC;EACH;CACF;CACA,QAAQ,yBAAyB,KAAK,IAAI,IAAI,UAAU,GAAG;CAC3D,QACE,GAAG,MAAM,cAAc,OAAO,0DAA0D,eAAe,KAAK,uCAAuC,MAAM,UAAU,0BACrK;CACA,eACE,8CAA8C,MAAM,cAAc,KAAK,IAAI,GAC7E;CACA,OAAO;AACT"}
@@ -1,6 +1,6 @@
1
1
  import { createDebugger } from "@vxrn/debug";
2
- import FSExtra from "fs-extra";
3
2
  import path from "path";
3
+ import { outputJSON, readJSON } from "../utils/fs.native.js";
4
4
  import { createFilter } from "vite";
5
5
  import { EXCLUDE_LIST, scanDepsToOptimize } from "../utils/scanDepsToOptimize.native.js";
6
6
  import { getFileHash, lookupFile } from "../utils/utils.native.js";
@@ -92,7 +92,7 @@ async function findDepsToOptimize(param) {
92
92
  var value;
93
93
  if (lockFileHash && !noCache) {
94
94
  try {
95
- var { lockFileHash: cachedLockFileHash, depsToPreBundleForSsr: cachedDepsToPreBundle } = await FSExtra.readJSON(cacheFilePath);
95
+ var { lockFileHash: cachedLockFileHash, depsToPreBundleForSsr: cachedDepsToPreBundle } = await readJSON(cacheFilePath);
96
96
  if (lockFileHash === cachedLockFileHash && !!cachedDepsToPreBundle && "prebundleDeps" in cachedDepsToPreBundle && Array.isArray(cachedDepsToPreBundle.noExternalDeps)) {
97
97
  value = cachedDepsToPreBundle;
98
98
  debug === null || debug === void 0 ? void 0 : debug(`Using cached scan results from ${cacheFilePath}`);
@@ -108,7 +108,7 @@ async function findDepsToOptimize(param) {
108
108
  sessionCacheVal = value;
109
109
  }
110
110
  if (!noCache) {
111
- void FSExtra.outputJSON(cacheFilePath, {
111
+ void outputJSON(cacheFilePath, {
112
112
  lockFileHash,
113
113
  depsToPreBundleForSsr: value
114
114
  });
@@ -1 +1 @@
1
- {"version":3,"file":"autoDepOptimizePlugin.native.js","names":[],"sources":["plugins/autoDepOptimizePlugin.native.js"],"sourcesContent":["import { createDebugger } from \"@vxrn/debug\";\nimport FSExtra from \"fs-extra\";\nimport path from \"path\";\nimport { createFilter } from \"vite\";\nimport { EXCLUDE_LIST, scanDepsToOptimize } from \"../utils/scanDepsToOptimize\";\nimport { getFileHash, lookupFile } from \"../utils/utils\";\nimport { getCacheDir } from \"../utils/getCacheDir\";\nvar name = \"vxrn:auto-dep-optimize\";\nvar { debug, debugDetails } = createDebugger(name);\nfunction autoDepOptimizePlugin(props) {\n return {\n name,\n enforce: \"pre\",\n async config(cfg, env) {\n var _cfg_optimizeDeps, _cfg_ssr_optimizeDeps, _cfg_ssr, _cfg_ssr1;\n debug === null || debug === void 0 ? void 0 : debug(\"Config hook called\");\n var userOptions = globalThis.__oneOptions;\n var depsConfig = userOptions === null || userOptions === void 0 ? void 0 : userOptions.deps;\n var exclude = depsConfig ? Object.entries(depsConfig).filter(function(param) {\n var [_, value] = param;\n return value === false;\n }).map(function(param) {\n var [k] = param;\n return k;\n }) : [];\n var userExcludes = Array.isArray(props.exclude) ? props.exclude : [\n props.exclude\n ];\n var userViteExcludes = ((_cfg_optimizeDeps = cfg.optimizeDeps) === null || _cfg_optimizeDeps === void 0 ? void 0 : _cfg_optimizeDeps.exclude) || [];\n var userSsrExcludes = ((_cfg_ssr = cfg.ssr) === null || _cfg_ssr === void 0 ? void 0 : (_cfg_ssr_optimizeDeps = _cfg_ssr.optimizeDeps) === null || _cfg_ssr_optimizeDeps === void 0 ? void 0 : _cfg_ssr_optimizeDeps.exclude) || [];\n var finalConfig = await getScannedOptimizeDepsConfig({\n ...props,\n mode: env.mode,\n external: (_cfg_ssr1 = cfg.ssr) === null || _cfg_ssr1 === void 0 ? void 0 : _cfg_ssr1.external,\n exclude: [\n ...exclude,\n ...userExcludes,\n ...userViteExcludes,\n ...userSsrExcludes\n ].filter(Boolean)\n });\n debugDetails === null || debugDetails === void 0 ? void 0 : debugDetails(`Final auto-dep-optimize config: ${JSON.stringify(finalConfig, null, 2)}\nfrom props: ${JSON.stringify(props)}`);\n return finalConfig;\n }\n };\n}\nvar getSSRExternalsCachePath = function getSSRExternalsCachePath2(root) {\n return path.join(getCacheDir(root), \"deps-to-pre-bundle-for-ssr-cache.json\");\n};\nasync function getScannedOptimizeDepsConfig(props) {\n var _props_onScannedDeps;\n var result = await findDepsToOptimize(props);\n (_props_onScannedDeps = props.onScannedDeps) === null || _props_onScannedDeps === void 0 ? void 0 : _props_onScannedDeps.call(props, result);\n var excludeArray = Array.isArray(props.exclude) ? props.exclude : [\n props.exclude\n ];\n var excludeStrings = excludeArray.filter(function(e) {\n return typeof e === \"string\";\n });\n var excludeSet = new Set(excludeStrings);\n var external = props.external;\n var shouldOptimize = function shouldOptimize2(dep) {\n return !excludeSet.has(dep) && external !== true && !(external === null || external === void 0 ? void 0 : external.some(function(name2) {\n return dep === name2 || dep.startsWith(`${name2}/`);\n }));\n };\n var filteredDeps = result.prebundleDeps.filter(shouldOptimize);\n return {\n ssr: {\n optimizeDeps: {\n include: filteredDeps,\n exclude: EXCLUDE_LIST\n },\n noExternal: [\n ...filteredDeps,\n ...result.noExternalDeps.filter(shouldOptimize)\n ]\n }\n };\n}\nvar sessionCacheVal = null;\nasync function findDepsToOptimize(param) {\n var { root, mode, exclude, include } = param;\n var cacheFilePath = getSSRExternalsCachePath(root);\n var startedAt = debug ? Date.now() : 0;\n var noCache = mode === \"production\";\n var sessionCache = mode === \"production\";\n if (sessionCache && sessionCacheVal) {\n return sessionCacheVal;\n }\n var lockFile = await lookupFile(root, [\n \"yarn.lock\",\n \"package-lock.json\",\n \"pnpm-lock.yaml\",\n \"bun.lock\",\n \"bun.lockb\"\n ]);\n var lockFileHash = lockFile ? await getFileHash(lockFile) : void 0;\n var value;\n if (lockFileHash && !noCache) {\n try {\n var { lockFileHash: cachedLockFileHash, depsToPreBundleForSsr: cachedDepsToPreBundle } = await FSExtra.readJSON(cacheFilePath);\n if (lockFileHash === cachedLockFileHash && !!cachedDepsToPreBundle && \"prebundleDeps\" in cachedDepsToPreBundle && Array.isArray(cachedDepsToPreBundle.noExternalDeps)) {\n value = cachedDepsToPreBundle;\n debug === null || debug === void 0 ? void 0 : debug(`Using cached scan results from ${cacheFilePath}`);\n }\n } catch (err) {\n debug === null || debug === void 0 ? void 0 : debug(`${err}`);\n }\n }\n var filter = createFilter(include, exclude);\n if (!value) {\n value = await scanDepsToOptimize(`${root}/package.json`, {\n filter\n });\n if (sessionCache) {\n sessionCacheVal = value;\n }\n if (!noCache) {\n void FSExtra.outputJSON(cacheFilePath, {\n lockFileHash,\n depsToPreBundleForSsr: value\n });\n }\n }\n debug === null || debug === void 0 ? void 0 : debug(`Scanning completed in ${Date.now() - startedAt}ms`);\n debug === null || debug === void 0 ? void 0 : debug(`${value.prebundleDeps.length} deps are discovered and will be pre-bundled for SSR.` + (debugDetails ? \"\" : ` (Focus on this debug scope, \"DEBUG=${debug.namespace}\", to see more details.)`));\n debugDetails === null || debugDetails === void 0 ? void 0 : debugDetails(`Deps discovered to be pre-bundled for SSR: ${value.prebundleDeps.join(\", \")}`);\n return value;\n}\nexport {\n autoDepOptimizePlugin,\n findDepsToOptimize,\n getSSRExternalsCachePath,\n getScannedOptimizeDepsConfig\n};\n//# sourceMappingURL=autoDepOptimizePl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ptimizePlugin.native.js"],"sourcesContent":["import { createDebugger } from \"@vxrn/debug\";\nimport path from \"path\";\nimport { outputJSON, readJSON } from \"../utils/fs\";\nimport { createFilter } from \"vite\";\nimport { EXCLUDE_LIST, scanDepsToOptimize } from \"../utils/scanDepsToOptimize\";\nimport { getFileHash, lookupFile } from \"../utils/utils\";\nimport { getCacheDir } from \"../utils/getCacheDir\";\nvar name = \"vxrn:auto-dep-optimize\";\nvar { debug, debugDetails } = createDebugger(name);\nfunction autoDepOptimizePlugin(props) {\n return {\n name,\n enforce: \"pre\",\n async config(cfg, env) {\n var _cfg_optimizeDeps, _cfg_ssr_optimizeDeps, _cfg_ssr, _cfg_ssr1;\n debug === null || debug === void 0 ? void 0 : debug(\"Config hook called\");\n var userOptions = globalThis.__oneOptions;\n var depsConfig = userOptions === null || userOptions === void 0 ? void 0 : userOptions.deps;\n var exclude = depsConfig ? Object.entries(depsConfig).filter(function(param) {\n var [_, value] = param;\n return value === false;\n }).map(function(param) {\n var [k] = param;\n return k;\n }) : [];\n var userExcludes = Array.isArray(props.exclude) ? props.exclude : [\n props.exclude\n ];\n var userViteExcludes = ((_cfg_optimizeDeps = cfg.optimizeDeps) === null || _cfg_optimizeDeps === void 0 ? void 0 : _cfg_optimizeDeps.exclude) || [];\n var userSsrExcludes = ((_cfg_ssr = cfg.ssr) === null || _cfg_ssr === void 0 ? void 0 : (_cfg_ssr_optimizeDeps = _cfg_ssr.optimizeDeps) === null || _cfg_ssr_optimizeDeps === void 0 ? void 0 : _cfg_ssr_optimizeDeps.exclude) || [];\n var finalConfig = await getScannedOptimizeDepsConfig({\n ...props,\n mode: env.mode,\n external: (_cfg_ssr1 = cfg.ssr) === null || _cfg_ssr1 === void 0 ? void 0 : _cfg_ssr1.external,\n exclude: [\n ...exclude,\n ...userExcludes,\n ...userViteExcludes,\n ...userSsrExcludes\n ].filter(Boolean)\n });\n debugDetails === null || debugDetails === void 0 ? void 0 : debugDetails(`Final auto-dep-optimize config: ${JSON.stringify(finalConfig, null, 2)}\nfrom props: ${JSON.stringify(props)}`);\n return finalConfig;\n }\n };\n}\nvar getSSRExternalsCachePath = function getSSRExternalsCachePath2(root) {\n return path.join(getCacheDir(root), \"deps-to-pre-bundle-for-ssr-cache.json\");\n};\nasync function getScannedOptimizeDepsConfig(props) {\n var _props_onScannedDeps;\n var result = await findDepsToOptimize(props);\n (_props_onScannedDeps = props.onScannedDeps) === null || _props_onScannedDeps === void 0 ? void 0 : _props_onScannedDeps.call(props, result);\n var excludeArray = Array.isArray(props.exclude) ? props.exclude : [\n props.exclude\n ];\n var excludeStrings = excludeArray.filter(function(e) {\n return typeof e === \"string\";\n });\n var excludeSet = new Set(excludeStrings);\n var external = props.external;\n var shouldOptimize = function shouldOptimize2(dep) {\n return !excludeSet.has(dep) && external !== true && !(external === null || external === void 0 ? void 0 : external.some(function(name2) {\n return dep === name2 || dep.startsWith(`${name2}/`);\n }));\n };\n var filteredDeps = result.prebundleDeps.filter(shouldOptimize);\n return {\n ssr: {\n optimizeDeps: {\n include: filteredDeps,\n exclude: EXCLUDE_LIST\n },\n noExternal: [\n ...filteredDeps,\n ...result.noExternalDeps.filter(shouldOptimize)\n ]\n }\n };\n}\nvar sessionCacheVal = null;\nasync function findDepsToOptimize(param) {\n var { root, mode, exclude, include } = param;\n var cacheFilePath = getSSRExternalsCachePath(root);\n var startedAt = debug ? Date.now() : 0;\n var noCache = mode === \"production\";\n var sessionCache = mode === \"production\";\n if (sessionCache && sessionCacheVal) {\n return sessionCacheVal;\n }\n var lockFile = await lookupFile(root, [\n \"yarn.lock\",\n \"package-lock.json\",\n \"pnpm-lock.yaml\",\n \"bun.lock\",\n \"bun.lockb\"\n ]);\n var lockFileHash = lockFile ? await getFileHash(lockFile) : void 0;\n var value;\n if (lockFileHash && !noCache) {\n try {\n var { lockFileHash: cachedLockFileHash, depsToPreBundleForSsr: cachedDepsToPreBundle } = await readJSON(cacheFilePath);\n if (lockFileHash === cachedLockFileHash && !!cachedDepsToPreBundle && \"prebundleDeps\" in cachedDepsToPreBundle && Array.isArray(cachedDepsToPreBundle.noExternalDeps)) {\n value = cachedDepsToPreBundle;\n debug === null || debug === void 0 ? void 0 : debug(`Using cached scan results from ${cacheFilePath}`);\n }\n } catch (err) {\n debug === null || debug === void 0 ? void 0 : debug(`${err}`);\n }\n }\n var filter = createFilter(include, exclude);\n if (!value) {\n value = await scanDepsToOptimize(`${root}/package.json`, {\n filter\n });\n if (sessionCache) {\n sessionCacheVal = value;\n }\n if (!noCache) {\n void outputJSON(cacheFilePath, {\n lockFileHash,\n depsToPreBundleForSsr: value\n });\n }\n }\n debug === null || debug === void 0 ? void 0 : debug(`Scanning completed in ${Date.now() - startedAt}ms`);\n debug === null || debug === void 0 ? void 0 : debug(`${value.prebundleDeps.length} deps are discovered and will be pre-bundled for SSR.` + (debugDetails ? \"\" : ` (Focus on this debug scope, \"DEBUG=${debug.namespace}\", to see more details.)`));\n debugDetails === null || debugDetails === void 0 ? void 0 : debugDetails(`Deps discovered to be pre-bundled for SSR: ${value.prebundleDeps.join(\", \")}`);\n return value;\n}\nexport {\n autoDepOptimizePlugin,\n findDepsToOptimize,\n getSSRExternalsCachePath,\n getScannedOptimizeDepsConfig\n};\n//# sourceMappingURL=autoDepOptimizePlugin.js.map\n"],"mappings":";;;;;;;;;AAOA,IAAI,OAAO;AACX,IAAI,EAAE,OAAO,iBAAiB,eAAe,IAAI;AACjD,SAAS,sBAAsB,OAAO;CACpC,OAAO;EACL;EACA,SAAS;EACT,MAAM,OAAO,KAAK,KAAK;GACrB,IAAI,mBAAmB,uBAAuB,UAAU;GACxD,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,oBAAoB;GACxE,IAAI,cAAc,WAAW;GAC7B,IAAI,aAAa,gBAAgB,QAAQ,gBAAgB,KAAK,IAAI,KAAK,IAAI,YAAY;GACvF,IAAI,UAAU,aAAa,OAAO,QAAQ,UAAU,CAAC,CAAC,OAAO,SAAS,OAAO;IAC3E,IAAI,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kC,eAAe;GACvG;EACF,SAAS,KAAK;GACZ,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,GAAG,KAAK;EAC9D;CACF;CACA,IAAI,SAAS,aAAa,SAAS,OAAO;CAC1C,IAAI,CAAC,OAAO;EACV,QAAQ,MAAM,mBAAmB,GAAG,KAAK,gBAAgB,EACvD,OACF,CAAC;EACD,IAAI,cAAc;GAChB,kBAAkB;EACpB;EACA,IAAI,CAAC,SAAS;GACZ,KAAK,WAAW,eAAe;IAC7B;IACA,uBAAuB;GACzB,CAAC;EACH;CACF;CACA,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,yBAAyB,KAAK,IAAI,IAAI,UAAU,GAAG;CACvG,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,GAAG,MAAM,cAAc,OAAO,0DAA0D,eAAe,KAAK,uCAAuC,MAAM,UAAU,0BAA0B;CACjP,iBAAiB,QAAQ,iBAAiB,KAAK,IAAI,KAAK,IAAI,aAAa,8CAA8C,MAAM,cAAc,KAAK,IAAI,GAAG;CACvJ,OAAO;AACT"}
@@ -1,5 +1,5 @@
1
1
  import path from "node:path";
2
- import FSExtra from "fs-extra";
2
+ import { copyFile, mkdir, readFile } from "node:fs/promises";
3
3
  import { getMimeType } from "hono/utils/mime";
4
4
  import colors from "picocolors";
5
5
  import { isNativeEnvironment } from "../utils/environmentUtils.mjs";
@@ -45,8 +45,8 @@ function reactNativeDevAssetPlugin(options) {
45
45
  const assetData = await getAssetData(id);
46
46
  if (options.mode === "prod" && options.assetsDest) {
47
47
  const assetsDestDir = path.join(options.assetsDest, ASSET_DEST_DIR, assetData.relativeFileSystemLocation);
48
- await FSExtra.ensureDir(assetsDestDir);
49
- await FSExtra.copyFile(id, path.join(assetsDestDir, `${assetData.name}.${assetData.type}`));
48
+ await mkdir(assetsDestDir, { recursive: true });
49
+ await copyFile(id, path.join(assetsDestDir, `${assetData.name}.${assetData.type}`));
50
50
  }
51
51
  const assetModuleCode = `
52
52
  import { AssetRegistry } from 'react-native';
@@ -71,7 +71,7 @@ export default asset;
71
71
  const pathname = url.pathname;
72
72
  const assetPath = "./" + pathname.slice(`/${DEV_ASSET_DEST_PATH}/`.length).replace(/\.*$/, "");
73
73
  try {
74
- const asset = await FSExtra.readFile(assetPath);
74
+ const asset = await readFile(assetPath);
75
75
  res.setHeader("content-type", getMimeType(assetPath) || "application/octet-stream");
76
76
  res.write(asset);
77
77
  res.end();
@@ -1 +1 @@
1
- {"version":3,"file":"reactNativeDevAssetPlugin.js","names":[],"sources":["plugins/reactNativeDevAssetPlugin.js"],"sourcesContent":["import path from \"node:path\";\nimport FSExtra from \"fs-extra\";\nimport { getMimeType } from \"hono/utils/mime\";\nimport colors from \"picocolors\";\nimport { isNativeEnvironment } from \"../utils/environmentUtils\";\nconst ASSET_DEST_DIR = \"assets\";\nconst DEV_ASSET_DEST_PATH = \"__vxrn_dev_native_assets\";\nfunction reactNativeDevAssetPlugin(options) {\n const { assetExts } = options;\n const assetExtsRegExp = new RegExp(`\\\\.(${assetExts.join(\"|\")})$`);\n const isAssetFile = (id) => assetExtsRegExp.test(id);\n let config;\n async function getAssetData(id) {\n const projectRoot = config.root;\n const relativeAssetPath = path.relative(projectRoot, id);\n let assetUrlPath = relativeAssetPath;\n if (path.sep === \"\\\\\") {\n assetUrlPath = assetUrlPath.replaceAll(\"\\\\\", \"/\");\n }\n const relativeAssetDir = path.dirname(relativeAssetPath);\n const assetBasename = path.basename(relativeAssetPath);\n const assetExt = path.extname(assetBasename).slice(1);\n const assetName = assetBasename.slice(\n 0,\n -(assetExt.length + 1)\n );\n const assetData = {\n __packager_asset: true,\n fileSystemLocation: path.dirname(id),\n relativeFileSystemLocation: relativeAssetDir,\n httpServerLocation: `/${options.mode === \"dev\" ? DEV_ASSET_DEST_PATH : ASSET_DEST_DIR}/${assetUrlPath.slice(\n 0,\n -(assetBasename.length + 1)\n /* removing the `/filename.ext` at the end */\n )}`,\n scales: [1],\n // TODO\n name: assetName,\n type: assetExt\n };\n return assetData;\n }\n return {\n name: \"vxrn:react-native-dev-asset\",\n enforce: \"pre\",\n configResolved(resolvedConfig) {\n config = resolvedConfig;\n },\n // resolveId(source, importer, options) {\n // if (!isNativeEnvironment(this.environment)) return\n // if (!isAssetFile(source)) return\n // // TODO: May need to handle platform specific extensions here.\n // },\n async load(id, _options) {\n if (!isNativeEnvironment(this.environment)) return;\n if (!isAssetFile(id)) return;\n const assetData = await getAssetData(id);\n if (options.mode === \"prod\" && options.assetsDest) {\n const assetsDestDir = path.join(\n options.assetsDest,\n ASSET_DEST_DIR,\n assetData.relativeFileSystemLocation\n );\n await FSExtra.ensureDir(assetsDestDir);\n await FSExtra.copyFile(\n id,\n path.join(assetsDestDir, `${assetData.name}.${assetData.type}`)\n );\n }\n const assetModuleCode = `\nimport { AssetRegistry } from 'react-native';\n\nexport const asset = AssetRegistry.registerAsset(${JSON.stringify(assetData, null, 2)});\n\nexport default asset;\n `;\n return assetModuleCode;\n },\n /**\n * Extend the dev server to serve assets during development.\n */\n configureServer(server) {\n const { logger } = server.config;\n const defaultLogOptions = { timestamp: true };\n server.middlewares.use(async (req, res, next) => {\n if (!req.url?.startsWith(`/${DEV_ASSET_DEST_PATH}/`)) {\n return next();\n }\n const url = new URL(\"http://example.com\" + req.url);\n const pathname = url.pathname;\n const assetPath = \"./\" + pathname.slice(`/${DEV_ASSET_DEST_PATH}/`.length).replace(/\\.*$/, \"\");\n try {\n const asset = await FSExtra.readFile(assetPath);\n res.setHeader(\n \"content-type\",\n getMimeType(assetPath) || \"application/octet-stream\"\n );\n res.write(asset);\n res.end();\n } catch (e) {\n logger.error(\n colors.red(\n `[vxrn] Failed to serve asset: ${assetPath}: ${e instanceof Error ? e.message : \"unknown error\"}`\n ),\n defaultLogOptions\n );\n res.statusCode = e instanceof Error && e.code === \"ENOENT\" ? 404 : 500;\n res.end();\n }\n });\n }\n };\n}\nexport {\n reactNativeDevAssetPlugin\n};\n//#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BACZ;IACA,MAAM,QAAQ,UAAU,aAAa;IACrC,MAAM,QAAQ,SACZ,IACA,KAAK,KAAK,eAAe,GAAG,UAAU,KAAK,GAAG,UAAU,MAAM,CAChE;GACF;GACA,MAAM,kBAAkB;;;mDAGqB,KAAK,UAAU,WAAW,MAAM,CAAC,EAAE;;;;GAIhF,OAAO;EACT;;;;EAIA,gBAAgB,QAAQ;GACtB,MAAM,EAAE,WAAW,OAAO;GAC1B,MAAM,oBAAoB,EAAE,WAAW,KAAK;GAC5C,OAAO,YAAY,IAAI,OAAO,KAAK,KAAK,SAAS;IAC/C,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,oBAAoB,EAAE,GAAG;KACpD,OAAO,KAAK;IACd;IACA,MAAM,MAAM,IAAI,IAAI,uBAAuB,IAAI,GAAG;IAClD,MAAM,WAAW,IAAI;IACrB,MAAM,YAAY,OAAO,SAAS,MAAM,IAAI,oBAAoB,GAAG,MAAM,CAAC,CAAC,QAAQ,QAAQ,EAAE;IAC7F,IAAI;KACF,MAAM,QAAQ,MAAM,QAAQ,SAAS,SAAS;KAC9C,IAAI,UACF,gBACA,YAAY,SAAS,KAAK,0BAC5B;KACA,IAAI,MAAM,KAAK;KACf,IAAI,IAAI;IACV,SAAS,GAAG;KACV,OAAO,MACL,OAAO,IACL,iCAAiC,UAAU,IAAI,aAAa,QAAQ,EAAE,UAAU,iBAClF,GACA,iBACF;KACA,IAAI,aAAa,aAAa,SAAS,EAAE,SAAS,WAAW,MAAM;KACnE,IAAI,IAAI;IACV;GACF,CAAC;EACH;CACF;AACF"}
1
+ {"version":3,"file":"reactNativeDevAssetPlugin.js","names":[],"sources":["plugins/reactNativeDevAssetPlugin.js"],"sourcesContent":["import path from \"node:path\";\nimport { copyFile, mkdir, readFile } from \"node:fs/promises\";\nimport { getMimeType } from \"hono/utils/mime\";\nimport colors from \"picocolors\";\nimport { isNativeEnvironment } from \"../utils/environmentUtils\";\nconst ASSET_DEST_DIR = \"assets\";\nconst DEV_ASSET_DEST_PATH = \"__vxrn_dev_native_assets\";\nfunction reactNativeDevAssetPlugin(options) {\n const { assetExts } = options;\n const assetExtsRegExp = new RegExp(`\\\\.(${assetExts.join(\"|\")})$`);\n const isAssetFile = (id) => assetExtsRegExp.test(id);\n let config;\n async function getAssetData(id) {\n const projectRoot = config.root;\n const relativeAssetPath = path.relative(projectRoot, id);\n let assetUrlPath = relativeAssetPath;\n if (path.sep === \"\\\\\") {\n assetUrlPath = assetUrlPath.replaceAll(\"\\\\\", \"/\");\n }\n const relativeAssetDir = path.dirname(relativeAssetPath);\n const assetBasename = path.basename(relativeAssetPath);\n const assetExt = path.extname(assetBasename).slice(1);\n const assetName = assetBasename.slice(\n 0,\n -(assetExt.length + 1)\n );\n const assetData = {\n __packager_asset: true,\n fileSystemLocation: path.dirname(id),\n relativeFileSystemLocation: relativeAssetDir,\n httpServerLocation: `/${options.mode === \"dev\" ? DEV_ASSET_DEST_PATH : ASSET_DEST_DIR}/${assetUrlPath.slice(\n 0,\n -(assetBasename.length + 1)\n /* removing the `/filename.ext` at the end */\n )}`,\n scales: [1],\n // TODO\n name: assetName,\n type: assetExt\n };\n return assetData;\n }\n return {\n name: \"vxrn:react-native-dev-asset\",\n enforce: \"pre\",\n configResolved(resolvedConfig) {\n config = resolvedConfig;\n },\n // resolveId(source, importer, options) {\n // if (!isNativeEnvironment(this.environment)) return\n // if (!isAssetFile(source)) return\n // // TODO: May need to handle platform specific extensions here.\n // },\n async load(id, _options) {\n if (!isNativeEnvironment(this.environment)) return;\n if (!isAssetFile(id)) return;\n const assetData = await getAssetData(id);\n if (options.mode === \"prod\" && options.assetsDest) {\n const assetsDestDir = path.join(\n options.assetsDest,\n ASSET_DEST_DIR,\n assetData.relativeFileSystemLocation\n );\n await mkdir(assetsDestDir, { recursive: true });\n await copyFile(\n id,\n path.join(assetsDestDir, `${assetData.name}.${assetData.type}`)\n );\n }\n const assetModuleCode = `\nimport { AssetRegistry } from 'react-native';\n\nexport const asset = AssetRegistry.registerAsset(${JSON.stringify(assetData, null, 2)});\n\nexport default asset;\n `;\n return assetModuleCode;\n },\n /**\n * Extend the dev server to serve assets during development.\n */\n configureServer(server) {\n const { logger } = server.config;\n const defaultLogOptions = { timestamp: true };\n server.middlewares.use(async (req, res, next) => {\n if (!req.url?.startsWith(`/${DEV_ASSET_DEST_PATH}/`)) {\n return next();\n }\n const url = new URL(\"http://example.com\" + req.url);\n const pathname = url.pathname;\n const assetPath = \"./\" + pathname.slice(`/${DEV_ASSET_DEST_PATH}/`.length).replace(/\\.*$/, \"\");\n try {\n const asset = await readFile(assetPath);\n res.setHeader(\n \"content-type\",\n getMimeType(assetPath) || \"application/octet-stream\"\n );\n res.write(asset);\n res.end();\n } catch (e) {\n logger.error(\n colors.red(\n `[vxrn] Failed to serve asset: ${assetPath}: ${e instanceof Error ? e.message : \"unknown error\"}`\n ),\n defaultLogOptions\n );\n res.statusCode = e instanceof Error && e.code === \"ENOENT\" ? 404 : 500;\n res.end();\n }\n });\n }\n };\n}\nexport {\n reactNativeDevAssetPlugin\n};\n//# sourceMappingURL=reactNativeDevAssetPlugin.js.map\n"],"mappings":";;;;;;;AAKA,MAAM,iBAAiB;AACvB,MAAM,sBAAsB;AAC5B,SAAS,0BAA0B,SAAS;CAC1C,MAAM,EAAE,cAAc;CACtB,MAAM,kBAAkB,IAAI,OAAO,OAAO,UAAU,KAAK,GAAG,EAAE,GAAG;CACjE,MAAM,eAAe,OAAO,gBAAgB,KAAK,EAAE;CACnD,IAAI;CACJ,eAAe,aAAa,IAAI;EAC9B,MAAM,cAAc,OAAO;EAC3B,MAAM,oBAAoB,KAAK,SAAS,aAAa,EAAE;EACvD,IAAI,eAAe;EACnB,IAAI,KAAK,QAAQ,MAAM;GACrB,eAAe,aAAa,WAAW,MAAM,GAAG;EAClD;EACA,MAAM,mBAAmB,KAAK,QAAQ,iBAAiB;EACvD,MAAM,gBAAgB,KAAK,SAAS,iBAAiB;EACrD,MAAM,WAAW,KAAK,QAAQ,aAA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I,oBAAoB,GAAG,MAAM,CAAC,CAAC,QAAQ,QAAQ,EAAE;IAC7F,IAAI;KACF,MAAM,QAAQ,MAAM,SAAS,SAAS;KACtC,IAAI,UACF,gBACA,YAAY,SAAS,KAAK,0BAC5B;KACA,IAAI,MAAM,KAAK;KACf,IAAI,IAAI;IACV,SAAS,GAAG;KACV,OAAO,MACL,OAAO,IACL,iCAAiC,UAAU,IAAI,aAAa,QAAQ,EAAE,UAAU,iBAClF,GACA,iBACF;KACA,IAAI,aAAa,aAAa,SAAS,EAAE,SAAS,WAAW,MAAM;KACnE,IAAI,IAAI;IACV;GACF,CAAC;EACH;CACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import FSExtra from "fs-extra";
2
+ import { copyFile, mkdir, readFile } from "fs/promises";
3
3
  import { getMimeType } from "hono/utils/mime";
4
4
  import colors from "picocolors";
5
5
  import { isNativeEnvironment } from "../utils/environmentUtils.native.js";
@@ -47,8 +47,8 @@ function reactNativeDevAssetPlugin(options) {
47
47
  var assetData = await getAssetData(id);
48
48
  if (options.mode === "prod" && options.assetsDest) {
49
49
  var assetsDestDir = path.join(options.assetsDest, ASSET_DEST_DIR, assetData.relativeFileSystemLocation);
50
- await FSExtra.ensureDir(assetsDestDir);
51
- await FSExtra.copyFile(id, path.join(assetsDestDir, `${assetData.name}.${assetData.type}`));
50
+ await mkdir(assetsDestDir, { recursive: true });
51
+ await copyFile(id, path.join(assetsDestDir, `${assetData.name}.${assetData.type}`));
52
52
  }
53
53
  var assetModuleCode = `
54
54
  import { AssetRegistry } from 'react-native';
@@ -74,7 +74,7 @@ export default asset;
74
74
  var pathname = url.pathname;
75
75
  var assetPath = "./" + pathname.slice(`/${DEV_ASSET_DEST_PATH}/`.length).replace(/\.*$/, "");
76
76
  try {
77
- var asset = await FSExtra.readFile(assetPath);
77
+ var asset = await readFile(assetPath);
78
78
  res.setHeader("content-type", getMimeType(assetPath) || "application/octet-stream");
79
79
  res.write(asset);
80
80
  res.end();
@@ -1 +1 @@
1
- {"version":3,"file":"reactNativeDevAssetPlugin.native.js","names":[],"sources":["plugins/reactNativeDevAssetPlugin.native.js"],"sourcesContent":["import path from \"path\";\nimport FSExtra from \"fs-extra\";\nimport { getMimeType } from \"hono/utils/mime\";\nimport colors from \"picocolors\";\nimport { isNativeEnvironment } from \"../utils/environmentUtils\";\nvar ASSET_DEST_DIR = \"assets\";\nvar DEV_ASSET_DEST_PATH = \"__vxrn_dev_native_assets\";\nfunction reactNativeDevAssetPlugin(options) {\n var { assetExts } = options;\n var assetExtsRegExp = new RegExp(`\\\\.(${assetExts.join(\"|\")})$`);\n var isAssetFile = function isAssetFile2(id) {\n return assetExtsRegExp.test(id);\n };\n var config;\n async function getAssetData(id) {\n var projectRoot = config.root;\n var relativeAssetPath = path.relative(projectRoot, id);\n var assetUrlPath = relativeAssetPath;\n if (path.sep === \"\\\\\") {\n assetUrlPath = assetUrlPath.replaceAll(\"\\\\\", \"/\");\n }\n var relativeAssetDir = path.dirname(relativeAssetPath);\n var assetBasename = path.basename(relativeAssetPath);\n var assetExt = path.extname(assetBasename).slice(1);\n var assetName = assetBasename.slice(0, -(assetExt.length + 1));\n var assetData = {\n __packager_asset: true,\n fileSystemLocation: path.dirname(id),\n relativeFileSystemLocation: relativeAssetDir,\n httpServerLocation: `/${options.mode === \"dev\" ? DEV_ASSET_DEST_PATH : ASSET_DEST_DIR}/${assetUrlPath.slice(0, -(assetBasename.length + 1))}`,\n scales: [\n 1\n ],\n // TODO\n name: assetName,\n type: assetExt\n };\n return assetData;\n }\n return {\n name: \"vxrn:react-native-dev-asset\",\n enforce: \"pre\",\n configResolved(resolvedConfig) {\n config = resolvedConfig;\n },\n // resolveId(source, importer, options) {\n // if (!isNativeEnvironment(this.environment)) return\n // if (!isAssetFile(source)) return\n // // TODO: May need to handle platform specific extensions here.\n // },\n async load(id, _options) {\n if (!isNativeEnvironment(this.environment)) return;\n if (!isAssetFile(id)) return;\n var assetData = await getAssetData(id);\n if (options.mode === \"prod\" && options.assetsDest) {\n var assetsDestDir = path.join(options.assetsDest, ASSET_DEST_DIR, assetData.relativeFileSystemLocation);\n await FSExtra.ensureDir(assetsDestDir);\n await FSExtra.copyFile(id, path.join(assetsDestDir, `${assetData.name}.${assetData.type}`));\n }\n var assetModuleCode = `\nimport { AssetRegistry } from 'react-native';\n\nexport const asset = AssetRegistry.registerAsset(${JSON.stringify(assetData, null, 2)});\n\nexport default asset;\n `;\n return assetModuleCode;\n },\n /**\n * Extend the dev server to serve assets during development.\n */\n configureServer(server) {\n var { logger } = server.config;\n var defaultLogOptions = {\n timestamp: true\n };\n server.middlewares.use(async function(req, res, next) {\n var _req_url;\n if (!((_req_url = req.url) === null || _req_url === void 0 ? void 0 : _req_url.startsWith(`/${DEV_ASSET_DEST_PATH}/`))) {\n return next();\n }\n var url = new URL(\"http://example.com\" + req.url);\n var pathname = url.pathname;\n var assetPath = \"./\" + pathname.slice(`/${DEV_ASSET_DEST_PATH}/`.length).replace(/\\.*$/, \"\");\n try {\n var asset = await FSExtra.readFile(assetPath);\n res.setHeader(\"content-type\", getMimeType(assetPath) || \"application/octet-stream\");\n res.write(asset);\n res.end();\n } catch (e) {\n logger.error(colors.red(`[vxrn] Failed to serve asset: ${assetPath}: ${e instanceof Error ? e.message : \"unknown error\"}`), defaultLogOptions);\n res.statusCode = e instanceof Error && e.code === \"ENOENT\" ? 404 : 500;\n res.end();\n }\n });\n }\n };\n}\nexport {\n reactNativeDevAssetPlugin\n};\n//# sourceMappingURL=reactNativeDevAssetPlugin.js.map\n"],"mappings":";;;;;;;AAKA,IAAI,iBAAiB;AACrB,IAAI,sBAAsB;AAC1B,SAAS,0BAA0B,SAAS;CAC1C,IAAI,EAAE,cAAc;CACpB,IAAI,kBAAkB,IAAI,OAAO,OAAO,UAAU,KAAK,GAAG,EAAE,GAAG;CAC/D,IAAI,cAAc,SAAS,aAAa,IAAI;EAC1C,OAAO,gBAAgB,KAAK,EAAE;CAChC;CACA,IAAI;CACJ,e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OAAO;GACxB,IAAI,oBAAoB,EACtB,WAAW,KACb;GACA,OAAO,YAAY,IAAI,eAAe,KAAK,KAAK,MAAM;IACpD,IAAI;IACJ,IAAI,GAAG,WAAW,IAAI,SAAS,QAAQ,aAAa,KAAK,IAAI,KAAK,IAAI,SAAS,WAAW,IAAI,oBAAoB,EAAE,IAAI;KACtH,OAAO,KAAK;IACd;IACA,IAAI,MAAM,IAAI,IAAI,uBAAuB,IAAI,GAAG;IAChD,IAAI,WAAW,IAAI;IACnB,IAAI,YAAY,OAAO,SAAS,MAAM,IAAI,oBAAoB,GAAG,MAAM,CAAC,CAAC,QAAQ,QAAQ,EAAE;IAC3F,IAAI;KACF,IAAI,QAAQ,MAAM,QAAQ,SAAS,SAAS;KAC5C,IAAI,UAAU,gBAAgB,YAAY,SAAS,KAAK,0BAA0B;KAClF,IAAI,MAAM,KAAK;KACf,IAAI,IAAI;IACV,SAAS,GAAG;KACV,OAAO,MAAM,OAAO,IAAI,iCAAiC,UAAU,IAAI,aAAa,QAAQ,EAAE,UAAU,iBAAiB,GAAG,iBAAiB;KAC7I,IAAI,aAAa,aAAa,SAAS,EAAE,SAAS,WAAW,MAAM;KACnE,IAAI,IAAI;IACV;GACF,CAAC;EACH;CACF;AACF"}
1
+ {"version":3,"file":"reactNativeDevAssetPlugin.native.js","names":[],"sources":["plugins/reactNativeDevAssetPlugin.native.js"],"sourcesContent":["import path from \"path\";\nimport { copyFile, mkdir, readFile } from \"fs/promises\";\nimport { getMimeType } from \"hono/utils/mime\";\nimport colors from \"picocolors\";\nimport { isNativeEnvironment } from \"../utils/environmentUtils\";\nvar ASSET_DEST_DIR = \"assets\";\nvar DEV_ASSET_DEST_PATH = \"__vxrn_dev_native_assets\";\nfunction reactNativeDevAssetPlugin(options) {\n var { assetExts } = options;\n var assetExtsRegExp = new RegExp(`\\\\.(${assetExts.join(\"|\")})$`);\n var isAssetFile = function isAssetFile2(id) {\n return assetExtsRegExp.test(id);\n };\n var config;\n async function getAssetData(id) {\n var projectRoot = config.root;\n var relativeAssetPath = path.relative(projectRoot, id);\n var assetUrlPath = relativeAssetPath;\n if (path.sep === \"\\\\\") {\n assetUrlPath = assetUrlPath.replaceAll(\"\\\\\", \"/\");\n }\n var relativeAssetDir = path.dirname(relativeAssetPath);\n var assetBasename = path.basename(relativeAssetPath);\n var assetExt = path.extname(assetBasename).slice(1);\n var assetName = assetBasename.slice(0, -(assetExt.length + 1));\n var assetData = {\n __packager_asset: true,\n fileSystemLocation: path.dirname(id),\n relativeFileSystemLocation: relativeAssetDir,\n httpServerLocation: `/${options.mode === \"dev\" ? DEV_ASSET_DEST_PATH : ASSET_DEST_DIR}/${assetUrlPath.slice(0, -(assetBasename.length + 1))}`,\n scales: [\n 1\n ],\n // TODO\n name: assetName,\n type: assetExt\n };\n return assetData;\n }\n return {\n name: \"vxrn:react-native-dev-asset\",\n enforce: \"pre\",\n configResolved(resolvedConfig) {\n config = resolvedConfig;\n },\n // resolveId(source, importer, options) {\n // if (!isNativeEnvironment(this.environment)) return\n // if (!isAssetFile(source)) return\n // // TODO: May need to handle platform specific extensions here.\n // },\n async load(id, _options) {\n if (!isNativeEnvironment(this.environment)) return;\n if (!isAssetFile(id)) return;\n var assetData = await getAssetData(id);\n if (options.mode === \"prod\" && options.assetsDest) {\n var assetsDestDir = path.join(options.assetsDest, ASSET_DEST_DIR, assetData.relativeFileSystemLocation);\n await mkdir(assetsDestDir, {\n recursive: true\n });\n await copyFile(id, path.join(assetsDestDir, `${assetData.name}.${assetData.type}`));\n }\n var assetModuleCode = `\nimport { AssetRegistry } from 'react-native';\n\nexport const asset = AssetRegistry.registerAsset(${JSON.stringify(assetData, null, 2)});\n\nexport default asset;\n `;\n return assetModuleCode;\n },\n /**\n * Extend the dev server to serve assets during development.\n */\n configureServer(server) {\n var { logger } = server.config;\n var defaultLogOptions = {\n timestamp: true\n };\n server.middlewares.use(async function(req, res, next) {\n var _req_url;\n if (!((_req_url = req.url) === null || _req_url === void 0 ? void 0 : _req_url.startsWith(`/${DEV_ASSET_DEST_PATH}/`))) {\n return next();\n }\n var url = new URL(\"http://example.com\" + req.url);\n var pathname = url.pathname;\n var assetPath = \"./\" + pathname.slice(`/${DEV_ASSET_DEST_PATH}/`.length).replace(/\\.*$/, \"\");\n try {\n var asset = await readFile(assetPath);\n res.setHeader(\"content-type\", getMimeType(assetPath) || \"application/octet-stream\");\n res.write(asset);\n res.end();\n } catch (e) {\n logger.error(colors.red(`[vxrn] Failed to serve asset: ${assetPath}: ${e instanceof Error ? e.message : \"unknown error\"}`), defaultLogOptions);\n res.statusCode = e instanceof Error && e.code === \"ENOENT\" ? 404 : 500;\n res.end();\n }\n });\n }\n };\n}\nexport {\n reactNativeDevAssetPlugin\n};\n//# sourceMappingURL=reactNativeDevAssetPlugin.js.map\n"],"mappings":";;;;;;;AAKA,IAAI,iBAAiB;AACrB,IAAI,sBAAsB;AAC1B,SAAS,0BAA0B,SAAS;CAC1C,IAAI,EAAE,cAAc;CACpB,IAAI,kBAAkB,IAAI,OAAO,OAAO,UAAU,KAAK,GAAG,EAAE,GAAG;CAC/D,IAAI,cAAc,SAAS,aAAa,IAAI;EAC1C,OAAO,gBAAgB,KAAK,EAAE;CAChC;CACA,IAAI;CACJ,eAAe,aAAa,IAAI;EAC9B,IAAI,cAAc,OAAO;EACzB,IAAI,oBAAoB,KAAK,SAAS,aAAa,EAAE;EACrD,IAAI,eAAe;EACnB,IAAI,KAAK,QAAQ,MAAM;GACrB,eAAe,aAAa,WAAW,MAAM,GAAG;EAClD;EACA,IAAI,mBAAmB,KAAK,QAAQ,iBAAiB;EACrD,IAAI,gBAAgB,KAAK,SAAS,iBAAiB;EACnD,IAAI,WAAW,KAAK,QAAQ,aAAa,CAAC,CAAC,MAAM,CAAC;EAClD,IAAI,YAAY,cAAc,MAAM,GAAG,EAAE,SAAS,SAAS,EAAE;EAC7D,IAAI,YAAY;GACd,kBAAkB;GAClB,oBAAoB,KAAK,QAAQ,EAAE;GACnC,4BAA4B;GAC5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IAAI,UAAU,gBAAgB,YAAY,SAAS,KAAK,0BAA0B;KAClF,IAAI,MAAM,KAAK;KACf,IAAI,IAAI;IACV,SAAS,GAAG;KACV,OAAO,MAAM,OAAO,IAAI,iCAAiC,UAAU,IAAI,aAAa,QAAQ,EAAE,UAAU,iBAAiB,GAAG,iBAAiB;KAC7I,IAAI,aAAa,aAAa,SAAS,EAAE,SAAS,WAAW,MAAM;KACnE,IAAI,IAAI;IACV;GACF,CAAC;EACH;CACF;AACF"}
@@ -1,7 +1,8 @@
1
- import FSExtra from "fs-extra";
2
1
  import { clearTransformCache } from "@vxrn/compiler";
2
+ import { cpSync, existsSync, mkdirSync, renameSync, rmSync } from "node:fs";
3
3
  import { resolveConfig } from "vite";
4
4
  import { dirname, join, resolve } from "node:path";
5
+ import { outputFileSync } from "../../utils/fs.mjs";
5
6
  import { loadEnv } from "../../exports/loadEnv.mjs";
6
7
  import { buildNativeBundle } from "../../utils/createNativeDevEngine.mjs";
7
8
 
@@ -46,15 +47,27 @@ async function buildBundle(_argv, ctx, args, bundleImpl = null) {
46
47
  const source = join(assetsDest, "one-dom");
47
48
  const destination = join(dirname(bundleOutput), "one-dom");
48
49
  if (resolve(source) !== resolve(destination)) {
49
- FSExtra.removeSync(destination);
50
- if (FSExtra.existsSync(source)) FSExtra.moveSync(source, destination);
50
+ rmSync(destination, {
51
+ recursive: true,
52
+ force: true
53
+ });
54
+ if (existsSync(source)) {
55
+ mkdirSync(dirname(destination), { recursive: true });
56
+ try {
57
+ renameSync(source, destination);
58
+ } catch (error) {
59
+ if (error.code !== "EXDEV") throw error;
60
+ cpSync(source, destination, { recursive: true });
61
+ rmSync(source, { recursive: true });
62
+ }
63
+ }
51
64
  }
52
65
  }
53
66
  if (result.map && args.sourcemapOutput) {
54
- FSExtra.outputFileSync(args.sourcemapOutput, result.map, { encoding: "utf8" });
67
+ outputFileSync(args.sourcemapOutput, result.map, { encoding: "utf8" });
55
68
  }
56
69
  console.info(`Writing bundle to ${bundleOutput}...`);
57
- FSExtra.outputFileSync(bundleOutput, builtBundle, { encoding: bundleEncoding });
70
+ outputFileSync(bundleOutput, builtBundle, { encoding: bundleEncoding });
58
71
  console.info("Done.");
59
72
  setTimeout(() => {
60
73
  console.info("Exiting process to prevent hanging.");
@@ -1 +1 @@
1
- {"version":3,"file":"buildBundle.js","names":[],"sources":["rn-commands/bundle/buildBundle.js"],"sourcesContent":["import FSExtra from \"fs-extra\";\nimport { clearTransformCache } from \"@vxrn/compiler\";\nimport { resolveConfig } from \"vite\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { loadEnv } from \"../../exports/loadEnv\";\nimport { buildNativeBundle } from \"../../utils/createNativeDevEngine\";\nasync function buildBundle(_argv, ctx, args, bundleImpl = null) {\n const {\n platform,\n dev,\n bundleOutput,\n // React Native's `--bundle-encoding` names a Node Buffer encoding.\n bundleEncoding = \"utf8\",\n assetsDest,\n // `--minify` overrides React Native's default of \"minify unless this is a\n // dev bundle\". undefined means the flag was not passed.\n minify,\n // `--reset-cache` drops the compiler's transform cache, the only cache a\n // rolldown production build reads.\n resetCache\n // `--entry-file` is a placeholder in generated native projects. VxRN apps\n // configure entries.native through vxrn/react-native-commands, while One\n // generates its native entry from the route tree.\n // `--read-global-cache` / `--max-workers` / `--config` / `--transformer` /\n // `--resolver-option` configure Metro's global cache, worker pool and\n // resolver. A rolldown production build has none of them: it transforms\n // from source in-process. React Native's own bundle command ignores\n // `--read-global-cache` too.\n // `--unstable-transform-profile` picks a JS engine to target. This pipeline\n // always downlevels for Hermes, which is what every profile it accepts\n // ('default', 'hermes', 'hermes-canary') can run.\n // `--sourcemap-use-absolute-path`, `--sourcemap-sources-root`,\n // `--asset-catalog-dest` and `--indexed-ram-bundle` are not implemented.\n } = args;\n const { root } = ctx;\n if (typeof root !== \"string\") {\n throw new Error(`Expected ctx.root to be a string, but got ${typeof root}`);\n }\n const viteConfig = await resolveConfig({}, \"build\", \"production\");\n if (globalThis[\"__viteMetroPluginOptions__\"]) {\n console.info(\"Using @vxrn/vite-plugin-metro to build the bundle.\");\n const { bundle } = await import(\"@vxrn/vite-plugin-metro/rn-commands\");\n await bundle.getBuildBundleFn(viteConfig)(_argv, ctx, args, bundleImpl);\n return;\n }\n process.env.IS_VXRN_CLI = \"true\";\n loadEnv(dev ? \"development\" : \"production\", root);\n if (!dev) {\n process.env.NODE_ENV = \"production\";\n }\n if (resetCache) {\n clearTransformCache();\n }\n console.info(`[vxrn] building native bundle for ${platform}...`);\n const nativeEntryFile = ctx.vxrnEntries?.native;\n if (nativeEntryFile !== void 0 && typeof nativeEntryFile !== \"string\") {\n throw new Error(\"Expected entries.native to be a string\");\n }\n const result = await buildNativeBundle({\n root,\n platform,\n dev,\n entryFile: nativeEntryFile,\n // pass through ONE_SERVER_URL so the native prelude can inject it into\n // process.env. without this, getURL.native falls back to the dummy\n // 'http://one-server.example.com' and runtime loader fetches fail in prod.\n serverUrl: process.env.ONE_SERVER_URL,\n assetsDest,\n sourcemap: !!args.sourcemapOutput,\n minify\n });\n const builtBundle = result.code;\n if (platform === \"android\" && assetsDest) {\n const source = join(assetsDest, \"one-dom\");\n const destination = join(dirname(bundleOutput), \"one-dom\");\n if (resolve(source) !== resolve(destination)) {\n FSExtra.removeSync(destination);\n if (FSExtra.existsSync(source)) FSExtra.moveSync(source, destination);\n }\n }\n if (result.map && args.sourcemapOutput) {\n FSExtra.outputFileSync(args.sourcemapOutput, result.map, { encoding: \"utf8\" });\n }\n console.info(`Writing bundle to ${bundleOutput}...`);\n FSExtra.outputFileSync(bundleOutput, builtBundle, { encoding: bundleEncoding });\n console.info(\"Done.\");\n setTimeout(() => {\n console.info(\"Exiting process to prevent hanging.\");\n process.exit();\n }, 3e4).unref();\n}\nexport {\n buildBundle\n};\n//# sourceMappingURL=buildBundle.js.map\n"],"mappings":";;;;;;;;AAMA,eAAe,YAAY,OAAO,KAAK,MAAM,aAAa,MAAM;CAC9D,MAAM,EACJ,UACA,KACA,cAEA,iBAAiB,QACjB,YAGA,QAG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,IAAI;CACnD,QAAQ,eAAe,cAAc,aAAa,EAAE,UAAU,eAAe,CAAC;CAC9E,QAAQ,KAAK,OAAO;CACpB,iBAAiB;EACf,QAAQ,KAAK,qCAAqC;EAClD,QAAQ,KAAK;CACf,GAAG,GAAG,CAAC,CAAC,MAAM;AAChB"}
1
+ {"version":3,"file":"buildBundle.js","names":[],"sources":["rn-commands/bundle/buildBundle.js"],"sourcesContent":["import { clearTransformCache } from \"@vxrn/compiler\";\nimport { cpSync, existsSync, mkdirSync, renameSync, rmSync } from \"node:fs\";\nimport { resolveConfig } from \"vite\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { outputFileSync } from \"../../utils/fs\";\nimport { loadEnv } from \"../../exports/loadEnv\";\nimport { buildNativeBundle } from \"../../utils/createNativeDevEngine\";\nasync function buildBundle(_argv, ctx, args, bundleImpl = null) {\n const {\n platform,\n dev,\n bundleOutput,\n // React Native's `--bundle-encoding` names a Node Buffer encoding.\n bundleEncoding = \"utf8\",\n assetsDest,\n // `--minify` overrides React Native's default of \"minify unless this is a\n // dev bundle\". undefined means the flag was not passed.\n minify,\n // `--reset-cache` drops the compiler's transform cache, the only cache a\n // rolldown production build reads.\n resetCache\n // `--entry-file` is a placeholder in generated native projects. VxRN apps\n // configure entries.native through vxrn/react-native-commands, while One\n // generates its native entry from the route tree.\n // `--read-global-cache` / `--max-workers` / `--config` / `--transformer` /\n // `--resolver-option` configure Metro's global cache, worker pool and\n // resolver. A rolldown production build has none of them: it transforms\n // from source in-process. React Native's own bundle command ignores\n // `--read-global-cache` too.\n // `--unstable-transform-profile` picks a JS engine to target. This pipeline\n // always downlevels for Hermes, which is what every profile it accepts\n // ('default', 'hermes', 'hermes-canary') can run.\n // `--sourcemap-use-absolute-path`, `--sourcemap-sources-root`,\n // `--asset-catalog-dest` and `--indexed-ram-bundle` are not implemented.\n } = args;\n const { root } = ctx;\n if (typeof root !== \"string\") {\n throw new Error(`Expected ctx.root to be a string, but got ${typeof root}`);\n }\n const viteConfig = await resolveConfig({}, \"build\", \"production\");\n if (globalThis[\"__viteMetroPluginOptions__\"]) {\n console.info(\"Using @vxrn/vite-plugin-metro to build the bundle.\");\n const { bundle } = await import(\"@vxrn/vite-plugin-metro/rn-commands\");\n await bundle.getBuildBundleFn(viteConfig)(_argv, ctx, args, bundleImpl);\n return;\n }\n process.env.IS_VXRN_CLI = \"true\";\n loadEnv(dev ? \"development\" : \"production\", root);\n if (!dev) {\n process.env.NODE_ENV = \"production\";\n }\n if (resetCache) {\n clearTransformCache();\n }\n console.info(`[vxrn] building native bundle for ${platform}...`);\n const nativeEntryFile = ctx.vxrnEntries?.native;\n if (nativeEntryFile !== void 0 && typeof nativeEntryFile !== \"string\") {\n throw new Error(\"Expected entries.native to be a string\");\n }\n const result = await buildNativeBundle({\n root,\n platform,\n dev,\n entryFile: nativeEntryFile,\n // pass through ONE_SERVER_URL so the native prelude can inject it into\n // process.env. without this, getURL.native falls back to the dummy\n // 'http://one-server.example.com' and runtime loader fetches fail in prod.\n serverUrl: process.env.ONE_SERVER_URL,\n assetsDest,\n sourcemap: !!args.sourcemapOutput,\n minify\n });\n const builtBundle = result.code;\n if (platform === \"android\" && assetsDest) {\n const source = join(assetsDest, \"one-dom\");\n const destination = join(dirname(bundleOutput), \"one-dom\");\n if (resolve(source) !== resolve(destination)) {\n rmSync(destination, { recursive: true, force: true });\n if (existsSync(source)) {\n mkdirSync(dirname(destination), { recursive: true });\n try {\n renameSync(source, destination);\n } catch (error) {\n if (error.code !== \"EXDEV\") throw error;\n cpSync(source, destination, { recursive: true });\n rmSync(source, { recursive: true });\n }\n }\n }\n }\n if (result.map && args.sourcemapOutput) {\n outputFileSync(args.sourcemapOutput, result.map, { encoding: \"utf8\" });\n }\n console.info(`Writing bundle to ${bundleOutput}...`);\n outputFileSync(bundleOutput, builtBundle, { encoding: bundleEncoding });\n console.info(\"Done.\");\n setTimeout(() => {\n console.info(\"Exiting process to prevent hanging.\");\n process.exit();\n }, 3e4).unref();\n}\nexport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GAAG;IACtB,UAAU,QAAQ,WAAW,GAAG,EAAE,WAAW,KAAK,CAAC;IACnD,IAAI;KACF,WAAW,QAAQ,WAAW;IAChC,SAAS,OAAO;KACd,IAAI,MAAM,SAAS,SAAS,MAAM;KAClC,OAAO,QAAQ,aAAa,EAAE,WAAW,KAAK,CAAC;KAC/C,OAAO,QAAQ,EAAE,WAAW,KAAK,CAAC;IACpC;GACF;EACF;CACF;CACA,IAAI,OAAO,OAAO,KAAK,iBAAiB;EACtC,eAAe,KAAK,iBAAiB,OAAO,KAAK,EAAE,UAAU,OAAO,CAAC;CACvE;CACA,QAAQ,KAAK,qBAAqB,aAAa,IAAI;CACnD,eAAe,cAAc,aAAa,EAAE,UAAU,eAAe,CAAC;CACtE,QAAQ,KAAK,OAAO;CACpB,iBAAiB;EACf,QAAQ,KAAK,qCAAqC;EAClD,QAAQ,KAAK;CACf,GAAG,GAAG,CAAC,CAAC,MAAM;AAChB"}
@@ -1,7 +1,8 @@
1
- import FSExtra from "fs-extra";
2
1
  import { clearTransformCache } from "@vxrn/compiler";
2
+ import { cpSync, existsSync, mkdirSync, renameSync, rmSync } from "fs";
3
3
  import { resolveConfig } from "vite";
4
4
  import { dirname, join, resolve } from "path";
5
+ import { outputFileSync } from "../../utils/fs.native.js";
5
6
  import { loadEnv } from "../../exports/loadEnv.native.js";
6
7
  import { buildNativeBundle } from "../../utils/createNativeDevEngine.native.js";
7
8
 
@@ -48,15 +49,27 @@ async function buildBundle(_argv, ctx, args) {
48
49
  var source = join(assetsDest, "one-dom");
49
50
  var destination = join(dirname(bundleOutput), "one-dom");
50
51
  if (resolve(source) !== resolve(destination)) {
51
- FSExtra.removeSync(destination);
52
- if (FSExtra.existsSync(source)) FSExtra.moveSync(source, destination);
52
+ rmSync(destination, {
53
+ recursive: true,
54
+ force: true
55
+ });
56
+ if (existsSync(source)) {
57
+ mkdirSync(dirname(destination), { recursive: true });
58
+ try {
59
+ renameSync(source, destination);
60
+ } catch (error) {
61
+ if (error.code !== "EXDEV") throw error;
62
+ cpSync(source, destination, { recursive: true });
63
+ rmSync(source, { recursive: true });
64
+ }
65
+ }
53
66
  }
54
67
  }
55
68
  if (result.map && args.sourcemapOutput) {
56
- FSExtra.outputFileSync(args.sourcemapOutput, result.map, { encoding: "utf8" });
69
+ outputFileSync(args.sourcemapOutput, result.map, { encoding: "utf8" });
57
70
  }
58
71
  console.info(`Writing bundle to ${bundleOutput}...`);
59
- FSExtra.outputFileSync(bundleOutput, builtBundle, { encoding: bundleEncoding });
72
+ outputFileSync(bundleOutput, builtBundle, { encoding: bundleEncoding });
60
73
  console.info("Done.");
61
74
  setTimeout(function() {
62
75
  console.info("Exiting process to prevent hanging.");
@@ -1 +1 @@
1
- {"version":3,"file":"buildBundle.native.js","names":[],"sources":["rn-commands/bundle/buildBundle.native.js"],"sourcesContent":["import FSExtra from \"fs-extra\";\nimport { clearTransformCache } from \"@vxrn/compiler\";\nimport { resolveConfig } from \"vite\";\nimport { dirname, join, resolve } from \"path\";\nimport { loadEnv } from \"../../exports/loadEnv\";\nimport { buildNativeBundle } from \"../../utils/createNativeDevEngine\";\nasync function buildBundle(_argv, ctx, args) {\n var bundleImpl = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;\n var _ctx_vxrnEntries;\n var {\n platform,\n dev,\n bundleOutput,\n // React Native's `--bundle-encoding` names a Node Buffer encoding.\n bundleEncoding = \"utf8\",\n assetsDest,\n // `--minify` overrides React Native's default of \"minify unless this is a\n // dev bundle\". undefined means the flag was not passed.\n minify,\n // `--reset-cache` drops the compiler's transform cache, the only cache a\n // rolldown production build reads.\n resetCache\n } = (\n // `--entry-file` is a placeholder in generated native projects. VxRN apps\n // configure entries.native through vxrn/react-native-commands, while One\n // generates its native entry from the route tree.\n // `--read-global-cache` / `--max-workers` / `--config` / `--transformer` /\n // `--resolver-option` configure Metro's global cache, worker pool and\n // resolver. A rolldown production build has none of them: it transforms\n // from source in-process. React Native's own bundle command ignores\n // `--read-global-cache` too.\n // `--unstable-transform-profile` picks a JS engine to target. This pipeline\n // always downlevels for Hermes, which is what every profile it accepts\n // ('default', 'hermes', 'hermes-canary') can run.\n // `--sourcemap-use-absolute-path`, `--sourcemap-sources-root`,\n // `--asset-catalog-dest` and `--indexed-ram-bundle` are not implemented.\n args\n );\n var { root } = ctx;\n if (typeof root !== \"string\") {\n throw new Error(`Expected ctx.root to be a string, but got ${typeof root}`);\n }\n var viteConfig = await resolveConfig({}, \"build\", \"production\");\n if (globalThis[\"__viteMetroPluginOptions__\"]) {\n console.info(\"Using @vxrn/vite-plugin-metro to build the bundle.\");\n var { bundle } = await import(\"@vxrn/vite-plugin-metro/rn-commands\");\n await bundle.getBuildBundleFn(viteConfig)(_argv, ctx, args, bundleImpl);\n return;\n }\n process.env.IS_VXRN_CLI = \"true\";\n loadEnv(dev ? \"development\" : \"production\", root);\n if (!dev) {\n process.env.NODE_ENV = \"production\";\n }\n if (resetCache) {\n clearTransformCache();\n }\n console.info(`[vxrn] building native bundle for ${platform}...`);\n var nativeEntryFile = (_ctx_vxrnEntries = ctx.vxrnEntries) === null || _ctx_vxrnEntries === void 0 ? void 0 : _ctx_vxrnEntries.native;\n if (nativeEntryFile !== void 0 && typeof nativeEntryFile !== \"string\") {\n throw new Error(\"Expected entries.native to be a string\");\n }\n var result = await buildNativeBundle({\n root,\n platform,\n dev,\n entryFile: nativeEntryFile,\n // pass through ONE_SERVER_URL so the native prelude can inject it into\n // process.env. without this, getURL.native falls back to the dummy\n // 'http://one-server.example.com' and runtime loader fetches fail in prod.\n serverUrl: process.env.ONE_SERVER_URL,\n assetsDest,\n sourcemap: !!args.sourcemapOutput,\n minify\n });\n var builtBundle = result.code;\n if (platform === \"android\" && assetsDest) {\n var source = join(assetsDest, \"one-dom\");\n var destination = join(dirname(bundleOutput), \"one-dom\");\n if (resolve(source) !== resolve(destination)) {\n FSExtra.removeSync(destination);\n if (FSExtra.existsSync(source)) FSExtra.moveSync(source, destination);\n }\n }\n if (result.map && args.sourcemapOutput) {\n FSExtra.outputFileSync(args.sourcemapOutput, result.map, {\n encoding: \"utf8\"\n });\n }\n console.info(`Writing bundle to ${bundleOutput}...`);\n FSExtra.outputFileSync(bundleOutput, builtBundle, {\n encoding: bundleEncoding\n });\n console.info(\"Done.\");\n setTimeout(function() {\n console.info(\"Exiting process to prevent hanging.\");\n process.exit();\n }, 3e4).unref();\n}\nexport {\n buildBundle\n};\n//# sourceMappingURL=buildBundle.js.map\n"],"mappings":";;;;;;;;AAMA,eAAe,YAAY,OAAO,KAAK,MAAM;CAC3C,IAAI,aAAa,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK;CAClF,IAAI;CACJ,IAAI,EACF,UACA,KACA,cAEA,iBAAiB,QACjB,YAGA,QAGA,eAeA;CAEF,IAAI,EAAE,SAAS;CACf,IAAI,OAAO,SAAS,UAAU;EAC5B,MAAM,IAAI,MAAM,6CAA6C,OAAO,MAAM;CAC5E;CACA,IAAI,aAAa,MAAM,cAAc,CAAC,GAAG,SAAS,YAAY;CAC9D,IAAI,WAAW,+BAA+B;EAC5C,QAAQ,KAAK,oDAAoD;EACjE,IAAI,EAAE,WAAW,MAAM,OAAO;EAC9B,MAAM,OAAO,iBAAiB,UAAU,CAAC,CAAC,OAAO,KAAK,MAAM,UAAU;EACtE;CACF;CACA,QAAQ,IAAI,cAAc;CAC1B,QAAQ,MAAM,gBAAgB,cAAc,IAAI;CAChD,IAAI,CAAC,KAAK;EACR,QAAQ,IAAI,WAAW;CACzB;CACA,IAAI,YAAY;EACd,oBAAoB;CACtB;CACA,QAAQ,KAAK,qCAAqC,SAAS,IAAI;CAC/D,IAAI,mBAAmB,mBAAmB,IAAI,iBAAiB,QAAQ,qBAAqB,KAAK,IAAI,KAAK,IAAI,iBAAiB;CAC/H,IAAI,oBAAoB,KAAK,KAAK,OAAO,oBAAoB,UAAU;EACrE,MAAM,IAAI,MAAM,wCAAwC;CAC1D;CACA,IAAI,SAAS,MAAM,kBAAkB;EACnC;EACA;EACA;EACA,WAAW;EAIX,WAAW,QAAQ,IAAI;EACvB;EACA,WAAW,CAAC,CAAC,KAAK;EAClB;CACF,CAAC;CACD,IAAI,cAAc,OAAO;CACzB,IAAI,aAAa,aAAa,YAAY;EACxC,IAAI,SAAS,KAAK,YAAY,SAAS;EACvC,IAAI,cAAc,KAAK,QAAQ,YAAY,GAAG,SAAS;EACvD,IAAI,QAAQ,MAAM,MAAM,QAAQ,WAAW,GAAG;GAC5C,QAAQ,WAAW,WAAW;GAC9B,IAAI,QAAQ,WAAW,MAAM,GAAG,QAAQ,SAAS,QAAQ,WAAW;EACtE;CACF;CACA,IAAI,OAAO,OAAO,KAAK,iBAAiB;EACtC,QAAQ,eAAe,KAAK,iBAAiB,OAAO,KAAK,EACvD,UAAU,OACZ,CAAC;CACH;CACA,QAAQ,KAAK,qBAAqB,aAAa,IAAI;CACnD,QAAQ,eAAe,cAAc,aAAa,EAChD,UAAU,eACZ,CAAC;CACD,QAAQ,KAAK,OAAO;CACpB,WAAW,WAAW;EACpB,QAAQ,KAAK,qCAAqC;EAClD,QAAQ,KAAK;CACf,GAAG,GAAG,CAAC,CAAC,MAAM;AAChB"}
1
+ {"version":3,"file":"buildBundle.native.js","names":[],"sources":["rn-commands/bundle/buildBundle.native.js"],"sourcesContent":["import { clearTransformCache } from \"@vxrn/compiler\";\nimport { cpSync, existsSync, mkdirSync, renameSync, rmSync } from \"fs\";\nimport { resolveConfig } from \"vite\";\nimport { dirname, join, resolve } from \"path\";\nimport { outputFileSync } from \"../../utils/fs\";\nimport { loadEnv } from \"../../exports/loadEnv\";\nimport { buildNativeBundle } from \"../../utils/createNativeDevEngine\";\nasync function buildBundle(_argv, ctx, args) {\n var bundleImpl = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;\n var _ctx_vxrnEntries;\n var {\n platform,\n dev,\n bundleOutput,\n // React Native's `--bundle-encoding` names a Node Buffer encoding.\n bundleEncoding = \"utf8\",\n assetsDest,\n // `--minify` overrides React Native's default of \"minify unless this is a\n // dev bundle\". undefined means the flag was not passed.\n minify,\n // `--reset-cache` drops the compiler's transform cache, the only cache a\n // rolldown production build reads.\n resetCache\n } = (\n // `--entry-file` is a placeholder in generated native projects. VxRN apps\n // configure entries.native through vxrn/react-native-commands, while One\n // generates its native entry from the route tree.\n // `--read-global-cache` / `--max-workers` / `--config` / `--transformer` /\n // `--resolver-option` configure Metro's global cache, worker pool and\n // resolver. A rolldown production build has none of them: it transforms\n // from source in-process. React Native's own bundle command ignores\n // `--read-global-cache` too.\n // `--unstable-transform-profile` picks a JS engine to target. This pipeline\n // always downlevels for Hermes, which is what every profile it accepts\n // ('default', 'hermes', 'hermes-canary') can run.\n // `--sourcemap-use-absolute-path`, `--sourcemap-sources-root`,\n // `--asset-catalog-dest` and `--indexed-ram-bundle` are not implemented.\n args\n );\n var { root } = ctx;\n if (typeof root !== \"string\") {\n throw new Error(`Expected ctx.root to be a string, but got ${typeof root}`);\n }\n var viteConfig = await resolveConfig({}, \"build\", \"production\");\n if (globalThis[\"__viteMetroPluginOptions__\"]) {\n console.info(\"Using @vxrn/vite-plugin-metro to build the bundle.\");\n var { bundle } = await import(\"@vxrn/vite-plugin-metro/rn-commands\");\n await bundle.getBuildBundleFn(viteConfig)(_argv, ctx, args, bundleImpl);\n return;\n }\n process.env.IS_VXRN_CLI = \"true\";\n loadEnv(dev ? \"development\" : \"production\", root);\n if (!dev) {\n process.env.NODE_ENV = \"production\";\n }\n if (resetCache) {\n clearTransformCache();\n }\n console.info(`[vxrn] building native bundle for ${platform}...`);\n var nativeEntryFile = (_ctx_vxrnEntries = ctx.vxrnEntries) === null || _ctx_vxrnEntries === void 0 ? void 0 : _ctx_vxrnEntries.native;\n if (nativeEntryFile !== void 0 && typeof nativeEntryFile !== \"string\") {\n throw new Error(\"Expected entries.native to be a string\");\n }\n var result = await buildNativeBundle({\n root,\n platform,\n dev,\n entryFile: nativeEntryFile,\n // pass through ONE_SERVER_URL so the native prelude can inject it into\n // process.env. without this, getURL.native falls back to the dummy\n // 'http://one-server.example.com' and runtime loader fetches fail in prod.\n serverUrl: process.env.ONE_SERVER_URL,\n assetsDest,\n sourcemap: !!args.sourcemapOutput,\n minify\n });\n var builtBundle = result.code;\n if (platform === \"android\" && assetsDest) {\n var source = join(assetsDest, \"one-dom\");\n var destination = join(dirname(bundleOutput), \"one-dom\");\n if (resolve(source) !== resolve(destination)) {\n rmSync(destination, {\n recursive: true,\n force: true\n });\n if (existsSync(source)) {\n mkdirSync(dirname(destination), {\n recursive: true\n });\n try {\n renameSync(source, destination);\n } catch (error) {\n if (error.code !== \"EXDEV\") throw error;\n cpSync(source, destination, {\n recursive: true\n });\n rmSync(source, {\n recursive: true\n });\n }\n }\n }\n }\n if (result.map && args.sourcemapOutput) {\n outputFileSync(args.sourcemapOutput, result.map, {\n encoding: \"utf8\"\n });\n }\n console.info(`Writing bundle to ${bundleOutput}...`);\n outputFileSync(bundleOutput, builtBundle, {\n encoding: bundleEncoding\n });\n console.info(\"Done.\");\n setTimeout(function() {\n console.info(\"Exiting process to prevent hanging.\");\n process.exit();\n }, 3e4).unref();\n}\nexport {\n buildBundle\n};\n//# sourceMappingURL=buildBundle.js.map\n"],"mappings":";;;;;;;;;AAOA,eAAe,YAAY,OAAO,KAAK,MAAM;CAC3C,IAAI,aAAa,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK;CAClF,IAAI;CACJ,IAAI,EACF,UACA,KACA,cAEA,iBAAiB,QACjB,YAGA,QAGA,eAeA;CAEF,IAAI,EAAE,SAAS;CACf,IAAI,OAAO,SAAS,UAAU;EAC5B,MAAM,IAAI,MAAM,6CAA6C,OAAO,MAAM;CAC5E;CACA,IAAI,aAAa,MAAM,cAAc,CAAC,GAAG,SAAS,YAAY;CAC9D,IAAI,WAAW,+BAA+B;EAC5C,QAAQ,KAAK,oDAAoD;EACjE,IAAI,EAAE,WAAW,MAAM,OAAO;EAC9B,MAAM,OAAO,iBAAiB,UAAU,CA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eAAe,cAAc,aAAa,EACxC,UAAU,eACZ,CAAC;CACD,QAAQ,KAAK,OAAO;CACpB,WAAW,WAAW;EACpB,QAAQ,KAAK,qCAAqC;EAClD,QAAQ,KAAK;CACf,GAAG,GAAG,CAAC,CAAC,MAAM;AAChB"}
@@ -1,3 +1,4 @@
1
+ import { defaultEditor } from "../utils/env-editor.mjs";
1
2
  import { exec } from "node:child_process";
2
3
  import { getBoundPort } from "../utils/getBoundPort.mjs";
3
4
  import { nativeRun } from "../utils/nativeRun.mjs";
@@ -37,7 +38,6 @@ const COMMANDS = [
37
38
  label: "open editor",
38
39
  terminalLabel: "\x1B[1mo\x1B[0mpen \x1B[1me\x1B[0mditor",
39
40
  action: async (ctx) => {
40
- const { defaultEditor } = await import("env-editor");
41
41
  exec(`${defaultEditor().binary} .`);
42
42
  }
43
43
  },
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["user-interface/index.js"],"sourcesContent":["import { exec } from \"node:child_process\";\nimport { getBoundPort } from \"../utils/getBoundPort\";\nimport { nativeRun } from \"../utils/nativeRun\";\nconst COMMANDS = [\n {\n keys: \"ow\",\n label: \"open web\",\n terminalLabel: \"\\x1B[1mo\\x1B[0mpen \\x1B[1mw\\x1B[0meb\",\n action: (ctx) => {\n const url = ctx.server.resolvedUrls?.local[0];\n if (!url) {\n console.warn(\"Cannot get the local server URL.\");\n return;\n }\n nativeOpen(url);\n }\n },\n {\n keys: \"oi\",\n label: \"open app in iOS Simulator\",\n terminalLabel: \"\\x1B[1mo\\x1B[0mpen app in \\x1B[1mi\\x1B[0mOS Simulator\",\n action: (ctx) => {\n openIos(ctx);\n }\n },\n {\n keys: \"oa\",\n label: \"open app in Android Emulator\",\n terminalLabel: \"\\x1B[1mo\\x1B[0mpen app in \\x1B[1mA\\x1B[0mndroid Emulator\",\n action: (ctx) => {\n openAndroid(ctx);\n }\n },\n {\n keys: \"oe\",\n label: \"open editor\",\n terminalLabel: \"\\x1B[1mo\\x1B[0mpen \\x1B[1me\\x1B[0mditor\",\n action: async (ctx) => {\n const { defaultEditor } = await import(\"env-editor\");\n exec(`${defaultEditor().binary} .`);\n }\n },\n // TODO this would need to be per-platform\n {\n keys: \"dt\",\n label: \"open React Native DevTools\",\n terminalLabel: \"open React Native \\x1B[1mD\\x1B[0mev\\x1B[1mT\\x1B[0mools\",\n action: openReactNativeDevTools\n },\n {\n keys: \"j\",\n label: \"open React Native DevTools\",\n terminalLabel: \"open React Native DevTools\",\n action: openReactNativeDevTools\n },\n {\n keys: \"?\",\n label: \"show commands\",\n terminalLabel: \"show this menu\",\n action: async (ctx) => {\n }\n }\n];\nfunction openReactNativeDevTools(ctx) {\n const { host } = ctx.server.config.server;\n const serverUrl = `http://${typeof host === \"string\" && !!host ? host : \"localhost\"}:${getBoundPort(ctx.server)}`;\n const url = new URL(\"/open-debugger\", serverUrl);\n (async () => {\n const response = await fetch(url, {\n method: \"POST\",\n signal: AbortSignal.timeout(3e3)\n }).catch((error) => {\n if (error.name === \"TimeoutError\") {\n return null;\n }\n throw error;\n });\n if (!response) {\n } else if (response.ok === false) {\n const responseText = await response.text();\n if (responseText.includes(\"Unable to find debugger target\")) {\n return;\n }\n console.warn(\n `Failed to open React Native DevTools, ${url} returns ${response.status}: ${responseText}.`\n );\n }\n })();\n}\nasync function startUserInterface(context) {\n if (!supportsKeyboardCommands()) {\n return;\n }\n printCommandsTable(context);\n startInterceptingKeyStrokes(context);\n}\nfunction printCommandsTable(context) {\n const longestKeyLength = COMMANDS.reduce(\n (max, command) => Math.max(max, command.keys.length),\n 0\n );\n const commandsInfo = COMMANDS.map(\n (cmd) => getCommandInfoInTerminal(cmd, { longestKeyLength })\n ).join(\"\\n\");\n console.info(`\n${commandsInfo}\n`);\n}\nfunction getCommandInfoInTerminal(command, { longestKeyLength = 0 } = {}) {\n return `\\x1B[90m\\u203A\\x1B[0m Press \\x1B[1m${longestKeyLength ? command.keys.padEnd(longestKeyLength, \" \") : command.keys}\\x1B[0m \\x1B[90m\\u2502\\x1B[0m ${command.terminalLabel}`;\n}\nfunction restoreTerminal() {\n const { stdin } = process;\n if (stdin.isTTY && stdin.setRawMode) {\n try {\n stdin.setRawMode(false);\n } catch {\n }\n }\n process.stdout.write(\"\\x1B[0m\");\n}\nfunction supportsKeyboardCommands() {\n const { stdin } = process;\n return Boolean(stdin.isTTY && stdin.setRawMode);\n}\nfunction startInterceptingKeyStrokes(context) {\n const { stdin } = process;\n if (!supportsKeyboardCommands()) {\n return;\n }\n stdin.setRawMode(true);\n stdin.resume();\n stdin.setEncoding(\"utf8\");\n stdin.on(\"data\", handleKeypress.bind(null, context));\n stdin.unref();\n process.on(\"exit\", restoreTerminal);\n process.on(\"SIGINT\", () => {\n restoreTerminal();\n process.exit(0);\n });\n process.on(\"SIGTERM\", () => {\n restoreTerminal();\n process.exit(0);\n });\n}\nlet pressedKeys = \"\";\nlet clearPressedKeysTimer = null;\nfunction clearPressedKeys() {\n pressedKeys = \"\";\n clearPrintedInfo();\n}\nfunction resetClearPressedKeysTimer() {\n if (clearPressedKeysTimer) {\n clearTimeout(clearPressedKeysTimer);\n }\n clearPressedKeysTimer = setTimeout(clearPressedKeys, 3e3);\n clearPressedKeysTimer.unref();\n}\nfunction handleKeypress(context, key) {\n if (key === \"\\x1B\") {\n clearPrintedInfo();\n pressedKeys = \"\";\n return;\n }\n if (key === \"?\" || key === \"/\") {\n clearPrintedInfo();\n console.info(\"> ?\\n\\u21D2 Available commands:\");\n printCommandsTable(context);\n return;\n }\n resetClearPressedKeysTimer();\n if (key === \"\\x7F\") {\n pressedKeys = pressedKeys.slice(0, -1);\n } else {\n key = key.toLowerCase();\n if (/^[a-z]$/.test(key)) {\n pressedKeys += key;\n }\n }\n if (pressedKeys.length === 0) {\n clearPrintedInfo();\n return;\n }\n const matchedCommand = COMMANDS.find((command) => command.keys === pressedKeys);\n if (matchedCommand) {\n clearPrintedInfo();\n console.info(`> ${matchedCommand.keys}\n\\u21D2 ${matchedCommand.label}...`);\n pressedKeys = \"\";\n setTimeout(() => matchedCommand.action?.(context), 500);\n return;\n }\n if (pressedKeys.length >= 3) {\n clearPrintedInfo();\n console.info(\n `> ${pressedKeys}\nNo matching command for \"${pressedKeys}\"! Press \"?\" for help.`\n );\n pressedKeys = \"\";\n return;\n }\n const possibleCommands = COMMANDS.filter(\n (command) => command.keys.startsWith(pressedKeys)\n );\n const commandsInfo = possibleCommands.map((command) => {\n const matchedPart = command.keys.slice(0, pressedKeys.length);\n const remainingPart = command.keys.slice(pressedKeys.length);\n return ` \\x1B[4m${matchedPart}\\x1B[0m\\x1B[1m${remainingPart}\\x1B[0m\\x1B[90m - \\x1B[0m${command.terminalLabel}`;\n }).join(\"\\n\");\n const infoToPrint = `\n${commandsInfo}\n> ${pressedKeys}`;\n printInfo(infoToPrint);\n}\nlet lastPrintedInfo = \"\";\nfunction printInfo(info) {\n clearPrintedInfo();\n lastPrintedInfo = info;\n process.stdout.write(info);\n}\nfunction clearPrintedInfo() {\n if (lastPrintedInfo) {\n process.stdout.write(\"\\x1B[2K\");\n process.stdout.write(\"\\x1B[1A\\x1B[2K\".repeat(lastPrintedInfo.split(\"\\n\").length - 1));\n process.stdout.write(\"\\x1B[2K\");\n process.stdout.write(\"\\x1B[G\");\n }\n lastPrintedInfo = \"\";\n}\nfunction nativeOpen(url) {\n const start = process.platform === \"darwin\" ? \"open\" : process.platform === \"win32\" ? \"start\" : \"xdg-open\";\n exec(`${start} ${url}`);\n}\nasync function openIos(ctx) {\n const projectRoot = ctx.server.config.root;\n const port = getBoundPort(ctx.server);\n try {\n await nativeRun({ root: projectRoot, platform: \"ios\", port });\n } catch (e) {\n const stack = e instanceof Error ? e.stack : null;\n console.error(`Failed to open app in iOS Simulator: ${e}${stack ? `\n${stack}` : \"\"}`);\n }\n}\nasync function openAndroid(ctx) {\n const projectRoot = ctx.server.config.root;\n const port = getBoundPort(ctx.server);\n try {\n await nativeRun({ root: projectRoot, platform: \"android\", port });\n } catch (e) {\n const stack = e instanceof Error ? e.stack : null;\n console.error(\n `Failed to open app in Android Emulator: ${e}${stack ? `\n${stack}` : \"\"}`\n );\n }\n}\nexport {\n startUserInterface\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;AAGA,MAAM,WAAW;CACf;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,SAAS,QAAQ;GACf,MAAM,MAAM,IAAI,OAAO,cAAc,MAAM;GAC3C,IAAI,CAAC,KAAK;IACR,QAAQ,KAAK,kCAAkC;IAC/C;GACF;GACA,WAAW,GAAG;EAChB;CACF;CACA;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,SAAS,QAAQ;GACf,QAAQ,GAAG;EACb;CACF;CACA;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,SAAS,QAAQ;GACf,YAAY,GAAG;EACjB;CACF;CACA;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,QAAQ,OAAO,QAAQ;GACrB,MAAM,EAAE,kBAAkB,MAAM,OAAO;GACvC,KAAK,GAAG,cAAc,CAAC,CAAC,OAAO,GAAG;EACpC;CACF;CAEA;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,QAAQ;CACV;CACA;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,QAAQ;CACV;CACA;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,QAAQ,OAAO,QAAQ,CACvB;CACF;AACF;AACA,SAAS,wBAAwB,KAAK;CACpC,MAAM,EAAE,SAAS,IAAI,OAAO,OAAO;CACnC,MAAM,YAAY,UAAU,OAAO,SAAS,YAAY,CAAC,CAAC,OAAO,OAAO,YAAY,GAAG,aAAa,IAAI,MAAM;CAC9G,MAAM,MAAM,IAAI,IAAI,kBAAkB,SAAS;CAC/C,CAAC,YAAY;EACX,MAAM,WAAW,MAAM,MAAM,KAAK;GAChC,QAAQ;GACR,QAAQ,YAAY,QAAQ,GAAG;EACjC,CAAC,CAAC,CAAC,OAAO,UAAU;GAClB,IAAI,MAAM,SAAS,gBAAgB;IACjC,OA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M,cAAc,IAAI,OAAO,OAAO;CACtC,MAAM,OAAO,aAAa,IAAI,MAAM;CACpC,IAAI;EACF,MAAM,UAAU;GAAE,MAAM;GAAa,UAAU;GAAW;EAAK,CAAC;CAClE,SAAS,GAAG;EACV,MAAM,QAAQ,aAAa,QAAQ,EAAE,QAAQ;EAC7C,QAAQ,MACN,2CAA2C,IAAI,QAAQ;EAC3D,UAAU,IACR;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["user-interface/index.js"],"sourcesContent":["import { defaultEditor } from \"../utils/env-editor\";\nimport { exec } from \"node:child_process\";\nimport { getBoundPort } from \"../utils/getBoundPort\";\nimport { nativeRun } from \"../utils/nativeRun\";\nconst COMMANDS = [\n {\n keys: \"ow\",\n label: \"open web\",\n terminalLabel: \"\\x1B[1mo\\x1B[0mpen \\x1B[1mw\\x1B[0meb\",\n action: (ctx) => {\n const url = ctx.server.resolvedUrls?.local[0];\n if (!url) {\n console.warn(\"Cannot get the local server URL.\");\n return;\n }\n nativeOpen(url);\n }\n },\n {\n keys: \"oi\",\n label: \"open app in iOS Simulator\",\n terminalLabel: \"\\x1B[1mo\\x1B[0mpen app in \\x1B[1mi\\x1B[0mOS Simulator\",\n action: (ctx) => {\n openIos(ctx);\n }\n },\n {\n keys: \"oa\",\n label: \"open app in Android Emulator\",\n terminalLabel: \"\\x1B[1mo\\x1B[0mpen app in \\x1B[1mA\\x1B[0mndroid Emulator\",\n action: (ctx) => {\n openAndroid(ctx);\n }\n },\n {\n keys: \"oe\",\n label: \"open editor\",\n terminalLabel: \"\\x1B[1mo\\x1B[0mpen \\x1B[1me\\x1B[0mditor\",\n action: async (ctx) => {\n exec(`${defaultEditor().binary} .`);\n }\n },\n // TODO this would need to be per-platform\n {\n keys: \"dt\",\n label: \"open React Native DevTools\",\n terminalLabel: \"open React Native \\x1B[1mD\\x1B[0mev\\x1B[1mT\\x1B[0mools\",\n action: openReactNativeDevTools\n },\n {\n keys: \"j\",\n label: \"open React Native DevTools\",\n terminalLabel: \"open React Native DevTools\",\n action: openReactNativeDevTools\n },\n {\n keys: \"?\",\n label: \"show commands\",\n terminalLabel: \"show this menu\",\n action: async (ctx) => {\n }\n }\n];\nfunction openReactNativeDevTools(ctx) {\n const { host } = ctx.server.config.server;\n const serverUrl = `http://${typeof host === \"string\" && !!host ? host : \"localhost\"}:${getBoundPort(ctx.server)}`;\n const url = new URL(\"/open-debugger\", serverUrl);\n (async () => {\n const response = await fetch(url, {\n method: \"POST\",\n signal: AbortSignal.timeout(3e3)\n }).catch((error) => {\n if (error.name === \"TimeoutError\") {\n return null;\n }\n throw error;\n });\n if (!response) {\n } else if (response.ok === false) {\n const responseText = await response.text();\n if (responseText.includes(\"Unable to find debugger target\")) {\n return;\n }\n console.warn(\n `Failed to open React Native DevTools, ${url} returns ${response.status}: ${responseText}.`\n );\n }\n })();\n}\nasync function startUserInterface(context) {\n if (!supportsKeyboardCommands()) {\n return;\n }\n printCommandsTable(context);\n startInterceptingKeyStrokes(context);\n}\nfunction printCommandsTable(context) {\n const longestKeyLength = COMMANDS.reduce(\n (max, command) => Math.max(max, command.keys.length),\n 0\n );\n const commandsInfo = COMMANDS.map(\n (cmd) => getCommandInfoInTerminal(cmd, { longestKeyLength })\n ).join(\"\\n\");\n console.info(`\n${commandsInfo}\n`);\n}\nfunction getCommandInfoInTerminal(command, { longestKeyLength = 0 } = {}) {\n return `\\x1B[90m\\u203A\\x1B[0m Press \\x1B[1m${longestKeyLength ? command.keys.padEnd(longestKeyLength, \" \") : command.keys}\\x1B[0m \\x1B[90m\\u2502\\x1B[0m ${command.terminalLabel}`;\n}\nfunction restoreTerminal() {\n const { stdin } = process;\n if (stdin.isTTY && stdin.setRawMode) {\n try {\n stdin.setRawMode(false);\n } catch {\n }\n }\n process.stdout.write(\"\\x1B[0m\");\n}\nfunction supportsKeyboardCommands() {\n const { stdin } = process;\n return Boolean(stdin.isTTY && stdin.setRawMode);\n}\nfunction startInterceptingKeyStrokes(context) {\n const { stdin } = process;\n if (!supportsKeyboardCommands()) {\n return;\n }\n stdin.setRawMode(true);\n stdin.resume();\n stdin.setEncoding(\"utf8\");\n stdin.on(\"data\", handleKeypress.bind(null, context));\n stdin.unref();\n process.on(\"exit\", restoreTerminal);\n process.on(\"SIGINT\", () => {\n restoreTerminal();\n process.exit(0);\n });\n process.on(\"SIGTERM\", () => {\n restoreTerminal();\n process.exit(0);\n });\n}\nlet pressedKeys = \"\";\nlet clearPressedKeysTimer = null;\nfunction clearPressedKeys() {\n pressedKeys = \"\";\n clearPrintedInfo();\n}\nfunction resetClearPressedKeysTimer() {\n if (clearPressedKeysTimer) {\n clearTimeout(clearPressedKeysTimer);\n }\n clearPressedKeysTimer = setTimeout(clearPressedKeys, 3e3);\n clearPressedKeysTimer.unref();\n}\nfunction handleKeypress(context, key) {\n if (key === \"\\x1B\") {\n clearPrintedInfo();\n pressedKeys = \"\";\n return;\n }\n if (key === \"?\" || key === \"/\") {\n clearPrintedInfo();\n console.info(\"> ?\\n\\u21D2 Available commands:\");\n printCommandsTable(context);\n return;\n }\n resetClearPressedKeysTimer();\n if (key === \"\\x7F\") {\n pressedKeys = pressedKeys.slice(0, -1);\n } else {\n key = key.toLowerCase();\n if (/^[a-z]$/.test(key)) {\n pressedKeys += key;\n }\n }\n if (pressedKeys.length === 0) {\n clearPrintedInfo();\n return;\n }\n const matchedCommand = COMMANDS.find((command) => command.keys === pressedKeys);\n if (matchedCommand) {\n clearPrintedInfo();\n console.info(`> ${matchedCommand.keys}\n\\u21D2 ${matchedCommand.label}...`);\n pressedKeys = \"\";\n setTimeout(() => matchedCommand.action?.(context), 500);\n return;\n }\n if (pressedKeys.length >= 3) {\n clearPrintedInfo();\n console.info(\n `> ${pressedKeys}\nNo matching command for \"${pressedKeys}\"! Press \"?\" for help.`\n );\n pressedKeys = \"\";\n return;\n }\n const possibleCommands = COMMANDS.filter(\n (command) => command.keys.startsWith(pressedKeys)\n );\n const commandsInfo = possibleCommands.map((command) => {\n const matchedPart = command.keys.slice(0, pressedKeys.length);\n const remainingPart = command.keys.slice(pressedKeys.length);\n return ` \\x1B[4m${matchedPart}\\x1B[0m\\x1B[1m${remainingPart}\\x1B[0m\\x1B[90m - \\x1B[0m${command.terminalLabel}`;\n }).join(\"\\n\");\n const infoToPrint = `\n${commandsInfo}\n> ${pressedKeys}`;\n printInfo(infoToPrint);\n}\nlet lastPrintedInfo = \"\";\nfunction printInfo(info) {\n clearPrintedInfo();\n lastPrintedInfo = info;\n process.stdout.write(info);\n}\nfunction clearPrintedInfo() {\n if (lastPrintedInfo) {\n process.stdout.write(\"\\x1B[2K\");\n process.stdout.write(\"\\x1B[1A\\x1B[2K\".repeat(lastPrintedInfo.split(\"\\n\").length - 1));\n process.stdout.write(\"\\x1B[2K\");\n process.stdout.write(\"\\x1B[G\");\n }\n lastPrintedInfo = \"\";\n}\nfunction nativeOpen(url) {\n const start = process.platform === \"darwin\" ? \"open\" : process.platform === \"win32\" ? \"start\" : \"xdg-open\";\n exec(`${start} ${url}`);\n}\nasync function openIos(ctx) {\n const projectRoot = ctx.server.config.root;\n const port = getBoundPort(ctx.server);\n try {\n await nativeRun({ root: projectRoot, platform: \"ios\", port });\n } catch (e) {\n const stack = e instanceof Error ? e.stack : null;\n console.error(`Failed to open app in iOS Simulator: ${e}${stack ? `\n${stack}` : \"\"}`);\n }\n}\nasync function openAndroid(ctx) {\n const projectRoot = ctx.server.config.root;\n const port = getBoundPort(ctx.server);\n try {\n await nativeRun({ root: projectRoot, platform: \"android\", port });\n } catch (e) {\n const stack = e instanceof Error ? e.stack : null;\n console.error(\n `Failed to open app in Android Emulator: ${e}${stack ? `\n${stack}` : \"\"}`\n );\n }\n}\nexport {\n startUserInterface\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;;AAIA,MAAM,WAAW;CACf;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,SAAS,QAAQ;GACf,MAAM,MAAM,IAAI,OAAO,cAAc,MAAM;GAC3C,IAAI,CAAC,KAA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"../utils/env-editor.native.js";
1
2
  import { exec } from "child_process";
2
3
  import { getBoundPort } from "../utils/getBoundPort.native.js";
3
4
  import { nativeRun } from "../utils/nativeRun.native.js";
@@ -38,7 +39,6 @@ var COMMANDS = [
38
39
  label: "open editor",
39
40
  terminalLabel: "\x1B[1mo\x1B[0mpen \x1B[1me\x1B[0mditor",
40
41
  action: async function action4(ctx) {
41
- var { defaultEditor } = await import("env-editor");
42
42
  exec(`${defaultEditor().binary} .`);
43
43
  }
44
44
  },
@@ -1 +1 @@
1
- {"version":3,"file":"index.native.js","names":[],"sources":["user-interface/index.native.js"],"sourcesContent":["import { exec } from \"child_process\";\nimport { getBoundPort } from \"../utils/getBoundPort\";\nimport { nativeRun } from \"../utils/nativeRun\";\nvar COMMANDS = [\n {\n keys: \"ow\",\n label: \"open web\",\n terminalLabel: \"\\x1B[1mo\\x1B[0mpen \\x1B[1mw\\x1B[0meb\",\n action: function action(ctx) {\n var _ctx_server_resolvedUrls;\n var url = (_ctx_server_resolvedUrls = ctx.server.resolvedUrls) === null || _ctx_server_resolvedUrls === void 0 ? void 0 : _ctx_server_resolvedUrls.local[0];\n if (!url) {\n console.warn(\"Cannot get the local server URL.\");\n return;\n }\n nativeOpen(url);\n }\n },\n {\n keys: \"oi\",\n label: \"open app in iOS Simulator\",\n terminalLabel: \"\\x1B[1mo\\x1B[0mpen app in \\x1B[1mi\\x1B[0mOS Simulator\",\n action: function action2(ctx) {\n openIos(ctx);\n }\n },\n {\n keys: \"oa\",\n label: \"open app in Android Emulator\",\n terminalLabel: \"\\x1B[1mo\\x1B[0mpen app in \\x1B[1mA\\x1B[0mndroid Emulator\",\n action: function action3(ctx) {\n openAndroid(ctx);\n }\n },\n {\n keys: \"oe\",\n label: \"open editor\",\n terminalLabel: \"\\x1B[1mo\\x1B[0mpen \\x1B[1me\\x1B[0mditor\",\n action: async function action4(ctx) {\n var { defaultEditor } = await import(\"env-editor\");\n exec(`${defaultEditor().binary} .`);\n }\n },\n // TODO this would need to be per-platform\n {\n keys: \"dt\",\n label: \"open React Native DevTools\",\n terminalLabel: \"open React Native \\x1B[1mD\\x1B[0mev\\x1B[1mT\\x1B[0mools\",\n action: openReactNativeDevTools\n },\n {\n keys: \"j\",\n label: \"open React Native DevTools\",\n terminalLabel: \"open React Native DevTools\",\n action: openReactNativeDevTools\n },\n {\n keys: \"?\",\n label: \"show commands\",\n terminalLabel: \"show this menu\",\n action: async function action5(ctx) {\n }\n }\n];\nfunction openReactNativeDevTools(ctx) {\n var { host } = ctx.server.config.server;\n var serverUrl = `http://${typeof host === \"string\" && !!host ? host : \"localhost\"}:${getBoundPort(ctx.server)}`;\n var url = new URL(\"/open-debugger\", serverUrl);\n (async function() {\n var response = await fetch(url, {\n method: \"POST\",\n signal: AbortSignal.timeout(3e3)\n }).catch(function(error) {\n if (error.name === \"TimeoutError\") {\n return null;\n }\n throw error;\n });\n if (!response) {\n } else if (response.ok === false) {\n var responseText = await response.text();\n if (responseText.includes(\"Unable to find debugger target\")) {\n return;\n }\n console.warn(`Failed to open React Native DevTools, ${url} returns ${response.status}: ${responseText}.`);\n }\n })();\n}\nasync function startUserInterface(context) {\n if (!supportsKeyboardCommands()) {\n return;\n }\n printCommandsTable(context);\n startInterceptingKeyStrokes(context);\n}\nfunction printCommandsTable(context) {\n var longestKeyLength = COMMANDS.reduce(function(max, command) {\n return Math.max(max, command.keys.length);\n }, 0);\n var commandsInfo = COMMANDS.map(function(cmd) {\n return getCommandInfoInTerminal(cmd, {\n longestKeyLength\n });\n }).join(\"\\n\");\n console.info(`\n${commandsInfo}\n`);\n}\nfunction getCommandInfoInTerminal(command) {\n var { longestKeyLength = 0 } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};\n return `\\x1B[90m\\u203A\\x1B[0m Press \\x1B[1m${longestKeyLength ? command.keys.padEnd(longestKeyLength, \" \") : command.keys}\\x1B[0m \\x1B[90m\\u2502\\x1B[0m ${command.terminalLabel}`;\n}\nfunction restoreTerminal() {\n var { stdin } = process;\n if (stdin.isTTY && stdin.setRawMode) {\n try {\n stdin.setRawMode(false);\n } catch (unused) {\n }\n }\n process.stdout.write(\"\\x1B[0m\");\n}\nfunction supportsKeyboardCommands() {\n var { stdin } = process;\n return Boolean(stdin.isTTY && stdin.setRawMode);\n}\nfunction startInterceptingKeyStrokes(context) {\n var { stdin } = process;\n if (!supportsKeyboardCommands()) {\n return;\n }\n stdin.setRawMode(true);\n stdin.resume();\n stdin.setEncoding(\"utf8\");\n stdin.on(\"data\", handleKeypress.bind(null, context));\n stdin.unref();\n process.on(\"exit\", restoreTerminal);\n process.on(\"SIGINT\", function() {\n restoreTerminal();\n process.exit(0);\n });\n process.on(\"SIGTERM\", function() {\n restoreTerminal();\n process.exit(0);\n });\n}\nvar pressedKeys = \"\";\nvar clearPressedKeysTimer = null;\nfunction clearPressedKeys() {\n pressedKeys = \"\";\n clearPrintedInfo();\n}\nfunction resetClearPressedKeysTimer() {\n if (clearPressedKeysTimer) {\n clearTimeout(clearPressedKeysTimer);\n }\n clearPressedKeysTimer = setTimeout(clearPressedKeys, 3e3);\n clearPressedKeysTimer.unref();\n}\nfunction handleKeypress(context, key) {\n if (key === \"\\x1B\") {\n clearPrintedInfo();\n pressedKeys = \"\";\n return;\n }\n if (key === \"?\" || key === \"/\") {\n clearPrintedInfo();\n console.info(\"> ?\\n\\u21D2 Available commands:\");\n printCommandsTable(context);\n return;\n }\n resetClearPressedKeysTimer();\n if (key === \"\\x7F\") {\n pressedKeys = pressedKeys.slice(0, -1);\n } else {\n key = key.toLowerCase();\n if (/^[a-z]$/.test(key)) {\n pressedKeys += key;\n }\n }\n if (pressedKeys.length === 0) {\n clearPrintedInfo();\n return;\n }\n var matchedCommand = COMMANDS.find(function(command) {\n return command.keys === pressedKeys;\n });\n if (matchedCommand) {\n clearPrintedInfo();\n console.info(`> ${matchedCommand.keys}\n\\u21D2 ${matchedCommand.label}...`);\n pressedKeys = \"\";\n setTimeout(function() {\n var _matchedCommand_action;\n return (_matchedCommand_action = matchedCommand.action) === null || _matchedCommand_action === void 0 ? void 0 : _matchedCommand_action.call(matchedCommand, context);\n }, 500);\n return;\n }\n if (pressedKeys.length >= 3) {\n clearPrintedInfo();\n console.info(`> ${pressedKeys}\nNo matching command for \"${pressedKeys}\"! Press \"?\" for help.`);\n pressedKeys = \"\";\n return;\n }\n var possibleCommands = COMMANDS.filter(function(command) {\n return command.keys.startsWith(pressedKeys);\n });\n var commandsInfo = possibleCommands.map(function(command) {\n var matchedPart = command.keys.slice(0, pressedKeys.length);\n var remainingPart = command.keys.slice(pressedKeys.length);\n return ` \\x1B[4m${matchedPart}\\x1B[0m\\x1B[1m${remainingPart}\\x1B[0m\\x1B[90m - \\x1B[0m${command.terminalLabel}`;\n }).join(\"\\n\");\n var infoToPrint = `\n${commandsInfo}\n> ${pressedKeys}`;\n printInfo(infoToPrint);\n}\nvar lastPrintedInfo = \"\";\nfunction printInfo(info) {\n clearPrintedInfo();\n lastPrintedInfo = info;\n process.stdout.write(info);\n}\nfunction clearPrintedInfo() {\n if (lastPrintedInfo) {\n process.stdout.write(\"\\x1B[2K\");\n process.stdout.write(\"\\x1B[1A\\x1B[2K\".repeat(lastPrintedInfo.split(\"\\n\").length - 1));\n process.stdout.write(\"\\x1B[2K\");\n process.stdout.write(\"\\x1B[G\");\n }\n lastPrintedInfo = \"\";\n}\nfunction nativeOpen(url) {\n var start = process.platform === \"darwin\" ? \"open\" : process.platform === \"win32\" ? \"start\" : \"xdg-open\";\n exec(`${start} ${url}`);\n}\nasync function openIos(ctx) {\n var projectRoot = ctx.server.config.root;\n var port = getBoundPort(ctx.server);\n try {\n await nativeRun({\n root: projectRoot,\n platform: \"ios\",\n port\n });\n } catch (e) {\n var stack = e instanceof Error ? e.stack : null;\n console.error(`Failed to open app in iOS Simulator: ${e}${stack ? `\n${stack}` : \"\"}`);\n }\n}\nasync function openAndroid(ctx) {\n var projectRoot = ctx.server.config.root;\n var port = getBoundPort(ctx.server);\n try {\n await nativeRun({\n root: projectRoot,\n platform: \"android\",\n port\n });\n } catch (e) {\n var stack = e instanceof Error ? e.stack : null;\n console.error(`Failed to open app in Android Emulator: ${e}${stack ? `\n${stack}` : \"\"}`);\n }\n}\nexport {\n startUserInterface\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;AAGA,IAAI,WAAW;CACb;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,QAAQ,SAAS,OAAO,KAAK;GAC3B,IAAI;GACJ,IAAI,OAAO,2BAA2B,IAAI,OAAO,kBAAkB,QAAQ,6BAA6B,KAAK,IAAI,KAAK,IAAI,yBAAyB,MAAM;GACzJ,IAAI,CAAC,KAAK;IACR,QAAQ,KAAK,kCAAkC;IAC/C;GACF;GACA,WAAW,GAAG;EAChB;CACF;CACA;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,QAAQ,SAAS,QAAQ,KAAK;GAC5B,QAAQ,GAAG;EACb;CACF;CACA;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,QAAQ,SAAS,QAAQ,KAAK;GAC5B,YAAY,GAAG;EACjB;CACF;CACA;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,QAAQ,eAAe,QAAQ,KAAK;GAClC,IAAI,EAAE,kBAAkB,MAAM,OAAO;GACrC,KAAK,GAAG,cAAc,CAAC,CAAC,OAAO,GAAG;EACpC;CACF;CAEA;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,QAAQ;CACV;CACA;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,QAAQ;CACV;CACA;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,QAAQ,eAAe,QAAQ,KAAK,CACpC;CACF;AACF;AACA,SAAS,wBAAwB,KAAK;CACpC,IAAI,EAAE,SAAS,IAAI,OAAO,OAAO;CACjC,IAAI,YAAY,UAAU,OAAO,SAAS,YAAY,CAAC,CAAC,OAAO,OAAO,YAAY,GAAG,aAAa,IAAI,MAAM;CAC5G,IAAI,MAAM,IAAI,IAAI,kBAAkB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kB;AACpB;AACA,SAAS,WAAW,KAAK;CACvB,IAAI,QAAQ,QAAQ,aAAa,WAAW,SAAS,QAAQ,aAAa,UAAU,UAAU;CAC9F,KAAK,GAAG,MAAM,GAAG,KAAK;AACxB;AACA,eAAe,QAAQ,KAAK;CAC1B,IAAI,cAAc,IAAI,OAAO,OAAO;CACpC,IAAI,OAAO,aAAa,IAAI,MAAM;CAClC,IAAI;EACF,MAAM,UAAU;GACd,MAAM;GACN,UAAU;GACV;EACF,CAAC;CACH,SAAS,GAAG;EACV,IAAI,QAAQ,aAAa,QAAQ,EAAE,QAAQ;EAC3C,QAAQ,MAAM,wCAAwC,IAAI,QAAQ;EACpE,UAAU,IAAI;CACd;AACF;AACA,eAAe,YAAY,KAAK;CAC9B,IAAI,cAAc,IAAI,OAAO,OAAO;CACpC,IAAI,OAAO,aAAa,IAAI,MAAM;CAClC,IAAI;EACF,MAAM,UAAU;GACd,MAAM;GACN,UAAU;GACV;EACF,CAAC;CACH,SAAS,GAAG;EACV,IAAI,QAAQ,aAAa,QAAQ,EAAE,QAAQ;EAC3C,QAAQ,MAAM,2CAA2C,IAAI,QAAQ;EACvE,UAAU,IAAI;CACd;AACF"}
1
+ {"version":3,"file":"index.native.js","names":[],"sources":["user-interface/index.native.js"],"sourcesContent":["import { defaultEditor } from \"../utils/env-editor\";\nimport { exec } from \"child_process\";\nimport { getBoundPort } from \"../utils/getBoundPort\";\nimport { nativeRun } from \"../utils/nativeRun\";\nvar COMMANDS = [\n {\n keys: \"ow\",\n label: \"open web\",\n terminalLabel: \"\\x1B[1mo\\x1B[0mpen \\x1B[1mw\\x1B[0meb\",\n action: function action(ctx) {\n var _ctx_server_resolvedUrls;\n var url = (_ctx_server_resolvedUrls = ctx.server.resolvedUrls) === null || _ctx_server_resolvedUrls === void 0 ? void 0 : _ctx_server_resolvedUrls.local[0];\n if (!url) {\n console.warn(\"Cannot get the local server URL.\");\n return;\n }\n nativeOpen(url);\n }\n },\n {\n keys: \"oi\",\n label: \"open app in iOS Simulator\",\n terminalLabel: \"\\x1B[1mo\\x1B[0mpen app in \\x1B[1mi\\x1B[0mOS Simulator\",\n action: function action2(ctx) {\n openIos(ctx);\n }\n },\n {\n keys: \"oa\",\n label: \"open app in Android Emulator\",\n terminalLabel: \"\\x1B[1mo\\x1B[0mpen app in \\x1B[1mA\\x1B[0mndroid Emulator\",\n action: function action3(ctx) {\n openAndroid(ctx);\n }\n },\n {\n keys: \"oe\",\n label: \"open editor\",\n terminalLabel: \"\\x1B[1mo\\x1B[0mpen \\x1B[1me\\x1B[0mditor\",\n action: async function action4(ctx) {\n exec(`${defaultEditor().binary} .`);\n }\n },\n // TODO this would need to be per-platform\n {\n keys: \"dt\",\n label: \"open React Native DevTools\",\n terminalLabel: \"open React Native \\x1B[1mD\\x1B[0mev\\x1B[1mT\\x1B[0mools\",\n action: openReactNativeDevTools\n },\n {\n keys: \"j\",\n label: \"open React Native DevTools\",\n terminalLabel: \"open React Native DevTools\",\n action: openReactNativeDevTools\n },\n {\n keys: \"?\",\n label: \"show commands\",\n terminalLabel: \"show this menu\",\n action: async function action5(ctx) {\n }\n }\n];\nfunction openReactNativeDevTools(ctx) {\n var { host } = ctx.server.config.server;\n var serverUrl = `http://${typeof host === \"string\" && !!host ? host : \"localhost\"}:${getBoundPort(ctx.server)}`;\n var url = new URL(\"/open-debugger\", serverUrl);\n (async function() {\n var response = await fetch(url, {\n method: \"POST\",\n signal: AbortSignal.timeout(3e3)\n }).catch(function(error) {\n if (error.name === \"TimeoutError\") {\n return null;\n }\n throw error;\n });\n if (!response) {\n } else if (response.ok === false) {\n var responseText = await response.text();\n if (responseText.includes(\"Unable to find debugger target\")) {\n return;\n }\n console.warn(`Failed to open React Native DevTools, ${url} returns ${response.status}: ${responseText}.`);\n }\n })();\n}\nasync function startUserInterface(context) {\n if (!supportsKeyboardCommands()) {\n return;\n }\n printCommandsTable(context);\n startInterceptingKeyStrokes(context);\n}\nfunction printCommandsTable(context) {\n var longestKeyLength = COMMANDS.reduce(function(max, command) {\n return Math.max(max, command.keys.length);\n }, 0);\n var commandsInfo = COMMANDS.map(function(cmd) {\n return getCommandInfoInTerminal(cmd, {\n longestKeyLength\n });\n }).join(\"\\n\");\n console.info(`\n${commandsInfo}\n`);\n}\nfunction getCommandInfoInTerminal(command) {\n var { longestKeyLength = 0 } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};\n return `\\x1B[90m\\u203A\\x1B[0m Press \\x1B[1m${longestKeyLength ? command.keys.padEnd(longestKeyLength, \" \") : command.keys}\\x1B[0m \\x1B[90m\\u2502\\x1B[0m ${command.terminalLabel}`;\n}\nfunction restoreTerminal() {\n var { stdin } = process;\n if (stdin.isTTY && stdin.setRawMode) {\n try {\n stdin.setRawMode(false);\n } catch (unused) {\n }\n }\n process.stdout.write(\"\\x1B[0m\");\n}\nfunction supportsKeyboardCommands() {\n var { stdin } = process;\n return Boolean(stdin.isTTY && stdin.setRawMode);\n}\nfunction startInterceptingKeyStrokes(context) {\n var { stdin } = process;\n if (!supportsKeyboardCommands()) {\n return;\n }\n stdin.setRawMode(true);\n stdin.resume();\n stdin.setEncoding(\"utf8\");\n stdin.on(\"data\", handleKeypress.bind(null, context));\n stdin.unref();\n process.on(\"exit\", restoreTerminal);\n process.on(\"SIGINT\", function() {\n restoreTerminal();\n process.exit(0);\n });\n process.on(\"SIGTERM\", function() {\n restoreTerminal();\n process.exit(0);\n });\n}\nvar pressedKeys = \"\";\nvar clearPressedKeysTimer = null;\nfunction clearPressedKeys() {\n pressedKeys = \"\";\n clearPrintedInfo();\n}\nfunction resetClearPressedKeysTimer() {\n if (clearPressedKeysTimer) {\n clearTimeout(clearPressedKeysTimer);\n }\n clearPressedKeysTimer = setTimeout(clearPressedKeys, 3e3);\n clearPressedKeysTimer.unref();\n}\nfunction handleKeypress(context, key) {\n if (key === \"\\x1B\") {\n clearPrintedInfo();\n pressedKeys = \"\";\n return;\n }\n if (key === \"?\" || key === \"/\") {\n clearPrintedInfo();\n console.info(\"> ?\\n\\u21D2 Available commands:\");\n printCommandsTable(context);\n return;\n }\n resetClearPressedKeysTimer();\n if (key === \"\\x7F\") {\n pressedKeys = pressedKeys.slice(0, -1);\n } else {\n key = key.toLowerCase();\n if (/^[a-z]$/.test(key)) {\n pressedKeys += key;\n }\n }\n if (pressedKeys.length === 0) {\n clearPrintedInfo();\n return;\n }\n var matchedCommand = COMMANDS.find(function(command) {\n return command.keys === pressedKeys;\n });\n if (matchedCommand) {\n clearPrintedInfo();\n console.info(`> ${matchedCommand.keys}\n\\u21D2 ${matchedCommand.label}...`);\n pressedKeys = \"\";\n setTimeout(function() {\n var _matchedCommand_action;\n return (_matchedCommand_action = matchedCommand.action) === null || _matchedCommand_action === void 0 ? void 0 : _matchedCommand_action.call(matchedCommand, context);\n }, 500);\n return;\n }\n if (pressedKeys.length >= 3) {\n clearPrintedInfo();\n console.info(`> ${pressedKeys}\nNo matching command for \"${pressedKeys}\"! Press \"?\" for help.`);\n pressedKeys = \"\";\n return;\n }\n var possibleCommands = COMMANDS.filter(function(command) {\n return command.keys.startsWith(pressedKeys);\n });\n var commandsInfo = possibleCommands.map(function(command) {\n var matchedPart = command.keys.slice(0, pressedKeys.length);\n var remainingPart = command.keys.slice(pressedKeys.length);\n return ` \\x1B[4m${matchedPart}\\x1B[0m\\x1B[1m${remainingPart}\\x1B[0m\\x1B[90m - \\x1B[0m${command.terminalLabel}`;\n }).join(\"\\n\");\n var infoToPrint = `\n${commandsInfo}\n> ${pressedKeys}`;\n printInfo(infoToPrint);\n}\nvar lastPrintedInfo = \"\";\nfunction printInfo(info) {\n clearPrintedInfo();\n lastPrintedInfo = info;\n process.stdout.write(info);\n}\nfunction clearPrintedInfo() {\n if (lastPrintedInfo) {\n process.stdout.write(\"\\x1B[2K\");\n process.stdout.write(\"\\x1B[1A\\x1B[2K\".repeat(lastPrintedInfo.split(\"\\n\").length - 1));\n process.stdout.write(\"\\x1B[2K\");\n process.stdout.write(\"\\x1B[G\");\n }\n lastPrintedInfo = \"\";\n}\nfunction nativeOpen(url) {\n var start = process.platform === \"darwin\" ? \"open\" : process.platform === \"win32\" ? \"start\" : \"xdg-open\";\n exec(`${start} ${url}`);\n}\nasync function openIos(ctx) {\n var projectRoot = ctx.server.config.root;\n var port = getBoundPort(ctx.server);\n try {\n await nativeRun({\n root: projectRoot,\n platform: \"ios\",\n port\n });\n } catch (e) {\n var stack = e instanceof Error ? e.stack : null;\n console.error(`Failed to open app in iOS Simulator: ${e}${stack ? `\n${stack}` : \"\"}`);\n }\n}\nasync function openAndroid(ctx) {\n var projectRoot = ctx.server.config.root;\n var port = getBoundPort(ctx.server);\n try {\n await nativeRun({\n root: projectRoot,\n platform: \"android\",\n port\n });\n } catch (e) {\n var stack = e instanceof Error ? e.stack : null;\n console.error(`Failed to open app in Android Emulator: ${e}${stack ? `\n${stack}` : \"\"}`);\n }\n}\nexport {\n startUserInterface\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;;AAIA,IAAI,WAAW;CACb;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,QAAQ,SAAS,OAAO,KAAK;GAC3B,IAAI;GACJ,IAAI,OAAO,2BAA2B,IAAI,OAAO,kBAAkB,QAAQ,6BAA6B,KAAK,IAAI,KAAK,IAAI,yBAAyB,MAAM;GACzJ,IAAI,CAAC,KAAK;IACR,QAAQ,KAAK,kCAAkC;IAC/C;GACF;GACA,WAAW,GAAG;EAChB;CACF;CACA;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,QAAQ,SAAS,QAAQ,KAAK;GAC5B,QAAQ,GAAG;EACb;CACF;CACA;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,QAAQ,SAAS,QAAQ,KAAK;GAC5B,YAAY,GAAG;EACjB;CACF;CACA;EACE,MAAM;EACN,OAAO;EACP,eAAe;EACf,QAAQ,eAAe,QAAQ,KAAK;GAClC,KAAK,GAAG,cAAc,CAAC,CAAC,OAAO,GAAG;EACpC;CACF;CAEA;EACE,MAAM;EAC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