@callstack/repack-dev-server
Advanced tools
Comparing version 5.0.0-canary-20240912125430 to 5.0.0-canary-20241010230910
# @callstack/repack-dev-server | ||
## 5.0.0-canary-20240912125430 | ||
## 5.0.0-canary-20241010230910 | ||
## 5.0.0-alpha.0 | ||
## 4.3.3 | ||
## 4.3.2 | ||
@@ -6,0 +10,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { Server } from './types'; | ||
import { type Server } from './types'; | ||
/** | ||
@@ -3,0 +3,0 @@ * Create instance of development server, powered by Fastify. |
@@ -1,17 +0,16 @@ | ||
import { Writable } from 'stream'; | ||
import Fastify from 'fastify'; | ||
import { Writable } from 'node:stream'; | ||
import middie from '@fastify/middie'; | ||
import fastifySensible from '@fastify/sensible'; | ||
import middie from '@fastify/middie'; | ||
// eslint-disable-next-line import/no-unresolved -- no main field in package.json | ||
import { debuggerUIMiddleware } from '@react-native-community/cli-debugger-ui'; | ||
import { openStackFrameInEditorMiddleware, openURLMiddleware } from '@react-native-community/cli-server-api'; | ||
import { createDevMiddleware } from '@react-native/dev-middleware'; | ||
import { debuggerUIMiddleware } from '@react-native-community/cli-debugger-ui'; | ||
import { openURLMiddleware, openStackFrameInEditorMiddleware } from '@react-native-community/cli-server-api'; | ||
import Fastify from 'fastify'; | ||
import apiPlugin from "./plugins/api/index.js"; | ||
import compilerPlugin from "./plugins/compiler/index.js"; | ||
import devtoolsPlugin from "./plugins/devtools/index.js"; | ||
import faviconPlugin from "./plugins/favicon/index.js"; | ||
import multipartPlugin from "./plugins/multipart/index.js"; | ||
import compilerPlugin from "./plugins/compiler/index.js"; | ||
import apiPlugin from "./plugins/api/index.js"; | ||
import symbolicatePlugin from "./plugins/symbolicate/index.js"; | ||
import wssPlugin from "./plugins/wss/index.js"; | ||
import faviconPlugin from "./plugins/favicon/index.js"; | ||
import { Internal } from "./types.js"; | ||
import symbolicatePlugin from "./plugins/symbolicate/index.js"; | ||
import devtoolsPlugin from "./plugins/devtools/index.js"; | ||
/** | ||
@@ -24,2 +23,3 @@ * Create instance of development server, powered by Fastify. | ||
export async function createServer(config) { | ||
// biome-ignore lint/style/useConst: needed in fastify constructor | ||
let delegate; | ||
@@ -26,0 +26,0 @@ |
@@ -19,9 +19,9 @@ import fastifyPlugin from 'fastify-plugin'; | ||
handler: async (request, reply) => { | ||
let file = request.params['*']; | ||
const filename = request.params['*']; | ||
let { | ||
platform | ||
} = request.query; | ||
if (!file) { | ||
if (!filename) { | ||
// This technically should never happen - this route should not be called if file is missing. | ||
request.log.error(`File was not provided`); | ||
request.log.error('File was not provided'); | ||
return reply.notFound(); | ||
@@ -33,11 +33,2 @@ } | ||
platform = delegate.compiler.inferPlatform?.(request.url) ?? platform; | ||
if (!platform) { | ||
request.log.error('Cannot detect platform'); | ||
return reply.badRequest('Cannot detect platform'); | ||
} | ||
// If platform happens to be in front of an asset remove it. | ||
if (file.startsWith(`${platform}/`)) { | ||
file = file.replace(`${platform}/`, ''); | ||
} | ||
const multipart = reply.asMultipart(); | ||
@@ -56,4 +47,4 @@ const sendProgress = ({ | ||
try { | ||
const asset = await delegate.compiler.getAsset(file, platform, sendProgress); | ||
const mimeType = delegate.compiler.getMimeType(file, platform, asset); | ||
const asset = await delegate.compiler.getAsset(filename, platform, sendProgress); | ||
const mimeType = delegate.compiler.getMimeType(filename, platform, asset); | ||
if (multipart) { | ||
@@ -60,0 +51,0 @@ const buffer = Buffer.isBuffer(asset) ? asset : Buffer.from(asset); |
@@ -15,3 +15,3 @@ import type { SendProgress } from '../../types'; | ||
*/ | ||
getAsset: (filename: string, platform: string, sendProgress?: SendProgress) => Promise<string | Buffer>; | ||
getAsset: (filename: string, platform: string | undefined, sendProgress?: SendProgress) => Promise<string | Buffer>; | ||
/** | ||
@@ -24,3 +24,3 @@ * Detect MIME type of the asset from `filename`, `platform` or `data` (or from combination of either). | ||
*/ | ||
getMimeType: (filename: string, platform: string, data: string | Buffer) => string; | ||
getMimeType: (filename: string, platform: string | undefined, data: string | Buffer) => string; | ||
/** | ||
@@ -27,0 +27,0 @@ * Detect the platform from the URI - either from filename, query params or both. |
@@ -0,3 +1,3 @@ | ||
import fastifyPlugin from 'fastify-plugin'; | ||
import open from 'open'; | ||
import fastifyPlugin from 'fastify-plugin'; | ||
async function devtoolsPlugin(instance, { | ||
@@ -4,0 +4,0 @@ options |
@@ -1,3 +0,3 @@ | ||
import path from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import fastifyFavicon from 'fastify-favicon'; | ||
@@ -4,0 +4,0 @@ import fastifyPlugin from 'fastify-plugin'; |
@@ -1,2 +0,2 @@ | ||
import { PassThrough } from 'stream'; | ||
import { PassThrough } from 'node:stream'; | ||
import fastifyPlugin from 'fastify-plugin'; | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import type { IncomingHttpHeaders } from 'http'; | ||
import type { IncomingHttpHeaders } from 'node:http'; | ||
export interface MultipartHandler { | ||
@@ -3,0 +3,0 @@ writeChunk: <T>(headers: IncomingHttpHeaders, data: T, isLast?: boolean) => void; |
@@ -0,3 +1,3 @@ | ||
import type { FastifyLoggerInstance } from 'fastify'; | ||
import { SourceMapConsumer } from 'source-map'; | ||
import type { FastifyLoggerInstance } from 'fastify'; | ||
import type { ReactNativeStackFrame, SymbolicatorDelegate, SymbolicatorResults } from './types'; | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { URL } from 'url'; | ||
import { URL } from 'node:url'; | ||
import { codeFrameColumns } from '@babel/code-frame'; | ||
@@ -31,9 +31,8 @@ import { SourceMapConsumer } from 'source-map'; | ||
return platform; | ||
} else { | ||
const [bundleFilename] = pathname.split('/').reverse(); | ||
const [, platformOrExtension, extension] = bundleFilename.split('.'); | ||
if (extension) { | ||
return platformOrExtension; | ||
} | ||
} | ||
const [bundleFilename] = pathname.split('/').reverse(); | ||
const [, platformOrExtension, extension] = bundleFilename.split('.'); | ||
if (extension) { | ||
return platformOrExtension; | ||
} | ||
} | ||
@@ -40,0 +39,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { FastifyInstance } from 'fastify'; | ||
import WebSocket from 'ws'; | ||
import type { FastifyInstance } from 'fastify'; | ||
import type WebSocket from 'ws'; | ||
import { WebSocketServer } from '../WebSocketServer'; | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,4 +0,4 @@ | ||
import type { IncomingMessage } from 'http'; | ||
import type { IncomingMessage } from 'node:http'; | ||
import type { FastifyInstance } from 'fastify'; | ||
import WebSocket from 'ws'; | ||
import type WebSocket from 'ws'; | ||
import { WebSocketServer } from '../WebSocketServer'; | ||
@@ -5,0 +5,0 @@ /** |
@@ -1,3 +0,3 @@ | ||
import WebSocket from 'ws'; | ||
import type { FastifyInstance } from 'fastify'; | ||
import type WebSocket from 'ws'; | ||
import { WebSocketServer } from '../WebSocketServer'; | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,5 +0,5 @@ | ||
import WebSocket from 'ws'; | ||
import type { FastifyInstance } from 'fastify'; | ||
import type WebSocket from 'ws'; | ||
import { WebSocketServer } from '../WebSocketServer'; | ||
import { WebSocketMessageServer } from './WebSocketMessageServer'; | ||
import type { WebSocketMessageServer } from './WebSocketMessageServer'; | ||
/** | ||
@@ -6,0 +6,0 @@ * {@link WebSocketEventsServer} configuration options. |
@@ -1,6 +0,6 @@ | ||
import { IncomingMessage } from 'http'; | ||
import { FastifyInstance } from 'fastify'; | ||
import WebSocket from 'ws'; | ||
import { HmrDelegate } from '../types'; | ||
import type { IncomingMessage } from 'node:http'; | ||
import type { FastifyInstance } from 'fastify'; | ||
import type WebSocket from 'ws'; | ||
import { WebSocketServer } from '../WebSocketServer'; | ||
import type { HmrDelegate } from '../types'; | ||
/** | ||
@@ -7,0 +7,0 @@ * Class for creating a WebSocket server for Hot Module Replacement. |
@@ -1,2 +0,2 @@ | ||
import { URL } from 'url'; | ||
import { URL } from 'node:url'; | ||
import { WebSocketServer } from "../WebSocketServer.js"; | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,4 +0,4 @@ | ||
import type { IncomingMessage } from 'http'; | ||
import type { IncomingMessage } from 'node:http'; | ||
import type { FastifyInstance } from 'fastify'; | ||
import WebSocket from 'ws'; | ||
import type WebSocket from 'ws'; | ||
import { WebSocketServer } from '../WebSocketServer'; | ||
@@ -5,0 +5,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { URL } from 'url'; | ||
import { URL } from 'node:url'; | ||
import { WebSocketServer } from "../WebSocketServer.js"; | ||
@@ -221,6 +221,6 @@ /** | ||
} = new URL(peerSocket.upgradeReq?.url || ''); | ||
output[peerId] = [...searchParams.entries()].reduce((acc, [key, value]) => ({ | ||
...acc, | ||
[key]: value | ||
}), {}); | ||
output[peerId] = [...searchParams.entries()].reduce((acc, [key, value]) => { | ||
acc[key] = value; | ||
return acc; | ||
}, {}); | ||
} | ||
@@ -299,3 +299,3 @@ }); | ||
const clientId = `client#${this.nextClientId++}`; | ||
let client = socket; | ||
const client = socket; | ||
client.upgradeReq = request; | ||
@@ -302,0 +302,0 @@ this.clients.set(clientId, client); |
@@ -1,3 +0,3 @@ | ||
import { IncomingMessage } from 'node:http'; | ||
import { Socket } from 'node:net'; | ||
import type { IncomingMessage } from 'node:http'; | ||
import type { Socket } from 'node:net'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Delegate with implementation for HMR-specific functions. |
import type { FastifyInstance } from 'fastify'; | ||
import { WebSocketServerInterface } from './types'; | ||
import type { WebSocketServerInterface } from './types'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Class for creating a WebSocket router to forward connections to the |
@@ -1,6 +0,6 @@ | ||
import type { IncomingMessage } from 'http'; | ||
import type { Socket } from 'net'; | ||
import type { IncomingMessage } from 'node:http'; | ||
import type { Socket } from 'node:net'; | ||
import type { FastifyInstance } from 'fastify'; | ||
import { ServerOptions, WebSocket, WebSocketServer as WebSocketServerImpl } from 'ws'; | ||
import { WebSocketServerInterface } from './types'; | ||
import { type ServerOptions, type WebSocket, WebSocketServer as WebSocketServerImpl } from 'ws'; | ||
import type { WebSocketServerInterface } from './types'; | ||
/** | ||
@@ -7,0 +7,0 @@ * Abstract class for providing common logic (eg routing) for all WebSocket servers. |
import type { IncomingMessage } from 'node:http'; | ||
import type { Socket } from 'node:net'; | ||
import type { FastifyInstance } from 'fastify'; | ||
import type { WebSocketServer as WebSocketServer } from 'ws'; | ||
import type { WebSocketServer } from 'ws'; | ||
import type { WebSocketServerInterface } from './types'; | ||
@@ -6,0 +6,0 @@ export declare class WebSocketServerAdapter implements WebSocketServerInterface { |
@@ -17,4 +17,4 @@ export class WebSocketServerAdapter { | ||
upgrade(request, socket, head) { | ||
this.server.handleUpgrade(request, socket, head, webSocket => { | ||
this.server.emit('connection', webSocket, request); | ||
this.server?.handleUpgrade(request, socket, head, webSocket => { | ||
this.server?.emit('connection', webSocket, request); | ||
}); | ||
@@ -21,0 +21,0 @@ } |
import type { FastifyInstance } from 'fastify'; | ||
import type { Server } from '../../types'; | ||
import { WebSocketRouter } from './WebSocketRouter'; | ||
import { WebSocketServerAdapter } from './WebSocketServerAdapter'; | ||
import { WebSocketApiServer } from './servers/WebSocketApiServer'; | ||
import { WebSocketDebuggerServer } from './servers/WebSocketDebuggerServer'; | ||
import { WebSocketDevClientServer } from './servers/WebSocketDevClientServer'; | ||
import { WebSocketMessageServer } from './servers/WebSocketMessageServer'; | ||
import { WebSocketEventsServer } from './servers/WebSocketEventsServer'; | ||
import { WebSocketApiServer } from './servers/WebSocketApiServer'; | ||
import { WebSocketHMRServer } from './servers/WebSocketHMRServer'; | ||
import { WebSocketRouter } from './WebSocketRouter'; | ||
import { WebSocketServerAdapter } from './WebSocketServerAdapter'; | ||
import { WebSocketMessageServer } from './servers/WebSocketMessageServer'; | ||
declare module 'fastify' { | ||
@@ -12,0 +12,0 @@ interface FastifyInstance { |
import fastifyPlugin from 'fastify-plugin'; | ||
import { WebSocketRouter } from "./WebSocketRouter.js"; | ||
import { WebSocketServerAdapter } from "./WebSocketServerAdapter.js"; | ||
import { WebSocketApiServer } from "./servers/WebSocketApiServer.js"; | ||
import { WebSocketDebuggerServer } from "./servers/WebSocketDebuggerServer.js"; | ||
import { WebSocketDevClientServer } from "./servers/WebSocketDevClientServer.js"; | ||
import { WebSocketMessageServer } from "./servers/WebSocketMessageServer.js"; | ||
import { WebSocketEventsServer } from "./servers/WebSocketEventsServer.js"; | ||
import { WebSocketApiServer } from "./servers/WebSocketApiServer.js"; | ||
import { WebSocketHMRServer } from "./servers/WebSocketHMRServer.js"; | ||
import { WebSocketRouter } from "./WebSocketRouter.js"; | ||
import { WebSocketServerAdapter } from "./WebSocketServerAdapter.js"; | ||
import { WebSocketMessageServer } from "./servers/WebSocketMessageServer.js"; | ||
/** | ||
@@ -11,0 +11,0 @@ * Defined in @react-native/dev-middleware |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "5.0.0-canary-20240912125430", | ||
"version": "5.0.0-canary-20241010230910", | ||
"type": "module", | ||
@@ -59,3 +59,2 @@ "main": "./dist/index.js", | ||
"babel-plugin-add-import-extension": "^1.6.0", | ||
"eslint": "^8.57.0", | ||
"typescript": "^5.5.3" | ||
@@ -79,3 +78,2 @@ }, | ||
"build": "pnpm run \"/^build:.*/\"", | ||
"lint": "eslint --ext .ts src", | ||
"typecheck": "tsc --noEmit", | ||
@@ -82,0 +80,0 @@ "archive": "pnpm build && pnpm pack" |
@@ -5,3 +5,3 @@ <p align="center"> | ||
<p align="center"> | ||
A Webpack-based toolkit to build your React Native application with full support of Webpack ecosystem. | ||
A toolkit to build your React Native application with Rspack or Webpack. | ||
</p> | ||
@@ -8,0 +8,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
9
239355
2574