@tamagui/cli 1.52.4 → 1.52.5

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 (53) hide show
  1. package/dist/dev/createDevServer.js +59 -39
  2. package/dist/dev/createDevServer.js.map +2 -2
  3. package/dist/dev.js +144 -87
  4. package/dist/dev.js.map +2 -2
  5. package/dist/vendor/repack/dev-server/src/createServer.js +15 -2
  6. package/dist/vendor/repack/dev-server/src/createServer.js.map +2 -2
  7. package/dist/vendor/repack/dev-server/src/plugins/wss/WebSocketRouter.js +0 -3
  8. package/dist/vendor/repack/dev-server/src/plugins/wss/WebSocketRouter.js.map +1 -1
  9. package/dist/vendor/repack/dev-server/src/plugins/wss/servers/HermesInspectorProxy.js +1 -1
  10. package/dist/vendor/repack/dev-server/src/plugins/wss/servers/HermesInspectorProxy.js.map +1 -1
  11. package/dist/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketApiServer.js +4 -1
  12. package/dist/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketApiServer.js.map +1 -1
  13. package/dist/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketEventsServer.js +1 -0
  14. package/dist/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketEventsServer.js.map +1 -1
  15. package/dist/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketHMRServer.js +2 -2
  16. package/dist/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketHMRServer.js.map +1 -1
  17. package/dist/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketMessageServer.js +1 -0
  18. package/dist/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketMessageServer.js.map +1 -1
  19. package/dist/vendor/repack/dev-server/src/plugins/wss/wssPlugin.js +4 -1
  20. package/dist/vendor/repack/dev-server/src/plugins/wss/wssPlugin.js.map +1 -1
  21. package/dist/vendor/repack/dev-server/src/types.js.map +1 -1
  22. package/package.json +11 -7
  23. package/src/dev/clientInjectPlugin.ts +112 -0
  24. package/src/dev/createDevServer.ts +59 -47
  25. package/src/dev/types.ts +1 -0
  26. package/src/dev.ts +197 -95
  27. package/src/vendor/repack/dev-server/src/createServer.ts +17 -7
  28. package/src/vendor/repack/dev-server/src/plugins/wss/WebSocketRouter.ts +1 -5
  29. package/src/vendor/repack/dev-server/src/plugins/wss/servers/HermesInspectorProxy.ts +1 -1
  30. package/src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketApiServer.ts +4 -1
  31. package/src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketEventsServer.ts +3 -0
  32. package/src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketHMRServer.ts +2 -2
  33. package/src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketMessageServer.ts +3 -0
  34. package/src/vendor/repack/dev-server/src/plugins/wss/wssPlugin.ts +5 -5
  35. package/src/vendor/repack/dev-server/src/types.ts +4 -0
  36. package/types/dev/WebpackHMRClient.d.ts +1 -0
  37. package/types/dev/clientInjectPlugin.d.ts +7 -0
  38. package/types/dev/createDevServer.d.ts +4 -1
  39. package/types/dev/createDevServer.d.ts.map +1 -1
  40. package/types/dev/types.d.ts +5 -0
  41. package/types/dev.d.ts.map +1 -1
  42. package/types/vendor/repack/dev-server/src/createServer.d.ts.map +1 -1
  43. package/types/vendor/repack/dev-server/src/plugins/wss/WebSocketRouter.d.ts.map +1 -1
  44. package/types/vendor/repack/dev-server/src/plugins/wss/servers/HermesInspectorProxy.d.ts.map +1 -1
  45. package/types/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketApiServer.d.ts.map +1 -1
  46. package/types/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketEventsServer.d.ts.map +1 -1
  47. package/types/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketMessageServer.d.ts.map +1 -1
  48. package/types/vendor/repack/dev-server/src/plugins/wss/wssPlugin.d.ts +2 -0
  49. package/types/vendor/repack/dev-server/src/plugins/wss/wssPlugin.d.ts.map +1 -1
  50. package/types/vendor/repack/dev-server/src/types.d.ts +3 -0
  51. package/types/vendor/repack/dev-server/src/types.d.ts.map +1 -1
  52. package/src/vendor/repack/dev-server/vendor/metro-inspector-proxy/src/Device.cjs +0 -1
  53. package/src/vendor/repack/dev-server/vendor/metro-inspector-proxy/src/Device.js +0 -1
package/src/dev.ts CHANGED
@@ -1,122 +1,164 @@
1
1
  import { readFile } from 'fs/promises'
2
- import { AddressInfo } from 'net'
3
2
  import { join } from 'path'
4
3
 
5
4
  import { CLIResolvedOptions } from '@tamagui/types'
6
- import { nativePlugin, nativePrebuild, tamaguiPlugin } from '@tamagui/vite-plugin'
5
+ import viteReactPlugin, { swcTransform } from '@tamagui/vite-native-swc'
6
+ import { nativeBabelTransform, nativePlugin, nativePrebuild } from '@tamagui/vite-plugin'
7
7
  import chalk from 'chalk'
8
- import fs, { ensureDir, pathExists } from 'fs-extra'
9
- import { build, createServer } from 'vite'
8
+ import fs, { pathExists } from 'fs-extra'
9
+ import { InlineConfig, build, createServer, resolveConfig } from 'vite'
10
10
 
11
+ import { clientInjectionsPlugin } from './dev/clientInjectPlugin'
11
12
  import { createDevServer } from './dev/createDevServer'
13
+ import { HMRListener } from './dev/types'
12
14
  import { registerDispose } from './utils'
13
15
 
14
16
  export const dev = async (options: CLIResolvedOptions) => {
15
17
  const { root, mode, paths } = options
16
-
17
- process.chdir(process.cwd())
18
+ const projectRoot = root
18
19
 
19
20
  const packageRootDir = join(__dirname, '..')
20
21
 
21
22
  // build react-native
22
23
  await nativePrebuild()
23
24
 
25
+ // react native port (it scans 19000 +5)
26
+ const port = options.port || 8081
27
+
24
28
  const plugins = [
25
29
  // tamaguiPlugin({
26
30
  // components: ['tamagui'],
27
31
  // target: 'native',
28
32
  // }),
29
- nativePlugin(),
33
+ viteReactPlugin({
34
+ tsDecorators: true,
35
+ }),
36
+ nativePlugin({
37
+ port,
38
+ }),
30
39
  ]
31
40
 
32
- const rootFile = join(root, 'src/test-tamagui-stack.tsx')
33
-
34
- console.log('root', root, rootFile)
41
+ const hmrListeners: HMRListener[] = []
42
+ const hotUpdatedCJSFiles = new Map<string, string>()
35
43
 
36
- const server = await createServer({
37
- root: rootFile,
44
+ let serverConfig = {
45
+ root,
38
46
  mode: 'development',
39
- plugins,
47
+ clearScreen: false,
48
+ plugins: [
49
+ ...plugins,
50
+
51
+ {
52
+ name: `tamagui-hot-update`,
53
+ async handleHotUpdate({ file, read, modules }) {
54
+ // idk why but its giving me dist asset stuff
55
+ if (!file.includes('/src/')) {
56
+ return
57
+ }
58
+
59
+ const id = modules[0]?.url || file.replace(root, '')
60
+
61
+ if (!id) {
62
+ console.log('⚠️ no modules?', file)
63
+ return
64
+ }
65
+
66
+ try {
67
+ const raw = await read()
68
+
69
+ // swc isnt applied here weird
70
+ const swcout = await swcTransform(
71
+ file,
72
+ raw,
73
+ {
74
+ tsDecorators: true,
75
+ },
76
+ true
77
+ )
78
+
79
+ if (!swcout) {
80
+ throw 'sadsad'
81
+ }
82
+
83
+ let contents = await nativeBabelTransform(swcout.code)
84
+
85
+ contents = `exports = ((exports) => { ${contents}; return exports })({})`
86
+
87
+ // set here to be fetched next
88
+ // i'd have just sent it in the websocket but maybe theres some size limits
89
+ hotUpdatedCJSFiles.set(id, contents)
90
+
91
+ // for (const listener of hmrListeners) {
92
+ // listener({
93
+ // file,
94
+ // contents,
95
+ // })
96
+ // }
97
+ } catch (err) {
98
+ console.log('error hmring', err)
99
+ }
100
+ },
101
+ },
102
+ ],
40
103
  server: {
104
+ cors: true,
41
105
  port: options.port,
42
- host: options.host || 'localhost',
106
+ host: options.host || '127.0.0.1',
43
107
  },
44
- })
108
+ } satisfies InlineConfig
45
109
 
46
- await server.listen()
110
+ // first resolve config so we can pass into client plugin, then add client plugin:
111
+ const resolvedConfig = await resolveConfig(serverConfig, 'serve')
112
+ const viteRNClient = clientInjectionsPlugin(resolvedConfig)
47
113
 
48
- await ensureDir(options.paths.dotDir)
49
- // const res = await watchTamaguiConfig(options.tamaguiOptions)
114
+ plugins.push(viteRNClient)
50
115
 
51
- const info = server.httpServer?.address() as AddressInfo
116
+ serverConfig = {
117
+ ...serverConfig,
118
+ plugins: [...serverConfig.plugins],
119
+ }
52
120
 
53
- // react native port (it scans 19000 +5)
54
- const port = 8081
121
+ const server = await createServer(serverConfig)
55
122
 
56
- const defaultResponse = {
57
- name: 'myapp',
58
- slug: 'myapp',
59
- scheme: 'myapp',
60
- version: '1.0.0',
61
- jsEngine: 'jsc',
62
- orientation: 'portrait',
63
- icon: './assets/icon.png',
64
- userInterfaceStyle: 'light',
65
- splash: {
66
- image: './assets/splash.png',
67
- resizeMode: 'contain',
68
- backgroundColor: '#ffffff',
69
- imageUrl: 'http://127.0.0.1:8081/assets/./assets/splash.png',
70
- },
71
- updates: { fallbackToCacheTimeout: 0 },
72
- assetBundlePatterns: ['**/*'],
73
- ios: { supportsTablet: true, bundleIdentifier: 'com.natew.myapp' },
74
- android: {
75
- package: 'com.tamagui.myapp',
76
- adaptiveIcon: {
77
- foregroundImage: './assets/adaptive-icon.png',
78
- backgroundColor: '#FFFFFF',
79
- foregroundImageUrl: 'http://127.0.0.1:8081/assets/./assets/adaptive-icon.png',
80
- },
81
- },
82
- web: { favicon: './assets/favicon.png' },
83
- extra: { eas: { projectId: '061b4470-78c7-4d6a-b850-8167fb0a3434' } },
84
- _internal: {
85
- isDebug: false,
86
- projectRoot: '/Users/n8/tamagui/apps/kitchen-sink',
87
- dynamicConfigPath: null,
88
- staticConfigPath: '/Users/n8/tamagui/apps/kitchen-sink/app.json',
89
- packageJsonPath: '/Users/n8/tamagui/apps/kitchen-sink/package.json',
90
- },
91
- sdkVersion: '47.0.0',
92
- platforms: ['ios', 'android', 'web'],
93
- iconUrl: `http://127.0.0.1:${port}/assets/./assets/icon.png`,
94
- debuggerHost: `127.0.0.1:${port}`,
95
- logUrl: `http://127.0.0.1:${port}/logs`,
96
- developer: { tool: 'expo-cli', projectRoot: '/Users/n8/tamagui/apps/kitchen-sink' },
97
- packagerOpts: { dev: true },
98
- mainModuleName: 'index',
99
- __flipperHack: 'React Native packager is running',
100
- hostUri: `127.0.0.1:${port}`,
101
- bundleUrl: `http://127.0.0.1:${port}/index.bundle?platform=ios&dev=true&hot=false&lazy=true`,
102
- id: '@anonymous/myapp-473c4543-3c36-4786-9db1-c66a62ac9b78',
103
- }
123
+ await server.listen()
104
124
 
105
- // new server
106
- const outputJsPath = join(process.cwd(), '.tamagui', 'bundle.js')
125
+ // need to simulate browser fetching a file so vite loads module into module graph and hmr works
126
+ // no luck yet:
127
+
128
+ // trying to see whats going on with this:
129
+ // server.moduleGraph = new Proxy(server.moduleGraph, {
130
+ // get(t, p) {
131
+ // console.log('get', p)
132
+ // const out = Reflect.get(t, p)
133
+ // if (typeof out === 'function') {
134
+ // return new Proxy(out, {
135
+ // apply(a, b, c) {
136
+ // console.log('apply', p, c)
137
+ // return Reflect.apply(a as any, b, c)
138
+ // },
139
+ // })
140
+ // }
141
+ // return out
142
+ // },
143
+ // })
144
+
145
+ // server.moduleGraph.resolveUrl('/src/App.tsx')
146
+ // server.moduleGraph.getModuleByUrl('/src/App.tsx')
147
+ // server.moduleGraph.ensureEntryFromUrl('/src/App.tsx', false)
148
+ // await ensureDir(options.paths.dotDir)
149
+ // const res = await watchTamaguiConfig(options.tamaguiOptions)
107
150
 
108
151
  const dispose = await createDevServer(options, {
152
+ hotUpdatedCJSFiles,
153
+ listenForHMR(cb) {
154
+ hmrListeners.push(cb)
155
+ },
109
156
  getIndexBundle: async function getBundle() {
110
157
  const outputCode = await getBundleCode()
111
158
 
112
- // so you can debug output easier
113
- setTimeout(() => {
114
- fs.writeFile(outputJsPath, outputCode)
115
- })
116
-
117
159
  return outputCode
118
160
  },
119
- indexJson: defaultResponse,
161
+ indexJson: getIndexJsonReponse({ port, root }),
120
162
  })
121
163
 
122
164
  // rome-ignore lint/nursery/noConsoleLog: ok
@@ -132,10 +174,13 @@ export const dev = async (options: CLIResolvedOptions) => {
132
174
 
133
175
  async function getBundleCode() {
134
176
  // for easier quick testing things:
135
- const tmpBundle = join(packageRootDir, 'bundle.tmp.js')
177
+ const tmpBundle = join(process.cwd(), 'bundle.tmp.js')
136
178
  if (await pathExists(tmpBundle)) {
137
179
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
138
- console.log('returning temp bundle', tmpBundle)
180
+ console.log(
181
+ '⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ returning temp bundle ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️',
182
+ tmpBundle
183
+ )
139
184
  return await readFile(tmpBundle, 'utf-8')
140
185
  }
141
186
 
@@ -145,12 +190,9 @@ export const dev = async (options: CLIResolvedOptions) => {
145
190
  plugins,
146
191
  appType: 'custom',
147
192
  root,
193
+ clearScreen: false,
148
194
  build: {
149
- ssr: true,
150
- },
151
- ssr: {
152
- format: 'cjs',
153
- target: 'node',
195
+ ssr: false,
154
196
  },
155
197
  mode: 'development',
156
198
  define: {
@@ -159,17 +201,23 @@ export const dev = async (options: CLIResolvedOptions) => {
159
201
  },
160
202
  })
161
203
 
162
- const appCode = 'output' in buildOutput ? buildOutput.output[0].code : null
204
+ const appCodeIn = 'output' in buildOutput ? buildOutput.output[0].code : null
163
205
 
164
- if (!appCode) {
206
+ if (!appCodeIn) {
165
207
  throw `❌`
166
208
  }
167
209
 
168
- const [react, reactJsxRuntime, reactNative] = await Promise.all([
169
- readFile(join(process.cwd(), 'testing-area', 'react.js'), 'utf-8'),
170
- readFile(join(process.cwd(), 'testing-area', 'react-jsx-runtime.js'), 'utf-8'),
171
- readFile(join(process.cwd(), 'testing-area', 'react-native.js'), 'utf-8'),
172
- ])
210
+ const appCode = await nativeBabelTransform(appCodeIn)
211
+
212
+ const paths = [
213
+ join(process.cwd(), 'testing-area', 'react.js'),
214
+ join(process.cwd(), 'testing-area', 'react-jsx-runtime.js'),
215
+ join(process.cwd(), 'testing-area', 'react-native.js'),
216
+ ]
217
+
218
+ const [react, reactJsxRuntime, reactNative] = await Promise.all(
219
+ paths.map((p) => readFile(p, 'utf-8'))
220
+ )
173
221
 
174
222
  const reactCode = react.replace(
175
223
  `module.exports = require_react_development();`,
@@ -179,16 +227,19 @@ export const dev = async (options: CLIResolvedOptions) => {
179
227
  const reactJSXRuntimeCode = reactJsxRuntime.replace(
180
228
  `module.exports = require_react_jsx_runtime_production_min();`,
181
229
  `return require_react_jsx_runtime_production_min()`
230
+ // `module.exports = require_react_jsx_dev_runtime_development();`,
231
+ // `return require_react_jsx_dev_runtime_development();`
182
232
  )
183
233
 
184
234
  const reactNativeCode = reactNative
185
235
  .replace(
186
236
  `module.exports = require_react_native();`,
187
- `return require_react_native()`
237
+ `require_ReactNative(); return require_react_native()`
188
238
  )
239
+ // forcing onto global so i can re-thread it into require
189
240
  .replace(
190
- `renderable = /* @__PURE__ */ react(RootComponentWithMeaningfulName, null, renderable);`,
191
- ``
241
+ `ReactRefreshRuntime.injectIntoGlobalHook(global);`,
242
+ `globalThis['_ReactRefreshRuntime'] = ReactRefreshRuntime; ReactRefreshRuntime.injectIntoGlobalHook(global);`
192
243
  )
193
244
 
194
245
  const templateFile = join(packageRootDir, 'react-native-template.js')
@@ -197,6 +248,57 @@ export const dev = async (options: CLIResolvedOptions) => {
197
248
  .replace(`// -- react --`, reactCode)
198
249
  .replace(`// -- react-native --`, reactNativeCode)
199
250
  .replace(`// -- react/jsx-runtime --`, reactJSXRuntimeCode)
200
- .replace(`// -- app --`, appCode)
251
+ .replace(`// -- app --`, appCode.replace('"use strict";', ''))
252
+ }
253
+ }
254
+
255
+ function getIndexJsonReponse({ port, root }: { port: number | string; root }) {
256
+ return {
257
+ name: 'myapp',
258
+ slug: 'myapp',
259
+ scheme: 'myapp',
260
+ version: '1.0.0',
261
+ jsEngine: 'jsc',
262
+ orientation: 'portrait',
263
+ icon: './assets/icon.png',
264
+ userInterfaceStyle: 'light',
265
+ splash: {
266
+ image: './assets/splash.png',
267
+ resizeMode: 'contain',
268
+ backgroundColor: '#ffffff',
269
+ imageUrl: 'http://127.0.0.1:8081/assets/./assets/splash.png',
270
+ },
271
+ updates: { fallbackToCacheTimeout: 0 },
272
+ assetBundlePatterns: ['**/*'],
273
+ ios: { supportsTablet: true, bundleIdentifier: 'com.natew.myapp' },
274
+ android: {
275
+ package: 'com.tamagui.myapp',
276
+ adaptiveIcon: {
277
+ foregroundImage: './assets/adaptive-icon.png',
278
+ backgroundColor: '#FFFFFF',
279
+ foregroundImageUrl: 'http://127.0.0.1:8081/assets/./assets/adaptive-icon.png',
280
+ },
281
+ },
282
+ web: { favicon: './assets/favicon.png' },
283
+ extra: { eas: { projectId: '061b4470-78c7-4d6a-b850-8167fb0a3434' } },
284
+ _internal: {
285
+ isDebug: false,
286
+ projectRoot: root,
287
+ dynamicConfigPath: null,
288
+ staticConfigPath: join(root, 'app.json'),
289
+ packageJsonPath: join(root, 'package.json'),
290
+ },
291
+ sdkVersion: '47.0.0',
292
+ platforms: ['ios', 'android', 'web'],
293
+ iconUrl: `http://127.0.0.1:${port}/assets/./assets/icon.png`,
294
+ debuggerHost: `127.0.0.1:${port}`,
295
+ logUrl: `http://127.0.0.1:${port}/logs`,
296
+ developer: { tool: 'expo-cli', projectRoot: root },
297
+ packagerOpts: { dev: true },
298
+ mainModuleName: 'index',
299
+ __flipperHack: 'React Native packager is running',
300
+ hostUri: `127.0.0.1:${port}`,
301
+ bundleUrl: `http://127.0.0.1:${port}/index.bundle?platform=ios&dev=true&hot=false&lazy=true`,
302
+ id: '@anonymous/myapp-473c4543-3c36-4786-9db1-c66a62ac9b78',
201
303
  }
202
304
  }
@@ -61,6 +61,16 @@ export async function createServer(config: Server.Config) {
61
61
  },
62
62
  })
63
63
 
64
+ // fuck delegates
65
+ instance.register(async (inst) => {
66
+ inst.get('/file', async (req, reply) => {
67
+ const query = req.query as Record<string, string>
68
+ console.log('getting', query.file)
69
+ const source = delegate.hotFiles.getSource(query.file)
70
+ reply.send(source)
71
+ })
72
+ })
73
+
64
74
  // Register plugins
65
75
  await instance.register(fastifySensible)
66
76
  await instance.register(wssPlugin, {
@@ -82,12 +92,13 @@ export async function createServer(config: Server.Config) {
82
92
  options: config.options,
83
93
  })
84
94
 
85
- console.warn('disable debugger-ui + favicon for now')
86
- // await instance.register(fastifyStatic, {
87
- // root: debuggerAppPath,
88
- // prefix: '/debugger-ui',
89
- // prefixAvoidTrailingSlash: true,
90
- // })
95
+ const debuggerAppPath = (await import('@callstack/repack-debugger-app')).default
96
+
97
+ await instance.register(fastifyStatic, {
98
+ root: debuggerAppPath,
99
+ prefix: '/debugger-ui',
100
+ prefixAvoidTrailingSlash: true,
101
+ })
91
102
 
92
103
  // below is to prevent showing `GET 400 /favicon.ico`
93
104
  // errors in console when requesting the bundle via browser
@@ -105,7 +116,6 @@ export async function createServer(config: Server.Config) {
105
116
  })
106
117
 
107
118
  // Register routes
108
- instance.head('/', async () => '')
109
119
  instance.get('/', async () => delegate.messages.getHello())
110
120
  instance.get('/status', async () => delegate.messages.getStatus())
111
121
 
@@ -33,20 +33,16 @@ export class WebSocketRouter {
33
33
  let matched = false
34
34
 
35
35
  if (pathname === '/inspector/device') {
36
+ // ignore
36
37
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
37
- console.log('ignoring', pathname)
38
38
  // socket.destroy()
39
39
  return
40
40
  }
41
41
 
42
- // rome-ignore lint/nursery/noConsoleLog: <explanation>
43
- console.log('check for upgrade', pathname)
44
-
45
42
  for (const server of this.servers) {
46
43
  if (server.shouldUpgrade(pathname)) {
47
44
  matched = true
48
45
  // rome-ignore lint/nursery/noConsoleLog: <explanation>
49
- console.log('matched', pathname)
50
46
  server.upgrade(request, socket, head)
51
47
  break
52
48
  }
@@ -2,9 +2,9 @@ import type { IncomingMessage } from 'http'
2
2
  import { URL } from 'url'
3
3
 
4
4
  import type { FastifyInstance, FastifyReply, FastifyRequest, LogLevel } from 'fastify'
5
+ import Device from 'metro-inspector-proxy/src/Device'
5
6
  import WebSocket from 'ws'
6
7
 
7
- import Device from '../../../../vendor/metro-inspector-proxy/src/Device'
8
8
  import { Server } from '../../../types'
9
9
  import { WebSocketServer } from '../WebSocketServer'
10
10
 
@@ -60,7 +60,10 @@ export class WebSocketApiServer extends WebSocketServer {
60
60
  this.clients.delete(clientId)
61
61
  }
62
62
 
63
- socket.addEventListener('error', onClose)
63
+ socket.addEventListener('error', () => {
64
+ console.log('error1')
65
+ onClose()
66
+ })
64
67
  socket.addEventListener('close', onClose)
65
68
  }
66
69
  }
@@ -69,6 +69,9 @@ export class WebSocketEventsServer extends WebSocketServer {
69
69
  parseMessage(data: string): Command | undefined {
70
70
  try {
71
71
  const message = JSON.parse(data)
72
+
73
+ console.log('event message', message)
74
+
72
75
  if (message.version === WebSocketEventsServer.PROTOCOL_VERSION) {
73
76
  return message
74
77
  }
@@ -42,7 +42,7 @@ export class WebSocketHMRServer extends WebSocketServer {
42
42
  key.platform !== platform ||
43
43
  !(clientIds ?? [key.clientId]).includes(key.clientId)
44
44
  ) {
45
- return
45
+ continue
46
46
  }
47
47
 
48
48
  try {
@@ -65,7 +65,7 @@ export class WebSocketHMRServer extends WebSocketServer {
65
65
  */
66
66
  onConnection(socket: WebSocket, request: IncomingMessage) {
67
67
  const { searchParams } = new URL(request.url || '', 'http://localhost')
68
- const platform = searchParams.get('platform')
68
+ const platform = searchParams.get('platform') || 'ios'
69
69
 
70
70
  if (!platform) {
71
71
  this.fastify.log.info({
@@ -109,6 +109,9 @@ export class WebSocketMessageServer extends WebSocketServer {
109
109
  }
110
110
  try {
111
111
  const message = JSON.parse(data) as Partial<ReactNativeMessage>
112
+
113
+ console.log('message', message)
114
+
112
115
  if (message.version === WebSocketMessageServer.PROTOCOL_VERSION.toString()) {
113
116
  return message
114
117
  }
@@ -2,7 +2,7 @@ import type { FastifyInstance } from 'fastify'
2
2
  import fastifyPlugin from 'fastify-plugin'
3
3
 
4
4
  import type { Server } from '../../types'
5
- // import { HermesInspectorProxy } from './servers/HermesInspectorProxy'
5
+ import { HermesInspectorProxy } from './servers/HermesInspectorProxy'
6
6
  import { WebSocketApiServer } from './servers/WebSocketApiServer'
7
7
  import { WebSocketDebuggerServer } from './servers/WebSocketDebuggerServer'
8
8
  import { WebSocketDevClientServer } from './servers/WebSocketDevClientServer'
@@ -18,7 +18,7 @@ declare module 'fastify' {
18
18
  devClientServer: WebSocketDevClientServer
19
19
  messageServer: WebSocketMessageServer
20
20
  eventsServer: WebSocketEventsServer
21
- // hermesInspectorProxy: HermesInspectorProxy
21
+ hermesInspectorProxy: HermesInspectorProxy
22
22
  apiServer: WebSocketApiServer
23
23
  hmrServer: WebSocketHMRServer
24
24
  router: WebSocketRouter
@@ -44,7 +44,7 @@ async function wssPlugin(
44
44
  const eventsServer = new WebSocketEventsServer(instance, {
45
45
  webSocketMessageServer: messageServer,
46
46
  })
47
- // const hermesInspectorProxy = new HermesInspectorProxy(instance, options)
47
+ const hermesInspectorProxy = new HermesInspectorProxy(instance, options)
48
48
  const apiServer = new WebSocketApiServer(instance)
49
49
  const hmrServer = new WebSocketHMRServer(instance, delegate.hmr)
50
50
 
@@ -52,7 +52,7 @@ async function wssPlugin(
52
52
  router.registerServer(devClientServer)
53
53
  router.registerServer(messageServer)
54
54
  router.registerServer(eventsServer)
55
- // router.registerServer(hermesInspectorProxy)
55
+ router.registerServer(hermesInspectorProxy)
56
56
  router.registerServer(apiServer)
57
57
  router.registerServer(hmrServer)
58
58
 
@@ -61,7 +61,7 @@ async function wssPlugin(
61
61
  devClientServer,
62
62
  messageServer,
63
63
  eventsServer,
64
- // hermesInspectorProxy,
64
+ hermesInspectorProxy,
65
65
  apiServer,
66
66
  hmrServer,
67
67
  router,
@@ -53,6 +53,10 @@ export namespace Server {
53
53
  * A complete delegate with implementations for all server functionalities.
54
54
  */
55
55
  export interface Delegate {
56
+ hotFiles: {
57
+ getSource: (path: string) => string
58
+ }
59
+
56
60
  /** A compiler delegate. */
57
61
  compiler: CompilerDelegate
58
62
 
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=WebpackHMRClient.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { Plugin, ResolvedConfig } from 'vite';
2
+ /**
3
+ * some values used by the client needs to be dynamically injected by the server
4
+ * @server-only
5
+ */
6
+ export declare function clientInjectionsPlugin(config: ResolvedConfig): Plugin;
7
+ //# sourceMappingURL=clientInjectPlugin.d.ts.map
@@ -1,7 +1,10 @@
1
1
  import { CLIResolvedOptions } from '@tamagui/types';
2
- export declare function createDevServer(options: CLIResolvedOptions, { indexJson, getIndexBundle, }: {
2
+ import { HMRListener } from './types';
3
+ export declare function createDevServer(options: CLIResolvedOptions, { indexJson, listenForHMR, getIndexBundle, hotUpdatedCJSFiles, }: {
3
4
  indexJson: Object;
4
5
  getIndexBundle: () => Promise<string>;
6
+ listenForHMR: (cb: HMRListener) => void;
7
+ hotUpdatedCJSFiles: Map<string, string>;
5
8
  }): Promise<() => Promise<void>>;
6
9
  /**
7
10
  * Represent Hot Module Replacement Update body.
@@ -1 +1 @@
1
- {"version":3,"file":"createDevServer.d.ts","sourceRoot":"","sources":["../../src/dev/createDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAKnD,wBAAsB,eAAe,CACnC,OAAO,EAAE,kBAAkB,EAC3B,EACE,SAAS,EACT,cAAc,GACf,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;CAAE,gCAgKhE;AAyBD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,GAAG,CAAA;IACb,MAAM,EAAE,GAAG,CAAA;IACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,UAAU,GAAG,OAAO,GAAG,MAAM,CAAA;IACrC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAA;CAC5B"}
1
+ {"version":3,"file":"createDevServer.d.ts","sourceRoot":"","sources":["../../src/dev/createDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAKnD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC,wBAAsB,eAAe,CACnC,OAAO,EAAE,kBAAkB,EAC3B,EACE,SAAS,EACT,YAAY,EACZ,cAAc,EACd,kBAAkB,GACnB,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IACrC,YAAY,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,IAAI,CAAA;IACvC,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACxC,gCAsLF;AAMD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,GAAG,CAAA;IACb,MAAM,EAAE,GAAG,CAAA;IACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,UAAU,GAAG,OAAO,GAAG,MAAM,CAAA;IACrC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAA;CAC5B"}
@@ -0,0 +1,5 @@
1
+ export type HMRListener = (update: {
2
+ file: string;
3
+ contents: string;
4
+ }) => void;
5
+ //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AASnD,eAAO,MAAM,GAAG,YAAmB,kBAAkB,kBA4LpD,CAAA"}
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAYnD,eAAO,MAAM,GAAG,YAAmB,kBAAkB,kBA6OpD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"createServer.d.ts","sourceRoot":"","sources":["../../../../../src/vendor/repack/dev-server/src/createServer.ts"],"names":[],"mappings":";AAcA,OAAO,EAAY,MAAM,EAAE,MAAM,SAAS,CAAA;AAE1C;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM;;;;GAwGvD"}
1
+ {"version":3,"file":"createServer.d.ts","sourceRoot":"","sources":["../../../../../src/vendor/repack/dev-server/src/createServer.ts"],"names":[],"mappings":";AAcA,OAAO,EAAY,MAAM,EAAE,MAAM,SAAS,CAAA;AAE1C;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM;;;;GAkHvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"WebSocketRouter.d.ts","sourceRoot":"","sources":["../../../../../../../src/vendor/repack/dev-server/src/plugins/wss/WebSocketRouter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD;;;;;;;;;GASG;AACH,qBAAa,eAAe;IAUd,OAAO,CAAC,OAAO;IAT3B,kDAAkD;IAClD,SAAS,CAAC,OAAO,EAAE,eAAe,EAAE,CAAK;IAEzC;;;;;OAKG;gBACiB,OAAO,EAAE,eAAe;IAuC5C;;;;;;OAMG;IACH,cAAc,CAAC,CAAC,SAAS,eAAe,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC;CAIxD"}
1
+ {"version":3,"file":"WebSocketRouter.d.ts","sourceRoot":"","sources":["../../../../../../../src/vendor/repack/dev-server/src/plugins/wss/WebSocketRouter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD;;;;;;;;;GASG;AACH,qBAAa,eAAe;IAUd,OAAO,CAAC,OAAO;IAT3B,kDAAkD;IAClD,SAAS,CAAC,OAAO,EAAE,eAAe,EAAE,CAAK;IAEzC;;;;;OAKG;gBACiB,OAAO,EAAE,eAAe;IAmC5C;;;;;;OAMG;IACH,cAAc,CAAC,CAAC,SAAS,eAAe,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC;CAIxD"}
@@ -1 +1 @@
1
- {"version":3,"file":"HermesInspectorProxy.d.ts","sourceRoot":"","sources":["../../../../../../../../src/vendor/repack/dev-server/src/plugins/wss/servers/HermesInspectorProxy.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAA;AAG3C,OAAO,KAAK,EAAE,eAAe,EAA0C,MAAM,SAAS,CAAA;AACtF,OAAO,SAAS,MAAM,IAAI,CAAA;AAG1B,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAuBpD,MAAM,WAAW,oBACf,SAAQ,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAAG;AAE9D,qBAAa,oBAAqB,SAAQ,eAAe;IAKjB,OAAO,CAAC,MAAM;IAJpD,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,aAAa,CAAI;IACzB,SAAgB,UAAU,EAAE,MAAM,CAAA;gBAEtB,OAAO,EAAE,eAAe,EAAU,MAAM,EAAE,oBAAoB;IAM1E,OAAO,CAAC,KAAK;IAsCb,OAAO,CAAC,oBAAoB;IAkB5B;;;;;OAKG;IACH,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe;CAkDzD"}
1
+ {"version":3,"file":"HermesInspectorProxy.d.ts","sourceRoot":"","sources":["../../../../../../../../src/vendor/repack/dev-server/src/plugins/wss/servers/HermesInspectorProxy.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAA;AAG3C,OAAO,KAAK,EAAE,eAAe,EAA0C,MAAM,SAAS,CAAA;AAEtF,OAAO,SAAS,MAAM,IAAI,CAAA;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAuBpD,MAAM,WAAW,oBACf,SAAQ,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAAG;AAE9D,qBAAa,oBAAqB,SAAQ,eAAe;IAKjB,OAAO,CAAC,MAAM;IAJpD,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,aAAa,CAAI;IACzB,SAAgB,UAAU,EAAE,MAAM,CAAA;gBAEtB,OAAO,EAAE,eAAe,EAAU,MAAM,EAAE,oBAAoB;IAM1E,OAAO,CAAC,KAAK;IAsCb,OAAO,CAAC,oBAAoB;IAkB5B;;;;;OAKG;IACH,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe;CAkDzD"}
@@ -1 +1 @@
1
- {"version":3,"file":"WebSocketApiServer.d.ts","sourceRoot":"","sources":["../../../../../../../../src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketApiServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,SAAS,MAAM,IAAI,CAAA;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,eAAe;IACrD,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,YAAY,CAAI;IAExB;;;;;OAKG;gBACS,OAAO,EAAE,eAAe;IAIpC;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE,GAAG;IAYf;;;;OAIG;IACH,YAAY,CAAC,MAAM,EAAE,SAAS;CAkB/B"}
1
+ {"version":3,"file":"WebSocketApiServer.d.ts","sourceRoot":"","sources":["../../../../../../../../src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketApiServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,SAAS,MAAM,IAAI,CAAA;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,eAAe;IACrD,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,YAAY,CAAI;IAExB;;;;;OAKG;gBACS,OAAO,EAAE,eAAe;IAIpC;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE,GAAG;IAYf;;;;OAIG;IACH,YAAY,CAAC,MAAM,EAAE,SAAS;CAqB/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"WebSocketEventsServer.d.ts","sourceRoot":"","sources":["../../../../../../../../src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketEventsServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,SAAS,MAAM,IAAI,CAAA;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,uFAAuF;IACvF,sBAAsB,EAAE,sBAAsB,CAAA;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,GAAG,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IACtB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,GAAG,CAAA;CACX;AAED;;;;;;GAMG;AACH,qBAAa,qBAAsB,SAAQ,eAAe;IAalB,OAAO,CAAC,MAAM;IAZpD,MAAM,CAAC,QAAQ,CAAC,gBAAgB,KAAI;IAEpC,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,YAAY,CAAI;IAExB;;;;;;OAMG;gBACS,OAAO,EAAE,eAAe,EAAU,MAAM,EAAE,2BAA2B;IAQjF;;;;;OAKG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAoB/C;;;;;OAKG;IACH,gBAAgB,CAAC,OAAO,EAAE,YAAY;IAoCtC;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,YAAY;IAwBlC;;;;OAIG;IACH,YAAY,CAAC,MAAM,EAAE,SAAS;CAqC/B"}
1
+ {"version":3,"file":"WebSocketEventsServer.d.ts","sourceRoot":"","sources":["../../../../../../../../src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketEventsServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,SAAS,MAAM,IAAI,CAAA;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,uFAAuF;IACvF,sBAAsB,EAAE,sBAAsB,CAAA;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,GAAG,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IACtB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,GAAG,CAAA;CACX;AAED;;;;;;GAMG;AACH,qBAAa,qBAAsB,SAAQ,eAAe;IAalB,OAAO,CAAC,MAAM;IAZpD,MAAM,CAAC,QAAQ,CAAC,gBAAgB,KAAI;IAEpC,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,YAAY,CAAI;IAExB;;;;;;OAMG;gBACS,OAAO,EAAE,eAAe,EAAU,MAAM,EAAE,2BAA2B;IAQjF;;;;;OAKG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAuB/C;;;;;OAKG;IACH,gBAAgB,CAAC,OAAO,EAAE,YAAY;IAoCtC;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,YAAY;IAwBlC;;;;OAIG;IACH,YAAY,CAAC,MAAM,EAAE,SAAS;CAqC/B"}