@stamprally/core 0.20.0 → 0.21.0
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/README.md +9 -4
- package/dist/index.cjs +13 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -5
- package/dist/index.d.ts +25 -5
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @stamprally/core v0.
|
|
1
|
+
# @stamprally/core v0.21.0
|
|
2
2
|
|
|
3
3
|
Dependency-free domain models, immutable state transitions, storage adapters, browser detectors, and safe configuration parsers.
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ import { InMemoryStorage, StampRallyClient, type PublicRallyConfig } from "@stam
|
|
|
7
7
|
|
|
8
8
|
const config: PublicRallyConfig = {
|
|
9
9
|
id: "city-tour",
|
|
10
|
-
version: "0.
|
|
10
|
+
version: "0.21.0",
|
|
11
11
|
title: "City Tour",
|
|
12
12
|
spots: [{ id: "station", orderIndex: 0, name: "Central Station", conditions: [{ type: "passcode" }] }],
|
|
13
13
|
rewards: [],
|
|
@@ -23,7 +23,7 @@ The browser detectors `getCurrentGeoContext`, `readNfcContext`, and `readQrConte
|
|
|
23
23
|
|
|
24
24
|
`InMemoryStorage`, `LocalStorageAdapter`, and `IndexedDBAdapter` implement `StampStorage`. `updateLocalizedField` updates one locale without dropping existing translations.
|
|
25
25
|
|
|
26
|
-
## v0.
|
|
26
|
+
## v0.21.0 offline synchronization
|
|
27
27
|
|
|
28
28
|
Configure `OfflineQueue` with `rallyId` and `userId` to persist pending work under
|
|
29
29
|
`stamprally:queue:<rallyId>:<userId-or-anonymous>`. `switchUser` loads the other
|
|
@@ -35,7 +35,7 @@ When no authenticated user is supplied, the client creates a persistent UUID v4
|
|
|
35
35
|
`anonymousSessionId` and includes it in sync requests. Queue replay uses Web Locks
|
|
36
36
|
when available and supports bounded exponential backoff through `retryOptions`.
|
|
37
37
|
|
|
38
|
-
### v0.
|
|
38
|
+
### v0.21.0 batch sync, queue capability, and storage capability
|
|
39
39
|
|
|
40
40
|
An adapter can return `SyncProgressResponse` from `sync` when it sends queued
|
|
41
41
|
operations to a server-side `syncProgress` endpoint. The adapter passes queued
|
|
@@ -62,6 +62,11 @@ cross-tab automatic synchronization is disabled, the foreground tab must trigger
|
|
|
62
62
|
sync explicitly, and a `storageCapabilityWarning` event is emitted. localStorage
|
|
63
63
|
may still be used for durable queue data, but it is never used as a lock.
|
|
64
64
|
|
|
65
|
+
`client.queueCapability` also exposes `mode` (`"persistent"` or
|
|
66
|
+
`"volatile_memory"`), `isPersistent`, and the actual `storage` type. The
|
|
67
|
+
deprecated `legacy` property and `getLegacyQueueCapability` helper expose
|
|
68
|
+
`"persistent"` or `"volatile"` while callers migrate to `mode`.
|
|
69
|
+
|
|
65
70
|
`evaluateSpotStatus` derives `UNCLAIMED`, `CLAIMED`, `LOCKED`, or `VERIFYING`
|
|
66
71
|
without mutating state. A spot with incomplete `prerequisites` is `LOCKED` and
|
|
67
72
|
must not be verified by a client or viewer.
|
package/dist/index.cjs
CHANGED
|
@@ -1007,6 +1007,9 @@ var IndexedDBAdapter = class {
|
|
|
1007
1007
|
};
|
|
1008
1008
|
|
|
1009
1009
|
// src/client/offlineQueue.ts
|
|
1010
|
+
function getLegacyQueueCapability(capability) {
|
|
1011
|
+
return capability.isPersistent ? "persistent" : "volatile";
|
|
1012
|
+
}
|
|
1010
1013
|
function rollbackOptimisticOperation(state, operation) {
|
|
1011
1014
|
const previous = operation.request.state;
|
|
1012
1015
|
if (operation.kind === "checkIn") {
|
|
@@ -1265,9 +1268,13 @@ var OfflineQueue = class {
|
|
|
1265
1268
|
return this.#operations.length;
|
|
1266
1269
|
}
|
|
1267
1270
|
get queueCapability() {
|
|
1271
|
+
const isPersistent = this.#queueCapability !== "memory";
|
|
1268
1272
|
return {
|
|
1269
1273
|
storage: this.#queueCapability,
|
|
1270
|
-
|
|
1274
|
+
mode: isPersistent ? "persistent" : "volatile_memory",
|
|
1275
|
+
multiTabSync: this.#hasWebLocks() ? "supported_web_locks" : "disabled_unsafe_environment",
|
|
1276
|
+
isPersistent,
|
|
1277
|
+
legacy: isPersistent ? "persistent" : "volatile"
|
|
1271
1278
|
};
|
|
1272
1279
|
}
|
|
1273
1280
|
get storageCapability() {
|
|
@@ -1991,7 +1998,10 @@ var StampRallyClient = class {
|
|
|
1991
1998
|
get queueCapability() {
|
|
1992
1999
|
return this.#offlineQueue?.queueCapability ?? {
|
|
1993
2000
|
storage: "custom",
|
|
1994
|
-
|
|
2001
|
+
mode: "persistent",
|
|
2002
|
+
multiTabSync: "disabled_unsafe_environment",
|
|
2003
|
+
isPersistent: true,
|
|
2004
|
+
legacy: "persistent"
|
|
1995
2005
|
};
|
|
1996
2006
|
}
|
|
1997
2007
|
get storageCapability() {
|
|
@@ -3481,6 +3491,7 @@ exports.evaluateConditionDetailed = evaluateConditionDetailed;
|
|
|
3481
3491
|
exports.evaluateSpotStatus = evaluateSpotStatus;
|
|
3482
3492
|
exports.exportProgressToken = exportProgressToken;
|
|
3483
3493
|
exports.getCurrentGeoContext = getCurrentGeoContext;
|
|
3494
|
+
exports.getLegacyQueueCapability = getLegacyQueueCapability;
|
|
3484
3495
|
exports.getOrderedSpots = getOrderedSpots;
|
|
3485
3496
|
exports.getSpotStatus = getSpotStatus;
|
|
3486
3497
|
exports.importProgressToken = importProgressToken;
|