@callstack/repack-dev-server 5.0.0-rc.2 → 5.0.0-rc.4

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 (88) hide show
  1. package/dist/createServer.d.ts +3 -2
  2. package/dist/createServer.js +110 -123
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.js +2 -3
  5. package/dist/plugins/api/apiPlugin.d.ts +1 -1
  6. package/dist/plugins/api/apiPlugin.js +21 -28
  7. package/dist/plugins/api/index.d.ts +1 -1
  8. package/dist/plugins/api/index.js +1 -2
  9. package/dist/plugins/compiler/compilerPlugin.d.ts +1 -1
  10. package/dist/plugins/compiler/compilerPlugin.js +53 -62
  11. package/dist/plugins/compiler/index.d.ts +2 -2
  12. package/dist/plugins/compiler/index.js +2 -3
  13. package/dist/plugins/compiler/types.d.ts +1 -1
  14. package/dist/plugins/compiler/types.js +0 -1
  15. package/dist/plugins/devtools/devtoolsPlugin.d.ts +1 -1
  16. package/dist/plugins/devtools/devtoolsPlugin.js +16 -19
  17. package/dist/plugins/devtools/index.d.ts +1 -1
  18. package/dist/plugins/devtools/index.js +1 -2
  19. package/dist/plugins/favicon/faviconPlugin.js +3 -7
  20. package/dist/plugins/favicon/index.d.ts +1 -1
  21. package/dist/plugins/favicon/index.js +1 -2
  22. package/dist/plugins/multipart/index.d.ts +2 -2
  23. package/dist/plugins/multipart/index.js +2 -3
  24. package/dist/plugins/multipart/multipartPlugin.js +44 -42
  25. package/dist/plugins/multipart/types.js +0 -1
  26. package/dist/plugins/symbolicate/Symbolicator.d.ts +1 -1
  27. package/dist/plugins/symbolicate/Symbolicator.js +172 -190
  28. package/dist/plugins/symbolicate/index.d.ts +3 -3
  29. package/dist/plugins/symbolicate/index.js +3 -4
  30. package/dist/plugins/symbolicate/sybmolicatePlugin.d.ts +1 -1
  31. package/dist/plugins/symbolicate/sybmolicatePlugin.js +29 -40
  32. package/dist/plugins/symbolicate/types.js +0 -1
  33. package/dist/plugins/wss/WebSocketRouter.d.ts +1 -1
  34. package/dist/plugins/wss/WebSocketRouter.js +39 -44
  35. package/dist/plugins/wss/WebSocketServer.d.ts +1 -1
  36. package/dist/plugins/wss/WebSocketServer.js +23 -38
  37. package/dist/plugins/wss/WebSocketServerAdapter.d.ts +1 -1
  38. package/dist/plugins/wss/WebSocketServerAdapter.js +16 -19
  39. package/dist/plugins/wss/index.d.ts +3 -3
  40. package/dist/plugins/wss/index.js +3 -4
  41. package/dist/plugins/wss/servers/WebSocketApiServer.d.ts +1 -1
  42. package/dist/plugins/wss/servers/WebSocketApiServer.js +47 -53
  43. package/dist/plugins/wss/servers/WebSocketDevClientServer.d.ts +1 -1
  44. package/dist/plugins/wss/servers/WebSocketDevClientServer.js +58 -80
  45. package/dist/plugins/wss/servers/WebSocketEventsServer.d.ts +2 -2
  46. package/dist/plugins/wss/servers/WebSocketEventsServer.js +146 -164
  47. package/dist/plugins/wss/servers/WebSocketHMRServer.d.ts +2 -2
  48. package/dist/plugins/wss/servers/WebSocketHMRServer.js +72 -79
  49. package/dist/plugins/wss/servers/WebSocketMessageServer.d.ts +1 -1
  50. package/dist/plugins/wss/servers/WebSocketMessageServer.js +309 -326
  51. package/dist/plugins/wss/types.js +0 -1
  52. package/dist/plugins/wss/wssPlugin.d.ts +8 -8
  53. package/dist/plugins/wss/wssPlugin.js +37 -42
  54. package/dist/types.d.ts +6 -6
  55. package/dist/types.js +8 -18
  56. package/package.json +4 -8
  57. package/CHANGELOG.md +0 -160
  58. package/dist/createServer.js.map +0 -1
  59. package/dist/index.js.map +0 -1
  60. package/dist/plugins/api/apiPlugin.js.map +0 -1
  61. package/dist/plugins/api/index.js.map +0 -1
  62. package/dist/plugins/compiler/compilerPlugin.js.map +0 -1
  63. package/dist/plugins/compiler/index.js.map +0 -1
  64. package/dist/plugins/compiler/types.js.map +0 -1
  65. package/dist/plugins/devtools/devtoolsPlugin.js.map +0 -1
  66. package/dist/plugins/devtools/index.js.map +0 -1
  67. package/dist/plugins/favicon/faviconPlugin.js.map +0 -1
  68. package/dist/plugins/favicon/index.js.map +0 -1
  69. package/dist/plugins/multipart/index.js.map +0 -1
  70. package/dist/plugins/multipart/multipartPlugin.js.map +0 -1
  71. package/dist/plugins/multipart/types.js.map +0 -1
  72. package/dist/plugins/symbolicate/Symbolicator.js.map +0 -1
  73. package/dist/plugins/symbolicate/index.js.map +0 -1
  74. package/dist/plugins/symbolicate/sybmolicatePlugin.js.map +0 -1
  75. package/dist/plugins/symbolicate/types.js.map +0 -1
  76. package/dist/plugins/wss/WebSocketRouter.js.map +0 -1
  77. package/dist/plugins/wss/WebSocketServer.js.map +0 -1
  78. package/dist/plugins/wss/WebSocketServerAdapter.js.map +0 -1
  79. package/dist/plugins/wss/index.js.map +0 -1
  80. package/dist/plugins/wss/servers/WebSocketApiServer.js.map +0 -1
  81. package/dist/plugins/wss/servers/WebSocketDevClientServer.js.map +0 -1
  82. package/dist/plugins/wss/servers/WebSocketEventsServer.js.map +0 -1
  83. package/dist/plugins/wss/servers/WebSocketHMRServer.js.map +0 -1
  84. package/dist/plugins/wss/servers/WebSocketMessageServer.js.map +0 -1
  85. package/dist/plugins/wss/types.js.map +0 -1
  86. package/dist/plugins/wss/wssPlugin.js.map +0 -1
  87. package/dist/types.js.map +0 -1
  88. /package/{dist/img → static}/favicon.ico +0 -0
@@ -1,12 +1,12 @@
1
1
  import type { FastifyInstance } from 'fastify';
2
- import type { Server } from '../../types';
3
- import { WebSocketRouter } from './WebSocketRouter';
4
- import { WebSocketServerAdapter } from './WebSocketServerAdapter';
5
- import { WebSocketApiServer } from './servers/WebSocketApiServer';
6
- import { WebSocketDevClientServer } from './servers/WebSocketDevClientServer';
7
- import { WebSocketEventsServer } from './servers/WebSocketEventsServer';
8
- import { WebSocketHMRServer } from './servers/WebSocketHMRServer';
9
- import { WebSocketMessageServer } from './servers/WebSocketMessageServer';
2
+ import type { Server } from '../../types.js';
3
+ import { WebSocketRouter } from './WebSocketRouter.js';
4
+ import { WebSocketServerAdapter } from './WebSocketServerAdapter.js';
5
+ import { WebSocketApiServer } from './servers/WebSocketApiServer.js';
6
+ import { WebSocketDevClientServer } from './servers/WebSocketDevClientServer.js';
7
+ import { WebSocketEventsServer } from './servers/WebSocketEventsServer.js';
8
+ import { WebSocketHMRServer } from './servers/WebSocketHMRServer.js';
9
+ import { WebSocketMessageServer } from './servers/WebSocketMessageServer.js';
10
10
  declare module 'fastify' {
11
11
  interface FastifyInstance {
12
12
  wss: {
@@ -1,52 +1,47 @@
1
1
  import fastifyPlugin from 'fastify-plugin';
2
- import { WebSocketRouter } from "./WebSocketRouter.js";
3
- import { WebSocketServerAdapter } from "./WebSocketServerAdapter.js";
4
- import { WebSocketApiServer } from "./servers/WebSocketApiServer.js";
5
- import { WebSocketDevClientServer } from "./servers/WebSocketDevClientServer.js";
6
- import { WebSocketEventsServer } from "./servers/WebSocketEventsServer.js";
7
- import { WebSocketHMRServer } from "./servers/WebSocketHMRServer.js";
8
- import { WebSocketMessageServer } from "./servers/WebSocketMessageServer.js";
2
+ import { WebSocketRouter } from './WebSocketRouter.js';
3
+ import { WebSocketServerAdapter } from './WebSocketServerAdapter.js';
4
+ import { WebSocketApiServer } from './servers/WebSocketApiServer.js';
5
+ import { WebSocketDevClientServer } from './servers/WebSocketDevClientServer.js';
6
+ import { WebSocketEventsServer } from './servers/WebSocketEventsServer.js';
7
+ import { WebSocketHMRServer } from './servers/WebSocketHMRServer.js';
8
+ import { WebSocketMessageServer } from './servers/WebSocketMessageServer.js';
9
9
  /**
10
10
  * Defined in @react-native/dev-middleware
11
11
  * Reference: https://github.com/facebook/react-native/blob/main/packages/dev-middleware/src/inspector-proxy/InspectorProxy.js
12
12
  */
13
13
  const WS_DEVICE_URL = '/inspector/device';
14
14
  const WS_DEBUGGER_URL = '/inspector/debug';
15
- async function wssPlugin(instance, {
16
- options,
17
- delegate
18
- }) {
19
- const router = new WebSocketRouter(instance);
20
- const devClientServer = new WebSocketDevClientServer(instance);
21
- const messageServer = new WebSocketMessageServer(instance);
22
- const eventsServer = new WebSocketEventsServer(instance, {
23
- webSocketMessageServer: messageServer
24
- });
25
- const apiServer = new WebSocketApiServer(instance);
26
- const hmrServer = new WebSocketHMRServer(instance, delegate.hmr);
27
-
28
- // @react-native/dev-middleware servers
29
- const deviceConnectionServer = new WebSocketServerAdapter(instance, WS_DEVICE_URL, options.endpoints?.[WS_DEVICE_URL]);
30
- const debuggerConnectionServer = new WebSocketServerAdapter(instance, WS_DEBUGGER_URL, options.endpoints?.[WS_DEBUGGER_URL]);
31
- router.registerServer(devClientServer);
32
- router.registerServer(messageServer);
33
- router.registerServer(eventsServer);
34
- router.registerServer(apiServer);
35
- router.registerServer(hmrServer);
36
- router.registerServer(deviceConnectionServer);
37
- router.registerServer(debuggerConnectionServer);
38
- instance.decorate('wss', {
39
- devClientServer,
40
- messageServer,
41
- eventsServer,
42
- apiServer,
43
- hmrServer,
44
- deviceConnectionServer,
45
- debuggerConnectionServer,
46
- router
47
- });
15
+ async function wssPlugin(instance, { options, delegate, }) {
16
+ const router = new WebSocketRouter(instance);
17
+ const devClientServer = new WebSocketDevClientServer(instance);
18
+ const messageServer = new WebSocketMessageServer(instance);
19
+ const eventsServer = new WebSocketEventsServer(instance, {
20
+ webSocketMessageServer: messageServer,
21
+ });
22
+ const apiServer = new WebSocketApiServer(instance);
23
+ const hmrServer = new WebSocketHMRServer(instance, delegate.hmr);
24
+ // @react-native/dev-middleware servers
25
+ const deviceConnectionServer = new WebSocketServerAdapter(instance, WS_DEVICE_URL, options.endpoints?.[WS_DEVICE_URL]);
26
+ const debuggerConnectionServer = new WebSocketServerAdapter(instance, WS_DEBUGGER_URL, options.endpoints?.[WS_DEBUGGER_URL]);
27
+ router.registerServer(devClientServer);
28
+ router.registerServer(messageServer);
29
+ router.registerServer(eventsServer);
30
+ router.registerServer(apiServer);
31
+ router.registerServer(hmrServer);
32
+ router.registerServer(deviceConnectionServer);
33
+ router.registerServer(debuggerConnectionServer);
34
+ instance.decorate('wss', {
35
+ devClientServer,
36
+ messageServer,
37
+ eventsServer,
38
+ apiServer,
39
+ hmrServer,
40
+ deviceConnectionServer,
41
+ debuggerConnectionServer,
42
+ router,
43
+ });
48
44
  }
49
45
  export default fastifyPlugin(wssPlugin, {
50
- name: 'wss-plugin'
46
+ name: 'wss-plugin',
51
47
  });
52
- //# sourceMappingURL=wssPlugin.js.map
package/dist/types.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import type { FastifyBaseLogger } from 'fastify';
2
2
  import type { WebSocketServer } from 'ws';
3
- import type { CompilerDelegate } from './plugins/compiler';
4
- import type { SymbolicatorDelegate } from './plugins/symbolicate';
5
- import type { HmrDelegate } from './plugins/wss';
6
- export type { CompilerDelegate } from './plugins/compiler';
7
- export type { SymbolicatorDelegate, ReactNativeStackFrame, InputStackFrame, StackFrame, CodeFrame, SymbolicatorResults, } from './plugins/symbolicate';
8
- export type { HmrDelegate } from './plugins/wss';
3
+ import type { CompilerDelegate } from './plugins/compiler/types.js';
4
+ import type { CodeFrame, InputStackFrame, ReactNativeStackFrame, StackFrame, SymbolicatorDelegate, SymbolicatorResults } from './plugins/symbolicate/types.js';
5
+ import type { HmrDelegate } from './plugins/wss/types.js';
6
+ export type { CompilerDelegate };
7
+ export type { CodeFrame, InputStackFrame, ReactNativeStackFrame, StackFrame, SymbolicatorDelegate, SymbolicatorResults, };
8
+ export type { HmrDelegate };
9
9
  export declare namespace Server {
10
10
  /** Development server configuration. */
11
11
  interface Config {
package/dist/types.js CHANGED
@@ -1,24 +1,14 @@
1
- export let Server;
2
- /** Representation of the compilation progress. */
3
- /**
4
- * Type representing a function to send the progress.
5
- *
6
- * Used by {@link CompilerDelegate} in `getAsset` function to send the compilation
7
- * progress to the client who requested the asset.
8
- */
9
1
  /**
10
2
  * Internal types. Do not use.
11
3
  *
12
4
  * @internal
13
5
  */
14
- export let Internal;
15
- (function (_Internal) {
16
- let EventTypes = /*#__PURE__*/function (EventTypes) {
17
- EventTypes["BuildStart"] = "BuildStart";
18
- EventTypes["BuildEnd"] = "BuildEnd";
19
- EventTypes["HmrEvent"] = "HmrEvent";
20
- return EventTypes;
21
- }({});
22
- _Internal.EventTypes = EventTypes;
6
+ export var Internal;
7
+ (function (Internal) {
8
+ let EventTypes;
9
+ (function (EventTypes) {
10
+ EventTypes["BuildStart"] = "BuildStart";
11
+ EventTypes["BuildEnd"] = "BuildEnd";
12
+ EventTypes["HmrEvent"] = "HmrEvent";
13
+ })(EventTypes = Internal.EventTypes || (Internal.EventTypes = {}));
23
14
  })(Internal || (Internal = {}));
24
- //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@callstack/repack-dev-server",
3
3
  "description": "A bundler-agnostic development server for React Native applications as part of @callstack/repack.",
4
4
  "license": "MIT",
5
- "version": "5.0.0-rc.2",
5
+ "version": "5.0.0-rc.4",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
@@ -12,9 +12,7 @@
12
12
  },
13
13
  "files": [
14
14
  "dist",
15
- "docs",
16
- "vendor",
17
- "CHANGELOG.md"
15
+ "static"
18
16
  ],
19
17
  "homepage": "https://github.com/callstack/repack",
20
18
  "repository": "github:callstack/repack",
@@ -53,7 +51,7 @@
53
51
  "@types/node": "18",
54
52
  "@types/ws": "^8.5.3",
55
53
  "babel-plugin-add-import-extension": "^1.6.0",
56
- "typescript": "^5.5.3"
54
+ "typescript": "^5.7.2"
57
55
  },
58
56
  "peerDependencies": {
59
57
  "@react-native-community/cli-server-api": ">=13.6.4"
@@ -64,9 +62,7 @@
64
62
  }
65
63
  },
66
64
  "scripts": {
67
- "build:js": "babel src --out-dir dist --extensions \".js,.cjs,.ts\" --source-maps --ignore \"**/__tests__/**\" --delete-dir-on-start --copy-files",
68
- "build:ts": "tsc --emitDeclarationOnly",
69
- "build": "pnpm run \"/^build:.*/\"",
65
+ "build": "tsc -b",
70
66
  "typecheck": "tsc --noEmit",
71
67
  "archive": "pnpm build && pnpm pack"
72
68
  }
package/CHANGELOG.md DELETED
@@ -1,160 +0,0 @@
1
- # @callstack/repack-dev-server
2
-
3
- ## 5.0.0-rc.2
4
-
5
- ## 5.0.0-rc.1
6
-
7
- ## 5.0.0-rc.0
8
-
9
- ## 5.0.0-alpha.0
10
-
11
- ## 4.3.3
12
-
13
- ## 4.3.2
14
-
15
- ## 4.3.1
16
-
17
- ## 4.3.0
18
-
19
- ## 4.2.0
20
-
21
- ## 4.1.1
22
-
23
- ## 4.1.0
24
-
25
- ## 4.0.0
26
-
27
- ### Major Changes
28
-
29
- - [#430](https://github.com/callstack/repack/pull/430) [`0d96b11`](https://github.com/callstack/repack/commit/0d96b11ff3a6e2c21eb622e21ff7947db29a3272) Thanks [@jbroma](https://github.com/jbroma)! - Upgrade to Node 18, drop support for Node 16
30
-
31
- - [#508](https://github.com/callstack/repack/pull/508) [`fec8962`](https://github.com/callstack/repack/commit/fec8962b45f3d744d7c41e8f6eeae0a2310c7693) Thanks [@RafikiTiki](https://github.com/RafikiTiki)! - - Fixed deprecated remote debugger integration:
32
- - Removed vendored code and used middlewares from `@react-native-community/cli-server-api`
33
- - Removed `package/debugger-app` and replaced it with `@react-native-community/cli-debugger-ui`
34
- - Removed vendored code responsible for integration with Flipper debugger & custom implementation of the Hermes Inspector Proxy
35
- - Added integration with `@react-native/dev-middleware` which enables us to use both Flipper and new experimental debugger
36
-
37
- ### Patch Changes
38
-
39
- - [#567](https://github.com/callstack/repack/pull/567) [`6417da7`](https://github.com/callstack/repack/commit/6417da7ba72e39602735062198165c998e4e19cf) Thanks [@kerm1it](https://github.com/kerm1it)! - Notify clients on all platforms when sending an HMR event update
40
-
41
- - [#554](https://github.com/callstack/repack/pull/554) [`ed82e29`](https://github.com/callstack/repack/commit/ed82e29c2871411fd73616f29a7d4b75ff3dd913) Thanks [@jbroma](https://github.com/jbroma)! - Fix path to `favicon.ico` on Windows
42
-
43
- - [#464](https://github.com/callstack/repack/pull/464) [`72c770b`](https://github.com/callstack/repack/commit/72c770bb4ac5540a3c73cf244ca861069a37b045) Thanks [@jbroma](https://github.com/jbroma)! - Upgrade TypeScript, ESLint, TypeDoc in the repository
44
-
45
- ## 4.0.0-rc.2
46
-
47
- ## 4.0.0-rc.1
48
-
49
- ### Patch Changes
50
-
51
- - [#554](https://github.com/callstack/repack/pull/554) [`ed82e29`](https://github.com/callstack/repack/commit/ed82e29c2871411fd73616f29a7d4b75ff3dd913) Thanks [@jbroma](https://github.com/jbroma)! - Fix path to favicon.ico on Windows
52
-
53
- ## 4.0.0-rc.0
54
-
55
- ### Major Changes
56
-
57
- - [#430](https://github.com/callstack/repack/pull/430) [`0d96b11`](https://github.com/callstack/repack/commit/0d96b11ff3a6e2c21eb622e21ff7947db29a3272) Thanks [@jbroma](https://github.com/jbroma)! - BREAKING CHANGE: Upgrade to Node 18, drop support for Node 16.
58
-
59
- ### Patch Changes
60
-
61
- - [#464](https://github.com/callstack/repack/pull/464) [`72c770b`](https://github.com/callstack/repack/commit/72c770bb4ac5540a3c73cf244ca861069a37b045) Thanks [@jbroma](https://github.com/jbroma)! - chore: upgrade TypeScript, ESLint, TypeDoc
62
-
63
- ## 1.1.0
64
-
65
- ### Minor Changes
66
-
67
- - [#475](https://github.com/callstack/repack/pull/475) [`cc997a2`](https://github.com/callstack/repack/commit/cc997a2f84b4835f8fe597487b0cde6f41b4b7f0) Thanks [@szymonrybczak](https://github.com/szymonrybczak)! - Added X-React-Native-Project-Root header, so the RN CLI picks up the running bundler correctly
68
-
69
- ## 1.0.2
70
-
71
- ### Patch Changes
72
-
73
- - [#441](https://github.com/callstack/repack/pull/441) [`a66785d`](https://github.com/callstack/repack/commit/a66785d4bdb629ab9abce2bf5fc0dc4b632072ef) Thanks [@hexboy](https://github.com/hexboy)! - fix(dev-server): fix Failed to open stack frame in editor error
74
-
75
- * [#426](https://github.com/callstack/repack/pull/426) [`719c2ef`](https://github.com/callstack/repack/commit/719c2ef3e1af0c82de8042de2c5c21ab88a287ea) Thanks [@jbroma](https://github.com/jbroma)! - Upgraded source-map to 0.7.4
76
-
77
- ## 1.0.1
78
-
79
- ### Patch Changes
80
-
81
- - [#308](https://github.com/callstack/repack/pull/308) [`ad9581a`](https://github.com/callstack/repack/commit/ad9581a6d690b128991a9d64374ecb4b8d49c413) Thanks [@jbroma](https://github.com/jbroma)! - Make all packages compatible with Node v18
82
-
83
- - Updated dependencies [[`ad9581a`](https://github.com/callstack/repack/commit/ad9581a6d690b128991a9d64374ecb4b8d49c413)]:
84
- - @callstack/repack-debugger-app@1.0.2
85
-
86
- ## 1.0.0
87
-
88
- ### Major Changes
89
-
90
- - [#186](https://github.com/callstack/repack/pull/186) [`05d126e`](https://github.com/callstack/repack/commit/05d126e63802f0702a9e353e762f8b6a77fcd73e) Thanks [@zamotany](https://github.com/zamotany)! - ### Bundler-agnostic development server
91
-
92
- Extracted development server from `@callstack/repack` into a separate package and made it bundler-agnostic.
93
-
94
- ### Minor Changes
95
-
96
- - [#189](https://github.com/callstack/repack/pull/189) [`bc42023`](https://github.com/callstack/repack/commit/bc420236687047752cf1ee42204b2f510aec144a) Thanks [@zamotany](https://github.com/zamotany)! - ### Development server API
97
-
98
- Added API endpoints to `@callstack/repack-dev-server`:
99
-
100
- - `GET /api/platforms` - List all platforms with active compilations
101
- - `GET /api/:platform/assets` - List all assets (`name` and `size`) for a given compilation
102
- - `GET /api/:platform/stats` - Get compilation stats
103
- - Websocket server under `/api` URI for logs and compilations events
104
-
105
- * [#230](https://github.com/callstack/repack/pull/230) [`e6dc69d`](https://github.com/callstack/repack/commit/e6dc69d35f287af08d09944edd8e6d12f28484cf) Thanks [@jbinda](https://github.com/jbinda)! - Introduce `fastify-favicon` plugin to prevent server logger from emitting error log related to `GET 400 /favicon.ico` when requesting bundles via browser.
106
-
107
- - [#239](https://github.com/callstack/repack/pull/239) [`6d65156`](https://github.com/callstack/repack/commit/6d65156366bc88edefdae7a3d0310ddbcdf48886) Thanks [@jbinda](https://github.com/jbinda)! - Expose favicon.ico in devserver
108
-
109
- ### Patch Changes
110
-
111
- - [#238](https://github.com/callstack/repack/pull/238) [`b913b89`](https://github.com/callstack/repack/commit/b913b8981334854cc13076af2a9c8a12bc465d1b) Thanks [@jbinda](https://github.com/jbinda)! - Add `archive` script in dev-server
112
-
113
- * [#200](https://github.com/callstack/repack/pull/200) [`c75cdc7`](https://github.com/callstack/repack/commit/c75cdc7a44351bb4702232e603031e2880f2839d) Thanks [@zamotany](https://github.com/zamotany)! - Prevent server logger from emitting log to API WS server before WS servers are created.
114
-
115
- * Updated dependencies [[`05d126e`](https://github.com/callstack/repack/commit/05d126e63802f0702a9e353e762f8b6a77fcd73e)]:
116
- - @callstack/repack-debugger-app@1.0.0
117
-
118
- ## 1.0.0-next.3
119
-
120
- ### Minor Changes
121
-
122
- - [#230](https://github.com/callstack/repack/pull/230) [`e6dc69d`](https://github.com/callstack/repack/commit/e6dc69d35f287af08d09944edd8e6d12f28484cf) Thanks [@jbinda](https://github.com/jbinda)! - Introduce `fastify-favicon` plugin to prevent server logger from emitting error log related to `GET 400 /favicon.ico` when requesting bundles via browser.
123
-
124
- * [#239](https://github.com/callstack/repack/pull/239) [`6d65156`](https://github.com/callstack/repack/commit/6d65156366bc88edefdae7a3d0310ddbcdf48886) Thanks [@jbinda](https://github.com/jbinda)! - Expose favicon.ico in devserver
125
-
126
- ### Patch Changes
127
-
128
- - [#238](https://github.com/callstack/repack/pull/238) [`b913b89`](https://github.com/callstack/repack/commit/b913b8981334854cc13076af2a9c8a12bc465d1b) Thanks [@jbinda](https://github.com/jbinda)! - Add `archive` script in dev-server
129
-
130
- ## 1.0.0-next.2
131
-
132
- ### Patch Changes
133
-
134
- - [#200](https://github.com/callstack/repack/pull/200) [`c75cdc7`](https://github.com/callstack/repack/commit/c75cdc7a44351bb4702232e603031e2880f2839d) Thanks [@zamotany](https://github.com/zamotany)! - Prevent server logger from emitting log to API WS server before WS servers are created.
135
-
136
- ## 1.0.0-next.1
137
-
138
- ### Minor Changes
139
-
140
- - ### Development server API
141
-
142
- Added API endpoints to `@callstack/repack-dev-server`:
143
-
144
- - `GET /api/platforms` - List all platforms with active compilations
145
- - `GET /api/:platform/assets` - List all assets (`name` and `size`) for a given compilation
146
- - `GET /api/:platform/stats` - Get compilation stats
147
- - Websocket server under `/api` URI for logs and compilations events
148
-
149
- ## 1.0.0-next.0
150
-
151
- ### Major Changes
152
-
153
- - ### Bundler-agnostic development server
154
-
155
- Extracted development server from `@callstack/repack` into a separate package and made it bundler-agnostic.
156
-
157
- ### Patch Changes
158
-
159
- - Updated dependencies []:
160
- - @callstack/repack-debugger-app@1.0.0-next.0
@@ -1 +0,0 @@
1
- {"version":3,"file":"createServer.js","names":["Writable","middie","fastifySensible","createDevMiddleware","Fastify","apiPlugin","compilerPlugin","devtoolsPlugin","faviconPlugin","multipartPlugin","symbolicatePlugin","wssPlugin","Internal","createServer","config","delegate","instance","disableRequestLogging","options","logRequests","logger","level","stream","write","chunk","_encoding","callback","log","JSON","parse","toString","onMessage","wss","apiServer","send","https","undefined","notifyBuildStart","platform","event","EventTypes","BuildStart","notifyBuildEnd","BuildEnd","broadcastToHmrClients","clientIds","hmrServer","broadcastToMessageClients","method","params","messageServer","broadcast","devMiddleware","projectRoot","rootDir","serverBaseUrl","host","port","unstable_experiments","enableNewDebugger","register","endpoints","websocketEndpoints","prefix","addHook","request","reply","payload","header","pathname","url","split","endsWith","use","middleware","get","messages","getHello","getStatus","start","listen","stop","close"],"sources":["../src/createServer.ts"],"sourcesContent":["import { Writable } from 'node:stream';\nimport middie from '@fastify/middie';\nimport fastifySensible from '@fastify/sensible';\nimport { createDevMiddleware } from '@react-native/dev-middleware';\nimport Fastify from 'fastify';\nimport apiPlugin from './plugins/api';\nimport compilerPlugin from './plugins/compiler';\nimport devtoolsPlugin from './plugins/devtools';\nimport faviconPlugin from './plugins/favicon';\nimport multipartPlugin from './plugins/multipart';\nimport symbolicatePlugin from './plugins/symbolicate';\nimport wssPlugin from './plugins/wss';\nimport { Internal, type Server } from './types';\n\n/**\n * Create instance of development server, powered by Fastify.\n *\n * @param config Server configuration.\n * @returns `start` and `stop` functions as well as an underlying Fastify `instance`.\n */\nexport async function createServer(config: Server.Config) {\n // biome-ignore lint/style/useConst: needed in fastify constructor\n let delegate: Server.Delegate;\n\n /** Fastify instance powering the development server. */\n const instance = Fastify({\n disableRequestLogging: !config.options.logRequests,\n logger: {\n level: 'trace',\n stream: new Writable({\n write: (chunk, _encoding, callback) => {\n const log = JSON.parse(chunk.toString());\n delegate?.logger.onMessage(log);\n instance.wss?.apiServer.send(log);\n callback();\n },\n }),\n },\n ...(config.options.https ? { https: config.options.https } : undefined),\n });\n\n delegate = await config.delegate({\n log: instance.log,\n notifyBuildStart: (platform) => {\n instance.wss.apiServer.send({\n event: Internal.EventTypes.BuildStart,\n platform,\n });\n },\n notifyBuildEnd: (platform) => {\n instance.wss.apiServer.send({\n event: Internal.EventTypes.BuildEnd,\n platform,\n });\n },\n broadcastToHmrClients: (event, platform, clientIds) => {\n instance.wss.hmrServer.send(event, platform, clientIds);\n },\n broadcastToMessageClients: ({ method, params }) => {\n instance.wss.messageServer.broadcast(method, params);\n },\n });\n\n const devMiddleware = createDevMiddleware({\n projectRoot: config.options.rootDir,\n serverBaseUrl: `http://${config.options.host}:${config.options.port}`,\n logger: instance.log,\n unstable_experiments: {\n // @ts-expect-error removed in 0.76, keep this for backkwards compatibility\n enableNewDebugger: true,\n },\n });\n\n // Register plugins\n await instance.register(fastifySensible);\n await instance.register(middie);\n await instance.register(wssPlugin, {\n options: {\n ...config.options,\n endpoints: devMiddleware.websocketEndpoints,\n },\n delegate,\n });\n await instance.register(multipartPlugin);\n await instance.register(apiPlugin, {\n delegate,\n prefix: '/api',\n });\n await instance.register(compilerPlugin, {\n delegate,\n });\n await instance.register(devtoolsPlugin, {\n options: config.options,\n });\n await instance.register(symbolicatePlugin, {\n delegate,\n });\n\n // below is to prevent showing `GET 400 /favicon.ico`\n // errors in console when requesting the bundle via browser\n await instance.register(faviconPlugin);\n\n instance.addHook('onSend', async (request, reply, payload) => {\n reply.header('X-Content-Type-Options', 'nosniff');\n reply.header('X-React-Native-Project-Root', config.options.rootDir);\n\n const [pathname] = request.url.split('?');\n if (pathname.endsWith('.map')) {\n reply.header('Access-Control-Allow-Origin', 'devtools://devtools');\n }\n\n return payload;\n });\n\n // Register dev middleware\n instance.use(devMiddleware.middleware);\n\n // Register routes\n instance.get('/', async () => delegate.messages.getHello());\n instance.get('/status', async () => delegate.messages.getStatus());\n\n /** Start the development server. */\n async function start() {\n await instance.listen({\n port: config.options.port,\n host: config.options.host,\n });\n }\n\n /** Stop the development server. */\n async function stop() {\n await instance.close();\n }\n\n return {\n start,\n stop,\n instance,\n };\n}\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,aAAa;AACtC,OAAOC,MAAM,MAAM,iBAAiB;AACpC,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,SAASC,mBAAmB,QAAQ,8BAA8B;AAClE,OAAOC,OAAO,MAAM,SAAS;AAAC,OACvBC,SAAS;AAAA,OACTC,cAAc;AAAA,OACdC,cAAc;AAAA,OACdC,aAAa;AAAA,OACbC,eAAe;AAAA,OACfC,iBAAiB;AAAA,OACjBC,SAAS;AAAA,SACPC,QAAQ;AAEjB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAACC,MAAqB,EAAE;EACxD;EACA,IAAIC,QAAyB;;EAE7B;EACA,MAAMC,QAAQ,GAAGZ,OAAO,CAAC;IACvBa,qBAAqB,EAAE,CAACH,MAAM,CAACI,OAAO,CAACC,WAAW;IAClDC,MAAM,EAAE;MACNC,KAAK,EAAE,OAAO;MACdC,MAAM,EAAE,IAAItB,QAAQ,CAAC;QACnBuB,KAAK,EAAEA,CAACC,KAAK,EAAEC,SAAS,EAAEC,QAAQ,KAAK;UACrC,MAAMC,GAAG,GAAGC,IAAI,CAACC,KAAK,CAACL,KAAK,CAACM,QAAQ,CAAC,CAAC,CAAC;UACxCf,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CAACoC,OAAO,CAAC;IAEnE,MAAM,CAACe,QAAQ,CAAC,GAAGJ,OAAO,CAACK,GAAG,CAACC,KAAK,CAAC,GAAG,CAAC;IACzC,IAAIF,QAAQ,CAACG,QAAQ,CAAC,MAAM,CAAC,EAAE;MAC7BN,KAAK,CAACE,MAAM,CAAC,6BAA6B,EAAE,qBAAqB,CAAC;IACpE;IAEA,OAAOD,OAAO;EAChB,CAAC,CAAC;;EAEF;EACAnD,QAAQ,CAACyD,GAAG,CAACrB,aAAa,CAACsB,UAAU,CAAC;;EAEtC;EACA1D,QAAQ,CAAC2D,GAAG,CAAC,GAAG,EAAE,YAAY5D,QAAQ,CAAC6D,QAAQ,CAACC,QAAQ,CAAC,CAAC,CAAC;EAC3D7D,QAAQ,CAAC2D,GAAG,CAAC,SAAS,EAAE,YAAY5D,QAAQ,CAAC6D,QAAQ,CAACE,SAAS,CAAC,CAAC,CAAC;;EAElE;EACA,eAAeC,KAAKA,CAAA,EAAG;IACrB,MAAM/D,QAAQ,CAACgE,MAAM,CAAC;MACpBvB,IAAI,EAAE3C,MAAM,CAACI,OAAO,CAACuC,IAAI;MACzBD,IAAI,EAAE1C,MAAM,CAACI,OAAO,CAACsC;IACvB,CAAC,CAAC;EACJ;;EAEA;EACA,eAAeyB,IAAIA,CAAA,EAAG;IACpB,MAAMjE,QAAQ,CAACkE,KAAK,CAAC,CAAC;EACxB;EAEA,OAAO;IACLH,KAAK;IACLE,IAAI;IACJjE;EACF,CAAC;AACH","ignoreList":[]}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from './createServer';\nexport * from './types';\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"apiPlugin.js","names":["paramsSchema","type","properties","platform","required","apiPlugin","instance","delegate","get","_request","reply","api","send","data","getPlatforms","notImplemented","schema","params","request","getAssets","getCompilationStats"],"sources":["../../../src/plugins/api/apiPlugin.ts"],"sourcesContent":["import type { FastifyInstance } from 'fastify';\nimport type { Server } from '../../types';\n\nconst paramsSchema = {\n type: 'object',\n properties: {\n platform: {\n type: 'string',\n },\n },\n required: ['platform'],\n};\n\ntype Params = { platform: string };\n\nasync function apiPlugin(\n instance: FastifyInstance,\n { delegate }: { delegate: Server.Delegate }\n) {\n instance.get('/platforms', async (_request, reply) =>\n delegate.api\n ? reply.send({ data: await delegate.api.getPlatforms() })\n : reply.notImplemented('Missing API delegate implementation')\n );\n\n instance.get<{ Params: Params }>(\n '/:platform/assets',\n { schema: { params: paramsSchema } },\n async (request, reply) =>\n delegate.api\n ? reply.send({\n data: await delegate.api.getAssets(request.params.platform),\n })\n : reply.notImplemented('Missing API delegate implementation')\n );\n\n instance.get<{ Params: Params }>(\n '/:platform/stats',\n { schema: { params: paramsSchema } },\n async (request, reply) =>\n delegate.api\n ? reply.send({\n data: await delegate.api?.getCompilationStats(\n request.params.platform\n ),\n })\n : reply.notImplemented('Missing API delegate implementation')\n );\n}\n\nexport default apiPlugin;\n"],"mappings":"AAGA,MAAMA,YAAY,GAAG;EACnBC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE;IACVC,QAAQ,EAAE;MACRF,IAAI,EAAE;IACR;EACF,CAAC;EACDG,QAAQ,EAAE,CAAC,UAAU;AACvB,CAAC;AAID,eAAeC,SAASA,CACtBC,QAAyB,EACzB;EAAEC;AAAwC,CAAC,EAC3C;EACAD,QAAQ,CAACE,GAAG,CAAC,YAAY,EAAE,OAAOC,QAAQ,EAAEC,KAAK,KAC/CH,QAAQ,CAACI,GAAG,GACRD,KAAK,CAACE,IAAI,CAAC;IAAEC,IAAI,EAAE,MAAMN,QAAQ,CAACI,GAAG,CAACG,YAAY,CAAC;EAAE,CAAC,CAAC,GACvDJ,KAAK,CAACK,cAAc,CAAC,qCAAqC,CAChE,CAAC;EAEDT,QAAQ,CAACE,GAAG,CACV,mBAAmB,EACnB;IAAEQ,MAAM,EAAE;MAAEC,MAAM,EAAEjB;IAAa;EAAE,CAAC,EACpC,OAAOkB,OAAO,EAAER,KAAK,KACnBH,QAAQ,CAACI,GAAG,GACRD,KAAK,CAACE,IAAI,CAAC;IACTC,IAAI,EAAE,MAAMN,QAAQ,CAACI,GAAG,CAACQ,SAAS,CAACD,OAAO,CAACD,MAAM,CAACd,QAAQ;EAC5D,CAAC,CAAC,GACFO,KAAK,CAACK,cAAc,CAAC,qCAAqC,CAClE,CAAC;EAEDT,QAAQ,CAACE,GAAG,CACV,kBAAkB,EAClB;IAAEQ,MAAM,EAAE;MAAEC,MAAM,EAAEjB;IAAa;EAAE,CAAC,EACpC,OAAOkB,OAAO,EAAER,KAAK,KACnBH,QAAQ,CAACI,GAAG,GACRD,KAAK,CAACE,IAAI,CAAC;IACTC,IAAI,EAAE,MAAMN,QAAQ,CAACI,GAAG,EAAES,mBAAmB,CAC3CF,OAAO,CAACD,MAAM,CAACd,QACjB;EACF,CAAC,CAAC,GACFO,KAAK,CAACK,cAAc,CAAC,qCAAqC,CAClE,CAAC;AACH;AAEA,eAAeV,SAAS","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["default"],"sources":["../../../src/plugins/api/index.ts"],"sourcesContent":["export { default } from './apiPlugin';\n"],"mappings":"SAASA,OAAO","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"compilerPlugin.js","names":["fastifyPlugin","compilerPlugin","instance","delegate","route","method","url","schema","querystring","type","properties","platform","handler","request","reply","filename","params","query","log","error","notFound","compiler","inferPlatform","multipart","asMultipart","sendProgress","completed","total","writeChunk","JSON","stringify","done","asset","getAsset","mimeType","getMimeType","buffer","Buffer","isBuffer","from","setHeader","String","byteLength","end","code","send","message","name","dependencies"],"sources":["../../../src/plugins/compiler/compilerPlugin.ts"],"sourcesContent":["import type { FastifyInstance } from 'fastify';\nimport fastifyPlugin from 'fastify-plugin';\nimport type { Server } from '../../types';\nimport type { SendProgress } from '../../types';\n\nasync function compilerPlugin(\n instance: FastifyInstance,\n { delegate }: { delegate: Server.Delegate }\n) {\n instance.route({\n method: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'HEAD'],\n url: '/*',\n schema: {\n querystring: {\n type: 'object',\n properties: {\n platform: {\n type: 'string',\n },\n },\n },\n },\n handler: async (request, reply) => {\n const filename = (request.params as { '*'?: string })['*'];\n let { platform } = request.query as { platform?: string };\n\n if (!filename) {\n // This technically should never happen - this route should not be called if file is missing.\n request.log.error('File was not provided');\n return reply.notFound();\n }\n\n // Let consumer infer the platform. If function is not provided fallback\n // to platform query param.\n platform = delegate.compiler.inferPlatform?.(request.url) ?? platform;\n\n const multipart = reply.asMultipart();\n\n const sendProgress: SendProgress = ({ completed, total }) => {\n multipart?.writeChunk(\n { 'Content-Type': 'application/json' },\n JSON.stringify({\n done: completed,\n total,\n })\n );\n };\n\n try {\n const asset = await delegate.compiler.getAsset(\n filename,\n platform,\n sendProgress\n );\n const mimeType = delegate.compiler.getMimeType(\n filename,\n platform,\n asset\n );\n\n if (multipart) {\n const buffer = Buffer.isBuffer(asset) ? asset : Buffer.from(asset);\n multipart.setHeader('Content-Type', `${mimeType}; charset=UTF-8`);\n multipart.setHeader(\n 'Content-Length',\n String(Buffer.byteLength(buffer))\n );\n multipart.end(buffer);\n } else {\n return reply.code(200).type(mimeType).send(asset);\n }\n } catch (error) {\n request.log.error(error);\n return reply.notFound((error as Error).message);\n }\n },\n });\n}\n\nexport default fastifyPlugin(compilerPlugin, {\n name: 'compiler-plugin',\n dependencies: ['@fastify/sensible', 'multipart-plugin'],\n});\n"],"mappings":"AACA,OAAOA,aAAa,MAAM,gBAAgB;AAI1C,eAAeC,cAAcA,CAC3BC,QAAyB,EACzB;EAAEC;AAAwC,CAAC,EAC3C;EACAD,QAAQ,CAACE,KAAK,CAAC;IACbC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC;IAC3DC,GAAG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M,CAACE,IAAI,CAACP,KAAK,CAAC;UAClET,SAAS,CAACiB,SAAS,CAAC,cAAc,EAAE,GAAGN,QAAQ,iBAAiB,CAAC;UACjEX,SAAS,CAACiB,SAAS,CACjB,gBAAgB,EAChBC,MAAM,CAACJ,MAAM,CAACK,UAAU,CAACN,MAAM,CAAC,CAClC,CAAC;UACDb,SAAS,CAACoB,GAAG,CAACP,MAAM,CAAC;QACvB,CAAC,MAAM;UACL,OAAOtB,KAAK,CAAC8B,IAAI,CAAC,GAAG,CAAC,CAACnC,IAAI,CAACyB,QAAQ,CAAC,CAACW,IAAI,CAACb,KAAK,CAAC;QACnD;MACF,CAAC,CAAC,OAAOb,KAAK,EAAE;QACdN,OAAO,CAACK,GAAG,CAACC,KAAK,CAACA,KAAK,CAAC;QACxB,OAAOL,KAAK,CAACM,QAAQ,CAAED,KAAK,CAAW2B,OAAO,CAAC;MACjD;IACF;EACF,CAAC,CAAC;AACJ;AAEA,eAAe9C,aAAa,CAACC,cAAc,EAAE;EAC3C8C,IAAI,EAAE,iBAAiB;EACvBC,YAAY,EAAE,CAAC,mBAAmB,EAAE,kBAAkB;AACxD,CAAC,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["default"],"sources":["../../../src/plugins/compiler/index.ts"],"sourcesContent":["export { default } from './compilerPlugin';\nexport * from './types';\n"],"mappings":"SAASA,OAAO;AAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/plugins/compiler/types.ts"],"sourcesContent":["import type { SendProgress } from '../../types';\n\n/**\n * Delegate with implementation for compiler-specific functions.\n */\nexport interface CompilerDelegate {\n /**\n * Get compiled asset content.\n *\n * If the compilation is in progress, it should wait until compilation finishes and then return the asset.\n *\n * @param filename Filename of the asset to get.\n * @param platform Platform of the asset to get.\n * @param sendProgress Function to notify the client who requested the asset about compilation progress.\n */\n getAsset: (\n filename: string,\n platform: string | undefined,\n sendProgress?: SendProgress\n ) => Promise<string | Buffer>;\n\n /**\n * Detect MIME type of the asset from `filename`, `platform` or `data` (or from combination of either).\n *\n * @param filename Filename of the asset.\n * @param platform Platform of the asset.\n * @param data Asset's content.\n */\n getMimeType: (\n filename: string,\n platform: string | undefined,\n data: string | Buffer\n ) => string;\n\n /**\n * Detect the platform from the URI - either from filename, query params or both.\n *\n * @param uri URI string.\n */\n inferPlatform?: (uri: string) => string | undefined;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"devtoolsPlugin.js","names":["openStackFrameInEditorMiddleware","openURLMiddleware","fastifyPlugin","devtoolsPlugin","instance","options","use","watchFolders","rootDir","route","method","url","handler","_request","reply","wss","messageServer","broadcast","send","name","dependencies"],"sources":["../../../src/plugins/devtools/devtoolsPlugin.ts"],"sourcesContent":["import {\n openStackFrameInEditorMiddleware,\n openURLMiddleware,\n} from '@react-native-community/cli-server-api';\nimport type { FastifyInstance } from 'fastify';\nimport fastifyPlugin from 'fastify-plugin';\nimport type { Server } from '../../types';\n\nasync function devtoolsPlugin(\n instance: FastifyInstance,\n { options }: { options: Server.Options }\n) {\n instance.use('/open-url', openURLMiddleware);\n\n instance.use(\n '/open-stack-frame',\n openStackFrameInEditorMiddleware({\n watchFolders: [options.rootDir],\n })\n );\n\n instance.route({\n method: ['GET', 'POST', 'PUT'],\n url: '/reload',\n handler: (_request, reply) => {\n instance.wss.messageServer.broadcast('reload');\n reply.send('OK');\n },\n });\n}\n\nexport default fastifyPlugin(devtoolsPlugin, {\n name: 'devtools-plugin',\n dependencies: ['wss-plugin'],\n});\n"],"mappings":"AAAA,SACEA,gCAAgC,EAChCC,iBAAiB,QACZ,wCAAwC;AAE/C,OAAOC,aAAa,MAAM,gBAAgB;AAG1C,eAAeC,cAAcA,CAC3BC,QAAyB,EACzB;EAAEC;AAAqC,CAAC,EACxC;EACAD,QAAQ,CAACE,GAAG,CAAC,WAAW,EAAEL,iBAAiB,CAAC;EAE5CG,QAAQ,CAACE,GAAG,CACV,mBAAmB,EACnBN,gCAAgC,CAAC;IAC/BO,YAAY,EAAE,CAACF,OAAO,CAACG,OAAO;EAChC,CAAC,CACH,CAAC;EAEDJ,QAAQ,CAACK,KAAK,CAAC;IACbC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC;IAC9BC,GAAG,EAAE,SAAS;IACdC,OAAO,EAAEA,CAACC,QAAQ,EAAEC,KAAK,KAAK;MAC5BV,QAAQ,CAACW,GAAG,CAACC,aAAa,CAACC,SAAS,CAAC,QAAQ,CAAC;MAC9CH,KAAK,CAACI,IAAI,CAAC,IAAI,CAAC;IAClB;EACF,CAAC,CAAC;AACJ;AAEA,eAAehB,aAAa,CAACC,cAAc,EAAE;EAC3CgB,IAAI,EAAE,iBAAiB;EACvBC,YAAY,EAAE,CAAC,YAAY;AAC7B,CAAC,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["default"],"sources":["../../../src/plugins/devtools/index.ts"],"sourcesContent":["export { default } from './devtoolsPlugin';\n"],"mappings":"SAASA,OAAO","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"faviconPlugin.js","names":["path","fileURLToPath","fastifyFavicon","fastifyPlugin","dirname","import","meta","url","pathToImgDir","join","faviconPlugin","instance","register","name"],"sources":["../../../src/plugins/favicon/faviconPlugin.ts"],"sourcesContent":["import path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { FastifyInstance } from 'fastify';\nimport fastifyFavicon from 'fastify-favicon';\nimport fastifyPlugin from 'fastify-plugin';\n\n// @ts-ignore\nconst dirname = path.dirname(fileURLToPath(import.meta.url));\nconst pathToImgDir = path.join(dirname, '../../img');\n\nasync function faviconPlugin(instance: FastifyInstance) {\n instance.register(fastifyFavicon, { path: pathToImgDir });\n}\n\nexport default fastifyPlugin(faviconPlugin, {\n name: 'favicon-plugin',\n});\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,WAAW;AAC5B,SAASC,aAAa,QAAQ,UAAU;AAExC,OAAOC,cAAc,MAAM,iBAAiB;AAC5C,OAAOC,aAAa,MAAM,gBAAgB;;AAE1C;AACA,MAAMC,OAAO,GAAGJ,IAAI,CAACI,OAAO,CAACH,aAAa,CAACI,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC;AAC5D,MAAMC,YAAY,GAAGR,IAAI,CAACS,IAAI,CAACL,OAAO,EAAE,WAAW,CAAC;AAEpD,eAAeM,aAAaA,CAACC,QAAyB,EAAE;EACtDA,QAAQ,CAACC,QAAQ,CAACV,cAAc,EAAE;IAAEF,IAAI,EAAEQ;EAAa,CAAC,CAAC;AAC3D;AAEA,eAAeL,aAAa,CAACO,aAAa,EAAE;EAC1CG,IAAI,EAAE;AACR,CAAC,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["default"],"sources":["../../../src/plugins/favicon/index.ts"],"sourcesContent":["export { default } from './faviconPlugin';\n"],"mappings":"SAASA,OAAO","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["default"],"sources":["../../../src/plugins/multipart/index.ts"],"sourcesContent":["export { default } from './multipartPlugin';\nexport * from './types';\n"],"mappings":"SAASA,OAAO;AAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"multipartPlugin.js","names":["PassThrough","fastifyPlugin","CRLF","BOUNDARY","multipartPlugin","instance","asMultipart","request","headers","accept","undefined","stream","code","header","send","serializeHeaders","Object","keys","map","key","join","writeChunk","data","isLast","chunk","write","setHeader","name","value","end","decorateReply"],"sources":["../../../src/plugins/multipart/multipartPlugin.ts"],"sourcesContent":["import type { IncomingHttpHeaders } from 'node:http';\nimport { PassThrough } from 'node:stream';\nimport type { FastifyInstance, FastifyReply } from 'fastify';\nimport fastifyPlugin from 'fastify-plugin';\nimport type { MultipartHandler } from './types';\n\n/**\n * Implementation is based on:\n * https://github.com/facebook/metro/blob/347b1d7ed87995d7951aaa9fd597c04b06013dac/packages/metro/src/Server/MultipartResponse.js\n */\n\nconst CRLF = '\\r\\n';\nconst BOUNDARY = '3beqjf3apnqeu3h5jqorms4i';\n\nasync function multipartPlugin(instance: FastifyInstance) {\n function asMultipart(this: FastifyReply): MultipartHandler | undefined {\n // We should check if is included in accept or if accept has multipart/* or */*,\n // but React Native will set accept to exactly `multipart/mixed`, so a simple check\n // will suffice.\n if (this.request.headers.accept !== 'multipart/mixed') {\n return undefined;\n }\n\n const headers: IncomingHttpHeaders = {};\n const stream = new PassThrough();\n\n this.code(200)\n .header('Content-Type', `multipart/mixed; boundary=\"${BOUNDARY}\"`)\n .send(stream);\n\n function serializeHeaders(headers: IncomingHttpHeaders) {\n return Object.keys(headers)\n .map((key) => `${key}: ${headers[key]}`)\n .join(CRLF);\n }\n\n function writeChunk<T>(\n headers: IncomingHttpHeaders,\n data: T,\n isLast?: boolean\n ) {\n let chunk = `${CRLF}--${BOUNDARY}${CRLF}`;\n if (headers) {\n chunk += serializeHeaders(headers) + CRLF + CRLF;\n }\n\n if (data) {\n chunk += data;\n }\n\n if (isLast) {\n chunk += `${CRLF}--${BOUNDARY}--${CRLF}`;\n }\n\n stream.write(chunk);\n }\n\n function setHeader(name: string, value: string | string[] | undefined) {\n headers[name] = value;\n }\n\n function end<T>(data: T) {\n writeChunk(headers, data, true);\n stream.end();\n }\n\n return {\n writeChunk,\n setHeader,\n end,\n };\n }\n\n instance.decorateReply('asMultipart', asMultipart);\n}\n\nexport default fastifyPlugin(multipartPlugin, {\n name: 'multipart-plugin',\n});\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,aAAa;AAEzC,OAAOC,aAAa,MAAM,gBAAgB;AAG1C;AACA;AACA;AACA;;AAEA,MAAMC,IAAI,GAAG,MAAM;AACnB,MAAMC,QAAQ,GAAG,0BAA0B;AAE3C,eAAeC,eAAeA,CAACC,QAAyB,EAAE;EACxD,SAASC,WAAWA,CAAA,EAAmD;IACrE;IACA;IACA;IACA,IAAI,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O;MACLR,UAAU;MACVK,SAAS;MACTG;IACF,CAAC;EACH;EAEAxB,QAAQ,CAACyB,aAAa,CAAC,aAAa,EAAExB,WAAW,CAAC;AACpD;AAEA,eAAeL,aAAa,CAACG,eAAe,EAAE;EAC5CuB,IAAI,EAAE;AACR,CAAC,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/plugins/multipart/types.ts"],"sourcesContent":["import type { IncomingHttpHeaders } from 'node:http';\n\nexport interface MultipartHandler {\n writeChunk: <T>(\n headers: IncomingHttpHeaders,\n data: T,\n isLast?: boolean\n ) => void;\n setHeader: (name: string, value: string | string[] | undefined) => void;\n end: <T>(data: T) => void;\n}\n\ndeclare module 'fastify' {\n interface FastifyReply {\n asMultipart: () => MultipartHandler | undefined;\n }\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Symbolicator.js","names":["URL","codeFrameColumns","SourceMapConsumer","Symbolicator","inferPlatformFromStack","stack","frame","file","searchParams","pathname","platform","get","bundleFilename","split","reverse","platformOrExtension","extension","sourceMapConsumerCache","constructor","delegate","process","logger","debug","msg","frames","startsWith","push","processedFrames","fileUrl","rawSourceMap","getSourceMap","sourceMapLength","length","sourceMapConsumer","toString","processedFrame","processFrame","codeFrame","getCodeFrame","key","destroy","lineNumber","column","collapse","consumer","lookup","originalPositionFor","line","bias","LEAST_UPPER_BOUND","source","methodName","name","shouldIncludeFrame","undefined","content","getSource","start","forceColor","location","row","fileName","error","message"],"sources":["../../../src/plugins/symbolicate/Symbolicator.ts"],"sourcesContent":["import { URL } from 'node:url';\nimport { codeFrameColumns } from '@babel/code-frame';\nimport type { FastifyLoggerInstance } from 'fastify';\nimport { SourceMapConsumer } from 'source-map';\nimport type {\n CodeFrame,\n InputStackFrame,\n ReactNativeStackFrame,\n StackFrame,\n SymbolicatorDelegate,\n SymbolicatorResults,\n} from './types';\n\n/**\n * Class for transforming stack traces from React Native application with using Source Map.\n * Raw stack frames produced by React Native, points to some location from the bundle\n * eg `index.bundle?platform=ios:567:1234`. By using Source Map for that bundle `Symbolicator`\n * produces frames that point to source code inside your project eg `Hello.tsx:10:9`.\n */\nexport class Symbolicator {\n /**\n * Infer platform from stack frames.\n * Usually at least one frame has `file` field with the bundle URL eg:\n * `http://localhost:8081/index.bundle?platform=ios&...`, which can be used to infer platform.\n *\n * @param stack Array of stack frames.\n * @returns Inferred platform or `undefined` if cannot infer.\n */\n static inferPlatformFromStack(stack: ReactNativeStackFrame[]) {\n for (const frame of stack) {\n if (!frame.file) {\n continue;\n }\n\n const { searchParams, pathname } = new URL(frame.file, 'file://');\n const platform = searchParams.get('platform');\n if (platform) {\n return platform;\n }\n const [bundleFilename] = pathname.split('/').reverse();\n const [, platformOrExtension, extension] = bundleFilename.split('.');\n if (extension) {\n return platformOrExtension;\n }\n }\n }\n\n /**\n * Cache with initialized `SourceMapConsumer` to improve symbolication performance.\n */\n sourceMapConsumerCache: Record<string, SourceMapConsumer> = {};\n\n /**\n * Constructs new `Symbolicator` instance.\n *\n * @param delegate Delegate instance with symbolication functions.\n */\n constructor(private delegate: SymbolicatorDelegate) {}\n\n /**\n * Process raw React Native stack frames and transform them using Source Maps.\n * Method will try to symbolicate as much data as possible, but if the Source Maps\n * are not available, invalid or the original positions/data is not found in Source Maps,\n * the method will return raw values - the same as supplied with `stack` parameter.\n * For example out of 10 frames, it's possible that only first 7 will be symbolicated and the\n * remaining 3 will be unchanged.\n *\n * @param logger Fastify logger instance.\n * @param stack Raw stack frames.\n * @returns Symbolicated stack frames.\n */\n async process(\n logger: FastifyLoggerInstance,\n stack: ReactNativeStackFrame[]\n ): Promise<SymbolicatorResults> {\n logger.debug({ msg: 'Filtering out unnecessary frames' });\n\n const frames: InputStackFrame[] = [];\n for (const frame of stack) {\n const { file } = frame;\n if (file?.startsWith('http')) {\n frames.push(frame as InputStackFrame);\n }\n }\n\n try {\n logger.debug({ msg: 'Processing frames', frames });\n\n const processedFrames: StackFrame[] = [];\n for (const frame of frames) {\n if (!this.sourceMapConsumerCache[frame.file]) {\n logger.debug({\n msg: 'Loading raw source map data',\n fileUrl: frame.file,\n });\n\n const rawSourceMap = await this.delegate.getSourceMap(frame.file);\n\n logger.debug({\n msg: 'Creating source map instance',\n fileUrl: frame.file,\n sourceMapLength: rawSourceMap.length,\n });\n const sourceMapConsumer = await new SourceMapConsumer(\n rawSourceMap.toString()\n );\n\n logger.debug({\n msg: 'Saving source map instance into cache',\n fileUrl: frame.file,\n });\n this.sourceMapConsumerCache[frame.file] = sourceMapConsumer;\n }\n\n logger.debug({\n msg: 'Symbolicating frame',\n frame,\n });\n const processedFrame = this.processFrame(frame);\n\n logger.debug({\n msg: 'Finished symbolicating frame',\n frame,\n });\n processedFrames.push(processedFrame);\n }\n\n const codeFrame =\n (await this.getCodeFrame(logger, processedFrames)) ?? null;\n\n logger.debug({\n msg: 'Finished symbolicating frames',\n processedFrames,\n codeFrame,\n });\n\n return {\n stack: processedFrames,\n codeFrame,\n };\n } finally {\n for (const key in this.sourceMapConsumerCache) {\n this.sourceMapConsumerCache[key].destroy();\n delete this.sourceMapConsumerCache[key];\n }\n }\n }\n\n private processFrame(frame: InputStackFrame): StackFrame {\n if (!frame.lineNumber || !frame.column) {\n return {\n ...frame,\n collapse: false,\n };\n }\n\n const consumer = this.sourceMapConsumerCache[frame.file];\n if (!consumer) {\n return {\n ...frame,\n collapse: false,\n };\n }\n\n const lookup = consumer.originalPositionFor({\n line: frame.lineNumber,\n column: frame.column,\n bias: SourceMapConsumer.LEAST_UPPER_BOUND,\n });\n\n // If lookup fails, we get the same shape object, but with\n // all values set to null\n if (!lookup.source) {\n // It is better to gracefully return the original frame\n // than to throw an exception\n return {\n ...frame,\n collapse: false,\n };\n }\n\n return {\n lineNumber: lookup.line || frame.lineNumber,\n column: lookup.column || frame.column,\n file: lookup.source,\n methodName: lookup.name || frame.methodName,\n collapse: false,\n };\n }\n\n private async getCodeFrame(\n logger: FastifyLoggerInstance,\n processedFrames: StackFrame[]\n ): Promise<CodeFrame | undefined> {\n for (const frame of processedFrames) {\n if (frame.collapse || !frame.lineNumber || !frame.column) {\n continue;\n }\n\n if (!this.delegate.shouldIncludeFrame(frame)) {\n return undefined;\n }\n\n logger.debug({\n msg: 'Generating code frame',\n frame,\n });\n\n try {\n return {\n content: codeFrameColumns(\n (await this.delegate.getSource(frame.file)).toString(),\n {\n start: { column: frame.column, line: frame.lineNumber },\n },\n { forceColor: true }\n ),\n location: {\n row: frame.lineNumber,\n column: frame.column,\n },\n fileName: frame.file,\n };\n } catch (error) {\n logger.error({\n msg: 'Failed to create code frame',\n error: (error as Error).message,\n });\n }\n\n return undefined;\n }\n }\n}\n"],"mappings":"AAAA,SAASA,GAAG,QAAQ,UAAU;AAC9B,SAASC,gBAAgB,QAAQ,mBAAmB;AAEpD,SAASC,iBAAiB,QAAQ,YAAY;AAU9C;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,CAAC;EACxB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOC,sBAAsBA,CAACC,KAA8B,EAAE;IAC5D,KAAK,MAAMC,KAAK,IAAID,KAAK,EAAE;MACzB,IAAI,CAACC,KAAK,CAACC,IAAI,EAAE;QACf;MACF;MAEA,MAAM;QAAEC,YAAY;QAAEC;MAAS,CAAC,GAAG,IAAIT,GAAG,CAACM,KAAK,CAACC,IAAI,EAAE,SAAS,CAAC;MACjE,MAAMG,QAAQ,GAAGF,YAAY,CAACG,GAAG,CAAC,UAAU,CAAC;MAC7C,IAAID,QAAQ,EAAE;QACZ,OAAOA,QAAQ;MACjB;MACA,MAAM,CAACE,cAAc,CAAC,GAAGH,QAAQ,CAACI,KAAK,CAAC,GAAG,CAAC,CAACC,OAAO,CAAC,CAAC;MACtD,MAAM,GAAGC,mBAAmB,EAAEC,SAAS,CAAC,GAAGJ,cAAc,CAACC,KAAK,CAAC,GAAG,CAAC;MACpE,IAAIG,SAAS,EAAE;QACb,O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ACvB,CAAC,MAAM,IAAI,CAACkB,QAAQ,CAACqC,SAAS,CAAClD,KAAK,CAACC,IAAI,CAAC,EAAE2B,QAAQ,CAAC,CAAC,EACtD;YACEuB,KAAK,EAAE;cAAEf,MAAM,EAAEpC,KAAK,CAACoC,MAAM;cAAEK,IAAI,EAAEzC,KAAK,CAACmC;YAAW;UACxD,CAAC,EACD;YAAEiB,UAAU,EAAE;UAAK,CACrB,CAAC;UACDC,QAAQ,EAAE;YACRC,GAAG,EAAEtD,KAAK,CAACmC,UAAU;YACrBC,MAAM,EAAEpC,KAAK,CAACoC;UAChB,CAAC;UACDmB,QAAQ,EAAEvD,KAAK,CAACC;QAClB,CAAC;MACH,CAAC,CAAC,OAAOuD,KAAK,EAAE;QACdzC,MAAM,CAACyC,KAAK,CAAC;UACXvC,GAAG,EAAE,6BAA6B;UAClCuC,KAAK,EAAGA,KAAK,CAAWC;QAC1B,CAAC,CAAC;MACJ;MAEA,OAAOT,SAAS;IAClB;EACF;AACF","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["default"],"sources":["../../../src/plugins/symbolicate/index.ts"],"sourcesContent":["export { default } from './sybmolicatePlugin';\nexport * from './Symbolicator';\nexport * from './types';\n"],"mappings":"SAASA,OAAO;AAAA;AAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sybmolicatePlugin.js","names":["fastifyPlugin","Symbolicator","symbolicatePlugin","instance","delegate","symbolicator","post","request","reply","stack","JSON","parse","body","platform","inferPlatformFromStack","log","debug","msg","badRequest","results","process","send","error","message","internalServerError","name","dependencies"],"sources":["../../../src/plugins/symbolicate/sybmolicatePlugin.ts"],"sourcesContent":["import type { FastifyInstance } from 'fastify';\nimport fastifyPlugin from 'fastify-plugin';\nimport type { Server } from '../../types';\nimport { Symbolicator } from './Symbolicator';\nimport type { ReactNativeStackFrame } from './types';\n\nasync function symbolicatePlugin(\n instance: FastifyInstance,\n {\n delegate,\n }: {\n delegate: Server.Delegate;\n }\n) {\n const symbolicator = new Symbolicator(delegate.symbolicator);\n\n instance.post('/symbolicate', async (request, reply) => {\n // React Native sends stack as JSON but tests content-type to text/plain, so\n // we cannot use JSON schema to validate the body.\n\n try {\n const { stack } = JSON.parse(request.body as string) as {\n stack: ReactNativeStackFrame[];\n };\n const platform = Symbolicator.inferPlatformFromStack(stack);\n if (!platform) {\n request.log.debug({ msg: 'Received stack', stack });\n reply.badRequest('Cannot infer platform from stack trace');\n } else {\n request.log.debug({ msg: 'Starting symbolication', platform, stack });\n const results = await symbolicator.process(request.log, stack);\n reply.send(results);\n }\n } catch (error) {\n request.log.error({\n msg: 'Failed to symbolicate',\n error: (error as Error).message,\n });\n reply.internalServerError();\n }\n });\n}\n\nexport default fastifyPlugin(symbolicatePlugin, {\n name: 'symbolicate-plugin',\n dependencies: ['@fastify/sensible'],\n});\n"],"mappings":"AACA,OAAOA,aAAa,MAAM,gBAAgB;AAAC,SAElCC,YAAY;AAGrB,eAAeC,iBAAiBA,CAC9BC,QAAyB,EACzB;EACEC;AAGF,CAAC,EACD;EACA,MAAMC,YAAY,GAAG,IAAIJ,YAAY,CAACG,QAAQ,CAACC,YAAY,CAAC;EAE5DF,QAAQ,CAACG,IAAI,CAAC,cAAc,EAAE,OAAOC,OAAO,EAAEC,KAAK,KAAK;IACtD;IACA;;IAEA,IAAI;MACF,MAAM;QAAEC;MAAM,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACJ,OAAO,CAACK,IAAc,CAElD;MACD,MAAMC,QAAQ,GAAGZ,YAAY,CAACa,sBAAsB,CAACL,KAAK,CAAC;MAC3D,IAAI,CAACI,QAAQ,EAAE;QACbN,OAAO,CAACQ,GAAG,CAACC,KAAK,CAAC;UAAEC,GAAG,EAAE,gBAAgB;UAAER;QAAM,CAAC,CAAC;QACnDD,KAAK,CAACU,UAAU,CAAC,wCAAwC,CAAC;MAC5D,CAAC,MAAM;QACLX,OAAO,CAACQ,GAAG,CAACC,KAAK,CAAC;UAAEC,GAAG,EAAE,wBAAwB;UAAEJ,QAAQ;UAAEJ;QAAM,CAAC,CAAC;QACrE,MAAMU,OAAO,GAAG,MAAMd,YAAY,CAACe,OAAO,CAACb,OAAO,CAACQ,GAAG,EAAEN,KAAK,CAAC;QAC9DD,KAAK,CAACa,IAAI,CAACF,OAAO,CAAC;MACrB;IACF,CAAC,CAAC,OAAOG,KAAK,EAAE;MACdf,OAAO,CAACQ,GAAG,CAACO,KAAK,CAAC;QAChBL,GAAG,EAAE,uBAAuB;QAC5BK,KAAK,EAAGA,KAAK,CAAWC;MAC1B,CAAC,CAAC;MACFf,KAAK,CAACgB,mBAAmB,CAAC,CAAC;IAC7B;EACF,CAAC,CAAC;AACJ;AAEA,eAAexB,aAAa,CAACE,iBAAiB,EAAE;EAC9CuB,IAAI,EAAE,oBAAoB;EAC1BC,YAAY,EAAE,CAAC,mBAAmB;AACpC,CAAC,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/plugins/symbolicate/types.ts"],"sourcesContent":["/**\n * Raw React Native stack frame.\n */\nexport interface ReactNativeStackFrame {\n lineNumber: number | null;\n column: number | null;\n file: string | null;\n methodName: string;\n}\n\n/**\n * React Native stack frame used as input when processing by {@link Symbolicator}.\n */\nexport interface InputStackFrame extends ReactNativeStackFrame {\n file: string;\n}\n\n/**\n * Final symbolicated stack frame.\n */\nexport interface StackFrame extends InputStackFrame {\n collapse: boolean;\n}\n\n/**\n * Represents [@babel/core-frame](https://babeljs.io/docs/en/babel-code-frame).\n */\nexport interface CodeFrame {\n content: string;\n location: {\n row: number;\n column: number;\n };\n fileName: string;\n}\n\n/**\n * Represents results of running {@link process} method on {@link Symbolicator} instance.\n */\nexport interface SymbolicatorResults {\n codeFrame: CodeFrame | null;\n stack: StackFrame[];\n}\n\n/**\n * Delegate with implementation for symbolication functions.\n */\nexport interface SymbolicatorDelegate {\n /**\n * Get source code of file in the URL.\n *\n * @param fileUrl A full URL pointing to a file.\n */\n getSource: (fileUrl: string) => Promise<string | Buffer>;\n\n /**\n * Get source map for the file in the URL.\n *\n * @param fileUrl A full (usually `http:`) URL pointing to a compiled file.\n * The URL points to a file for which to return source map, not to the source map file itself,\n * e.g: `http://localhost:8081/index.bundle?platform=ios`.\n */\n getSourceMap: (fileUrl: string) => Promise<string | Buffer>;\n\n /**\n * Check if given stack frame should be included in the new symbolicated stack.\n *\n * @param frame Stack frame to check.\n */\n shouldIncludeFrame: (frame: StackFrame) => boolean;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebSocketRouter.js","names":["WebSocketRouter","servers","constructor","fastify","server","on","request","socket","head","pathname","URL","url","matched","shouldUpgrade","upgrade","log","debug","msg","destroy","registerServer","push"],"sources":["../../../src/plugins/wss/WebSocketRouter.ts"],"sourcesContent":["import type { IncomingMessage } from 'node:http';\nimport type { Socket } from 'node:net';\nimport type { FastifyInstance } from 'fastify';\nimport type { WebSocketServerInterface } from './types';\n\n/**\n * Class for creating a WebSocket router to forward connections to the\n * respective {@link WebSocketServer} as long as the connection is accepted for the upgrade by the\n * server.\n *\n * If the connection is not accepted by any `WebSocketServer`, it will be destroyed to avoid\n * creating handling connections and potentially throwing `ECONNRESET` errors.\n *\n * @category Development server\n */\nexport class WebSocketRouter {\n /** The list of all register WebSocket servers. */\n protected servers: WebSocketServerInterface[] = [];\n\n /**\n * Create new instance of `WebSocketRouter` and attach it to the given Fastify instance.\n * Any logging information, will be passed through standard `fastify.log` API.\n *\n * @param fastify Fastify instance to attach the WebSocket router to.\n */\n constructor(private fastify: FastifyInstance) {\n this.fastify.server.on(\n 'upgrade',\n (request: IncomingMessage, socket: Socket, head: Buffer) => {\n const { pathname } = new URL(request.url || '', 'http://localhost');\n let matched = false;\n for (const server of this.servers) {\n if (server.shouldUpgrade(pathname)) {\n matched = true;\n server.upgrade(request, socket, head);\n break;\n }\n }\n\n if (!matched) {\n this.fastify.log.debug({\n msg: 'Destroying socket connection as no server was matched',\n pathname,\n });\n socket.destroy();\n }\n }\n );\n }\n\n /**\n * Register a new {@link WebSocketServer}. New connection will now\n * check if the given server will accept them and forward them.\n *\n * @param server WebSocket server to register.\n * @returns The same instance of the WebSocket server after it's been registered.\n */\n registerServer<T extends WebSocketServerInterface>(server: T): T {\n this.servers.push(server);\n return server;\n }\n}\n"],"mappings":"AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,eAAe,CAAC;EAC3B;EACUC,OAAO,GAA+B,EAAE;;EAElD;AACF;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAASC,OAAwB,EAAE;IAAA,KAA1BA,OAAwB,GAAxBA,OAAwB;IAC1C,IAAI,CAACA,OAAO,CAACC,MAAM,CAACC,EAAE,CACpB,SAAS,EACT,CAACC,OAAwB,EAAEC,MAAc,EAAEC,IAAY,KAAK;MAC1D,MAAM;QAAEC;MAAS,CAAC,GAAG,IAAIC,GAAG,CAACJ,OAAO,CAACK,GAAG,IAAI,EAAE,EAAE,kBAAkB,CAAC;MACnE,IAAIC,OAAO,GAAG,KAAK;MACnB,KAAK,MAAMR,MAAM,IAAI,IAAI,CAACH,OAAO,EAAE;QACjC,IAAIG,MAAM,CAACS,aAAa,CAACJ,QAAQ,CAAC,EAAE;UAClCG,OAAO,GAAG,IAAI;UACdR,MAAM,CAACU,OAAO,CAACR,OAAO,EAAEC,MAAM,EAAEC,IAAI,CAAC;UACrC;QACF;MACF;MAEA,IAAI,CAACI,OAAO,EAAE;QACZ,IAAI,CAACT,OAAO,CAACY,GAAG,CAACC,KAAK,CAAC;UACrBC,GAAG,EAAE,uDAAuD;UAC5DR;QACF,CAAC,CAAC;QACFF,MAAM,CAACW,OAAO,CAAC,CAAC;MAClB;IACF,CACF,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,cAAcA,CAAqCf,MAAS,EAAK;IAC/D,IAAI,CAACH,OAAO,CAACmB,IAAI,CAAChB,MAAM,CAAC;IACzB,OAAOA,MAAM;EACf;AACF","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebSocketServer.js","names":["WebSocketServer","WebSocketServerImpl","constructor","fastify","path","wssOptions","server","noServer","on","onConnection","bind","paths","Array","isArray","shouldUpgrade","pathname","includes","upgrade","request","socket","head","handleUpgrade","webSocket","emit"],"sources":["../../../src/plugins/wss/WebSocketServer.ts"],"sourcesContent":["import type { IncomingMessage } from 'node:http';\nimport type { Socket } from 'node:net';\nimport type { FastifyInstance } from 'fastify';\nimport {\n type ServerOptions,\n type WebSocket,\n WebSocketServer as WebSocketServerImpl,\n} from 'ws';\nimport type { WebSocketServerInterface } from './types';\n\n/**\n * Abstract class for providing common logic (eg routing) for all WebSocket servers.\n *\n * @category Development server\n */\nexport abstract class WebSocketServer implements WebSocketServerInterface {\n /** An instance of the underlying WebSocket server. */\n protected server: WebSocketServerImpl;\n\n /** Fastify instance from which {@link server} will receive upgrade connections. */\n protected fastify: FastifyInstance;\n\n protected paths: string[];\n\n /**\n * Create a new instance of the WebSocketServer.\n * Any logging information, will be passed through standard `fastify.log` API.\n *\n * @param fastify Fastify instance to which the WebSocket will be attached to.\n * @param path Path on which this WebSocketServer will be accepting connections.\n * @param wssOptions WebSocket Server options.\n */\n constructor(\n fastify: FastifyInstance,\n path: string | string[],\n wssOptions: Omit<\n ServerOptions,\n 'noServer' | 'server' | 'host' | 'port' | 'path'\n > = {}\n ) {\n this.fastify = fastify;\n this.server = new WebSocketServerImpl({ noServer: true, ...wssOptions });\n this.server.on('connection', this.onConnection.bind(this));\n this.paths = Array.isArray(path) ? path : [path];\n }\n\n shouldUpgrade(pathname: string) {\n return this.paths.includes(pathname);\n }\n\n upgrade(request: IncomingMessage, socket: Socket, head: Buffer) {\n this.server.handleUpgrade(request, socket, head, (webSocket) => {\n this.server.emit('connection', webSocket, request);\n });\n }\n\n /**\n * Process incoming WebSocket connection.\n *\n * @param socket Incoming WebSocket connection.\n * @param request Upgrade request for the connection.\n */\n abstract onConnection(socket: WebSocket, request: IncomingMessage): void;\n}\n"],"mappings":"AAGA,SAGEA,eAAe,IAAIC,mBAAmB,QACjC,IAAI;AAGX;AACA;AACA;AACA;AACA;AACA,OAAO,MAAeD,eAAe,CAAqC;EACxE;;EAGA;;EAKA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEE,WAAWA,CACTC,OAAwB,EACxBC,IAAuB,EACvBC,UAGC,GAAG,CAAC,CAAC,EACN;IACA,IAAI,CAACF,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACG,MAAM,GAAG,IAAIL,mBAAmB,CAAC;MAAEM,QAAQ,EAAE,IAAI;MAAE,GAAGF;IAAW,CAAC,CAAC;IACxE,IAAI,CAACC,MAAM,CAACE,EAAE,CAAC,YAAY,EAAE,IAAI,CAACC,YAAY,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1D,IAAI,CAACC,KAAK,GAAGC,KAAK,CAACC,OAAO,CAACT,IAAI,CAAC,GAAGA,IAAI,GAAG,CAACA,IAAI,CAAC;EAClD;EAEAU,aAAaA,CAACC,QAAgB,EAAE;IAC9B,OAAO,IAAI,CAACJ,KAAK,CAACK,QAAQ,CAACD,QAAQ,CAAC;EACtC;EAEAE,OAAOA,CAACC,OAAwB,EAAEC,MAAc,EAAEC,IAAY,EAAE;IAC9D,IAAI,CAACd,MAAM,CAACe,aAAa,CAACH,OAAO,EAAEC,MAAM,EAAEC,IAAI,EAAGE,SAAS,IAAK;MAC9D,IAAI,CAAChB,MAAM,CAACiB,IAAI,CAAC,YAAY,EAAED,SAAS,EAAEJ,OAAO,CAAC;IACpD,CAAC,CAAC;EACJ;;EAEA;AACF;AACA;AACA;AACA;AACA;AAEA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebSocketServerAdapter.js","names":["WebSocketServerAdapter","constructor","fastify","path","server","shouldUpgrade","pathname","log","warn","msg","upgrade","request","socket","head","handleUpgrade","webSocket","emit"],"sources":["../../../src/plugins/wss/WebSocketServerAdapter.ts"],"sourcesContent":["import type { IncomingMessage } from 'node:http';\nimport type { Socket } from 'node:net';\nimport type { FastifyInstance } from 'fastify';\nimport type { WebSocketServer } from 'ws';\nimport type { WebSocketServerInterface } from './types';\n\nexport class WebSocketServerAdapter implements WebSocketServerInterface {\n constructor(\n private fastify: FastifyInstance,\n private path: string,\n private server?: WebSocketServer\n ) {}\n\n shouldUpgrade(pathname: string) {\n if (!this.server) {\n this.fastify.log.warn({ msg: `No handler active for ${this.path}` });\n return false;\n }\n return this.path === pathname;\n }\n\n upgrade(request: IncomingMessage, socket: Socket, head: Buffer) {\n this.server?.handleUpgrade(request, socket, head, (webSocket) => {\n this.server?.emit('connection', webSocket, request);\n });\n }\n}\n"],"mappings":"AAMA,OAAO,MAAMA,sBAAsB,CAAqC;EACtEC,WAAWA,CACDC,OAAwB,EACxBC,IAAY,EACZC,MAAwB,EAChC;IAAA,KAHQF,OAAwB,GAAxBA,OAAwB;IAAA,KACxBC,IAAY,GAAZA,IAAY;IAAA,KACZC,MAAwB,GAAxBA,MAAwB;EAC/B;EAEHC,aAAaA,CAACC,QAAgB,EAAE;IAC9B,IAAI,CAAC,IAAI,CAACF,MAAM,EAAE;MAChB,IAAI,CAACF,OAAO,CAACK,GAAG,CAACC,IAAI,CAAC;QAAEC,GAAG,EAAE,yBAAyB,IAAI,CAACN,IAAI;MAAG,CAAC,CAAC;MACpE,OAAO,KAAK;IACd;IACA,OAAO,IAAI,CAACA,IAAI,KAAKG,QAAQ;EAC/B;EAEAI,OAAOA,CAACC,OAAwB,EAAEC,MAAc,EAAEC,IAAY,EAAE;IAC9D,IAAI,CAACT,MAAM,EAAEU,aAAa,CAACH,OAAO,EAAEC,MAAM,EAAEC,IAAI,EAAGE,SAAS,IAAK;MAC/D,IAAI,CAACX,MAAM,EAAEY,IAAI,CAAC,YAAY,EAAED,SAAS,EAAEJ,OAAO,CAAC;IACrD,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["default"],"sources":["../../../src/plugins/wss/index.ts"],"sourcesContent":["export { default } from './wssPlugin';\nexport * from './WebSocketServer';\nexport * from './types';\n"],"mappings":"SAASA,OAAO;AAAA;AAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebSocketApiServer.js","names":["WebSocketServer","WebSocketApiServer","clients","Map","nextClientId","constructor","fastify","send","event","data","JSON","stringify","socket","entries","onConnection","clientId","set","log","debug","msg","onClose","delete","addEventListener"],"sources":["../../../../src/plugins/wss/servers/WebSocketApiServer.ts"],"sourcesContent":["import type { FastifyInstance } from 'fastify';\nimport type WebSocket from 'ws';\nimport { WebSocketServer } from '../WebSocketServer';\n\n/**\n * Class for creating a WebSocket server for API clients.\n * Useful to listening for compilation events and new logs.\n *\n * @category Development server\n */\nexport class WebSocketApiServer extends WebSocketServer {\n private clients = new Map<string, WebSocket>();\n private nextClientId = 0;\n\n /**\n * Create new instance of WebSocketApiServer and attach it to the given Fastify instance.\n * Any logging information, will be passed through standard `fastify.log` API.\n *\n * @param fastify Fastify instance to attach the WebSocket server to.\n */\n constructor(fastify: FastifyInstance) {\n super(fastify, '/api');\n }\n\n /**\n * Send message to all connected API clients.\n *\n * @param event Event string or object to send.\n */\n send(event: any) {\n const data = typeof event === 'string' ? event : JSON.stringify(event);\n\n for (const [, socket] of this.clients.entries()) {\n try {\n socket.send(data);\n } catch {\n // NOOP\n }\n }\n }\n\n /**\n * Process new WebSocket connection from client application.\n *\n * @param socket Incoming client's WebSocket connection.\n */\n onConnection(socket: WebSocket) {\n const clientId = `client#${this.nextClientId++}`;\n this.clients.set(clientId, socket);\n\n this.fastify.log.debug({ msg: 'API client connected', clientId });\n this.clients.set(clientId, socket);\n\n const onClose = () => {\n this.fastify.log.debug({\n msg: 'API client disconnected',\n clientId,\n });\n this.clients.delete(clientId);\n };\n\n socket.addEventListener('error', onClose);\n socket.addEventListener('close', onClose);\n }\n}\n"],"m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,CAACU,gBAAgB,CAAC,OAAO,EAAEF,OAAO,CAAC;IACzCR,MAAM,CAACU,gBAAgB,CAAC,OAAO,EAAEF,OAAO,CAAC;EAC3C;AACF","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebSocketDevClientServer.js","names":["WebSocketServer","WebSocketDevClientServer","clients","Map","nextClientId","constructor","fastify","processMessage","message","type","body","JSON","parse","level","log","error","issuer","msg","data","warn","info","debug","onConnection","socket","clientId","set","onClose","delete","addEventListener","event","toString"],"sources":["../../../../src/plugins/wss/servers/WebSocketDevClientServer.ts"],"sourcesContent":["import type { FastifyInstance } from 'fastify';\nimport type WebSocket from 'ws';\nimport { WebSocketServer } from '../WebSocketServer';\n\n/**\n * Class for creating a WebSocket server for communication with React Native clients.\n * All client logs - logs from React Native application - are processed here.\n *\n * @category Development server\n */\nexport class WebSocketDevClientServer extends WebSocketServer {\n private clients = new Map<string, WebSocket>();\n private nextClientId = 0;\n\n /**\n * Create new instance of WebSocketDevClientServer and attach it to the given Fastify instance.\n * Any logging information, will be passed through standard `fastify.log` API.\n *\n * @param fastify Fastify instance to attach the WebSocket server to.\n */\n constructor(fastify: FastifyInstance) {\n super(fastify, '/__client');\n }\n\n /**\n * Process client message.\n *\n * @param message Stringified client message.\n */\n processMessage(message: string) {\n const { type, ...body } = JSON.parse(message);\n switch (type) {\n case 'client-log':\n if (body.level === 'error') {\n this.fastify.log.error({ issuer: 'Console', msg: body.data });\n } else if (body.level === 'warn') {\n this.fastify.log.warn({ issuer: 'Console', msg: body.data });\n } else if (body.level === 'info' || body.level === 'log') {\n this.fastify.log.info({ issuer: 'Console', msg: body.data });\n } else {\n // body.level === 'debug' || body.level === 'trace'\n this.fastify.log.debug({ issuer: 'Console', msg: body.data });\n }\n break;\n default:\n this.fastify.log.warn({ msg: 'Unknown client message', message });\n }\n }\n\n /**\n * Process new WebSocket connection from client application.\n *\n * @param socket Incoming client's WebSocket connection.\n */\n onConnection(socket: WebSocket) {\n const clientId = `client#${this.nextClientId++}`;\n this.clients.set(clientId, socket);\n this.fastify.log.debug({ msg: 'React Native client connected', clientId });\n\n const onClose = () => {\n this.fastify.log.debug({\n msg: 'React Native client disconnected',\n clientId,\n });\n this.clients.delete(clientId);\n };\n\n socket.addEventListener('error', onClose);\n socket.addEventListener('close', onClose);\n socket.addEventListener('message', (event) => {\n this.processMessage(event.data.toString());\n });\n }\n}\n"],"mappings":"SAESA,eAAe;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,SAASD,eAAe,CAAC;EACpDE,OAAO,GAAG,IAAIC,GAAG,CAAoB,CAAC;EACtCC,YAAY,GAAG,CAAC;;EAExB;AACF;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,OAAwB,EAAE;IACpC,KAAK,CAACA,OAAO,EAAE,WAAW,CAAC;EAC7B;;EAEA;AACF;AACA;AACA;AACA;EACEC,cAAcA,CAACC,OAAe,EAAE;IAC9B,MAAM;MAAEC,IAAI;MAAE,GAAGC;IAAK,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACJ,OAAO,CAAC;IAC7C,QAAQC,IAAI;MACV,KAAK,YAAY;QACf,IAAIC,IAAI,CAACG,KAAK,KAAK,OAAO,EAAE;UAC1B,IAAI,CAACP,OAAO,CAACQ,GAAG,CAACC,KAAK,CAAC;YAAEC,MAAM,EAAE,SAAS;YAAEC,GAAG,EAAEP,IAAI,CAACQ;UAAK,CAAC,CAAC;QAC/D,CAAC,MAAM,IAAIR,IAAI,CAACG,KAAK,KAAK,MAAM,EAAE;UAChC,IAAI,CAACP,OAAO,CAACQ,GAAG,CAACK,IAAI,CAAC;YAAEH,MAAM,EAAE,SAAS;YAAEC,GAAG,EAAEP,IAAI,CAACQ;UAAK,CAAC,CAAC;QAC9D,CAAC,MAAM,IAAIR,IAAI,CAACG,KAAK,KAAK,MAAM,IAAIH,IAAI,CAACG,KAAK,KAAK,KAAK,EAAE;UACxD,IAAI,CAACP,OAAO,CAACQ,G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