@tinycloud/replica 0.4.5-beta.3 → 0.4.5-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kv-storage.js +1 -1
- package/dist/{kv-storage.worker.845167ca35516ebdaf4e9b2f667db81e465be7779dd4952a32c3d148241052fd.js → kv-storage.worker.4eb6410bd51645dbfb285409f17747981162454e86b9c68acb5ae2cdc8dfb3cd.js} +14 -11
- package/dist/kv-storage.worker.js +14 -11
- package/dist/kv-storage.worker.js.map +1 -1
- package/dist/replica.worker.js +14 -11
- package/dist/replica.worker.js.map +1 -1
- package/package.json +2 -2
package/dist/kv-storage.js
CHANGED
|
@@ -1527,7 +1527,7 @@ function spawn(source) {
|
|
|
1527
1527
|
if (source instanceof URL || typeof source === "string") return new Worker(source, { type: "module" });
|
|
1528
1528
|
if (typeof source === "function") return source();
|
|
1529
1529
|
}
|
|
1530
|
-
return new Worker(new URL("./kv-storage.worker.
|
|
1530
|
+
return new Worker(new URL("./kv-storage.worker.4eb6410bd51645dbfb285409f17747981162454e86b9c68acb5ae2cdc8dfb3cd.js", import.meta.url), { type: "module" });
|
|
1531
1531
|
}
|
|
1532
1532
|
var WorkerConnection = class {
|
|
1533
1533
|
ready;
|
|
@@ -8054,11 +8054,15 @@ var KVService = class extends BaseService {
|
|
|
8054
8054
|
}
|
|
8055
8055
|
/** Delay KV routing until an asynchronously loaded read-through is attached. */
|
|
8056
8056
|
setReadThroughReady(ready) {
|
|
8057
|
-
const
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8057
|
+
const start = () => {
|
|
8058
|
+
if (typeof ready === "function") ready = Promise.resolve().then(ready);
|
|
8059
|
+
const finish = () => {
|
|
8060
|
+
if (this.readThroughReady === start) this.readThroughReady = null;
|
|
8061
|
+
};
|
|
8062
|
+
return ready.then(finish, finish);
|
|
8063
|
+
};
|
|
8064
|
+
this.readThroughReady = start;
|
|
8065
|
+
if (typeof ready !== "function") void start();
|
|
8062
8066
|
}
|
|
8063
8067
|
/**
|
|
8064
8068
|
* Get the service configuration.
|
|
@@ -8305,7 +8309,6 @@ var KVService = class extends BaseService {
|
|
|
8305
8309
|
return aligned;
|
|
8306
8310
|
}
|
|
8307
8311
|
async batchRead(keys, action, options) {
|
|
8308
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
8309
8312
|
if (!this.requireAuth()) return err(authRequiredError("kv"));
|
|
8310
8313
|
if (keys.length === 0) return ok({ results: [], count: 0 });
|
|
8311
8314
|
if (keys.length > MAX_KV_BATCH_READ_ITEMS) {
|
|
@@ -8556,7 +8559,7 @@ var KVService = class extends BaseService {
|
|
|
8556
8559
|
*/
|
|
8557
8560
|
async get(key, options) {
|
|
8558
8561
|
return this.withTelemetry("get", key, async () => {
|
|
8559
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
8562
|
+
if (options?.source !== "network" && this.readThroughReady !== null) await this.readThroughReady();
|
|
8560
8563
|
if (!this.requireAuth()) {
|
|
8561
8564
|
return err(authRequiredError("kv"));
|
|
8562
8565
|
}
|
|
@@ -8675,7 +8678,7 @@ var KVService = class extends BaseService {
|
|
|
8675
8678
|
*/
|
|
8676
8679
|
async put(key, value, options) {
|
|
8677
8680
|
return this.withTelemetry("put", key, async () => {
|
|
8678
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
8681
|
+
if (this.readThroughReady !== null) await this.readThroughReady();
|
|
8679
8682
|
if (!this.requireAuth()) {
|
|
8680
8683
|
return err(authRequiredError("kv"));
|
|
8681
8684
|
}
|
|
@@ -8760,7 +8763,7 @@ var KVService = class extends BaseService {
|
|
|
8760
8763
|
*/
|
|
8761
8764
|
async batchPut(items, options) {
|
|
8762
8765
|
return this.withTelemetry("batchPut", String(items.length), async () => {
|
|
8763
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
8766
|
+
if (this.readThroughReady !== null) await this.readThroughReady();
|
|
8764
8767
|
if (!this.requireAuth()) {
|
|
8765
8768
|
return err(authRequiredError("kv"));
|
|
8766
8769
|
}
|
|
@@ -8959,7 +8962,7 @@ var KVService = class extends BaseService {
|
|
|
8959
8962
|
*/
|
|
8960
8963
|
async list(options) {
|
|
8961
8964
|
return this.withTelemetry("list", options?.prefix, async () => {
|
|
8962
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
8965
|
+
if (options?.source !== "network" && this.readThroughReady !== null) await this.readThroughReady();
|
|
8963
8966
|
if (!this.requireAuth()) {
|
|
8964
8967
|
return err(authRequiredError("kv"));
|
|
8965
8968
|
}
|
|
@@ -9247,7 +9250,7 @@ var KVService = class extends BaseService {
|
|
|
9247
9250
|
*/
|
|
9248
9251
|
async delete(key, options) {
|
|
9249
9252
|
return this.withTelemetry("delete", key, async () => {
|
|
9250
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
9253
|
+
if (this.readThroughReady !== null) await this.readThroughReady();
|
|
9251
9254
|
if (!this.requireAuth()) {
|
|
9252
9255
|
return err(authRequiredError("kv"));
|
|
9253
9256
|
}
|
|
@@ -8054,11 +8054,15 @@ var KVService = class extends BaseService {
|
|
|
8054
8054
|
}
|
|
8055
8055
|
/** Delay KV routing until an asynchronously loaded read-through is attached. */
|
|
8056
8056
|
setReadThroughReady(ready) {
|
|
8057
|
-
const
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8057
|
+
const start = () => {
|
|
8058
|
+
if (typeof ready === "function") ready = Promise.resolve().then(ready);
|
|
8059
|
+
const finish = () => {
|
|
8060
|
+
if (this.readThroughReady === start) this.readThroughReady = null;
|
|
8061
|
+
};
|
|
8062
|
+
return ready.then(finish, finish);
|
|
8063
|
+
};
|
|
8064
|
+
this.readThroughReady = start;
|
|
8065
|
+
if (typeof ready !== "function") void start();
|
|
8062
8066
|
}
|
|
8063
8067
|
/**
|
|
8064
8068
|
* Get the service configuration.
|
|
@@ -8305,7 +8309,6 @@ var KVService = class extends BaseService {
|
|
|
8305
8309
|
return aligned;
|
|
8306
8310
|
}
|
|
8307
8311
|
async batchRead(keys, action, options) {
|
|
8308
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
8309
8312
|
if (!this.requireAuth()) return err(authRequiredError("kv"));
|
|
8310
8313
|
if (keys.length === 0) return ok({ results: [], count: 0 });
|
|
8311
8314
|
if (keys.length > MAX_KV_BATCH_READ_ITEMS) {
|
|
@@ -8556,7 +8559,7 @@ var KVService = class extends BaseService {
|
|
|
8556
8559
|
*/
|
|
8557
8560
|
async get(key, options) {
|
|
8558
8561
|
return this.withTelemetry("get", key, async () => {
|
|
8559
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
8562
|
+
if (options?.source !== "network" && this.readThroughReady !== null) await this.readThroughReady();
|
|
8560
8563
|
if (!this.requireAuth()) {
|
|
8561
8564
|
return err(authRequiredError("kv"));
|
|
8562
8565
|
}
|
|
@@ -8675,7 +8678,7 @@ var KVService = class extends BaseService {
|
|
|
8675
8678
|
*/
|
|
8676
8679
|
async put(key, value, options) {
|
|
8677
8680
|
return this.withTelemetry("put", key, async () => {
|
|
8678
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
8681
|
+
if (this.readThroughReady !== null) await this.readThroughReady();
|
|
8679
8682
|
if (!this.requireAuth()) {
|
|
8680
8683
|
return err(authRequiredError("kv"));
|
|
8681
8684
|
}
|
|
@@ -8760,7 +8763,7 @@ var KVService = class extends BaseService {
|
|
|
8760
8763
|
*/
|
|
8761
8764
|
async batchPut(items, options) {
|
|
8762
8765
|
return this.withTelemetry("batchPut", String(items.length), async () => {
|
|
8763
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
8766
|
+
if (this.readThroughReady !== null) await this.readThroughReady();
|
|
8764
8767
|
if (!this.requireAuth()) {
|
|
8765
8768
|
return err(authRequiredError("kv"));
|
|
8766
8769
|
}
|
|
@@ -8959,7 +8962,7 @@ var KVService = class extends BaseService {
|
|
|
8959
8962
|
*/
|
|
8960
8963
|
async list(options) {
|
|
8961
8964
|
return this.withTelemetry("list", options?.prefix, async () => {
|
|
8962
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
8965
|
+
if (options?.source !== "network" && this.readThroughReady !== null) await this.readThroughReady();
|
|
8963
8966
|
if (!this.requireAuth()) {
|
|
8964
8967
|
return err(authRequiredError("kv"));
|
|
8965
8968
|
}
|
|
@@ -9247,7 +9250,7 @@ var KVService = class extends BaseService {
|
|
|
9247
9250
|
*/
|
|
9248
9251
|
async delete(key, options) {
|
|
9249
9252
|
return this.withTelemetry("delete", key, async () => {
|
|
9250
|
-
if (this.readThroughReady !== null) await this.readThroughReady;
|
|
9253
|
+
if (this.readThroughReady !== null) await this.readThroughReady();
|
|
9251
9254
|
if (!this.requireAuth()) {
|
|
9252
9255
|
return err(authRequiredError("kv"));
|
|
9253
9256
|
}
|