@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,4 +1,5 @@
1
- import { type Server } from './types';
1
+ import Fastify from 'fastify';
2
+ import { type Server } from './types.js';
2
3
  /**
3
4
  * Create instance of development server, powered by Fastify.
4
5
  *
@@ -8,5 +9,5 @@ import { type Server } from './types';
8
9
  export declare function createServer(config: Server.Config): Promise<{
9
10
  start: () => Promise<void>;
10
11
  stop: () => Promise<void>;
11
- instance: import("fastify").FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault> & PromiseLike<import("fastify").FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>>;
12
+ instance: Fastify.FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, Fastify.FastifyBaseLogger, Fastify.FastifyTypeProviderDefault> & PromiseLike<Fastify.FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, Fastify.FastifyBaseLogger, Fastify.FastifyTypeProviderDefault>>;
12
13
  }>;
@@ -3,14 +3,14 @@ import middie from '@fastify/middie';
3
3
  import fastifySensible from '@fastify/sensible';
4
4
  import { createDevMiddleware } from '@react-native/dev-middleware';
5
5
  import Fastify from 'fastify';
6
- import apiPlugin from "./plugins/api/index.js";
7
- import compilerPlugin from "./plugins/compiler/index.js";
8
- import devtoolsPlugin from "./plugins/devtools/index.js";
9
- import faviconPlugin from "./plugins/favicon/index.js";
10
- import multipartPlugin from "./plugins/multipart/index.js";
11
- import symbolicatePlugin from "./plugins/symbolicate/index.js";
12
- import wssPlugin from "./plugins/wss/index.js";
13
- import { Internal } from "./types.js";
6
+ import apiPlugin from './plugins/api/apiPlugin.js';
7
+ import compilerPlugin from './plugins/compiler/compilerPlugin.js';
8
+ import devtoolsPlugin from './plugins/devtools/devtoolsPlugin.js';
9
+ import faviconPlugin from './plugins/favicon/faviconPlugin.js';
10
+ import multipartPlugin from './plugins/multipart/multipartPlugin.js';
11
+ import symbolicatePlugin from './plugins/symbolicate/sybmolicatePlugin.js';
12
+ import wssPlugin from './plugins/wss/wssPlugin.js';
13
+ import { Internal } from './types.js';
14
14
  /**
15
15
  * Create instance of development server, powered by Fastify.
16
16
  *
@@ -18,122 +18,109 @@ import { Internal } from "./types.js";
18
18
  * @returns `start` and `stop` functions as well as an underlying Fastify `instance`.
19
19
  */
20
20
  export async function createServer(config) {
21
- // biome-ignore lint/style/useConst: needed in fastify constructor
22
- let delegate;
23
-
24
- /** Fastify instance powering the development server. */
25
- const instance = Fastify({
26
- disableRequestLogging: !config.options.logRequests,
27
- logger: {
28
- level: 'trace',
29
- stream: new Writable({
30
- write: (chunk, _encoding, callback) => {
31
- const log = JSON.parse(chunk.toString());
32
- delegate?.logger.onMessage(log);
33
- instance.wss?.apiServer.send(log);
34
- callback();
21
+ // biome-ignore lint/style/useConst: needed in fastify constructor
22
+ let delegate;
23
+ /** Fastify instance powering the development server. */
24
+ const instance = Fastify({
25
+ disableRequestLogging: !config.options.logRequests,
26
+ logger: {
27
+ level: 'trace',
28
+ stream: new Writable({
29
+ write: (chunk, _encoding, callback) => {
30
+ const log = JSON.parse(chunk.toString());
31
+ delegate?.logger.onMessage(log);
32
+ instance.wss?.apiServer.send(log);
33
+ callback();
34
+ },
35
+ }),
36
+ },
37
+ ...(config.options.https ? { https: config.options.https } : undefined),
38
+ });
39
+ delegate = await config.delegate({
40
+ log: instance.log,
41
+ notifyBuildStart: (platform) => {
42
+ instance.wss.apiServer.send({
43
+ event: Internal.EventTypes.BuildStart,
44
+ platform,
45
+ });
46
+ },
47
+ notifyBuildEnd: (platform) => {
48
+ instance.wss.apiServer.send({
49
+ event: Internal.EventTypes.BuildEnd,
50
+ platform,
51
+ });
52
+ },
53
+ broadcastToHmrClients: (event, platform, clientIds) => {
54
+ instance.wss.hmrServer.send(event, platform, clientIds);
55
+ },
56
+ broadcastToMessageClients: ({ method, params }) => {
57
+ instance.wss.messageServer.broadcast(method, params);
58
+ },
59
+ });
60
+ const devMiddleware = createDevMiddleware({
61
+ projectRoot: config.options.rootDir,
62
+ serverBaseUrl: `http://${config.options.host}:${config.options.port}`,
63
+ logger: instance.log,
64
+ unstable_experiments: {
65
+ // @ts-expect-error removed in 0.76, keep this for backkwards compatibility
66
+ enableNewDebugger: true,
67
+ },
68
+ });
69
+ // Register plugins
70
+ await instance.register(fastifySensible);
71
+ await instance.register(middie);
72
+ await instance.register(wssPlugin, {
73
+ options: {
74
+ ...config.options,
75
+ endpoints: devMiddleware.websocketEndpoints,
76
+ },
77
+ delegate,
78
+ });
79
+ await instance.register(multipartPlugin);
80
+ await instance.register(apiPlugin, {
81
+ delegate,
82
+ prefix: '/api',
83
+ });
84
+ await instance.register(compilerPlugin, {
85
+ delegate,
86
+ });
87
+ await instance.register(devtoolsPlugin, {
88
+ options: config.options,
89
+ });
90
+ await instance.register(symbolicatePlugin, {
91
+ delegate,
92
+ });
93
+ // below is to prevent showing `GET 400 /favicon.ico`
94
+ // errors in console when requesting the bundle via browser
95
+ await instance.register(faviconPlugin);
96
+ instance.addHook('onSend', async (request, reply, payload) => {
97
+ reply.header('X-Content-Type-Options', 'nosniff');
98
+ reply.header('X-React-Native-Project-Root', config.options.rootDir);
99
+ const [pathname] = request.url.split('?');
100
+ if (pathname.endsWith('.map')) {
101
+ reply.header('Access-Control-Allow-Origin', 'devtools://devtools');
35
102
  }
36
- })
37
- },
38
- ...(config.options.https ? {
39
- https: config.options.https
40
- } : undefined)
41
- });
42
- delegate = await config.delegate({
43
- log: instance.log,
44
- notifyBuildStart: platform => {
45
- instance.wss.apiServer.send({
46
- event: Internal.EventTypes.BuildStart,
47
- platform
48
- });
49
- },
50
- notifyBuildEnd: platform => {
51
- instance.wss.apiServer.send({
52
- event: Internal.EventTypes.BuildEnd,
53
- platform
54
- });
55
- },
56
- broadcastToHmrClients: (event, platform, clientIds) => {
57
- instance.wss.hmrServer.send(event, platform, clientIds);
58
- },
59
- broadcastToMessageClients: ({
60
- method,
61
- params
62
- }) => {
63
- instance.wss.messageServer.broadcast(method, params);
64
- }
65
- });
66
- const devMiddleware = createDevMiddleware({
67
- projectRoot: config.options.rootDir,
68
- serverBaseUrl: `http://${config.options.host}:${config.options.port}`,
69
- logger: instance.log,
70
- unstable_experiments: {
71
- // @ts-expect-error removed in 0.76, keep this for backkwards compatibility
72
- enableNewDebugger: true
103
+ return payload;
104
+ });
105
+ // Register dev middleware
106
+ instance.use(devMiddleware.middleware);
107
+ // Register routes
108
+ instance.get('/', async () => delegate.messages.getHello());
109
+ instance.get('/status', async () => delegate.messages.getStatus());
110
+ /** Start the development server. */
111
+ async function start() {
112
+ await instance.listen({
113
+ port: config.options.port,
114
+ host: config.options.host,
115
+ });
73
116
  }
74
- });
75
-
76
- // Register plugins
77
- await instance.register(fastifySensible);
78
- await instance.register(middie);
79
- await instance.register(wssPlugin, {
80
- options: {
81
- ...config.options,
82
- endpoints: devMiddleware.websocketEndpoints
83
- },
84
- delegate
85
- });
86
- await instance.register(multipartPlugin);
87
- await instance.register(apiPlugin, {
88
- delegate,
89
- prefix: '/api'
90
- });
91
- await instance.register(compilerPlugin, {
92
- delegate
93
- });
94
- await instance.register(devtoolsPlugin, {
95
- options: config.options
96
- });
97
- await instance.register(symbolicatePlugin, {
98
- delegate
99
- });
100
-
101
- // below is to prevent showing `GET 400 /favicon.ico`
102
- // errors in console when requesting the bundle via browser
103
- await instance.register(faviconPlugin);
104
- instance.addHook('onSend', async (request, reply, payload) => {
105
- reply.header('X-Content-Type-Options', 'nosniff');
106
- reply.header('X-React-Native-Project-Root', config.options.rootDir);
107
- const [pathname] = request.url.split('?');
108
- if (pathname.endsWith('.map')) {
109
- reply.header('Access-Control-Allow-Origin', 'devtools://devtools');
117
+ /** Stop the development server. */
118
+ async function stop() {
119
+ await instance.close();
110
120
  }
111
- return payload;
112
- });
113
-
114
- // Register dev middleware
115
- instance.use(devMiddleware.middleware);
116
-
117
- // Register routes
118
- instance.get('/', async () => delegate.messages.getHello());
119
- instance.get('/status', async () => delegate.messages.getStatus());
120
-
121
- /** Start the development server. */
122
- async function start() {
123
- await instance.listen({
124
- port: config.options.port,
125
- host: config.options.host
126
- });
127
- }
128
-
129
- /** Stop the development server. */
130
- async function stop() {
131
- await instance.close();
132
- }
133
- return {
134
- start,
135
- stop,
136
- instance
137
- };
121
+ return {
122
+ start,
123
+ stop,
124
+ instance,
125
+ };
138
126
  }
139
- //# sourceMappingURL=createServer.js.map
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './createServer';
2
- export * from './types';
1
+ export * from './createServer.js';
2
+ export * from './types.js';
package/dist/index.js CHANGED
@@ -1,3 +1,2 @@
1
- export * from "./createServer.js";
2
- export * from "./types.js";
3
- //# sourceMappingURL=index.js.map
1
+ export * from './createServer.js';
2
+ export * from './types.js';
@@ -1,5 +1,5 @@
1
1
  import type { FastifyInstance } from 'fastify';
2
- import type { Server } from '../../types';
2
+ import type { Server } from '../../types.js';
3
3
  declare function apiPlugin(instance: FastifyInstance, { delegate }: {
4
4
  delegate: Server.Delegate;
5
5
  }): Promise<void>;
@@ -1,32 +1,25 @@
1
1
  const paramsSchema = {
2
- type: 'object',
3
- properties: {
4
- platform: {
5
- type: 'string'
6
- }
7
- },
8
- required: ['platform']
2
+ type: 'object',
3
+ properties: {
4
+ platform: {
5
+ type: 'string',
6
+ },
7
+ },
8
+ required: ['platform'],
9
9
  };
10
- async function apiPlugin(instance, {
11
- delegate
12
- }) {
13
- instance.get('/platforms', async (_request, reply) => delegate.api ? reply.send({
14
- data: await delegate.api.getPlatforms()
15
- }) : reply.notImplemented('Missing API delegate implementation'));
16
- instance.get('/:platform/assets', {
17
- schema: {
18
- params: paramsSchema
19
- }
20
- }, async (request, reply) => delegate.api ? reply.send({
21
- data: await delegate.api.getAssets(request.params.platform)
22
- }) : reply.notImplemented('Missing API delegate implementation'));
23
- instance.get('/:platform/stats', {
24
- schema: {
25
- params: paramsSchema
26
- }
27
- }, async (request, reply) => delegate.api ? reply.send({
28
- data: await delegate.api?.getCompilationStats(request.params.platform)
29
- }) : reply.notImplemented('Missing API delegate implementation'));
10
+ async function apiPlugin(instance, { delegate }) {
11
+ instance.get('/platforms', async (_request, reply) => delegate.api
12
+ ? reply.send({ data: await delegate.api.getPlatforms() })
13
+ : reply.notImplemented('Missing API delegate implementation'));
14
+ instance.get('/:platform/assets', { schema: { params: paramsSchema } }, async (request, reply) => delegate.api
15
+ ? reply.send({
16
+ data: await delegate.api.getAssets(request.params.platform),
17
+ })
18
+ : reply.notImplemented('Missing API delegate implementation'));
19
+ instance.get('/:platform/stats', { schema: { params: paramsSchema } }, async (request, reply) => delegate.api
20
+ ? reply.send({
21
+ data: await delegate.api?.getCompilationStats(request.params.platform),
22
+ })
23
+ : reply.notImplemented('Missing API delegate implementation'));
30
24
  }
31
25
  export default apiPlugin;
32
- //# sourceMappingURL=apiPlugin.js.map
@@ -1 +1 @@
1
- export { default } from './apiPlugin';
1
+ export { default } from './apiPlugin.js';
@@ -1,2 +1 @@
1
- export { default } from "./apiPlugin.js";
2
- //# sourceMappingURL=index.js.map
1
+ export { default } from './apiPlugin.js';
@@ -1,5 +1,5 @@
1
1
  import type { FastifyInstance } from 'fastify';
2
- import type { Server } from '../../types';
2
+ import type { Server } from '../../types.js';
3
3
  declare function compilerPlugin(instance: FastifyInstance, { delegate }: {
4
4
  delegate: Server.Delegate;
5
5
  }): Promise<void>;
@@ -1,66 +1,57 @@
1
1
  import fastifyPlugin from 'fastify-plugin';
2
- async function compilerPlugin(instance, {
3
- delegate
4
- }) {
5
- instance.route({
6
- method: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'HEAD'],
7
- url: '/*',
8
- schema: {
9
- querystring: {
10
- type: 'object',
11
- properties: {
12
- platform: {
13
- type: 'string'
14
- }
15
- }
16
- }
17
- },
18
- handler: async (request, reply) => {
19
- const filename = request.params['*'];
20
- let {
21
- platform
22
- } = request.query;
23
- if (!filename) {
24
- // This technically should never happen - this route should not be called if file is missing.
25
- request.log.error('File was not provided');
26
- return reply.notFound();
27
- }
28
-
29
- // Let consumer infer the platform. If function is not provided fallback
30
- // to platform query param.
31
- platform = delegate.compiler.inferPlatform?.(request.url) ?? platform;
32
- const multipart = reply.asMultipart();
33
- const sendProgress = ({
34
- completed,
35
- total
36
- }) => {
37
- multipart?.writeChunk({
38
- 'Content-Type': 'application/json'
39
- }, JSON.stringify({
40
- done: completed,
41
- total
42
- }));
43
- };
44
- try {
45
- const asset = await delegate.compiler.getAsset(filename, platform, sendProgress);
46
- const mimeType = delegate.compiler.getMimeType(filename, platform, asset);
47
- if (multipart) {
48
- const buffer = Buffer.isBuffer(asset) ? asset : Buffer.from(asset);
49
- multipart.setHeader('Content-Type', `${mimeType}; charset=UTF-8`);
50
- multipart.setHeader('Content-Length', String(Buffer.byteLength(buffer)));
51
- multipart.end(buffer);
52
- } else {
53
- return reply.code(200).type(mimeType).send(asset);
54
- }
55
- } catch (error) {
56
- request.log.error(error);
57
- return reply.notFound(error.message);
58
- }
59
- }
60
- });
2
+ async function compilerPlugin(instance, { delegate }) {
3
+ instance.route({
4
+ method: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'HEAD'],
5
+ url: '/*',
6
+ schema: {
7
+ querystring: {
8
+ type: 'object',
9
+ properties: {
10
+ platform: {
11
+ type: 'string',
12
+ },
13
+ },
14
+ },
15
+ },
16
+ handler: async (request, reply) => {
17
+ const filename = request.params['*'];
18
+ let { platform } = request.query;
19
+ if (!filename) {
20
+ // This technically should never happen - this route should not be called if file is missing.
21
+ request.log.error('File was not provided');
22
+ return reply.notFound();
23
+ }
24
+ // Let consumer infer the platform. If function is not provided fallback
25
+ // to platform query param.
26
+ platform = delegate.compiler.inferPlatform?.(request.url) ?? platform;
27
+ const multipart = reply.asMultipart();
28
+ const sendProgress = ({ completed, total }) => {
29
+ multipart?.writeChunk({ 'Content-Type': 'application/json' }, JSON.stringify({
30
+ done: completed,
31
+ total,
32
+ }));
33
+ };
34
+ try {
35
+ const asset = await delegate.compiler.getAsset(filename, platform, sendProgress);
36
+ const mimeType = delegate.compiler.getMimeType(filename, platform, asset);
37
+ if (multipart) {
38
+ const buffer = Buffer.isBuffer(asset) ? asset : Buffer.from(asset);
39
+ multipart.setHeader('Content-Type', `${mimeType}; charset=UTF-8`);
40
+ multipart.setHeader('Content-Length', String(Buffer.byteLength(buffer)));
41
+ multipart.end(buffer);
42
+ }
43
+ else {
44
+ return reply.code(200).type(mimeType).send(asset);
45
+ }
46
+ }
47
+ catch (error) {
48
+ request.log.error(error);
49
+ return reply.notFound(error.message);
50
+ }
51
+ },
52
+ });
61
53
  }
62
54
  export default fastifyPlugin(compilerPlugin, {
63
- name: 'compiler-plugin',
64
- dependencies: ['@fastify/sensible', 'multipart-plugin']
55
+ name: 'compiler-plugin',
56
+ dependencies: ['@fastify/sensible', 'multipart-plugin'],
65
57
  });
66
- //# sourceMappingURL=compilerPlugin.js.map
@@ -1,2 +1,2 @@
1
- export { default } from './compilerPlugin';
2
- export * from './types';
1
+ export { default } from './compilerPlugin.js';
2
+ export * from './types.js';
@@ -1,3 +1,2 @@
1
- export { default } from "./compilerPlugin.js";
2
- export * from "./types.js";
3
- //# sourceMappingURL=index.js.map
1
+ export { default } from './compilerPlugin.js';
2
+ export * from './types.js';
@@ -1,4 +1,4 @@
1
- import type { SendProgress } from '../../types';
1
+ import type { SendProgress } from '../../types.js';
2
2
  /**
3
3
  * Delegate with implementation for compiler-specific functions.
4
4
  */
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -1,5 +1,5 @@
1
1
  import type { FastifyInstance } from 'fastify';
2
- import type { Server } from '../../types';
2
+ import type { Server } from '../../types.js';
3
3
  declare function devtoolsPlugin(instance: FastifyInstance, { options }: {
4
4
  options: Server.Options;
5
5
  }): Promise<void>;
@@ -1,23 +1,20 @@
1
- import { openStackFrameInEditorMiddleware, openURLMiddleware } from '@react-native-community/cli-server-api';
1
+ import { openStackFrameInEditorMiddleware, openURLMiddleware, } from '@react-native-community/cli-server-api';
2
2
  import fastifyPlugin from 'fastify-plugin';
3
- async function devtoolsPlugin(instance, {
4
- options
5
- }) {
6
- instance.use('/open-url', openURLMiddleware);
7
- instance.use('/open-stack-frame', openStackFrameInEditorMiddleware({
8
- watchFolders: [options.rootDir]
9
- }));
10
- instance.route({
11
- method: ['GET', 'POST', 'PUT'],
12
- url: '/reload',
13
- handler: (_request, reply) => {
14
- instance.wss.messageServer.broadcast('reload');
15
- reply.send('OK');
16
- }
17
- });
3
+ async function devtoolsPlugin(instance, { options }) {
4
+ instance.use('/open-url', openURLMiddleware);
5
+ instance.use('/open-stack-frame', openStackFrameInEditorMiddleware({
6
+ watchFolders: [options.rootDir],
7
+ }));
8
+ instance.route({
9
+ method: ['GET', 'POST', 'PUT'],
10
+ url: '/reload',
11
+ handler: (_request, reply) => {
12
+ instance.wss.messageServer.broadcast('reload');
13
+ reply.send('OK');
14
+ },
15
+ });
18
16
  }
19
17
  export default fastifyPlugin(devtoolsPlugin, {
20
- name: 'devtools-plugin',
21
- dependencies: ['wss-plugin']
18
+ name: 'devtools-plugin',
19
+ dependencies: ['wss-plugin'],
22
20
  });
23
- //# sourceMappingURL=devtoolsPlugin.js.map
@@ -1 +1 @@
1
- export { default } from './devtoolsPlugin';
1
+ export { default } from './devtoolsPlugin.js';
@@ -1,2 +1 @@
1
- export { default } from "./devtoolsPlugin.js";
2
- //# sourceMappingURL=index.js.map
1
+ export { default } from './devtoolsPlugin.js';
@@ -2,16 +2,12 @@ import path from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import fastifyFavicon from 'fastify-favicon';
4
4
  import fastifyPlugin from 'fastify-plugin';
5
-
6
5
  // @ts-ignore
7
6
  const dirname = path.dirname(fileURLToPath(import.meta.url));
8
- const pathToImgDir = path.join(dirname, '../../img');
7
+ const pathToImgDir = path.join(dirname, '../../../static');
9
8
  async function faviconPlugin(instance) {
10
- instance.register(fastifyFavicon, {
11
- path: pathToImgDir
12
- });
9
+ instance.register(fastifyFavicon, { path: pathToImgDir });
13
10
  }
14
11
  export default fastifyPlugin(faviconPlugin, {
15
- name: 'favicon-plugin'
12
+ name: 'favicon-plugin',
16
13
  });
17
- //# sourceMappingURL=faviconPlugin.js.map
@@ -1 +1 @@
1
- export { default } from './faviconPlugin';
1
+ export { default } from './faviconPlugin.js';
@@ -1,2 +1 @@
1
- export { default } from "./faviconPlugin.js";
2
- //# sourceMappingURL=index.js.map
1
+ export { default } from './faviconPlugin.js';
@@ -1,2 +1,2 @@
1
- export { default } from './multipartPlugin';
2
- export * from './types';
1
+ export { default } from './multipartPlugin.js';
2
+ export * from './types.js';
@@ -1,3 +1,2 @@
1
- export { default } from "./multipartPlugin.js";
2
- export * from "./types.js";
3
- //# sourceMappingURL=index.js.map
1
+ export { default } from './multipartPlugin.js';
2
+ export * from './types.js';