vxrn 1.12.8 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/getAdditionalViteConfig.mjs +1 -4
- package/dist/config/getAdditionalViteConfig.mjs.map +1 -1
- package/dist/config/getAdditionalViteConfig.native.js +1 -4
- package/dist/config/getAdditionalViteConfig.native.js.map +1 -1
- package/dist/config/getReactNativePlugins.mjs +1 -5
- package/dist/config/getReactNativePlugins.mjs.map +1 -1
- package/dist/config/getReactNativePlugins.native.js +1 -5
- package/dist/config/getReactNativePlugins.native.js.map +1 -1
- package/dist/exports/build.mjs +5 -0
- package/dist/exports/build.mjs.map +1 -1
- package/dist/exports/build.native.js +5 -0
- package/dist/exports/build.native.js.map +1 -1
- package/dist/exports/createServer.mjs +30 -25
- package/dist/exports/createServer.mjs.map +1 -1
- package/dist/exports/createServer.native.js +6 -3
- package/dist/exports/createServer.native.js.map +1 -1
- package/dist/exports/prebuild.mjs +25 -1
- package/dist/exports/prebuild.mjs.map +1 -1
- package/dist/exports/prebuild.native.js +30 -1
- package/dist/exports/prebuild.native.js.map +1 -1
- package/dist/exports/serve.mjs +2 -2
- package/dist/exports/serve.mjs.map +1 -1
- package/dist/exports/serve.native.js +2 -2
- package/dist/exports/serve.native.js.map +1 -1
- package/dist/exports/serveStaticAssets.mjs +43 -11
- package/dist/exports/serveStaticAssets.mjs.map +1 -1
- package/dist/exports/serveStaticAssets.native.js +69 -6
- package/dist/exports/serveStaticAssets.native.js.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -2
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +1 -2
- package/dist/index.native.js.map +1 -1
- package/dist/patches/builtInDepPatches.mjs +14 -0
- package/dist/patches/builtInDepPatches.mjs.map +1 -1
- package/dist/patches/builtInDepPatches.native.js +14 -0
- package/dist/patches/builtInDepPatches.native.js.map +1 -1
- package/dist/plugins/clientInjectPlugin.mjs +2 -62
- package/dist/plugins/clientInjectPlugin.mjs.map +1 -1
- package/dist/plugins/clientInjectPlugin.native.js +2 -75
- package/dist/plugins/clientInjectPlugin.native.js.map +1 -1
- package/dist/plugins/reactNativeDevAssetPlugin.mjs +1 -3
- package/dist/plugins/reactNativeDevAssetPlugin.mjs.map +1 -1
- package/dist/plugins/reactNativeDevAssetPlugin.native.js +1 -3
- package/dist/plugins/reactNativeDevAssetPlugin.native.js.map +1 -1
- package/dist/plugins/reactNativeDevServer.mjs +55 -77
- package/dist/plugins/reactNativeDevServer.mjs.map +1 -1
- package/dist/plugins/reactNativeDevServer.native.js +73 -84
- package/dist/plugins/reactNativeDevServer.native.js.map +1 -1
- package/dist/plugins/serverExtensions.test.mjs +12 -6
- package/dist/plugins/serverExtensions.test.mjs.map +1 -1
- package/dist/plugins/serverExtensions.test.native.js +12 -6
- package/dist/plugins/serverExtensions.test.native.js.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.mjs +11 -35
- package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.native.js +9 -36
- package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
- package/dist/runtime/hmr-client.mjs +125 -0
- package/dist/runtime/hmr-client.mjs.map +1 -0
- package/dist/runtime/hmr-client.native.js +197 -0
- package/dist/runtime/hmr-client.native.js.map +1 -0
- package/dist/runtime/hmr-runtime.mjs +162 -0
- package/dist/runtime/hmr-runtime.mjs.map +1 -0
- package/dist/runtime/hmr-runtime.native.js +348 -0
- package/dist/runtime/hmr-runtime.native.js.map +1 -0
- package/dist/runtime/hmr-types.mjs +2 -0
- package/dist/runtime/hmr-types.mjs.map +1 -0
- package/dist/runtime/hmr-types.native.js +2 -0
- package/dist/runtime/hmr-types.native.js.map +1 -0
- package/dist/runtime/native-prelude.mjs +97 -0
- package/dist/runtime/native-prelude.mjs.map +1 -0
- package/dist/runtime/native-prelude.native.js +97 -0
- package/dist/runtime/native-prelude.native.js.map +1 -0
- package/dist/runtime/react-refresh-utils.mjs +19 -0
- package/dist/runtime/react-refresh-utils.mjs.map +1 -0
- package/dist/runtime/react-refresh-utils.native.js +24 -0
- package/dist/runtime/react-refresh-utils.native.js.map +1 -0
- package/dist/utils/createNativeDevEngine.mjs +661 -0
- package/dist/utils/createNativeDevEngine.mjs.map +1 -0
- package/dist/utils/createNativeDevEngine.native.js +702 -0
- package/dist/utils/createNativeDevEngine.native.js.map +1 -0
- package/dist/utils/patches.mjs +6 -2
- package/dist/utils/patches.mjs.map +1 -1
- package/dist/utils/patches.native.js +6 -2
- package/dist/utils/patches.native.js.map +1 -1
- package/dist/utils/scanDepsToOptimize.mjs +4 -3
- package/dist/utils/scanDepsToOptimize.mjs.map +1 -1
- package/dist/utils/scanDepsToOptimize.native.js +4 -3
- package/dist/utils/scanDepsToOptimize.native.js.map +1 -1
- package/expo-plugin.cjs +122 -0
- package/package.json +15 -19
- package/src/config/getAdditionalViteConfig.ts +1 -3
- package/src/config/getReactNativePlugins.ts +0 -6
- package/src/exports/build.ts +5 -0
- package/src/exports/createServer.ts +7 -2
- package/src/exports/prebuild.ts +45 -0
- package/src/exports/serve.ts +2 -1
- package/src/exports/serveStaticAssets.ts +67 -4
- package/src/index.ts +0 -2
- package/src/patches/builtInDepPatches.ts +29 -0
- package/src/plugins/clientInjectPlugin.ts +2 -109
- package/src/plugins/reactNativeDevAssetPlugin.ts +0 -21
- package/src/plugins/reactNativeDevServer.ts +57 -84
- package/src/plugins/serverExtensions.test.ts +6 -8
- package/src/rn-commands/bundle/buildBundle.ts +9 -62
- package/src/runtime/hmr-client.ts +215 -0
- package/src/runtime/hmr-runtime.ts +276 -0
- package/src/runtime/hmr-types.ts +84 -0
- package/src/runtime/native-prelude.ts +110 -0
- package/src/runtime/react-refresh-utils.ts +36 -0
- package/src/types.ts +22 -4
- package/src/utils/createNativeDevEngine.ts +942 -0
- package/src/utils/patches.ts +36 -18
- package/src/utils/scanDepsToOptimize.ts +2 -3
- package/types/config/getAdditionalViteConfig.d.ts.map +1 -1
- package/types/config/getOptionsFilled.d.ts +2 -18
- package/types/config/getOptionsFilled.d.ts.map +1 -1
- package/types/config/getReactNativePlugins.d.ts.map +1 -1
- package/types/exports/build.d.ts +1 -9
- package/types/exports/build.d.ts.map +1 -1
- package/types/exports/createServer.d.ts.map +1 -1
- package/types/exports/prebuild.d.ts.map +1 -1
- package/types/exports/serve.d.ts +2 -1
- package/types/exports/serve.d.ts.map +1 -1
- package/types/exports/serveStaticAssets.d.ts +12 -1
- package/types/exports/serveStaticAssets.d.ts.map +1 -1
- package/types/index.d.ts +0 -1
- package/types/index.d.ts.map +1 -1
- package/types/patches/builtInDepPatches.d.ts.map +1 -1
- package/types/plugins/clientInjectPlugin.d.ts +1 -7
- package/types/plugins/clientInjectPlugin.d.ts.map +1 -1
- package/types/plugins/reactNativeDevAssetPlugin.d.ts.map +1 -1
- package/types/plugins/reactNativeDevServer.d.ts.map +1 -1
- package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
- package/types/runtime/hmr-client.d.ts +40 -0
- package/types/runtime/hmr-client.d.ts.map +1 -0
- package/types/runtime/hmr-runtime.d.ts +69 -0
- package/types/runtime/hmr-runtime.d.ts.map +1 -0
- package/types/runtime/hmr-types.d.ts +76 -0
- package/types/runtime/hmr-types.d.ts.map +1 -0
- package/types/runtime/native-prelude.d.ts +11 -0
- package/types/runtime/native-prelude.d.ts.map +1 -0
- package/types/runtime/react-refresh-utils.d.ts +3 -0
- package/types/runtime/react-refresh-utils.d.ts.map +1 -0
- package/types/types.d.ts +15 -1
- package/types/types.d.ts.map +1 -1
- package/types/utils/createNativeDevEngine.d.ts +42 -0
- package/types/utils/createNativeDevEngine.d.ts.map +1 -0
- package/types/utils/patches.d.ts.map +1 -1
- package/types/utils/scanDepsToOptimize.d.ts.map +1 -1
- package/dist/config/getReactNativeBuildConfig.mjs +0 -200
- package/dist/config/getReactNativeBuildConfig.mjs.map +0 -1
- package/dist/config/getReactNativeBuildConfig.native.js +0 -204
- package/dist/config/getReactNativeBuildConfig.native.js.map +0 -1
- package/dist/plugins/reactNativeHMRPlugin.mjs +0 -120
- package/dist/plugins/reactNativeHMRPlugin.mjs.map +0 -1
- package/dist/plugins/reactNativeHMRPlugin.native.js +0 -151
- package/dist/plugins/reactNativeHMRPlugin.native.js.map +0 -1
- package/dist/utils/filterPluginsForNative.mjs +0 -27
- package/dist/utils/filterPluginsForNative.mjs.map +0 -1
- package/dist/utils/filterPluginsForNative.native.js +0 -33
- package/dist/utils/filterPluginsForNative.native.js.map +0 -1
- package/dist/utils/getReactNativeBundle.mjs +0 -104
- package/dist/utils/getReactNativeBundle.mjs.map +0 -1
- package/dist/utils/getReactNativeBundle.native.js +0 -135
- package/dist/utils/getReactNativeBundle.native.js.map +0 -1
- package/dist/utils/hotUpdateCache.mjs +0 -3
- package/dist/utils/hotUpdateCache.mjs.map +0 -1
- package/dist/utils/hotUpdateCache.native.js +0 -3
- package/dist/utils/hotUpdateCache.native.js.map +0 -1
- package/dist/utils/isBuildingNativeBundle.mjs +0 -6
- package/dist/utils/isBuildingNativeBundle.mjs.map +0 -1
- package/dist/utils/isBuildingNativeBundle.native.js +0 -7
- package/dist/utils/isBuildingNativeBundle.native.js.map +0 -1
- package/dist/utils/swapPrebuiltReactModules.mjs +0 -168
- package/dist/utils/swapPrebuiltReactModules.mjs.map +0 -1
- package/dist/utils/swapPrebuiltReactModules.native.js +0 -181
- package/dist/utils/swapPrebuiltReactModules.native.js.map +0 -1
- package/dist/worker.mjs +0 -55
- package/dist/worker.mjs.map +0 -1
- package/dist/worker.native.js +0 -55
- package/dist/worker.native.js.map +0 -1
- package/react-native-template.js +0 -375
- package/src/config/getReactNativeBuildConfig.ts +0 -349
- package/src/plugins/reactNativeHMRPlugin.ts +0 -237
- package/src/utils/filterPluginsForNative.ts +0 -55
- package/src/utils/getReactNativeBundle.ts +0 -243
- package/src/utils/hotUpdateCache.ts +0 -1
- package/src/utils/isBuildingNativeBundle.ts +0 -7
- package/src/utils/swapPrebuiltReactModules.ts +0 -341
- package/src/worker.ts +0 -90
- package/types/config/getReactNativeBuildConfig.d.ts +0 -72
- package/types/config/getReactNativeBuildConfig.d.ts.map +0 -1
- package/types/plugins/reactNativeHMRPlugin.d.ts +0 -10
- package/types/plugins/reactNativeHMRPlugin.d.ts.map +0 -1
- package/types/utils/filterPluginsForNative.d.ts +0 -8
- package/types/utils/filterPluginsForNative.d.ts.map +0 -1
- package/types/utils/getReactNativeBundle.d.ts +0 -12
- package/types/utils/getReactNativeBundle.d.ts.map +0 -1
- package/types/utils/hotUpdateCache.d.ts +0 -2
- package/types/utils/hotUpdateCache.d.ts.map +0 -1
- package/types/utils/isBuildingNativeBundle.d.ts +0 -3
- package/types/utils/isBuildingNativeBundle.d.ts.map +0 -1
- package/types/utils/swapPrebuiltReactModules.d.ts +0 -9
- package/types/utils/swapPrebuiltReactModules.d.ts.map +0 -1
- package/types/worker.d.ts +0 -13
- package/types/worker.d.ts.map +0 -1
package/react-native-template.js
DELETED
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
const global =
|
|
2
|
-
typeof globalThis !== 'undefined'
|
|
3
|
-
? globalThis
|
|
4
|
-
: typeof global !== 'undefined'
|
|
5
|
-
? global
|
|
6
|
-
: typeof window !== 'undefined'
|
|
7
|
-
? window
|
|
8
|
-
: this
|
|
9
|
-
|
|
10
|
-
globalThis['global'] = global
|
|
11
|
-
global['react'] = {}
|
|
12
|
-
global['exports'] = {}
|
|
13
|
-
global['module'] = {}
|
|
14
|
-
global['__DEV__'] = process.env.__DEV__
|
|
15
|
-
global['___modules___'] = {}
|
|
16
|
-
global['___vxrnAbsoluteToRelative___'] = {}
|
|
17
|
-
|
|
18
|
-
// Prevents the `HMRClient.unstable_notifyFuseboxConsoleEnabled is not a function (it is undefined)` error
|
|
19
|
-
global.__FUSEBOX_HAS_FULL_CONSOLE_SUPPORT__ = false
|
|
20
|
-
|
|
21
|
-
global['Event'] =
|
|
22
|
-
global['Event'] ||
|
|
23
|
-
function () {
|
|
24
|
-
return this
|
|
25
|
-
}
|
|
26
|
-
global['dispatchEvent'] = global['dispatchEvent'] || (() => {})
|
|
27
|
-
|
|
28
|
-
globalThis['__cachedModules'] = {
|
|
29
|
-
// potentially, but need to verify other things first:
|
|
30
|
-
// // framer-motion fix
|
|
31
|
-
// '@emotion/is-prop-valid': {
|
|
32
|
-
// default: {},
|
|
33
|
-
// },
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
globalThis['__RN_INTERNAL_MODULE_REQUIRES_MAP__'] = {}
|
|
37
|
-
|
|
38
|
-
if (typeof process === 'undefined') {
|
|
39
|
-
globalThis['process'] = {
|
|
40
|
-
env: {},
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
process.env.EXPO_OS = __VXRN_PLATFORM__
|
|
45
|
-
|
|
46
|
-
function printError(err) {
|
|
47
|
-
return `${err instanceof Error ? `${err.message}\n${err.stack}` : err}`
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const __runningModules = new Map()
|
|
51
|
-
|
|
52
|
-
const getRunningModulesPrint = () => [...__runningModules.keys()].join(' > ')
|
|
53
|
-
|
|
54
|
-
function __getRequire(absPath, parent) {
|
|
55
|
-
absPath = ___vxrnAbsoluteToRelative___[absPath] || absPath
|
|
56
|
-
|
|
57
|
-
// START WORKAROUND
|
|
58
|
-
// Since during HMR, `getVitePath` is used and it'll always return with `.js` extension while turning relative paths to absolute paths (see: https://github.com/onejs/one/blob/v1.1.432/packages/vxrn/src/utils/getVitePath.ts#L33),
|
|
59
|
-
// we need to check for other extensions as well.
|
|
60
|
-
if (absPath.endsWith('.js')) {
|
|
61
|
-
for (const ext of ['.jsx', '.ts', '.tsx']) {
|
|
62
|
-
for (const platformExt of ['', `.${__VXRN_PLATFORM__.toLowerCase()}`, `.native`]) {
|
|
63
|
-
const possibleAbsPath = absPath.replace(/\.js$/, `${platformExt}${ext}`)
|
|
64
|
-
if (___vxrnAbsoluteToRelative___[possibleAbsPath]) {
|
|
65
|
-
absPath = ___vxrnAbsoluteToRelative___[possibleAbsPath]
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
// END WORKAROUND
|
|
71
|
-
|
|
72
|
-
if (!__cachedModules[absPath]) {
|
|
73
|
-
const runModule = ___modules___[absPath]
|
|
74
|
-
|
|
75
|
-
// do not run again if the module is already running, avoids stack overflow on circular dependencies
|
|
76
|
-
if (__runningModules.has(absPath)) {
|
|
77
|
-
console.info('‼️ circular dependency:', absPath, 'imported from', parent, ':')
|
|
78
|
-
console.info(' running modules:', getRunningModulesPrint())
|
|
79
|
-
// TODO we can probably print a circular dependency warning for this
|
|
80
|
-
return __runningModules.get(absPath).exports
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (runModule) {
|
|
84
|
-
const mod = { exports: {} }
|
|
85
|
-
__runningModules.set(absPath, mod)
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
runModule(mod.exports, mod)
|
|
89
|
-
} catch (err) {
|
|
90
|
-
throw new Error(
|
|
91
|
-
`Error running module (parent: ${parent}): "${absPath}"\n${printError(err)}`
|
|
92
|
-
)
|
|
93
|
-
} finally {
|
|
94
|
-
__runningModules.delete(absPath)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
__cachedModules[absPath] = mod.exports || mod
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return __cachedModules[absPath]
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const __specialRequireMap = globalThis.__vxrnPrebuildSpecialRequireMap || {
|
|
105
|
-
'react-native': `.vxrn/react-native.${__VXRN_PLATFORM__.toLowerCase()}.js`,
|
|
106
|
-
react: '.vxrn/react.js',
|
|
107
|
-
'react/jsx-runtime': '.vxrn/react-jsx-runtime.js',
|
|
108
|
-
'react/jsx-dev-runtime': '.vxrn/react-jsx-runtime.js',
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// WORKAROUND: react-native-reanimated may be dynamically imported by react-native-gesture-handler, which the import path will not be transformed. Doing this so `require('react-native-reanimated')` can work.
|
|
112
|
-
// See: https://github.com/software-mansion/react-native-gesture-handler/blob/2.23.0/src/handlers/gestures/reanimatedWrapper.ts#L33
|
|
113
|
-
__specialRequireMap['react-native-reanimated'] = 'react-native-reanimated/src/index.js'
|
|
114
|
-
|
|
115
|
-
const nodeImports = {
|
|
116
|
-
fs: true,
|
|
117
|
-
path: true,
|
|
118
|
-
os: true,
|
|
119
|
-
child_process: true,
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function createRequire(importer, importsMap) {
|
|
123
|
-
if (!importsMap) {
|
|
124
|
-
console.error(`No imports map given from ${importer}\n${new Error().stack}`)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return function require(_mod) {
|
|
128
|
-
const output = getRequire(importer, importsMap, _mod)
|
|
129
|
-
|
|
130
|
-
// this adds a hacky compat with new Rollup commonjs transform
|
|
131
|
-
// going from vite 6.0.0-beta.1 to beta.5 needed this
|
|
132
|
-
if (output && typeof output === 'object' && !('__require' in output)) {
|
|
133
|
-
return new Proxy(output, {
|
|
134
|
-
get(target, key) {
|
|
135
|
-
// if (!Reflect.has(target, key)) {
|
|
136
|
-
if (key === '__require') {
|
|
137
|
-
return () => output
|
|
138
|
-
}
|
|
139
|
-
// }
|
|
140
|
-
|
|
141
|
-
return Reflect.get(target, key)
|
|
142
|
-
},
|
|
143
|
-
})
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return output
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function getRequire(importer, importsMap, _mod) {
|
|
151
|
-
if (_mod.endsWith('.css')) {
|
|
152
|
-
console.info(`Ignoring css import: ${_mod}`)
|
|
153
|
-
return {}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const getErrorDetails = (withStack) => {
|
|
157
|
-
return `Running modules: ${getRunningModulesPrint()}
|
|
158
|
-
|
|
159
|
-
In importsMap: ${JSON.stringify(importsMap, null, 2)}
|
|
160
|
-
|
|
161
|
-
${
|
|
162
|
-
/* process.env.DEBUG?.startsWith('tamagui') ? debugExtraDetail : '' // Will break Android: property 'process' doesn't exist */ ''
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
${
|
|
166
|
-
withStack
|
|
167
|
-
? `Stack:
|
|
168
|
-
|
|
169
|
-
${new Error().stack
|
|
170
|
-
.split('\n')
|
|
171
|
-
.map((l) => ` ${l}`)
|
|
172
|
-
.join('\n')}`
|
|
173
|
-
: ''
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
--------------`
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
try {
|
|
180
|
-
if (_mod === 'one' || _mod === 'one' || _mod.endsWith('one/dist/esm/index.mjs')) {
|
|
181
|
-
// TODO this should be passed in not hardcoded
|
|
182
|
-
const found =
|
|
183
|
-
__getRequire('packages/one/dist/esm/index.js', _mod) ||
|
|
184
|
-
// this is only for developing links module in ~/vxrn, can remove later
|
|
185
|
-
__getRequire('vxrn/packages/one/dist/esm/index.js', _mod) ||
|
|
186
|
-
__getRequire('one/dist/esm/index.native.js') ||
|
|
187
|
-
__getRequire('one/dist/esm/index.native.js') ||
|
|
188
|
-
__getRequire('packages/one/dist/esm/index.native.js', _mod) ||
|
|
189
|
-
__getRequire('vxrn/packages/one/dist/esm/index.native.js', _mod)
|
|
190
|
-
|
|
191
|
-
if (found) return found
|
|
192
|
-
|
|
193
|
-
// Try harder
|
|
194
|
-
const possibleId = Object.keys(___modules___).find((m) =>
|
|
195
|
-
/(one|one)\/dist\/esm\/index\.native\.js$/.test(m)
|
|
196
|
-
)
|
|
197
|
-
if (possibleId) {
|
|
198
|
-
return __getRequire(possibleId, _mod)
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (_mod.startsWith('node:') || nodeImports[_mod]) {
|
|
203
|
-
console.warn(`Warning node import not supported: "${_mod}" from "${importer}"`)
|
|
204
|
-
return {}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// find via maps
|
|
208
|
-
let path = __specialRequireMap[_mod] || importsMap[_mod] || _mod
|
|
209
|
-
const found = __getRequire(path, _mod)
|
|
210
|
-
if (found) return found
|
|
211
|
-
|
|
212
|
-
// quick and dirty relative()
|
|
213
|
-
if (importer && path[0] === '.') {
|
|
214
|
-
let currentDir = (() => {
|
|
215
|
-
const paths = importer.split('/')
|
|
216
|
-
return paths.slice(0, paths.length - 1) // remove last part to get dir
|
|
217
|
-
})()
|
|
218
|
-
|
|
219
|
-
const pathParts = path.split('/')
|
|
220
|
-
while (true) {
|
|
221
|
-
if (pathParts[0] !== '..') break
|
|
222
|
-
pathParts.shift()
|
|
223
|
-
currentDir.pop()
|
|
224
|
-
}
|
|
225
|
-
path = [...currentDir, ...pathParts]
|
|
226
|
-
// Prevent generating a path like this: `foo/./bar.js` when requiring `./bar.js` from `foo`.
|
|
227
|
-
.filter((p) => p !== '.')
|
|
228
|
-
.join('/')
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// find our import.meta.glob which don't get the nice path addition, for now hardcode but this shouldnt be hard to fix properly:
|
|
232
|
-
const foundGlob = __getRequire(path.replace(/\.[jt]sx?$/, '.js'), _mod)
|
|
233
|
-
if (foundGlob) {
|
|
234
|
-
return foundGlob
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// find internals loosely
|
|
238
|
-
try {
|
|
239
|
-
for (const [key, value] of Object.entries(__specialRequireMap)) {
|
|
240
|
-
if (_mod.endsWith(value)) {
|
|
241
|
-
const found = __getRequire(__specialRequireMap[key])
|
|
242
|
-
if (found) {
|
|
243
|
-
return found
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
} catch (err) {
|
|
248
|
-
console.info('error loose internal', err)
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// find externals loosely
|
|
252
|
-
try {
|
|
253
|
-
for (const [key, value] of Object.entries(importsMap)) {
|
|
254
|
-
if (key.endsWith(_mod.replace(/(\.\.?\/)+/, ''))) {
|
|
255
|
-
const found = __getRequire(importsMap[key], key)
|
|
256
|
-
if (found) {
|
|
257
|
-
return found
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
} catch (err) {
|
|
262
|
-
console.info('error loose external', err)
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// is this cruft
|
|
266
|
-
if (globalThis[path]) {
|
|
267
|
-
const output = globalThis[path]()
|
|
268
|
-
__cachedModules[_mod] = output
|
|
269
|
-
return output
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (_mod.endsWith('.css.js')) {
|
|
273
|
-
// temp fix for hmr error logs
|
|
274
|
-
return
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
console.error(
|
|
278
|
-
`Module not found "${_mod}" imported by "${importer}"\n${getErrorDetails()}`
|
|
279
|
-
)
|
|
280
|
-
return {}
|
|
281
|
-
} catch (err) {
|
|
282
|
-
const errorMessage =
|
|
283
|
-
`\n◆ ${_mod} "${err}"`.replace('Error: ', '').replaceAll('"', '') +
|
|
284
|
-
'\n' +
|
|
285
|
-
getErrorDetails(false)
|
|
286
|
-
|
|
287
|
-
if (globalThis['no_console']) {
|
|
288
|
-
// If we are in production, do not suppress error as it will be hard to debug (currently console.error in production is not shown or being logged anywhere).
|
|
289
|
-
throw new Error(errorMessage)
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
console.error(errorMessage)
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
globalThis['setImmediate'] = (cb) => cb()
|
|
297
|
-
//cb => Promise.resolve().then(() => cb())
|
|
298
|
-
|
|
299
|
-
globalThis.__vxrnReloadApp = () => {
|
|
300
|
-
__getRequire(__specialRequireMap['react-native']).DevSettings.reload()
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
if (!globalThis['console']) {
|
|
304
|
-
globalThis['console'] = {}
|
|
305
|
-
globalThis['no_console'] = true // Probably running in production
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// idk why
|
|
309
|
-
globalThis.__vxrnTmpLogs = []
|
|
310
|
-
;['trace', 'info', 'warn', 'error', 'log', 'group', 'groupCollapsed', 'debug'].forEach(
|
|
311
|
-
(level) => {
|
|
312
|
-
const og = globalThis['console'][level] || (() => {})
|
|
313
|
-
globalThis['_ogConsole' + level] = og
|
|
314
|
-
const ogConsole = og.bind(globalThis['console'])
|
|
315
|
-
globalThis['console'][level] = (...data) => {
|
|
316
|
-
if (globalThis.__vxrnTmpLogs) {
|
|
317
|
-
globalThis.__vxrnTmpLogs.push({ level, data })
|
|
318
|
-
}
|
|
319
|
-
return ogConsole(...data)
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
)
|
|
323
|
-
|
|
324
|
-
console._isPolyfilled = true
|
|
325
|
-
|
|
326
|
-
global.performance = {
|
|
327
|
-
now: () => Date.now(),
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
let _globalErrorHandler
|
|
331
|
-
global.ErrorUtils = {
|
|
332
|
-
setGlobalHandler: (fun) => {
|
|
333
|
-
_globalErrorHandler = fun
|
|
334
|
-
},
|
|
335
|
-
getGlobalHandler: () => _globalErrorHandler || (() => {}),
|
|
336
|
-
reportError: (error) => {
|
|
337
|
-
_globalErrorHandler && _globalErrorHandler(error, false)
|
|
338
|
-
console.log(
|
|
339
|
-
'e1',
|
|
340
|
-
error.message,
|
|
341
|
-
error.stack,
|
|
342
|
-
Object.keys(error),
|
|
343
|
-
JSON.stringify(error)
|
|
344
|
-
)
|
|
345
|
-
},
|
|
346
|
-
reportFatalError: (error) => {
|
|
347
|
-
_globalErrorHandler && _globalErrorHandler(error, true)
|
|
348
|
-
console.log(
|
|
349
|
-
'e2',
|
|
350
|
-
error.message,
|
|
351
|
-
error.stack,
|
|
352
|
-
Object.keys(error),
|
|
353
|
-
JSON.stringify(error)
|
|
354
|
-
)
|
|
355
|
-
},
|
|
356
|
-
// mocked
|
|
357
|
-
applyWithGuard: () => {},
|
|
358
|
-
applyWithGuardIfNeeded: () => {},
|
|
359
|
-
inGuard: () => {},
|
|
360
|
-
guard: () => {},
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// These are necessary for react-native-reanimated to work. Without this, app will crash with `EXC_BAD_ACCESS` [here](https://github.com/software-mansion/react-native-reanimated/blob/3.10.1/Common/cpp/SharedItems/Shareables.cpp#L57) with `function.getProperty(rt, "name").getString(rt).utf8(rt).c_str()` being `assert`, `clear`, `dir`, `dirxml`, `profile`, `profileEnd`, `table`, etc.
|
|
364
|
-
// TODO: We may need to implement these functions in the future.
|
|
365
|
-
console.assert = () => {}
|
|
366
|
-
console.clear = () => {}
|
|
367
|
-
console.dir = () => {}
|
|
368
|
-
console.dirxml = () => {}
|
|
369
|
-
console.profile = () => {}
|
|
370
|
-
console.profileEnd = () => {}
|
|
371
|
-
console.table = () => {}
|
|
372
|
-
|
|
373
|
-
// ensure this exists
|
|
374
|
-
global.$RefreshReg$ = () => {}
|
|
375
|
-
global.$RefreshSig$ = () => (type) => type
|