dfx 0.21.22 → 0.22.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/Cache/memory.d.ts +2 -2
- package/Cache/memoryTTL.d.ts +2 -2
- package/Cache/memoryTTL.js +11 -11
- package/Cache/memoryTTL.js.map +1 -1
- package/Cache/prelude.d.ts +5 -5
- package/Cache/prelude.js +52 -52
- package/Cache/prelude.js.map +1 -1
- package/Cache.d.ts +69 -0
- package/{Cache/index.js → Cache.js} +15 -15
- package/Cache.js.map +1 -0
- package/{DiscordConfig/index.d.ts → DiscordConfig.d.ts} +3 -3
- package/{DiscordConfig/index.js → DiscordConfig.js} +2 -2
- package/DiscordConfig.js.map +1 -0
- package/DiscordGateway/{DiscordWS/index.d.ts → DiscordWS.d.ts} +5 -5
- package/DiscordGateway/{DiscordWS/index.js → DiscordWS.js} +9 -9
- package/DiscordGateway/DiscordWS.js.map +1 -0
- package/DiscordGateway/Shard/heartbeats.d.ts +1 -1
- package/DiscordGateway/Shard/heartbeats.js +7 -7
- package/DiscordGateway/Shard/heartbeats.js.map +1 -1
- package/DiscordGateway/Shard/identify.d.ts +1 -1
- package/DiscordGateway/Shard/identify.js +3 -3
- package/DiscordGateway/Shard/identify.js.map +1 -1
- package/DiscordGateway/Shard/invalidSession.d.ts +1 -1
- package/DiscordGateway/Shard/invalidSession.js +1 -1
- package/DiscordGateway/Shard/invalidSession.js.map +1 -1
- package/DiscordGateway/Shard/utils.d.ts +2 -2
- package/DiscordGateway/Shard/utils.js +3 -3
- package/DiscordGateway/Shard/utils.js.map +1 -1
- package/DiscordGateway/Shard.d.ts +9 -0
- package/DiscordGateway/Shard.js +44 -0
- package/DiscordGateway/Shard.js.map +1 -0
- package/DiscordGateway/{ShardStore/index.d.ts → ShardStore.d.ts} +2 -2
- package/DiscordGateway/{ShardStore/index.js → ShardStore.js} +1 -1
- package/DiscordGateway/ShardStore.js.map +1 -0
- package/DiscordGateway/Sharder.d.ts +16 -0
- package/DiscordGateway/Sharder.js +42 -0
- package/DiscordGateway/Sharder.js.map +1 -0
- package/DiscordGateway/{WS/index.d.ts → WS.d.ts} +1 -1
- package/DiscordGateway/{WS/index.js → WS.js} +10 -10
- package/DiscordGateway/WS.js.map +1 -0
- package/DiscordGateway.d.ts +12 -0
- package/DiscordGateway.js +20 -0
- package/DiscordGateway.js.map +1 -0
- package/DiscordREST/types.d.ts +5 -7
- package/DiscordREST/utils.d.ts +1 -1
- package/DiscordREST/utils.js +3 -4
- package/DiscordREST/utils.js.map +1 -1
- package/DiscordREST.d.ts +194 -0
- package/DiscordREST.js +120 -0
- package/DiscordREST.js.map +1 -0
- package/Helpers/interactions.js +10 -10
- package/Helpers/interactions.js.map +1 -1
- package/Helpers/permissions.d.ts +2 -2
- package/Helpers/permissions.js +4 -4
- package/Helpers/permissions.js.map +1 -1
- package/Interactions/context.d.ts +6 -6
- package/Interactions/context.js +6 -6
- package/Interactions/context.js.map +1 -1
- package/Interactions/gateway.d.ts +4 -2
- package/Interactions/gateway.js +6 -7
- package/Interactions/gateway.js.map +1 -1
- package/Interactions/handlers.js +6 -6
- package/Interactions/handlers.js.map +1 -1
- package/Interactions/index.d.ts +3 -2
- package/Interactions/index.js +5 -4
- package/Interactions/index.js.map +1 -1
- package/Interactions/webhook.d.ts +3 -3
- package/Interactions/webhook.js +9 -9
- package/Interactions/webhook.js.map +1 -1
- package/Log.d.ts +12 -0
- package/{Log/index.js → Log.js} +1 -1
- package/Log.js.map +1 -0
- package/RateLimit/memory.d.ts +1 -1
- package/RateLimit/memory.js +3 -3
- package/RateLimit/memory.js.map +1 -1
- package/{RateLimit/index.d.ts → RateLimit.d.ts} +6 -6
- package/{RateLimit/index.js → RateLimit.js} +8 -8
- package/RateLimit.js.map +1 -0
- package/gateway.d.ts +10 -10
- package/gateway.js +11 -12
- package/gateway.js.map +1 -1
- package/global.d.ts +1 -1
- package/index.d.ts +5 -6
- package/index.js +5 -6
- package/index.js.map +1 -1
- package/package.json +8 -6
- package/webhooks.d.ts +4 -4
- package/webhooks.js +3 -4
- package/webhooks.js.map +1 -1
- package/Cache/index.d.ts +0 -69
- package/Cache/index.js.map +0 -1
- package/DiscordConfig/index.js.map +0 -1
- package/DiscordGateway/DiscordWS/index.js.map +0 -1
- package/DiscordGateway/Shard/index.d.ts +0 -9
- package/DiscordGateway/Shard/index.js +0 -44
- package/DiscordGateway/Shard/index.js.map +0 -1
- package/DiscordGateway/ShardStore/index.js.map +0 -1
- package/DiscordGateway/Sharder/index.d.ts +0 -16
- package/DiscordGateway/Sharder/index.js +0 -42
- package/DiscordGateway/Sharder/index.js.map +0 -1
- package/DiscordGateway/WS/index.js.map +0 -1
- package/DiscordGateway/index.d.ts +0 -12
- package/DiscordGateway/index.js +0 -20
- package/DiscordGateway/index.js.map +0 -1
- package/DiscordREST/index.d.ts +0 -188
- package/DiscordREST/index.js +0 -122
- package/DiscordREST/index.js.map +0 -1
- package/Http/index.d.ts +0 -37
- package/Http/index.js +0 -51
- package/Http/index.js.map +0 -1
- package/Log/index.d.ts +0 -12
- package/Log/index.js.map +0 -1
- package/RateLimit/index.js.map +0 -1
package/DiscordREST/index.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "dfx/_common";
|
|
2
|
-
import * as tsplus_module_2 from "@effect/io/Effect";
|
|
3
|
-
import * as tsplus_module_3 from "@effect/data/Duration";
|
|
4
|
-
import * as tsplus_module_4 from "@fp-ts/core/Option";
|
|
5
|
-
import * as tsplus_module_5 from "@effect/io/Config/Secret";
|
|
6
|
-
import * as tsplus_module_6 from "@effect/data/HashSet";
|
|
7
|
-
import * as tsplus_module_7 from "@effect/io/Ref";
|
|
8
|
-
import * as tsplus_module_8 from "dfx";
|
|
9
|
-
import * as tsplus_module_9 from "@effect/io/Layer";
|
|
10
|
-
import { millis } from "@effect/data/Duration";
|
|
11
|
-
import Pkg from "../package.json" assert { type: "json" };
|
|
12
|
-
import { rateLimitFromHeaders, retryAfter, routeFromConfig } from "./utils.js";
|
|
13
|
-
const make = tsplus_module_2.flatMap(http => tsplus_module_2.flatMap(({ token, rest }) => tsplus_module_2.flatMap(log => tsplus_module_2.flatMap(store => tsplus_module_2.flatMap(({ maybeWait }) => {
|
|
14
|
-
const globalRateLimit = maybeWait("dfx.rest.global", rest.globalRateLimit.window, rest.globalRateLimit.limit);
|
|
15
|
-
return tsplus_module_2.map(badRoutesRef => {
|
|
16
|
-
const addBadRoute = (route) => tsplus_module_2.collectAllParDiscard([
|
|
17
|
-
log.info("DiscordREST", "addBadRoute", route),
|
|
18
|
-
tsplus_module_7.update(s => tsplus_module_6.add(route)(s))(badRoutesRef),
|
|
19
|
-
store.incrementCounter("dfx.rest.invalid", tsplus_module_3.minutes(10).millis, 10000),
|
|
20
|
-
]);
|
|
21
|
-
const isBadRoute = (route) => tsplus_module_2.map(s => tsplus_module_6.has(route)(s))(tsplus_module_7.get(badRoutesRef));
|
|
22
|
-
const removeBadRoute = (route) => tsplus_module_7.update(s => tsplus_module_6.remove(route)(s))(badRoutesRef);
|
|
23
|
-
const invalidRateLimit = (route) => tsplus_module_2.asUnit(tsplus_module_2.tap(invalid => invalid
|
|
24
|
-
? maybeWait("dfx.rest.invalid", tsplus_module_3.minutes(10), 10000)
|
|
25
|
-
: tsplus_module_2.unit())(isBadRoute(route)));
|
|
26
|
-
// Request rate limiting
|
|
27
|
-
const requestRateLimit = (path, init) => (() => {
|
|
28
|
-
const route = routeFromConfig(path, init);
|
|
29
|
-
return tsplus_module_2.flatMap(maybeBucket => {
|
|
30
|
-
const bucket = tsplus_module_4.getOrElse(() => ({
|
|
31
|
-
key: `?.${route}`,
|
|
32
|
-
resetAfter: 5000,
|
|
33
|
-
limit: 1,
|
|
34
|
-
}))(maybeBucket);
|
|
35
|
-
const resetAfter = millis(bucket.resetAfter);
|
|
36
|
-
return tsplus_module_2.flatMap(() => tsplus_module_2.map(() => void 0)(maybeWait(`dfx.rest.${bucket.key}`, resetAfter, bucket.limit)))(invalidRateLimit(route));
|
|
37
|
-
})(store.getBucketForRoute(route));
|
|
38
|
-
})();
|
|
39
|
-
// Update rate limit buckets
|
|
40
|
-
const updateBuckets = (path, init, response) => tsplus_module_2.ignore((() => {
|
|
41
|
-
const route = routeFromConfig(path, init);
|
|
42
|
-
return tsplus_module_2.flatMap(({ bucket, retryAfter, limit, remaining }) => {
|
|
43
|
-
const effectsToRun = [
|
|
44
|
-
removeBadRoute(route),
|
|
45
|
-
store.putBucketRoute(route, bucket),
|
|
46
|
-
];
|
|
47
|
-
return tsplus_module_2.flatMap(hasBucket => {
|
|
48
|
-
if (!hasBucket || limit - 1 === remaining) {
|
|
49
|
-
effectsToRun.push(store.removeCounter(`dfx.rest.?.${route}`), store.putBucket({
|
|
50
|
-
key: bucket,
|
|
51
|
-
resetAfter: retryAfter.millis,
|
|
52
|
-
limit: !hasBucket && remaining > 0 ? remaining : limit,
|
|
53
|
-
}));
|
|
54
|
-
}
|
|
55
|
-
return tsplus_module_2.map(() => void 0)(tsplus_module_2.collectAllParDiscard(effectsToRun));
|
|
56
|
-
})(store.hasBucket(bucket));
|
|
57
|
-
})(tsplus_module_2.fromOption(rateLimitFromHeaders(response.headers)));
|
|
58
|
-
})());
|
|
59
|
-
const request = (path, init = {}) => tsplus_module_2.catchTag("StatusCodeError", e => {
|
|
60
|
-
switch (e.code) {
|
|
61
|
-
case 403:
|
|
62
|
-
return tsplus_module_2.flatMap(() => tsplus_module_2.fail(e))(tsplus_module_2.collectAllParDiscard([
|
|
63
|
-
log.info("DiscordREST", "403", path),
|
|
64
|
-
addBadRoute(routeFromConfig(path, init)),
|
|
65
|
-
updateBuckets(path, init, e.response),
|
|
66
|
-
]));
|
|
67
|
-
case 429:
|
|
68
|
-
return tsplus_module_2.flatMap(() => request(path, init))(tsplus_module_2.collectAllParDiscard([
|
|
69
|
-
log.info("DiscordREST", "429", path),
|
|
70
|
-
addBadRoute(routeFromConfig(path, init)),
|
|
71
|
-
updateBuckets(path, init, e.response),
|
|
72
|
-
tsplus_module_2.sleep(tsplus_module_4.getOrElse(() => tsplus_module_3.seconds(5))(retryAfter(e.response.headers))),
|
|
73
|
-
]));
|
|
74
|
-
}
|
|
75
|
-
return tsplus_module_2.fail(e);
|
|
76
|
-
})(tsplus_module_2.flatMap(() => tsplus_module_2.flatMap(() => tsplus_module_2.flatMap(response => tsplus_module_2.map(() => response)(updateBuckets(path, init, response.response)))(http.requestWithJson(`${rest.baseUrl}${path}`, {
|
|
77
|
-
...init,
|
|
78
|
-
headers: {
|
|
79
|
-
...(init?.headers ?? {}),
|
|
80
|
-
Authorization: `Bot ${tsplus_module_5.value(token)}`,
|
|
81
|
-
"User-Agent": `DiscordBot (https://github.com/tim-smart/dfx, ${Pkg.version})`,
|
|
82
|
-
},
|
|
83
|
-
})))(globalRateLimit))(requestRateLimit(path, init)));
|
|
84
|
-
const routes = tsplus_module_1.Discord.createRoutes(({ method, url, params, options = {}, }) => {
|
|
85
|
-
const hasBody = method !== "GET" && method !== "DELETE";
|
|
86
|
-
let hasFormData = typeof options?.body?.append === "function";
|
|
87
|
-
let body = undefined;
|
|
88
|
-
const headers = {};
|
|
89
|
-
if (hasBody && !hasFormData) {
|
|
90
|
-
headers["content-type"] = "application/json";
|
|
91
|
-
}
|
|
92
|
-
const qs = new URLSearchParams();
|
|
93
|
-
if (!hasBody) {
|
|
94
|
-
Object.entries((params ?? {})).forEach(([key, value]) => {
|
|
95
|
-
qs.append(key, value);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
else if (hasFormData) {
|
|
99
|
-
body = options.body;
|
|
100
|
-
if (params) {
|
|
101
|
-
;
|
|
102
|
-
body.append("payload_json", JSON.stringify(params));
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else if (params) {
|
|
106
|
-
body = JSON.stringify(params);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
body = options.body;
|
|
110
|
-
}
|
|
111
|
-
return request(`${url}?${qs.toString()}`, {
|
|
112
|
-
method,
|
|
113
|
-
headers,
|
|
114
|
-
body,
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
return { request, ...routes };
|
|
118
|
-
})(tsplus_module_7.make(tsplus_module_6.empty()));
|
|
119
|
-
})(tsplus_module_2.service(tsplus_module_8.RateLimiter)))(tsplus_module_2.service(tsplus_module_8.RateLimitStore)))(tsplus_module_2.service(tsplus_module_8.Log.Log)))(tsplus_module_2.service(tsplus_module_8.DiscordConfig.DiscordConfig)))(tsplus_module_2.service(tsplus_module_8.Http));
|
|
120
|
-
export const DiscordREST = tsplus_module_1.Tag();
|
|
121
|
-
export const LiveDiscordREST = tsplus_module_9.effect(DiscordREST, make);
|
|
122
|
-
//# sourceMappingURL=index.js.map
|
package/DiscordREST/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DiscordREST/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,GAAG,MAAM,iBAAiB,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,CAAA;AAEzD,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE9E,MAAM,IAAI,2BACF,IAAI,6BACJ,EAAE,KAAK,EAAE,IAAI,EAAE,6BAEf,GAAG,4BACH,KAAK,6BACL,EAAE,SAAS,EAAE;IAEnB,MAAM,eAAe,GAAG,SAAS,CAC/B,iBAAiB,EACjB,IAAI,CAAC,eAAe,CAAC,MAAM,EAC3B,IAAI,CAAC,eAAe,CAAC,KAAK,CAC3B,CAAA;+BAGK,YAAY;QAClB,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,EAAE,sCACpC;YACE,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,aAAa,EAAE,KAAK,CAAC;YAC7C,uBAAoB,CAAC,CAAC,EAAE,CAAC,oBAAM,KAA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,gBAAA,GAAG,CAAC,GAAG,CAAC,GAFX,wBAAe,gBAAA,aAAa,CAAC,aAAa,CAAC,GADtD,wCAAe,IAAI,CAAC,CA0LnC,CAAA;AAGF,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAA,GAAG,EAAe,CAAA;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG,uBAAa,WAAW,EAAE,IAAI,CAAC,CAAA"}
|
package/Http/index.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
declare const make: () => {
|
|
2
|
-
request: (url: URL | string, init?: RequestInit) => import("../_common.js").Effect<never, FetchError | StatusCodeError, Response>;
|
|
3
|
-
requestWithJson: <A = unknown>(url: URL | string, init?: RequestInit) => import("../_common.js").Effect<never, FetchError | StatusCodeError, {
|
|
4
|
-
response: Response;
|
|
5
|
-
json: import("../_common.js").Effect<never, JsonParseError, A>;
|
|
6
|
-
blob: import("../_common.js").Effect<never, BlobError, Blob>;
|
|
7
|
-
text: import("../_common.js").Effect<never, never, string>;
|
|
8
|
-
}>;
|
|
9
|
-
};
|
|
10
|
-
export interface Http extends ReturnType<typeof make> {
|
|
11
|
-
}
|
|
12
|
-
export declare const Http: import("../_common.js").Tag<Http>;
|
|
13
|
-
export declare const LiveHttp: import("../_common.js").Layer<never, never, Http>;
|
|
14
|
-
export declare class FetchError {
|
|
15
|
-
readonly reason: unknown;
|
|
16
|
-
readonly _tag = "FetchError";
|
|
17
|
-
constructor(reason: unknown);
|
|
18
|
-
}
|
|
19
|
-
export declare class StatusCodeError {
|
|
20
|
-
readonly response: Response;
|
|
21
|
-
readonly _tag = "StatusCodeError";
|
|
22
|
-
readonly code: number;
|
|
23
|
-
constructor(response: Response);
|
|
24
|
-
}
|
|
25
|
-
export declare class JsonParseError {
|
|
26
|
-
readonly reason: unknown;
|
|
27
|
-
readonly _tag = "JsonParseError";
|
|
28
|
-
constructor(reason: unknown);
|
|
29
|
-
}
|
|
30
|
-
export declare const json: <A = unknown>(r: Response) => import("../_common.js").Effect<never, JsonParseError, A>;
|
|
31
|
-
export declare class BlobError {
|
|
32
|
-
readonly reason: unknown;
|
|
33
|
-
readonly _tag = "BlobError";
|
|
34
|
-
constructor(reason: unknown);
|
|
35
|
-
}
|
|
36
|
-
export declare const blob: (r: Response) => import("../_common.js").Effect<never, BlobError, Blob>;
|
|
37
|
-
export {};
|
package/Http/index.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
|
-
import * as tsplus_module_2 from "dfx/_common";
|
|
3
|
-
import * as tsplus_module_3 from "@effect/io/Layer";
|
|
4
|
-
const make = () => {
|
|
5
|
-
const request = (url, init = {}) => tsplus_module_1.filterOrElseWith(r => r.status < 300, r => tsplus_module_1.fail(new StatusCodeError(r)))(tsplus_module_1.tryCatchPromiseInterrupt(signal => fetch(url, {
|
|
6
|
-
...init,
|
|
7
|
-
signal,
|
|
8
|
-
}), e => new FetchError(e)));
|
|
9
|
-
const requestWithJson = (url, init = {}) => tsplus_module_1.map(response => ({
|
|
10
|
-
response,
|
|
11
|
-
json: json(response),
|
|
12
|
-
blob: blob(response),
|
|
13
|
-
text: tsplus_module_1.promise(() => response.text()),
|
|
14
|
-
}))(request(url, init));
|
|
15
|
-
return { request, requestWithJson };
|
|
16
|
-
};
|
|
17
|
-
export const Http = tsplus_module_2.Tag();
|
|
18
|
-
export const LiveHttp = tsplus_module_3.sync(Http, make);
|
|
19
|
-
export class FetchError {
|
|
20
|
-
reason;
|
|
21
|
-
_tag = "FetchError";
|
|
22
|
-
constructor(reason) {
|
|
23
|
-
this.reason = reason;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export class StatusCodeError {
|
|
27
|
-
response;
|
|
28
|
-
_tag = "StatusCodeError";
|
|
29
|
-
code;
|
|
30
|
-
constructor(response) {
|
|
31
|
-
this.response = response;
|
|
32
|
-
this.code = response.status;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export class JsonParseError {
|
|
36
|
-
reason;
|
|
37
|
-
_tag = "JsonParseError";
|
|
38
|
-
constructor(reason) {
|
|
39
|
-
this.reason = reason;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export const json = (r) => tsplus_module_1.tryCatchPromise(() => r.json(), reason => new JsonParseError(reason));
|
|
43
|
-
export class BlobError {
|
|
44
|
-
reason;
|
|
45
|
-
_tag = "BlobError";
|
|
46
|
-
constructor(reason) {
|
|
47
|
-
this.reason = reason;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
export const blob = (r) => tsplus_module_1.tryCatchPromise(() => r.blob(), reason => new BlobError(reason));
|
|
51
|
-
//# sourceMappingURL=index.js.map
|
package/Http/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Http/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,GAAG,EAAE;IAChB,MAAM,OAAO,GAAG,CAAC,GAAiB,EAAE,OAAoB,EAAE,EAAE,EAAE,CAC5D,iCAQE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,EACnB,CAAC,CAAC,EAAE,CAAC,qBAAY,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC,EAT1C,yCACE,MAAM,CAAC,EAAE,CACP,KAAK,CAAC,GAAG,EAAE;QACT,GAAG,IAAI;QACP,MAAM;KACP,CAAC,EACJ,CAAC,CAAC,EAAE,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CACvB,CAGA,CAAA;IAEH,MAAM,eAAe,GAAG,CACtB,GAAiB,EACjB,OAAoB,EAAE,EACtB,EAAE,CACF,oBAAuB,QAAQ,CAAC,EAAE,CAAC,CAAC;QAClC,QAAQ;QACR,IAAI,EAAE,IAAI,CAAI,QAAQ,CAAC;QACvB,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC;QACpB,IAAI,EAAE,wBAAe,GAAG,EAAE,CAA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IAAI,SAAS,CAAC,MAAM,CAAC,CAChC,CAAA"}
|
package/Log/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare const make: (debug?: boolean) => {
|
|
2
|
-
info: (...args: any[]) => import("../_common.js").Effect<never, never, void>;
|
|
3
|
-
debug: (...args: any[]) => import("../_common.js").Effect<never, never, void>;
|
|
4
|
-
};
|
|
5
|
-
export interface Log extends ReturnType<typeof make> {
|
|
6
|
-
}
|
|
7
|
-
export declare const Log: import("../_common.js").Tag<Log>;
|
|
8
|
-
export declare const LiveLog: import("../_common.js").Layer<never, never, Log>;
|
|
9
|
-
export declare const LiveLogDebug: import("../_common.js").Layer<never, never, Log>;
|
|
10
|
-
export declare const info: (...args: any[]) => import("../_common.js").Effect<Log, never, void>;
|
|
11
|
-
export declare const debug: (...args: any[]) => import("../_common.js").Effect<Log, never, void>;
|
|
12
|
-
export {};
|
package/Log/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Log/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,CAAC,KAAK,GAAG,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/B,IAAI,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE,CACvB,qBAAY,GAAG,EAAE;QACf,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAA;IAChC,CAAC,CAAC;IACJ,KAAK,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE,CACxB,KAAK;QACH,CAAC,CAAC,qBAAY,GAAG,EAAE;YACf,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;QACjC,CAAC,CAAC;QACJ,CAAC,CAAC,sBAAa;CACpB,CAAC,CAAA;AAGF,MAAM,CAAC,MAAM,GAAG,GAAG,gBAAA,GAAG,EAAO,CAAA;AAC7B,MAAM,CAAC,MAAM,OAAO,GAAG,w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