devframe 0.9.8 → 0.9.10

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.
Files changed (121) hide show
  1. package/dist/_shared-CCzf9Hub.d.mts +83 -0
  2. package/dist/_shared-U8D-xzrp.mjs +115 -0
  3. package/dist/adapters/build.d.mts +6 -6
  4. package/dist/adapters/build.mjs +33 -36
  5. package/dist/adapters/cac.d.mts +12 -1
  6. package/dist/adapters/cac.mjs +8 -8
  7. package/dist/adapters/dev.d.mts +17 -17
  8. package/dist/adapters/dev.mjs +2 -2
  9. package/dist/adapters/embedded.d.mts +1 -1
  10. package/dist/adapters/initiate.d.mts +31 -28
  11. package/dist/adapters/initiate.mjs +1 -1
  12. package/dist/adapters/mcp.d.mts +28 -14
  13. package/dist/adapters/mcp.mjs +76 -40
  14. package/dist/{agent-tool-name-EgfoFO8C.mjs → agent-tool-name-DGzeuWcO.mjs} +2 -2
  15. package/dist/cli/main.d.mts +1 -1
  16. package/dist/cli/main.mjs +41 -17
  17. package/dist/client/index.d.mts +36 -36
  18. package/dist/client/index.mjs +90 -52
  19. package/dist/{client-assets-C7SXgTWY.mjs → client-assets-DNdhagGm.mjs} +2 -2
  20. package/dist/constants.d.mts +8 -7
  21. package/dist/constants.mjs +7 -6
  22. package/dist/{context-omlma_1n.mjs → context-B29Oh0oA.mjs} +166 -93
  23. package/dist/{context-DftYyXaR.d.mts → context-BJiKJqyW.d.mts} +5 -5
  24. package/dist/{context-CLF4-8Pp.d.mts → context-CHW4BZOj.d.mts} +203 -134
  25. package/dist/{context-KUqAfawQ.mjs → context-jXO5vzjH.mjs} +3 -3
  26. package/dist/{crypto-token-XCqTSMg9.mjs → crypto-token-TVbGGFuj.mjs} +1 -1
  27. package/dist/{dev-CzkPCJwi.mjs → dev-CRYHx7iG.mjs} +73 -40
  28. package/dist/{diagnostics-BXWW3VK-.mjs → diagnostics-DZA6KQ_Z.mjs} +32 -19
  29. package/dist/{events-4daw0uK9.mjs → events-BV4Dj59a.mjs} +2 -2
  30. package/dist/{services-install-CqqQVls5.mjs → host-agent-CKqSTEX9.mjs} +15 -151
  31. package/dist/{host-h3-fRbF9yor.mjs → host-h3-BROI6SQ4.mjs} +2 -2
  32. package/dist/in-page-channel/index.d.mts +14 -14
  33. package/dist/in-page-channel/index.mjs +63 -54
  34. package/dist/{index-D3k0BIhe.d.mts → index-CNC390b_.d.mts} +4 -4
  35. package/dist/{index-BzyopqxV.d.mts → index-pIVt92jP.d.mts} +9 -9
  36. package/dist/index.d.mts +8 -8
  37. package/dist/index.mjs +2 -2
  38. package/dist/{instance-registry-BjlMQbFB.mjs → instance-registry-DCq762YJ.mjs} +9 -9
  39. package/dist/{instance-shell-Tcp5hGoq.d.mts → instance-shell-DZipaP9k.d.mts} +18 -18
  40. package/dist/{instance-shell-CpVW4zG0.mjs → instance-shell-DvYCwrDy.mjs} +223 -67
  41. package/dist/internal/index.d.mts +45 -26
  42. package/dist/internal/index.mjs +10 -10
  43. package/dist/node/auth.d.mts +2 -2
  44. package/dist/node/auth.mjs +2 -2
  45. package/dist/node/hub-internals.d.mts +2 -2
  46. package/dist/node/hub-internals.mjs +2 -2
  47. package/dist/node/index.d.mts +5 -5
  48. package/dist/node/index.mjs +2 -2
  49. package/dist/{nostics-SPGDgHEP.d.mts → nostics-0sKe5HIj.d.mts} +2 -2
  50. package/dist/{nostics-CzECRXpE.mjs → nostics-D0PvLZsn.mjs} +1 -1
  51. package/dist/origin-DGDH8BI9.d.mts +45 -0
  52. package/dist/origin-DZit9g29.mjs +80 -0
  53. package/dist/recipes/common-rpc-functions.d.mts +5 -5
  54. package/dist/recipes/common-rpc-functions.mjs +3 -3
  55. package/dist/recipes/interactive-auth.d.mts +6 -6
  56. package/dist/recipes/interactive-auth.mjs +6 -6
  57. package/dist/{remote-assets-DezQmPQU.mjs → remote-assets-DMFzLSoH.mjs} +27 -7
  58. package/dist/{remote-assets-B13_vRkJ.d.mts → remote-assets-eBvSKZMS.d.mts} +7 -7
  59. package/dist/{revoke-COLW0cOi.mjs → revoke-cqztiCX4.mjs} +1 -1
  60. package/dist/rpc/dump.d.mts +19 -12
  61. package/dist/rpc/dump.mjs +2 -2
  62. package/dist/rpc/index.d.mts +2 -2
  63. package/dist/rpc/index.mjs +2 -3
  64. package/dist/rpc/transports/sse-client.d.mts +1 -1
  65. package/dist/rpc/transports/sse-client.mjs +30 -14
  66. package/dist/rpc/transports/sse-server.d.mts +4 -4
  67. package/dist/rpc/transports/sse-server.mjs +7 -7
  68. package/dist/rpc/transports/ws-bun.d.mts +5 -5
  69. package/dist/rpc/transports/ws-bun.mjs +8 -2
  70. package/dist/rpc/transports/ws-client.d.mts +1 -1
  71. package/dist/rpc/transports/ws-client.mjs +2 -2
  72. package/dist/rpc/transports/ws-deno.d.mts +4 -4
  73. package/dist/rpc/transports/ws-deno.mjs +8 -2
  74. package/dist/rpc/transports/ws-server.d.mts +2 -1
  75. package/dist/rpc/transports/ws-server.mjs +232 -1
  76. package/dist/{rpc-core-DlHd276T.mjs → rpc-core-CvkU23bQ.mjs} +14 -2
  77. package/dist/{rpc-core-B3W3z9ff.d.mts → rpc-core-DsyDViQy.d.mts} +4 -4
  78. package/dist/serialization-DFg5sUt6.mjs +116 -0
  79. package/dist/services-install-Ben4yh52.mjs +154 -0
  80. package/dist/session-DPfj6zQG.mjs +16 -0
  81. package/dist/{shared-state--sduc6Xi.mjs → shared-state-CaxB1q0h.mjs} +2 -2
  82. package/dist/{simple-schema-DQPZrAaZ.mjs → simple-schema-Bi40l-P6.mjs} +2 -2
  83. package/dist/{sse-client-DwX021ST.d.mts → sse-client-BQ4jS3eO.d.mts} +4 -4
  84. package/dist/{state-CK9LjrnT.mjs → state-Mwt6--el.mjs} +17 -9
  85. package/dist/{storage-BXNVhKyR.mjs → storage-B70AXK64.mjs} +2 -2
  86. package/dist/types/index.d.mts +6 -6
  87. package/dist/{types-CMdPYhOx.d.mts → types-Dq4i156u.d.mts} +17 -17
  88. package/dist/utils/agent-tool-name.d.mts +2 -2
  89. package/dist/utils/agent-tool-name.mjs +2 -2
  90. package/dist/utils/colors.d.mts +1 -1
  91. package/dist/utils/crypto-token.d.mts +1 -1
  92. package/dist/utils/crypto-token.mjs +1 -1
  93. package/dist/utils/events.d.mts +1 -1
  94. package/dist/utils/nostics.d.mts +1 -1
  95. package/dist/utils/nostics.mjs +1 -1
  96. package/dist/utils/open.mjs +1 -1
  97. package/dist/utils/origin.d.mts +2 -0
  98. package/dist/utils/origin.mjs +80 -0
  99. package/dist/utils/remote-assets.d.mts +2 -2
  100. package/dist/utils/remote-assets.mjs +1 -1
  101. package/dist/utils/serve-static.d.mts +4 -4
  102. package/dist/utils/serve-static.mjs +56 -19
  103. package/dist/utils/shared-state.d.mts +1 -1
  104. package/dist/utils/shared-state.mjs +1 -1
  105. package/dist/utils/simple-schema.d.mts +5 -5
  106. package/dist/utils/simple-schema.mjs +2 -2
  107. package/dist/utils/streaming-channel.d.mts +1 -1
  108. package/dist/utils/streaming-channel.mjs +2 -2
  109. package/dist/utils/when.d.mts +5 -5
  110. package/dist/{validation-YrZH6atx.mjs → validation-CfV1s0SF.mjs} +2 -2
  111. package/dist/{wire-codec-0K-o5MYW.mjs → wire-codec-BHGt0sSs.mjs} +3 -3
  112. package/dist/{static-DV_qUSRS.mjs → write-BuLCrn9h.mjs} +153 -137
  113. package/dist/{ws-client-7_lZi-B9.d.mts → ws-client-Xpxt0oPA.d.mts} +3 -3
  114. package/dist/{ws-server-VyHlanzy.d.mts → ws-server-D2nv68Hg.d.mts} +13 -37
  115. package/package.json +3 -6
  116. package/skills/devframe/SKILL.md +5 -3
  117. package/dist/_shared-BM3PdYli.mjs +0 -68
  118. package/dist/_shared-mtXpcJIv.d.mts +0 -41
  119. package/dist/diagnostics-CD8nlgll.mjs +0 -39
  120. package/dist/serialization-BGzEwAdr.mjs +0 -77
  121. package/dist/ws-server-Y_AumUQH.mjs +0 -294
@@ -1,11 +1,11 @@
1
- import { t as diagnostics } from "./diagnostics-BXWW3VK-.mjs";
1
+ import { t as diagnostics } from "./diagnostics-DZA6KQ_Z.mjs";
2
2
  import { createRequire } from "node:module";
3
+ import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
4
+ import { dirname, extname, isAbsolute, join, normalize, resolve, sep } from "pathe";
3
5
  import { isatty } from "node:tty";
4
6
  import { formatWithOptions, inspect } from "node:util";
5
- import { dirname, extname, join, normalize, sep } from "pathe";
6
7
  import { createReadStream, existsSync } from "node:fs";
7
8
  import { Buffer } from "node:buffer";
8
- import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
9
9
  import { Readable } from "node:stream";
10
10
  import { lookup } from "mrmime";
11
11
  //#region ../../node_modules/.pnpm/obug@2.1.4/node_modules/obug/dist/core.js
@@ -302,7 +302,7 @@ const MANIFEST_FILENAME = ".manifest.json";
302
302
  * list is dropped, because it describes the *provider's* transfer rather than
303
303
  * the file: hop-by-hop and encoding headers no longer match the body `fetch`
304
304
  * already decoded, and a CDN's policy headers (`set-cookie`, `cache-control`,
305
- * framing/CSP) belong to its origin — replaying them under the dev server's
305
+ * framing/CSP) belong to its origin, so replaying them under the dev server's
306
306
  * origin could just as well break the iframe these assets render in.
307
307
  */
308
308
  const PROXIED_HEADERS = [
@@ -436,6 +436,24 @@ function candidatePaths(prefix, cleaned) {
436
436
  if (!/\.[a-z0-9]+$/i.test(cleaned) && !candidates.includes(`${prefix}index.html`)) candidates.push(`${prefix}index.html`);
437
437
  return candidates;
438
438
  }
439
+ /**
440
+ * Resolve the safe destination for a provider-listed `filePath` beneath
441
+ * `prefix`, materializing into the already-resolved `root`, or `null` when
442
+ * the entry is unsafe or lies outside the selected `prefix`. A compromised
443
+ * provider is an untrusted boundary even though the built-in jsDelivr/unpkg
444
+ * listings never emit any of this: reject an absolute path, a backslash
445
+ * (never normalized into a separator; Windows-style traversal stays rejected
446
+ * on every platform), and any suffix whose resolved destination would land
447
+ * outside `root`. `target === root` is deliberately unsafe too: it names the
448
+ * directory itself, never a writable file.
449
+ */
450
+ function materializeTarget(filePath, prefix, root) {
451
+ if (filePath.includes("\\") || isAbsolute(filePath) || !filePath.startsWith(prefix)) return null;
452
+ const suffix = filePath.slice(prefix.length);
453
+ if (!suffix || isAbsolute(suffix)) return null;
454
+ const target = resolve(root, suffix);
455
+ return target === root || !target.startsWith(root + sep) ? null : target;
456
+ }
439
457
  function createStore(assets, cacheDir) {
440
458
  const normalized = {
441
459
  ...assets,
@@ -582,8 +600,10 @@ function createStore(assets, cacheDir) {
582
600
  } catch (error) {
583
601
  return fail(errText(error), error);
584
602
  }
585
- for (const filePath of files.filter((f) => f.startsWith(prefix))) {
586
- const target = join(targetDir, filePath.slice(prefix.length));
603
+ const root = resolve(targetDir);
604
+ for (const filePath of files) {
605
+ const target = materializeTarget(filePath, prefix, root);
606
+ if (target == null) continue;
587
607
  const url = provider.fileUrl(normalized.package, normalized.version, filePath);
588
608
  let res;
589
609
  try {
@@ -625,7 +645,7 @@ function assertValidRemoteAssets(assets) {
625
645
  * {@link RemoteAssetsStore} back-proxy. Remote caches live under
626
646
  * `<projectStorageDir>/.remote-assets/<package>@<version>/`.
627
647
  *
628
- * A remote source's `package`/`version` are validated first (`DF0065`) — both
648
+ * A remote source's `package`/`version` are validated first (`DF0065`); both
629
649
  * are interpolated into CDN URLs and the cache path.
630
650
  *
631
651
  * `defaultResolveFrom` (typically the declaring devframe's `importMetaUrl`)
@@ -6,16 +6,16 @@
6
6
  *
7
7
  * Resolution order at serve time:
8
8
  *
9
- * 1. The package installed locally (resolved from {@link resolveFrom})
10
- * — the zero-network / air-gap path. Version skew warns; a major
9
+ * 1. The package installed locally (resolved from {@link resolveFrom}),
10
+ * the zero-network / air-gap path. Version skew warns; a major
11
11
  * version mismatch throws.
12
12
  * 2. The per-file cache under
13
13
  * `<storageDir project>/.remote-assets/<package>@<version>/`.
14
- * 3. The CDN {@link provider} — each requested file streams through to
14
+ * 3. The CDN {@link provider}: each requested file streams through to
15
15
  * the browser while being written into the cache.
16
16
  *
17
17
  * Anywhere a static mount accepts a dist directory (`clientAssets`,
18
- * `hostStatic`, `mountStatic`) it also accepts this object — see
18
+ * `hostStatic`, `mountStatic`) it also accepts this object; see
19
19
  * {@link StaticAssetsSource}.
20
20
  */
21
21
  interface RemoteAssets {
@@ -39,7 +39,7 @@ interface RemoteAssets {
39
39
  * `import.meta.url` of the declaring module. When set, a locally
40
40
  * installed copy of {@link package} is resolved from this module's own
41
41
  * dependency graph first (works under pnpm's strict layout) and served
42
- * with zero network. Omitting it skips the installed-package step —
42
+ * with zero network. Omitting it skips the installed-package step;
43
43
  * cache + CDN still work.
44
44
  */
45
45
  resolveFrom?: string | null;
@@ -54,7 +54,7 @@ interface RemoteAssets {
54
54
  offline?: boolean;
55
55
  }
56
56
  /**
57
- * Built-in CDN providers (`'jsdelivr'` — default, `'unpkg'`) or a custom
57
+ * Built-in CDN providers (`'jsdelivr'`, the default, or `'unpkg'`) or a custom
58
58
  * provider for corp mirrors.
59
59
  */
60
60
  type RemoteAssetsProvider = 'jsdelivr' | 'unpkg' | RemoteAssetsProviderCustom;
@@ -97,7 +97,7 @@ interface RemoteAssetsErrorMessage {
97
97
  reason: string;
98
98
  }
99
99
  /**
100
- * A resolved, servable handle over a {@link RemoteAssets} declaration —
100
+ * A resolved, servable handle over a {@link RemoteAssets} declaration,
101
101
  * produced by `resolveStaticAssetsSource()` (`devframe/utils/remote-assets`)
102
102
  * and consumed by the static-serving engine (`devframe/utils/serve-static`).
103
103
  */
@@ -1,4 +1,4 @@
1
- import { t as DEVFRAME_EVENTS } from "./events-4daw0uK9.mjs";
1
+ import { t as DEVFRAME_EVENTS } from "./events-BV4Dj59a.mjs";
2
2
  //#region src/node/auth/revoke.ts
3
3
  /**
4
4
  * Flip `isTrusted` to false on any live WS clients connected with `token`
@@ -1,14 +1,5 @@
1
- import { h as RpcDumpStore, l as RpcDumpClientOptions, m as RpcDumpRecordError, n as BirpcReturn, o as RpcDefinitionsToFunctions, u as RpcDumpCollectionOptions, v as RpcFunctionDefinitionAny } from "../types-CMdPYhOx.mjs";
1
+ import { h as RpcDumpStore, l as RpcDumpClientOptions, m as RpcDumpRecordError, n as BirpcReturn, o as RpcDefinitionsToFunctions, u as RpcDumpCollectionOptions, v as RpcFunctionDefinitionAny } from "../types-Dq4i156u.mjs";
2
2
  //#region src/rpc/dump/collect.d.ts
3
- /**
4
- * Collects pre-computed dumps by executing functions with their defined input combinations.
5
- * Static functions without dump config automatically get `{ inputs: [[]] }`.
6
- *
7
- * @example
8
- * ```ts
9
- * const store = await dumpFunctions([greet], context, { concurrency: 10 })
10
- * ```
11
- */
12
3
  declare function dumpFunctions<T extends readonly RpcFunctionDefinitionAny[]>(definitions: T, context?: any, options?: RpcDumpCollectionOptions): Promise<RpcDumpStore<RpcDefinitionsToFunctions<T>>>;
13
4
  /**
14
5
  * Creates a client that serves pre-computed results from a dump store.
@@ -64,7 +55,7 @@ type StaticRpcDumpManifest = Record<string, StaticRpcDumpManifestValue>;
64
55
  interface StaticRpcDumpFile {
65
56
  /** Whether this file was written via `JSON.stringify` or `structured-clone-es.stringify`. */
66
57
  serialization: StaticRpcDumpSerialization;
67
- /** Function name the file belongs to — used to scope `DF0019` errors during write. */
58
+ /** Function name the file belongs to, used to scope `DF0019` errors during write. */
68
59
  fnName: string;
69
60
  /** Payload to encode. */
70
61
  data: unknown;
@@ -75,4 +66,20 @@ interface StaticRpcDumpCollection {
75
66
  }
76
67
  declare function collectStaticRpcDump(definitions: Iterable<RpcFunctionDefinitionAny>, context: any): Promise<StaticRpcDumpCollection>;
77
68
  //#endregion
78
- export { StaticRpcDumpCollection, StaticRpcDumpFile, StaticRpcDumpManifest, StaticRpcDumpManifestQueryEntry, StaticRpcDumpManifestStaticEntry, StaticRpcDumpManifestValue, StaticRpcDumpSerialization, collectStaticRpcDump, createClientFromDump, dumpFunctions, getDefinitionsWithDumps, reviveDumpError, serializeDumpError };
69
+ //#region src/rpc/dump/write.d.ts
70
+ interface WriteStaticRpcDumpOptions {
71
+ /**
72
+ * Pretty-print RPC dump JSON files. Defaults to `false` so payload
73
+ * shards (which can be multiple MB for graph-heavy tools) ship
74
+ * minified. Set `true` when you need to diff / read the dumps by hand.
75
+ */
76
+ pretty?: boolean;
77
+ }
78
+ /**
79
+ * Write a collected static RPC dump to disk: every sharded record file plus
80
+ * the `__rpc-dump/index.json` manifest, under `outDir`. Shared by the build
81
+ * adapter (`createBuild`) and `@devframes/hub`'s `buildHub`.
82
+ */
83
+ declare function writeStaticRpcDump(dump: StaticRpcDumpCollection, outDir: string, options?: WriteStaticRpcDumpOptions): Promise<void>;
84
+ //#endregion
85
+ export { StaticRpcDumpCollection, StaticRpcDumpFile, StaticRpcDumpManifest, StaticRpcDumpManifestQueryEntry, StaticRpcDumpManifestStaticEntry, StaticRpcDumpManifestValue, StaticRpcDumpSerialization, WriteStaticRpcDumpOptions, collectStaticRpcDump, createClientFromDump, dumpFunctions, getDefinitionsWithDumps, reviveDumpError, serializeDumpError, writeStaticRpcDump };
package/dist/rpc/dump.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as reviveDumpError, i as getDefinitionsWithDumps, n as createClientFromDump, o as serializeDumpError, r as dumpFunctions, t as collectStaticRpcDump } from "../static-DV_qUSRS.mjs";
2
- export { collectStaticRpcDump, createClientFromDump, dumpFunctions, getDefinitionsWithDumps, reviveDumpError, serializeDumpError };
1
+ import { a as getDefinitionsWithDumps, i as dumpFunctions, n as collectStaticRpcDump, o as reviveDumpError, r as createClientFromDump, s as serializeDumpError, t as writeStaticRpcDump } from "../write-BuLCrn9h.mjs";
2
+ export { collectStaticRpcDump, createClientFromDump, dumpFunctions, getDefinitionsWithDumps, reviveDumpError, serializeDumpError, writeStaticRpcDump };
@@ -1,3 +1,3 @@
1
- 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-BzyopqxV.mjs";
2
- import { C as RpcFunctionType, E as Thenable, S as RpcFunctionSetupResult, T as RpcReturnSchema, _ as RpcFunctionDefinition, a as RpcDefinitionsFilter, b as RpcFunctionDefinitionBase, c as RpcDump, d as RpcDumpDefinition, f as RpcDumpGetter, g as RpcFunctionAgentOptions, h as RpcDumpStore, i as RpcArgsSchema, l as RpcDumpClientOptions, m as RpcDumpRecordError, n as BirpcReturn, o as RpcDefinitionsToFunctions, p as RpcDumpRecord, r as EntriesToObject, s as RpcDefinitionsToFunctionsWithNamespace, t as BirpcFn, u as RpcDumpCollectionOptions, v as RpcFunctionDefinitionAny, w as RpcFunctionsCollector, x as RpcFunctionDefinitionToFunction, y as RpcFunctionDefinitionAnyWithContext } from "../types-CMdPYhOx.mjs";
1
+ 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-pIVt92jP.mjs";
2
+ import { C as RpcFunctionType, E as Thenable, S as RpcFunctionSetupResult, T as RpcReturnSchema, _ as RpcFunctionDefinition, a as RpcDefinitionsFilter, b as RpcFunctionDefinitionBase, c as RpcDump, d as RpcDumpDefinition, f as RpcDumpGetter, g as RpcFunctionAgentOptions, h as RpcDumpStore, i as RpcArgsSchema, l as RpcDumpClientOptions, m as RpcDumpRecordError, n as BirpcReturn, o as RpcDefinitionsToFunctions, p as RpcDumpRecord, r as EntriesToObject, s as RpcDefinitionsToFunctionsWithNamespace, t as BirpcFn, u as RpcDumpCollectionOptions, v as RpcFunctionDefinitionAny, w as RpcFunctionsCollector, x as RpcFunctionDefinitionToFunction, y as RpcFunctionDefinitionAnyWithContext } from "../types-Dq4i156u.mjs";
3
3
  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, RpcFunctionSetupResult, RpcFunctionType, RpcFunctionsCollector, RpcFunctionsCollectorBase, RpcReturnSchema, STRUCTURED_CLONE_PREFIX, Thenable, createDefineWrapperWithContext, defineRpcFunction, getRpcHandler, getRpcResolvedSetupResult, strictJsonStringify, validateDefinition, validateDefinitions, validateRpcArgs, validateRpcReturn };
@@ -1,7 +1,6 @@
1
- import { a as validateRpcArgs, i as getRpcResolvedSetupResult, n as validateDefinitions, o as validateRpcReturn, r as getRpcHandler, s as hash, t as validateDefinition } from "../validation-YrZH6atx.mjs";
2
- import { t as diagnostics } from "../diagnostics-CD8nlgll.mjs";
1
+ import { a as validateRpcArgs, i as getRpcResolvedSetupResult, n as validateDefinitions, o as validateRpcReturn, r as getRpcHandler, s as hash, t as validateDefinition } from "../validation-CfV1s0SF.mjs";
2
+ import { n as strictJsonStringify, r as diagnostics, t as STRUCTURED_CLONE_PREFIX } from "../serialization-DFg5sUt6.mjs";
3
3
  import { n as defineRpcFunction, t as createDefineWrapperWithContext } from "../define-BLWPsH6y.mjs";
4
- import { n as strictJsonStringify, t as STRUCTURED_CLONE_PREFIX } from "../serialization-BGzEwAdr.mjs";
5
4
  //#region src/rpc/cache.ts
6
5
  /**
7
6
  * @experimental API is expected to change.
@@ -1,2 +1,2 @@
1
- import { n as createSseRpcChannel, t as SseRpcChannelOptions } from "../../sse-client-DwX021ST.mjs";
1
+ import { n as createSseRpcChannel, t as SseRpcChannelOptions } from "../../sse-client-BQ4jS3eO.mjs";
2
2
  export { SseRpcChannelOptions, createSseRpcChannel };
@@ -1,10 +1,33 @@
1
1
  import { DEVFRAME_AUTH_TOKEN_QUERY_PARAM, DEVFRAME_SSE_SESSION_HEADER } from "../../constants.mjs";
2
- import { t as createRpcWireCodec } from "../../wire-codec-0K-o5MYW.mjs";
2
+ import { t as createRpcWireCodec } from "../../wire-codec-BHGt0sSs.mjs";
3
3
  //#region src/rpc/transports/sse-client.ts
4
4
  function NOOP() {}
5
+ /** Split the next complete SSE frame (up to a blank line) off the buffer. */
6
+ function takeFrame(buffer) {
7
+ const boundary = buffer.search(/\n\n|\r\n\r\n/);
8
+ if (boundary < 0) return void 0;
9
+ return {
10
+ frame: buffer.slice(0, boundary),
11
+ rest: buffer.slice(boundary + (buffer[boundary] === "\r" ? 4 : 2))
12
+ };
13
+ }
14
+ /** Parse one SSE frame's lines into its event name and data lines. */
15
+ function parseFrame(frame) {
16
+ let event = "message";
17
+ const data = [];
18
+ for (const rawLine of frame.split(/\r?\n/)) {
19
+ if (rawLine.startsWith(":")) continue;
20
+ if (rawLine.startsWith("event:")) event = rawLine.slice(6).trimStart();
21
+ else if (rawLine.startsWith("data:")) data.push(rawLine.slice(5).replace(/^ /, ""));
22
+ }
23
+ return {
24
+ event,
25
+ data
26
+ };
27
+ }
5
28
  /**
6
29
  * Build a birpc `ChannelOptions` object backed by an SSE stream (server →
7
- * client) and HTTP `POST` (client → server) — the WebSocket-free counterpart
30
+ * client) and HTTP `POST` (client → server): the WebSocket-free counterpart
8
31
  * to `createWsRpcChannel`, wire-compatible with `attachSseRpcTransport`.
9
32
  *
10
33
  * The stream is consumed via `fetch` streaming (not `EventSource`), so it
@@ -12,7 +35,7 @@ function NOOP() {}
12
35
  * (`event: session`) carries the session id; every `POST` echoes it in the
13
36
  * `x-birpc-session` header. A response to a client-initiated request comes
14
37
  * back in the `POST`'s own body and is re-injected into the channel; a
15
- * dropped stream terminates the channel — there is no reconnect, matching
38
+ * dropped stream terminates the channel; there is no reconnect, matching
16
39
  * the WS channel's closed-is-done semantics.
17
40
  */
18
41
  function createSseRpcChannel(options) {
@@ -63,17 +86,10 @@ function createSseRpcChannel(options) {
63
86
  if (done) break;
64
87
  buffer += decoder.decode(value, { stream: true });
65
88
  for (;;) {
66
- const boundary = buffer.search(/\n\n|\r\n\r\n/);
67
- if (boundary < 0) break;
68
- const frame = buffer.slice(0, boundary);
69
- buffer = buffer.slice(boundary + (buffer[boundary] === "\r" ? 4 : 2));
70
- let event = "message";
71
- const data = [];
72
- for (const rawLine of frame.split(/\r?\n/)) {
73
- if (rawLine.startsWith(":")) continue;
74
- if (rawLine.startsWith("event:")) event = rawLine.slice(6).trimStart();
75
- else if (rawLine.startsWith("data:")) data.push(rawLine.slice(5).replace(/^ /, ""));
76
- }
89
+ const taken = takeFrame(buffer);
90
+ if (!taken) break;
91
+ buffer = taken.rest;
92
+ const { event, data } = parseFrame(taken.frame);
77
93
  if (data.length > 0) dispatch(event, data.join("\n"));
78
94
  }
79
95
  }
@@ -1,5 +1,5 @@
1
- import { v as RpcFunctionDefinitionAny } from "../../types-CMdPYhOx.mjs";
2
- import { d as DevframeRpcConnection, n as WsOriginRegistry, u as DevframeNodeRpcSessionMeta } from "../../ws-server-VyHlanzy.mjs";
1
+ import { v as RpcFunctionDefinitionAny } from "../../types-Dq4i156u.mjs";
2
+ import { c as DevframeNodeRpcSessionMeta, l as DevframeRpcConnection, n as WsOriginRegistry } from "../../ws-server-D2nv68Hg.mjs";
3
3
  import { BirpcGroup } from "birpc";
4
4
  //#region src/rpc/transports/sse-server.d.ts
5
5
  interface SseRpcTransportOptions {
@@ -14,7 +14,7 @@ interface SseRpcTransportOptions {
14
14
  * RPC function definitions, used by the per-call wire serializer to
15
15
  * dispatch between strict-JSON and structured-clone encoding based on
16
16
  * each function's `jsonSerializable` flag. When omitted, all messages
17
- * fall back to structured-clone — same contract as the WS transport.
17
+ * fall back to structured-clone, the same contract as the WS transport.
18
18
  */
19
19
  definitions?: ReadonlyMap<string, Pick<RpcFunctionDefinitionAny, 'jsonSerializable'>>;
20
20
  onConnected?: (connection: DevframeRpcConnection, meta: DevframeNodeRpcSessionMeta) => void;
@@ -42,7 +42,7 @@ interface SseRpcTransport {
42
42
  close: () => void;
43
43
  }
44
44
  /**
45
- * Attach an SSE + HTTP POST transport to an existing RPC group — the
45
+ * Attach an SSE + HTTP POST transport to an existing RPC group: the
46
46
  * WebSocket-free counterpart to `attachWsRpcTransport`, for hosts and
47
47
  * proxies where the upgrade isn't available. Speaks the same birpc wire
48
48
  * protocol (one channel per session, per-method `jsonSerializable`
@@ -1,15 +1,17 @@
1
1
  import { DEVFRAME_SSE_SESSION_HEADER } from "../../constants.mjs";
2
- import { n as peekRpcWireFrame, t as createRpcWireCodec } from "../../wire-codec-0K-o5MYW.mjs";
3
- import { i as isAllowedOrigin, o as createRpcSessionMeta } from "../../ws-server-Y_AumUQH.mjs";
2
+ import { n as peekRpcWireFrame, t as createRpcWireCodec } from "../../wire-codec-BHGt0sSs.mjs";
3
+ import { t as isAllowedOrigin } from "../../origin-DZit9g29.mjs";
4
+ import { t as createRpcSessionMeta } from "../../session-DPfj6zQG.mjs";
4
5
  //#region src/rpc/transports/sse-server.ts
5
6
  const SSE_STREAM_HEADERS = {
6
7
  "content-type": "text/event-stream",
7
8
  "cache-control": "no-cache, no-transform",
9
+ /** Tell buffering reverse proxies (nginx) to pass frames through as-is. */
8
10
  "x-accel-buffering": "no"
9
11
  };
10
12
  function NOOP() {}
11
13
  /**
12
- * Attach an SSE + HTTP POST transport to an existing RPC group — the
14
+ * Attach an SSE + HTTP POST transport to an existing RPC group: the
13
15
  * WebSocket-free counterpart to `attachWsRpcTransport`, for hosts and
14
16
  * proxies where the upgrade isn't available. Speaks the same birpc wire
15
17
  * protocol (one channel per session, per-method `jsonSerializable`
@@ -33,7 +35,7 @@ function attachSseRpcTransport(rpcGroup, options = {}) {
33
35
  return allowedOrigins && !Array.isArray(allowedOrigins) ? allowedOrigins.isAllowed(origin) : isAllowedOrigin(origin, allowedOrigins ?? []);
34
36
  }
35
37
  /**
36
- * CORS headers for a browser on another (allowed) origin — the side-car /
38
+ * CORS headers for a browser on another (allowed) origin: the side-car /
37
39
  * registered-viewer case. Same-origin requests carry no `Origin` (or their
38
40
  * own), where these headers are inert.
39
41
  */
@@ -65,8 +67,6 @@ function attachSseRpcTransport(rpcGroup, options = {}) {
65
67
  const session = {
66
68
  id,
67
69
  meta,
68
- connection: void 0,
69
- channel: void 0,
70
70
  parked: /* @__PURE__ */ new Map(),
71
71
  closed: false,
72
72
  close: () => {
@@ -80,7 +80,7 @@ function attachSseRpcTransport(rpcGroup, options = {}) {
80
80
  controller?.close();
81
81
  } catch {}
82
82
  rpcGroup.updateChannels((channels) => {
83
- const index = channels.indexOf(session.channel);
83
+ const index = session.channel ? channels.indexOf(session.channel) : -1;
84
84
  if (index >= 0) channels.splice(index, 1);
85
85
  });
86
86
  onDisconnected(session.connection, meta);
@@ -1,5 +1,5 @@
1
- import { n as WsOriginRegistry } from "../../ws-server-VyHlanzy.mjs";
2
- import { t as ContextRpcServer } from "../../rpc-core-B3W3z9ff.mjs";
1
+ import { n as WsOriginRegistry } from "../../ws-server-D2nv68Hg.mjs";
2
+ import { t as ContextRpcServer } from "../../rpc-core-DsyDViQy.mjs";
3
3
  //#region src/rpc/transports/ws-bun.d.ts
4
4
  interface AttachBunWsTransportOptions {
5
5
  /** Same contract as `WsRpcTransportOptions.allowedOrigins`. */
@@ -7,7 +7,7 @@ interface AttachBunWsTransportOptions {
7
7
  }
8
8
  /**
9
9
  * Structural view of the Bun `Bun.serve({ websocket })` handler object the
10
- * crossws Bun adapter produces — typed loosely so devframe carries no
10
+ * crossws Bun adapter produces, typed loosely so devframe carries no
11
11
  * dependency on Bun's own types.
12
12
  */
13
13
  interface BunWsTierWebSocket {
@@ -17,14 +17,14 @@ interface BunWsTierWebSocket {
17
17
  drain?: (ws: unknown) => unknown;
18
18
  }
19
19
  interface BunWsTier {
20
- /** Complete a WS upgrade request — `Bun.serve`'s server as 2nd argument. */
20
+ /** Complete a WS upgrade request; `Bun.serve`'s server as 2nd argument. */
21
21
  handleUpgrade: (request: Request, server: unknown) => Promise<Response | undefined>;
22
22
  /** The handlers to spread into `Bun.serve({ websocket })`. */
23
23
  websocket: BunWsTierWebSocket;
24
24
  close: () => Promise<void>;
25
25
  }
26
26
  /**
27
- * The Bun fetch-upgrade WebSocket tier for `initDevframe` / `initHub` — the
27
+ * The Bun fetch-upgrade WebSocket tier for `initDevframe` / `initHub`: the
28
28
  * same RPC peer wiring as `attachWsRpcTransport`, driven by crossws's Bun
29
29
  * adapter so upgrades complete through `handler(request, server)` on the
30
30
  * app's own origin, with no side-car server. Load it dynamically so the Bun
@@ -1,7 +1,8 @@
1
- import { i as isAllowedOrigin, r as createWsRpcPeerHooks } from "../../ws-server-Y_AumUQH.mjs";
1
+ import { t as isAllowedOrigin } from "../../origin-DZit9g29.mjs";
2
+ import { createWsRpcPeerHooks } from "./ws-server.mjs";
2
3
  //#region src/rpc/transports/ws-bun.ts
3
4
  /**
4
- * The Bun fetch-upgrade WebSocket tier for `initDevframe` / `initHub` — the
5
+ * The Bun fetch-upgrade WebSocket tier for `initDevframe` / `initHub`: the
5
6
  * same RPC peer wiring as `attachWsRpcTransport`, driven by crossws's Bun
6
7
  * adapter so upgrades complete through `handler(request, server)` on the
7
8
  * app's own origin, with no side-car server. Load it dynamically so the Bun
@@ -15,6 +16,11 @@ async function attachBunWsTransport(core, options = {}) {
15
16
  onConnected: core.onConnected,
16
17
  onDisconnected: core.onDisconnected
17
18
  }),
19
+ /**
20
+ * The same origin policy `routeUpgrades` applies for the Node
21
+ * transport, enforced at the upgrade hook since Bun upgrades arrive
22
+ * as fetch requests rather than `upgrade` socket events.
23
+ */
18
24
  upgrade(request) {
19
25
  const origin = request.headers.get("origin") ?? void 0;
20
26
  const allowed = allowedOrigins && !Array.isArray(allowedOrigins) ? allowedOrigins.isAllowed(origin) : isAllowedOrigin(origin, allowedOrigins || []);
@@ -1,2 +1,2 @@
1
- import { n as createWsRpcChannel, t as WsRpcChannelOptions } from "../../ws-client-7_lZi-B9.mjs";
1
+ import { n as createWsRpcChannel, t as WsRpcChannelOptions } from "../../ws-client-Xpxt0oPA.mjs";
2
2
  export { WsRpcChannelOptions, createWsRpcChannel };
@@ -1,5 +1,5 @@
1
1
  import { DEVFRAME_AUTH_TOKEN_QUERY_PARAM } from "../../constants.mjs";
2
- import { t as createRpcWireCodec } from "../../wire-codec-0K-o5MYW.mjs";
2
+ import { t as createRpcWireCodec } from "../../wire-codec-BHGt0sSs.mjs";
3
3
  //#region src/rpc/transports/ws-client.ts
4
4
  function NOOP() {}
5
5
  const EMPTY_DEFS = /* @__PURE__ */ new Map();
@@ -7,7 +7,7 @@ const EMPTY_DEFS = /* @__PURE__ */ new Map();
7
7
  * Build a birpc `ChannelOptions` object backed by a browser `WebSocket`.
8
8
  * Pass the result straight to `createRpcClient`'s `channel` option.
9
9
  *
10
- * Also returns `close()`, closing the underlying socket — mirroring the server transport's
10
+ * Also returns `close()`, closing the underlying socket, mirroring the server transport's
11
11
  * existing `WsRpcTransport.close()`. `birpc`'s own `ChannelOptions` has no teardown of its own.
12
12
  */
13
13
  function createWsRpcChannel(options) {
@@ -1,5 +1,5 @@
1
- import { n as WsOriginRegistry } from "../../ws-server-VyHlanzy.mjs";
2
- import { t as ContextRpcServer } from "../../rpc-core-B3W3z9ff.mjs";
1
+ import { n as WsOriginRegistry } from "../../ws-server-D2nv68Hg.mjs";
2
+ import { t as ContextRpcServer } from "../../rpc-core-DsyDViQy.mjs";
3
3
  //#region src/rpc/transports/ws-deno.d.ts
4
4
  interface AttachDenoWsTransportOptions {
5
5
  /** Same contract as `WsRpcTransportOptions.allowedOrigins`. */
@@ -7,7 +7,7 @@ interface AttachDenoWsTransportOptions {
7
7
  }
8
8
  interface DenoWsTier {
9
9
  /**
10
- * Complete a WS upgrade request — `Deno.serve`'s handler info as the 2nd
10
+ * Complete a WS upgrade request; `Deno.serve`'s handler info as the 2nd
11
11
  * argument. Unlike Bun, Deno's adapter attaches the socket to the returned
12
12
  * `Response` itself, so there is no `websocket` handler object to register.
13
13
  */
@@ -15,7 +15,7 @@ interface DenoWsTier {
15
15
  close: () => Promise<void>;
16
16
  }
17
17
  /**
18
- * The Deno fetch-upgrade WebSocket tier for `initDevframe` / `initHub` — the
18
+ * The Deno fetch-upgrade WebSocket tier for `initDevframe` / `initHub`: the
19
19
  * same RPC peer wiring as `attachWsRpcTransport`, driven by crossws's Deno
20
20
  * adapter so upgrades complete through `handleUpgrade(request, info)` on the
21
21
  * app's own origin, with no side-car server. Load it dynamically so the Deno
@@ -1,7 +1,8 @@
1
- import { i as isAllowedOrigin, r as createWsRpcPeerHooks } from "../../ws-server-Y_AumUQH.mjs";
1
+ import { t as isAllowedOrigin } from "../../origin-DZit9g29.mjs";
2
+ import { createWsRpcPeerHooks } from "./ws-server.mjs";
2
3
  //#region src/rpc/transports/ws-deno.ts
3
4
  /**
4
- * The Deno fetch-upgrade WebSocket tier for `initDevframe` / `initHub` — the
5
+ * The Deno fetch-upgrade WebSocket tier for `initDevframe` / `initHub`: the
5
6
  * same RPC peer wiring as `attachWsRpcTransport`, driven by crossws's Deno
6
7
  * adapter so upgrades complete through `handleUpgrade(request, info)` on the
7
8
  * app's own origin, with no side-car server. Load it dynamically so the Deno
@@ -15,6 +16,11 @@ async function attachDenoWsTransport(core, options = {}) {
15
16
  onConnected: core.onConnected,
16
17
  onDisconnected: core.onDisconnected
17
18
  }),
19
+ /**
20
+ * The same origin policy `routeUpgrades` applies for the Node
21
+ * transport, enforced at the upgrade hook since Deno upgrades arrive
22
+ * as fetch requests rather than `upgrade` socket events.
23
+ */
18
24
  upgrade(request) {
19
25
  const origin = request.headers.get("origin") ?? void 0;
20
26
  const allowed = allowedOrigins && !Array.isArray(allowedOrigins) ? allowedOrigins.isAllowed(origin) : isAllowedOrigin(origin, allowedOrigins || []);
@@ -1,2 +1,3 @@
1
- import { a as attachWsRpcTransport, c as isAllowedOrigin, d as DevframeRpcConnection, f as DevframeRpcConnectionRequest, i as WsRpcTransportOptions, l as isLoopbackHostname, n as WsOriginRegistry, o as createWsOriginRegistry, p as DevframeRpcTransportKind, r as WsRpcTransport, s as createWsRpcPeerHooks, t as CreateWsOriginRegistryOptions, u as DevframeNodeRpcSessionMeta } from "../../ws-server-VyHlanzy.mjs";
1
+ import { a as attachWsRpcTransport, c as DevframeNodeRpcSessionMeta, d as DevframeRpcTransportKind, i as WsRpcTransportOptions, l as DevframeRpcConnection, n as WsOriginRegistry, o as createWsOriginRegistry, r as WsRpcTransport, s as createWsRpcPeerHooks, t as CreateWsOriginRegistryOptions, u as DevframeRpcConnectionRequest } from "../../ws-server-D2nv68Hg.mjs";
2
+ import { n as isLoopbackHostname, t as isAllowedOrigin } from "../../origin-DGDH8BI9.mjs";
2
3
  export { CreateWsOriginRegistryOptions, type DevframeNodeRpcSessionMeta, type DevframeRpcConnection, type DevframeRpcConnectionRequest, type DevframeRpcTransportKind, WsOriginRegistry, WsRpcTransport, WsRpcTransportOptions, attachWsRpcTransport, createWsOriginRegistry, createWsRpcPeerHooks, isAllowedOrigin, isLoopbackHostname };