devframe 0.9.19 → 0.10.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/_shared-B2PZsp-J.mjs +191 -0
- package/dist/{_shared-BIUet_Jh.d.mts → _shared-Dy1UBMUN.d.mts} +13 -14
- package/dist/adapters/build.d.mts +3 -4
- package/dist/adapters/build.mjs +4 -5
- package/dist/adapters/cac.d.mts +3 -4
- package/dist/adapters/cac.mjs +3 -3
- package/dist/adapters/dev.d.mts +8 -8
- package/dist/adapters/dev.mjs +2 -2
- package/dist/adapters/embedded.d.mts +1 -1
- package/dist/adapters/initiate.d.mts +8 -8
- package/dist/adapters/initiate.mjs +1 -1
- package/dist/adapters/mcp.d.mts +4 -123
- package/dist/adapters/mcp.mjs +1 -589
- package/dist/agentic-D4QQQUjE.d.mts +30 -0
- package/dist/cli/main.mjs +12 -260
- package/dist/client/index.d.mts +6 -6
- package/dist/client/index.mjs +3 -4
- package/dist/constants.d.mts +2 -1
- package/dist/constants.mjs +2 -1
- package/dist/{context-BA5FPz7K.d.mts → context-B4BKPuaa.d.mts} +1 -1
- package/dist/{context-BLXXjoBW.mjs → context-C141q8H4.mjs} +5 -5
- package/dist/{context-jXO5vzjH.mjs → context-CHpyLX8W.mjs} +1 -1
- package/dist/{context-BLHBDQcZ.d.mts → context-CTAxz9ec.d.mts} +108 -47
- package/dist/{dev-DbWecpjA.mjs → dev-DM1mIlgi.mjs} +16 -24
- package/dist/{diagnostics-DZA6KQ_Z.mjs → diagnostics-Cx4_VjlG.mjs} +11 -3
- package/dist/dist-Bw3EbMj4.mjs +305 -0
- package/dist/dist-CO98PBnQ.mjs +265 -0
- package/dist/{host-agent-C3MBpNCd.mjs → host-agent-ZSKgzMVu.mjs} +2 -7
- package/dist/import-runtime-module-BzlEQ9PI.mjs +24 -0
- package/dist/in-page-channel/index.d.mts +2 -7
- package/dist/in-page-channel/index.mjs +1 -4
- package/dist/index-Bia1vKjL.d.mts +218 -0
- package/dist/{index-r6NstVmM.d.mts → index-CcPSKbxb.d.mts} +2 -2
- package/dist/index-CeEtxDmK.d.mts +78 -0
- package/dist/{index-CiA6C705.d.mts → index-DuEm0sDH.d.mts} +1 -1
- package/dist/index.d.mts +4 -11
- package/dist/index.mjs +1 -10
- package/dist/{instance-registry-DCq762YJ.mjs → instance-registry-DtvYxc0Y.mjs} +1 -1
- package/dist/{instance-shell-C6Vg97lg.d.mts → instance-shell-DOZSxst6.d.mts} +31 -5
- package/dist/{instance-shell-370Oee9K.mjs → instance-shell-wC2sfEU_.mjs} +6 -6
- package/dist/interactive-auth-BCa_iamv.mjs +384 -0
- package/dist/internal/index.d.mts +66 -22
- package/dist/internal/index.mjs +143 -8
- package/dist/mrmime-40h5OOIp.mjs +448 -0
- package/dist/node/auth.d.mts +2 -2
- package/dist/node/hub-internals.d.mts +2 -2
- package/dist/node/hub-internals.mjs +2 -2
- package/dist/node/index.d.mts +2 -4
- package/dist/node/index.mjs +2 -2
- package/dist/{nostics-0sKe5HIj.d.mts → nostics-DWvukRwa.d.mts} +11 -2
- package/dist/{origin-DGDH8BI9.d.mts → origin-CY6BBHOy.d.mts} +14 -1
- package/dist/recipes/interactive-auth.d.mts +2 -2
- package/dist/recipes/interactive-auth.mjs +1 -231
- package/dist/{remote-assets-D0StJVLp.mjs → remote-assets-B9MeWmW6.mjs} +2 -2
- package/dist/rpc/client.d.mts +1 -1
- package/dist/rpc/client.mjs +1 -1
- package/dist/rpc/dump.d.mts +2 -1
- package/dist/rpc/index.d.mts +3 -2
- package/dist/rpc/server.d.mts +1 -1
- package/dist/rpc/server.mjs +1 -1
- package/dist/rpc/transports/sse-client.d.mts +1 -1
- package/dist/rpc/transports/sse-server.d.mts +3 -3
- package/dist/rpc/transports/ws-bun.d.mts +2 -2
- package/dist/rpc/transports/ws-client.d.mts +1 -1
- package/dist/rpc/transports/ws-deno.d.mts +2 -2
- package/dist/rpc/transports/ws-server.d.mts +2 -2
- package/dist/{rpc-core-CvkU23bQ.mjs → rpc-core-BXyMjbKG.mjs} +1 -1
- package/dist/{rpc-core-BlL-Ip8n.d.mts → rpc-core-rLrwFEcw.d.mts} +4 -4
- package/dist/{services-install-Ben4yh52.mjs → services-install-D5YUwFXW.mjs} +17 -1
- package/dist/{sse-client-BcbYwXdD.d.mts → sse-client-DNdscfu_.d.mts} +2 -2
- package/dist/{storage-B70AXK64.mjs → storage-CHD1IkqU.mjs} +1 -1
- package/dist/types/index.d.mts +4 -4
- package/dist/{types-D2vGd7-2.d.mts → types-BmDbfHCx.d.mts} +2 -3
- package/dist/utils/debounce.d.mts +50 -0
- package/dist/utils/debounce.mjs +88 -0
- package/dist/utils/events.d.mts +1 -1
- package/dist/utils/launch-editor.d.mts +8 -0
- package/dist/utils/launch-editor.mjs +36 -1
- package/dist/utils/nostics.d.mts +2 -2
- package/dist/utils/origin.d.mts +2 -2
- package/dist/utils/origin.mjs +21 -1
- package/dist/utils/remote-assets.mjs +1 -1
- package/dist/utils/serve-static.mjs +1 -1
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/simple-schema.d.mts +3 -2
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/dist/utils/url.d.mts +31 -0
- package/dist/utils/url.mjs +58 -0
- package/dist/{ws-client-CNpP6Ium.d.mts → ws-client-6Mrz6eC4.d.mts} +2 -2
- package/dist/{ws-server-BB8jhxeT.d.mts → ws-server-y2R76aSW.d.mts} +2 -2
- package/package.json +10 -11
- package/dist/_shared-U8D-xzrp.mjs +0 -115
- package/dist/agent-tool-name-DGzeuWcO.mjs +0 -31
- package/dist/client-assets-DNdhagGm.mjs +0 -16
- package/dist/nostics-DD6gsDZA.mjs +0 -108
- package/dist/recipes/common-rpc-functions.d.mts +0 -70
- package/dist/recipes/common-rpc-functions.mjs +0 -115
- package/dist/simple-schema-Bi40l-P6.mjs +0 -154
|
@@ -1,232 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as defineRpcFunction } from "../define-BLWPsH6y.mjs";
|
|
3
|
-
import { isAnonymousRpcMethod } from "../constants.mjs";
|
|
4
|
-
import { a as getTempAuthCodeInfo, n as describeUA, o as refreshTempAuthCode, r as exchangeTempAuthCode, s as verifyAuthToken, t as buildOtpAuthUrl } from "../state-W4wI6X5X.mjs";
|
|
5
|
-
import { t as getInternalContext } from "../context-jXO5vzjH.mjs";
|
|
6
|
-
import { t as s } from "../simple-schema-Bi40l-P6.mjs";
|
|
7
|
-
//#region src/recipes/interactive-auth.ts
|
|
8
|
-
/**
|
|
9
|
-
* Build a {@link AuthBannerFunction} that renders the auth code + magic-link
|
|
10
|
-
* URL as a small bordered box, its two rows label-aligned. `createInteractiveAuth`
|
|
11
|
-
* falls back to `createAuthBanner()` when no `banner` is given; call this
|
|
12
|
-
* yourself to rebrand the box (`title` / `colors`) and pass the result as
|
|
13
|
-
* `options.banner`.
|
|
14
|
-
*/
|
|
15
|
-
function createAuthBanner(options = {}) {
|
|
16
|
-
const title = options.title ?? "Devframe";
|
|
17
|
-
const palette = {
|
|
18
|
-
border: colors.dim,
|
|
19
|
-
title: (x) => colors.gray(colors.bold(x)),
|
|
20
|
-
label: colors.dim,
|
|
21
|
-
code: (f) => colors.green(colors.bold(f)),
|
|
22
|
-
url: colors.cyan,
|
|
23
|
-
...options.colors
|
|
24
|
-
};
|
|
25
|
-
return (info) => {
|
|
26
|
-
const rows = [
|
|
27
|
-
[
|
|
28
|
-
"auth code",
|
|
29
|
-
info.code,
|
|
30
|
-
palette.code
|
|
31
|
-
],
|
|
32
|
-
[
|
|
33
|
-
"or open",
|
|
34
|
-
info.url,
|
|
35
|
-
palette.url
|
|
36
|
-
],
|
|
37
|
-
[
|
|
38
|
-
"expires at",
|
|
39
|
-
new Date(info.expireAt).toLocaleTimeString(),
|
|
40
|
-
palette.label
|
|
41
|
-
]
|
|
42
|
-
];
|
|
43
|
-
if (info.requester) {
|
|
44
|
-
rows.push([
|
|
45
|
-
"ua",
|
|
46
|
-
info.requester.ua,
|
|
47
|
-
palette.label
|
|
48
|
-
]);
|
|
49
|
-
rows.push([
|
|
50
|
-
"origin",
|
|
51
|
-
info.requester.origin,
|
|
52
|
-
palette.label
|
|
53
|
-
]);
|
|
54
|
-
}
|
|
55
|
-
const labelWidth = Math.max(...rows.map(([label]) => label.length));
|
|
56
|
-
const contentWidth = Math.max(...rows.map(([, value]) => labelWidth + 2 + value.length));
|
|
57
|
-
const titleBarLength = title.length + 2;
|
|
58
|
-
const lineWidth = Math.max(contentWidth, titleBarLength - 2);
|
|
59
|
-
const top = [
|
|
60
|
-
palette.border(`╭`),
|
|
61
|
-
palette.title(title),
|
|
62
|
-
palette.border(`${"─".repeat(Math.max(lineWidth + 2 - titleBarLength, 0))}╮`)
|
|
63
|
-
].join(" ");
|
|
64
|
-
const bottom = `╰${"─".repeat(lineWidth + 2)}╯`;
|
|
65
|
-
const body = rows.map(([label, value, color]) => {
|
|
66
|
-
const plain = `${label.padEnd(labelWidth)} ${value}`;
|
|
67
|
-
const pad = " ".repeat(lineWidth - plain.length);
|
|
68
|
-
return `${palette.border("│")} ${palette.label(label.padEnd(labelWidth))} ${color(value)}${pad} ${palette.border("│")}`;
|
|
69
|
-
});
|
|
70
|
-
console.log(`\n${palette.border(top)}\n${body.join("\n")}\n${palette.border(bottom)}\n`);
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Package the interactive OTP auth protocol devframe's primitives
|
|
75
|
-
* (`exchangeTempAuthCode`, `verifyAuthToken`, `revokeAuthToken`,
|
|
76
|
-
* `getTempAuthCode`, `buildOtpAuthUrl`) implement into a ready-made
|
|
77
|
-
* {@link DevframeAuthHandler}: the handshake RPC functions, the resolver
|
|
78
|
-
* gate, the connect-time trust hook, and the startup banner.
|
|
79
|
-
*
|
|
80
|
-
* The auth storage stays internal to this handler; callers never reach into
|
|
81
|
-
* `devframe/node/hub-internals` themselves.
|
|
82
|
-
*
|
|
83
|
-
* ```ts
|
|
84
|
-
* import { createInteractiveAuth } from 'devframe/recipes/interactive-auth'
|
|
85
|
-
*
|
|
86
|
-
* const auth = createInteractiveAuth(ctx)
|
|
87
|
-
* auth.rpcFunctions.forEach(fn => ctx.rpc.register(fn))
|
|
88
|
-
* auth.printBanner()
|
|
89
|
-
*
|
|
90
|
-
* // wire `auth.authorize` / `auth.onConnect` into your transport, or pass
|
|
91
|
-
* // the whole handler to `initDevframe` / `initHub` via their `auth` option.
|
|
92
|
-
* ```
|
|
93
|
-
*/
|
|
94
|
-
function createInteractiveAuth(context, options = {}) {
|
|
95
|
-
const internal = getInternalContext(context);
|
|
96
|
-
const storage = internal.storage.auth;
|
|
97
|
-
const staticTokens = new Set(options.clientAuthTokens ?? []);
|
|
98
|
-
function isStaticToken(token) {
|
|
99
|
-
return !!token && staticTokens.has(token);
|
|
100
|
-
}
|
|
101
|
-
function resolveServerUrl() {
|
|
102
|
-
return options.serverUrl?.() ?? context.host.resolveOrigin();
|
|
103
|
-
}
|
|
104
|
-
const banner = options.banner ?? createAuthBanner();
|
|
105
|
-
let bannerPrintedForCode;
|
|
106
|
-
function printBanner(info) {
|
|
107
|
-
const { code, expireAt } = getTempAuthCodeInfo();
|
|
108
|
-
if (code === bannerPrintedForCode) return;
|
|
109
|
-
bannerPrintedForCode = code;
|
|
110
|
-
const url = buildOtpAuthUrl(resolveServerUrl(), code);
|
|
111
|
-
banner({
|
|
112
|
-
code,
|
|
113
|
-
url,
|
|
114
|
-
expireAt,
|
|
115
|
-
...info?.requester ? { requester: info.requester } : {}
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
const anonymousAuth = defineRpcFunction({
|
|
119
|
-
name: "anonymous:devframe:auth",
|
|
120
|
-
type: "action",
|
|
121
|
-
jsonSerializable: true,
|
|
122
|
-
args: [s.object({
|
|
123
|
-
authToken: s.string(),
|
|
124
|
-
ua: s.string(),
|
|
125
|
-
origin: s.string()
|
|
126
|
-
})],
|
|
127
|
-
returns: s.object({ isTrusted: s.boolean() }),
|
|
128
|
-
handler(params) {
|
|
129
|
-
const session = context.rpc.getCurrentRpcSession();
|
|
130
|
-
if (!session) return { isTrusted: false };
|
|
131
|
-
if (session.meta.isTrusted) return { isTrusted: true };
|
|
132
|
-
if (isStaticToken(params.authToken)) {
|
|
133
|
-
session.meta.clientAuthToken = params.authToken;
|
|
134
|
-
session.meta.isTrusted = true;
|
|
135
|
-
return { isTrusted: true };
|
|
136
|
-
}
|
|
137
|
-
return { isTrusted: verifyAuthToken(params.authToken, session, storage) };
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
const anonymousAuthExchange = defineRpcFunction({
|
|
141
|
-
name: "anonymous:devframe:auth:exchange",
|
|
142
|
-
type: "action",
|
|
143
|
-
jsonSerializable: true,
|
|
144
|
-
args: [s.object({
|
|
145
|
-
code: s.string(),
|
|
146
|
-
ua: s.string(),
|
|
147
|
-
origin: s.string()
|
|
148
|
-
})],
|
|
149
|
-
returns: s.object({ authToken: s.nullable(s.string()) }),
|
|
150
|
-
handler(params) {
|
|
151
|
-
const session = context.rpc.getCurrentRpcSession();
|
|
152
|
-
if (!session) return { authToken: null };
|
|
153
|
-
const authToken = exchangeTempAuthCode(params.code, session, params, storage);
|
|
154
|
-
if (authToken) options.onTrusted?.({
|
|
155
|
-
session,
|
|
156
|
-
authToken
|
|
157
|
-
});
|
|
158
|
-
return { authToken };
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
const anonymousAuthRequestCode = defineRpcFunction({
|
|
162
|
-
name: "anonymous:devframe:auth:request-code",
|
|
163
|
-
type: "action",
|
|
164
|
-
jsonSerializable: true,
|
|
165
|
-
args: [s.object({
|
|
166
|
-
ua: s.string(),
|
|
167
|
-
origin: s.string(),
|
|
168
|
-
reissue: s.optional(s.boolean())
|
|
169
|
-
})],
|
|
170
|
-
returns: s.void(),
|
|
171
|
-
handler(params) {
|
|
172
|
-
if (params.reissue) refreshTempAuthCode();
|
|
173
|
-
printBanner({ requester: {
|
|
174
|
-
ua: describeUA(params.ua),
|
|
175
|
-
origin: params.origin
|
|
176
|
-
} });
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
const revoke = defineRpcFunction({
|
|
180
|
-
name: "devframe:auth:revoke",
|
|
181
|
-
type: "action",
|
|
182
|
-
jsonSerializable: true,
|
|
183
|
-
args: [],
|
|
184
|
-
returns: s.void(),
|
|
185
|
-
async handler() {
|
|
186
|
-
const token = context.rpc.getCurrentRpcSession()?.meta.clientAuthToken;
|
|
187
|
-
if (token) await internal.revokeAuthToken(token);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
function authorize(methodName, session) {
|
|
191
|
-
if (isAnonymousRpcMethod(methodName)) return true;
|
|
192
|
-
return !!session.meta.isTrusted;
|
|
193
|
-
}
|
|
194
|
-
function onConnect(connection, session) {
|
|
195
|
-
let token;
|
|
196
|
-
let requestOrigin;
|
|
197
|
-
try {
|
|
198
|
-
token = new URL(connection.request?.url ?? "", "http://localhost").searchParams.get("devframe_auth_token") ?? void 0;
|
|
199
|
-
} catch {}
|
|
200
|
-
try {
|
|
201
|
-
requestOrigin = connection.request?.headers?.get?.("origin") ?? void 0;
|
|
202
|
-
} catch {}
|
|
203
|
-
if (!token) return;
|
|
204
|
-
if (isStaticToken(token)) {
|
|
205
|
-
session.meta.clientAuthToken = token;
|
|
206
|
-
session.meta.isTrusted = true;
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
if (verifyAuthToken(token, session, storage)) return;
|
|
210
|
-
if (internal.isRemoteTokenTrusted(token, requestOrigin)) {
|
|
211
|
-
session.meta.clientAuthToken = token;
|
|
212
|
-
session.meta.isTrusted = true;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
function buildOpenUrl(url) {
|
|
216
|
-
return buildOtpAuthUrl(url);
|
|
217
|
-
}
|
|
218
|
-
return {
|
|
219
|
-
rpcFunctions: [
|
|
220
|
-
anonymousAuth,
|
|
221
|
-
anonymousAuthExchange,
|
|
222
|
-
anonymousAuthRequestCode,
|
|
223
|
-
revoke
|
|
224
|
-
],
|
|
225
|
-
authorize,
|
|
226
|
-
onConnect,
|
|
227
|
-
printBanner,
|
|
228
|
-
buildOpenUrl
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
//#endregion
|
|
1
|
+
import { n as createInteractiveAuth, t as createAuthBanner } from "../interactive-auth-BCa_iamv.mjs";
|
|
232
2
|
export { createAuthBanner, createInteractiveAuth };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { t as diagnostics } from "./diagnostics-
|
|
1
|
+
import { t as diagnostics } from "./diagnostics-Cx4_VjlG.mjs";
|
|
2
|
+
import { t as lookup } from "./mrmime-40h5OOIp.mjs";
|
|
2
3
|
import { createRequire } from "node:module";
|
|
3
4
|
import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
4
5
|
import { dirname, extname, isAbsolute, join, normalize, resolve, sep } from "pathe";
|
|
@@ -7,7 +8,6 @@ import { formatWithOptions, inspect } from "node:util";
|
|
|
7
8
|
import { createReadStream, existsSync } from "node:fs";
|
|
8
9
|
import { Buffer } from "node:buffer";
|
|
9
10
|
import { Readable } from "node:stream";
|
|
10
|
-
import { lookup } from "mrmime";
|
|
11
11
|
//#region ../../node_modules/.pnpm/obug@3.0.0/node_modules/obug/dist/core.js
|
|
12
12
|
/**
|
|
13
13
|
* Coerce `value`.
|
package/dist/rpc/client.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as ChannelOptions, i as BirpcReturn, r as BirpcOptions } from "../index-Bia1vKjL.mjs";
|
|
2
2
|
//#region src/rpc/client.d.ts
|
|
3
3
|
export declare function createRpcClient<ServerFunctions extends object = Record<string, never>, ClientFunctions extends object = Record<string, never>>(functions: ClientFunctions, options: {
|
|
4
4
|
channel: ChannelOptions;
|
package/dist/rpc/client.mjs
CHANGED
package/dist/rpc/dump.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as BirpcReturn } from "../index-Bia1vKjL.mjs";
|
|
2
|
+
import { c as RpcDumpCollectionOptions, f as RpcDumpRecordError, g as RpcFunctionDefinitionAny, i as RpcDefinitionsToFunctions, p as RpcDumpStore, s as RpcDumpClientOptions } from "../types-BmDbfHCx.mjs";
|
|
2
3
|
//#region src/rpc/dump/collect.d.ts
|
|
3
4
|
export declare function dumpFunctions<T extends readonly RpcFunctionDefinitionAny[]>(definitions: T, context?: any, options?: RpcDumpCollectionOptions): Promise<RpcDumpStore<RpcDefinitionsToFunctions<T>>>;
|
|
4
5
|
/**
|
package/dist/rpc/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { i as BirpcReturn, t as BirpcFn } from "../index-Bia1vKjL.mjs";
|
|
2
|
+
import { a as STRUCTURED_CLONE_PREFIX, c as getRpcResolvedSetupResult, d as RpcFunctionsCollectorBase, f as RpcCacheManager, i as validateRpcReturn, l as createDefineWrapperWithContext, n as validateDefinitions, o as strictJsonStringify, p as RpcCacheOptions, r as validateRpcArgs, s as getRpcHandler, t as validateDefinition, u as defineRpcFunction } from "../index-DuEm0sDH.mjs";
|
|
3
|
+
import { C as RpcFunctionType, E as Thenable, S as RpcFunctionSetupResult, T as RpcReturnSchema, _ as RpcFunctionDefinitionAnyWithContext, a as RpcDefinitionsToFunctionsWithNamespace, b as RpcFunctionDefinitionWithSchemas, c as RpcDumpCollectionOptions, d as RpcDumpRecord, f as RpcDumpRecordError, g as RpcFunctionDefinitionAny, h as RpcFunctionDefinition, i as RpcDefinitionsToFunctions, l as RpcDumpDefinition, m as RpcFunctionAgentOptions, n as RpcArgsSchema, o as RpcDump, p as RpcDumpStore, r as RpcDefinitionsFilter, s as RpcDumpClientOptions, t as EntriesToObject, u as RpcDumpGetter, v as RpcFunctionDefinitionBase, w as RpcFunctionsCollector, x as RpcFunctionDefinitionWithoutSchemas, y as RpcFunctionDefinitionToFunction } from "../types-BmDbfHCx.mjs";
|
|
3
4
|
export { type BirpcFn, type BirpcReturn, EntriesToObject, RpcArgsSchema, RpcCacheManager, RpcCacheOptions, RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcDefinitionsToFunctionsWithNamespace, RpcDump, RpcDumpClientOptions, RpcDumpCollectionOptions, RpcDumpDefinition, RpcDumpGetter, RpcDumpRecord, RpcDumpRecordError, RpcDumpStore, RpcFunctionAgentOptions, RpcFunctionDefinition, RpcFunctionDefinitionAny, RpcFunctionDefinitionAnyWithContext, RpcFunctionDefinitionBase, RpcFunctionDefinitionToFunction, RpcFunctionDefinitionWithSchemas, RpcFunctionDefinitionWithoutSchemas, RpcFunctionSetupResult, RpcFunctionType, RpcFunctionsCollector, RpcFunctionsCollectorBase, RpcReturnSchema, STRUCTURED_CLONE_PREFIX, Thenable, createDefineWrapperWithContext, defineRpcFunction, getRpcHandler, getRpcResolvedSetupResult, strictJsonStringify, validateDefinition, validateDefinitions, validateRpcArgs, validateRpcReturn };
|
package/dist/rpc/server.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BirpcGroup, EventOptions } from "
|
|
1
|
+
import { n as BirpcGroup, o as EventOptions } from "../index-Bia1vKjL.mjs";
|
|
2
2
|
//#region src/rpc/server.d.ts
|
|
3
3
|
export declare function createRpcServer<ClientFunctions extends object = Record<string, never>, ServerFunctions extends object = Record<string, never>>(functions: ServerFunctions, options?: {
|
|
4
4
|
rpcOptions?: EventOptions<ClientFunctions, ServerFunctions, false>;
|
package/dist/rpc/server.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createSseRpcChannel, t as SseRpcChannelOptions } from "../../sse-client-
|
|
1
|
+
import { n as createSseRpcChannel, t as SseRpcChannelOptions } from "../../sse-client-DNdscfu_.mjs";
|
|
2
2
|
export { SseRpcChannelOptions, createSseRpcChannel };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as BirpcGroup } from "../../index-Bia1vKjL.mjs";
|
|
2
|
+
import { g as RpcFunctionDefinitionAny } from "../../types-BmDbfHCx.mjs";
|
|
2
3
|
import { n as DevframeRpcConnection, t as DevframeNodeRpcSessionMeta } from "../../session-r6PDixP6.mjs";
|
|
3
|
-
import { n as WsOriginRegistry } from "../../ws-server-
|
|
4
|
-
import { BirpcGroup } from "birpc";
|
|
4
|
+
import { n as WsOriginRegistry } from "../../ws-server-y2R76aSW.mjs";
|
|
5
5
|
//#region src/rpc/transports/sse-server.d.ts
|
|
6
6
|
export interface SseRpcTransportOptions {
|
|
7
7
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as WsOriginRegistry } from "../../ws-server-
|
|
2
|
-
import { t as ContextRpcServer } from "../../rpc-core-
|
|
1
|
+
import { n as WsOriginRegistry } from "../../ws-server-y2R76aSW.mjs";
|
|
2
|
+
import { t as ContextRpcServer } from "../../rpc-core-rLrwFEcw.mjs";
|
|
3
3
|
//#region src/rpc/transports/ws-bun.d.ts
|
|
4
4
|
export interface AttachBunWsTransportOptions {
|
|
5
5
|
/** Same contract as `WsRpcTransportOptions.allowedOrigins`. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createWsRpcChannel, t as WsRpcChannelOptions } from "../../ws-client-
|
|
1
|
+
import { n as createWsRpcChannel, t as WsRpcChannelOptions } from "../../ws-client-6Mrz6eC4.mjs";
|
|
2
2
|
export { WsRpcChannelOptions, createWsRpcChannel };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as WsOriginRegistry } from "../../ws-server-
|
|
2
|
-
import { t as ContextRpcServer } from "../../rpc-core-
|
|
1
|
+
import { n as WsOriginRegistry } from "../../ws-server-y2R76aSW.mjs";
|
|
2
|
+
import { t as ContextRpcServer } from "../../rpc-core-rLrwFEcw.mjs";
|
|
3
3
|
//#region src/rpc/transports/ws-deno.d.ts
|
|
4
4
|
export interface AttachDenoWsTransportOptions {
|
|
5
5
|
/** Same contract as `WsRpcTransportOptions.allowedOrigins`. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as DevframeWsPeer, i as DevframeRpcTransportKind, n as DevframeRpcConnection, r as DevframeRpcConnectionRequest, t as DevframeNodeRpcSessionMeta } from "../../session-r6PDixP6.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { a as attachWsRpcTransport, i as WsRpcTransportOptions, n as WsOriginRegistry, o as createWsOriginRegistry, r as WsRpcTransport, s as createWsRpcPeerHooks, t as CreateWsOriginRegistryOptions } from "../../ws-server-
|
|
2
|
+
import { r as isLoopbackHostname, t as isAllowedOrigin } from "../../origin-CY6BBHOy.mjs";
|
|
3
|
+
import { a as attachWsRpcTransport, i as WsRpcTransportOptions, n as WsOriginRegistry, o as createWsOriginRegistry, r as WsRpcTransport, s as createWsRpcPeerHooks, t as CreateWsOriginRegistryOptions } from "../../ws-server-y2R76aSW.mjs";
|
|
4
4
|
export { CreateWsOriginRegistryOptions, type DevframeNodeRpcSessionMeta, type DevframeRpcConnection, type DevframeRpcConnectionRequest, type DevframeRpcTransportKind, type DevframeWsPeer, WsOriginRegistry, WsRpcTransport, WsRpcTransportOptions, attachWsRpcTransport, createWsOriginRegistry, createWsRpcPeerHooks, isAllowedOrigin, isLoopbackHostname };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.mjs";
|
|
2
2
|
import { createRpcServer } from "./rpc/server.mjs";
|
|
3
|
-
import { t as diagnostics } from "./diagnostics-
|
|
3
|
+
import { t as diagnostics } from "./diagnostics-Cx4_VjlG.mjs";
|
|
4
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
5
|
//#region src/node/rpc-core.ts
|
|
6
6
|
var rpc_core_exports = /* @__PURE__ */ __exportAll({ createContextRpcServer: () => createContextRpcServer });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as BirpcGroup, o as EventOptions } from "./index-Bia1vKjL.mjs";
|
|
2
|
+
import { At as DevframeAuthHandler, Ct as DevframeRpcClientFunctions, o as DevframeNodeContext, s as DevframeNodeRpcSession, wt as DevframeRpcServerFunctions } from "./context-CTAxz9ec.mjs";
|
|
2
3
|
import { n as DevframeRpcConnection, t as DevframeNodeRpcSessionMeta } from "./session-r6PDixP6.mjs";
|
|
3
|
-
import "./ws-server-
|
|
4
|
-
import "./index-
|
|
5
|
-
import { BirpcGroup, EventOptions } from "birpc";
|
|
4
|
+
import "./ws-server-y2R76aSW.mjs";
|
|
5
|
+
import "./index-CcPSKbxb.mjs";
|
|
6
6
|
//#region src/node/rpc-core.d.ts
|
|
7
7
|
interface CreateContextRpcServerOptions {
|
|
8
8
|
context: DevframeNodeContext;
|
|
@@ -31,6 +31,22 @@ function expandResolveFrom(resolveFrom, cwd) {
|
|
|
31
31
|
} catch {}
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
+
* Resolve a package specifier against each `resolveFrom` candidate in order,
|
|
35
|
+
* returning the resolved absolute path or `undefined`. A pure probe: nothing
|
|
36
|
+
* is imported. The resolution base arrives as a parameter (not a literal
|
|
37
|
+
* `createRequire(import.meta.url)`), which keeps bundlers that special-case
|
|
38
|
+
* that pattern (turbopack rewrites its `.resolve()` of a dynamic specifier
|
|
39
|
+
* into a throwing stub) from touching the runtime resolution.
|
|
40
|
+
*/
|
|
41
|
+
function resolveServicePackage(pkg, resolveFrom) {
|
|
42
|
+
for (const from of resolveFrom) {
|
|
43
|
+
if (typeof from !== "string" || from.length === 0) continue;
|
|
44
|
+
try {
|
|
45
|
+
return createRequire(toRequireBase(from)).resolve(pkg);
|
|
46
|
+
} catch {}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
34
50
|
* Import a service package's module, trying each `resolveFrom` candidate in
|
|
35
51
|
* order (so a plugin-declared service resolves against the plugin's own
|
|
36
52
|
* dependency tree first, then the workspace fallback). Throws the last
|
|
@@ -151,4 +167,4 @@ function deepMergeOptionSets(sets) {
|
|
|
151
167
|
return sets.reduce((merged, set) => deepMergeTwo(merged, set));
|
|
152
168
|
}
|
|
153
169
|
//#endregion
|
|
154
|
-
export { satisfiesVersionRange as i, expandResolveFrom as n, importServicePackage as r, deepMergeOptionSets as t };
|
|
170
|
+
export { satisfiesVersionRange as a, resolveServicePackage as i, expandResolveFrom as n, importServicePackage as r, deepMergeOptionSets as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as ChannelOptions } from "./index-Bia1vKjL.mjs";
|
|
2
|
+
import { g as RpcFunctionDefinitionAny } from "./types-BmDbfHCx.mjs";
|
|
3
3
|
//#region src/rpc/transports/sse-client.d.ts
|
|
4
4
|
interface SseRpcChannelOptions {
|
|
5
5
|
/** Resolved `http(s)://` URL of the SSE endpoint. */
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { $ as
|
|
1
|
+
import { m as RpcFunctionAgentOptions } from "../types-BmDbfHCx.mjs";
|
|
2
|
+
import { $ as DevframeServiceDefinition, B as DevframeDefinition, Bt as AgentTool, Ct as DevframeRpcClientFunctions, Dt as DevframeStorageScope, Et as DevframeHost, F as CreateMcpServerOptions, Ft as AgentHandle, G as DevframeSetupInfo, Gt as DevframeAgentHostEvents, H as DevframeDockDefaults, Ht as AgentToolProvider, I as McpConnectionInfo, It as AgentManifest, J as DevframeSseOptions, Jt as EventsMap, K as DevframeSnapshotRpcEntry, Kt as EventEmitter, L as McpFetchHandler, Lt as AgentResource, Ot as DevframeDiagnosticsHost, P as CreateMcpFetchHandlerOptions, Q as McpSetting, R as McpServerHandle, Rt as AgentResourceContent, St as DevframeViewHost, Tt as DevframeRpcSharedStates, U as DevframeDuplicationStrategy, Ut as AgentToolProviderHandle, V as DevframeDeploymentKind, Vt as AgentToolInput, W as DevframeRpcOptions, Wt as DevframeAgentHost, X as McpAuthorization, Y as DevframeWsOptions, Z as McpRouteOptions, _t as ScopedClientFunctions, a as DevframeConnectionConfigsRegistry, at as DevframeServiceScopeOf, bt as ScopedSharedStates, c as RpcBroadcastOptions, ct as DevframeServicesScopeRegistry, d as RpcSharedStateHost, dt as DevframeScopedNodeRpc, et as DevframeServiceDescriptor, f as RpcStreamingChannel, ft as DevframeScopedStreamingHost, gt as ScopedBroadcastOptions, ht as DevframeSettingsStore, i as DevframeCapabilities, it as DevframeServiceOf, kt as DevframeDiagnosticsLogger, l as RpcFunctionsHost, lt as DevframeServicesState, m as RpcStreamingHost, mt as DevframeSettingsRegistry, n as ConnectionMetaSse, nt as DevframeServiceInput, o as DevframeNodeContext, ot as DevframeServicesHost, p as RpcStreamingChannelOptions, pt as DevframeSettings, q as DevframeSnapshotRpcInputs, qt as EventUnsubscribe, r as ConnectionMetaWebsocket, rt as DevframeServiceMeta, s as DevframeNodeRpcSession, st as DevframeServicesRegistry, t as ConnectionMeta, tt as DevframeServiceId, u as RpcSharedStateGetOptions, ut as DevframeScopedNodeContext, vt as ScopedRpcFn, wt as DevframeRpcServerFunctions, xt as SettingsForNamespace, yt as ScopedServerFunctions, z as DevframeCliOptions, zt as AgentResourceInput } from "../context-CTAxz9ec.mjs";
|
|
3
3
|
import { a as DevframeWsPeer, i as DevframeRpcTransportKind, n as DevframeRpcConnection, r as DevframeRpcConnectionRequest, t as DevframeNodeRpcSessionMeta } from "../session-r6PDixP6.mjs";
|
|
4
4
|
import { a as RemoteAssetsStore, i as RemoteAssetsProviderCustom, n as RemoteAssetsErrorMessage, o as StaticAssetsSource, r as RemoteAssetsProvider, t as RemoteAssets } from "../remote-assets-eBvSKZMS.mjs";
|
|
5
|
-
import { i as DevframeDefineDiagnosticsOptions } from "../nostics-
|
|
6
|
-
export { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, AgentToolProvider, AgentToolProviderHandle, ConnectionMeta, ConnectionMetaSse, ConnectionMetaWebsocket, DevframeAgentHost, DevframeAgentHostEvents, DevframeCapabilities, DevframeCliOptions, DevframeConnectionConfigsRegistry, type DevframeDefineDiagnosticsOptions, DevframeDefinition, DevframeDeploymentKind, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeDockDefaults, DevframeDuplicationStrategy, DevframeHost, DevframeNodeContext, DevframeNodeRpcSession, type DevframeNodeRpcSessionMeta, DevframeRpcClientFunctions, type DevframeRpcConnection, type DevframeRpcConnectionRequest, DevframeRpcOptions, DevframeRpcServerFunctions, DevframeRpcSharedStates, type DevframeRpcTransportKind, DevframeScopedNodeContext, DevframeScopedNodeRpc, DevframeScopedStreamingHost, DevframeServiceDefinition, DevframeServiceDescriptor, DevframeServiceId, DevframeServiceInput, DevframeServiceMeta, DevframeServiceOf, DevframeServiceScopeOf, DevframeServicesHost, DevframeServicesRegistry, DevframeServicesScopeRegistry, DevframeServicesState, DevframeSettings, DevframeSettingsRegistry, DevframeSettingsStore, DevframeSetupInfo, DevframeSnapshotRpcEntry, DevframeSnapshotRpcInputs, DevframeSseOptions, DevframeStorageScope, DevframeViewHost, DevframeWsOptions, type DevframeWsPeer, EventEmitter, EventUnsubscribe, EventsMap, McpAuthorization, McpRouteOptions, McpSetting, RemoteAssets, RemoteAssetsErrorMessage, RemoteAssetsProvider, RemoteAssetsProviderCustom, RemoteAssetsStore, RpcBroadcastOptions, type RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, ScopedBroadcastOptions, ScopedClientFunctions, ScopedRpcFn, ScopedServerFunctions, ScopedSharedStates, SettingsForNamespace, StaticAssetsSource };
|
|
5
|
+
import { i as DevframeDefineDiagnosticsOptions } from "../nostics-DWvukRwa.mjs";
|
|
6
|
+
export { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, AgentToolProvider, AgentToolProviderHandle, ConnectionMeta, ConnectionMetaSse, ConnectionMetaWebsocket, CreateMcpFetchHandlerOptions, CreateMcpServerOptions, DevframeAgentHost, DevframeAgentHostEvents, DevframeCapabilities, DevframeCliOptions, DevframeConnectionConfigsRegistry, type DevframeDefineDiagnosticsOptions, DevframeDefinition, DevframeDeploymentKind, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeDockDefaults, DevframeDuplicationStrategy, DevframeHost, DevframeNodeContext, DevframeNodeRpcSession, type DevframeNodeRpcSessionMeta, DevframeRpcClientFunctions, type DevframeRpcConnection, type DevframeRpcConnectionRequest, DevframeRpcOptions, DevframeRpcServerFunctions, DevframeRpcSharedStates, type DevframeRpcTransportKind, DevframeScopedNodeContext, DevframeScopedNodeRpc, DevframeScopedStreamingHost, DevframeServiceDefinition, DevframeServiceDescriptor, DevframeServiceId, DevframeServiceInput, DevframeServiceMeta, DevframeServiceOf, DevframeServiceScopeOf, DevframeServicesHost, DevframeServicesRegistry, DevframeServicesScopeRegistry, DevframeServicesState, DevframeSettings, DevframeSettingsRegistry, DevframeSettingsStore, DevframeSetupInfo, DevframeSnapshotRpcEntry, DevframeSnapshotRpcInputs, DevframeSseOptions, DevframeStorageScope, DevframeViewHost, DevframeWsOptions, type DevframeWsPeer, EventEmitter, EventUnsubscribe, EventsMap, McpAuthorization, McpConnectionInfo, McpFetchHandler, McpRouteOptions, McpServerHandle, McpSetting, RemoteAssets, RemoteAssetsErrorMessage, RemoteAssetsProvider, RemoteAssetsProviderCustom, RemoteAssetsStore, RpcBroadcastOptions, type RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, ScopedBroadcastOptions, ScopedClientFunctions, ScopedRpcFn, ScopedServerFunctions, ScopedSharedStates, SettingsForNamespace, StaticAssetsSource };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
1
|
+
import { t as StandardSchemaV1 } from "./index-CeEtxDmK.mjs";
|
|
3
2
|
//#region src/rpc/utils.d.ts
|
|
4
3
|
/** Infers a TypeScript argument tuple from a Standard Schema array */
|
|
5
4
|
type InferArgsType<S extends RpcArgsSchema | undefined> = S extends readonly [] ? [] : S extends readonly [infer H, ...infer T] ? H extends StandardSchemaV1 ? T extends readonly StandardSchemaV1[] ? [StandardSchemaV1.InferInput<H>, ...InferArgsType<T>] : never : never : never;
|
|
@@ -259,4 +258,4 @@ type RpcDefinitionsFilter<T extends readonly RpcFunctionDefinitionAny[], Type ex
|
|
|
259
258
|
type: Type;
|
|
260
259
|
} ? T[K] : never; };
|
|
261
260
|
//#endregion
|
|
262
|
-
export {
|
|
261
|
+
export { RpcFunctionType as C, InferArgsType as D, Thenable as E, InferReturnType as O, RpcFunctionSetupResult as S, RpcReturnSchema as T, RpcFunctionDefinitionAnyWithContext as _, RpcDefinitionsToFunctionsWithNamespace as a, RpcFunctionDefinitionWithSchemas as b, RpcDumpCollectionOptions as c, RpcDumpRecord as d, RpcDumpRecordError as f, RpcFunctionDefinitionAny as g, RpcFunctionDefinition as h, RpcDefinitionsToFunctions as i, RpcDumpDefinition as l, RpcFunctionAgentOptions as m, RpcArgsSchema as n, RpcDump as o, RpcDumpStore as p, RpcDefinitionsFilter as r, RpcDumpClientOptions as s, EntriesToObject as t, RpcDumpGetter as u, RpcFunctionDefinitionBase as v, RpcFunctionsCollector as w, RpcFunctionDefinitionWithoutSchemas as x, RpcFunctionDefinitionToFunction as y };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/perfect-debounce@2.1.0/node_modules/perfect-debounce/dist/index.d.mts
|
|
2
|
+
//#region src/index.d.ts
|
|
3
|
+
interface DebounceOptions {
|
|
4
|
+
/**
|
|
5
|
+
Call the `fn` on the [leading edge of the timeout](https://css-tricks.com/debouncing-throttling-explained-examples/#article-header-id-1).
|
|
6
|
+
Meaning immediately, instead of waiting for `wait` milliseconds.
|
|
7
|
+
@default false
|
|
8
|
+
*/
|
|
9
|
+
readonly leading?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
Call the `fn` on trailing edge with last used arguments. Result of call is from previous call.
|
|
12
|
+
@default true
|
|
13
|
+
*/
|
|
14
|
+
readonly trailing?: boolean;
|
|
15
|
+
}
|
|
16
|
+
type DebouncedReturn<ArgumentsT extends unknown[], ReturnT> = ((...args: ArgumentsT) => Promise<ReturnT>) & {
|
|
17
|
+
/**
|
|
18
|
+
* Cancel pending function call
|
|
19
|
+
*/
|
|
20
|
+
cancel: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Immediately invoke pending function call
|
|
23
|
+
*/
|
|
24
|
+
flush: () => Promise<ReturnT> | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Get pending function call
|
|
27
|
+
*/
|
|
28
|
+
isPending: () => boolean;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
Debounce functions
|
|
32
|
+
@param fn - Promise-returning/async function to debounce.
|
|
33
|
+
@param wait - Milliseconds to wait before calling `fn`. Default value is 25ms
|
|
34
|
+
@returns A function that delays calling `fn` until after `wait` milliseconds have elapsed since the last time it was called.
|
|
35
|
+
@example
|
|
36
|
+
```
|
|
37
|
+
import { debounce } from 'perfect-debounce';
|
|
38
|
+
const expensiveCall = async input => input;
|
|
39
|
+
const debouncedFn = debounce(expensiveCall, 200);
|
|
40
|
+
for (const number of [1, 2, 3]) {
|
|
41
|
+
console.log(await debouncedFn(number));
|
|
42
|
+
}
|
|
43
|
+
//=> 1
|
|
44
|
+
//=> 2
|
|
45
|
+
//=> 3
|
|
46
|
+
```
|
|
47
|
+
*/
|
|
48
|
+
declare function debounce<ArgumentsT extends unknown[], ReturnT>(fn: (...args: ArgumentsT) => PromiseLike<ReturnT> | ReturnT, wait?: number, options?: DebounceOptions): DebouncedReturn<ArgumentsT, ReturnT>;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { type DebounceOptions, type DebouncedReturn, debounce };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/perfect-debounce@2.1.0/node_modules/perfect-debounce/dist/index.mjs
|
|
2
|
+
const DEBOUNCE_DEFAULTS = { trailing: true };
|
|
3
|
+
/**
|
|
4
|
+
Debounce functions
|
|
5
|
+
@param fn - Promise-returning/async function to debounce.
|
|
6
|
+
@param wait - Milliseconds to wait before calling `fn`. Default value is 25ms
|
|
7
|
+
@returns A function that delays calling `fn` until after `wait` milliseconds have elapsed since the last time it was called.
|
|
8
|
+
@example
|
|
9
|
+
```
|
|
10
|
+
import { debounce } from 'perfect-debounce';
|
|
11
|
+
const expensiveCall = async input => input;
|
|
12
|
+
const debouncedFn = debounce(expensiveCall, 200);
|
|
13
|
+
for (const number of [1, 2, 3]) {
|
|
14
|
+
console.log(await debouncedFn(number));
|
|
15
|
+
}
|
|
16
|
+
//=> 1
|
|
17
|
+
//=> 2
|
|
18
|
+
//=> 3
|
|
19
|
+
```
|
|
20
|
+
*/
|
|
21
|
+
function debounce(fn, wait = 25, options = {}) {
|
|
22
|
+
options = {
|
|
23
|
+
...DEBOUNCE_DEFAULTS,
|
|
24
|
+
...options
|
|
25
|
+
};
|
|
26
|
+
if (!Number.isFinite(wait)) throw new TypeError("Expected `wait` to be a finite number");
|
|
27
|
+
let leadingValue;
|
|
28
|
+
let timeout;
|
|
29
|
+
let resolveList = [];
|
|
30
|
+
let currentPromise;
|
|
31
|
+
let trailingArgs;
|
|
32
|
+
const applyFn = (_this, args) => {
|
|
33
|
+
currentPromise = _applyPromised(fn, _this, args);
|
|
34
|
+
currentPromise.finally(() => {
|
|
35
|
+
currentPromise = null;
|
|
36
|
+
if (options.trailing && trailingArgs && !timeout) {
|
|
37
|
+
const promise = applyFn(_this, trailingArgs);
|
|
38
|
+
trailingArgs = null;
|
|
39
|
+
return promise;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return currentPromise;
|
|
43
|
+
};
|
|
44
|
+
const debounced = function(...args) {
|
|
45
|
+
if (options.trailing) trailingArgs = args;
|
|
46
|
+
if (currentPromise) return currentPromise;
|
|
47
|
+
return new Promise((resolve) => {
|
|
48
|
+
const shouldCallNow = !timeout && options.leading;
|
|
49
|
+
clearTimeout(timeout);
|
|
50
|
+
timeout = setTimeout(() => {
|
|
51
|
+
timeout = null;
|
|
52
|
+
const promise = options.leading ? leadingValue : applyFn(this, args);
|
|
53
|
+
trailingArgs = null;
|
|
54
|
+
for (const _resolve of resolveList) _resolve(promise);
|
|
55
|
+
resolveList = [];
|
|
56
|
+
}, wait);
|
|
57
|
+
if (shouldCallNow) {
|
|
58
|
+
leadingValue = applyFn(this, args);
|
|
59
|
+
resolve(leadingValue);
|
|
60
|
+
} else resolveList.push(resolve);
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
const _clearTimeout = (timer) => {
|
|
64
|
+
if (timer) {
|
|
65
|
+
clearTimeout(timer);
|
|
66
|
+
timeout = null;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
debounced.isPending = () => !!timeout;
|
|
70
|
+
debounced.cancel = () => {
|
|
71
|
+
_clearTimeout(timeout);
|
|
72
|
+
resolveList = [];
|
|
73
|
+
trailingArgs = null;
|
|
74
|
+
};
|
|
75
|
+
debounced.flush = () => {
|
|
76
|
+
_clearTimeout(timeout);
|
|
77
|
+
if (!trailingArgs || currentPromise) return;
|
|
78
|
+
const args = trailingArgs;
|
|
79
|
+
trailingArgs = null;
|
|
80
|
+
return applyFn(this, args);
|
|
81
|
+
};
|
|
82
|
+
return debounced;
|
|
83
|
+
}
|
|
84
|
+
async function _applyPromised(fn, _this, args) {
|
|
85
|
+
return await fn.apply(_this, args);
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
export { debounce };
|
package/dist/utils/events.d.mts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
//#region src/utils/launch-editor.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Editor commands `launch-editor` recognizes with a tailored
|
|
4
|
+
* `file:line:column` invocation. Callers that gate an RPC surface's editor
|
|
5
|
+
* argument to this union keep it from spawning an arbitrary command.
|
|
6
|
+
*/
|
|
7
|
+
export type KnownEditor = 'atom' | 'subl' | 'sublime' | 'sublime_text' | 'wstorm' | 'charm' | 'zed' | 'notepad++' | 'vim' | 'mvim' | 'joe' | 'gvim' | 'emacs' | 'emacsclient' | 'rmate' | 'mate' | 'code' | 'code-insiders' | 'codium' | 'vscodium' | 'trae' | 'antigravity' | 'cursor' | 'appcode' | 'clion' | 'idea' | 'phpstorm' | 'pycharm' | 'rubymine' | 'webstorm' | 'goland' | 'rider';
|
|
8
|
+
/** Runtime list of every {@link KnownEditor}. */
|
|
9
|
+
export declare const KNOWN_EDITORS: KnownEditor[];
|
|
2
10
|
/**
|
|
3
11
|
* Open a file in the user's editor.
|
|
4
12
|
*
|