@callstack/repack-dev-server 5.0.0-rc.1 → 5.0.0-rc.11

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 (92) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +18 -23
  3. package/dist/createServer.d.ts +3 -2
  4. package/dist/createServer.js +110 -123
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +2 -3
  7. package/dist/plugins/api/apiPlugin.d.ts +1 -1
  8. package/dist/plugins/api/apiPlugin.js +21 -28
  9. package/dist/plugins/api/index.d.ts +1 -1
  10. package/dist/plugins/api/index.js +1 -2
  11. package/dist/plugins/compiler/compilerPlugin.d.ts +1 -1
  12. package/dist/plugins/compiler/compilerPlugin.js +53 -62
  13. package/dist/plugins/compiler/index.d.ts +2 -2
  14. package/dist/plugins/compiler/index.js +2 -3
  15. package/dist/plugins/compiler/types.d.ts +1 -1
  16. package/dist/plugins/compiler/types.js +0 -1
  17. package/dist/plugins/devtools/devtoolsPlugin.d.ts +2 -3
  18. package/dist/plugins/devtools/devtoolsPlugin.js +16 -19
  19. package/dist/plugins/devtools/index.d.ts +1 -1
  20. package/dist/plugins/devtools/index.js +1 -2
  21. package/dist/plugins/favicon/faviconPlugin.js +3 -7
  22. package/dist/plugins/favicon/index.d.ts +1 -1
  23. package/dist/plugins/favicon/index.js +1 -2
  24. package/dist/plugins/multipart/index.d.ts +2 -2
  25. package/dist/plugins/multipart/index.js +2 -3
  26. package/dist/plugins/multipart/multipartPlugin.js +44 -42
  27. package/dist/plugins/multipart/types.js +0 -1
  28. package/dist/plugins/symbolicate/Symbolicator.d.ts +1 -1
  29. package/dist/plugins/symbolicate/Symbolicator.js +172 -190
  30. package/dist/plugins/symbolicate/index.d.ts +3 -3
  31. package/dist/plugins/symbolicate/index.js +3 -4
  32. package/dist/plugins/symbolicate/sybmolicatePlugin.d.ts +1 -1
  33. package/dist/plugins/symbolicate/sybmolicatePlugin.js +29 -40
  34. package/dist/plugins/symbolicate/types.js +0 -1
  35. package/dist/plugins/wss/WebSocketRouter.d.ts +1 -1
  36. package/dist/plugins/wss/WebSocketRouter.js +39 -44
  37. package/dist/plugins/wss/WebSocketServer.d.ts +1 -1
  38. package/dist/plugins/wss/WebSocketServer.js +23 -38
  39. package/dist/plugins/wss/WebSocketServerAdapter.d.ts +1 -1
  40. package/dist/plugins/wss/WebSocketServerAdapter.js +16 -19
  41. package/dist/plugins/wss/index.d.ts +3 -3
  42. package/dist/plugins/wss/index.js +3 -4
  43. package/dist/plugins/wss/servers/WebSocketApiServer.d.ts +1 -1
  44. package/dist/plugins/wss/servers/WebSocketApiServer.js +47 -53
  45. package/dist/plugins/wss/servers/WebSocketDevClientServer.d.ts +1 -1
  46. package/dist/plugins/wss/servers/WebSocketDevClientServer.js +58 -80
  47. package/dist/plugins/wss/servers/WebSocketEventsServer.d.ts +2 -2
  48. package/dist/plugins/wss/servers/WebSocketEventsServer.js +146 -164
  49. package/dist/plugins/wss/servers/WebSocketHMRServer.d.ts +2 -2
  50. package/dist/plugins/wss/servers/WebSocketHMRServer.js +72 -79
  51. package/dist/plugins/wss/servers/WebSocketMessageServer.d.ts +1 -1
  52. package/dist/plugins/wss/servers/WebSocketMessageServer.js +309 -326
  53. package/dist/plugins/wss/types.js +0 -1
  54. package/dist/plugins/wss/wssPlugin.d.ts +11 -10
  55. package/dist/plugins/wss/wssPlugin.js +37 -42
  56. package/dist/types.d.ts +30 -24
  57. package/dist/types.js +8 -18
  58. package/dist/utils/normalizeOptions.d.ts +12 -0
  59. package/dist/utils/normalizeOptions.js +28 -0
  60. package/package.json +4 -8
  61. package/CHANGELOG.md +0 -158
  62. package/dist/createServer.js.map +0 -1
  63. package/dist/index.js.map +0 -1
  64. package/dist/plugins/api/apiPlugin.js.map +0 -1
  65. package/dist/plugins/api/index.js.map +0 -1
  66. package/dist/plugins/compiler/compilerPlugin.js.map +0 -1
  67. package/dist/plugins/compiler/index.js.map +0 -1
  68. package/dist/plugins/compiler/types.js.map +0 -1
  69. package/dist/plugins/devtools/devtoolsPlugin.js.map +0 -1
  70. package/dist/plugins/devtools/index.js.map +0 -1
  71. package/dist/plugins/favicon/faviconPlugin.js.map +0 -1
  72. package/dist/plugins/favicon/index.js.map +0 -1
  73. package/dist/plugins/multipart/index.js.map +0 -1
  74. package/dist/plugins/multipart/multipartPlugin.js.map +0 -1
  75. package/dist/plugins/multipart/types.js.map +0 -1
  76. package/dist/plugins/symbolicate/Symbolicator.js.map +0 -1
  77. package/dist/plugins/symbolicate/index.js.map +0 -1
  78. package/dist/plugins/symbolicate/sybmolicatePlugin.js.map +0 -1
  79. package/dist/plugins/symbolicate/types.js.map +0 -1
  80. package/dist/plugins/wss/WebSocketRouter.js.map +0 -1
  81. package/dist/plugins/wss/WebSocketServer.js.map +0 -1
  82. package/dist/plugins/wss/WebSocketServerAdapter.js.map +0 -1
  83. package/dist/plugins/wss/index.js.map +0 -1
  84. package/dist/plugins/wss/servers/WebSocketApiServer.js.map +0 -1
  85. package/dist/plugins/wss/servers/WebSocketDevClientServer.js.map +0 -1
  86. package/dist/plugins/wss/servers/WebSocketEventsServer.js.map +0 -1
  87. package/dist/plugins/wss/servers/WebSocketHMRServer.js.map +0 -1
  88. package/dist/plugins/wss/servers/WebSocketMessageServer.js.map +0 -1
  89. package/dist/plugins/wss/types.js.map +0 -1
  90. package/dist/plugins/wss/wssPlugin.js.map +0 -1
  91. package/dist/types.js.map +0 -1
  92. /package/{dist/img → static}/favicon.ico +0 -0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Callstack
3
+ Copyright (c) 2025 Callstack
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,32 +1,27 @@
1
- <p align="center">
2
- <img src="https://raw.githubusercontent.com/callstack/repack/HEAD/logo.png">
3
- </p>
4
- <p align="center">
5
- A toolkit to build your React Native application with Rspack or Webpack.
6
- </p>
1
+ <div align="center">
2
+ <img src="https://raw.githubusercontent.com/callstack/repack/HEAD/logo.png" width="650" alt="Re.Pack logo" />
3
+ <h3>A toolkit to build your React Native application with Rspack or Webpack.</h3>
4
+ </div>
5
+ <div align="center">
7
6
 
8
- ---
9
-
10
- [![Build Status][build-badge]][build]
11
- [![Version][version-badge]][version]
12
- [![MIT License][license-badge]][license]
7
+ [![mit licence][license-badge]][license]
8
+ [![npm downloads][npm-downloads-badge]][npm-downloads]
9
+ [![Chat][chat-badge]][chat]
13
10
  [![PRs Welcome][prs-welcome-badge]][prs-welcome]
14
- [![Code of Conduct][coc-badge]][coc]
15
11
 
16
- `@callstack/repack-dev-sever` is bundler-agnostic development server for React Native applications as part of `@callstack/repack`.
12
+ </div>
13
+
14
+ `@callstack/repack-dev-server` is a bundler-agnostic development server for React Native applications as part of [`@callstack/repack`](https://github.com/callstack/repack).
17
15
 
18
16
  Check out our website at https://re-pack.dev for more info and documentation or out GitHub: https://github.com/callstack/repack.
19
17
 
20
18
  <!-- badges -->
21
19
 
22
- [callstack-readme-with-love]: https://callstack.com/?utm_source=github.com&utm_medium=referral&utm_campaign=react-native-paper&utm_term=readme-with-love
23
- [build-badge]: https://img.shields.io/github/workflow/status/callstack/repack/CI/main?style=flat-square
24
- [build]: https://github.com/callstack/repack/actions/workflows/main.yml
25
- [version-badge]: https://img.shields.io/npm/v/@callstack/repack-dev-server?style=flat-square
26
- [version]: https://www.npmjs.com/package/@callstack/repack-dev-server
27
- [license-badge]: https://img.shields.io/npm/l/@callstack/repack-debugger-app?style=flat-square
28
- [license]: https://github.com/callstack/repack/blob/master/LICENSE
29
- [prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
20
+ [license-badge]: https://img.shields.io/npm/l/@callstack/repack?style=for-the-badge
21
+ [license]: https://github.com/callstack/repack/blob/main/LICENSE
22
+ [npm-downloads-badge]: https://img.shields.io/npm/dm/@callstack/repack?style=for-the-badge
23
+ [npm-downloads]: https://www.npmjs.com/package/@callstack/repack
24
+ [prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
30
25
  [prs-welcome]: ./CONTRIBUTING.md
31
- [coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
32
- [coc]: https://github.com/callstack/repack/blob/master/CODE_OF_CONDUCT.md
26
+ [chat-badge]: https://img.shields.io/discord/426714625279524876.svg?style=for-the-badge
27
+ [chat]: https://discord.gg/Q4yr2rTWYF
@@ -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,15 @@ 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
+ import { normalizeOptions } from './utils/normalizeOptions.js';
14
15
  /**
15
16
  * Create instance of development server, powered by Fastify.
16
17
  *
@@ -18,122 +19,108 @@ import { Internal } from "./types.js";
18
19
  * @returns `start` and `stop` functions as well as an underlying Fastify `instance`.
19
20
  */
20
21
  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();
22
+ // biome-ignore lint/style/useConst: needed in fastify constructor
23
+ let delegate;
24
+ const options = normalizeOptions(config.options);
25
+ /** Fastify instance powering the development server. */
26
+ const instance = Fastify({
27
+ disableRequestLogging: options.disableRequestLogging,
28
+ logger: {
29
+ level: 'trace',
30
+ stream: new Writable({
31
+ write: (chunk, _encoding, callback) => {
32
+ const log = JSON.parse(chunk.toString());
33
+ delegate?.logger.onMessage(log);
34
+ instance.wss?.apiServer.send(log);
35
+ callback();
36
+ },
37
+ }),
38
+ },
39
+ ...(options.https ? { https: options.https } : {}),
40
+ });
41
+ delegate = config.delegate({
42
+ options,
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: ({ method, params }) => {
60
+ instance.wss.messageServer.broadcast(method, params);
61
+ },
62
+ });
63
+ const devMiddleware = createDevMiddleware({
64
+ projectRoot: options.rootDir,
65
+ serverBaseUrl: options.url,
66
+ logger: instance.log,
67
+ unstable_experiments: {
68
+ // @ts-expect-error removed in 0.76, keep this for backkwards compatibility
69
+ enableNewDebugger: true,
70
+ },
71
+ });
72
+ // Register plugins
73
+ await instance.register(fastifySensible);
74
+ await instance.register(middie);
75
+ await instance.register(wssPlugin, {
76
+ delegate,
77
+ endpoints: devMiddleware.websocketEndpoints,
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
+ rootDir: options.rootDir,
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', 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: options.port,
114
+ host: 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,7 +1,6 @@
1
1
  import type { FastifyInstance } from 'fastify';
2
- import type { Server } from '../../types';
3
- declare function devtoolsPlugin(instance: FastifyInstance, { options }: {
4
- options: Server.Options;
2
+ declare function devtoolsPlugin(instance: FastifyInstance, { rootDir }: {
3
+ rootDir: string;
5
4
  }): Promise<void>;
6
5
  declare const _default: typeof devtoolsPlugin;
7
6
  export default _default;
@@ -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, { rootDir }) {
4
+ instance.use('/open-url', openURLMiddleware);
5
+ instance.use('/open-stack-frame', openStackFrameInEditorMiddleware({
6
+ watchFolders: [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';