devframe 0.9.0 → 0.9.2
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-BPmX9fqK.d.mts → _shared-BAGBgTUO.d.mts} +1 -1
- package/dist/{_shared-CbZ_yhbz.mjs → _shared-BM3PdYli.mjs} +1 -1
- package/dist/adapters/build.d.mts +1 -1
- package/dist/adapters/build.mjs +12 -9
- package/dist/adapters/cac.d.mts +1 -1
- package/dist/adapters/cac.mjs +4 -3
- package/dist/adapters/dev.d.mts +3 -3
- package/dist/adapters/dev.mjs +2 -2
- package/dist/adapters/embedded.d.mts +1 -1
- package/dist/adapters/embedded.mjs +2 -0
- package/dist/adapters/initiate.d.mts +2 -2
- package/dist/adapters/initiate.mjs +1 -1
- package/dist/adapters/mcp.d.mts +1 -1
- package/dist/adapters/mcp.mjs +1 -1
- package/dist/cli/main.mjs +2 -2
- package/dist/client/index.d.mts +48 -2
- package/dist/client/index.mjs +133 -23
- package/dist/constants.d.mts +74 -2
- package/dist/constants.mjs +9 -2
- package/dist/{context-xdynGSLP.mjs → context-af2w_F0_.mjs} +2 -2
- package/dist/{context-B3YUu_95.d.mts → context-al99DDJ8.d.mts} +1 -1
- package/dist/{context-CEe4PBz1.mjs → context-riPPHGiu.mjs} +339 -26
- package/dist/{dev--rAPzbvO.mjs → dev-BKm_HisC.mjs} +15 -11
- package/dist/{devframe-DJMg0WLe.d.mts → devframe-mbfgpQQC.d.mts} +774 -587
- package/dist/{diagnostics-DOQPnQmX.mjs → diagnostics-DI1HGj2I.mjs} +20 -0
- package/dist/{dist-eNI9qM_I.mjs → dist-CZXfGEkd.mjs} +1 -1
- package/dist/events-DKfSmoTj.mjs +65 -0
- package/dist/hash-DdPnc4k3.mjs +360 -0
- package/dist/{host-agent-xLCSe65D.mjs → host-agent-DVDLqjvj.mjs} +14 -13
- package/dist/{http-DYpK0cUi.mjs → http-POepPnaQ.mjs} +10 -6
- package/dist/{index-CB-fSUyn.d.mts → index-Dipgo9ji.d.mts} +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/{instance-registry-WvQkt42E.mjs → instance-registry-Dy28drtm.mjs} +4 -4
- package/dist/{instance-shell-CMFyszWJ.mjs → instance-shell-GqTY93gC.mjs} +5 -5
- package/dist/{instance-shell-CljiKq1c.d.mts → instance-shell-mU5j5xWn.d.mts} +2 -2
- package/dist/internal/index.d.mts +40 -4
- package/dist/internal/index.mjs +7 -7
- package/dist/node/auth.d.mts +2 -2
- package/dist/node/auth.mjs +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 +10 -1
- package/dist/node/index.mjs +2 -2
- package/dist/recipes/common-rpc-functions.d.mts +11 -1
- package/dist/recipes/common-rpc-functions.mjs +10 -0
- package/dist/recipes/interactive-auth.d.mts +2 -2
- package/dist/recipes/interactive-auth.mjs +2 -2
- package/dist/{remote-assets-nTTxY2MU.mjs → remote-assets-CqxiyltC.mjs} +18 -7
- package/dist/{revoke-DZbJ7Cl0.mjs → revoke-3Q6aDKWk.mjs} +2 -1
- package/dist/{rolldown-runtime-JspESFgx.mjs → rolldown-runtime-B4iAMlE-.mjs} +1 -1
- package/dist/rpc/dump.mjs +1 -1
- package/dist/rpc/index.mjs +1 -1
- package/dist/rpc/transports/ws-bun.d.mts +1 -1
- package/dist/rpc/transports/ws-deno.d.mts +26 -0
- package/dist/rpc/transports/ws-deno.mjs +30 -0
- package/dist/{rpc-core-DMTe-hLo.mjs → rpc-core-DRYnbxdD.mjs} +2 -2
- package/dist/{rpc-core-Cc4lucI0.d.mts → rpc-core-dV69u4lY.d.mts} +2 -2
- package/dist/{shared-state-fRRbRUtD.mjs → shared-state-DoXutg_U.mjs} +1 -1
- package/dist/{state-Cc1IeSmQ.mjs → state-CK9LjrnT.mjs} +1 -1
- package/dist/{static-BPZ1_OPA.mjs → static-DV_qUSRS.mjs} +1 -1
- package/dist/{storage-CYye7P7L.mjs → storage-BNqSAOxA.mjs} +3 -3
- package/dist/types/index.d.mts +2 -2
- package/dist/utils/events.d.mts +1 -1
- package/dist/utils/get-port.mjs +1 -1
- package/dist/utils/hash.mjs +1 -1
- package/dist/utils/launch-editor.mjs +12 -11
- package/dist/utils/open.mjs +1 -1
- package/dist/utils/remote-assets.d.mts +7 -1
- package/dist/utils/remote-assets.mjs +1 -1
- package/dist/utils/serve-static.mjs +6 -5
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/shared-state.mjs +1 -1
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/dist/validation-YrZH6atx.mjs +311 -0
- package/package.json +4 -3
- package/skills/devframe/SKILL.md +1 -1
- package/dist/hash-KtDZYXDN.mjs +0 -266
- package/dist/validation-CpXFB6Dz.mjs +0 -266
- package/dist/{host-h3-Crkzm42q.mjs → host-h3-fRbF9yor.mjs} +1 -1
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import { t as diagnostics } from "./diagnostics-CD8nlgll.mjs";
|
|
2
|
-
import { createHash } from "node:crypto";
|
|
3
|
-
//#region ../../node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/shared/ohash.D__AXeF1.mjs
|
|
4
|
-
function serialize(o) {
|
|
5
|
-
return typeof o == "string" ? `'${o}'` : new c().serialize(o);
|
|
6
|
-
}
|
|
7
|
-
const c = /*@__PURE__*/ function() {
|
|
8
|
-
class o {
|
|
9
|
-
#t = /* @__PURE__ */ new Map();
|
|
10
|
-
compare(t, r) {
|
|
11
|
-
const e = typeof t, n = typeof r;
|
|
12
|
-
return e === "string" && n === "string" ? t.localeCompare(r) : e === "number" && n === "number" ? t - r : String.prototype.localeCompare.call(this.serialize(t, true), this.serialize(r, true));
|
|
13
|
-
}
|
|
14
|
-
serialize(t, r) {
|
|
15
|
-
if (t === null) return "null";
|
|
16
|
-
switch (typeof t) {
|
|
17
|
-
case "string": return r ? t : `'${t}'`;
|
|
18
|
-
case "bigint": return `${t}n`;
|
|
19
|
-
case "object": return this.$object(t);
|
|
20
|
-
case "function": return this.$function(t);
|
|
21
|
-
}
|
|
22
|
-
return String(t);
|
|
23
|
-
}
|
|
24
|
-
serializeObject(t) {
|
|
25
|
-
const r = Object.prototype.toString.call(t);
|
|
26
|
-
if (r !== "[object Object]") return this.serializeBuiltInType(r.length < 10 ? `unknown:${r}` : r.slice(8, -1), t);
|
|
27
|
-
const e = t.constructor, n = e === Object || e === void 0 ? "" : e.name;
|
|
28
|
-
if (n !== "" && globalThis[n] === e) return this.serializeBuiltInType(n, t);
|
|
29
|
-
if (typeof t.toJSON == "function") {
|
|
30
|
-
const i = t.toJSON();
|
|
31
|
-
return n + (i !== null && typeof i == "object" ? this.$object(i) : `(${this.serialize(i)})`);
|
|
32
|
-
}
|
|
33
|
-
return this.serializeObjectEntries(n, Object.entries(t));
|
|
34
|
-
}
|
|
35
|
-
serializeBuiltInType(t, r) {
|
|
36
|
-
const e = this["$" + t];
|
|
37
|
-
if (e) return e.call(this, r);
|
|
38
|
-
if (typeof r?.entries == "function") return this.serializeObjectEntries(t, r.entries());
|
|
39
|
-
throw new Error(`Cannot serialize ${t}`);
|
|
40
|
-
}
|
|
41
|
-
serializeObjectEntries(t, r) {
|
|
42
|
-
const e = Array.from(r).sort((i, a) => this.compare(i[0], a[0]));
|
|
43
|
-
let n = `${t}{`;
|
|
44
|
-
for (let i = 0; i < e.length; i++) {
|
|
45
|
-
const [a, l] = e[i];
|
|
46
|
-
n += `${this.serialize(a, true)}:${this.serialize(l)}`, i < e.length - 1 && (n += ",");
|
|
47
|
-
}
|
|
48
|
-
return n + "}";
|
|
49
|
-
}
|
|
50
|
-
$object(t) {
|
|
51
|
-
let r = this.#t.get(t);
|
|
52
|
-
return r === void 0 && (this.#t.set(t, `#${this.#t.size}`), r = this.serializeObject(t), this.#t.set(t, r)), r;
|
|
53
|
-
}
|
|
54
|
-
$function(t) {
|
|
55
|
-
const r = Function.prototype.toString.call(t);
|
|
56
|
-
return r.slice(-15) === "[native code] }" ? `${t.name || ""}()[native]` : `${t.name}(${t.length})${r.replace(/\s*\n\s*/g, "")}`;
|
|
57
|
-
}
|
|
58
|
-
$Array(t) {
|
|
59
|
-
let r = "[";
|
|
60
|
-
for (let e = 0; e < t.length; e++) r += this.serialize(t[e]), e < t.length - 1 && (r += ",");
|
|
61
|
-
return r + "]";
|
|
62
|
-
}
|
|
63
|
-
$Date(t) {
|
|
64
|
-
try {
|
|
65
|
-
return `Date(${t.toISOString()})`;
|
|
66
|
-
} catch {
|
|
67
|
-
return "Date(null)";
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
$ArrayBuffer(t) {
|
|
71
|
-
return `ArrayBuffer[${new Uint8Array(t).join(",")}]`;
|
|
72
|
-
}
|
|
73
|
-
$Set(t) {
|
|
74
|
-
return `Set${this.$Array(Array.from(t).sort((r, e) => this.compare(r, e)))}`;
|
|
75
|
-
}
|
|
76
|
-
$Map(t) {
|
|
77
|
-
return this.serializeObjectEntries("Map", t.entries());
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
for (const s of [
|
|
81
|
-
"Error",
|
|
82
|
-
"RegExp",
|
|
83
|
-
"URL"
|
|
84
|
-
]) o.prototype["$" + s] = function(t) {
|
|
85
|
-
return `${s}(${t})`;
|
|
86
|
-
};
|
|
87
|
-
for (const s of [
|
|
88
|
-
"Int8Array",
|
|
89
|
-
"Uint8Array",
|
|
90
|
-
"Uint8ClampedArray",
|
|
91
|
-
"Int16Array",
|
|
92
|
-
"Uint16Array",
|
|
93
|
-
"Int32Array",
|
|
94
|
-
"Uint32Array",
|
|
95
|
-
"Float32Array",
|
|
96
|
-
"Float64Array"
|
|
97
|
-
]) o.prototype["$" + s] = function(t) {
|
|
98
|
-
return `${s}[${t.join(",")}]`;
|
|
99
|
-
};
|
|
100
|
-
for (const s of ["BigInt64Array", "BigUint64Array"]) o.prototype["$" + s] = function(t) {
|
|
101
|
-
return `${s}[${t.join("n,")}${t.length > 0 ? "n" : ""}]`;
|
|
102
|
-
};
|
|
103
|
-
return o;
|
|
104
|
-
}();
|
|
105
|
-
//#endregion
|
|
106
|
-
//#region ../../node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.mjs
|
|
107
|
-
const e = globalThis.process?.getBuiltinModule?.("crypto")?.hash;
|
|
108
|
-
const r = "sha256";
|
|
109
|
-
const s = "base64url";
|
|
110
|
-
function digest(t) {
|
|
111
|
-
if (e) return e(r, t, s);
|
|
112
|
-
const o = createHash(r).update(t);
|
|
113
|
-
return globalThis.process?.versions?.webcontainer ? o.digest().toString(s) : o.digest(s);
|
|
114
|
-
}
|
|
115
|
-
//#endregion
|
|
116
|
-
//#region ../../node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/index.mjs
|
|
117
|
-
function hash$1(input) {
|
|
118
|
-
return digest(serialize(input));
|
|
119
|
-
}
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region src/utils/hash.ts
|
|
122
|
-
/**
|
|
123
|
-
* Stable, deterministic hash of any structured-cloneable value.
|
|
124
|
-
*/
|
|
125
|
-
function hash(value) {
|
|
126
|
-
return hash$1(value);
|
|
127
|
-
}
|
|
128
|
-
//#endregion
|
|
129
|
-
//#region src/rpc/validate-io.ts
|
|
130
|
-
/**
|
|
131
|
-
* Run a single [Standard Schema](https://standardschema.dev) validator,
|
|
132
|
-
* awaiting the result when the validator is asynchronous.
|
|
133
|
-
*/
|
|
134
|
-
async function runStandardSchema(schema, value) {
|
|
135
|
-
const result = schema["~standard"].validate(value);
|
|
136
|
-
return result instanceof Promise ? await result : result;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Render Standard Schema issues into a single human-readable line for a
|
|
140
|
-
* diagnostic message, prefixing each with its dotted path when present.
|
|
141
|
-
*/
|
|
142
|
-
function formatIssues(issues) {
|
|
143
|
-
return issues.map((issue) => {
|
|
144
|
-
const path = issue.path?.map((segment) => typeof segment === "object" ? segment.key : segment).join(".");
|
|
145
|
-
return path ? `${path}: ${issue.message}` : issue.message;
|
|
146
|
-
}).join("; ");
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Validate positional arguments against their declared schemas. Only
|
|
150
|
-
* indices with a schema are checked; extra arguments pass through
|
|
151
|
-
* untouched. Throws `DF0038` on the first failing argument.
|
|
152
|
-
*
|
|
153
|
-
* Validation guards the payload without rewriting it: the original values
|
|
154
|
-
* are handed to the handler unchanged, so a schema that describes a subset
|
|
155
|
-
* of an object never silently strips the sender's extra fields (and any
|
|
156
|
-
* declared transforms stay a purely type-level concern).
|
|
157
|
-
*
|
|
158
|
-
* @internal
|
|
159
|
-
*/
|
|
160
|
-
async function validateRpcArgs(name, argsSchema, args) {
|
|
161
|
-
const original = args.slice();
|
|
162
|
-
if (!argsSchema || argsSchema.length === 0) return original;
|
|
163
|
-
for (let index = 0; index < argsSchema.length; index++) {
|
|
164
|
-
const schema = argsSchema[index];
|
|
165
|
-
if (!schema) continue;
|
|
166
|
-
const result = await runStandardSchema(schema, args[index]);
|
|
167
|
-
if (result.issues) throw diagnostics.DF0043({
|
|
168
|
-
name,
|
|
169
|
-
index,
|
|
170
|
-
issues: formatIssues(result.issues)
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
return original;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Validate a handler's resolved return value against its declared schema.
|
|
177
|
-
* Throws `DF0039` when the value fails the schema, otherwise returns the
|
|
178
|
-
* original value unchanged (guard-only, never rewriting the payload — see
|
|
179
|
-
* {@link validateRpcArgs}). Passes through when no return schema is set.
|
|
180
|
-
*
|
|
181
|
-
* @internal
|
|
182
|
-
*/
|
|
183
|
-
async function validateRpcReturn(name, returnSchema, value) {
|
|
184
|
-
if (!returnSchema) return value;
|
|
185
|
-
const result = await runStandardSchema(returnSchema, value);
|
|
186
|
-
if (result.issues) throw diagnostics.DF0044({
|
|
187
|
-
name,
|
|
188
|
-
issues: formatIssues(result.issues)
|
|
189
|
-
});
|
|
190
|
-
return value;
|
|
191
|
-
}
|
|
192
|
-
//#endregion
|
|
193
|
-
//#region src/rpc/handler.ts
|
|
194
|
-
async function getRpcResolvedSetupResult(definition, context) {
|
|
195
|
-
if (!definition.setup) return {};
|
|
196
|
-
if (typeof context === "object" && context !== null) {
|
|
197
|
-
definition.__cache ??= /* @__PURE__ */ new WeakMap();
|
|
198
|
-
const cache = definition.__cache;
|
|
199
|
-
let promise = cache.get(context);
|
|
200
|
-
if (!promise) {
|
|
201
|
-
promise = Promise.resolve(definition.setup(context));
|
|
202
|
-
promise.catch(() => {
|
|
203
|
-
if (cache.get(context) === promise) cache.delete(context);
|
|
204
|
-
});
|
|
205
|
-
cache.set(context, promise);
|
|
206
|
-
}
|
|
207
|
-
return await promise;
|
|
208
|
-
}
|
|
209
|
-
if (!definition.__promise) {
|
|
210
|
-
const promise = Promise.resolve(definition.setup(context));
|
|
211
|
-
promise.catch(() => {
|
|
212
|
-
if (definition.__promise === promise) definition.__promise = void 0;
|
|
213
|
-
});
|
|
214
|
-
definition.__promise = promise;
|
|
215
|
-
}
|
|
216
|
-
return await definition.__promise;
|
|
217
|
-
}
|
|
218
|
-
async function getRpcHandler(definition, context) {
|
|
219
|
-
let handler = definition.handler;
|
|
220
|
-
if (!handler) {
|
|
221
|
-
const result = await getRpcResolvedSetupResult(definition, context);
|
|
222
|
-
if (!result.handler) throw diagnostics.DF0024({ name: definition.name });
|
|
223
|
-
handler = result.handler;
|
|
224
|
-
}
|
|
225
|
-
const argsSchema = definition.args;
|
|
226
|
-
const returnSchema = definition.returns;
|
|
227
|
-
if (!argsSchema && !returnSchema) return handler;
|
|
228
|
-
const inner = handler;
|
|
229
|
-
const validating = async (...args) => {
|
|
230
|
-
const validatedArgs = await validateRpcArgs(definition.name, argsSchema, args);
|
|
231
|
-
const output = await inner(...validatedArgs);
|
|
232
|
-
return await validateRpcReturn(definition.name, returnSchema, output);
|
|
233
|
-
};
|
|
234
|
-
return validating;
|
|
235
|
-
}
|
|
236
|
-
//#endregion
|
|
237
|
-
//#region src/rpc/validation.ts
|
|
238
|
-
/**
|
|
239
|
-
* Validates RPC function definitions.
|
|
240
|
-
* Action and event functions cannot have dumps (side effects should not be cached).
|
|
241
|
-
*
|
|
242
|
-
* @throws {Error} If an action or event function has a dump configuration
|
|
243
|
-
*/
|
|
244
|
-
function validateDefinitions(definitions) {
|
|
245
|
-
for (const definition of definitions) {
|
|
246
|
-
const type = definition.type || "query";
|
|
247
|
-
if ((type === "action" || type === "event") && definition.dump) throw diagnostics.DF0027({
|
|
248
|
-
name: definition.name,
|
|
249
|
-
type
|
|
250
|
-
});
|
|
251
|
-
if (definition.snapshot && type !== "query") throw diagnostics.DF0028({
|
|
252
|
-
name: definition.name,
|
|
253
|
-
type
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Validates a single RPC function definition.
|
|
259
|
-
*
|
|
260
|
-
* @throws {Error} If an action or event function has a dump configuration
|
|
261
|
-
*/
|
|
262
|
-
function validateDefinition(definition) {
|
|
263
|
-
validateDefinitions([definition]);
|
|
264
|
-
}
|
|
265
|
-
//#endregion
|
|
266
|
-
export { validateRpcArgs as a, getRpcResolvedSetupResult as i, validateDefinitions as n, validateRpcReturn as o, getRpcHandler as r, hash as s, validateDefinition as t };
|