Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .oxlintrc.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@
"curly": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/consistent-type-imports": "off",
"@typescript-eslint/no-floating-promises": "off",
"no-shadow": "off",
"no-useless-escape": "off",
Expand Down
4 changes: 2 additions & 2 deletions packages/miniflare/src/cf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
import path from "node:path";
import { dim } from "kleur/colors";
import { fetch } from "undici";
import { Plugins } from "./plugins";
import { Log, OptionalZodTypeOf } from "./shared";
import type { Plugins } from "./plugins";
import type { Log, OptionalZodTypeOf } from "./shared";
import type { IncomingRequestCfProperties } from "@cloudflare/workers-types/experimental";

/**
Expand Down
9 changes: 5 additions & 4 deletions packages/miniflare/src/http/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import assert from "node:assert";
import http from "node:http";
import { IncomingRequestCfProperties } from "@cloudflare/workers-types/experimental";
import * as undici from "undici";
import { UndiciHeaders } from "undici/types/dispatcher";
import NodeWebSocket from "ws";
import { CoreHeaders, DeferredPromise } from "../workers";
import { Request, RequestInfo, RequestInit } from "./request";
import { Request } from "./request";
import { Response } from "./response";
import { coupleWebSocket, WebSocketPair } from "./websocket";
import type { RequestInfo, RequestInit } from "./request";
import type { IncomingRequestCfProperties } from "@cloudflare/workers-types/experimental";
import type http from "node:http";
import type { UndiciHeaders } from "undici/types/dispatcher";

const ignored = ["transfer-encoding", "connection", "keep-alive", "expect"];

Expand Down
10 changes: 5 additions & 5 deletions packages/miniflare/src/http/request.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
Request as BaseRequest,
RequestInfo as BaseRequestInfo,
RequestInit as BaseRequestInit,
} from "undici";
import { Request as BaseRequest } from "undici";
import type {
IncomingRequestCfProperties,
RequestInitCfProperties,
} from "@cloudflare/workers-types/experimental";
import type {
RequestInfo as BaseRequestInfo,
RequestInit as BaseRequestInit,
} from "undici";

export type RequestInitCfType =
| Partial<IncomingRequestCfProperties>
Expand Down
6 changes: 3 additions & 3 deletions packages/miniflare/src/http/response.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
Response as BaseResponse,
import { Response as BaseResponse } from "undici";
import type { WebSocket } from "./websocket";
import type {
ResponseInit as BaseResponseInit,
BodyInit,
ResponseRedirectStatus,
} from "undici";
import { WebSocket } from "./websocket";

export interface ResponseInit extends BaseResponseInit {
webSocket?: WebSocket | null;
Expand Down
8 changes: 4 additions & 4 deletions packages/miniflare/src/http/server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import fs from "node:fs/promises";
import { z } from "zod";
import { CORE_PLUGIN } from "../plugins";
import { HttpOptions, Socket_Https } from "../runtime";
import { Awaitable } from "../workers";
import { CERT, KEY } from "./cert";
import type { CORE_PLUGIN } from "../plugins";
import type { HttpOptions, Socket_Https } from "../runtime";
import type { Awaitable } from "../workers";
import type { z } from "zod";

export async function getEntrySocketHttpOptions(
coreOpts: z.infer<typeof CORE_PLUGIN.sharedOptions>
Expand Down
3 changes: 2 additions & 1 deletion packages/miniflare/src/http/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import assert from "node:assert";
import { once } from "node:events";
import NodeWebSocket from "ws";
import { TypedEventTarget } from "../shared";
import { ValueOf, viewToBuffer } from "../workers";
import { viewToBuffer } from "../workers";
import type { ValueOf } from "../workers";

export class MessageEvent extends Event {
readonly data: string | ArrayBuffer | Uint8Array<ArrayBuffer>;
Expand Down
66 changes: 33 additions & 33 deletions packages/miniflare/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import assert from "node:assert";
import crypto from "node:crypto";
import { Abortable } from "node:events";
import fs from "node:fs";
import { mkdir, writeFile } from "node:fs/promises";
import http from "node:http";
import net from "node:net";
import os from "node:os";
import path from "node:path";
import { Duplex, Transform, Writable } from "node:stream";
import { ReadableStream } from "node:stream/web";
import util from "node:util";
import zlib from "node:zlib";
Expand All @@ -16,34 +14,26 @@ import { removeDir, removeDirSync } from "@cloudflare/workers-utils";
import exitHook from "exit-hook";
import { $ as colors$, green } from "kleur/colors";
import stoppable from "stoppable";
import {
Dispatcher,
getGlobalDispatcher,
Pool,
Response as UndiciResponse,
} from "undici";
import { getGlobalDispatcher, Pool } from "undici";
import SCRIPT_MINIFLARE_SHARED from "worker:shared/index";
import SCRIPT_MINIFLARE_ZOD from "worker:shared/zod";
import { WebSocketServer } from "ws";
import { z } from "zod";
import { fallbackCf, setupCf } from "./cf";
import {
coupleWebSocket,
DispatchFetch,
DispatchFetchDispatcher,
fetch,
getAccessibleHosts,
getEntrySocketHttpOptions,
Headers,
Request,
RequestInit,
Response,
} from "./http";
import {
BROWSER_RENDERING_PLUGIN_NAME,
D1_PLUGIN_NAME,
DURABLE_OBJECTS_PLUGIN_NAME,
DurableObjectClassNames,
getDirectSocketName,
getGlobalServices,
getPersistPath,
Expand All @@ -54,27 +44,18 @@ import {
launchBrowser,
loadExternalPlugins,
normaliseDurableObject,
Plugin,
PLUGIN_ENTRIES,
Plugins,
PluginServicesOptions,
ProxyClient,
ProxyNodeBinding,
QueueConsumers,
QueueProducers,
QUEUES_PLUGIN_NAME,
QueuesError,
R2_PLUGIN_NAME,
ReplaceWorkersTypes,
SECRET_STORE_PLUGIN_NAME,
SERVICE_ENTRY,
SharedOptions,
SOCKET_ENTRY,
SOCKET_ENTRY_LOCAL,
STREAM_PLUGIN_NAME,
WorkerOptions,
WORKFLOWS_PLUGIN_NAME,
WrappedBindingNames,
} from "./plugins";
import { RPC_PROXY_SERVICE_NAME } from "./plugins/assets/constants";
import {
Expand All @@ -84,35 +65,22 @@ import {
handlePrettyErrorRequest,
JsonErrorSchema,
maybeWrappedModuleToWorkerName,
NameSourceOptions,
reviveError,
ServiceDesignatorSchema,
} from "./plugins/core";
import { InspectorProxyController } from "./plugins/core/inspector-proxy";
import { HyperdriveProxyController } from "./plugins/hyperdrive/hyperdrive-proxy";
import { imagesLocalFetcher } from "./plugins/images/fetcher";
import {
Config,
Extension,
HttpOptions_Style,
kInspectorSocket,
Runtime,
RuntimeOptions,
serializeConfig,
Service,
Socket,
SocketIdentifier,
SocketPorts,
Worker_Binding,
Worker_Module,
} from "./runtime";
import {
_isCyclic,
isFileNotFoundError,
Log,
MiniflareCoreError,
NoOpLog,
OptionalZodTypeOf,
parseWithRootPath,
stripAnsi,
} from "./shared";
Expand Down Expand Up @@ -143,6 +111,35 @@ import {
} from "./workers";
import { ADMIN_API } from "./workers/secrets-store/constants";
import { formatZodError } from "./zod-format";
import type { DispatchFetch, RequestInit } from "./http";
import type {
DurableObjectClassNames,
Plugin,
Plugins,
PluginServicesOptions,
QueueConsumers,
QueueProducers,
ReplaceWorkersTypes,
SharedOptions,
WorkerOptions,
WrappedBindingNames,
} from "./plugins";
import type {
NameSourceOptions,
ServiceDesignatorSchema,
} from "./plugins/core";
import type {
Config,
Extension,
RuntimeOptions,
Service,
Socket,
SocketIdentifier,
SocketPorts,
Worker_Binding,
Worker_Module,
} from "./runtime";
import type { Log, OptionalZodTypeOf } from "./shared";
import type { WorkerDefinition } from "./shared/dev-registry-types";
import type {
CacheStorage,
Expand All @@ -157,6 +154,9 @@ import type {
StreamBinding,
} from "@cloudflare/workers-types/experimental";
import type { Process } from "@puppeteer/browsers";
import type { Abortable } from "node:events";
import type { Duplex, Transform, Writable } from "node:stream";
import type { Dispatcher, Response as UndiciResponse } from "undici";

const DEFAULT_HOST = "127.0.0.1";
function getURLSafeHost(host: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/miniflare/src/merge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WorkerOptions } from "./plugins";
import type { WorkerOptions } from "./plugins";

// https://github.com/Rich-Harris/devalue/blob/50af63e2b2c648f6e6ea29904a14faac25a581fc/src/utils.js#L31-L51
const objectProtoNames = Object.getOwnPropertyNames(Object.prototype)
Expand Down
3 changes: 1 addition & 2 deletions packages/miniflare/src/plugins/ai-search/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { z } from "zod";
import {
getUserBindingServiceName,
Plugin,
ProxyNodeBinding,
remoteProxyClientWorker,
RemoteProxyConnectionString,
} from "../shared";
import type { Plugin, RemoteProxyConnectionString } from "../shared";

const AISearchEntrySchema = z.object({
namespace: z.string().optional(),
Expand Down
3 changes: 1 addition & 2 deletions packages/miniflare/src/plugins/ai/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { z } from "zod";
import {
getUserBindingServiceName,
Plugin,
ProxyNodeBinding,
remoteProxyClientWorker,
RemoteProxyConnectionString,
} from "../shared";
import type { Plugin, RemoteProxyConnectionString } from "../shared";

const AISchema = z.object({
binding: z.string(),
Expand Down
5 changes: 3 additions & 2 deletions packages/miniflare/src/plugins/analytics-engine/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import ANALYTICS_ENGINE from "worker:analytics-engine/analytics-engine";
import { z } from "zod";
import { Worker_Binding } from "../../runtime";
import { PersistenceSchema, Plugin, ProxyNodeBinding } from "../shared";
import { PersistenceSchema, ProxyNodeBinding } from "../shared";
import type { Worker_Binding } from "../../runtime";
import type { Plugin } from "../shared";

const AnalyticsEngineSchema = z.record(
z.object({
Expand Down
11 changes: 6 additions & 5 deletions packages/miniflare/src/plugins/assets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
ENTRY_SIZE,
getContentType,
HEADER_SIZE,
Logger,
MAX_ASSET_COUNT,
MAX_ASSET_SIZE,
normalizeFilePath,
Expand All @@ -28,7 +27,6 @@ import {
maybeGetFile,
} from "@cloudflare/workers-shared/utils/helpers";
import {
AssetConfig,
HeadersSchema,
RedirectsSchema,
} from "@cloudflare/workers-shared/utils/types";
Expand All @@ -37,11 +35,9 @@ import SCRIPT_ASSETS from "worker:assets/assets";
import SCRIPT_ASSETS_KV from "worker:assets/assets-kv";
import SCRIPT_ROUTER from "worker:assets/router";
import SCRIPT_RPC_PROXY from "worker:assets/rpc-proxy";
import { z } from "zod";
import { Service } from "../../runtime";
import { SharedBindings } from "../../workers";
import { getUserServiceName } from "../core";
import { Plugin, ProxyNodeBinding } from "../shared";
import { ProxyNodeBinding } from "../shared";
import {
ASSETS_KV_SERVICE_NAME,
ASSETS_PLUGIN_NAME,
Expand All @@ -50,6 +46,11 @@ import {
RPC_PROXY_SERVICE_NAME,
} from "./constants";
import { AssetsOptionsSchema } from "./schema";
import type { Service } from "../../runtime";
import type { Plugin } from "../shared";
import type { Logger } from "@cloudflare/workers-shared";
import type { AssetConfig } from "@cloudflare/workers-shared/utils/types";
import type { z } from "zod";

export const ASSETS_PLUGIN: Plugin<typeof AssetsOptionsSchema> = {
options: AssetsOptionsSchema,
Expand Down
5 changes: 2 additions & 3 deletions packages/miniflare/src/plugins/browser-rendering/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ import { dim } from "kleur/colors";
import BROWSER_RENDERING_WORKER from "worker:browser-rendering/binding";
import { z } from "zod";
import { kVoid } from "../../runtime";
import { Log } from "../../shared";
import { getGlobalWranglerCachePath } from "../../shared/wrangler";
import {
getUserBindingServiceName,
Plugin,
ProxyNodeBinding,
remoteProxyClientWorker,
RemoteProxyConnectionString,
WORKER_BINDING_SERVICE_LOOPBACK,
} from "../shared";
import type { Log } from "../../shared";
import type { Plugin, RemoteProxyConnectionString } from "../shared";

const BrowserRenderingSchema = z.object({
binding: z.string(),
Expand Down
12 changes: 6 additions & 6 deletions packages/miniflare/src/plugins/cache/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import SCRIPT_CACHE_OBJECT from "worker:cache/cache";
import SCRIPT_CACHE_ENTRY from "worker:cache/cache-entry";
import SCRIPT_CACHE_ENTRY_NOOP from "worker:cache/cache-entry-noop";
import { z } from "zod";
import {
Service,
Worker,
Worker_Binding_DurableObjectNamespaceDesignator,
} from "../../runtime";
import { CacheBindings, SharedBindings } from "../../workers";
import {
getMiniflareObjectBindings,
getPersistPath,
PersistenceSchema,
Plugin,
SERVICE_LOOPBACK,
} from "../shared";
import type {
Service,
Worker,
Worker_Binding_DurableObjectNamespaceDesignator,
} from "../../runtime";
import type { Plugin } from "../shared";

export const CacheOptionsSchema = z.object({
cache: z.boolean().optional(),
Expand Down
Loading
Loading