@miniflare/durable-objects
Advanced tools
Comparing version 2.0.0-rc.4 to 2.0.0-rc.5
import { Awaitable } from '@miniflare/shared'; | ||
import { Compatibility } from '@miniflare/shared'; | ||
import { Context } from '@miniflare/shared'; | ||
import { Log } from '@miniflare/shared'; | ||
import { MiniflareError } from '@miniflare/shared'; | ||
import { Mount } from '@miniflare/shared'; | ||
import { Plugin } from '@miniflare/shared'; | ||
@@ -59,3 +58,3 @@ import { PluginContext } from '@miniflare/shared'; | ||
#private; | ||
constructor(objectName: string, factory: DurableObjectFactory, compat?: Compatibility, log?: Log); | ||
constructor(objectName: string, factory: DurableObjectFactory, ctx?: PluginContext); | ||
newUniqueId(_options?: NewUniqueIdOptions): DurableObjectId; | ||
@@ -100,3 +99,3 @@ idFromName(name: string): DurableObjectId; | ||
beforeReload(): void; | ||
reload(bindings: Context, moduleExports: Context, mountedModuleExports: Record<string, Context>): void; | ||
reload(bindings: Context, moduleExports: Context, mounts: Map<string, Mount>): void; | ||
dispose(): void; | ||
@@ -133,3 +132,3 @@ } | ||
readonly id: DurableObjectId; | ||
constructor(factory: DurableObjectFactory, id: DurableObjectId, compat?: Compatibility, log?: Log); | ||
constructor(factory: DurableObjectFactory, id: DurableObjectId, ctx?: PluginContext); | ||
get name(): string | undefined; | ||
@@ -136,0 +135,0 @@ fetch(input: RequestInfo, init?: RequestInit): Promise<Response>; |
@@ -100,11 +100,9 @@ var __create = Object.create; | ||
var DurableObjectStub = class { | ||
constructor(factory, id, compat, log) { | ||
constructor(factory, id, ctx) { | ||
this.id = id; | ||
this.#factory = factory; | ||
this.#compat = compat; | ||
this.#log = log; | ||
this.#ctx = ctx; | ||
} | ||
#factory; | ||
#compat; | ||
#log; | ||
#ctx; | ||
get name() { | ||
@@ -115,3 +113,3 @@ return this.id.name; | ||
const state = await this.#factory(this.id); | ||
if (!this.#compat?.isEnabled("durable_object_fetch_requires_full_url") && typeof input === "string") { | ||
if (!this.#ctx?.compat.isEnabled("durable_object_fetch_requires_full_url") && typeof input === "string") { | ||
input = new import_url.URL(input, "https://fake-host"); | ||
@@ -121,10 +119,16 @@ } | ||
if (url.protocol !== "http:" && url.protocol !== "https:") { | ||
if (this.#compat?.isEnabled("fetch_refuses_unknown_protocols")) { | ||
if (this.#ctx?.compat.isEnabled("fetch_refuses_unknown_protocols")) { | ||
throw new TypeError(`Fetch API cannot load: ${url.toString()}`); | ||
} else { | ||
this.#log?.warn((0, import_core._buildUnknownProtocolWarning)(url)); | ||
this.#ctx?.log.warn((0, import_core._buildUnknownProtocolWarning)(url)); | ||
} | ||
} | ||
const req = input instanceof import_core.Request && !init ? input : new import_core.Request(input, init); | ||
const res = await new import_shared2.RequestContext().runWith(() => state[kFetch]((0, import_core.withInputGating)((0, import_core.withImmutableHeaders)(req)))); | ||
const parentContext = (0, import_shared2.getRequestContext)(); | ||
const requestDepth = (parentContext?.requestDepth ?? 0) + 1; | ||
const res = await new import_shared2.RequestContext({ | ||
requestDepth, | ||
pipelineDepth: 1, | ||
durableObject: true | ||
}).runWith(() => state[kFetch]((0, import_core.withInputGating)((0, import_core.withImmutableHeaders)(req)))); | ||
const validRes = res instanceof import_core.Response || res instanceof import_undici.Response; | ||
@@ -143,5 +147,4 @@ if (!validRes) { | ||
#objectNameHashHex; | ||
#compat; | ||
#log; | ||
constructor(objectName, factory, compat, log) { | ||
#ctx; | ||
constructor(objectName, factory, ctx) { | ||
this.#objectName = objectName; | ||
@@ -151,4 +154,3 @@ this.#factory = factory; | ||
this.#objectNameHashHex = hexEncode(this.#objectNameHash); | ||
this.#compat = compat; | ||
this.#log = log; | ||
this.#ctx = ctx; | ||
} | ||
@@ -182,3 +184,3 @@ newUniqueId(_options) { | ||
} | ||
return new DurableObjectStub(this.#factory, id, this.#compat, this.#log); | ||
return new DurableObjectStub(this.#factory, id, this.#ctx); | ||
} | ||
@@ -781,3 +783,3 @@ }; | ||
const factory = (id) => this.getObject(storage, id); | ||
return new DurableObjectNamespace(objectName, factory, this.ctx.compat, this.ctx.log); | ||
return new DurableObjectNamespace(objectName, factory, this.ctx); | ||
} | ||
@@ -798,3 +800,3 @@ setup(storageFactory) { | ||
} | ||
reload(bindings, moduleExports, mountedModuleExports) { | ||
reload(bindings, moduleExports, mounts) { | ||
this.#constructors.clear(); | ||
@@ -806,5 +808,5 @@ for (const { name, className, scriptName } of this.#processedObjects) { | ||
} else { | ||
const scriptExports = mountedModuleExports[scriptName]; | ||
const scriptExports = mounts.get(scriptName)?.moduleExports; | ||
if (!scriptExports) { | ||
throw new DurableObjectError("ERR_SCRIPT_NOT_FOUND", `Script ${scriptName} for Durable Object ${name} not found`); | ||
throw new DurableObjectError("ERR_SCRIPT_NOT_FOUND", `Script "${scriptName}" for Durable Object "${name}" not found`); | ||
} | ||
@@ -816,4 +818,4 @@ constructor = scriptExports[className]; | ||
} else { | ||
const script = scriptName ? ` in script ${scriptName}` : ""; | ||
throw new DurableObjectError("ERR_CLASS_NOT_FOUND", `Class ${className}${script} for Durable Object ${name} not found`); | ||
const script = scriptName ? ` in script "${scriptName}"` : ""; | ||
throw new DurableObjectError("ERR_CLASS_NOT_FOUND", `Class "${className}"${script} for Durable Object "${name}" not found`); | ||
} | ||
@@ -820,0 +822,0 @@ } |
{ | ||
"name": "@miniflare/durable-objects", | ||
"version": "2.0.0-rc.4", | ||
"version": "2.0.0-rc.5", | ||
"description": "Durable Objects module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers", | ||
@@ -38,12 +38,12 @@ "keywords": [ | ||
"dependencies": { | ||
"@miniflare/core": "2.0.0-rc.4", | ||
"@miniflare/shared": "2.0.0-rc.4", | ||
"@miniflare/storage-memory": "2.0.0-rc.4", | ||
"@miniflare/core": "2.0.0-rc.5", | ||
"@miniflare/shared": "2.0.0-rc.5", | ||
"@miniflare/storage-memory": "2.0.0-rc.5", | ||
"undici": "^4.11.1" | ||
}, | ||
"devDependencies": { | ||
"@miniflare/cache": "2.0.0-rc.4", | ||
"@miniflare/runner-vm": "2.0.0-rc.4", | ||
"@miniflare/shared-test": "2.0.0-rc.4" | ||
"@miniflare/cache": "2.0.0-rc.5", | ||
"@miniflare/runner-vm": "2.0.0-rc.5", | ||
"@miniflare/shared-test": "2.0.0-rc.5" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56242
1028
+ Added@miniflare/core@2.0.0-rc.5(transitive)
+ Added@miniflare/shared@2.0.0-rc.5(transitive)
+ Added@miniflare/storage-memory@2.0.0-rc.5(transitive)
- Removed@miniflare/core@2.0.0-rc.4(transitive)
- Removed@miniflare/shared@2.0.0-rc.4(transitive)
- Removed@miniflare/storage-memory@2.0.0-rc.4(transitive)
Updated@miniflare/core@2.0.0-rc.5
Updated@miniflare/shared@2.0.0-rc.5