dfx 0.21.4 → 0.21.6
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/Cache/driver.d.ts +16 -16
- package/Cache/driver.js.map +1 -1
- package/Cache/index.d.ts +21 -21
- package/Cache/index.js +2 -3
- package/Cache/index.js.map +1 -1
- package/Cache/memory.d.ts +3 -3
- package/Cache/memory.js +19 -18
- package/Cache/memory.js.map +1 -1
- package/Cache/memoryTTL.d.ts +5 -5
- package/Cache/memoryTTL.js +15 -15
- package/Cache/memoryTTL.js.map +1 -1
- package/Cache/prelude.d.ts +37 -37
- package/Cache/prelude.js +5 -6
- package/Cache/prelude.js.map +1 -1
- package/DiscordConfig/index.d.ts +4 -4
- package/DiscordConfig/index.js +8 -5
- package/DiscordConfig/index.js.map +1 -1
- package/DiscordGateway/DiscordWS/index.d.ts +8 -9
- package/DiscordGateway/DiscordWS/index.js +19 -16
- package/DiscordGateway/DiscordWS/index.js.map +1 -1
- package/DiscordGateway/Shard/heartbeats.d.ts +3 -3
- package/DiscordGateway/Shard/heartbeats.js +12 -10
- package/DiscordGateway/Shard/heartbeats.js.map +1 -1
- package/DiscordGateway/Shard/identify.d.ts +4 -5
- package/DiscordGateway/Shard/identify.js +4 -4
- package/DiscordGateway/Shard/identify.js.map +1 -1
- package/DiscordGateway/Shard/index.d.ts +7 -8
- package/DiscordGateway/Shard/index.js +17 -17
- package/DiscordGateway/Shard/index.js.map +1 -1
- package/DiscordGateway/Shard/invalidSession.d.ts +2 -2
- package/DiscordGateway/Shard/invalidSession.js +7 -5
- package/DiscordGateway/Shard/invalidSession.js.map +1 -1
- package/DiscordGateway/Shard/utils.d.ts +3 -3
- package/DiscordGateway/Shard/utils.js +5 -5
- package/DiscordGateway/Shard/utils.js.map +1 -1
- package/DiscordGateway/ShardStore/index.d.ts +6 -6
- package/DiscordGateway/ShardStore/index.js +10 -7
- package/DiscordGateway/ShardStore/index.js.map +1 -1
- package/DiscordGateway/Sharder/index.d.ts +10 -12
- package/DiscordGateway/Sharder/index.js +15 -14
- package/DiscordGateway/Sharder/index.js.map +1 -1
- package/DiscordGateway/WS/index.d.ts +3 -3
- package/DiscordGateway/WS/index.js +12 -11
- package/DiscordGateway/WS/index.js.map +1 -1
- package/DiscordGateway/index.d.ts +8 -8
- package/DiscordGateway/index.js +9 -8
- package/DiscordGateway/index.js.map +1 -1
- package/DiscordREST/index.d.ts +136 -136
- package/DiscordREST/index.js +39 -36
- package/DiscordREST/index.js.map +1 -1
- package/DiscordREST/types.d.ts +4 -4
- package/DiscordREST/utils.d.ts +4 -5
- package/DiscordREST/utils.js +5 -5
- package/DiscordREST/utils.js.map +1 -1
- package/Helpers/intents.js +9 -8
- package/Helpers/intents.js.map +1 -1
- package/Helpers/interactions.d.ts +18 -18
- package/Helpers/interactions.js +23 -22
- package/Helpers/interactions.js.map +1 -1
- package/Helpers/members.d.ts +3 -3
- package/Helpers/members.js.map +1 -1
- package/Helpers/permissions.d.ts +4 -5
- package/Helpers/permissions.js +14 -13
- package/Helpers/permissions.js.map +1 -1
- package/Http/index.d.ts +9 -10
- package/Http/index.js +8 -7
- package/Http/index.js.map +1 -1
- package/Interactions/context.d.ts +23 -22
- package/Interactions/context.js +25 -22
- package/Interactions/context.js.map +1 -1
- package/Interactions/definitions.d.ts +29 -30
- package/Interactions/definitions.js +2 -1
- package/Interactions/definitions.js.map +1 -1
- package/Interactions/gateway.d.ts +3 -4
- package/Interactions/gateway.js +6 -6
- package/Interactions/gateway.js.map +1 -1
- package/Interactions/handlers.d.ts +2 -2
- package/Interactions/handlers.js +18 -17
- package/Interactions/handlers.js.map +1 -1
- package/Interactions/index.d.ts +7 -7
- package/Interactions/index.js +7 -8
- package/Interactions/index.js.map +1 -1
- package/Interactions/webhook.d.ts +7 -7
- package/Interactions/webhook.js +13 -11
- package/Interactions/webhook.js.map +1 -1
- package/Log/index.d.ts +8 -8
- package/Log/index.js +11 -9
- package/Log/index.js.map +1 -1
- package/RateLimit/index.d.ts +12 -13
- package/RateLimit/index.js +12 -11
- package/RateLimit/index.js.map +1 -1
- package/RateLimit/memory.js +7 -7
- package/RateLimit/memory.js.map +1 -1
- package/RateLimit/utils.d.ts +1 -1
- package/RateLimit/utils.js.map +1 -1
- package/_common.d.ts +22 -18
- package/_common.js +0 -18
- package/_common.js.map +1 -1
- package/gateway.d.ts +6 -7
- package/gateway.js +0 -2
- package/gateway.js.map +1 -1
- package/global.d.ts +21 -0
- package/global.js +2 -0
- package/global.js.map +1 -0
- package/package.json +3 -3
- package/utils/effect.d.ts +9 -8
- package/utils/effect.js +4 -4
- package/utils/effect.js.map +1 -1
- package/webhooks.d.ts +4 -5
- package/webhooks.js +3 -5
- package/webhooks.js.map +1 -1
package/Cache/driver.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Effect,
|
|
1
|
+
import { Effect, Maybe } from "dfx/_common";
|
|
2
2
|
export interface ParentCacheDriver<E, T> {
|
|
3
|
-
readonly size: Effect
|
|
4
|
-
sizeForParent: (parentId: string) => Effect
|
|
5
|
-
get: (parentId: string, resourceId: string) => Effect
|
|
6
|
-
getForParent: (parentId: string) => Effect
|
|
7
|
-
set: (parentId: string, resourceId: string, resource: T) => Effect
|
|
8
|
-
delete: (parentId: string, resourceId: string) => Effect
|
|
9
|
-
parentDelete: (parentId: string) => Effect
|
|
10
|
-
refreshTTL: (parentId: string, resourceId: string) => Effect
|
|
11
|
-
readonly run: Effect
|
|
3
|
+
readonly size: Effect<never, E, number>;
|
|
4
|
+
sizeForParent: (parentId: string) => Effect<never, E, number>;
|
|
5
|
+
get: (parentId: string, resourceId: string) => Effect<never, E, Maybe<T>>;
|
|
6
|
+
getForParent: (parentId: string) => Effect<never, E, Maybe<ReadonlyMap<string, T>>>;
|
|
7
|
+
set: (parentId: string, resourceId: string, resource: T) => Effect<never, E, void>;
|
|
8
|
+
delete: (parentId: string, resourceId: string) => Effect<never, E, void>;
|
|
9
|
+
parentDelete: (parentId: string) => Effect<never, E, void>;
|
|
10
|
+
refreshTTL: (parentId: string, resourceId: string) => Effect<never, E, void>;
|
|
11
|
+
readonly run: Effect<never, E, void>;
|
|
12
12
|
}
|
|
13
13
|
export declare const createParentDriver: <E, T>(driver: ParentCacheDriver<E, T>) => ParentCacheDriver<E, T>;
|
|
14
14
|
export interface CacheDriver<E, T> {
|
|
15
|
-
readonly size: Effect
|
|
16
|
-
get: (resourceId: string) => Effect
|
|
17
|
-
set: (resourceId: string, resource: T) => Effect
|
|
18
|
-
delete: (resourceId: string) => Effect
|
|
19
|
-
refreshTTL: (resourceId: string) => Effect
|
|
20
|
-
readonly run: Effect
|
|
15
|
+
readonly size: Effect<never, E, number>;
|
|
16
|
+
get: (resourceId: string) => Effect<never, E, Maybe<T>>;
|
|
17
|
+
set: (resourceId: string, resource: T) => Effect<never, E, void>;
|
|
18
|
+
delete: (resourceId: string) => Effect<never, E, void>;
|
|
19
|
+
refreshTTL: (resourceId: string) => Effect<never, E, void>;
|
|
20
|
+
readonly run: Effect<never, E, void>;
|
|
21
21
|
}
|
|
22
22
|
export declare const createDriver: <E, T>(driver: CacheDriver<E, T>) => CacheDriver<E, T>;
|
package/Cache/driver.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../../src/Cache/driver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../../src/Cache/driver.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAO,MAA+B,EAAE,EAAE,CAC1E,MAAM,CAAA;AAWR,MAAM,CAAC,MAAM,YAAY,GAAG,CAAO,MAAyB,EAAE,EAAE,CAAC,MAAM,CAAA"}
|
package/Cache/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Stream, Effect } from "dfx/_common";
|
|
1
2
|
import { CacheDriver, ParentCacheDriver } from "./driver.js";
|
|
2
|
-
import { Effect, Stream } from "dfx/_common";
|
|
3
3
|
export * from "./driver.js";
|
|
4
4
|
export { create as memoryDriver, createWithParent as memoryParentDriver, } from "./memory.js";
|
|
5
5
|
export { create as memoryTTLDriver, createWithParent as memoryTTLParentDriver, } from "./memoryTTL.js";
|
|
@@ -35,31 +35,31 @@ export type CacheOp<T> = {
|
|
|
35
35
|
};
|
|
36
36
|
export declare const makeWithParent: <EOps, EDriver, EMiss, EPMiss, A>({ driver, ops, onMiss, onParentMiss, }: {
|
|
37
37
|
driver: ParentCacheDriver<EDriver, A>;
|
|
38
|
-
ops?:
|
|
39
|
-
onMiss: (parentId: string, id: string) =>
|
|
40
|
-
onParentMiss: (parentId: string) =>
|
|
38
|
+
ops?: import("../_common.js").Stream<never, EOps, ParentCacheOp<A>> | undefined;
|
|
39
|
+
onMiss: (parentId: string, id: string) => import("../_common.js").Effect<never, EMiss, A>;
|
|
40
|
+
onParentMiss: (parentId: string) => import("../_common.js").Effect<never, EPMiss, [id: string, resource: A][]>;
|
|
41
41
|
}) => {
|
|
42
|
-
get: (parentId: string, id: string) =>
|
|
43
|
-
getForParent: (parentId: string) =>
|
|
44
|
-
run:
|
|
45
|
-
size:
|
|
46
|
-
sizeForParent: (parentId: string) =>
|
|
47
|
-
set: (parentId: string, resourceId: string, resource: A) =>
|
|
48
|
-
delete: (parentId: string, resourceId: string) =>
|
|
49
|
-
parentDelete: (parentId: string) =>
|
|
50
|
-
refreshTTL: (parentId: string, resourceId: string) =>
|
|
42
|
+
get: (parentId: string, id: string) => import("../_common.js").Effect<never, EDriver | EMiss, A>;
|
|
43
|
+
getForParent: (parentId: string) => import("../_common.js").Effect<never, EDriver | EPMiss, ReadonlyMap<string, A>>;
|
|
44
|
+
run: import("../_common.js").Effect<never, EOps | EDriver, void>;
|
|
45
|
+
size: import("../_common.js").Effect<never, EDriver, number>;
|
|
46
|
+
sizeForParent: (parentId: string) => import("../_common.js").Effect<never, EDriver, number>;
|
|
47
|
+
set: (parentId: string, resourceId: string, resource: A) => import("../_common.js").Effect<never, EDriver, void>;
|
|
48
|
+
delete: (parentId: string, resourceId: string) => import("../_common.js").Effect<never, EDriver, void>;
|
|
49
|
+
parentDelete: (parentId: string) => import("../_common.js").Effect<never, EDriver, void>;
|
|
50
|
+
refreshTTL: (parentId: string, resourceId: string) => import("../_common.js").Effect<never, EDriver, void>;
|
|
51
51
|
};
|
|
52
52
|
export declare const make: <EOps, EDriver, EMiss, A>({ driver, ops, onMiss, }: {
|
|
53
53
|
driver: CacheDriver<EDriver, A>;
|
|
54
|
-
ops?:
|
|
55
|
-
onMiss: (id: string) =>
|
|
54
|
+
ops?: import("../_common.js").Stream<never, EOps, CacheOp<A>> | undefined;
|
|
55
|
+
onMiss: (id: string) => import("../_common.js").Effect<never, EMiss, A>;
|
|
56
56
|
}) => {
|
|
57
|
-
get: (id: string) =>
|
|
58
|
-
run:
|
|
59
|
-
size:
|
|
60
|
-
set: (resourceId: string, resource: A) =>
|
|
61
|
-
delete: (resourceId: string) =>
|
|
62
|
-
refreshTTL: (resourceId: string) =>
|
|
57
|
+
get: (id: string) => import("../_common.js").Effect<never, EDriver | EMiss, A>;
|
|
58
|
+
run: import("../_common.js").Effect<never, EOps | EDriver, void>;
|
|
59
|
+
size: import("../_common.js").Effect<never, EDriver, number>;
|
|
60
|
+
set: (resourceId: string, resource: A) => import("../_common.js").Effect<never, EDriver, void>;
|
|
61
|
+
delete: (resourceId: string) => import("../_common.js").Effect<never, EDriver, void>;
|
|
62
|
+
refreshTTL: (resourceId: string) => import("../_common.js").Effect<never, EDriver, void>;
|
|
63
63
|
};
|
|
64
64
|
export declare class CacheMissError {
|
|
65
65
|
readonly cacheName: string;
|
package/Cache/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "@effect/stream/Stream";
|
|
2
2
|
import * as tsplus_module_2 from "@effect/io/Effect";
|
|
3
|
-
import { Stream, } from "dfx/_common";
|
|
4
3
|
export * from "./driver.js";
|
|
5
4
|
export { create as memoryDriver, createWithParent as memoryParentDriver, } from "./memory.js";
|
|
6
5
|
export { create as memoryTTLDriver, createWithParent as memoryTTLParentDriver, } from "./memoryTTL.js";
|
|
7
|
-
export const makeWithParent = ({ driver, ops =
|
|
6
|
+
export const makeWithParent = ({ driver, ops = tsplus_module_1.empty, onMiss, onParentMiss, }) => {
|
|
8
7
|
const sync = tsplus_module_1.runDrain(tsplus_module_1.tap((op) => {
|
|
9
8
|
switch (op.op) {
|
|
10
9
|
case "create":
|
|
@@ -24,7 +23,7 @@ export const makeWithParent = ({ driver, ops = Stream.empty, onMiss, onParentMis
|
|
|
24
23
|
run: tsplus_module_2.asUnit(tsplus_module_2.zipPar(driver.run)(sync)),
|
|
25
24
|
};
|
|
26
25
|
};
|
|
27
|
-
export const make = ({ driver, ops =
|
|
26
|
+
export const make = ({ driver, ops = tsplus_module_1.empty, onMiss, }) => {
|
|
28
27
|
const sync = tsplus_module_1.runDrain(tsplus_module_1.tap((op) => {
|
|
29
28
|
switch (op.op) {
|
|
30
29
|
case "create":
|
package/Cache/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Cache/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Cache/index.ts"],"names":[],"mappings":";;AAEA,cAAc,aAAa,CAAA;AAC3B,OAAO,EACL,MAAM,IAAI,YAAY,EACtB,gBAAgB,IAAI,kBAAkB,GACvC,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,MAAM,IAAI,eAAe,EACzB,gBAAgB,IAAI,qBAAqB,GAC1C,MAAM,gBAAgB,CAAA;AAavB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAkC,EAC9D,MAAM,EACN,GAAG,wBAAe,EAClB,MAAM,EACN,YAAY,GAQb,EAAE,EAAE;IACH,MAAM,IAAI,4BAAG,oBAAQ,CAAC,EAAE,EAAgC,EAAE;Q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|
1
|
+
import { Maybe } from "dfx/_common";
|
|
2
|
+
export declare const createWithParent: <T>() => import("../_common.js").Effect<never, never, import("./driver.js").ParentCacheDriver<never, T>>;
|
|
3
|
+
export declare const create: <T>() => import("../_common.js").Effect<never, never, import("./driver.js").CacheDriver<never, T>>;
|
package/Cache/memory.js
CHANGED
|
@@ -1,47 +1,48 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
|
+
import * as tsplus_module_2 from "@fp-ts/data/Option";
|
|
2
3
|
import { createDriver, createParentDriver } from "./driver.js";
|
|
3
|
-
export const createWithParent = () =>
|
|
4
|
+
export const createWithParent = () => tsplus_module_1.sync(() => {
|
|
4
5
|
const map = new Map();
|
|
5
6
|
return createParentDriver({
|
|
6
|
-
size:
|
|
7
|
+
size: tsplus_module_1.sync(() => {
|
|
7
8
|
let count = 0;
|
|
8
9
|
for (const a of map.values()) {
|
|
9
10
|
count += a.size;
|
|
10
11
|
}
|
|
11
12
|
return count;
|
|
12
13
|
}),
|
|
13
|
-
sizeForParent: (parentId) =>
|
|
14
|
-
get: (parentId, resourceId) =>
|
|
15
|
-
getForParent: (parentId) =>
|
|
16
|
-
set: (parentId, resourceId, resource) =>
|
|
14
|
+
sizeForParent: (parentId) => tsplus_module_1.sync(() => map.get(parentId)?.size ?? 0),
|
|
15
|
+
get: (parentId, resourceId) => tsplus_module_1.sync(() => tsplus_module_2.fromNullable(map.get(parentId)?.get(resourceId))),
|
|
16
|
+
getForParent: (parentId) => tsplus_module_1.sync(() => tsplus_module_2.fromNullable(map.get(parentId))),
|
|
17
|
+
set: (parentId, resourceId, resource) => tsplus_module_1.sync(() => {
|
|
17
18
|
if (!map.has(parentId)) {
|
|
18
19
|
map.set(parentId, new Map());
|
|
19
20
|
}
|
|
20
21
|
map.get(parentId).set(resourceId, resource);
|
|
21
22
|
}),
|
|
22
|
-
delete: (parentId, resourceId) =>
|
|
23
|
+
delete: (parentId, resourceId) => tsplus_module_1.sync(() => {
|
|
23
24
|
map.get(parentId)?.delete(resourceId);
|
|
24
25
|
}),
|
|
25
|
-
parentDelete: (parentId) =>
|
|
26
|
+
parentDelete: (parentId) => tsplus_module_1.sync(() => {
|
|
26
27
|
map.delete(parentId);
|
|
27
28
|
}),
|
|
28
|
-
refreshTTL: () =>
|
|
29
|
-
run:
|
|
29
|
+
refreshTTL: () => tsplus_module_1.unit(),
|
|
30
|
+
run: tsplus_module_1.unit(),
|
|
30
31
|
});
|
|
31
32
|
});
|
|
32
|
-
export const create = () =>
|
|
33
|
+
export const create = () => tsplus_module_1.sync(() => {
|
|
33
34
|
const map = new Map();
|
|
34
35
|
return createDriver({
|
|
35
|
-
size:
|
|
36
|
-
get: (resourceId) =>
|
|
37
|
-
set: (resourceId, resource) =>
|
|
36
|
+
size: tsplus_module_1.sync(() => map.size),
|
|
37
|
+
get: (resourceId) => tsplus_module_1.sync(() => tsplus_module_2.fromNullable(map.get(resourceId))),
|
|
38
|
+
set: (resourceId, resource) => tsplus_module_1.sync(() => {
|
|
38
39
|
map.set(resourceId, resource);
|
|
39
40
|
}),
|
|
40
|
-
delete: (resourceId) =>
|
|
41
|
+
delete: (resourceId) => tsplus_module_1.sync(() => {
|
|
41
42
|
map.delete(resourceId);
|
|
42
43
|
}),
|
|
43
|
-
refreshTTL: () =>
|
|
44
|
-
run:
|
|
44
|
+
refreshTTL: () => tsplus_module_1.unit(),
|
|
45
|
+
run: tsplus_module_1.unit(),
|
|
45
46
|
});
|
|
46
47
|
});
|
|
47
48
|
//# sourceMappingURL=memory.js.map
|
package/Cache/memory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/Cache/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/Cache/memory.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAA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x/_common";
|
|
1
|
+
import { Duration, Maybe, Effect } from "dfx/_common";
|
|
2
2
|
export interface MemoryTTLOpts {
|
|
3
3
|
/** The approx. number of milliseconds to keep items */
|
|
4
|
-
ttl: Duration
|
|
4
|
+
ttl: Duration;
|
|
5
5
|
/**
|
|
6
6
|
* How often items should be cleared.
|
|
7
7
|
*/
|
|
8
|
-
resolution?: Duration
|
|
8
|
+
resolution?: Duration;
|
|
9
9
|
/**
|
|
10
10
|
* What sweep strategy to use.
|
|
11
11
|
*
|
|
@@ -16,5 +16,5 @@ export interface MemoryTTLOpts {
|
|
|
16
16
|
*/
|
|
17
17
|
strategy?: "activity" | "usage" | "expiry";
|
|
18
18
|
}
|
|
19
|
-
export declare const create: <T>(opts: MemoryTTLOpts) =>
|
|
20
|
-
export declare const createWithParent: <T>(opts: MemoryTTLOpts) =>
|
|
19
|
+
export declare const create: <T>(opts: MemoryTTLOpts) => import("../_common.js").Effect<never, never, import("./driver.js").CacheDriver<never, T>>;
|
|
20
|
+
export declare const createWithParent: <T>(opts: MemoryTTLOpts) => import("../_common.js").Effect<never, never, import("./driver.js").ParentCacheDriver<never, T>>;
|
package/Cache/memoryTTL.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "@fp-ts/data/Duration";
|
|
2
2
|
import * as tsplus_module_2 from "@effect/io/Effect";
|
|
3
|
-
import * as tsplus_module_3 from "@fp-ts/data/
|
|
4
|
-
import
|
|
3
|
+
import * as tsplus_module_3 from "@fp-ts/data/Option";
|
|
4
|
+
import * as tsplus_module_4 from "@fp-ts/data/Chunk";
|
|
5
5
|
import { createDriver, createParentDriver } from "./driver.js";
|
|
6
|
-
const make = ({ ttl, resolution =
|
|
6
|
+
const make = ({ ttl, resolution = tsplus_module_1.minutes(1), strategy = "usage", }) => {
|
|
7
7
|
const additionalMilliseconds = (Math.floor(ttl.millis / resolution.millis) + 1) * resolution.millis;
|
|
8
8
|
const items = new Map();
|
|
9
9
|
const buckets = [];
|
|
@@ -47,12 +47,12 @@ const make = ({ ttl, resolution = Duration.minutes(1), strategy = "usage", }) =>
|
|
|
47
47
|
return item.resource;
|
|
48
48
|
};
|
|
49
49
|
return createDriver({
|
|
50
|
-
size:
|
|
51
|
-
get: (resourceId) =>
|
|
52
|
-
refreshTTL: (id) =>
|
|
50
|
+
size: tsplus_module_2.sync(() => items.size),
|
|
51
|
+
get: (resourceId) => tsplus_module_2.sync(() => tsplus_module_3.fromNullable(getSync(resourceId))),
|
|
52
|
+
refreshTTL: (id) => tsplus_module_2.sync(() => {
|
|
53
53
|
getSync(id);
|
|
54
54
|
}),
|
|
55
|
-
set: (resourceId, resource) =>
|
|
55
|
+
set: (resourceId, resource) => tsplus_module_2.sync(() => {
|
|
56
56
|
const item = items.get(resourceId)?.deref();
|
|
57
57
|
if (item && strategy !== "activity") {
|
|
58
58
|
item.resource = resource;
|
|
@@ -63,25 +63,25 @@ const make = ({ ttl, resolution = Duration.minutes(1), strategy = "usage", }) =>
|
|
|
63
63
|
items.set(resourceId, new WeakRef(newItem));
|
|
64
64
|
}
|
|
65
65
|
}),
|
|
66
|
-
delete: (resourceId) =>
|
|
66
|
+
delete: (resourceId) => tsplus_module_2.sync(() => {
|
|
67
67
|
items.delete(resourceId);
|
|
68
68
|
}),
|
|
69
|
-
run: tsplus_module_2.forever(tsplus_module_2.delay(tsplus_module_1.times(0.5)(resolution))(
|
|
69
|
+
run: tsplus_module_2.forever(tsplus_module_2.delay(tsplus_module_1.times(0.5)(resolution))(tsplus_module_2.sync(sweep))),
|
|
70
70
|
});
|
|
71
71
|
};
|
|
72
|
-
export const create = (opts) =>
|
|
73
|
-
export const createWithParent = (opts) =>
|
|
72
|
+
export const create = (opts) => tsplus_module_2.sync(() => make(opts));
|
|
73
|
+
export const createWithParent = (opts) => tsplus_module_2.sync(() => {
|
|
74
74
|
const store = make(opts);
|
|
75
75
|
const parentIds = new Map();
|
|
76
76
|
return createParentDriver({
|
|
77
77
|
size: store.size,
|
|
78
|
-
sizeForParent: (parentId) =>
|
|
78
|
+
sizeForParent: (parentId) => tsplus_module_2.sync(() => parentIds.get(parentId)?.size ?? 0),
|
|
79
79
|
refreshTTL: (_, id) => store.refreshTTL(id),
|
|
80
80
|
get: (_, id) => store.get(id),
|
|
81
81
|
getForParent: (parentId) => (() => {
|
|
82
82
|
const ids = parentIds.get(parentId);
|
|
83
83
|
if (!ids)
|
|
84
|
-
return
|
|
84
|
+
return tsplus_module_3.none;
|
|
85
85
|
const toGet = [];
|
|
86
86
|
ids.forEach((id) => {
|
|
87
87
|
toGet.push(tsplus_module_2.map(item => {
|
|
@@ -92,8 +92,8 @@ export const createWithParent = (opts) => Effect.sync(() => {
|
|
|
92
92
|
})(store.get(id)));
|
|
93
93
|
});
|
|
94
94
|
return tsplus_module_2.map(results => {
|
|
95
|
-
const map =
|
|
96
|
-
return
|
|
95
|
+
const map = tsplus_module_4.reduce(new Map(), (map, [id, a]) => a._tag === "Some" ? map.set(id, a.value) : map)(results);
|
|
96
|
+
return tsplus_module_3.some(map);
|
|
97
97
|
})(tsplus_module_2.collectAllPar(toGet));
|
|
98
98
|
})(),
|
|
99
99
|
set: (parentId, resourceId, resource) => tsplus_module_2.map(() => {
|
package/Cache/memoryTTL.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoryTTL.js","sourceRoot":"","sources":["../../src/Cache/memoryTTL.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"memoryTTL.js","sourceRoot":"","sources":["../../src/Cache/memoryTTL.ts"],"names":[],"mappings":";;;;AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AA+B9D,MAAM,IAAI,GAAG,CAAI,EACf,GAAG,EACH,UAAU,GAAG,wBAAiB,CAAC,CAAC,EAChC,QAAQ,GAAG,OAAO,GACJ,EAAE,EAAE;IAClB,MAAM,sBAAsB,GAC1B,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,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,CAAC,CAAA;YACnC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YAE1B,MAAM,OAAO,GAAiC,EAAE,CAAA;YAChD,IAAI,GAAG,EAAE;gBACP,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;oBACjB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;gBAChC,CAAC,CAAC,CAAA;aACH;0FAEC,OAAO;YACT;QAEJ,GAAG,EAAE,KAAK,CAAC,GAAG;KACf,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/Cache/prelude.d.ts
CHANGED
|
@@ -4,47 +4,47 @@ import { Discord, Effect, Stream } from "dfx/_common";
|
|
|
4
4
|
import { CacheDriver, CacheMissError, CacheOp, ParentCacheDriver, ParentCacheOp } from "./index.js";
|
|
5
5
|
export interface OptsWithParentOptions<E, A> {
|
|
6
6
|
id: (a: A) => string;
|
|
7
|
-
fromParent: Stream
|
|
8
|
-
create: Stream
|
|
9
|
-
update: Stream
|
|
10
|
-
remove: Stream
|
|
11
|
-
parentRemove: Stream
|
|
7
|
+
fromParent: Stream<never, E, [parentId: string, resources: A[]]>;
|
|
8
|
+
create: Stream<never, E, [parentId: string, resource: A]>;
|
|
9
|
+
update: Stream<never, E, [parentId: string, resource: A]>;
|
|
10
|
+
remove: Stream<never, E, [parentId: string, id: string]>;
|
|
11
|
+
parentRemove: Stream<never, E, string>;
|
|
12
12
|
}
|
|
13
|
-
export declare const opsWithParent: <E, T>({ id, fromParent, create, update, remove, parentRemove, }: OptsWithParentOptions<E, T>) => Stream
|
|
13
|
+
export declare const opsWithParent: <E, T>({ id, fromParent, create, update, remove, parentRemove, }: OptsWithParentOptions<E, T>) => Stream<never, E, ParentCacheOp<T>>;
|
|
14
14
|
export interface OpsOptions<E, A> {
|
|
15
15
|
id: (a: A) => string;
|
|
16
|
-
create: Stream
|
|
17
|
-
update: Stream
|
|
18
|
-
remove: Stream
|
|
16
|
+
create: Stream<never, E, A>;
|
|
17
|
+
update: Stream<never, E, A>;
|
|
18
|
+
remove: Stream<never, E, string>;
|
|
19
19
|
}
|
|
20
|
-
export declare const ops: <E, T>({ id, create, update, remove }: OpsOptions<E, T>) => Stream
|
|
21
|
-
export declare const guilds: <RM, EM, E>(makeDriver: Effect
|
|
22
|
-
get: (id: string) => Effect
|
|
23
|
-
run: Effect
|
|
24
|
-
size: Effect
|
|
25
|
-
set: (resourceId: string, resource: Discord.Guild) => Effect
|
|
26
|
-
delete: (resourceId: string) => Effect
|
|
27
|
-
refreshTTL: (resourceId: string) => Effect
|
|
20
|
+
export declare const ops: <E, T>({ id, create, update, remove }: OpsOptions<E, T>) => Stream<never, E, CacheOp<T>>;
|
|
21
|
+
export declare const guilds: <RM, EM, E>(makeDriver: Effect<RM, EM, CacheDriver<E, Discord.Guild>>) => Effect<DiscordREST | Gateway.DiscordGateway | RM, EM, {
|
|
22
|
+
get: (id: string) => Effect<never, import("dfx").FetchError | import("dfx").StatusCodeError | import("dfx").JsonParseError | E, Discord.Guild>;
|
|
23
|
+
run: Effect<never, E, void>;
|
|
24
|
+
size: Effect<never, E, number>;
|
|
25
|
+
set: (resourceId: string, resource: Discord.Guild) => Effect<never, E, void>;
|
|
26
|
+
delete: (resourceId: string) => Effect<never, E, void>;
|
|
27
|
+
refreshTTL: (resourceId: string) => Effect<never, E, void>;
|
|
28
28
|
}>;
|
|
29
|
-
export declare const channels: <RM, EM, E>(makeDriver: Effect
|
|
30
|
-
get: (parentId: string, id: string) => Effect
|
|
31
|
-
getForParent: (parentId: string) => Effect
|
|
32
|
-
run: Effect
|
|
33
|
-
size: Effect
|
|
34
|
-
sizeForParent: (parentId: string) => Effect
|
|
35
|
-
set: (parentId: string, resourceId: string, resource: Discord.Channel) => Effect
|
|
36
|
-
delete: (parentId: string, resourceId: string) => Effect
|
|
37
|
-
parentDelete: (parentId: string) => Effect
|
|
38
|
-
refreshTTL: (parentId: string, resourceId: string) => Effect
|
|
29
|
+
export declare const channels: <RM, EM, E>(makeDriver: Effect<RM, EM, ParentCacheDriver<E, Discord.Channel>>) => Effect<DiscordREST | Gateway.DiscordGateway | RM, EM, {
|
|
30
|
+
get: (parentId: string, id: string) => Effect<never, import("dfx").FetchError | import("dfx").StatusCodeError | import("dfx").JsonParseError | E, Discord.Channel>;
|
|
31
|
+
getForParent: (parentId: string) => Effect<never, import("dfx").FetchError | import("dfx").StatusCodeError | import("dfx").JsonParseError | E, ReadonlyMap<string, Discord.Channel>>;
|
|
32
|
+
run: Effect<never, E, void>;
|
|
33
|
+
size: Effect<never, E, number>;
|
|
34
|
+
sizeForParent: (parentId: string) => Effect<never, E, number>;
|
|
35
|
+
set: (parentId: string, resourceId: string, resource: Discord.Channel) => Effect<never, E, void>;
|
|
36
|
+
delete: (parentId: string, resourceId: string) => Effect<never, E, void>;
|
|
37
|
+
parentDelete: (parentId: string) => Effect<never, E, void>;
|
|
38
|
+
refreshTTL: (parentId: string, resourceId: string) => Effect<never, E, void>;
|
|
39
39
|
}>;
|
|
40
|
-
export declare const roles: <RM, EM, E>(makeDriver: Effect
|
|
41
|
-
get: (parentId: string, id: string) => Effect
|
|
42
|
-
getForParent: (parentId: string) => Effect
|
|
43
|
-
run: Effect
|
|
44
|
-
size: Effect
|
|
45
|
-
sizeForParent: (parentId: string) => Effect
|
|
46
|
-
set: (parentId: string, resourceId: string, resource: Discord.Role) => Effect
|
|
47
|
-
delete: (parentId: string, resourceId: string) => Effect
|
|
48
|
-
parentDelete: (parentId: string) => Effect
|
|
49
|
-
refreshTTL: (parentId: string, resourceId: string) => Effect
|
|
40
|
+
export declare const roles: <RM, EM, E>(makeDriver: Effect<RM, EM, ParentCacheDriver<E, Discord.Role>>) => Effect<DiscordREST | Gateway.DiscordGateway | RM, EM, {
|
|
41
|
+
get: (parentId: string, id: string) => Effect<never, CacheMissError | E, Discord.Role>;
|
|
42
|
+
getForParent: (parentId: string) => Effect<never, import("dfx").FetchError | import("dfx").StatusCodeError | import("dfx").JsonParseError | E, ReadonlyMap<string, Discord.Role>>;
|
|
43
|
+
run: Effect<never, E, void>;
|
|
44
|
+
size: Effect<never, E, number>;
|
|
45
|
+
sizeForParent: (parentId: string) => Effect<never, E, number>;
|
|
46
|
+
set: (parentId: string, resourceId: string, resource: Discord.Role) => Effect<never, E, void>;
|
|
47
|
+
delete: (parentId: string, resourceId: string) => Effect<never, E, void>;
|
|
48
|
+
parentDelete: (parentId: string) => Effect<never, E, void>;
|
|
49
|
+
refreshTTL: (parentId: string, resourceId: string) => Effect<never, E, void>;
|
|
50
50
|
}>;
|
package/Cache/prelude.js
CHANGED
|
@@ -2,10 +2,9 @@ import * as tsplus_module_1 from "@effect/stream/Stream";
|
|
|
2
2
|
import * as tsplus_module_2 from "@effect/io/Effect";
|
|
3
3
|
import { DiscordREST } from "dfx";
|
|
4
4
|
import { Gateway } from "dfx/gateway";
|
|
5
|
-
import { Effect, Stream } from "dfx/_common";
|
|
6
5
|
import { CacheMissError, make, makeWithParent, } from "./index.js";
|
|
7
6
|
export const opsWithParent = ({ id, fromParent, create, update, remove, parentRemove, }) => {
|
|
8
|
-
const fromParentOps = tsplus_module_1.flatMap(([parentId, a]) =>
|
|
7
|
+
const fromParentOps = tsplus_module_1.flatMap(([parentId, a]) => tsplus_module_1.fromIterable(a.map((resource) => ({
|
|
9
8
|
op: "create",
|
|
10
9
|
parentId,
|
|
11
10
|
resourceId: id(resource),
|
|
@@ -66,7 +65,7 @@ export const guilds = (makeDriver) => tsplus_module_2.flatMap(driver => tsplus_m
|
|
|
66
65
|
remove: tsplus_module_1.map((a) => a.id)(gateway.fromDispatch("GUILD_DELETE")),
|
|
67
66
|
}),
|
|
68
67
|
onMiss: (id) => tsplus_module_2.flatMap((r) => r.json)(rest.getGuild(id)),
|
|
69
|
-
}))(
|
|
68
|
+
}))(tsplus_module_2.service(DiscordREST)))(tsplus_module_2.service(Gateway.DiscordGateway)))(makeDriver);
|
|
70
69
|
export const channels = (makeDriver) => tsplus_module_2.flatMap(driver => tsplus_module_2.flatMap(gateway => tsplus_module_2.map(rest => makeWithParent({
|
|
71
70
|
driver,
|
|
72
71
|
ops: opsWithParent({
|
|
@@ -84,7 +83,7 @@ export const channels = (makeDriver) => tsplus_module_2.flatMap(driver => tsplus
|
|
|
84
83
|
onMiss: (id) => tsplus_module_2.flatMap((r) => r.json)(rest.getChannel(id)),
|
|
85
84
|
onParentMiss: (guildId) => tsplus_module_2.map((a) => a.map((a) => [a.id, a]))(tsplus_module_2.flatMap((r) => r.json)(rest
|
|
86
85
|
.getGuildChannels(guildId))),
|
|
87
|
-
}))(
|
|
86
|
+
}))(tsplus_module_2.service(DiscordREST)))(tsplus_module_2.service(Gateway.DiscordGateway)))(makeDriver);
|
|
88
87
|
export const roles = (makeDriver) => tsplus_module_2.flatMap(driver => tsplus_module_2.flatMap(gateway => tsplus_module_2.map(rest => makeWithParent({
|
|
89
88
|
driver,
|
|
90
89
|
ops: opsWithParent({
|
|
@@ -99,8 +98,8 @@ export const roles = (makeDriver) => tsplus_module_2.flatMap(driver => tsplus_mo
|
|
|
99
98
|
.fromDispatch("GUILD_ROLE_DELETE")),
|
|
100
99
|
parentRemove: tsplus_module_1.map((g) => g.id)(gateway.fromDispatch("GUILD_DELETE")),
|
|
101
100
|
}),
|
|
102
|
-
onMiss: (id) =>
|
|
101
|
+
onMiss: (id) => tsplus_module_2.fail(new CacheMissError("RolesCache", id)),
|
|
103
102
|
onParentMiss: (guildId) => tsplus_module_2.map((a) => a.map((a) => [a.id, a]))(tsplus_module_2.flatMap((r) => r.json)(rest
|
|
104
103
|
.getGuildRoles(guildId))),
|
|
105
|
-
}))(
|
|
104
|
+
}))(tsplus_module_2.service(DiscordREST)))(tsplus_module_2.service(Gateway.DiscordGateway)))(makeDriver);
|
|
106
105
|
//# sourceMappingURL=prelude.js.map
|
package/Cache/prelude.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prelude.js","sourceRoot":"","sources":["../../src/Cache/prelude.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"prelude.js","sourceRoot":"","sources":["../../src/Cache/prelude.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,OAAO,EAEL,cAAc,EAEd,IAAI,EACJ,cAAc,GAGf,MAAM,YAAY,CAAA;AAWnB,MAAM,CAAC,MAAM,aAAa,GAAG,CAAO,EAClC,EAAE,EACF,UAAU,EACV,MAAM,EACN,MAAM,EACN,MAAM,EACN,YAAY,GACgB,EAAE,EAAE;IAChC,MAAM,aAAa,GAAG,wBAAmB,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CACzD,6BACE,CAAC,CAAC,GAAG,CACH,CAAC,QAAQ,EAAoB,EAAE,CAAC,CAAC;QAC/B,EAAE,EAAE,QAAQ;QACZ,QAAQ;QACR,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC;QACxB,QAAQ;KACT,CAAC,CACH,CACF,EAVmB,UAAU,CAW/B,CAAA;IAED,MAAM,SAAS,GAAG,oBAChB,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAoB,EAAE,CAAC,CAAC;QAC3C,EAAE,EAAE,QAAQ;QACZ,QAAQ;QACR,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC;QACxB,QAAQ;KACT,CAAC,EANc,MAAM,CAOvB,CAAA;IAED,MAAM,SAAS,GAAG,oBAChB,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAoB,EAAE,CAAC,CAAC;QAC3C,EAAE,EAAE,QAAQ;QACZ,QAAQ;QACR,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC;QACxB,QAAQ;KACT,CAAC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C,CAAC,CAAC,EAHrC,wBAEW,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAFxB,IAAI;SACD,aAAa,CAAC,OAAO,CAAC,CACA,CACa;CACzC,CAAC,EA1Ba,wBAAe,WAAW,CAAC,GADxB,wBAAe,OAAO,CAAC,cAAc,CAAC,GADvC,UAAU,CA6B3B,CAAA"}
|
package/DiscordConfig/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Duration, Discord } from "dfx/_common";
|
|
2
2
|
export interface DiscordConfig {
|
|
3
3
|
token: string;
|
|
4
4
|
rest: {
|
|
5
5
|
baseUrl: string;
|
|
6
6
|
globalRateLimit: {
|
|
7
7
|
limit: number;
|
|
8
|
-
window: Duration
|
|
8
|
+
window: Duration;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
gateway: {
|
|
@@ -15,11 +15,11 @@ export interface DiscordConfig {
|
|
|
15
15
|
identifyRateLimit: readonly [window: number, limit: number];
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
export declare const DiscordConfig:
|
|
18
|
+
export declare const DiscordConfig: import("../_common.js").Tag<DiscordConfig>;
|
|
19
19
|
export interface MakeOpts {
|
|
20
20
|
token: string;
|
|
21
21
|
rest?: Partial<DiscordConfig["rest"]>;
|
|
22
22
|
gateway?: Partial<DiscordConfig["gateway"]>;
|
|
23
23
|
}
|
|
24
24
|
export declare const make: ({ token, rest, gateway }: MakeOpts) => DiscordConfig;
|
|
25
|
-
export declare const makeLayer: (a_0: MakeOpts) =>
|
|
25
|
+
export declare const makeLayer: (a_0: MakeOpts) => import("../_common.js").Layer<never, never, DiscordConfig>;
|
package/DiscordConfig/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as tsplus_module_1 from "dfx/_common";
|
|
2
|
+
import * as tsplus_module_2 from "@fp-ts/data/Duration";
|
|
3
|
+
import * as tsplus_module_3 from "@effect/io/Layer";
|
|
4
|
+
import * as tsplus_module_4 from "@fp-ts/data/Function";
|
|
2
5
|
const VERSION = 10;
|
|
3
|
-
export const DiscordConfig =
|
|
6
|
+
export const DiscordConfig = tsplus_module_1.Tag();
|
|
4
7
|
export const make = ({ token, rest, gateway }) => ({
|
|
5
8
|
token,
|
|
6
9
|
rest: {
|
|
@@ -8,15 +11,15 @@ export const make = ({ token, rest, gateway }) => ({
|
|
|
8
11
|
...(rest ?? {}),
|
|
9
12
|
globalRateLimit: {
|
|
10
13
|
limit: 50,
|
|
11
|
-
window:
|
|
14
|
+
window: tsplus_module_2.seconds(1),
|
|
12
15
|
...(rest?.globalRateLimit ?? {}),
|
|
13
16
|
},
|
|
14
17
|
},
|
|
15
18
|
gateway: {
|
|
16
|
-
intents: Discord.GatewayIntents.GUILDS,
|
|
19
|
+
intents: tsplus_module_1.Discord.GatewayIntents.GUILDS,
|
|
17
20
|
identifyRateLimit: [5000, 1],
|
|
18
21
|
...(gateway ?? {}),
|
|
19
22
|
},
|
|
20
23
|
});
|
|
21
|
-
export const makeLayer = flow(make,
|
|
24
|
+
export const makeLayer = tsplus_module_4.flow(make, tsplus_module_3.succeed(DiscordConfig));
|
|
22
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DiscordConfig/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DiscordConfig/index.ts"],"names":[],"mappings":";;;;AAAA,MAAM,OAAO,GAAG,EAAE,CAAA;AAmBlB,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAA,GAAG,EAAiB,CAAA;AAQjD,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAY,EAAiB,EAAE,CAAC,CAAC;IAC1E,KAAK;IACL,IAAI,EAAE;QACJ,OAAO,EAAE,4BAA4B,OAAO,EAAE;QAC9C,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;QACf,eAAe,EAAE;YACf,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,wBAAiB,CAAC,CAAC;YAC3B,GAAG,CAAC,IAAI,EAAE,eAAe,IAAI,EAAE,CAAC;SACjC;KACF;IACD,OAAO,EAAE;QACP,OAAO,EAAE,gBAAA,OAAO,CAAC,cAAc,CAAC,MAAM;QACtC,iBAAiB,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5B,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;KACnB;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,gBAAA,IAAI,CAAC,IAAI,EAAE,wBAAc,aAAa,CAAC,CAAC,CAAA"}
|