From 547fda99ba52ea5b2acc96819d14049f1f02c9c6 Mon Sep 17 00:00:00 2001 From: MrBBot Date: Mon, 13 Feb 2023 21:47:58 +0000 Subject: [PATCH] Move `Range` header handling to `@miniflare/core` (#499) `range.ts` was previously located in `@miniflare/shared`, but had a dependency on `Response` from `@miniflare/core`. `@miniflare/shared` isn't meant to have any `@miniflare/*` dependencies, so this change moves the implementation to `@miniflare/core`. --- packages/cache/src/cache.ts | 2 +- packages/core/src/standards/index.ts | 1 + packages/{shared/src => core/src/standards}/range.ts | 2 +- packages/{shared/test => core/test/standards}/range.spec.ts | 2 +- packages/r2/src/bucket.ts | 2 +- packages/shared/src/index.ts | 1 - 6 files changed, 5 insertions(+), 5 deletions(-) rename packages/{shared/src => core/src/standards}/range.ts (99%) rename packages/{shared/test => core/test/standards}/range.spec.ts (98%) diff --git a/packages/cache/src/cache.ts b/packages/cache/src/cache.ts index ce2730c5d..69bbf19aa 100644 --- a/packages/cache/src/cache.ts +++ b/packages/cache/src/cache.ts @@ -3,6 +3,7 @@ import { Request, RequestInfo, Response, + getRangeResponse, withImmutableHeaders, withStringFormDataFiles, } from "@miniflare/core"; @@ -12,7 +13,6 @@ import { Storage, assertInRequest, defaultClock, - getRangeResponse, getRequestContext, millisToSeconds, waitForOpenInputGate, diff --git a/packages/core/src/standards/index.ts b/packages/core/src/standards/index.ts index 0a4f104c2..e2471a891 100644 --- a/packages/core/src/standards/index.ts +++ b/packages/core/src/standards/index.ts @@ -51,4 +51,5 @@ export { } from "./streams"; export type { ArrayBufferViewConstructor } from "./streams"; export * from "./navigator"; +export * from "./range"; export * from "./timers"; diff --git a/packages/shared/src/range.ts b/packages/core/src/standards/range.ts similarity index 99% rename from packages/shared/src/range.ts rename to packages/core/src/standards/range.ts index 8193823f9..f79eb548b 100644 --- a/packages/shared/src/range.ts +++ b/packages/core/src/standards/range.ts @@ -1,7 +1,7 @@ import { ReadableStream } from "stream/web"; import { TextEncoder } from "util"; -import { Response } from "@miniflare/core"; import { Headers } from "undici"; +import { Response } from "./http"; const encoder = new TextEncoder(); diff --git a/packages/shared/test/range.spec.ts b/packages/core/test/standards/range.spec.ts similarity index 98% rename from packages/shared/test/range.spec.ts rename to packages/core/test/standards/range.spec.ts index 012f45301..43616bb0e 100644 --- a/packages/shared/test/range.spec.ts +++ b/packages/core/test/standards/range.spec.ts @@ -1,5 +1,5 @@ import assert from "assert"; -import { getRangeResponse, parseRanges } from "@miniflare/shared"; +import { getRangeResponse, parseRanges } from "@miniflare/core"; import { utf8Encode } from "@miniflare/shared-test"; import test from "ava"; import { Headers } from "undici"; diff --git a/packages/r2/src/bucket.ts b/packages/r2/src/bucket.ts index 410278461..46240cf1b 100644 --- a/packages/r2/src/bucket.ts +++ b/packages/r2/src/bucket.ts @@ -5,13 +5,13 @@ import crypto from "crypto"; import { arrayBuffer } from "stream/consumers"; import { ReadableStream } from "stream/web"; import { TextEncoder } from "util"; +import { parseRanges } from "@miniflare/core"; import { RangeStoredValueMeta, RequestContext, Storage, assertInRequest, getRequestContext, - parseRanges, viewToArray, waitForOpenInputGate, waitForOpenOutputGate, diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 6427997cd..4ad9efd88 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -6,7 +6,6 @@ export * from "./event"; export * from "./log"; export * from "./plugin"; export * from "./queues"; -export * from "./range"; export * from "./runner"; export * from "./storage"; export * from "./sync/";