@miniflare/durable-objects
Advanced tools
Comparing version 2.12.0 to 2.12.1
@@ -1011,2 +1011,4 @@ var __create = Object.create; | ||
} | ||
var STORAGE_PREFIX = "durable-objects:storage:"; | ||
var STATE_PREFIX = "durable-objects:state:"; | ||
var DurableObjectsPlugin = class extends import_shared5.Plugin { | ||
@@ -1023,4 +1025,3 @@ durableObjects; | ||
#bindings = {}; | ||
#objectStorages = new Map(); | ||
#objectStates = new Map(); | ||
#sharedCache; | ||
#alarmStore; | ||
@@ -1033,2 +1034,3 @@ #alarmStoreCallback; | ||
this.#persist = (0, import_shared5.resolveStoragePersist)(ctx.rootPath, this.durableObjectsPersist); | ||
this.#sharedCache = ctx.sharedCache; | ||
this.#alarmStore = new AlarmStore(); | ||
@@ -1044,7 +1046,8 @@ this.#processedObjects = Object.entries(this.durableObjects ?? {}).map(([name, options2]) => { | ||
const key = getObjectKeyFromId(id); | ||
let objectStorage = this.#objectStorages.get(key); | ||
const cacheKey = `${STORAGE_PREFIX}${key}`; | ||
let objectStorage = this.#sharedCache.get(cacheKey); | ||
if (objectStorage !== void 0) | ||
return objectStorage; | ||
objectStorage = new DurableObjectStorage(storage.storage(key, this.#persist), this.#alarmStore.buildBridge(key)); | ||
this.#objectStorages.set(key, objectStorage); | ||
this.#sharedCache.set(cacheKey, objectStorage); | ||
return objectStorage; | ||
@@ -1056,3 +1059,4 @@ } | ||
const key = getObjectKeyFromId(id); | ||
let state = this.#objectStates.get(key); | ||
const cacheKey = `${STATE_PREFIX}${key}`; | ||
let state = this.#sharedCache.get(cacheKey); | ||
if (state !== void 0) | ||
@@ -1064,3 +1068,3 @@ return state; | ||
state = new DurableObjectState(unnamedId, objectStorage); | ||
this.#objectStates.set(key, state); | ||
this.#sharedCache.set(cacheKey, state); | ||
const constructor = this.#constructors.get(objectName); | ||
@@ -1114,7 +1118,14 @@ (0, import_assert4.default)(constructor); | ||
getObjects(storageFactory, namespace) { | ||
return [...this.#objectStates.keys()].map(getObjectIdFromKey).filter((id) => id[kObjectName] === namespace); | ||
const ids = []; | ||
for (const cacheKey of this.#sharedCache.keys()) { | ||
if (cacheKey.startsWith(STATE_PREFIX)) { | ||
const key = cacheKey.substring(STATE_PREFIX.length); | ||
const id = getObjectIdFromKey(key); | ||
if (id[kObjectName] === namespace) | ||
ids.push(id); | ||
} | ||
} | ||
return ids; | ||
} | ||
async beforeReload() { | ||
this.#objectStorages.clear(); | ||
this.#objectStates.clear(); | ||
this.#contextPromise = new Promise((resolve) => this.#contextResolve = resolve); | ||
@@ -1121,0 +1132,0 @@ if (!this.#alarmStoreCallbackAttached && this.#alarmStoreCallback !== void 0) { |
{ | ||
"name": "@miniflare/durable-objects", | ||
"version": "2.12.0", | ||
"version": "2.12.1", | ||
"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.12.0", | ||
"@miniflare/shared": "2.12.0", | ||
"@miniflare/storage-memory": "2.12.0", | ||
"undici": "5.11.0" | ||
"@miniflare/core": "2.12.1", | ||
"@miniflare/shared": "2.12.1", | ||
"@miniflare/storage-memory": "2.12.1", | ||
"undici": "5.20.0" | ||
}, | ||
"devDependencies": { | ||
"@miniflare/cache": "2.12.0", | ||
"@miniflare/runner-vm": "2.12.0", | ||
"@miniflare/shared-test": "2.12.0" | ||
"@miniflare/cache": "2.12.1", | ||
"@miniflare/runner-vm": "2.12.1", | ||
"@miniflare/shared-test": "2.12.1" | ||
} | ||
} |
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
78186
1438
+ Added@miniflare/core@2.12.1(transitive)
+ Added@miniflare/queues@2.12.1(transitive)
+ Added@miniflare/shared@2.12.1(transitive)
+ Added@miniflare/storage-memory@2.12.1(transitive)
+ Added@miniflare/watcher@2.12.1(transitive)
+ Addedundici@5.20.0(transitive)
- Removed@miniflare/core@2.12.0(transitive)
- Removed@miniflare/queues@2.12.0(transitive)
- Removed@miniflare/shared@2.12.0(transitive)
- Removed@miniflare/storage-memory@2.12.0(transitive)
- Removed@miniflare/watcher@2.12.0(transitive)
- Removedundici@5.11.0(transitive)
Updated@miniflare/core@2.12.1
Updated@miniflare/shared@2.12.1
Updatedundici@5.20.0