heliumts 0.9.7 → 0.10.1

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 (79) hide show
  1. package/README.md +37 -12
  2. package/dist/bin/helium.js +15 -10
  3. package/dist/bin/helium.js.map +1 -1
  4. package/dist/client/Router.d.ts.map +1 -1
  5. package/dist/client/Router.js +2 -4
  6. package/dist/client/Router.js.map +1 -1
  7. package/dist/client/callMethod.d.ts +2 -7
  8. package/dist/client/callMethod.d.ts.map +1 -1
  9. package/dist/client/callMethod.js +4 -5
  10. package/dist/client/callMethod.js.map +1 -1
  11. package/dist/client/index.d.ts +3 -3
  12. package/dist/client/index.d.ts.map +1 -1
  13. package/dist/client/index.js +1 -1
  14. package/dist/client/index.js.map +1 -1
  15. package/dist/client/rpcClient.d.ts +7 -41
  16. package/dist/client/rpcClient.d.ts.map +1 -1
  17. package/dist/client/rpcClient.js +118 -752
  18. package/dist/client/rpcClient.js.map +1 -1
  19. package/dist/client/rpcStreaming.d.ts +10 -0
  20. package/dist/client/rpcStreaming.d.ts.map +1 -0
  21. package/dist/client/rpcStreaming.js +125 -0
  22. package/dist/client/rpcStreaming.js.map +1 -0
  23. package/dist/client/useStreaming.d.ts +26 -0
  24. package/dist/client/useStreaming.d.ts.map +1 -0
  25. package/dist/client/useStreaming.js +126 -0
  26. package/dist/client/useStreaming.js.map +1 -0
  27. package/dist/runtime/protocol.d.ts +14 -0
  28. package/dist/runtime/protocol.d.ts.map +1 -1
  29. package/dist/runtime/protocol.js +3 -1
  30. package/dist/runtime/protocol.js.map +1 -1
  31. package/dist/server/config.d.ts +16 -101
  32. package/dist/server/config.d.ts.map +1 -1
  33. package/dist/server/config.js +5 -27
  34. package/dist/server/config.js.map +1 -1
  35. package/dist/server/context.d.ts +8 -6
  36. package/dist/server/context.d.ts.map +1 -1
  37. package/dist/server/context.js.map +1 -1
  38. package/dist/server/defineWorker.d.ts +1 -1
  39. package/dist/server/defineWorker.d.ts.map +1 -1
  40. package/dist/server/defineWorker.js +2 -1
  41. package/dist/server/defineWorker.js.map +1 -1
  42. package/dist/server/devServer.d.ts +1 -1
  43. package/dist/server/devServer.d.ts.map +1 -1
  44. package/dist/server/devServer.js +13 -235
  45. package/dist/server/devServer.js.map +1 -1
  46. package/dist/server/httpRouter.d.ts.map +1 -1
  47. package/dist/server/httpRouter.js +5 -2
  48. package/dist/server/httpRouter.js.map +1 -1
  49. package/dist/server/httpRpc.d.ts +10 -0
  50. package/dist/server/httpRpc.d.ts.map +1 -0
  51. package/dist/server/httpRpc.js +186 -0
  52. package/dist/server/httpRpc.js.map +1 -0
  53. package/dist/server/prodServer.d.ts +3 -1
  54. package/dist/server/prodServer.d.ts.map +1 -1
  55. package/dist/server/prodServer.js +36 -214
  56. package/dist/server/prodServer.js.map +1 -1
  57. package/dist/server/rateLimiter.d.ts +6 -36
  58. package/dist/server/rateLimiter.d.ts.map +1 -1
  59. package/dist/server/rateLimiter.js +18 -125
  60. package/dist/server/rateLimiter.js.map +1 -1
  61. package/dist/server/requestSignal.d.ts +10 -0
  62. package/dist/server/requestSignal.d.ts.map +1 -0
  63. package/dist/server/requestSignal.js +79 -0
  64. package/dist/server/requestSignal.js.map +1 -0
  65. package/dist/server/rpcDecoder.d.ts +4 -0
  66. package/dist/server/rpcDecoder.d.ts.map +1 -0
  67. package/dist/server/rpcDecoder.js +151 -0
  68. package/dist/server/rpcDecoder.js.map +1 -0
  69. package/dist/server/rpcRegistry.d.ts +10 -22
  70. package/dist/server/rpcRegistry.d.ts.map +1 -1
  71. package/dist/server/rpcRegistry.js +181 -274
  72. package/dist/server/rpcRegistry.js.map +1 -1
  73. package/dist/vite/heliumPlugin.d.ts.map +1 -1
  74. package/dist/vite/heliumPlugin.js +73 -43
  75. package/dist/vite/heliumPlugin.js.map +1 -1
  76. package/dist/vite/ssg.d.ts.map +1 -1
  77. package/dist/vite/ssg.js +16 -1
  78. package/dist/vite/ssg.js.map +1 -1
  79. package/package.json +2 -4
@@ -3,9 +3,10 @@ export type { AppShellProps, LinkProps, RouterNavigationOptions } from "./Router
3
3
  export { AppRouter, Link, Redirect, RouterContext, useRouter } from "./Router.js";
4
4
  export type { LayoutProps } from "./routerManifest.js";
5
5
  export type { PageTransitionProps } from "./transitions.js";
6
- export { callMethod, type CallMethodOptions } from "./callMethod.js";
6
+ export { callMethod } from "./callMethod.js";
7
7
  export * from "./useCall.js";
8
8
  export * from "./useFetch.js";
9
+ export * from "./useStreaming.js";
9
10
  export { RpcError } from "./RpcError.js";
10
11
  /**
11
12
  * Returns `true` when the current code is executing during server-side rendering.
@@ -13,7 +14,6 @@ export { RpcError } from "./RpcError.js";
13
14
  * while still rendering providers and structural content for SSR.
14
15
  */
15
16
  export declare function isSSR(): boolean;
16
- export type { RpcResult, RpcTransport } from "./rpcClient.js";
17
- export { getRpcTransport, isAutoHttpOnMobileEnabled, preconnect } from "./rpcClient.js";
17
+ export type { RpcResult } from "./rpcClient.js";
18
18
  export * from "./types.js";
19
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAK7E,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClF,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAG5D,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACrE,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAG9B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;GAIG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAE/B;AAGD,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGxF,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAK7E,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClF,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAG5D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;GAIG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAE/B;AAED,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,cAAc,YAAY,CAAC"}
@@ -6,6 +6,7 @@ export { AppRouter, Link, Redirect, RouterContext, useRouter } from "./Router.js
6
6
  export { callMethod } from "./callMethod.js";
7
7
  export * from "./useCall.js";
8
8
  export * from "./useFetch.js";
9
+ export * from "./useStreaming.js";
9
10
  // RPC error type
10
11
  export { RpcError } from "./RpcError.js";
11
12
  /**
@@ -16,7 +17,6 @@ export { RpcError } from "./RpcError.js";
16
17
  export function isSSR() {
17
18
  return typeof window === "undefined";
18
19
  }
19
- export { getRpcTransport, isAutoHttpOnMobileEnabled, preconnect } from "./rpcClient.js";
20
20
  // Type definitions
21
21
  export * from "./types.js";
22
22
  // Internal - rpcClient and cache are used by hooks, not exposed to users
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE7E,0BAA0B,EAAE,CAAC;AAI7B,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAOlF,4CAA4C;AAC5C,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AACrE,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAE9B,iBAAiB;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;GAIG;AACH,MAAM,UAAU,KAAK;IACjB,OAAO,OAAO,MAAM,KAAK,WAAW,CAAC;AACzC,CAAC;AAID,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAExF,mBAAmB;AACnB,cAAc,YAAY,CAAC;AAE3B,yEAAyE","sourcesContent":["import { installStaleClientRecovery } from \"./staleRecovery.js\";\n\nexport { getPublicEnv, getPublicEnvValue, isDevEnvironment } from \"./env.js\";\n\ninstallStaleClientRecovery();\n\n// Router components and hooks\nexport type { AppShellProps, LinkProps, RouterNavigationOptions } from \"./Router.js\";\nexport { AppRouter, Link, Redirect, RouterContext, useRouter } from \"./Router.js\";\nexport type { LayoutProps } from \"./routerManifest.js\";\n\n// React 18+ page transitions (separate module for better tree-shaking)\n// Import from \"heliumts/client/transitions\" to ensure they're only bundled when used\nexport type { PageTransitionProps } from \"./transitions.js\";\n\n// RPC hooks for data fetching and mutations\nexport { callMethod, type CallMethodOptions } from \"./callMethod.js\";\nexport * from \"./useCall.js\";\nexport * from \"./useFetch.js\";\n\n// RPC error type\nexport { RpcError } from \"./RpcError.js\";\n\n/**\n * Returns `true` when the current code is executing during server-side rendering.\n * Use this in layouts or components to skip browser-only logic (e.g. auth guards)\n * while still rendering providers and structural content for SSR.\n */\nexport function isSSR(): boolean {\n return typeof window === \"undefined\";\n}\n\n// RPC transport info (configured via helium.config.js)\nexport type { RpcResult, RpcTransport } from \"./rpcClient.js\";\nexport { getRpcTransport, isAutoHttpOnMobileEnabled, preconnect } from \"./rpcClient.js\";\n\n// Type definitions\nexport * from \"./types.js\";\n\n// Internal - rpcClient and cache are used by hooks, not exposed to users\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE7E,0BAA0B,EAAE,CAAC;AAI7B,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAOlF,4CAA4C;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAElC,iBAAiB;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;GAIG;AACH,MAAM,UAAU,KAAK;IACjB,OAAO,OAAO,MAAM,KAAK,WAAW,CAAC;AACzC,CAAC;AAID,mBAAmB;AACnB,cAAc,YAAY,CAAC;AAE3B,yEAAyE","sourcesContent":["import { installStaleClientRecovery } from \"./staleRecovery.js\";\n\nexport { getPublicEnv, getPublicEnvValue, isDevEnvironment } from \"./env.js\";\n\ninstallStaleClientRecovery();\n\n// Router components and hooks\nexport type { AppShellProps, LinkProps, RouterNavigationOptions } from \"./Router.js\";\nexport { AppRouter, Link, Redirect, RouterContext, useRouter } from \"./Router.js\";\nexport type { LayoutProps } from \"./routerManifest.js\";\n\n// React 18+ page transitions (separate module for better tree-shaking)\n// Import from \"heliumts/client/transitions\" to ensure they're only bundled when used\nexport type { PageTransitionProps } from \"./transitions.js\";\n\n// RPC hooks for data fetching and mutations\nexport { callMethod } from \"./callMethod.js\";\nexport * from \"./useCall.js\";\nexport * from \"./useFetch.js\";\nexport * from \"./useStreaming.js\";\n\n// RPC error type\nexport { RpcError } from \"./RpcError.js\";\n\n/**\n * Returns `true` when the current code is executing during server-side rendering.\n * Use this in layouts or components to skip browser-only logic (e.g. auth guards)\n * while still rendering providers and structural content for SSR.\n */\nexport function isSSR(): boolean {\n return typeof window === \"undefined\";\n}\n\nexport type { RpcResult } from \"./rpcClient.js\";\n\n// Type definitions\nexport * from \"./types.js\";\n\n// Internal - rpcClient and cache are used by hooks, not exposed to users\n"]}
@@ -1,46 +1,12 @@
1
- import type { RpcStats } from "../runtime/protocol.js";
1
+ import type { RpcRequest, RpcStats } from "../runtime/protocol.js";
2
2
  export type RpcResult<T> = {
3
3
  data: T;
4
4
  stats: RpcStats;
5
- /** The transport that actually delivered this response, including automatic fallback. */
6
- transport: "http" | "websocket";
7
5
  };
8
- export type RpcCallOptions = {
9
- forceHttp?: boolean;
10
- /** Explicit selection disables automatic transport switching. */
11
- transport?: "http" | "websocket";
12
- };
13
- /**
14
- * Transport mode for RPC calls.
15
- * - "http": Uses HTTP POST requests, with connection reuse provided by the browser
16
- * - "websocket": Uses a persistent WebSocket connection
17
- * - "auto": Automatically selects based on connection type
18
- */
19
- export type RpcTransport = "http" | "websocket" | "auto";
20
- /**
21
- * Get the configured RPC transport mode (from helium.config.js).
22
- */
23
- export declare function getRpcTransport(): RpcTransport;
24
- /**
25
- * Check if auto HTTP on mobile is enabled (from helium.config.js).
26
- */
27
- export declare function isAutoHttpOnMobileEnabled(): boolean;
28
- export declare function isMobileRpcDevice(): boolean;
29
- /**
30
- * Make an RPC call using the appropriate transport.
31
- * Automatically selects HTTP or WebSocket based on network conditions and configuration.
32
- *
33
- * Includes automatic retry logic: if a call fails due to a connection error
34
- * (e.g. stale WebSocket after mobile browser was backgrounded), the client
35
- * forces a fresh connection and retries with bounded exponential backoff.
36
- */
37
- export declare function rpcCall<TResult = unknown, TArgs = unknown>(methodId: string, args?: TArgs): Promise<RpcResult<TResult>>;
38
- export declare function rpcCallWithOptions<TResult = unknown, TArgs = unknown>(methodId: string, args: TArgs | undefined, options: RpcCallOptions): Promise<RpcResult<TResult>>;
39
- /**
40
- * Pre-establishes the WebSocket connection.
41
- * Call this early (e.g., on page load) to avoid connection latency on first RPC call.
42
- * This is especially beneficial on high-latency networks like mobile LTE.
43
- * Note: Only effective when using WebSocket transport (not HTTP transport).
44
- */
45
- export declare function preconnect(): void;
6
+ export declare function createRpcRequest<TArgs>(method: string, args?: TArgs): RpcRequest;
7
+ /** Shared HTTP request authentication for unary and streaming calls. */
8
+ export declare function postRpc(endpoint: "/__helium__/rpc" | "/__helium__/stream", request: RpcRequest | RpcRequest[], signal: AbortSignal): Promise<Response>;
9
+ export declare function isRpcStats(value: unknown): value is RpcStats;
10
+ /** Call an RPC method over HTTP; simultaneous calls share capped batch envelopes. */
11
+ export declare function rpcCall<TResult = unknown, TArgs = unknown>(method: string, args?: TArgs): Promise<RpcResult<TResult>>;
46
12
  //# sourceMappingURL=rpcClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rpcClient.d.ts","sourceRoot":"","sources":["../../src/client/rpcClient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA2B,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGhF,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IACvB,IAAI,EAAE,C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