@zap-js/client 0.0.9 → 0.1.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.
@@ -2,7 +2,7 @@ import { execSync } from 'child_process';
2
2
  import { join, resolve } from 'path';
3
3
  import { existsSync, mkdirSync, copyFileSync, readdirSync, statSync, rmSync, writeFileSync } from 'fs';
4
4
  import { cliLogger } from '../utils/logger.js';
5
- import { resolveBinary } from '../utils/binary-resolver.js';
5
+ import { resolveBinary, getPlatformIdentifier } from '../utils/binary-resolver.js';
6
6
  /**
7
7
  * Build for production
8
8
  */
@@ -61,7 +61,37 @@ export async function buildCommand(options) {
61
61
  }
62
62
  }
63
63
  async function buildRust(outputDir, options) {
64
- cliLogger.spinner('rust', 'Building Rust backend (release mode)...');
64
+ const projectDir = process.cwd();
65
+ // STEP 1: Try to use pre-built binary from platform package
66
+ const prebuiltBinary = resolveBinary('zap', projectDir);
67
+ if (prebuiltBinary && existsSync(prebuiltBinary)) {
68
+ cliLogger.spinner('rust', 'Using pre-built binary...');
69
+ const platformId = getPlatformIdentifier();
70
+ try {
71
+ // Copy pre-built binary to output directory
72
+ const destBinary = join(outputDir, 'bin', 'zap');
73
+ copyFileSync(prebuiltBinary, destBinary);
74
+ execSync(`chmod +x "${destBinary}"`, { stdio: 'pipe' });
75
+ cliLogger.succeedSpinner('rust', `Using pre-built binary for ${platformId}`);
76
+ return;
77
+ }
78
+ catch (error) {
79
+ cliLogger.failSpinner('rust', 'Failed to copy pre-built binary');
80
+ throw error;
81
+ }
82
+ }
83
+ // STEP 2: No pre-built binary found - check if we can build from source
84
+ const cargoTomlPath = join(projectDir, 'Cargo.toml');
85
+ if (!existsSync(cargoTomlPath)) {
86
+ cliLogger.failSpinner('rust', 'No binary available');
87
+ throw new Error('Cannot build: No pre-built binary found and no Cargo.toml to build from source.\n' +
88
+ '\n' +
89
+ 'Solutions:\n' +
90
+ `1. Install platform package: npm install @zap-js/${getPlatformIdentifier()}\n` +
91
+ '2. Or build from source by cloning the ZapJS repository');
92
+ }
93
+ // STEP 3: Build from source with cargo
94
+ cliLogger.spinner('rust', 'Building Rust backend from source (release mode)...');
65
95
  const args = ['build', '--release', '--bin', 'zap'];
66
96
  if (options.target) {
67
97
  args.push('--target', options.target);
@@ -123,7 +153,7 @@ async function buildRust(outputDir, options) {
123
153
  const destBinary = join(outputDir, 'bin', 'zap');
124
154
  copyFileSync(srcBinary, destBinary);
125
155
  execSync(`chmod +x "${destBinary}"`, { stdio: 'pipe' });
126
- cliLogger.succeedSpinner('rust', 'Rust backend built (release + LTO)');
156
+ cliLogger.succeedSpinner('rust', 'Rust backend built from source (release + LTO)');
127
157
  }
128
158
  catch (error) {
129
159
  cliLogger.failSpinner('rust', 'Rust build failed');
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Browser-safe exports for @zap-js/client
3
+ *
4
+ * This entry point contains NO Node.js imports and is safe to use in:
5
+ * - Vite builds
6
+ * - Webpack builds
7
+ * - Browser environments
8
+ * - React/Vue/Svelte applications
9
+ *
10
+ * For server-side functionality, use @zap-js/client/node instead.
11
+ */
12
+ export { RouterProvider, useRouter, useParams, usePathname, useSearchParams, useRouteMatch, useIsPending, Link, NavLink, Outlet, Redirect, type Router, type RouteDefinition, type RouteMatch, type RouterState, type NavigateOptions, type LinkProps, } from './router.js';
13
+ export { ErrorBoundary, DefaultErrorComponent, RouteErrorContext, createRouteError, ZapError, type ZapRouteError, type ErrorComponentProps, type ErrorComponent, } from './error-boundary.js';
14
+ export { useRouteError, useIsErrorState, useErrorState, } from './hooks.js';
15
+ export { getCsrfToken, useCsrfToken, createCsrfFetch, CsrfTokenInput, CsrfForm, addCsrfToFormData, getCsrfHeaders, type CsrfConfig, type CsrfTokenInputProps, type CsrfFormProps, } from './csrf.js';
16
+ export { composeMiddleware, requireAuth, requireRole, routeLogger, preloadData, type MiddlewareContext, type MiddlewareResult, type MiddlewareFunction, type RouteMiddleware, } from './middleware.js';
17
+ export * from './streaming-utils.js';
18
+ export * from './websockets-utils.js';
19
+ export type { Handler, ZapRequest, ZapHandlerResponse, RouteConfig, HttpMethod, MiddlewareConfig, FileRouteConfig, StreamChunk, StreamingHandler, AnyHandler, StreamStartMessage, StreamChunkMessage, StreamEndMessage, StreamMessage, WsConnection, WsHandler, WsConnectMessage, WsMessageMessage, WsCloseMessage, WsSendMessage, WsMessage, } from './types.js';
20
+ export { isInvokeHandlerMessage, isHandlerResponseMessage, isErrorMessage, isHealthCheckMessage, isHealthCheckResponseMessage, isRpcResponseMessage, isRpcErrorMessage, isAsyncIterable, } from './types.js';
21
+ /**
22
+ * Router namespace - all routing functionality
23
+ * Usage: import { router } from '@zap-js/client/browser'
24
+ */
25
+ import { RouterProvider, useRouter as useRouterFn, useParams as useParamsFn, usePathname as usePathnameFn, useSearchParams as useSearchParamsFn, useRouteMatch as useRouteMatchFn, useIsPending as useIsPendingFn, Link, NavLink, Outlet, Redirect } from './router.js';
26
+ export declare const router: {
27
+ readonly RouterProvider: typeof RouterProvider;
28
+ readonly useRouter: typeof useRouterFn;
29
+ readonly useParams: typeof useParamsFn;
30
+ readonly usePathname: typeof usePathnameFn;
31
+ readonly useSearchParams: typeof useSearchParamsFn;
32
+ readonly useRouteMatch: typeof useRouteMatchFn;
33
+ readonly useIsPending: typeof useIsPendingFn;
34
+ readonly Link: typeof Link;
35
+ readonly NavLink: typeof NavLink;
36
+ readonly Outlet: typeof Outlet;
37
+ readonly Redirect: typeof Redirect;
38
+ };
39
+ /**
40
+ * Errors namespace - error handling and boundaries
41
+ * Usage: import { errors } from '@zap-js/client/browser'
42
+ */
43
+ import { ErrorBoundary, DefaultErrorComponent, createRouteError, ZapError } from './error-boundary.js';
44
+ import { useRouteError, useIsErrorState, useErrorState } from './hooks.js';
45
+ export declare const errors: {
46
+ readonly ErrorBoundary: typeof ErrorBoundary;
47
+ readonly DefaultErrorComponent: typeof DefaultErrorComponent;
48
+ readonly createRouteError: typeof createRouteError;
49
+ readonly ZapError: typeof ZapError;
50
+ readonly useRouteError: typeof useRouteError;
51
+ readonly useIsErrorState: typeof useIsErrorState;
52
+ readonly useErrorState: typeof useErrorState;
53
+ };
54
+ /**
55
+ * Middleware namespace - route middleware utilities
56
+ * Usage: import { middleware } from '@zap-js/client/browser'
57
+ */
58
+ import { composeMiddleware, requireAuth, requireRole, routeLogger, preloadData } from './middleware.js';
59
+ export declare const middleware: {
60
+ readonly compose: typeof composeMiddleware;
61
+ readonly requireAuth: typeof requireAuth;
62
+ readonly requireRole: typeof requireRole;
63
+ readonly logger: typeof routeLogger;
64
+ readonly preloadData: typeof preloadData;
65
+ };
66
+ /**
67
+ * Types namespace - type definitions and guards
68
+ * Usage: import { types } from '@zap-js/client/browser'
69
+ */
70
+ import * as TypeGuards from './types.js';
71
+ export declare const types: {
72
+ readonly isInvokeHandlerMessage: typeof TypeGuards.isInvokeHandlerMessage;
73
+ readonly isHandlerResponseMessage: typeof TypeGuards.isHandlerResponseMessage;
74
+ readonly isErrorMessage: typeof TypeGuards.isErrorMessage;
75
+ readonly isHealthCheckMessage: typeof TypeGuards.isHealthCheckMessage;
76
+ readonly isHealthCheckResponseMessage: typeof TypeGuards.isHealthCheckResponseMessage;
77
+ readonly isRpcResponseMessage: typeof TypeGuards.isRpcResponseMessage;
78
+ readonly isRpcErrorMessage: typeof TypeGuards.isRpcErrorMessage;
79
+ readonly isAsyncIterable: typeof TypeGuards.isAsyncIterable;
80
+ };
81
+ /**
82
+ * WebSockets namespace - WebSocket utilities and helpers
83
+ * Usage: import { websockets } from '@zap-js/client/browser'
84
+ */
85
+ import * as WebSocketUtils from './websockets-utils.js';
86
+ export declare const websockets: {
87
+ readonly isWsMessage: typeof WebSocketUtils.isWsMessage;
88
+ readonly broadcast: typeof WebSocketUtils.broadcast;
89
+ readonly broadcastExcept: typeof WebSocketUtils.broadcastExcept;
90
+ readonly sendJson: typeof WebSocketUtils.sendJson;
91
+ readonly parseMessage: typeof WebSocketUtils.parseMessage;
92
+ readonly createErrorMessage: typeof WebSocketUtils.createErrorMessage;
93
+ readonly createSuccessMessage: typeof WebSocketUtils.createSuccessMessage;
94
+ };
95
+ /**
96
+ * Streaming namespace - Streaming response utilities
97
+ * Usage: import { streaming } from '@zap-js/client/browser'
98
+ */
99
+ import * as StreamingUtils from './streaming-utils.js';
100
+ export declare const streaming: {
101
+ readonly isAsyncIterable: typeof TypeGuards.isAsyncIterable;
102
+ readonly createChunk: typeof StreamingUtils.createChunk;
103
+ readonly createStream: typeof StreamingUtils.createStream;
104
+ readonly streamJson: typeof StreamingUtils.streamJson;
105
+ readonly streamSSE: typeof StreamingUtils.streamSSE;
106
+ readonly mapStream: typeof StreamingUtils.mapStream;
107
+ readonly filterStream: typeof StreamingUtils.filterStream;
108
+ readonly batchStream: typeof StreamingUtils.batchStream;
109
+ readonly delayStream: typeof StreamingUtils.delayStream;
110
+ readonly fromReadableStream: typeof StreamingUtils.fromReadableStream;
111
+ readonly intervalStream: typeof StreamingUtils.intervalStream;
112
+ };
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Browser-safe exports for @zap-js/client
3
+ *
4
+ * This entry point contains NO Node.js imports and is safe to use in:
5
+ * - Vite builds
6
+ * - Webpack builds
7
+ * - Browser environments
8
+ * - React/Vue/Svelte applications
9
+ *
10
+ * For server-side functionality, use @zap-js/client/node instead.
11
+ */
12
+ // ============================================================================
13
+ // Router Exports (Client-side)
14
+ // ============================================================================
15
+ export {
16
+ // Provider
17
+ RouterProvider,
18
+ // Hooks
19
+ useRouter, useParams, usePathname, useSearchParams, useRouteMatch, useIsPending,
20
+ // Components
21
+ Link, NavLink, Outlet, Redirect, } from './router.js';
22
+ // ============================================================================
23
+ // Error Handling Exports
24
+ // ============================================================================
25
+ export { ErrorBoundary, DefaultErrorComponent, RouteErrorContext, createRouteError, ZapError, } from './error-boundary.js';
26
+ export { useRouteError, useIsErrorState, useErrorState, } from './hooks.js';
27
+ // ============================================================================
28
+ // CSRF Protection Exports
29
+ // ============================================================================
30
+ export { getCsrfToken, useCsrfToken, createCsrfFetch, CsrfTokenInput, CsrfForm, addCsrfToFormData, getCsrfHeaders, } from './csrf.js';
31
+ // ============================================================================
32
+ // Middleware Exports (Pure TypeScript, no Node.js deps)
33
+ // ============================================================================
34
+ export { composeMiddleware, requireAuth, requireRole, routeLogger, preloadData, } from './middleware.js';
35
+ // ============================================================================
36
+ // Utility Exports (Browser-safe)
37
+ // ============================================================================
38
+ export * from './streaming-utils.js';
39
+ export * from './websockets-utils.js';
40
+ // Re-export type guards (pure functions, no Node.js deps)
41
+ export { isInvokeHandlerMessage, isHandlerResponseMessage, isErrorMessage, isHealthCheckMessage, isHealthCheckResponseMessage, isRpcResponseMessage, isRpcErrorMessage, isAsyncIterable, } from './types.js';
42
+ // ============================================================================
43
+ // Namespace Exports for Convenience
44
+ // ============================================================================
45
+ /**
46
+ * Router namespace - all routing functionality
47
+ * Usage: import { router } from '@zap-js/client/browser'
48
+ */
49
+ import { RouterProvider, useRouter as useRouterFn, useParams as useParamsFn, usePathname as usePathnameFn, useSearchParams as useSearchParamsFn, useRouteMatch as useRouteMatchFn, useIsPending as useIsPendingFn, Link, NavLink, Outlet, Redirect, } from './router.js';
50
+ export const router = {
51
+ RouterProvider,
52
+ useRouter: useRouterFn,
53
+ useParams: useParamsFn,
54
+ usePathname: usePathnameFn,
55
+ useSearchParams: useSearchParamsFn,
56
+ useRouteMatch: useRouteMatchFn,
57
+ useIsPending: useIsPendingFn,
58
+ Link,
59
+ NavLink,
60
+ Outlet,
61
+ Redirect,
62
+ };
63
+ /**
64
+ * Errors namespace - error handling and boundaries
65
+ * Usage: import { errors } from '@zap-js/client/browser'
66
+ */
67
+ import { ErrorBoundary, DefaultErrorComponent, createRouteError, ZapError, } from './error-boundary.js';
68
+ import { useRouteError, useIsErrorState, useErrorState, } from './hooks.js';
69
+ export const errors = {
70
+ ErrorBoundary,
71
+ DefaultErrorComponent,
72
+ createRouteError,
73
+ ZapError,
74
+ useRouteError,
75
+ useIsErrorState,
76
+ useErrorState,
77
+ };
78
+ /**
79
+ * Middleware namespace - route middleware utilities
80
+ * Usage: import { middleware } from '@zap-js/client/browser'
81
+ */
82
+ import { composeMiddleware, requireAuth, requireRole, routeLogger, preloadData, } from './middleware.js';
83
+ export const middleware = {
84
+ compose: composeMiddleware,
85
+ requireAuth,
86
+ requireRole,
87
+ logger: routeLogger,
88
+ preloadData,
89
+ };
90
+ /**
91
+ * Types namespace - type definitions and guards
92
+ * Usage: import { types } from '@zap-js/client/browser'
93
+ */
94
+ import * as TypeGuards from './types.js';
95
+ export const types = {
96
+ isInvokeHandlerMessage: TypeGuards.isInvokeHandlerMessage,
97
+ isHandlerResponseMessage: TypeGuards.isHandlerResponseMessage,
98
+ isErrorMessage: TypeGuards.isErrorMessage,
99
+ isHealthCheckMessage: TypeGuards.isHealthCheckMessage,
100
+ isHealthCheckResponseMessage: TypeGuards.isHealthCheckResponseMessage,
101
+ isRpcResponseMessage: TypeGuards.isRpcResponseMessage,
102
+ isRpcErrorMessage: TypeGuards.isRpcErrorMessage,
103
+ isAsyncIterable: TypeGuards.isAsyncIterable,
104
+ };
105
+ /**
106
+ * WebSockets namespace - WebSocket utilities and helpers
107
+ * Usage: import { websockets } from '@zap-js/client/browser'
108
+ */
109
+ import * as WebSocketUtils from './websockets-utils.js';
110
+ export const websockets = {
111
+ isWsMessage: WebSocketUtils.isWsMessage,
112
+ broadcast: WebSocketUtils.broadcast,
113
+ broadcastExcept: WebSocketUtils.broadcastExcept,
114
+ sendJson: WebSocketUtils.sendJson,
115
+ parseMessage: WebSocketUtils.parseMessage,
116
+ createErrorMessage: WebSocketUtils.createErrorMessage,
117
+ createSuccessMessage: WebSocketUtils.createSuccessMessage,
118
+ };
119
+ /**
120
+ * Streaming namespace - Streaming response utilities
121
+ * Usage: import { streaming } from '@zap-js/client/browser'
122
+ */
123
+ import * as StreamingUtils from './streaming-utils.js';
124
+ export const streaming = {
125
+ isAsyncIterable: StreamingUtils.isAsyncIterable,
126
+ createChunk: StreamingUtils.createChunk,
127
+ createStream: StreamingUtils.createStream,
128
+ streamJson: StreamingUtils.streamJson,
129
+ streamSSE: StreamingUtils.streamSSE,
130
+ mapStream: StreamingUtils.mapStream,
131
+ filterStream: StreamingUtils.filterStream,
132
+ batchStream: StreamingUtils.batchStream,
133
+ delayStream: StreamingUtils.delayStream,
134
+ fromReadableStream: StreamingUtils.fromReadableStream,
135
+ intervalStream: StreamingUtils.intervalStream,
136
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Client exports for @zap-js/client
3
+ *
4
+ * Semantic alias for browser.ts - provides all browser-safe functionality.
5
+ * Use this when you want to be explicit about client-side code.
6
+ *
7
+ * Usage:
8
+ * ```ts
9
+ * import { router } from '@zap-js/client/client';
10
+ * ```
11
+ */
12
+ export * from './browser.js';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Client exports for @zap-js/client
3
+ *
4
+ * Semantic alias for browser.ts - provides all browser-safe functionality.
5
+ * Use this when you want to be explicit about client-side code.
6
+ *
7
+ * Usage:
8
+ * ```ts
9
+ * import { router } from '@zap-js/client/client';
10
+ * ```
11
+ */
12
+ export * from './browser.js';
@@ -3,6 +3,13 @@ import { tmpdir } from "os";
3
3
  import { existsSync, readFileSync } from "fs";
4
4
  import { ProcessManager } from "./process-manager.js";
5
5
  import { IpcServer } from "./ipc-client.js";
6
+ // DEPRECATION WARNING - Show in development only
7
+ if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') {
8
+ console.warn('\x1b[33m[DEPRECATION]\x1b[0m Importing from @zap-js/client is deprecated.\n' +
9
+ 'Use explicit imports:\n' +
10
+ ' - Server/Node.js: import { Zap } from "@zap-js/client/node"\n' +
11
+ ' - Browser/Client: import { router } from "@zap-js/client/browser"');
12
+ }
6
13
  // Re-export type guards
7
14
  export { isInvokeHandlerMessage, isHandlerResponseMessage, isErrorMessage, isHealthCheckMessage, isHealthCheckResponseMessage, isRpcResponseMessage, isRpcErrorMessage, isAsyncIterable, } from "./types.js";
8
15
  // Re-export internal modules for dev-server usage
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Node.js exports for @zap-js/client
3
+ *
4
+ * This entry point includes server-side functionality that requires Node.js:
5
+ * - Zap class (server instance)
6
+ * - ProcessManager (manages Rust binary)
7
+ * - IpcServer/IpcClient (inter-process communication)
8
+ * - Logger (server-side logging)
9
+ * - RPC client utilities
10
+ *
11
+ * For browser/client-side functionality, use @zap-js/client/browser instead.
12
+ */
13
+ export { Zap } from './index.js';
14
+ export { ProcessManager } from './process-manager.js';
15
+ export { IpcServer, IpcClient } from './ipc-client.js';
16
+ export { rpcCall } from './rpc-client.js';
17
+ export { Logger, logger, type LogContext, type LogLevel, type ChildLogger } from './logger.js';
18
+ export type { Handler, ZapRequest, ZapHandlerResponse, ZapConfig, RouteConfig, MiddlewareConfig, StaticFileConfig, StaticFileOptions, FileRouteConfig, ZapOptions, IpcMessage, InvokeHandlerMessage, HandlerResponseMessage, ErrorMessage, HealthCheckMessage, HealthCheckResponseMessage, HttpMethod, InternalHandlerFunction, RpcMessage, RpcCallMessage, RpcResponseMessage, RpcErrorMessage, PendingRequest, SecurityConfig, SecurityHeadersConfig, HstsConfig, RateLimitConfig, CorsConfig, ObservabilityConfig, StreamChunk, StreamingHandler, AnyHandler, StreamStartMessage, StreamChunkMessage, StreamEndMessage, StreamMessage, WsConnection, WsHandler, WsConnectMessage, WsMessageMessage, WsCloseMessage, WsSendMessage, WsMessage, } from './types.js';
19
+ export { isInvokeHandlerMessage, isHandlerResponseMessage, isErrorMessage, isHealthCheckMessage, isHealthCheckResponseMessage, isRpcResponseMessage, isRpcErrorMessage, isAsyncIterable, } from './types.js';
20
+ export { composeMiddleware, requireAuth, requireRole, routeLogger, preloadData, type MiddlewareContext, type MiddlewareResult, type MiddlewareFunction, type RouteMiddleware, } from './middleware.js';
21
+ export { RouterProvider, useRouter, useParams, usePathname, useSearchParams, useRouteMatch, useIsPending, Link, NavLink, Outlet, Redirect, type Router, type RouteDefinition, type RouteMatch, type RouterState, type NavigateOptions, type LinkProps, ErrorBoundary, DefaultErrorComponent, RouteErrorContext, createRouteError, ZapError, type ZapRouteError, type ErrorComponentProps, type ErrorComponent, useRouteError, useIsErrorState, useErrorState, getCsrfToken, useCsrfToken, createCsrfFetch, CsrfTokenInput, CsrfForm, addCsrfToFormData, getCsrfHeaders, type CsrfConfig, type CsrfTokenInputProps, type CsrfFormProps, router, errors, middleware, types, websockets, streaming, } from './index.js';
22
+ export { default } from './index.js';
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Node.js exports for @zap-js/client
3
+ *
4
+ * This entry point includes server-side functionality that requires Node.js:
5
+ * - Zap class (server instance)
6
+ * - ProcessManager (manages Rust binary)
7
+ * - IpcServer/IpcClient (inter-process communication)
8
+ * - Logger (server-side logging)
9
+ * - RPC client utilities
10
+ *
11
+ * For browser/client-side functionality, use @zap-js/client/browser instead.
12
+ */
13
+ // ============================================================================
14
+ // Server-Side Core Exports
15
+ // ============================================================================
16
+ export { Zap } from './index.js';
17
+ export { ProcessManager } from './process-manager.js';
18
+ export { IpcServer, IpcClient } from './ipc-client.js';
19
+ export { rpcCall } from './rpc-client.js';
20
+ export { Logger, logger } from './logger.js';
21
+ // Re-export type guards
22
+ export { isInvokeHandlerMessage, isHandlerResponseMessage, isErrorMessage, isHealthCheckMessage, isHealthCheckResponseMessage, isRpcResponseMessage, isRpcErrorMessage, isAsyncIterable, } from './types.js';
23
+ // ============================================================================
24
+ // Middleware Exports
25
+ // ============================================================================
26
+ export { composeMiddleware, requireAuth, requireRole, routeLogger, preloadData, } from './middleware.js';
27
+ // ============================================================================
28
+ // Re-export Browser-Safe Functionality
29
+ // ============================================================================
30
+ // Note: Server code might also need router, errors, etc. for SSR
31
+ export {
32
+ // Router
33
+ RouterProvider, useRouter, useParams, usePathname, useSearchParams, useRouteMatch, useIsPending, Link, NavLink, Outlet, Redirect,
34
+ // Error handling
35
+ ErrorBoundary, DefaultErrorComponent, RouteErrorContext, createRouteError, ZapError, useRouteError, useIsErrorState, useErrorState,
36
+ // CSRF
37
+ getCsrfToken, useCsrfToken, createCsrfFetch, CsrfTokenInput, CsrfForm, addCsrfToFormData, getCsrfHeaders,
38
+ // Utilities
39
+ router, errors, middleware, types, websockets, streaming, } from './index.js';
40
+ // ============================================================================
41
+ // Default Export
42
+ // ============================================================================
43
+ export { default } from './index.js';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Server exports for @zap-js/client
3
+ *
4
+ * Semantic alias for node.ts - provides all server-side functionality.
5
+ * Use this when you want to be explicit about server-side code.
6
+ *
7
+ * Usage:
8
+ * ```ts
9
+ * import { Zap } from '@zap-js/client/server';
10
+ * ```
11
+ */
12
+ export * from './node.js';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Server exports for @zap-js/client
3
+ *
4
+ * Semantic alias for node.ts - provides all server-side functionality.
5
+ * Use this when you want to be explicit about server-side code.
6
+ *
7
+ * Usage:
8
+ * ```ts
9
+ * import { Zap } from '@zap-js/client/server';
10
+ * ```
11
+ */
12
+ export * from './node.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zap-js/client",
3
- "version": "0.0.9",
3
+ "version": "0.1.0",
4
4
  "description": "High-performance fullstack React framework - Client package",
5
5
  "homepage": "https://github.com/saint0x/zapjs",
6
6
  "repository": {
@@ -16,7 +16,24 @@
16
16
  "exports": {
17
17
  ".": {
18
18
  "types": "./index.d.ts",
19
- "default": "./dist/runtime/index.js"
19
+ "node": "./dist/runtime/node.js",
20
+ "default": "./dist/runtime/browser.js"
21
+ },
22
+ "./node": {
23
+ "types": "./index.d.ts",
24
+ "default": "./dist/runtime/node.js"
25
+ },
26
+ "./server": {
27
+ "types": "./index.d.ts",
28
+ "default": "./dist/runtime/server.js"
29
+ },
30
+ "./browser": {
31
+ "types": "./index.d.ts",
32
+ "default": "./dist/runtime/browser.js"
33
+ },
34
+ "./client": {
35
+ "types": "./index.d.ts",
36
+ "default": "./dist/runtime/client.js"
20
37
  },
21
38
  "./router": "./dist/router/index.js"
22
39
  },
@@ -54,9 +71,9 @@
54
71
  "ws": "^8.16.0"
55
72
  },
56
73
  "optionalDependencies": {
57
- "@zap-js/darwin-arm64": "0.0.9",
58
- "@zap-js/darwin-x64": "0.0.9",
59
- "@zap-js/linux-x64": "0.0.9"
74
+ "@zap-js/darwin-arm64": "0.1.0",
75
+ "@zap-js/darwin-x64": "0.1.0",
76
+ "@zap-js/linux-x64": "0.1.0"
60
77
  },
61
78
  "peerDependencies": {
62
79
  "react": "^18.0.0",