zudoku 0.1.1-dev.19 → 0.1.1-dev.20

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.
@@ -1,12 +1,143 @@
1
- function e() {
2
- return new SharedWorker(new URL(
1
+ import { C as p, c as w, m as g, f as b } from "./urql-B7mLfVog.js";
2
+ function i(r) {
3
+ var e = new Error(r);
4
+ return e.source = "ulid", e;
5
+ }
6
+ var c = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", s = c.length, l = Math.pow(2, 48) - 1, f = 10, m = 16;
7
+ function h(r, e, n) {
8
+ return e > r.length - 1 ? r : r.substr(0, e) + n + r.substr(e + 1);
9
+ }
10
+ function N(r) {
11
+ for (var e = void 0, n = r.length, o = void 0, t = void 0, a = s - 1; !e && n-- >= 0; ) {
12
+ if (o = r[n], t = c.indexOf(o), t === -1)
13
+ throw i("incorrectly encoded string");
14
+ if (t === a) {
15
+ r = h(r, n, c[0]);
16
+ continue;
17
+ }
18
+ e = h(r, n, c[t + 1]);
19
+ }
20
+ if (typeof e == "string")
21
+ return e;
22
+ throw i("cannot increment this string");
23
+ }
24
+ function E(r) {
25
+ var e = Math.floor(r() * s);
26
+ return e === s && (e = s - 1), c.charAt(e);
27
+ }
28
+ function d(r, e) {
29
+ if (isNaN(r))
30
+ throw new Error(r + " must be a number");
31
+ if (r > l)
32
+ throw i("cannot encode time greater than " + l);
33
+ if (r < 0)
34
+ throw i("time must be positive");
35
+ if (Number.isInteger(r) === !1)
36
+ throw i("time must be an integer");
37
+ for (var n = void 0, o = ""; e > 0; e--)
38
+ n = r % s, o = c.charAt(n) + o, r = (r - n) / s;
39
+ return o;
40
+ }
41
+ function v(r, e) {
42
+ for (var n = ""; r > 0; r--)
43
+ n = E(e) + n;
44
+ return n;
45
+ }
46
+ function y() {
47
+ var r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, e = arguments[1];
48
+ e || (e = typeof window < "u" ? window : null);
49
+ var n = e && (e.crypto || e.msCrypto);
50
+ if (n)
51
+ return function() {
52
+ var t = new Uint8Array(1);
53
+ return n.getRandomValues(t), t[0] / 255;
54
+ };
55
+ try {
56
+ var o = require("crypto");
57
+ return function() {
58
+ return o.randomBytes(1).readUInt8() / 255;
59
+ };
60
+ } catch {
61
+ }
62
+ if (r) {
63
+ try {
64
+ console.error("secure crypto unusable, falling back to insecure Math.random()!");
65
+ } catch {
66
+ }
67
+ return function() {
68
+ return Math.random();
69
+ };
70
+ }
71
+ throw i("secure crypto unusable, insecure Math.random not allowed");
72
+ }
73
+ function C(r) {
74
+ return r || (r = y()), function(n) {
75
+ return isNaN(n) && (n = Date.now()), d(n, f) + v(m, r);
76
+ };
77
+ }
78
+ function M(r) {
79
+ r || (r = y());
80
+ var e = 0, n = void 0;
81
+ return function(t) {
82
+ if (isNaN(t) && (t = Date.now()), t <= e) {
83
+ var a = n = N(n);
84
+ return d(e, f) + a;
85
+ }
86
+ e = t;
87
+ var u = n = v(m, r);
88
+ return d(t, f) + u;
89
+ };
90
+ }
91
+ C();
92
+ const x = () => {
93
+ const r = /* @__PURE__ */ new Map();
94
+ return [(o) => new Promise((t) => {
95
+ r.set(o, t);
96
+ }), (o, t) => {
97
+ const a = r.get(o);
98
+ a && (a(t), r.delete(o));
99
+ }];
100
+ }, I = M(), A = () => {
101
+ const r = new SharedWorker(new URL(
3
102
  /* @vite-ignore */
4
103
  "./assets/worker-CnXQsqxH.js",
5
104
  import.meta.url
6
105
  ), {
7
106
  type: "module"
8
107
  });
9
- }
108
+ r.port.start();
109
+ const [e, n] = x();
110
+ return r.port.onmessage = (o) => {
111
+ n(o.data.id, o.data.body);
112
+ }, new p({
113
+ url: "/__z/graphql",
114
+ // Custom fetch to send the GraphQL request to the worker and convert the response back to a `Response` object
115
+ fetch: async (o, t) => {
116
+ if (!(t != null && t.body)) throw new Error("No body");
117
+ const a = I();
118
+ r.port.postMessage({
119
+ id: a,
120
+ body: t.body
121
+ });
122
+ const u = await e(a);
123
+ return new Response(u, {
124
+ headers: {
125
+ "Content-Type": "application/json"
126
+ }
127
+ });
128
+ },
129
+ exchanges: [
130
+ w,
131
+ g({
132
+ onError(o, t) {
133
+ var a;
134
+ console.error(o), console.groupCollapsed("Operation info"), console.log("body", (a = t.query.loc) == null ? void 0 : a.source.body.trim()), console.log("variables", t.variables), console.groupEnd();
135
+ }
136
+ }),
137
+ b
138
+ ]
139
+ });
140
+ };
10
141
  export {
11
- e as createSharedWorker
142
+ A as createSharedWorkerClient
12
143
  };