@tamagui/cli 1.74.3 → 1.74.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 (67) hide show
  1. package/dist/cli.js +0 -15
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.native.js +0 -15
  4. package/dist/cli.native.js.map +1 -1
  5. package/dist/dev/clientInjectPlugin.js +1 -1
  6. package/dist/dev/clientInjectPlugin.js.map +1 -1
  7. package/dist/dev/clientInjectPlugin.native.js +1 -1
  8. package/dist/dev/clientInjectPlugin.native.js.map +1 -1
  9. package/dist/dev.js +40 -6
  10. package/dist/dev.js.map +2 -2
  11. package/dist/dev.native.js +40 -6
  12. package/dist/dev.native.js.map +2 -2
  13. package/dist/vendor/repack/dev-server/src/createServer.js +1 -1
  14. package/dist/vendor/repack/dev-server/src/createServer.js.map +1 -1
  15. package/dist/vendor/repack/dev-server/src/createServer.native.js +1 -1
  16. package/dist/vendor/repack/dev-server/src/createServer.native.js.map +1 -1
  17. package/package.json +10 -38
  18. package/src/cli.ts +0 -18
  19. package/types/dev.d.ts.map +1 -1
  20. package/src/dev/clientInjectPlugin.ts +0 -112
  21. package/src/dev/createDevServer.ts +0 -250
  22. package/src/dev/types.ts +0 -1
  23. package/src/dev.ts +0 -475
  24. package/src/test.ts +0 -12
  25. package/src/utils/constants.ts +0 -1
  26. package/src/vendor/debugger-app/index.d.ts +0 -2
  27. package/src/vendor/debugger-app/index.js +0 -3
  28. package/src/vendor/debugger-app/public/index.html +0 -49
  29. package/src/vendor/debugger-app/src/assets/blue-icon.png +0 -0
  30. package/src/vendor/debugger-app/src/assets/gray-icon.png +0 -0
  31. package/src/vendor/debugger-app/src/assets/orange-icon.png +0 -0
  32. package/src/vendor/debugger-app/src/debuggerWorker.js +0 -84
  33. package/src/vendor/debugger-app/src/index.css +0 -37
  34. package/src/vendor/debugger-app/src/index.js +0 -199
  35. package/src/vendor/debugger-app/webpack.config.cjs +0 -73
  36. package/src/vendor/repack/dev-server/src/createServer.ts +0 -155
  37. package/src/vendor/repack/dev-server/src/img/favicon.ico +0 -0
  38. package/src/vendor/repack/dev-server/src/index.ts +0 -2
  39. package/src/vendor/repack/dev-server/src/plugins/api/apiPlugin.ts +0 -50
  40. package/src/vendor/repack/dev-server/src/plugins/api/index.ts +0 -1
  41. package/src/vendor/repack/dev-server/src/plugins/compiler/compilerPlugin.ts +0 -84
  42. package/src/vendor/repack/dev-server/src/plugins/compiler/index.ts +0 -2
  43. package/src/vendor/repack/dev-server/src/plugins/compiler/types.ts +0 -37
  44. package/src/vendor/repack/dev-server/src/plugins/devtools/devtoolsPlugin.ts +0 -107
  45. package/src/vendor/repack/dev-server/src/plugins/devtools/index.ts +0 -1
  46. package/src/vendor/repack/dev-server/src/plugins/favicon/faviconPlugin.ts +0 -14
  47. package/src/vendor/repack/dev-server/src/plugins/favicon/index.ts +0 -1
  48. package/src/vendor/repack/dev-server/src/plugins/multipart/index.ts +0 -2
  49. package/src/vendor/repack/dev-server/src/plugins/multipart/multipartPlugin.ts +0 -77
  50. package/src/vendor/repack/dev-server/src/plugins/multipart/types.ts +0 -13
  51. package/src/vendor/repack/dev-server/src/plugins/symbolicate/Symbolicator.ts +0 -233
  52. package/src/vendor/repack/dev-server/src/plugins/symbolicate/index.ts +0 -3
  53. package/src/vendor/repack/dev-server/src/plugins/symbolicate/sybmolicatePlugin.ts +0 -48
  54. package/src/vendor/repack/dev-server/src/plugins/symbolicate/types.ts +0 -71
  55. package/src/vendor/repack/dev-server/src/plugins/wss/WebSocketRouter.ts +0 -74
  56. package/src/vendor/repack/dev-server/src/plugins/wss/WebSocketServer.ts +0 -60
  57. package/src/vendor/repack/dev-server/src/plugins/wss/index.ts +0 -3
  58. package/src/vendor/repack/dev-server/src/plugins/wss/servers/HermesInspectorProxy.ts +0 -158
  59. package/src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketApiServer.ts +0 -69
  60. package/src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketDebuggerServer.ts +0 -134
  61. package/src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketDevClientServer.ts +0 -74
  62. package/src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketEventsServer.ts +0 -205
  63. package/src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketHMRServer.ts +0 -97
  64. package/src/vendor/repack/dev-server/src/plugins/wss/servers/WebSocketMessageServer.ts +0 -401
  65. package/src/vendor/repack/dev-server/src/plugins/wss/types.ts +0 -17
  66. package/src/vendor/repack/dev-server/src/plugins/wss/wssPlugin.ts +0 -73
  67. package/src/vendor/repack/dev-server/src/types.ts +0 -206
package/src/dev.ts DELETED
@@ -1,475 +0,0 @@
1
- import { readFile, writeFile } from 'fs/promises'
2
- import { dirname, join, relative } from 'path'
3
-
4
- import * as babel from '@babel/core'
5
- import { CLIResolvedOptions } from '@tamagui/types'
6
- import viteReactPlugin, {
7
- swcTransform,
8
- transformForBuild,
9
- } from '@tamagui/vite-native-swc'
10
- import { getVitePath, nativePlugin, tamaguiPlugin } from '@tamagui/vite-plugin'
11
- import react from '@vitejs/plugin-react-swc'
12
- import chalk from 'chalk'
13
- import { parse } from 'es-module-lexer'
14
- import { pathExists } from 'fs-extra'
15
- import { InlineConfig, build, createServer, resolveConfig } from 'vite'
16
-
17
- import { clientInjectionsPlugin } from './dev/clientInjectPlugin'
18
- import { createDevServer } from './dev/createDevServer'
19
- import { HMRListener } from './dev/types'
20
- import { registerDispose } from './utils'
21
-
22
- export const dev = async (options: CLIResolvedOptions) => {
23
- const { root } = options
24
-
25
- process.on('uncaughtException', (err) => {
26
- // biome-ignore lint/suspicious/noConsoleLog: <explanation>
27
- console.log(err?.message || err)
28
- })
29
-
30
- const packageRootDir = join(__dirname, '..')
31
-
32
- // react native port (it scans 19000 +5)
33
- const port = options.port || 8081
34
-
35
- const tamaguiVitePlugin = tamaguiPlugin({
36
- ...options.tamaguiOptions,
37
- })
38
-
39
- const plugins = [
40
- //
41
- tamaguiVitePlugin,
42
- ] satisfies InlineConfig['plugins']
43
-
44
- if (process.env.IS_TAMAGUI_DEV) {
45
- const inspect = require('vite-plugin-inspect')
46
- // @ts-ignore
47
- plugins.push(inspect())
48
- }
49
-
50
- const hmrListeners: HMRListener[] = []
51
- const hotUpdatedCJSFiles = new Map<string, string>()
52
-
53
- let serverConfig = {
54
- root,
55
- mode: 'development',
56
- clearScreen: false,
57
-
58
- plugins: [
59
- ...plugins,
60
-
61
- react(),
62
-
63
- {
64
- name: 'tamagui-client-transform',
65
-
66
- async handleHotUpdate({ read, modules, file }) {
67
- try {
68
- if (!file.includes('/src/')) {
69
- return
70
- }
71
-
72
- const [module] = modules
73
- if (!module) return
74
-
75
- const id = module?.url || file.replace(root, '')
76
-
77
- const code = await read()
78
-
79
- // got a weird pre compiled file on startup
80
- if (code.startsWith(`'use strict';`)) return
81
-
82
- if (!code) {
83
- return
84
- }
85
-
86
- let source = code
87
-
88
- // we have to remove jsx before we can parse imports...
89
- source = (await transformForBuild(id, source))?.code || ''
90
-
91
- const importsMap = {}
92
-
93
- // parse imports of modules into ids:
94
- // eg `import x from '@tamagui/core'` => `import x from '/me/node_modules/@tamagui/core/index.js'`
95
- const [imports] = parse(source)
96
-
97
- let accumulatedSliceOffset = 0
98
-
99
- for (const specifier of imports) {
100
- const { n: importName, s: start } = specifier
101
-
102
- if (importName) {
103
- const id = await getVitePath(file, importName)
104
- if (!id) {
105
- console.warn('???')
106
- continue
107
- }
108
-
109
- importsMap[id] = id.replace(/^(\.\.\/)+/, '')
110
-
111
- // replace module name with id for hmr
112
- const len = importName.length
113
- const extraLen = id.length - len
114
- source =
115
- source.slice(0, start + accumulatedSliceOffset) +
116
- id +
117
- source.slice(start + accumulatedSliceOffset + len)
118
- accumulatedSliceOffset += extraLen
119
- }
120
- }
121
-
122
- // then we have to convert to commonjs..
123
- source =
124
- (
125
- await swcTransform(id, source, {
126
- mode: 'serve-cjs',
127
- })
128
- )?.code || ''
129
-
130
- if (!source) {
131
- throw '❌ no source'
132
- }
133
-
134
- const hotUpdateSource = `exports = ((exports) => {
135
- const require = createRequire(${JSON.stringify(importsMap, null, 2)})
136
- ${source
137
- .replace(`import.meta.hot.accept(() => {})`, ``)
138
- // replace import.meta.glob with empty array in hot reloads
139
- .replaceAll(
140
- /import.meta.glob\(.*\)/gi,
141
- `globalThis['__importMetaGlobbed'] || {}`
142
- )};
143
- return exports })({})`
144
-
145
- hotUpdatedCJSFiles.set(id, hotUpdateSource)
146
- } catch (err) {
147
- // biome-ignore lint/suspicious/noConsoleLog: <explanation>
148
- console.log(`Error processing hmr update:`, err)
149
- }
150
- },
151
- },
152
- ],
153
- server: {
154
- cors: true,
155
- port: options.port,
156
- host: options.host || '127.0.0.1',
157
- },
158
- } satisfies InlineConfig
159
-
160
- // first resolve config so we can pass into client plugin, then add client plugin:
161
- const resolvedConfig = await resolveConfig(serverConfig, 'serve')
162
-
163
- const viteRNClientPlugin = clientInjectionsPlugin(resolvedConfig)
164
-
165
- serverConfig = {
166
- ...serverConfig,
167
- plugins: [...serverConfig.plugins],
168
- }
169
-
170
- const server = await createServer(serverConfig)
171
-
172
- server.watcher.addListener('change', async (path) => {
173
- const id = path.replace(process.cwd(), '')
174
- if (!id.endsWith('tsx') && !id.endsWith('jsx')) {
175
- return
176
- }
177
- // just so it thinks its loaded
178
- try {
179
- void server.transformRequest(id)
180
- } catch (err) {
181
- // ok
182
- // biome-ignore lint/suspicious/noConsoleLog: <explanation>
183
- console.log('err', err)
184
- }
185
- })
186
-
187
- await server.listen()
188
-
189
- let isBuilding: Promise<string> | null = null
190
-
191
- const dispose = await createDevServer(options, {
192
- hotUpdatedCJSFiles,
193
- listenForHMR(cb) {
194
- hmrListeners.push(cb)
195
- },
196
- getIndexBundle: getBundleCode,
197
- indexJson: getIndexJsonReponse({ port, root }),
198
- })
199
-
200
- // biome-ignore lint/suspicious/noConsoleLog: ok
201
- console.log(`Listening on:`, chalk.green(`http://localhost:${port}`))
202
- server.printUrls()
203
-
204
- registerDispose(() => {
205
- dispose()
206
- server.close()
207
- })
208
-
209
- await new Promise((res) => server.httpServer?.on('close', res))
210
-
211
- async function getBundleCode() {
212
- // for easier quick testing things:
213
- const tmpBundle = join(process.cwd(), 'bundle.tmp.js')
214
- if (await pathExists(tmpBundle)) {
215
- // biome-ignore lint/suspicious/noConsoleLog: <explanation>
216
- console.log(
217
- '⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ returning temp bundle ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️',
218
- tmpBundle
219
- )
220
- return await readFile(tmpBundle, 'utf-8')
221
- }
222
-
223
- if (isBuilding) {
224
- const res = await isBuilding
225
- return res
226
- }
227
-
228
- let done
229
- isBuilding = new Promise((res) => {
230
- done = res
231
- })
232
-
233
- const jsxRuntime = {
234
- alias: 'virtual:react-jsx',
235
- contents: await readFile(
236
- require.resolve('@tamagui/react-native-prebuilt/jsx-runtime'),
237
- 'utf-8'
238
- ),
239
- } as const
240
-
241
- const virtualModules = {
242
- 'react-native': {
243
- alias: 'virtual:react-native',
244
- contents: await readFile(
245
- require.resolve('@tamagui/react-native-prebuilt'),
246
- 'utf-8'
247
- ),
248
- },
249
- react: {
250
- alias: 'virtual:react',
251
- contents: await readFile(
252
- require.resolve('@tamagui/react-native-prebuilt/react'),
253
- 'utf-8'
254
- ),
255
- },
256
- 'react/jsx-runtime': jsxRuntime,
257
- 'react/jsx-dev-runtime': jsxRuntime,
258
- } as const
259
-
260
- const swapRnPlugin = {
261
- name: `swap-react-native`,
262
- enforce: 'pre',
263
-
264
- resolveId(id) {
265
- if (id.startsWith('react-native/Libraries')) {
266
- return `virtual:rn-internals:${id}`
267
- }
268
-
269
- for (const targetId in virtualModules) {
270
- if (id === targetId || id.includes(`node_modules/${targetId}/`)) {
271
- const info = virtualModules[targetId]
272
- return info.alias
273
- }
274
- }
275
- },
276
-
277
- load(id) {
278
- if (id.startsWith('virtual:rn-internals')) {
279
- const idOut = id.replace('virtual:rn-internals:', '')
280
- return `const val = __cachedModules["${idOut}"]
281
- export const PressabilityDebugView = val.PressabilityDebugView
282
- export default val ? val.default || val : val`
283
- }
284
-
285
- for (const targetId in virtualModules) {
286
- const info = virtualModules[targetId as keyof typeof virtualModules]
287
- if (id === info.alias) {
288
- return info.contents
289
- }
290
- }
291
- },
292
- } as const
293
-
294
- async function babelReanimated(input: string, filename: string) {
295
- return await new Promise<string>((res, rej) => {
296
- babel.transform(
297
- input,
298
- {
299
- plugins: ['react-native-reanimated/plugin'],
300
- filename,
301
- },
302
- (err: any, result) => {
303
- if (!result || err) rej(err || 'no res')
304
- res(result!.code!)
305
- }
306
- )
307
- })
308
- }
309
-
310
- // build app
311
- const buildConfig = {
312
- plugins: [
313
- swapRnPlugin,
314
-
315
- {
316
- name: 'reanimated',
317
-
318
- async transform(code, id) {
319
- if (code.includes('worklet')) {
320
- const out = await babelReanimated(code, id)
321
- return out
322
- }
323
- },
324
- },
325
-
326
- viteRNClientPlugin,
327
-
328
- nativePlugin({
329
- port,
330
- mode: 'build',
331
- }),
332
-
333
- viteReactPlugin({
334
- tsDecorators: true,
335
- mode: 'build',
336
- }),
337
- ],
338
- appType: 'custom',
339
- root,
340
- clearScreen: false,
341
- build: {
342
- ssr: false,
343
- minify: false,
344
- commonjsOptions: {
345
- transformMixedEsModules: true,
346
- },
347
- rollupOptions: {
348
- treeshake: false,
349
- preserveEntrySignatures: 'strict',
350
- output: {
351
- preserveModules: true,
352
- format: 'cjs',
353
- },
354
- },
355
- },
356
- mode: 'development',
357
- define: {
358
- 'process.env.NODE_ENV': `"development"`,
359
- },
360
- } satisfies InlineConfig
361
-
362
- // this fixes my swap-react-native plugin not being called pre 😳
363
- await resolveConfig(buildConfig, 'build')
364
-
365
- const buildOutput = await build(buildConfig)
366
-
367
- if (!('output' in buildOutput)) {
368
- throw `❌`
369
- }
370
-
371
- let appCode = buildOutput.output
372
- // entry last
373
- .sort((a, b) => (a['isEntry'] ? 1 : -1))
374
- .map((module) => {
375
- if (module.type == 'chunk') {
376
- const importsMap = {}
377
- for (const imp of module.imports) {
378
- const relativePath = relative(dirname(module.fileName), imp)
379
- importsMap[relativePath[0] === '.' ? relativePath : './' + relativePath] = imp
380
- }
381
-
382
- return `
383
- ___modules___["${module.fileName}"] = ((exports, module) => {
384
- const require = createRequire(${JSON.stringify(importsMap, null, 2)})
385
-
386
- ${module.code}
387
- })
388
-
389
- ${
390
- module.isEntry
391
- ? `
392
- // run entry
393
- const __require = createRequire({})
394
- __require("react-native")
395
- __require("${module.fileName}")
396
- `
397
- : ''
398
- }
399
- `
400
- }
401
- })
402
- .join('\n')
403
-
404
- if (!appCode) {
405
- throw `❌`
406
- }
407
-
408
- appCode = appCode
409
- // this can be done in the individual file transform
410
- .replaceAll('undefined.accept(() => {})', '')
411
- .replaceAll('undefined.accept(function() {});', '') // swc
412
-
413
- const templateFile = join(packageRootDir, 'react-native-template.js')
414
-
415
- const out = (await readFile(templateFile, 'utf-8')) + appCode
416
-
417
- void writeFile(join(process.cwd(), '.tamagui', 'bundle.js'), out, 'utf-8')
418
-
419
- done(out)
420
- isBuilding = null
421
-
422
- return out
423
- }
424
- }
425
-
426
- function getIndexJsonReponse({ port, root }: { port: number | string; root }) {
427
- return {
428
- name: 'myapp',
429
- slug: 'myapp',
430
- scheme: 'myapp',
431
- version: '1.0.0',
432
- jsEngine: 'jsc',
433
- orientation: 'portrait',
434
- icon: './assets/icon.png',
435
- userInterfaceStyle: 'light',
436
- splash: {
437
- image: './assets/splash.png',
438
- resizeMode: 'contain',
439
- backgroundColor: '#ffffff',
440
- imageUrl: 'http://127.0.0.1:8081/assets/./assets/splash.png',
441
- },
442
- updates: { fallbackToCacheTimeout: 0 },
443
- assetBundlePatterns: ['**/*'],
444
- ios: { supportsTablet: true, bundleIdentifier: 'com.natew.myapp' },
445
- android: {
446
- package: 'com.tamagui.myapp',
447
- adaptiveIcon: {
448
- foregroundImage: './assets/adaptive-icon.png',
449
- backgroundColor: '#FFFFFF',
450
- foregroundImageUrl: 'http://127.0.0.1:8081/assets/./assets/adaptive-icon.png',
451
- },
452
- },
453
- web: { favicon: './assets/favicon.png' },
454
- extra: { eas: { projectId: '061b4470-78c7-4d6a-b850-8167fb0a3434' } },
455
- _internal: {
456
- isDebug: false,
457
- projectRoot: root,
458
- dynamicConfigPath: null,
459
- staticConfigPath: join(root, 'app.json'),
460
- packageJsonPath: join(root, 'package.json'),
461
- },
462
- sdkVersion: '47.0.0',
463
- platforms: ['ios', 'android', 'web'],
464
- iconUrl: `http://127.0.0.1:${port}/assets/./assets/icon.png`,
465
- debuggerHost: `127.0.0.1:${port}`,
466
- logUrl: `http://127.0.0.1:${port}/logs`,
467
- developer: { tool: 'expo-cli', projectRoot: root },
468
- packagerOpts: { dev: true },
469
- mainModuleName: 'index',
470
- __flipperHack: 'React Native packager is running',
471
- hostUri: `127.0.0.1:${port}`,
472
- bundleUrl: `http://127.0.0.1:${port}/index.bundle?platform=ios&dev=true&hot=false&lazy=true`,
473
- id: '@anonymous/myapp-473c4543-3c36-4786-9db1-c66a62ac9b78',
474
- }
475
- }
package/src/test.ts DELETED
@@ -1,12 +0,0 @@
1
- /* eslint-disable no-console */
2
- import { CLIResolvedOptions } from '@tamagui/types'
3
-
4
- export const test = async (options: CLIResolvedOptions) => {
5
- const { dev } = await import('./dev.js')
6
-
7
- // failing on startup "Tamagui error bundling components require() of ES Module"
8
-
9
- void dev(options)
10
-
11
- console.log('run tests')
12
- }
@@ -1 +0,0 @@
1
- export const DEFAULT_PORT = 8081
@@ -1,2 +0,0 @@
1
- const debuggerAppPath: string
2
- export default debuggerAppPath
@@ -1,3 +0,0 @@
1
- import { URL, fileURLToPath } from 'url';
2
-
3
- export default fileURLToPath(new URL('./dist', import.meta.url));
@@ -1,49 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <link rel="icon" href="data:;base64,iVBORw0KGgo=" />
7
- <title>React Native Debugger</title>
8
- </head>
9
- <body>
10
- <!-- <noscript>You need to enable JavaScript to run Learning Lab.</noscript>
11
- <div id="root"></div> -->
12
- <div class="content">
13
- <label for="dark">
14
- <input type="checkbox" id="dark" onclick="Page.toggleDarkTheme()" />
15
- Dark Theme
16
- </label>
17
- <label for="maintain-priority">
18
- <input
19
- type="checkbox"
20
- id="maintain-priority"
21
- onclick="Page.togglePriorityMaintenance()"
22
- />
23
- Maintain Priority
24
- </label>
25
- <p>
26
- React Native JS code runs as a web worker inside this tab.
27
- </p>
28
- <p>
29
- Press <kbd id="shortcut" class="shortcut">⌘⌥I</kbd> to open Developer
30
- Tools. Enable
31
- <a href="https://stackoverflow.com/a/17324511/232122" target="_blank"
32
- >Pause On Caught Exceptions</a
33
- >
34
- for a better debugging experience.
35
- </p>
36
- <p>
37
- You may also install
38
- <a href="https://www.npmjs.com/package/react-devtools" target="_blank"
39
- >the standalone version of React Developer Tools</a
40
- >
41
- to inspect the React component hierarchy, their props, and state.
42
- </p>
43
- <p>Status: <span id="status">Loading...</span></p>
44
- <button class="reload-btn" onclick="window.onReloadClicked()">
45
- Reload app
46
- </button>
47
- </div>
48
- </body>
49
- </html>
@@ -1,84 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- /* global __fbBatchedBridge, importScripts */
10
- /* eslint no-unused-vars: 0 */
11
- /* eslint no-restricted-globals: 0 */
12
-
13
- onmessage = (function () {
14
- var visibilityState;
15
- var showVisibilityWarning = (function () {
16
- var hasWarned = false;
17
- return function () {
18
- // Wait until `YellowBox` gets initialized before displaying the warning.
19
- if (hasWarned || console.warn.toString().includes('[native code]')) {
20
- return;
21
- }
22
- hasWarned = true;
23
- console.warn(
24
- 'Remote debugger is in a background tab which may cause apps to ' +
25
- 'perform slowly. Fix this by foregrounding the tab (or opening it in ' +
26
- 'a separate window).'
27
- );
28
- };
29
- })();
30
-
31
- var messageHandlers = {
32
- executeApplicationScript: function (message, sendReply) {
33
- for (var key in message.inject) {
34
- self[key] = JSON.parse(message.inject[key]);
35
- }
36
- var error;
37
- try {
38
- importScripts(message.url);
39
- } catch (err) {
40
- error = err.message;
41
- }
42
- sendReply(null /* result */, error);
43
- },
44
- setDebuggerVisibility: function (message) {
45
- visibilityState = message.visibilityState;
46
- },
47
- };
48
-
49
- return function (message) {
50
- if (visibilityState === 'hidden') {
51
- showVisibilityWarning();
52
- }
53
-
54
- var object = message.data;
55
-
56
- var sendReply = function (result, error) {
57
- postMessage({ replyID: object.id, result: result, error: error });
58
- };
59
-
60
- var handler = messageHandlers[object.method];
61
- if (handler) {
62
- // Special cased handlers
63
- handler(object, sendReply);
64
- } else {
65
- // Other methods get called on the bridge
66
- var returnValue = [[], [], [], 0];
67
- var error;
68
- try {
69
- if (typeof __fbBatchedBridge === 'object') {
70
- returnValue = __fbBatchedBridge[object.method].apply(
71
- null,
72
- object.arguments
73
- );
74
- } else {
75
- error = 'Failed to call function, __fbBatchedBridge is undefined';
76
- }
77
- } catch (err) {
78
- error = err.message;
79
- } finally {
80
- sendReply(JSON.stringify(returnValue), error);
81
- }
82
- }
83
- };
84
- })();
@@ -1,37 +0,0 @@
1
- html,
2
- body {
3
- font-family: Helvetica, Verdana, sans-serif;
4
- font-size: large;
5
- font-weight: 200;
6
- height: 100%;
7
- margin: 0;
8
- padding: 0;
9
- }
10
- .shortcut {
11
- border-radius: 4px;
12
- color: #eee;
13
- background-color: #333;
14
- font-family: 'Monaco', monospace;
15
- font-size: medium;
16
- letter-spacing: 3px;
17
- padding: 4px;
18
- }
19
- .content {
20
- padding: 10px;
21
- }
22
- .reload-btn {
23
- padding: 5px 10px;
24
- }
25
- body.dark {
26
- background-color: #242424;
27
- color: #afafaf;
28
- }
29
- .dark .shortcut {
30
- color: #c1c1c1;
31
- }
32
- .dark a {
33
- color: #3b99fc;
34
- }
35
- input[type='checkbox'] {
36
- vertical-align: middle;
37
- }