@lmvz-ds/components 0.12.5-alpha.5 → 0.13.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/dist/{esm/Effect-BhQLGXPs.js → cjs/assets-CB5ikzmP.js} +857 -4832
- package/dist/cjs/{icons-7wUEcWEo.js → icons-DM_TTn48.js} +363 -113
- package/dist/cjs/{index-CVw4GUo6.js → index-Bp6Dd2i1.js} +4 -2
- package/dist/cjs/{index-9ZJx0550.js → index-D3BMpL5w.js} +0 -3
- package/dist/cjs/index.cjs.js +4 -6
- package/dist/cjs/lmvz-action.cjs.entry.js +1 -1
- package/dist/cjs/lmvz-button.cjs.entry.js +7 -10
- package/dist/cjs/lmvz-card.cjs.entry.js +3 -4
- package/dist/cjs/lmvz-chip.cjs.entry.js +1 -1
- package/dist/cjs/lmvz-components.cjs.js +1 -1
- package/dist/cjs/lmvz-header.cjs.entry.js +13 -12
- package/dist/cjs/lmvz-icon.cjs.entry.js +8 -10
- package/dist/cjs/lmvz-input.cjs.entry.js +8 -11
- package/dist/cjs/lmvz-menuitem.cjs.entry.js +5 -7
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/reactive-controller-host-BMDEj1kX.js +168 -0
- package/dist/collection/components/lmvz-button/lmvz-button.js +4 -4
- package/dist/collection/components/lmvz-header/lmvz-header.js +11 -8
- package/dist/collection/components/lmvz-icon/lmvz-icon.js +2 -2
- package/dist/collection/components/lmvz-icon/test/icons.unit.js +21 -12
- package/dist/collection/components/lmvz-input/lmvz-input.css +5 -2
- package/dist/collection/components/lmvz-input/lmvz-input.js +3 -3
- package/dist/collection/components/lmvz-menuitem/lmvz-menuitem.js +4 -4
- package/dist/collection/integration/header-integration.js +4 -2
- package/dist/collection/utils/{validation → aria}/aria-validation-controller.js +15 -34
- package/dist/collection/utils/{list-keyboard-controller.js → aria/list-keyboard-controller.js} +1 -1
- package/dist/collection/utils/{http.test.js → http.unit.js} +7 -6
- package/dist/components/index.js +1 -1
- package/dist/components/lmvz-action.js +1 -1
- package/dist/components/lmvz-button.js +1 -1
- package/dist/components/lmvz-card.js +1 -1
- package/dist/components/lmvz-chip.js +1 -1
- package/dist/components/lmvz-header.js +1 -1
- package/dist/components/lmvz-icon.js +1 -1
- package/dist/components/lmvz-input.js +1 -1
- package/dist/components/lmvz-menuitem.js +1 -1
- package/dist/components/p-BBDH9X49.js +1 -0
- package/dist/components/{p-DMLRPGid.js → p-BfTCfPZ1.js} +1 -1
- package/dist/components/p-Bs6_m7Uw.js +1 -0
- package/dist/components/p-CMteT-Yo.js +1 -0
- package/dist/components/p-vi4YzJmv.js +1 -0
- package/dist/{cjs/Effect-CNhHt4Xb.js → esm/assets-ozES4zSA.js} +785 -5032
- package/dist/esm/{icons-Bx1wWPM2.js → icons-kpJZ1u9g.js} +268 -18
- package/dist/esm/{index-Bt32KzDW.js → index-BfTCfPZ1.js} +3 -1
- package/dist/esm/{index-smGPjoDX.js → index-T5ljELGS.js} +1 -3
- package/dist/esm/index.js +3 -5
- package/dist/esm/lmvz-action.entry.js +1 -1
- package/dist/esm/lmvz-button.entry.js +5 -8
- package/dist/esm/lmvz-card.entry.js +2 -3
- package/dist/esm/lmvz-chip.entry.js +1 -1
- package/dist/esm/lmvz-components.js +2 -2
- package/dist/esm/lmvz-header.entry.js +11 -10
- package/dist/esm/lmvz-icon.entry.js +5 -7
- package/dist/esm/lmvz-input.entry.js +6 -9
- package/dist/esm/lmvz-menuitem.entry.js +3 -5
- package/dist/esm/loader.js +2 -2
- package/dist/esm/reactive-controller-host-CZ3dGAjR.js +165 -0
- package/dist/lmvz-components/index.esm.js +1 -1
- package/dist/lmvz-components/lmvz-components.esm.js +1 -1
- package/dist/lmvz-components/p-16878d4c.entry.js +1 -0
- package/dist/lmvz-components/p-4ad8c332.entry.js +1 -0
- package/dist/lmvz-components/p-5eee0752.entry.js +1 -0
- package/dist/lmvz-components/p-8ea1a349.entry.js +1 -0
- package/dist/lmvz-components/{p-d4b68381.entry.js → p-980688a0.entry.js} +1 -1
- package/dist/lmvz-components/{p-DMLRPGid.js → p-BfTCfPZ1.js} +1 -1
- package/dist/lmvz-components/p-CZ3dGAjR.js +1 -0
- package/dist/lmvz-components/p-D9lc4ayG.js +1 -0
- package/dist/lmvz-components/p-T5ljELGS.js +2 -0
- package/dist/lmvz-components/p-a34542fa.entry.js +1 -0
- package/dist/lmvz-components/p-d2bf6a3f.entry.js +1 -0
- package/dist/lmvz-components/{p-9faac8f3.entry.js → p-feda2ec5.entry.js} +1 -1
- package/dist/lmvz-components/p-iviTjlUy.js +1 -0
- package/dist/manifest.json +3 -3
- package/dist/types/components/lmvz-button/lmvz-button.d.ts +2 -2
- package/dist/types/components/lmvz-header/lmvz-header.d.ts +5 -4
- package/dist/types/components/lmvz-icon/lmvz-icon.d.ts +1 -1
- package/dist/types/components/lmvz-input/lmvz-input.d.ts +1 -1
- package/dist/types/components/lmvz-menuitem/lmvz-menuitem.d.ts +2 -2
- package/dist/types/components.d.ts +6 -0
- package/dist/types/utils/{validation → aria}/aria-validation-controller.d.ts +1 -5
- package/dist/types/utils/{element-activation-controller.d.ts → aria/element-activation-controller.d.ts} +2 -2
- package/dist/types/utils/{list-keyboard-controller.d.ts → aria/list-keyboard-controller.d.ts} +1 -1
- package/hydrate/index.js +9610 -50169
- package/hydrate/index.mjs +9610 -50169
- package/package.json +17 -18
- package/readme.md +18 -0
- package/dist/cjs/MutableQueue-Bk9tBfaK.js +0 -462
- package/dist/cjs/_commonjsHelpers-CFO10eej.js +0 -7
- package/dist/cjs/aria-validation-controller-B3hMkau3.js +0 -2930
- package/dist/cjs/assets-BguFB3wV.js +0 -71
- package/dist/cjs/axe-BNqwbBGU.js +0 -32834
- package/dist/components/p-3I3wZmp8.js +0 -1
- package/dist/components/p-B85MJLTf.js +0 -1
- package/dist/components/p-BaPwpeMs.js +0 -1
- package/dist/components/p-CAi33KTt.js +0 -1
- package/dist/components/p-CdofjRtQ.js +0 -1
- package/dist/components/p-D1HbKFuh.js +0 -12
- package/dist/components/p-UwhTS2ue.js +0 -1
- package/dist/esm/MutableQueue-CNlEFklh.js +0 -431
- package/dist/esm/_commonjsHelpers-B85MJLTf.js +0 -5
- package/dist/esm/aria-validation-controller-iA4YWFG-.js +0 -2927
- package/dist/esm/assets-Iu8neKuE.js +0 -67
- package/dist/esm/axe-cRQ9Ux1I.js +0 -32832
- package/dist/lmvz-components/p-1a10fcbd.entry.js +0 -1
- package/dist/lmvz-components/p-274c36df.entry.js +0 -1
- package/dist/lmvz-components/p-4XIjw3k8.js +0 -1
- package/dist/lmvz-components/p-4b70fe08.entry.js +0 -1
- package/dist/lmvz-components/p-51Fb_qqD.js +0 -1
- package/dist/lmvz-components/p-68001ab7.entry.js +0 -1
- package/dist/lmvz-components/p-77e26e71.entry.js +0 -1
- package/dist/lmvz-components/p-B85MJLTf.js +0 -1
- package/dist/lmvz-components/p-BhQLGXPs.js +0 -1
- package/dist/lmvz-components/p-CXWyvf0D.js +0 -1
- package/dist/lmvz-components/p-D1HbKFuh.js +0 -12
- package/dist/lmvz-components/p-D7I-Bc5i.js +0 -1
- package/dist/lmvz-components/p-c8b78793.entry.js +0 -1
- package/dist/lmvz-components/p-smGPjoDX.js +0 -2
- /package/dist/collection/utils/{element-activation-controller.js → aria/element-activation-controller.js} +0 -0
- /package/dist/types/utils/{http.test.d.ts → http.unit.d.ts} +0 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var MutableQueue = require('./MutableQueue-Bk9tBfaK.js');
|
|
5
|
-
var assets = require('./assets-BguFB3wV.js');
|
|
3
|
+
var assets = require('./assets-CB5ikzmP.js');
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* This module provides types and utility functions to create and work with branded types,
|
|
@@ -38,22 +36,274 @@ const error = (message, meta) => [{
|
|
|
38
36
|
meta
|
|
39
37
|
}];
|
|
40
38
|
function refined(...args) {
|
|
41
|
-
const either = args.length === 2 ? unbranded => args[0](unbranded) ?
|
|
42
|
-
return
|
|
43
|
-
onNone: () =>
|
|
44
|
-
onSome:
|
|
39
|
+
const either = args.length === 2 ? unbranded => args[0](unbranded) ? assets.right(unbranded) : assets.left(args[1](unbranded)) : unbranded => {
|
|
40
|
+
return assets.match(args[0](unbranded), {
|
|
41
|
+
onNone: () => assets.right(unbranded),
|
|
42
|
+
onSome: assets.left
|
|
45
43
|
});
|
|
46
44
|
};
|
|
47
|
-
return Object.assign(unbranded =>
|
|
45
|
+
return Object.assign(unbranded => assets.getOrThrowWith(either(unbranded), assets.identity), {
|
|
48
46
|
[RefinedConstructorsTypeId]: RefinedConstructorsTypeId,
|
|
49
|
-
option: args =>
|
|
47
|
+
option: args => assets.getRight(either(args)),
|
|
50
48
|
either,
|
|
51
|
-
is: args =>
|
|
49
|
+
is: args => assets.isRight(either(args))
|
|
52
50
|
});
|
|
53
51
|
}
|
|
54
52
|
|
|
53
|
+
const _await = assets.deferredAwait;
|
|
54
|
+
/**
|
|
55
|
+
* Exits the `Deferred` with the specified `Exit` value, which will be
|
|
56
|
+
* propagated to all fibers waiting on the value of the `Deferred`.
|
|
57
|
+
*
|
|
58
|
+
* @since 2.0.0
|
|
59
|
+
* @category utils
|
|
60
|
+
*/
|
|
61
|
+
const done = assets.deferredDone;
|
|
62
|
+
/**
|
|
63
|
+
* Completes the `Deferred` with interruption. This will interrupt all fibers
|
|
64
|
+
* waiting on the value of the `Deferred` with the `FiberId` of the fiber
|
|
65
|
+
* calling this method.
|
|
66
|
+
*
|
|
67
|
+
* @since 2.0.0
|
|
68
|
+
* @category utils
|
|
69
|
+
*/
|
|
70
|
+
const interrupt = assets.deferredInterrupt;
|
|
71
|
+
/**
|
|
72
|
+
* Unsafely creates a new `Deferred` from the specified `FiberId`.
|
|
73
|
+
*
|
|
74
|
+
* @since 2.0.0
|
|
75
|
+
* @category unsafe
|
|
76
|
+
*/
|
|
77
|
+
const unsafeMake = assets.deferredUnsafeMake;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Constructs a new `Exit.Success` containing the specified value of type `A`.
|
|
81
|
+
*
|
|
82
|
+
* @since 2.0.0
|
|
83
|
+
* @category constructors
|
|
84
|
+
*/
|
|
85
|
+
const succeed = assets.exitSucceed;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @since 2.0.0
|
|
89
|
+
*/
|
|
90
|
+
const TypeId$1 = /*#__PURE__*/Symbol.for("effect/MutableList");
|
|
91
|
+
const MutableListProto = {
|
|
92
|
+
[TypeId$1]: TypeId$1,
|
|
93
|
+
[Symbol.iterator]() {
|
|
94
|
+
let done = false;
|
|
95
|
+
let head = this.head;
|
|
96
|
+
return {
|
|
97
|
+
next() {
|
|
98
|
+
if (done) {
|
|
99
|
+
return this.return();
|
|
100
|
+
}
|
|
101
|
+
if (head == null) {
|
|
102
|
+
done = true;
|
|
103
|
+
return this.return();
|
|
104
|
+
}
|
|
105
|
+
const value = head.value;
|
|
106
|
+
head = head.next;
|
|
107
|
+
return {
|
|
108
|
+
done,
|
|
109
|
+
value
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
return(value) {
|
|
113
|
+
if (!done) {
|
|
114
|
+
done = true;
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
done: true,
|
|
118
|
+
value
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
toString() {
|
|
124
|
+
return assets.format(this.toJSON());
|
|
125
|
+
},
|
|
126
|
+
toJSON() {
|
|
127
|
+
return {
|
|
128
|
+
_id: "MutableList",
|
|
129
|
+
values: Array.from(this).map(assets.toJSON)
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
[assets.NodeInspectSymbol]() {
|
|
133
|
+
return this.toJSON();
|
|
134
|
+
},
|
|
135
|
+
pipe() {
|
|
136
|
+
return assets.pipeArguments(this, arguments);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
/** @internal */
|
|
140
|
+
const makeNode = value => ({
|
|
141
|
+
value,
|
|
142
|
+
removed: false,
|
|
143
|
+
prev: undefined,
|
|
144
|
+
next: undefined
|
|
145
|
+
});
|
|
146
|
+
/**
|
|
147
|
+
* Creates an empty `MutableList`.
|
|
148
|
+
*
|
|
149
|
+
* @since 2.0.0
|
|
150
|
+
* @category constructors
|
|
151
|
+
*/
|
|
152
|
+
const empty = () => {
|
|
153
|
+
const list = Object.create(MutableListProto);
|
|
154
|
+
list.head = undefined;
|
|
155
|
+
list.tail = undefined;
|
|
156
|
+
list._length = 0;
|
|
157
|
+
return list;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Returns `true` if the list contains zero elements, `false`, otherwise.
|
|
161
|
+
*
|
|
162
|
+
* @since 2.0.0
|
|
163
|
+
* @category getters
|
|
164
|
+
*/
|
|
165
|
+
const isEmpty = self => length(self) === 0;
|
|
166
|
+
/**
|
|
167
|
+
* Returns the length of the list.
|
|
168
|
+
*
|
|
169
|
+
* @since 2.0.0
|
|
170
|
+
* @category getters
|
|
171
|
+
*/
|
|
172
|
+
const length = self => self._length;
|
|
173
|
+
/**
|
|
174
|
+
* Appends the specified element to the end of the `MutableList`.
|
|
175
|
+
*
|
|
176
|
+
* @category concatenating
|
|
177
|
+
* @since 2.0.0
|
|
178
|
+
*/
|
|
179
|
+
const append = /*#__PURE__*/assets.dual(2, (self, value) => {
|
|
180
|
+
const node = makeNode(value);
|
|
181
|
+
if (self.head === undefined) {
|
|
182
|
+
self.head = node;
|
|
183
|
+
}
|
|
184
|
+
if (self.tail === undefined) {
|
|
185
|
+
self.tail = node;
|
|
186
|
+
} else {
|
|
187
|
+
self.tail.next = node;
|
|
188
|
+
node.prev = self.tail;
|
|
189
|
+
self.tail = node;
|
|
190
|
+
}
|
|
191
|
+
self._length += 1;
|
|
192
|
+
return self;
|
|
193
|
+
});
|
|
194
|
+
/**
|
|
195
|
+
* Removes the first value from the list and returns it, if it exists.
|
|
196
|
+
*
|
|
197
|
+
* @since 0.0.1
|
|
198
|
+
*/
|
|
199
|
+
const shift = self => {
|
|
200
|
+
const head = self.head;
|
|
201
|
+
if (head !== undefined) {
|
|
202
|
+
remove(self, head);
|
|
203
|
+
return head.value;
|
|
204
|
+
}
|
|
205
|
+
return undefined;
|
|
206
|
+
};
|
|
207
|
+
const remove = (self, node) => {
|
|
208
|
+
if (node.removed) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
node.removed = true;
|
|
212
|
+
if (node.prev !== undefined && node.next !== undefined) {
|
|
213
|
+
node.prev.next = node.next;
|
|
214
|
+
node.next.prev = node.prev;
|
|
215
|
+
} else if (node.prev !== undefined) {
|
|
216
|
+
self.tail = node.prev;
|
|
217
|
+
node.prev.next = undefined;
|
|
218
|
+
} else if (node.next !== undefined) {
|
|
219
|
+
self.head = node.next;
|
|
220
|
+
node.next.prev = undefined;
|
|
221
|
+
} else {
|
|
222
|
+
self.tail = undefined;
|
|
223
|
+
self.head = undefined;
|
|
224
|
+
}
|
|
225
|
+
if (self._length > 0) {
|
|
226
|
+
self._length -= 1;
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* @since 2.0.0
|
|
232
|
+
*/
|
|
233
|
+
const TypeId = /*#__PURE__*/Symbol.for("effect/MutableQueue");
|
|
234
|
+
/**
|
|
235
|
+
* @since 2.0.0
|
|
236
|
+
* @category symbol
|
|
237
|
+
*/
|
|
238
|
+
const EmptyMutableQueue = /*#__PURE__*/Symbol.for("effect/mutable/MutableQueue/Empty");
|
|
239
|
+
const MutableQueueProto = {
|
|
240
|
+
[TypeId]: TypeId,
|
|
241
|
+
[Symbol.iterator]() {
|
|
242
|
+
return Array.from(this.queue)[Symbol.iterator]();
|
|
243
|
+
},
|
|
244
|
+
toString() {
|
|
245
|
+
return assets.format(this.toJSON());
|
|
246
|
+
},
|
|
247
|
+
toJSON() {
|
|
248
|
+
return {
|
|
249
|
+
_id: "MutableQueue",
|
|
250
|
+
values: Array.from(this).map(assets.toJSON)
|
|
251
|
+
};
|
|
252
|
+
},
|
|
253
|
+
[assets.NodeInspectSymbol]() {
|
|
254
|
+
return this.toJSON();
|
|
255
|
+
},
|
|
256
|
+
pipe() {
|
|
257
|
+
return assets.pipeArguments(this, arguments);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const make$2 = capacity => {
|
|
261
|
+
const queue = Object.create(MutableQueueProto);
|
|
262
|
+
queue.queue = empty();
|
|
263
|
+
queue.capacity = capacity;
|
|
264
|
+
return queue;
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Creates a new unbounded `MutableQueue`.
|
|
268
|
+
*
|
|
269
|
+
* @since 2.0.0
|
|
270
|
+
* @category constructors
|
|
271
|
+
*/
|
|
272
|
+
const unbounded = () => make$2(undefined);
|
|
273
|
+
/**
|
|
274
|
+
* Offers an element to the queue.
|
|
275
|
+
*
|
|
276
|
+
* Returns whether the enqueue was successful or not.
|
|
277
|
+
*
|
|
278
|
+
* @since 2.0.0
|
|
279
|
+
*/
|
|
280
|
+
const offer = /*#__PURE__*/assets.dual(2, (self, value) => {
|
|
281
|
+
const queueLength = length(self.queue);
|
|
282
|
+
if (self.capacity !== undefined && queueLength === self.capacity) {
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
append(value)(self.queue);
|
|
286
|
+
return true;
|
|
287
|
+
});
|
|
288
|
+
/**
|
|
289
|
+
* Dequeues an element from the queue.
|
|
290
|
+
*
|
|
291
|
+
* Returns either an element from the queue, or the `def` param.
|
|
292
|
+
*
|
|
293
|
+
* **Note**: if there is no meaningful default for your type, you can always
|
|
294
|
+
* use `poll(MutableQueue.EmptyMutableQueue)`.
|
|
295
|
+
*
|
|
296
|
+
* @since 2.0.0
|
|
297
|
+
*/
|
|
298
|
+
const poll = /*#__PURE__*/assets.dual(2, (self, def) => {
|
|
299
|
+
if (isEmpty(self.queue)) {
|
|
300
|
+
return def;
|
|
301
|
+
}
|
|
302
|
+
return shift(self.queue);
|
|
303
|
+
});
|
|
304
|
+
|
|
55
305
|
/** @internal */
|
|
56
|
-
const complete = (key, exit, entryStats, timeToLiveMillis) =>
|
|
306
|
+
const complete = (key, exit, entryStats, timeToLiveMillis) => assets.struct({
|
|
57
307
|
_tag: "Complete",
|
|
58
308
|
key,
|
|
59
309
|
exit,
|
|
@@ -61,13 +311,13 @@ const complete = (key, exit, entryStats, timeToLiveMillis) => Effect.struct({
|
|
|
61
311
|
timeToLiveMillis
|
|
62
312
|
});
|
|
63
313
|
/** @internal */
|
|
64
|
-
const pending = (key, deferred) =>
|
|
314
|
+
const pending = (key, deferred) => assets.struct({
|
|
65
315
|
_tag: "Pending",
|
|
66
316
|
key,
|
|
67
317
|
deferred
|
|
68
318
|
});
|
|
69
319
|
/** @internal */
|
|
70
|
-
const refreshing = (deferred, complete) =>
|
|
320
|
+
const refreshing = (deferred, complete) => assets.struct({
|
|
71
321
|
_tag: "Refreshing",
|
|
72
322
|
deferred,
|
|
73
323
|
complete
|
|
@@ -82,20 +332,20 @@ class MapKeyImpl {
|
|
|
82
332
|
constructor(current) {
|
|
83
333
|
this.current = current;
|
|
84
334
|
}
|
|
85
|
-
[
|
|
86
|
-
return
|
|
335
|
+
[assets.symbol]() {
|
|
336
|
+
return assets.pipe(assets.hash(this.current), assets.combine(assets.hash(this.previous)), assets.combine(assets.hash(this.next)), assets.cached(this));
|
|
87
337
|
}
|
|
88
|
-
[
|
|
338
|
+
[assets.symbol$1](that) {
|
|
89
339
|
if (this === that) {
|
|
90
340
|
return true;
|
|
91
341
|
}
|
|
92
|
-
return isMapKey(that) &&
|
|
342
|
+
return isMapKey(that) && assets.equals(this.current, that.current) && assets.equals(this.previous, that.previous) && assets.equals(this.next, that.next);
|
|
93
343
|
}
|
|
94
344
|
}
|
|
95
345
|
/** @internal */
|
|
96
346
|
const makeMapKey = current => new MapKeyImpl(current);
|
|
97
347
|
/** @internal */
|
|
98
|
-
const isMapKey = u =>
|
|
348
|
+
const isMapKey = u => assets.hasProperty(u, MapKeyTypeId);
|
|
99
349
|
class KeySetImpl {
|
|
100
350
|
head = undefined;
|
|
101
351
|
tail = undefined;
|
|
@@ -159,7 +409,7 @@ const makeCacheState = (map, keys, accesses, updating, hits, misses) => ({
|
|
|
159
409
|
*
|
|
160
410
|
* @internal
|
|
161
411
|
*/
|
|
162
|
-
const initialCacheState = () => makeCacheState(
|
|
412
|
+
const initialCacheState = () => makeCacheState(assets.empty(), makeKeySet(), unbounded(), assets.make(false), 0, 0);
|
|
163
413
|
/** @internal */
|
|
164
414
|
const CacheSymbolKey = "effect/Cache";
|
|
165
415
|
/** @internal */
|
|
@@ -208,177 +458,177 @@ class CacheImpl {
|
|
|
208
458
|
this.cacheState = initialCacheState();
|
|
209
459
|
}
|
|
210
460
|
get(key) {
|
|
211
|
-
return
|
|
461
|
+
return assets.map(this.getEither(key), assets.merge);
|
|
212
462
|
}
|
|
213
463
|
get cacheStats() {
|
|
214
|
-
return
|
|
464
|
+
return assets.sync(() => makeCacheStats({
|
|
215
465
|
hits: this.cacheState.hits,
|
|
216
466
|
misses: this.cacheState.misses,
|
|
217
|
-
size:
|
|
467
|
+
size: assets.size(this.cacheState.map)
|
|
218
468
|
}));
|
|
219
469
|
}
|
|
220
470
|
getOption(key) {
|
|
221
|
-
return
|
|
471
|
+
return assets.suspend(() => assets.match(assets.get(this.cacheState.map, key), {
|
|
222
472
|
onNone: () => {
|
|
223
473
|
const mapKey = makeMapKey(key);
|
|
224
474
|
this.trackAccess(mapKey);
|
|
225
475
|
this.trackMiss();
|
|
226
|
-
return
|
|
476
|
+
return assets.succeed$1(assets.none());
|
|
227
477
|
},
|
|
228
478
|
onSome: value => this.resolveMapValue(value)
|
|
229
479
|
}));
|
|
230
480
|
}
|
|
231
481
|
getOptionComplete(key) {
|
|
232
|
-
return
|
|
482
|
+
return assets.suspend(() => assets.match(assets.get(this.cacheState.map, key), {
|
|
233
483
|
onNone: () => {
|
|
234
484
|
const mapKey = makeMapKey(key);
|
|
235
485
|
this.trackAccess(mapKey);
|
|
236
486
|
this.trackMiss();
|
|
237
|
-
return
|
|
487
|
+
return assets.succeed$1(assets.none());
|
|
238
488
|
},
|
|
239
489
|
onSome: value => this.resolveMapValue(value, true)
|
|
240
490
|
}));
|
|
241
491
|
}
|
|
242
492
|
contains(key) {
|
|
243
|
-
return
|
|
493
|
+
return assets.sync(() => assets.has(this.cacheState.map, key));
|
|
244
494
|
}
|
|
245
495
|
entryStats(key) {
|
|
246
|
-
return
|
|
247
|
-
const option =
|
|
248
|
-
if (
|
|
496
|
+
return assets.sync(() => {
|
|
497
|
+
const option = assets.get(this.cacheState.map, key);
|
|
498
|
+
if (assets.isSome(option)) {
|
|
249
499
|
switch (option.value._tag) {
|
|
250
500
|
case "Complete":
|
|
251
501
|
{
|
|
252
502
|
const loaded = option.value.entryStats.loadedMillis;
|
|
253
|
-
return
|
|
503
|
+
return assets.some(makeEntryStats(loaded));
|
|
254
504
|
}
|
|
255
505
|
case "Pending":
|
|
256
506
|
{
|
|
257
|
-
return
|
|
507
|
+
return assets.none();
|
|
258
508
|
}
|
|
259
509
|
case "Refreshing":
|
|
260
510
|
{
|
|
261
511
|
const loaded = option.value.complete.entryStats.loadedMillis;
|
|
262
|
-
return
|
|
512
|
+
return assets.some(makeEntryStats(loaded));
|
|
263
513
|
}
|
|
264
514
|
}
|
|
265
515
|
}
|
|
266
|
-
return
|
|
516
|
+
return assets.none();
|
|
267
517
|
});
|
|
268
518
|
}
|
|
269
519
|
getEither(key) {
|
|
270
|
-
return
|
|
520
|
+
return assets.suspend(() => {
|
|
271
521
|
const k = key;
|
|
272
522
|
let mapKey = undefined;
|
|
273
523
|
let deferred = undefined;
|
|
274
|
-
let value =
|
|
524
|
+
let value = assets.getOrUndefined(assets.get(this.cacheState.map, k));
|
|
275
525
|
if (value === undefined) {
|
|
276
|
-
deferred =
|
|
526
|
+
deferred = unsafeMake(this.fiberId);
|
|
277
527
|
mapKey = makeMapKey(k);
|
|
278
|
-
if (
|
|
279
|
-
value =
|
|
528
|
+
if (assets.has(this.cacheState.map, k)) {
|
|
529
|
+
value = assets.getOrUndefined(assets.get(this.cacheState.map, k));
|
|
280
530
|
} else {
|
|
281
|
-
|
|
531
|
+
assets.set(this.cacheState.map, k, pending(mapKey, deferred));
|
|
282
532
|
}
|
|
283
533
|
}
|
|
284
534
|
if (value === undefined) {
|
|
285
535
|
this.trackAccess(mapKey);
|
|
286
536
|
this.trackMiss();
|
|
287
|
-
return
|
|
537
|
+
return assets.map(this.lookupValueOf(key, deferred), assets.right);
|
|
288
538
|
} else {
|
|
289
|
-
return
|
|
539
|
+
return assets.flatMap(this.resolveMapValue(value), assets.match({
|
|
290
540
|
onNone: () => this.getEither(key),
|
|
291
|
-
onSome: value =>
|
|
541
|
+
onSome: value => assets.succeed$1(assets.left(value))
|
|
292
542
|
}));
|
|
293
543
|
}
|
|
294
544
|
});
|
|
295
545
|
}
|
|
296
546
|
invalidate(key) {
|
|
297
|
-
return
|
|
298
|
-
|
|
547
|
+
return assets.sync(() => {
|
|
548
|
+
assets.remove(this.cacheState.map, key);
|
|
299
549
|
});
|
|
300
550
|
}
|
|
301
551
|
invalidateWhen(key, when) {
|
|
302
|
-
return
|
|
303
|
-
const value =
|
|
304
|
-
if (
|
|
552
|
+
return assets.sync(() => {
|
|
553
|
+
const value = assets.get(this.cacheState.map, key);
|
|
554
|
+
if (assets.isSome(value) && value.value._tag === "Complete") {
|
|
305
555
|
if (value.value.exit._tag === "Success") {
|
|
306
556
|
if (when(value.value.exit.value)) {
|
|
307
|
-
|
|
557
|
+
assets.remove(this.cacheState.map, key);
|
|
308
558
|
}
|
|
309
559
|
}
|
|
310
560
|
}
|
|
311
561
|
});
|
|
312
562
|
}
|
|
313
563
|
get invalidateAll() {
|
|
314
|
-
return
|
|
315
|
-
this.cacheState.map =
|
|
564
|
+
return assets.sync(() => {
|
|
565
|
+
this.cacheState.map = assets.empty();
|
|
316
566
|
});
|
|
317
567
|
}
|
|
318
568
|
refresh(key) {
|
|
319
|
-
return
|
|
569
|
+
return assets.clockWith(clock => assets.suspend(() => {
|
|
320
570
|
const k = key;
|
|
321
|
-
const deferred =
|
|
322
|
-
let value =
|
|
571
|
+
const deferred = unsafeMake(this.fiberId);
|
|
572
|
+
let value = assets.getOrUndefined(assets.get(this.cacheState.map, k));
|
|
323
573
|
if (value === undefined) {
|
|
324
|
-
if (
|
|
325
|
-
value =
|
|
574
|
+
if (assets.has(this.cacheState.map, k)) {
|
|
575
|
+
value = assets.getOrUndefined(assets.get(this.cacheState.map, k));
|
|
326
576
|
} else {
|
|
327
|
-
|
|
577
|
+
assets.set(this.cacheState.map, k, pending(makeMapKey(k), deferred));
|
|
328
578
|
}
|
|
329
579
|
}
|
|
330
580
|
if (value === undefined) {
|
|
331
|
-
return
|
|
581
|
+
return assets.asVoid(this.lookupValueOf(key, deferred));
|
|
332
582
|
} else {
|
|
333
583
|
switch (value._tag) {
|
|
334
584
|
case "Complete":
|
|
335
585
|
{
|
|
336
586
|
if (this.hasExpired(clock, value.timeToLiveMillis)) {
|
|
337
|
-
const found =
|
|
338
|
-
if (
|
|
339
|
-
|
|
587
|
+
const found = assets.getOrUndefined(assets.get(this.cacheState.map, k));
|
|
588
|
+
if (assets.equals(found, value)) {
|
|
589
|
+
assets.remove(this.cacheState.map, k);
|
|
340
590
|
}
|
|
341
|
-
return
|
|
591
|
+
return assets.asVoid(this.get(key));
|
|
342
592
|
}
|
|
343
593
|
// Only trigger the lookup if we're still the current value, `completedResult`
|
|
344
|
-
return
|
|
345
|
-
const current =
|
|
346
|
-
if (
|
|
594
|
+
return assets.pipe(this.lookupValueOf(key, deferred), assets.when(() => {
|
|
595
|
+
const current = assets.getOrUndefined(assets.get(this.cacheState.map, k));
|
|
596
|
+
if (assets.equals(current, value)) {
|
|
347
597
|
const mapValue = refreshing(deferred, value);
|
|
348
|
-
|
|
598
|
+
assets.set(this.cacheState.map, k, mapValue);
|
|
349
599
|
return true;
|
|
350
600
|
}
|
|
351
601
|
return false;
|
|
352
|
-
}),
|
|
602
|
+
}), assets.asVoid);
|
|
353
603
|
}
|
|
354
604
|
case "Pending":
|
|
355
605
|
{
|
|
356
|
-
return
|
|
606
|
+
return _await(value.deferred);
|
|
357
607
|
}
|
|
358
608
|
case "Refreshing":
|
|
359
609
|
{
|
|
360
|
-
return
|
|
610
|
+
return _await(value.deferred);
|
|
361
611
|
}
|
|
362
612
|
}
|
|
363
613
|
}
|
|
364
614
|
}));
|
|
365
615
|
}
|
|
366
616
|
set(key, value) {
|
|
367
|
-
return
|
|
617
|
+
return assets.clockWith(clock => assets.sync(() => {
|
|
368
618
|
const now = clock.unsafeCurrentTimeMillis();
|
|
369
619
|
const k = key;
|
|
370
|
-
const lookupResult =
|
|
371
|
-
const mapValue = complete(makeMapKey(k), lookupResult, makeEntryStats(now), now +
|
|
372
|
-
|
|
620
|
+
const lookupResult = succeed(value);
|
|
621
|
+
const mapValue = complete(makeMapKey(k), lookupResult, makeEntryStats(now), now + assets.toMillis(assets.decode(this.timeToLive(lookupResult))));
|
|
622
|
+
assets.set(this.cacheState.map, k, mapValue);
|
|
373
623
|
}));
|
|
374
624
|
}
|
|
375
625
|
get size() {
|
|
376
|
-
return
|
|
377
|
-
return
|
|
626
|
+
return assets.sync(() => {
|
|
627
|
+
return assets.size(this.cacheState.map);
|
|
378
628
|
});
|
|
379
629
|
}
|
|
380
630
|
get values() {
|
|
381
|
-
return
|
|
631
|
+
return assets.sync(() => {
|
|
382
632
|
const values = [];
|
|
383
633
|
for (const entry of this.cacheState.map) {
|
|
384
634
|
if (entry[1]._tag === "Complete" && entry[1].exit._tag === "Success") {
|
|
@@ -389,7 +639,7 @@ class CacheImpl {
|
|
|
389
639
|
});
|
|
390
640
|
}
|
|
391
641
|
get entries() {
|
|
392
|
-
return
|
|
642
|
+
return assets.sync(() => {
|
|
393
643
|
const values = [];
|
|
394
644
|
for (const entry of this.cacheState.map) {
|
|
395
645
|
if (entry[1]._tag === "Complete" && entry[1].exit._tag === "Success") {
|
|
@@ -400,7 +650,7 @@ class CacheImpl {
|
|
|
400
650
|
});
|
|
401
651
|
}
|
|
402
652
|
get keys() {
|
|
403
|
-
return
|
|
653
|
+
return assets.sync(() => {
|
|
404
654
|
const keys = [];
|
|
405
655
|
for (const entry of this.cacheState.map) {
|
|
406
656
|
if (entry[1]._tag === "Complete" && entry[1].exit._tag === "Success") {
|
|
@@ -411,26 +661,26 @@ class CacheImpl {
|
|
|
411
661
|
});
|
|
412
662
|
}
|
|
413
663
|
resolveMapValue(value, ignorePending = false) {
|
|
414
|
-
return
|
|
664
|
+
return assets.clockWith(clock => {
|
|
415
665
|
switch (value._tag) {
|
|
416
666
|
case "Complete":
|
|
417
667
|
{
|
|
418
668
|
this.trackAccess(value.key);
|
|
419
669
|
if (this.hasExpired(clock, value.timeToLiveMillis)) {
|
|
420
|
-
|
|
421
|
-
return
|
|
670
|
+
assets.remove(this.cacheState.map, value.key.current);
|
|
671
|
+
return assets.succeed$1(assets.none());
|
|
422
672
|
}
|
|
423
673
|
this.trackHit();
|
|
424
|
-
return
|
|
674
|
+
return assets.map(value.exit, assets.some);
|
|
425
675
|
}
|
|
426
676
|
case "Pending":
|
|
427
677
|
{
|
|
428
678
|
this.trackAccess(value.key);
|
|
429
679
|
this.trackHit();
|
|
430
680
|
if (ignorePending) {
|
|
431
|
-
return
|
|
681
|
+
return assets.succeed$1(assets.none());
|
|
432
682
|
}
|
|
433
|
-
return
|
|
683
|
+
return assets.map(_await(value.deferred), assets.some);
|
|
434
684
|
}
|
|
435
685
|
case "Refreshing":
|
|
436
686
|
{
|
|
@@ -438,11 +688,11 @@ class CacheImpl {
|
|
|
438
688
|
this.trackHit();
|
|
439
689
|
if (this.hasExpired(clock, value.complete.timeToLiveMillis)) {
|
|
440
690
|
if (ignorePending) {
|
|
441
|
-
return
|
|
691
|
+
return assets.succeed$1(assets.none());
|
|
442
692
|
}
|
|
443
|
-
return
|
|
693
|
+
return assets.map(_await(value.deferred), assets.some);
|
|
444
694
|
}
|
|
445
|
-
return
|
|
695
|
+
return assets.map(value.complete.exit, assets.some);
|
|
446
696
|
}
|
|
447
697
|
}
|
|
448
698
|
});
|
|
@@ -454,24 +704,24 @@ class CacheImpl {
|
|
|
454
704
|
this.cacheState.misses = this.cacheState.misses + 1;
|
|
455
705
|
}
|
|
456
706
|
trackAccess(key) {
|
|
457
|
-
|
|
458
|
-
if (
|
|
707
|
+
offer(this.cacheState.accesses, key);
|
|
708
|
+
if (assets.compareAndSet(this.cacheState.updating, false, true)) {
|
|
459
709
|
let loop = true;
|
|
460
710
|
while (loop) {
|
|
461
|
-
const key =
|
|
462
|
-
if (key ===
|
|
711
|
+
const key = poll(this.cacheState.accesses, EmptyMutableQueue);
|
|
712
|
+
if (key === EmptyMutableQueue) {
|
|
463
713
|
loop = false;
|
|
464
714
|
} else {
|
|
465
715
|
this.cacheState.keys.add(key);
|
|
466
716
|
}
|
|
467
717
|
}
|
|
468
|
-
let size =
|
|
718
|
+
let size = assets.size(this.cacheState.map);
|
|
469
719
|
loop = size > this.capacity;
|
|
470
720
|
while (loop) {
|
|
471
721
|
const key = this.cacheState.keys.remove();
|
|
472
722
|
if (key !== undefined) {
|
|
473
|
-
if (
|
|
474
|
-
|
|
723
|
+
if (assets.has(this.cacheState.map, key.current)) {
|
|
724
|
+
assets.remove(this.cacheState.map, key.current);
|
|
475
725
|
size = size - 1;
|
|
476
726
|
loop = size > this.capacity;
|
|
477
727
|
}
|
|
@@ -479,30 +729,30 @@ class CacheImpl {
|
|
|
479
729
|
loop = false;
|
|
480
730
|
}
|
|
481
731
|
}
|
|
482
|
-
|
|
732
|
+
assets.set$1(this.cacheState.updating, false);
|
|
483
733
|
}
|
|
484
734
|
}
|
|
485
735
|
hasExpired(clock, timeToLiveMillis) {
|
|
486
736
|
return clock.unsafeCurrentTimeMillis() > timeToLiveMillis;
|
|
487
737
|
}
|
|
488
738
|
lookupValueOf(input, deferred) {
|
|
489
|
-
return
|
|
739
|
+
return assets.clockWith(clock => assets.suspend(() => {
|
|
490
740
|
const key = input;
|
|
491
|
-
return
|
|
741
|
+
return assets.pipe(this.lookup(input), assets.provideContext(this.context), assets.exit, assets.flatMap(exit => {
|
|
492
742
|
const now = clock.unsafeCurrentTimeMillis();
|
|
493
743
|
const stats = makeEntryStats(now);
|
|
494
|
-
const value = complete(makeMapKey(key), exit, stats, now +
|
|
495
|
-
|
|
496
|
-
return
|
|
497
|
-
}),
|
|
498
|
-
|
|
744
|
+
const value = complete(makeMapKey(key), exit, stats, now + assets.toMillis(assets.decode(this.timeToLive(exit))));
|
|
745
|
+
assets.set(this.cacheState.map, key, value);
|
|
746
|
+
return assets.zipRight(done(deferred, exit), exit);
|
|
747
|
+
}), assets.onInterrupt(() => assets.zipRight(interrupt(deferred), assets.sync(() => {
|
|
748
|
+
assets.remove(this.cacheState.map, key);
|
|
499
749
|
}))));
|
|
500
750
|
}));
|
|
501
751
|
}
|
|
502
752
|
}
|
|
503
753
|
/** @internal */
|
|
504
754
|
const make$1 = options => {
|
|
505
|
-
const timeToLive =
|
|
755
|
+
const timeToLive = assets.decode(options.timeToLive);
|
|
506
756
|
return makeWith({
|
|
507
757
|
capacity: options.capacity,
|
|
508
758
|
lookup: options.lookup,
|
|
@@ -510,7 +760,7 @@ const make$1 = options => {
|
|
|
510
760
|
});
|
|
511
761
|
};
|
|
512
762
|
/** @internal */
|
|
513
|
-
const makeWith = options =>
|
|
763
|
+
const makeWith = options => assets.map(assets.all([assets.context(), assets.fiberId]), ([context, fiberId]) => new CacheImpl(options.capacity, context, fiberId, options.lookup, exit => assets.decode(options.timeToLive(exit))));
|
|
514
764
|
|
|
515
765
|
/**
|
|
516
766
|
* Constructs a new cache with the specified capacity, time to live, and
|
|
@@ -525,8 +775,8 @@ class FetchError extends assets.TaggedError('FetchError') {
|
|
|
525
775
|
}
|
|
526
776
|
class NotFoundError extends assets.TaggedError('NotFoundError') {
|
|
527
777
|
}
|
|
528
|
-
const httpClient = (input, init) =>
|
|
529
|
-
const response = yield*
|
|
778
|
+
const httpClient = (input, init) => assets.gen(function* () {
|
|
779
|
+
const response = yield* assets.tryPromise({
|
|
530
780
|
try: () => fetch(input, init),
|
|
531
781
|
catch: error => new FetchError({ cause: error }),
|
|
532
782
|
});
|
|
@@ -540,7 +790,7 @@ class ResponseTextError extends assets.TaggedError('ResponseTextError') {
|
|
|
540
790
|
super(new Error(`Failed to read response text`, { cause: error }));
|
|
541
791
|
}
|
|
542
792
|
}
|
|
543
|
-
const responseAsText = (res) =>
|
|
793
|
+
const responseAsText = (res) => assets.tryPromise({
|
|
544
794
|
try: () => res.text(),
|
|
545
795
|
catch: error => new ResponseTextError(error),
|
|
546
796
|
});
|
|
@@ -551,7 +801,7 @@ class BrandValidationError extends assets.TaggedError('BrandValidationError') {
|
|
|
551
801
|
super(new Error(`Brand validation failed for type ${type}.`, { cause: error }));
|
|
552
802
|
}
|
|
553
803
|
}
|
|
554
|
-
const createValidSVGString = (svg) =>
|
|
804
|
+
const createValidSVGString = (svg) => assets.try_({
|
|
555
805
|
try: () => SVGString(svg),
|
|
556
806
|
catch: error => new BrandValidationError(error, 'SVGString'),
|
|
557
807
|
});
|
|
@@ -572,8 +822,8 @@ function isValidSVG(svg) {
|
|
|
572
822
|
const emptyDefaultSvg = () => SVGString(`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"></svg>`);
|
|
573
823
|
const createIconCache = () => make({
|
|
574
824
|
capacity: 200,
|
|
575
|
-
timeToLive:
|
|
576
|
-
lookup: (key) =>
|
|
825
|
+
timeToLive: assets.infinity,
|
|
826
|
+
lookup: (key) => assets.gen(function* () {
|
|
577
827
|
const name = key;
|
|
578
828
|
const assetPath = yield* assets.syncCreateAssetUrlSafely(`${name}.svg`, 'icons');
|
|
579
829
|
const res = yield* httpClient(assetPath);
|
|
@@ -584,7 +834,7 @@ const createIconCache = () => make({
|
|
|
584
834
|
let cacheInstance = null;
|
|
585
835
|
function fetchIconSvg(name) {
|
|
586
836
|
const key = name;
|
|
587
|
-
return
|
|
837
|
+
return assets.gen(function* () {
|
|
588
838
|
if (!cacheInstance) {
|
|
589
839
|
cacheInstance = yield* createIconCache();
|
|
590
840
|
}
|
|
@@ -592,12 +842,12 @@ function fetchIconSvg(name) {
|
|
|
592
842
|
});
|
|
593
843
|
}
|
|
594
844
|
function clearIconCache() {
|
|
595
|
-
return
|
|
845
|
+
return assets.gen(function* () {
|
|
596
846
|
if (cacheInstance) {
|
|
597
847
|
yield* cacheInstance.invalidateAll;
|
|
598
848
|
}
|
|
599
849
|
else {
|
|
600
|
-
|
|
850
|
+
assets.logWarning('Attempted to clear icon cache before it was initialized');
|
|
601
851
|
}
|
|
602
852
|
});
|
|
603
853
|
}
|