@anfenn/dync 1.0.15 → 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.
@@ -31,8 +31,33 @@ var ApiError = class extends Error {
31
31
  this.cause = cause;
32
32
  }
33
33
  };
34
+ var SyncAction = /* @__PURE__ */ ((SyncAction2) => {
35
+ SyncAction2["Create"] = "create";
36
+ SyncAction2["Update"] = "update";
37
+ SyncAction2["Remove"] = "remove";
38
+ return SyncAction2;
39
+ })(SyncAction || {});
40
+
41
+ // src/createLocalId.ts
42
+ function createLocalId() {
43
+ if (typeof globalThis.crypto?.randomUUID === "function") {
44
+ return globalThis.crypto.randomUUID();
45
+ }
46
+ throw new Error("createLocalId(): crypto.randomUUID is not available");
47
+ }
48
+
49
+ // src/helpers.ts
50
+ function parseApiError(error) {
51
+ if (error instanceof ApiError) {
52
+ return error;
53
+ }
54
+ if (typeof error === "string") {
55
+ return new ApiError(error, false);
56
+ }
57
+ return new ApiError(error.message, isNetworkError(error), error);
58
+ }
34
59
  function isNetworkError(error) {
35
- const message = error.message.toLowerCase();
60
+ const message = error.message?.toLowerCase() ?? "";
36
61
  const name = error.name;
37
62
  if (name === "TypeError" && (message.includes("failed to fetch") || message.includes("network request failed"))) {
38
63
  return true;
@@ -52,32 +77,6 @@ function isNetworkError(error) {
52
77
  }
53
78
  return false;
54
79
  }
55
- function parseApiError(error) {
56
- if (error instanceof ApiError) {
57
- return error;
58
- }
59
- if (error instanceof Error) {
60
- return new ApiError(error.message, isNetworkError(error), error);
61
- }
62
- const message = String(error);
63
- return new ApiError(message, false);
64
- }
65
- var SyncAction = /* @__PURE__ */ ((SyncAction2) => {
66
- SyncAction2["Create"] = "create";
67
- SyncAction2["Update"] = "update";
68
- SyncAction2["Remove"] = "remove";
69
- return SyncAction2;
70
- })(SyncAction || {});
71
-
72
- // src/createLocalId.ts
73
- function createLocalId() {
74
- if (typeof globalThis.crypto?.randomUUID === "function") {
75
- return globalThis.crypto.randomUUID();
76
- }
77
- throw new Error("createLocalId(): crypto.randomUUID is not available");
78
- }
79
-
80
- // src/helpers.ts
81
80
  function sleep(ms, signal) {
82
81
  return new Promise((resolve) => {
83
82
  if (signal?.aborted) {
@@ -3807,4 +3806,4 @@ export {
3807
3806
  SqliteQueryContext,
3808
3807
  SQLiteAdapter2 as SQLiteAdapter
3809
3808
  };
3810
- //# sourceMappingURL=chunk-I4L3W4PX.js.map
3809
+ //# sourceMappingURL=chunk-NJF2KCLA.js.map