@communecter/cocolight-api-client 1.0.14 → 1.0.16
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/339.cocolight-api-client.mjs.js +1 -0
- package/dist/394.cocolight-api-client.browser.js +1 -0
- package/dist/394.cocolight-api-client.cjs +1 -0
- package/dist/cocolight-api-client.browser.js +3 -3
- package/dist/cocolight-api-client.cjs +1 -1
- package/dist/cocolight-api-client.mjs.js +1 -1
- package/package.json +1 -1
- package/src/Api.js +2 -2
- package/src/ApiClient.js +191 -8
- package/src/api/UserApi.js +10 -4
- package/src/index.js +2 -1
- package/src/mixin/UtilMixin.js +3 -1
- package/src/utils/FileOfflineStorageStrategy.node.js +47 -0
- package/src/utils/OfflineClientManager.js +220 -0
- package/src/utils/OfflineQueueStorageStrategy.js +51 -0
- package/src/utils/createDefaultOfflineStrategy.js +29 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LocalStorageOfflineStorage, MemoryOfflineStorage } from "./OfflineQueueStorageStrategy.js";
|
|
2
|
+
|
|
3
|
+
export async function createDefaultOfflineStrategy(offlineStorageStrategy = "auto") {
|
|
4
|
+
if (offlineStorageStrategy === "memory") {
|
|
5
|
+
return new MemoryOfflineStorage();
|
|
6
|
+
}
|
|
7
|
+
if (offlineStorageStrategy === "localStorage") {
|
|
8
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
9
|
+
return new LocalStorageOfflineStorage();
|
|
10
|
+
} else {
|
|
11
|
+
throw new Error("localStorage is not available in this environment.");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (offlineStorageStrategy === "file") {
|
|
15
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
16
|
+
throw new Error("file storage is not available in this environment.");
|
|
17
|
+
}
|
|
18
|
+
const { FileOfflineStorage } = await import("./FileOfflineStorageStrategy.node.js");
|
|
19
|
+
return new FileOfflineStorage();
|
|
20
|
+
}
|
|
21
|
+
if (offlineStorageStrategy === "auto") {
|
|
22
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
23
|
+
return new LocalStorageOfflineStorage();
|
|
24
|
+
} else {
|
|
25
|
+
const { FileOfflineStorage } = await import("./FileOfflineStorageStrategy.node.js");
|
|
26
|
+
return new FileOfflineStorage();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|