@replanejs/sdk 0.8.13 → 0.8.19
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/README.md +12 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -482,6 +482,18 @@ unsubscribeMaxUsers();
|
|
|
482
482
|
replane.close();
|
|
483
483
|
```
|
|
484
484
|
|
|
485
|
+
## Framework SDKs
|
|
486
|
+
|
|
487
|
+
For React, Next.js, and Svelte applications, use the dedicated framework SDKs which provide hooks, context providers, and SSR support:
|
|
488
|
+
|
|
489
|
+
| Framework | Package | Description |
|
|
490
|
+
| ----------- | ------------------- | ---------------------------------------- |
|
|
491
|
+
| **React** | `@replanejs/react` | Hooks and context for React apps |
|
|
492
|
+
| **Next.js** | `@replanejs/next` | SSR/SSG support for Next.js |
|
|
493
|
+
| **Svelte** | `@replanejs/svelte` | Reactive stores for Svelte and SvelteKit |
|
|
494
|
+
|
|
495
|
+
See the [examples directory](./examples/) for runtime-specific examples (Node.js, Bun, Deno, Browser).
|
|
496
|
+
|
|
485
497
|
## Community
|
|
486
498
|
|
|
487
499
|
Have questions or want to discuss Replane? Join the conversation in [GitHub Discussions](https://github.com/orgs/replane-dev/discussions).
|
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["params: { message: string; code: string; cause?: unknown }","ms: number","averageDelay: number","signals: Array<AbortSignal | undefined | null>","input: string | URL | Request","init: RequestInit","timeoutMs: number","fetchFn: typeof fetch","response: Response","message: string","body: unknown","params: FetchSseOptions","dataLines: string[]","comment: string | null","options: StartReplicationStreamOptions","error: unknown","inactivityTimer: ReturnType<typeof setTimeout> | null","options: ReplaneFinalOptions","path: string","input: string","baseValue: T","overrides: RenderedOverride[]","context: ReplaneContext","logger: ReplaneLogger","overrideResult: EvaluationResult","condition: RenderedCondition","contextValue","value: never","message: string","expectedValue: unknown","contextValue: unknown","options: ClientCoreOptions","configs: Map<string, ConfigDto>","updatedConfigs: ConfigDto[]","configName: K","getConfigOptions: GetConfigOptions<T[K]>","callbackOrConfigName: keyof T | ((config: MapConfig<T>) => void)","callbackOrUndefined?: (config: MapConfig<T>) => void","configName: keyof T | undefined","callback: (config: MapConfig<T>) => void","client: ReplaneClient<T>","sdkOptions: ReplaneClientOptions<T>","initialData: T","options: RestoreReplaneClientOptions<T>","initialConfigs: ConfigDto[]","storage: ReplaneRemoteStorage | null","streamOptions: ReplaneFinalOptions | null","sdkOptions: ReplaneFinalOptions","storage: ReplaneStorage","missingRequiredConfigs: string[]","options: ReplaneClientOptions<T>","options: ReplaneClientOptions<T>","cacheKey: string","keepAliveMs: number","options: GetReplaneSnapshotOptions<T>","client","entry: CachedClient"],"sources":["../src/error.ts","../src/utils.ts","../src/sse.ts","../src/storage.ts","../src/hash.ts","../src/evaluation.ts","../src/version.ts","../src/client.ts","../src/snapshot.ts"],"sourcesContent":["/**\n * Error codes for ReplaneError\n */\nexport enum ReplaneErrorCode {\n NotFound = \"not_found\",\n Timeout = \"timeout\",\n NetworkError = \"network_error\",\n AuthError = \"auth_error\",\n Forbidden = \"forbidden\",\n ServerError = \"server_error\",\n ClientError = \"client_error\",\n Closed = \"closed\",\n NotInitialized = \"not_initialized\",\n Unknown = \"unknown\",\n}\n\n/**\n * Custom error class for Replane SDK errors\n */\nexport class ReplaneError extends Error {\n code: string;\n\n constructor(params: { message: string; code: string; cause?: unknown }) {\n super(params.message, { cause: params.cause });\n this.name = \"ReplaneError\";\n this.code = params.code;\n }\n}\n","/**\n * Returns a promise that resolves after the specified delay\n *\n * @param ms - Delay in milliseconds\n */\nexport async function delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Returns a promise that resolves after a delay with jitter.\n * The actual delay is the average delay ± 10% (jitter = averageDelay/5).\n *\n * @param averageDelay - The average delay in milliseconds\n */\nexport async function retryDelay(averageDelay: number): Promise<void> {\n const jitter = averageDelay / 5;\n const delayMs = averageDelay + Math.random() * jitter - jitter / 2;\n\n await delay(delayMs);\n}\n\n/**\n * Combines multiple abort signals into one.\n * When any of the input signals is aborted, the combined signal will also be aborted.\n *\n * @param signals - Array of AbortSignal instances (can contain undefined/null)\n * @returns An object containing the combined signal and a cleanup function\n */\nexport function combineAbortSignals(signals: Array<AbortSignal | undefined | null>): {\n signal: AbortSignal;\n cleanUpSignals: () => void;\n} {\n const controller = new AbortController();\n const onAbort = () => {\n controller.abort();\n cleanUpSignals();\n };\n\n const cleanUpSignals = () => {\n for (const s of signals) {\n s?.removeEventListener(\"abort\", onAbort);\n }\n };\n\n for (const s of signals) {\n s?.addEventListener(\"abort\", onAbort, { once: true });\n }\n\n if (signals.some((s) => s?.aborted)) {\n onAbort();\n }\n\n return { signal: controller.signal, cleanUpSignals };\n}\n\n/**\n * A deferred promise that can be resolved or rejected from outside.\n * Useful for coordinating async operations.\n */\nexport class Deferred<T> {\n public readonly promise: Promise<T>;\n public resolve!: (value: T) => void;\n public reject!: (error: unknown) => void;\n\n constructor() {\n this.promise = new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n}\n","import { ReplaneError, ReplaneErrorCode } from \"./error\";\nimport { combineAbortSignals } from \"./utils\";\n\nconst SSE_DATA_PREFIX = \"data:\";\n\n/**\n * Parsed SSE event\n */\nexport type SseEvent = { type: \"comment\"; comment: string } | { type: \"data\"; data: string };\n\n/**\n * Options for fetchSse\n */\nexport interface FetchSseOptions {\n fetchFn: typeof fetch;\n url: string;\n timeoutMs: number;\n body?: string;\n headers?: Record<string, string>;\n method?: string;\n signal?: AbortSignal;\n onConnect?: () => void;\n}\n\n/**\n * Fetch with timeout support\n */\nexport async function fetchWithTimeout(\n input: string | URL | Request,\n init: RequestInit,\n timeoutMs: number,\n fetchFn: typeof fetch\n): Promise<Response> {\n if (!fetchFn) {\n throw new Error(\"Global fetch is not available. Provide options.fetchFn.\");\n }\n if (!timeoutMs) return fetchFn(input, init);\n\n const timeoutController = new AbortController();\n const t = setTimeout(() => timeoutController.abort(), timeoutMs);\n // Note: We intentionally don't call cleanUpSignals() here because for streaming\n // responses (like SSE), the connection remains open after the response headers\n // are received. The abort signal needs to remain connected so that close() can\n // propagate the abort through the signal chain.\n const { signal } = combineAbortSignals([init.signal, timeoutController.signal]);\n try {\n return await fetchFn(input, {\n ...init,\n signal,\n });\n } finally {\n clearTimeout(t);\n }\n}\n\n/**\n * Ensures the response is successful, throwing ReplaneError if not\n */\nexport async function ensureSuccessfulResponse(response: Response, message: string): Promise<void> {\n if (response.status === 404) {\n throw new ReplaneError({\n message: `Not found: ${message}`,\n code: ReplaneErrorCode.NotFound,\n });\n }\n\n if (response.status === 401) {\n throw new ReplaneError({\n message: `Unauthorized access: ${message}`,\n code: ReplaneErrorCode.AuthError,\n });\n }\n\n if (response.status === 403) {\n throw new ReplaneError({\n message: `Forbidden access: ${message}`,\n code: ReplaneErrorCode.Forbidden,\n });\n }\n\n if (!response.ok) {\n let body: unknown;\n try {\n body = await response.text();\n } catch {\n body = \"<unable to read response body>\";\n }\n\n const code =\n response.status >= 500\n ? ReplaneErrorCode.ServerError\n : response.status >= 400\n ? ReplaneErrorCode.ClientError\n : ReplaneErrorCode.Unknown;\n\n throw new ReplaneError({\n message: `Fetch response isn't successful (${message}): ${response.status} ${response.statusText} - ${body}`,\n code,\n });\n }\n}\n\n/**\n * Fetches a Server-Sent Events (SSE) stream and yields parsed events.\n *\n * @param params - Options for the SSE fetch\n * @yields SseEvent objects containing either data or comment events\n */\nexport async function* fetchSse(params: FetchSseOptions): AsyncGenerator<SseEvent> {\n const abortController = new AbortController();\n const { signal, cleanUpSignals } = params.signal\n ? combineAbortSignals([params.signal, abortController.signal])\n : { signal: abortController.signal, cleanUpSignals: () => {} };\n\n try {\n const res = await fetchWithTimeout(\n params.url,\n {\n method: params.method ?? \"GET\",\n headers: { Accept: \"text/event-stream\", ...(params.headers ?? {}) },\n body: params.body,\n signal,\n },\n params.timeoutMs,\n params.fetchFn\n );\n\n await ensureSuccessfulResponse(res, `SSE ${params.url}`);\n const responseContentType = res.headers.get(\"content-type\") ?? \"\";\n\n if (!responseContentType.includes(\"text/event-stream\")) {\n throw new ReplaneError({\n message: `Expected text/event-stream, got \"${responseContentType}\"`,\n code: ReplaneErrorCode.ServerError,\n });\n }\n\n if (!res.body) {\n throw new ReplaneError({\n message: `Failed to fetch SSE ${params.url}: body is empty`,\n code: ReplaneErrorCode.Unknown,\n });\n }\n\n if (params.onConnect) {\n params.onConnect();\n }\n\n const decoded = res.body.pipeThrough(new TextDecoderStream());\n const reader = decoded.getReader();\n\n let buffer = \"\";\n\n try {\n while (true) {\n const { value, done } = await reader.read();\n if (done) break;\n buffer += value!;\n\n // Split on blank line; handle both \\n\\n and \\r\\n\\r\\n\n const frames = buffer.split(/\\r?\\n\\r?\\n/);\n buffer = frames.pop() ?? \"\";\n\n for (const frame of frames) {\n // Parse lines inside a single SSE event frame\n const dataLines: string[] = [];\n let comment: string | null = null;\n\n for (const rawLine of frame.split(/\\r?\\n/)) {\n if (!rawLine) continue;\n if (rawLine.startsWith(\":\")) {\n // comment/keepalive\n comment = rawLine.slice(1);\n continue;\n }\n\n if (rawLine.startsWith(SSE_DATA_PREFIX)) {\n // Keep leading space after \"data:\" if present per spec\n const line = rawLine.slice(SSE_DATA_PREFIX.length).replace(/^\\s/, \"\");\n dataLines.push(line);\n }\n }\n\n if (dataLines.length) {\n const data = dataLines.join(\"\\n\");\n yield { type: \"data\", data };\n } else if (comment !== null) {\n yield { type: \"comment\", comment };\n }\n }\n }\n } finally {\n try {\n await reader.cancel();\n } catch {\n // ignore error\n }\n abortController.abort();\n }\n } finally {\n cleanUpSignals();\n }\n}\n","import type { ReplicationStreamRecord, StartReplicationStreamBody } from \"./types\";\nimport type { ReplaneFinalOptions } from \"./client-types\";\nimport { fetchSse } from \"./sse\";\nimport { combineAbortSignals, retryDelay } from \"./utils\";\n\nconst SUPPORTED_REPLICATION_STREAM_RECORD_TYPES = Object.keys({\n config_change: true,\n init: true,\n} satisfies Record<ReplicationStreamRecord[\"type\"], true>);\n\n/**\n * Options for starting a replication stream\n */\nexport interface StartReplicationStreamOptions extends ReplaneFinalOptions {\n // getBody is a function to get the latest configs when we are trying\n // to reestablish the replication stream\n getBody: () => StartReplicationStreamBody;\n signal?: AbortSignal;\n onConnect?: () => void;\n onConnectionError?: (error: unknown) => void;\n onConnected?: () => void;\n}\n\n/**\n * Interface for storage implementations\n */\nexport interface ReplaneStorage {\n startReplicationStream(\n options: StartReplicationStreamOptions\n ): AsyncIterable<ReplicationStreamRecord>;\n close(): void;\n}\n\n/**\n * Remote storage implementation that connects to the Replane server\n * and streams config updates via SSE.\n */\nexport class ReplaneRemoteStorage implements ReplaneStorage {\n private closeController = new AbortController();\n\n /**\n * Start a replication stream that yields config updates.\n * This method never throws - it retries on failure with exponential backoff.\n */\n async *startReplicationStream(\n options: StartReplicationStreamOptions\n ): AsyncIterable<ReplicationStreamRecord> {\n const { signal, cleanUpSignals } = combineAbortSignals([\n this.closeController.signal,\n options.signal,\n ]);\n try {\n let failedAttempts = 0;\n while (!signal.aborted) {\n try {\n for await (const event of this.startReplicationStreamImpl({\n ...options,\n signal,\n onConnect: () => {\n failedAttempts = 0;\n },\n })) {\n yield event;\n }\n } catch (error: unknown) {\n failedAttempts++;\n const retryDelayMs = Math.min(options.retryDelayMs * 2 ** (failedAttempts - 1), 10_000);\n if (!signal.aborted) {\n options.logger.error(\n `Failed to fetch project events, retrying in ${retryDelayMs}ms...`,\n error\n );\n\n // Call the connection error callback if provided\n options.onConnectionError?.(error);\n\n await retryDelay(retryDelayMs);\n }\n }\n }\n } finally {\n cleanUpSignals();\n }\n }\n\n private async *startReplicationStreamImpl(\n options: StartReplicationStreamOptions\n ): AsyncIterable<ReplicationStreamRecord> {\n // Create an abort controller for inactivity timeout\n const inactivityAbortController = new AbortController();\n const { signal: combinedSignal, cleanUpSignals } = options.signal\n ? combineAbortSignals([options.signal, inactivityAbortController.signal])\n : { signal: inactivityAbortController.signal, cleanUpSignals: () => {} };\n\n let inactivityTimer: ReturnType<typeof setTimeout> | null = null;\n\n const resetInactivityTimer = () => {\n if (inactivityTimer) clearTimeout(inactivityTimer);\n inactivityTimer = setTimeout(() => {\n inactivityAbortController.abort();\n }, options.inactivityTimeoutMs);\n };\n\n try {\n const rawEvents = fetchSse({\n fetchFn: options.fetchFn,\n headers: {\n Authorization: this.getAuthHeader(options),\n \"Content-Type\": \"application/json\",\n \"User-Agent\": options.agent,\n },\n body: JSON.stringify(options.getBody()),\n timeoutMs: options.requestTimeoutMs,\n method: \"POST\",\n signal: combinedSignal,\n url: this.getApiEndpoint(`/sdk/v1/replication/stream`, options),\n onConnect: () => {\n resetInactivityTimer();\n options.onConnect?.();\n // Call the user's onConnected callback\n options.onConnected?.();\n },\n });\n\n for await (const sseEvent of rawEvents) {\n resetInactivityTimer();\n\n if (sseEvent.type === \"comment\") continue;\n\n const event = JSON.parse(sseEvent.data);\n if (\n typeof event === \"object\" &&\n event !== null &&\n \"type\" in event &&\n typeof event.type === \"string\" &&\n (SUPPORTED_REPLICATION_STREAM_RECORD_TYPES as unknown as string[]).includes(event.type)\n ) {\n yield event as ReplicationStreamRecord;\n }\n }\n } finally {\n if (inactivityTimer) clearTimeout(inactivityTimer);\n cleanUpSignals();\n }\n }\n\n /**\n * Close the storage and abort any active connections\n */\n close(): void {\n this.closeController.abort();\n }\n\n private getAuthHeader(options: ReplaneFinalOptions): string {\n return `Bearer ${options.sdkKey}`;\n }\n\n private getApiEndpoint(path: string, options: ReplaneFinalOptions): string {\n return `${options.baseUrl}/api${path}`;\n }\n}\n","/**\n * FNV-1a 32-bit hash function\n *\n * FNV (Fowler–Noll–Vo) is a non-cryptographic hash function known for its\n * speed and good distribution. This implementation uses the FNV-1a variant\n * which XORs before multiplying for better avalanche characteristics.\n *\n * @param input - The string to hash\n * @returns A 32-bit unsigned integer hash value\n */\nexport function fnv1a32(input: string): number {\n // Convert string to bytes (UTF-8)\n const encoder = new TextEncoder();\n const bytes = encoder.encode(input);\n\n // FNV-1a core\n let hash = 0x811c9dc5 >>> 0; // 2166136261, force uint32\n\n for (let i = 0; i < bytes.length; i++) {\n hash ^= bytes[i]; // XOR with byte\n hash = Math.imul(hash, 0x01000193) >>> 0; // * 16777619 mod 2^32\n }\n\n return hash >>> 0; // ensure unsigned 32-bit\n}\n\n/**\n * Convert FNV-1a hash to [0, 1) for bucketing.\n *\n * This is useful for percentage-based segmentation where you need\n * to deterministically assign a value to a bucket based on a string input.\n *\n * @param input - The string to hash\n * @returns A number in the range [0, 1)\n */\nexport function fnv1a32ToUnit(input: string): number {\n const h = fnv1a32(input);\n return h / 2 ** 32; // double in [0, 1)\n}\n","import type { RenderedCondition, RenderedOverride } from \"./types\";\nimport type { ReplaneContext, ReplaneLogger } from \"./client-types\";\nimport { fnv1a32ToUnit } from \"./hash\";\n\n/**\n * Result of evaluating a condition\n */\nexport type EvaluationResult = \"matched\" | \"not_matched\" | \"unknown\";\n\n/**\n * Evaluate config overrides based on context.\n * Returns the first matching override's value, or the base value if no override matches.\n *\n * @param baseValue - The default value to return if no override matches\n * @param overrides - Array of overrides to evaluate\n * @param context - The context to evaluate conditions against\n * @param logger - Logger for warnings\n * @returns The evaluated value\n */\nexport function evaluateOverrides<T>(\n baseValue: T,\n overrides: RenderedOverride[],\n context: ReplaneContext,\n logger: ReplaneLogger\n): T {\n // Find first matching override\n for (const override of overrides) {\n // All conditions must match (implicit AND)\n let overrideResult: EvaluationResult = \"matched\";\n const results = override.conditions.map((c) => evaluateCondition(c, context, logger));\n // AND: false > unknown > true\n if (results.some((r) => r === \"not_matched\")) {\n overrideResult = \"not_matched\";\n } else if (results.some((r) => r === \"unknown\")) {\n overrideResult = \"unknown\";\n }\n\n // Only use override if all conditions matched (not unknown)\n if (overrideResult === \"matched\") {\n return override.value as T;\n }\n }\n\n return baseValue;\n}\n\n/**\n * Evaluate a single condition against a context.\n *\n * @param condition - The condition to evaluate\n * @param context - The context to evaluate against\n * @param logger - Logger for warnings\n * @returns The evaluation result\n */\nexport function evaluateCondition(\n condition: RenderedCondition,\n context: ReplaneContext,\n logger: ReplaneLogger\n): EvaluationResult {\n const operator = condition.operator;\n\n // Composite conditions\n if (operator === \"and\") {\n const results = condition.conditions.map((c) => evaluateCondition(c, context, logger));\n // AND: false > unknown > true\n if (results.some((r) => r === \"not_matched\")) return \"not_matched\";\n if (results.some((r) => r === \"unknown\")) return \"unknown\";\n return \"matched\";\n }\n\n if (operator === \"or\") {\n const results = condition.conditions.map((c) => evaluateCondition(c, context, logger));\n // OR: true > unknown > false\n if (results.some((r) => r === \"matched\")) return \"matched\";\n if (results.some((r) => r === \"unknown\")) return \"unknown\";\n return \"not_matched\";\n }\n\n if (operator === \"not\") {\n const result = evaluateCondition(condition.condition, context, logger);\n if (result === \"matched\") return \"not_matched\";\n if (result === \"not_matched\") return \"matched\";\n return \"unknown\"; // NOT unknown = unknown\n }\n\n // Segmentation\n if (operator === \"segmentation\") {\n const contextValue = context[condition.property];\n if (contextValue === undefined || contextValue === null) {\n return \"unknown\";\n }\n\n // FNV-1a hash to bucket [0, 100)\n const hashInput = String(contextValue) + condition.seed;\n const unitValue = fnv1a32ToUnit(hashInput);\n return unitValue >= condition.fromPercentage / 100 && unitValue < condition.toPercentage / 100\n ? \"matched\"\n : \"not_matched\";\n }\n\n // Property-based conditions\n const property = condition.property;\n const contextValue = context[property];\n const expectedValue = condition.value;\n\n if (contextValue === undefined) {\n return \"unknown\";\n }\n\n // Type casting\n const castedValue = castToContextType(expectedValue, contextValue);\n\n switch (operator) {\n case \"equals\":\n return contextValue === castedValue ? \"matched\" : \"not_matched\";\n\n case \"in\":\n if (!Array.isArray(castedValue)) return \"unknown\";\n return castedValue.includes(contextValue) ? \"matched\" : \"not_matched\";\n\n case \"not_in\":\n if (!Array.isArray(castedValue)) return \"unknown\";\n return !castedValue.includes(contextValue) ? \"matched\" : \"not_matched\";\n\n case \"less_than\":\n if (typeof contextValue === \"number\" && typeof castedValue === \"number\") {\n return contextValue < castedValue ? \"matched\" : \"not_matched\";\n }\n if (typeof contextValue === \"string\" && typeof castedValue === \"string\") {\n return contextValue < castedValue ? \"matched\" : \"not_matched\";\n }\n return \"not_matched\";\n\n case \"less_than_or_equal\":\n if (typeof contextValue === \"number\" && typeof castedValue === \"number\") {\n return contextValue <= castedValue ? \"matched\" : \"not_matched\";\n }\n if (typeof contextValue === \"string\" && typeof castedValue === \"string\") {\n return contextValue <= castedValue ? \"matched\" : \"not_matched\";\n }\n return \"not_matched\";\n\n case \"greater_than\":\n if (typeof contextValue === \"number\" && typeof castedValue === \"number\") {\n return contextValue > castedValue ? \"matched\" : \"not_matched\";\n }\n if (typeof contextValue === \"string\" && typeof castedValue === \"string\") {\n return contextValue > castedValue ? \"matched\" : \"not_matched\";\n }\n return \"not_matched\";\n\n case \"greater_than_or_equal\":\n if (typeof contextValue === \"number\" && typeof castedValue === \"number\") {\n return contextValue >= castedValue ? \"matched\" : \"not_matched\";\n }\n if (typeof contextValue === \"string\" && typeof castedValue === \"string\") {\n return contextValue >= castedValue ? \"matched\" : \"not_matched\";\n }\n return \"not_matched\";\n\n default:\n warnNever(operator, logger, `Unexpected operator: ${operator}`);\n return \"unknown\";\n }\n}\n\n/**\n * Helper to warn about exhaustive check failures\n */\nfunction warnNever(value: never, logger: ReplaneLogger, message: string): void {\n logger.warn(message, { value });\n}\n\n/**\n * Cast expected value to match context value type.\n * This enables loose matching between different types (e.g., \"25\" matches 25).\n *\n * @param expectedValue - The value from the condition\n * @param contextValue - The value from the context\n * @returns The expected value cast to match the context value's type\n */\nexport function castToContextType(expectedValue: unknown, contextValue: unknown): unknown {\n if (typeof contextValue === \"number\") {\n if (typeof expectedValue === \"string\") {\n const num = Number(expectedValue);\n return isNaN(num) ? expectedValue : num;\n }\n return expectedValue;\n }\n\n if (typeof contextValue === \"boolean\") {\n if (typeof expectedValue === \"string\") {\n if (expectedValue === \"true\") return true;\n if (expectedValue === \"false\") return false;\n }\n if (typeof expectedValue === \"number\") {\n return expectedValue !== 0;\n }\n return expectedValue;\n }\n\n if (typeof contextValue === \"string\") {\n if (typeof expectedValue === \"number\" || typeof expectedValue === \"boolean\") {\n return String(expectedValue);\n }\n return expectedValue;\n }\n\n return expectedValue;\n}\n","// Auto-generated - do not edit manually\nexport const VERSION = \"0.8.13\";\nexport const DEFAULT_AGENT = `replane-js-sdk/${VERSION}`;\n","import type { ConfigDto } from \"./types\";\nimport type {\n ReplaneContext,\n ReplaneLogger,\n GetConfigOptions,\n MapConfig,\n ReplaneSnapshot,\n ReplaneClient,\n ReplaneClientOptions,\n RestoreReplaneClientOptions,\n ReplaneFinalOptions,\n} from \"./client-types\";\nimport type { ReplaneStorage } from \"./storage\";\nimport { ReplaneRemoteStorage } from \"./storage\";\nimport { ReplaneError, ReplaneErrorCode } from \"./error\";\nimport { evaluateOverrides } from \"./evaluation\";\nimport { Deferred } from \"./utils\";\nimport { DEFAULT_AGENT } from \"./version\";\n\n/**\n * Internal options for creating the client core\n */\ninterface ClientCoreOptions {\n initialConfigs: ConfigDto[];\n context: ReplaneContext;\n logger: ReplaneLogger;\n storage: ReplaneStorage | null;\n streamOptions: ReplaneFinalOptions | null;\n requiredConfigs: string[];\n}\n\n/**\n * Result from creating the client core\n */\ninterface ClientCoreResult<T extends object> {\n client: ReplaneClient<T>;\n configs: Map<string, ConfigDto>;\n startStreaming: () => Promise<void>;\n clientReady: Deferred<void>;\n}\n\n/**\n * Creates the core client logic shared between createReplaneClient and restoreReplaneClient\n */\nfunction createClientCore<T extends object = Record<string, unknown>>(\n options: ClientCoreOptions\n): ClientCoreResult<T> {\n const { initialConfigs, context, logger, storage, streamOptions, requiredConfigs } = options;\n\n const configs: Map<string, ConfigDto> = new Map(\n initialConfigs.map((config) => [config.name, config])\n );\n\n const clientReady = new Deferred<void>();\n const configSubscriptions = new Map<keyof T, Set<(config: MapConfig<T>) => void>>();\n const clientSubscriptions = new Set<(config: MapConfig<T>) => void>();\n\n function processConfigUpdates(updatedConfigs: ConfigDto[]) {\n for (const config of updatedConfigs) {\n configs.set(config.name, {\n name: config.name,\n overrides: config.overrides,\n value: config.value,\n });\n for (const callback of clientSubscriptions) {\n callback({ name: config.name as keyof T, value: config.value as T[keyof T] });\n }\n for (const callback of configSubscriptions.get(config.name as keyof T) ?? []) {\n callback({ name: config.name as keyof T, value: config.value as T[keyof T] });\n }\n }\n }\n\n async function startStreaming(): Promise<void> {\n if (!storage || !streamOptions) return;\n\n try {\n const replicationStream = storage.startReplicationStream({\n ...streamOptions,\n getBody: () => ({\n currentConfigs: [...configs.values()].map((config) => ({\n name: config.name,\n overrides: config.overrides,\n value: config.value,\n })),\n requiredConfigs,\n }),\n });\n\n for await (const event of replicationStream) {\n const updatedConfigs: ConfigDto[] =\n event.type === \"config_change\" ? [event.config] : event.configs;\n processConfigUpdates(updatedConfigs);\n clientReady.resolve();\n }\n } catch (error) {\n logger.error(\"Replane: error in SSE connection:\", error);\n clientReady.reject(error);\n throw error;\n }\n }\n\n function get<K extends keyof T>(\n configName: K,\n getConfigOptions: GetConfigOptions<T[K]> = {}\n ): T[K] {\n const config = configs.get(String(configName));\n\n if (config === undefined) {\n if (\"default\" in getConfigOptions) {\n return getConfigOptions.default as T[K];\n }\n throw new ReplaneError({\n message: `Config not found: ${String(configName)}`,\n code: ReplaneErrorCode.NotFound,\n });\n }\n\n try {\n return evaluateOverrides<T[K]>(\n config.value as T[K],\n config.overrides,\n { ...context, ...(getConfigOptions?.context ?? {}) },\n logger\n );\n } catch (error) {\n logger.error(`Replane: error evaluating overrides for config ${String(configName)}:`, error);\n return config.value as T[K];\n }\n }\n\n const subscribe = (\n callbackOrConfigName: keyof T | ((config: MapConfig<T>) => void),\n callbackOrUndefined?: (config: MapConfig<T>) => void\n ) => {\n let configName: keyof T | undefined = undefined;\n let callback: (config: MapConfig<T>) => void;\n if (typeof callbackOrConfigName === \"function\") {\n callback = callbackOrConfigName;\n } else {\n configName = callbackOrConfigName as keyof T;\n if (callbackOrUndefined === undefined) {\n throw new Error(\"callback is required when config name is provided\");\n }\n callback = callbackOrUndefined!;\n }\n\n // Wrap the callback to ensure that we have a unique reference\n const originalCallback = callback;\n callback = (...args: Parameters<typeof callback>) => {\n originalCallback(...args);\n };\n\n if (configName === undefined) {\n clientSubscriptions.add(callback);\n return () => {\n clientSubscriptions.delete(callback);\n };\n }\n\n if (!configSubscriptions.has(configName)) {\n configSubscriptions.set(configName, new Set());\n }\n configSubscriptions.get(configName)!.add(callback);\n return () => {\n configSubscriptions.get(configName)?.delete(callback);\n if (configSubscriptions.get(configName)?.size === 0) {\n configSubscriptions.delete(configName);\n }\n };\n };\n\n const getSnapshot = (): ReplaneSnapshot<T> => ({\n configs: [...configs.values()].map((config) => ({\n name: config.name,\n value: config.value,\n overrides: config.overrides.map((override) => ({\n name: override.name,\n conditions: override.conditions,\n value: override.value,\n })),\n })),\n context,\n });\n\n const close = () => storage?.close();\n\n const client: ReplaneClient<T> = {\n get,\n subscribe: subscribe as ReplaneClient<T>[\"subscribe\"],\n getSnapshot,\n close,\n };\n\n return { client, configs, startStreaming, clientReady };\n}\n\n/**\n * Create a Replane client bound to an SDK key.\n *\n * @example\n * ```typescript\n * const client = await createReplaneClient({\n * sdkKey: 'your-sdk-key',\n * baseUrl: 'https://app.replane.dev'\n * });\n * const value = client.get('my-config');\n * ```\n */\nexport async function createReplaneClient<T extends object = Record<string, unknown>>(\n sdkOptions: ReplaneClientOptions<T>\n): Promise<ReplaneClient<T>> {\n const storage = new ReplaneRemoteStorage();\n return await createReplaneClientInternal(toFinalOptions(sdkOptions), storage);\n}\n\n/**\n * Create a Replane client that uses in-memory storage.\n * Useful for testing or when you have static config values.\n *\n * @example\n * ```typescript\n * const client = createInMemoryReplaneClient({ 'my-config': 123 });\n * const value = client.get('my-config'); // 123\n * ```\n */\nexport function createInMemoryReplaneClient<T extends object = Record<string, unknown>>(\n initialData: T\n): ReplaneClient<T> {\n return {\n get: (configName, options) => {\n const config = initialData[configName];\n if (config === undefined) {\n if (options && \"default\" in options) {\n return options.default as T[typeof configName];\n }\n throw new ReplaneError({\n message: `Config not found: ${String(configName)}`,\n code: ReplaneErrorCode.NotFound,\n });\n }\n return config;\n },\n subscribe: () => {\n return () => {};\n },\n getSnapshot: () => ({\n configs: Object.entries(initialData).map(([name, value]) => ({\n name,\n value,\n overrides: [],\n })),\n }),\n close: () => {},\n };\n}\n\n/**\n * Restore a Replane client from a snapshot.\n * This is useful for SSR/hydration scenarios where the server has already fetched configs.\n *\n * @example\n * ```typescript\n * // On the server:\n * const serverClient = await createReplaneClient({ ... });\n * const snapshot = serverClient.getSnapshot();\n * // Pass snapshot to client via props/serialization\n *\n * // On the client:\n * const client = restoreReplaneClient({\n * snapshot,\n * connection: { sdkKey, baseUrl }\n * });\n * const value = client.get('my-config');\n * ```\n */\nexport function restoreReplaneClient<T extends object = Record<string, unknown>>(\n options: RestoreReplaneClientOptions<T>\n): ReplaneClient<T> {\n const { snapshot, connection } = options;\n const context = options.context ?? snapshot.context ?? {};\n const logger = connection?.logger ?? console;\n\n // Initialize configs from snapshot\n const initialConfigs: ConfigDto[] = snapshot.configs.map((config) => ({\n name: config.name,\n value: config.value,\n overrides: config.overrides,\n }));\n\n let storage: ReplaneRemoteStorage | null = null;\n let streamOptions: ReplaneFinalOptions | null = null;\n\n if (connection) {\n storage = new ReplaneRemoteStorage();\n streamOptions = toFinalOptions(connection);\n }\n\n const { client, startStreaming } = createClientCore<T>({\n initialConfigs,\n context,\n logger,\n storage,\n streamOptions,\n requiredConfigs: [],\n });\n\n // Start streaming in background (non-blocking) if connection is provided\n if (storage && streamOptions) {\n startStreaming().catch((error) => {\n logger.error(\"Replane: error in restored client SSE connection:\", error);\n });\n }\n\n return client;\n}\n\n/**\n * Internal function to create a Replane client with the given options and storage\n */\nasync function createReplaneClientInternal<T extends object = Record<string, unknown>>(\n sdkOptions: ReplaneFinalOptions,\n storage: ReplaneStorage\n): Promise<ReplaneClient<T>> {\n const { client, configs, startStreaming, clientReady } = createClientCore<T>({\n initialConfigs: sdkOptions.defaults,\n context: sdkOptions.context,\n logger: sdkOptions.logger,\n storage,\n streamOptions: sdkOptions,\n requiredConfigs: sdkOptions.requiredConfigs,\n });\n\n // Start streaming in background\n startStreaming().catch((error) => {\n sdkOptions.logger.error(\"Replane: error initializing client:\", error);\n });\n\n const initializationTimeoutId = setTimeout(() => {\n if (sdkOptions.defaults.length === 0) {\n // no defaults, we have nothing to work with\n client.close();\n\n clientReady.reject(\n new ReplaneError({\n message: \"Replane client initialization timed out\",\n code: ReplaneErrorCode.Timeout,\n })\n );\n\n return;\n }\n\n const missingRequiredConfigs: string[] = [];\n for (const requiredConfigName of sdkOptions.requiredConfigs) {\n if (!configs.has(requiredConfigName)) {\n missingRequiredConfigs.push(requiredConfigName);\n }\n }\n\n if (missingRequiredConfigs.length > 0) {\n client.close();\n clientReady.reject(\n new ReplaneError({\n message: `Required configs are missing: ${missingRequiredConfigs.join(\", \")}`,\n code: ReplaneErrorCode.NotFound,\n })\n );\n\n return;\n }\n\n clientReady.resolve();\n }, sdkOptions.initializationTimeoutMs);\n\n clientReady.promise.then(() => clearTimeout(initializationTimeoutId));\n\n await clientReady.promise;\n\n return client;\n}\n\n/**\n * Convert user options to final options with defaults\n */\nfunction toFinalOptions<T extends object>(options: ReplaneClientOptions<T>): ReplaneFinalOptions {\n return {\n sdkKey: options.sdkKey ?? \"\",\n baseUrl: (options.baseUrl ?? \"\").replace(/\\/+$/, \"\"),\n fetchFn:\n options.fetchFn ??\n // some browsers require binding the fetch function to window\n globalThis.fetch.bind(globalThis),\n requestTimeoutMs: options.requestTimeoutMs ?? 2000,\n initializationTimeoutMs: options.initializationTimeoutMs ?? 5000,\n inactivityTimeoutMs: options.inactivityTimeoutMs ?? 30_000,\n logger: options.logger ?? console,\n retryDelayMs: options.retryDelayMs ?? 200,\n context: {\n ...(options.context ?? {}),\n },\n requiredConfigs: Array.isArray(options.required)\n ? options.required.map((name) => String(name))\n : Object.entries(options.required ?? {})\n .filter(([_, value]) => value !== undefined)\n .map(([name]) => name),\n defaults: Object.entries(options.defaults ?? {})\n .filter(([_, value]) => value !== undefined)\n .map(([name, value]) => ({\n name,\n overrides: [],\n version: -1,\n value,\n })),\n agent: options.agent ?? DEFAULT_AGENT,\n onConnectionError: options.onConnectionError,\n onConnected: options.onConnected,\n };\n}\n","import { createReplaneClient } from \"./client\";\nimport type { ReplaneClient, ReplaneClientOptions, ReplaneSnapshot } from \"./client-types\";\n\n/**\n * Extended options for getReplaneSnapshot with caching support.\n */\nexport interface GetReplaneSnapshotOptions<T extends object> extends ReplaneClientOptions<T> {\n /**\n * Cache TTL in milliseconds. When set, the client is cached and reused\n * for instant subsequent calls within this duration.\n * @default 60_000 (1 minute)\n */\n keepAliveMs?: number;\n}\n\ninterface CachedClient {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n clientPromise: Promise<ReplaneClient<any>>;\n timeoutId: TimeoutId;\n}\n\nconst clientCache = new Map<string, CachedClient>();\n\nfunction getCacheKey<T extends object>(options: ReplaneClientOptions<T>): string {\n return `${options.baseUrl}:${options.sdkKey}`;\n}\n\ntype TimeoutId = ReturnType<typeof setTimeout>;\n\nfunction setupCleanupTimeout(cacheKey: string, keepAliveMs: number): TimeoutId {\n return setTimeout(() => {\n clientCache.delete(cacheKey);\n }, keepAliveMs);\n}\n\n/**\n * Creates a Replane client and returns a snapshot.\n * Useful for SSR/SSG scenarios where you need to fetch config once\n * and pass it to the client.\n *\n * @example\n * ```ts\n * const snapshot = await getReplaneSnapshot({\n * baseUrl: process.env.REPLANE_BASE_URL!,\n * sdkKey: process.env.REPLANE_SDK_KEY!,\n * });\n * ```\n */\nexport async function getReplaneSnapshot<T extends object>(\n options: GetReplaneSnapshotOptions<T>\n): Promise<ReplaneSnapshot<T>> {\n const { keepAliveMs = 60_000, ...clientOptions } = options;\n\n const cacheKey = getCacheKey(clientOptions);\n const cached = clientCache.get(cacheKey);\n\n // Return from cache if valid\n if (cached) {\n clearTimeout(cached.timeoutId);\n cached.timeoutId = setupCleanupTimeout(cacheKey, keepAliveMs);\n\n const client = await cached.clientPromise;\n return client.getSnapshot() as ReplaneSnapshot<T>;\n }\n\n // Create new client and cache it\n const clientPromise = createReplaneClient<T>(clientOptions);\n const entry: CachedClient = {\n clientPromise: clientPromise,\n timeoutId: setupCleanupTimeout(cacheKey, keepAliveMs),\n };\n clientCache.set(cacheKey, entry);\n\n const client = await clientPromise;\n\n return client.getSnapshot();\n}\n\n/**\n * Clears the client cache used by getReplaneSnapshot.\n * Useful for testing or when you need to force re-initialization.\n */\nexport async function clearSnapshotCache(): Promise<void> {\n const clientPromises = [...clientCache.values()].map((cached) => cached.clientPromise);\n clientCache.clear();\n for (const clientPromise of clientPromises) {\n const client = await clientPromise;\n client.close();\n }\n}\n"],"mappings":";;;;AAGA,IAAY,gEAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACD;;;;AAKD,IAAa,eAAb,cAAkC,MAAM;CACtC;CAEA,YAAYA,QAA4D;AACtE,QAAM,OAAO,SAAS,EAAE,OAAO,OAAO,MAAO,EAAC;AAC9C,OAAK,OAAO;AACZ,OAAK,OAAO,OAAO;CACpB;AACF;;;;;;;;;ACtBD,eAAsB,MAAMC,IAA2B;AACrD,QAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAG;AACxD;;;;;;;AAQD,eAAsB,WAAWC,cAAqC;CACpE,MAAM,SAAS,eAAe;CAC9B,MAAM,UAAU,eAAe,KAAK,QAAQ,GAAG,SAAS,SAAS;AAEjE,OAAM,MAAM,QAAQ;AACrB;;;;;;;;AASD,SAAgB,oBAAoBC,SAGlC;CACA,MAAM,aAAa,IAAI;CACvB,MAAM,UAAU,MAAM;AACpB,aAAW,OAAO;AAClB,kBAAgB;CACjB;CAED,MAAM,iBAAiB,MAAM;AAC3B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AAY,oBAAoB,UAAU,YAAY;EAE7D,MAAMC,WAAS,MAAM,OAAO;AAC5B,SAAO,SAAO,aAAa;CAC5B;CAGD,MAAM,gBAAgB,oBAAuB,cAAc;CAC3D,MAAMC,QAAsB;EACX;EACf,WAAW,oBAAoB,UAAU,YAAY;CACtD;AACD,aAAY,IAAI,UAAU,MAAM;CAEhC,MAAM,SAAS,MAAM;AAErB,QAAO,OAAO,aAAa;AAC5B"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["params: { message: string; code: string; cause?: unknown }","ms: number","averageDelay: number","signals: Array<AbortSignal | undefined | null>","input: string | URL | Request","init: RequestInit","timeoutMs: number","fetchFn: typeof fetch","response: Response","message: string","body: unknown","params: FetchSseOptions","dataLines: string[]","comment: string | null","options: StartReplicationStreamOptions","error: unknown","inactivityTimer: ReturnType<typeof setTimeout> | null","options: ReplaneFinalOptions","path: string","input: string","baseValue: T","overrides: RenderedOverride[]","context: ReplaneContext","logger: ReplaneLogger","overrideResult: EvaluationResult","condition: RenderedCondition","contextValue","value: never","message: string","expectedValue: unknown","contextValue: unknown","options: ClientCoreOptions","configs: Map<string, ConfigDto>","updatedConfigs: ConfigDto[]","configName: K","getConfigOptions: GetConfigOptions<T[K]>","callbackOrConfigName: keyof T | ((config: MapConfig<T>) => void)","callbackOrUndefined?: (config: MapConfig<T>) => void","configName: keyof T | undefined","callback: (config: MapConfig<T>) => void","client: ReplaneClient<T>","sdkOptions: ReplaneClientOptions<T>","initialData: T","options: RestoreReplaneClientOptions<T>","initialConfigs: ConfigDto[]","storage: ReplaneRemoteStorage | null","streamOptions: ReplaneFinalOptions | null","sdkOptions: ReplaneFinalOptions","storage: ReplaneStorage","missingRequiredConfigs: string[]","options: ReplaneClientOptions<T>","options: ReplaneClientOptions<T>","cacheKey: string","keepAliveMs: number","options: GetReplaneSnapshotOptions<T>","client","entry: CachedClient"],"sources":["../src/error.ts","../src/utils.ts","../src/sse.ts","../src/storage.ts","../src/hash.ts","../src/evaluation.ts","../src/version.ts","../src/client.ts","../src/snapshot.ts"],"sourcesContent":["/**\n * Error codes for ReplaneError\n */\nexport enum ReplaneErrorCode {\n NotFound = \"not_found\",\n Timeout = \"timeout\",\n NetworkError = \"network_error\",\n AuthError = \"auth_error\",\n Forbidden = \"forbidden\",\n ServerError = \"server_error\",\n ClientError = \"client_error\",\n Closed = \"closed\",\n NotInitialized = \"not_initialized\",\n Unknown = \"unknown\",\n}\n\n/**\n * Custom error class for Replane SDK errors\n */\nexport class ReplaneError extends Error {\n code: string;\n\n constructor(params: { message: string; code: string; cause?: unknown }) {\n super(params.message, { cause: params.cause });\n this.name = \"ReplaneError\";\n this.code = params.code;\n }\n}\n","/**\n * Returns a promise that resolves after the specified delay\n *\n * @param ms - Delay in milliseconds\n */\nexport async function delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Returns a promise that resolves after a delay with jitter.\n * The actual delay is the average delay ± 10% (jitter = averageDelay/5).\n *\n * @param averageDelay - The average delay in milliseconds\n */\nexport async function retryDelay(averageDelay: number): Promise<void> {\n const jitter = averageDelay / 5;\n const delayMs = averageDelay + Math.random() * jitter - jitter / 2;\n\n await delay(delayMs);\n}\n\n/**\n * Combines multiple abort signals into one.\n * When any of the input signals is aborted, the combined signal will also be aborted.\n *\n * @param signals - Array of AbortSignal instances (can contain undefined/null)\n * @returns An object containing the combined signal and a cleanup function\n */\nexport function combineAbortSignals(signals: Array<AbortSignal | undefined | null>): {\n signal: AbortSignal;\n cleanUpSignals: () => void;\n} {\n const controller = new AbortController();\n const onAbort = () => {\n controller.abort();\n cleanUpSignals();\n };\n\n const cleanUpSignals = () => {\n for (const s of signals) {\n s?.removeEventListener(\"abort\", onAbort);\n }\n };\n\n for (const s of signals) {\n s?.addEventListener(\"abort\", onAbort, { once: true });\n }\n\n if (signals.some((s) => s?.aborted)) {\n onAbort();\n }\n\n return { signal: controller.signal, cleanUpSignals };\n}\n\n/**\n * A deferred promise that can be resolved or rejected from outside.\n * Useful for coordinating async operations.\n */\nexport class Deferred<T> {\n public readonly promise: Promise<T>;\n public resolve!: (value: T) => void;\n public reject!: (error: unknown) => void;\n\n constructor() {\n this.promise = new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n}\n","import { ReplaneError, ReplaneErrorCode } from \"./error\";\nimport { combineAbortSignals } from \"./utils\";\n\nconst SSE_DATA_PREFIX = \"data:\";\n\n/**\n * Parsed SSE event\n */\nexport type SseEvent = { type: \"comment\"; comment: string } | { type: \"data\"; data: string };\n\n/**\n * Options for fetchSse\n */\nexport interface FetchSseOptions {\n fetchFn: typeof fetch;\n url: string;\n timeoutMs: number;\n body?: string;\n headers?: Record<string, string>;\n method?: string;\n signal?: AbortSignal;\n onConnect?: () => void;\n}\n\n/**\n * Fetch with timeout support\n */\nexport async function fetchWithTimeout(\n input: string | URL | Request,\n init: RequestInit,\n timeoutMs: number,\n fetchFn: typeof fetch\n): Promise<Response> {\n if (!fetchFn) {\n throw new Error(\"Global fetch is not available. Provide options.fetchFn.\");\n }\n if (!timeoutMs) return fetchFn(input, init);\n\n const timeoutController = new AbortController();\n const t = setTimeout(() => timeoutController.abort(), timeoutMs);\n // Note: We intentionally don't call cleanUpSignals() here because for streaming\n // responses (like SSE), the connection remains open after the response headers\n // are received. The abort signal needs to remain connected so that close() can\n // propagate the abort through the signal chain.\n const { signal } = combineAbortSignals([init.signal, timeoutController.signal]);\n try {\n return await fetchFn(input, {\n ...init,\n signal,\n });\n } finally {\n clearTimeout(t);\n }\n}\n\n/**\n * Ensures the response is successful, throwing ReplaneError if not\n */\nexport async function ensureSuccessfulResponse(response: Response, message: string): Promise<void> {\n if (response.status === 404) {\n throw new ReplaneError({\n message: `Not found: ${message}`,\n code: ReplaneErrorCode.NotFound,\n });\n }\n\n if (response.status === 401) {\n throw new ReplaneError({\n message: `Unauthorized access: ${message}`,\n code: ReplaneErrorCode.AuthError,\n });\n }\n\n if (response.status === 403) {\n throw new ReplaneError({\n message: `Forbidden access: ${message}`,\n code: ReplaneErrorCode.Forbidden,\n });\n }\n\n if (!response.ok) {\n let body: unknown;\n try {\n body = await response.text();\n } catch {\n body = \"<unable to read response body>\";\n }\n\n const code =\n response.status >= 500\n ? ReplaneErrorCode.ServerError\n : response.status >= 400\n ? ReplaneErrorCode.ClientError\n : ReplaneErrorCode.Unknown;\n\n throw new ReplaneError({\n message: `Fetch response isn't successful (${message}): ${response.status} ${response.statusText} - ${body}`,\n code,\n });\n }\n}\n\n/**\n * Fetches a Server-Sent Events (SSE) stream and yields parsed events.\n *\n * @param params - Options for the SSE fetch\n * @yields SseEvent objects containing either data or comment events\n */\nexport async function* fetchSse(params: FetchSseOptions): AsyncGenerator<SseEvent> {\n const abortController = new AbortController();\n const { signal, cleanUpSignals } = params.signal\n ? combineAbortSignals([params.signal, abortController.signal])\n : { signal: abortController.signal, cleanUpSignals: () => {} };\n\n try {\n const res = await fetchWithTimeout(\n params.url,\n {\n method: params.method ?? \"GET\",\n headers: { Accept: \"text/event-stream\", ...(params.headers ?? {}) },\n body: params.body,\n signal,\n },\n params.timeoutMs,\n params.fetchFn\n );\n\n await ensureSuccessfulResponse(res, `SSE ${params.url}`);\n const responseContentType = res.headers.get(\"content-type\") ?? \"\";\n\n if (!responseContentType.includes(\"text/event-stream\")) {\n throw new ReplaneError({\n message: `Expected text/event-stream, got \"${responseContentType}\"`,\n code: ReplaneErrorCode.ServerError,\n });\n }\n\n if (!res.body) {\n throw new ReplaneError({\n message: `Failed to fetch SSE ${params.url}: body is empty`,\n code: ReplaneErrorCode.Unknown,\n });\n }\n\n if (params.onConnect) {\n params.onConnect();\n }\n\n const decoded = res.body.pipeThrough(new TextDecoderStream());\n const reader = decoded.getReader();\n\n let buffer = \"\";\n\n try {\n while (true) {\n const { value, done } = await reader.read();\n if (done) break;\n buffer += value!;\n\n // Split on blank line; handle both \\n\\n and \\r\\n\\r\\n\n const frames = buffer.split(/\\r?\\n\\r?\\n/);\n buffer = frames.pop() ?? \"\";\n\n for (const frame of frames) {\n // Parse lines inside a single SSE event frame\n const dataLines: string[] = [];\n let comment: string | null = null;\n\n for (const rawLine of frame.split(/\\r?\\n/)) {\n if (!rawLine) continue;\n if (rawLine.startsWith(\":\")) {\n // comment/keepalive\n comment = rawLine.slice(1);\n continue;\n }\n\n if (rawLine.startsWith(SSE_DATA_PREFIX)) {\n // Keep leading space after \"data:\" if present per spec\n const line = rawLine.slice(SSE_DATA_PREFIX.length).replace(/^\\s/, \"\");\n dataLines.push(line);\n }\n }\n\n if (dataLines.length) {\n const data = dataLines.join(\"\\n\");\n yield { type: \"data\", data };\n } else if (comment !== null) {\n yield { type: \"comment\", comment };\n }\n }\n }\n } finally {\n try {\n await reader.cancel();\n } catch {\n // ignore error\n }\n abortController.abort();\n }\n } finally {\n cleanUpSignals();\n }\n}\n","import type { ReplicationStreamRecord, StartReplicationStreamBody } from \"./types\";\nimport type { ReplaneFinalOptions } from \"./client-types\";\nimport { fetchSse } from \"./sse\";\nimport { combineAbortSignals, retryDelay } from \"./utils\";\n\nconst SUPPORTED_REPLICATION_STREAM_RECORD_TYPES = Object.keys({\n config_change: true,\n init: true,\n} satisfies Record<ReplicationStreamRecord[\"type\"], true>);\n\n/**\n * Options for starting a replication stream\n */\nexport interface StartReplicationStreamOptions extends ReplaneFinalOptions {\n // getBody is a function to get the latest configs when we are trying\n // to reestablish the replication stream\n getBody: () => StartReplicationStreamBody;\n signal?: AbortSignal;\n onConnect?: () => void;\n onConnectionError?: (error: unknown) => void;\n onConnected?: () => void;\n}\n\n/**\n * Interface for storage implementations\n */\nexport interface ReplaneStorage {\n startReplicationStream(\n options: StartReplicationStreamOptions\n ): AsyncIterable<ReplicationStreamRecord>;\n close(): void;\n}\n\n/**\n * Remote storage implementation that connects to the Replane server\n * and streams config updates via SSE.\n */\nexport class ReplaneRemoteStorage implements ReplaneStorage {\n private closeController = new AbortController();\n\n /**\n * Start a replication stream that yields config updates.\n * This method never throws - it retries on failure with exponential backoff.\n */\n async *startReplicationStream(\n options: StartReplicationStreamOptions\n ): AsyncIterable<ReplicationStreamRecord> {\n const { signal, cleanUpSignals } = combineAbortSignals([\n this.closeController.signal,\n options.signal,\n ]);\n try {\n let failedAttempts = 0;\n while (!signal.aborted) {\n try {\n for await (const event of this.startReplicationStreamImpl({\n ...options,\n signal,\n onConnect: () => {\n failedAttempts = 0;\n },\n })) {\n yield event;\n }\n } catch (error: unknown) {\n failedAttempts++;\n const retryDelayMs = Math.min(options.retryDelayMs * 2 ** (failedAttempts - 1), 10_000);\n if (!signal.aborted) {\n options.logger.error(\n `Failed to fetch project events, retrying in ${retryDelayMs}ms...`,\n error\n );\n\n // Call the connection error callback if provided\n options.onConnectionError?.(error);\n\n await retryDelay(retryDelayMs);\n }\n }\n }\n } finally {\n cleanUpSignals();\n }\n }\n\n private async *startReplicationStreamImpl(\n options: StartReplicationStreamOptions\n ): AsyncIterable<ReplicationStreamRecord> {\n // Create an abort controller for inactivity timeout\n const inactivityAbortController = new AbortController();\n const { signal: combinedSignal, cleanUpSignals } = options.signal\n ? combineAbortSignals([options.signal, inactivityAbortController.signal])\n : { signal: inactivityAbortController.signal, cleanUpSignals: () => {} };\n\n let inactivityTimer: ReturnType<typeof setTimeout> | null = null;\n\n const resetInactivityTimer = () => {\n if (inactivityTimer) clearTimeout(inactivityTimer);\n inactivityTimer = setTimeout(() => {\n inactivityAbortController.abort();\n }, options.inactivityTimeoutMs);\n };\n\n try {\n const rawEvents = fetchSse({\n fetchFn: options.fetchFn,\n headers: {\n Authorization: this.getAuthHeader(options),\n \"Content-Type\": \"application/json\",\n \"User-Agent\": options.agent,\n },\n body: JSON.stringify(options.getBody()),\n timeoutMs: options.requestTimeoutMs,\n method: \"POST\",\n signal: combinedSignal,\n url: this.getApiEndpoint(`/sdk/v1/replication/stream`, options),\n onConnect: () => {\n resetInactivityTimer();\n options.onConnect?.();\n // Call the user's onConnected callback\n options.onConnected?.();\n },\n });\n\n for await (const sseEvent of rawEvents) {\n resetInactivityTimer();\n\n if (sseEvent.type === \"comment\") continue;\n\n const event = JSON.parse(sseEvent.data);\n if (\n typeof event === \"object\" &&\n event !== null &&\n \"type\" in event &&\n typeof event.type === \"string\" &&\n (SUPPORTED_REPLICATION_STREAM_RECORD_TYPES as unknown as string[]).includes(event.type)\n ) {\n yield event as ReplicationStreamRecord;\n }\n }\n } finally {\n if (inactivityTimer) clearTimeout(inactivityTimer);\n cleanUpSignals();\n }\n }\n\n /**\n * Close the storage and abort any active connections\n */\n close(): void {\n this.closeController.abort();\n }\n\n private getAuthHeader(options: ReplaneFinalOptions): string {\n return `Bearer ${options.sdkKey}`;\n }\n\n private getApiEndpoint(path: string, options: ReplaneFinalOptions): string {\n return `${options.baseUrl}/api${path}`;\n }\n}\n","/**\n * FNV-1a 32-bit hash function\n *\n * FNV (Fowler–Noll–Vo) is a non-cryptographic hash function known for its\n * speed and good distribution. This implementation uses the FNV-1a variant\n * which XORs before multiplying for better avalanche characteristics.\n *\n * @param input - The string to hash\n * @returns A 32-bit unsigned integer hash value\n */\nexport function fnv1a32(input: string): number {\n // Convert string to bytes (UTF-8)\n const encoder = new TextEncoder();\n const bytes = encoder.encode(input);\n\n // FNV-1a core\n let hash = 0x811c9dc5 >>> 0; // 2166136261, force uint32\n\n for (let i = 0; i < bytes.length; i++) {\n hash ^= bytes[i]; // XOR with byte\n hash = Math.imul(hash, 0x01000193) >>> 0; // * 16777619 mod 2^32\n }\n\n return hash >>> 0; // ensure unsigned 32-bit\n}\n\n/**\n * Convert FNV-1a hash to [0, 1) for bucketing.\n *\n * This is useful for percentage-based segmentation where you need\n * to deterministically assign a value to a bucket based on a string input.\n *\n * @param input - The string to hash\n * @returns A number in the range [0, 1)\n */\nexport function fnv1a32ToUnit(input: string): number {\n const h = fnv1a32(input);\n return h / 2 ** 32; // double in [0, 1)\n}\n","import type { RenderedCondition, RenderedOverride } from \"./types\";\nimport type { ReplaneContext, ReplaneLogger } from \"./client-types\";\nimport { fnv1a32ToUnit } from \"./hash\";\n\n/**\n * Result of evaluating a condition\n */\nexport type EvaluationResult = \"matched\" | \"not_matched\" | \"unknown\";\n\n/**\n * Evaluate config overrides based on context.\n * Returns the first matching override's value, or the base value if no override matches.\n *\n * @param baseValue - The default value to return if no override matches\n * @param overrides - Array of overrides to evaluate\n * @param context - The context to evaluate conditions against\n * @param logger - Logger for warnings\n * @returns The evaluated value\n */\nexport function evaluateOverrides<T>(\n baseValue: T,\n overrides: RenderedOverride[],\n context: ReplaneContext,\n logger: ReplaneLogger\n): T {\n // Find first matching override\n for (const override of overrides) {\n // All conditions must match (implicit AND)\n let overrideResult: EvaluationResult = \"matched\";\n const results = override.conditions.map((c) => evaluateCondition(c, context, logger));\n // AND: false > unknown > true\n if (results.some((r) => r === \"not_matched\")) {\n overrideResult = \"not_matched\";\n } else if (results.some((r) => r === \"unknown\")) {\n overrideResult = \"unknown\";\n }\n\n // Only use override if all conditions matched (not unknown)\n if (overrideResult === \"matched\") {\n return override.value as T;\n }\n }\n\n return baseValue;\n}\n\n/**\n * Evaluate a single condition against a context.\n *\n * @param condition - The condition to evaluate\n * @param context - The context to evaluate against\n * @param logger - Logger for warnings\n * @returns The evaluation result\n */\nexport function evaluateCondition(\n condition: RenderedCondition,\n context: ReplaneContext,\n logger: ReplaneLogger\n): EvaluationResult {\n const operator = condition.operator;\n\n // Composite conditions\n if (operator === \"and\") {\n const results = condition.conditions.map((c) => evaluateCondition(c, context, logger));\n // AND: false > unknown > true\n if (results.some((r) => r === \"not_matched\")) return \"not_matched\";\n if (results.some((r) => r === \"unknown\")) return \"unknown\";\n return \"matched\";\n }\n\n if (operator === \"or\") {\n const results = condition.conditions.map((c) => evaluateCondition(c, context, logger));\n // OR: true > unknown > false\n if (results.some((r) => r === \"matched\")) return \"matched\";\n if (results.some((r) => r === \"unknown\")) return \"unknown\";\n return \"not_matched\";\n }\n\n if (operator === \"not\") {\n const result = evaluateCondition(condition.condition, context, logger);\n if (result === \"matched\") return \"not_matched\";\n if (result === \"not_matched\") return \"matched\";\n return \"unknown\"; // NOT unknown = unknown\n }\n\n // Segmentation\n if (operator === \"segmentation\") {\n const contextValue = context[condition.property];\n if (contextValue === undefined || contextValue === null) {\n return \"unknown\";\n }\n\n // FNV-1a hash to bucket [0, 100)\n const hashInput = String(contextValue) + condition.seed;\n const unitValue = fnv1a32ToUnit(hashInput);\n return unitValue >= condition.fromPercentage / 100 && unitValue < condition.toPercentage / 100\n ? \"matched\"\n : \"not_matched\";\n }\n\n // Property-based conditions\n const property = condition.property;\n const contextValue = context[property];\n const expectedValue = condition.value;\n\n if (contextValue === undefined) {\n return \"unknown\";\n }\n\n // Type casting\n const castedValue = castToContextType(expectedValue, contextValue);\n\n switch (operator) {\n case \"equals\":\n return contextValue === castedValue ? \"matched\" : \"not_matched\";\n\n case \"in\":\n if (!Array.isArray(castedValue)) return \"unknown\";\n return castedValue.includes(contextValue) ? \"matched\" : \"not_matched\";\n\n case \"not_in\":\n if (!Array.isArray(castedValue)) return \"unknown\";\n return !castedValue.includes(contextValue) ? \"matched\" : \"not_matched\";\n\n case \"less_than\":\n if (typeof contextValue === \"number\" && typeof castedValue === \"number\") {\n return contextValue < castedValue ? \"matched\" : \"not_matched\";\n }\n if (typeof contextValue === \"string\" && typeof castedValue === \"string\") {\n return contextValue < castedValue ? \"matched\" : \"not_matched\";\n }\n return \"not_matched\";\n\n case \"less_than_or_equal\":\n if (typeof contextValue === \"number\" && typeof castedValue === \"number\") {\n return contextValue <= castedValue ? \"matched\" : \"not_matched\";\n }\n if (typeof contextValue === \"string\" && typeof castedValue === \"string\") {\n return contextValue <= castedValue ? \"matched\" : \"not_matched\";\n }\n return \"not_matched\";\n\n case \"greater_than\":\n if (typeof contextValue === \"number\" && typeof castedValue === \"number\") {\n return contextValue > castedValue ? \"matched\" : \"not_matched\";\n }\n if (typeof contextValue === \"string\" && typeof castedValue === \"string\") {\n return contextValue > castedValue ? \"matched\" : \"not_matched\";\n }\n return \"not_matched\";\n\n case \"greater_than_or_equal\":\n if (typeof contextValue === \"number\" && typeof castedValue === \"number\") {\n return contextValue >= castedValue ? \"matched\" : \"not_matched\";\n }\n if (typeof contextValue === \"string\" && typeof castedValue === \"string\") {\n return contextValue >= castedValue ? \"matched\" : \"not_matched\";\n }\n return \"not_matched\";\n\n default:\n warnNever(operator, logger, `Unexpected operator: ${operator}`);\n return \"unknown\";\n }\n}\n\n/**\n * Helper to warn about exhaustive check failures\n */\nfunction warnNever(value: never, logger: ReplaneLogger, message: string): void {\n logger.warn(message, { value });\n}\n\n/**\n * Cast expected value to match context value type.\n * This enables loose matching between different types (e.g., \"25\" matches 25).\n *\n * @param expectedValue - The value from the condition\n * @param contextValue - The value from the context\n * @returns The expected value cast to match the context value's type\n */\nexport function castToContextType(expectedValue: unknown, contextValue: unknown): unknown {\n if (typeof contextValue === \"number\") {\n if (typeof expectedValue === \"string\") {\n const num = Number(expectedValue);\n return isNaN(num) ? expectedValue : num;\n }\n return expectedValue;\n }\n\n if (typeof contextValue === \"boolean\") {\n if (typeof expectedValue === \"string\") {\n if (expectedValue === \"true\") return true;\n if (expectedValue === \"false\") return false;\n }\n if (typeof expectedValue === \"number\") {\n return expectedValue !== 0;\n }\n return expectedValue;\n }\n\n if (typeof contextValue === \"string\") {\n if (typeof expectedValue === \"number\" || typeof expectedValue === \"boolean\") {\n return String(expectedValue);\n }\n return expectedValue;\n }\n\n return expectedValue;\n}\n","// Auto-generated - do not edit manually\nexport const VERSION = \"0.8.19\";\nexport const DEFAULT_AGENT = `replane-js-sdk/${VERSION}`;\n","import type { ConfigDto } from \"./types\";\nimport type {\n ReplaneContext,\n ReplaneLogger,\n GetConfigOptions,\n MapConfig,\n ReplaneSnapshot,\n ReplaneClient,\n ReplaneClientOptions,\n RestoreReplaneClientOptions,\n ReplaneFinalOptions,\n} from \"./client-types\";\nimport type { ReplaneStorage } from \"./storage\";\nimport { ReplaneRemoteStorage } from \"./storage\";\nimport { ReplaneError, ReplaneErrorCode } from \"./error\";\nimport { evaluateOverrides } from \"./evaluation\";\nimport { Deferred } from \"./utils\";\nimport { DEFAULT_AGENT } from \"./version\";\n\n/**\n * Internal options for creating the client core\n */\ninterface ClientCoreOptions {\n initialConfigs: ConfigDto[];\n context: ReplaneContext;\n logger: ReplaneLogger;\n storage: ReplaneStorage | null;\n streamOptions: ReplaneFinalOptions | null;\n requiredConfigs: string[];\n}\n\n/**\n * Result from creating the client core\n */\ninterface ClientCoreResult<T extends object> {\n client: ReplaneClient<T>;\n configs: Map<string, ConfigDto>;\n startStreaming: () => Promise<void>;\n clientReady: Deferred<void>;\n}\n\n/**\n * Creates the core client logic shared between createReplaneClient and restoreReplaneClient\n */\nfunction createClientCore<T extends object = Record<string, unknown>>(\n options: ClientCoreOptions\n): ClientCoreResult<T> {\n const { initialConfigs, context, logger, storage, streamOptions, requiredConfigs } = options;\n\n const configs: Map<string, ConfigDto> = new Map(\n initialConfigs.map((config) => [config.name, config])\n );\n\n const clientReady = new Deferred<void>();\n const configSubscriptions = new Map<keyof T, Set<(config: MapConfig<T>) => void>>();\n const clientSubscriptions = new Set<(config: MapConfig<T>) => void>();\n\n function processConfigUpdates(updatedConfigs: ConfigDto[]) {\n for (const config of updatedConfigs) {\n configs.set(config.name, {\n name: config.name,\n overrides: config.overrides,\n value: config.value,\n });\n for (const callback of clientSubscriptions) {\n callback({ name: config.name as keyof T, value: config.value as T[keyof T] });\n }\n for (const callback of configSubscriptions.get(config.name as keyof T) ?? []) {\n callback({ name: config.name as keyof T, value: config.value as T[keyof T] });\n }\n }\n }\n\n async function startStreaming(): Promise<void> {\n if (!storage || !streamOptions) return;\n\n try {\n const replicationStream = storage.startReplicationStream({\n ...streamOptions,\n getBody: () => ({\n currentConfigs: [...configs.values()].map((config) => ({\n name: config.name,\n overrides: config.overrides,\n value: config.value,\n })),\n requiredConfigs,\n }),\n });\n\n for await (const event of replicationStream) {\n const updatedConfigs: ConfigDto[] =\n event.type === \"config_change\" ? [event.config] : event.configs;\n processConfigUpdates(updatedConfigs);\n clientReady.resolve();\n }\n } catch (error) {\n logger.error(\"Replane: error in SSE connection:\", error);\n clientReady.reject(error);\n throw error;\n }\n }\n\n function get<K extends keyof T>(\n configName: K,\n getConfigOptions: GetConfigOptions<T[K]> = {}\n ): T[K] {\n const config = configs.get(String(configName));\n\n if (config === undefined) {\n if (\"default\" in getConfigOptions) {\n return getConfigOptions.default as T[K];\n }\n throw new ReplaneError({\n message: `Config not found: ${String(configName)}`,\n code: ReplaneErrorCode.NotFound,\n });\n }\n\n try {\n return evaluateOverrides<T[K]>(\n config.value as T[K],\n config.overrides,\n { ...context, ...(getConfigOptions?.context ?? {}) },\n logger\n );\n } catch (error) {\n logger.error(`Replane: error evaluating overrides for config ${String(configName)}:`, error);\n return config.value as T[K];\n }\n }\n\n const subscribe = (\n callbackOrConfigName: keyof T | ((config: MapConfig<T>) => void),\n callbackOrUndefined?: (config: MapConfig<T>) => void\n ) => {\n let configName: keyof T | undefined = undefined;\n let callback: (config: MapConfig<T>) => void;\n if (typeof callbackOrConfigName === \"function\") {\n callback = callbackOrConfigName;\n } else {\n configName = callbackOrConfigName as keyof T;\n if (callbackOrUndefined === undefined) {\n throw new Error(\"callback is required when config name is provided\");\n }\n callback = callbackOrUndefined!;\n }\n\n // Wrap the callback to ensure that we have a unique reference\n const originalCallback = callback;\n callback = (...args: Parameters<typeof callback>) => {\n originalCallback(...args);\n };\n\n if (configName === undefined) {\n clientSubscriptions.add(callback);\n return () => {\n clientSubscriptions.delete(callback);\n };\n }\n\n if (!configSubscriptions.has(configName)) {\n configSubscriptions.set(configName, new Set());\n }\n configSubscriptions.get(configName)!.add(callback);\n return () => {\n configSubscriptions.get(configName)?.delete(callback);\n if (configSubscriptions.get(configName)?.size === 0) {\n configSubscriptions.delete(configName);\n }\n };\n };\n\n const getSnapshot = (): ReplaneSnapshot<T> => ({\n configs: [...configs.values()].map((config) => ({\n name: config.name,\n value: config.value,\n overrides: config.overrides.map((override) => ({\n name: override.name,\n conditions: override.conditions,\n value: override.value,\n })),\n })),\n context,\n });\n\n const close = () => storage?.close();\n\n const client: ReplaneClient<T> = {\n get,\n subscribe: subscribe as ReplaneClient<T>[\"subscribe\"],\n getSnapshot,\n close,\n };\n\n return { client, configs, startStreaming, clientReady };\n}\n\n/**\n * Create a Replane client bound to an SDK key.\n *\n * @example\n * ```typescript\n * const client = await createReplaneClient({\n * sdkKey: 'your-sdk-key',\n * baseUrl: 'https://app.replane.dev'\n * });\n * const value = client.get('my-config');\n * ```\n */\nexport async function createReplaneClient<T extends object = Record<string, unknown>>(\n sdkOptions: ReplaneClientOptions<T>\n): Promise<ReplaneClient<T>> {\n const storage = new ReplaneRemoteStorage();\n return await createReplaneClientInternal(toFinalOptions(sdkOptions), storage);\n}\n\n/**\n * Create a Replane client that uses in-memory storage.\n * Useful for testing or when you have static config values.\n *\n * @example\n * ```typescript\n * const client = createInMemoryReplaneClient({ 'my-config': 123 });\n * const value = client.get('my-config'); // 123\n * ```\n */\nexport function createInMemoryReplaneClient<T extends object = Record<string, unknown>>(\n initialData: T\n): ReplaneClient<T> {\n return {\n get: (configName, options) => {\n const config = initialData[configName];\n if (config === undefined) {\n if (options && \"default\" in options) {\n return options.default as T[typeof configName];\n }\n throw new ReplaneError({\n message: `Config not found: ${String(configName)}`,\n code: ReplaneErrorCode.NotFound,\n });\n }\n return config;\n },\n subscribe: () => {\n return () => {};\n },\n getSnapshot: () => ({\n configs: Object.entries(initialData).map(([name, value]) => ({\n name,\n value,\n overrides: [],\n })),\n }),\n close: () => {},\n };\n}\n\n/**\n * Restore a Replane client from a snapshot.\n * This is useful for SSR/hydration scenarios where the server has already fetched configs.\n *\n * @example\n * ```typescript\n * // On the server:\n * const serverClient = await createReplaneClient({ ... });\n * const snapshot = serverClient.getSnapshot();\n * // Pass snapshot to client via props/serialization\n *\n * // On the client:\n * const client = restoreReplaneClient({\n * snapshot,\n * connection: { sdkKey, baseUrl }\n * });\n * const value = client.get('my-config');\n * ```\n */\nexport function restoreReplaneClient<T extends object = Record<string, unknown>>(\n options: RestoreReplaneClientOptions<T>\n): ReplaneClient<T> {\n const { snapshot, connection } = options;\n const context = options.context ?? snapshot.context ?? {};\n const logger = connection?.logger ?? console;\n\n // Initialize configs from snapshot\n const initialConfigs: ConfigDto[] = snapshot.configs.map((config) => ({\n name: config.name,\n value: config.value,\n overrides: config.overrides,\n }));\n\n let storage: ReplaneRemoteStorage | null = null;\n let streamOptions: ReplaneFinalOptions | null = null;\n\n if (connection) {\n storage = new ReplaneRemoteStorage();\n streamOptions = toFinalOptions(connection);\n }\n\n const { client, startStreaming } = createClientCore<T>({\n initialConfigs,\n context,\n logger,\n storage,\n streamOptions,\n requiredConfigs: [],\n });\n\n // Start streaming in background (non-blocking) if connection is provided\n if (storage && streamOptions) {\n startStreaming().catch((error) => {\n logger.error(\"Replane: error in restored client SSE connection:\", error);\n });\n }\n\n return client;\n}\n\n/**\n * Internal function to create a Replane client with the given options and storage\n */\nasync function createReplaneClientInternal<T extends object = Record<string, unknown>>(\n sdkOptions: ReplaneFinalOptions,\n storage: ReplaneStorage\n): Promise<ReplaneClient<T>> {\n const { client, configs, startStreaming, clientReady } = createClientCore<T>({\n initialConfigs: sdkOptions.defaults,\n context: sdkOptions.context,\n logger: sdkOptions.logger,\n storage,\n streamOptions: sdkOptions,\n requiredConfigs: sdkOptions.requiredConfigs,\n });\n\n // Start streaming in background\n startStreaming().catch((error) => {\n sdkOptions.logger.error(\"Replane: error initializing client:\", error);\n });\n\n const initializationTimeoutId = setTimeout(() => {\n if (sdkOptions.defaults.length === 0) {\n // no defaults, we have nothing to work with\n client.close();\n\n clientReady.reject(\n new ReplaneError({\n message: \"Replane client initialization timed out\",\n code: ReplaneErrorCode.Timeout,\n })\n );\n\n return;\n }\n\n const missingRequiredConfigs: string[] = [];\n for (const requiredConfigName of sdkOptions.requiredConfigs) {\n if (!configs.has(requiredConfigName)) {\n missingRequiredConfigs.push(requiredConfigName);\n }\n }\n\n if (missingRequiredConfigs.length > 0) {\n client.close();\n clientReady.reject(\n new ReplaneError({\n message: `Required configs are missing: ${missingRequiredConfigs.join(\", \")}`,\n code: ReplaneErrorCode.NotFound,\n })\n );\n\n return;\n }\n\n clientReady.resolve();\n }, sdkOptions.initializationTimeoutMs);\n\n clientReady.promise.then(() => clearTimeout(initializationTimeoutId));\n\n await clientReady.promise;\n\n return client;\n}\n\n/**\n * Convert user options to final options with defaults\n */\nfunction toFinalOptions<T extends object>(options: ReplaneClientOptions<T>): ReplaneFinalOptions {\n return {\n sdkKey: options.sdkKey ?? \"\",\n baseUrl: (options.baseUrl ?? \"\").replace(/\\/+$/, \"\"),\n fetchFn:\n options.fetchFn ??\n // some browsers require binding the fetch function to window\n globalThis.fetch.bind(globalThis),\n requestTimeoutMs: options.requestTimeoutMs ?? 2000,\n initializationTimeoutMs: options.initializationTimeoutMs ?? 5000,\n inactivityTimeoutMs: options.inactivityTimeoutMs ?? 30_000,\n logger: options.logger ?? console,\n retryDelayMs: options.retryDelayMs ?? 200,\n context: {\n ...(options.context ?? {}),\n },\n requiredConfigs: Array.isArray(options.required)\n ? options.required.map((name) => String(name))\n : Object.entries(options.required ?? {})\n .filter(([_, value]) => value !== undefined)\n .map(([name]) => name),\n defaults: Object.entries(options.defaults ?? {})\n .filter(([_, value]) => value !== undefined)\n .map(([name, value]) => ({\n name,\n overrides: [],\n version: -1,\n value,\n })),\n agent: options.agent ?? DEFAULT_AGENT,\n onConnectionError: options.onConnectionError,\n onConnected: options.onConnected,\n };\n}\n","import { createReplaneClient } from \"./client\";\nimport type { ReplaneClient, ReplaneClientOptions, ReplaneSnapshot } from \"./client-types\";\n\n/**\n * Extended options for getReplaneSnapshot with caching support.\n */\nexport interface GetReplaneSnapshotOptions<T extends object> extends ReplaneClientOptions<T> {\n /**\n * Cache TTL in milliseconds. When set, the client is cached and reused\n * for instant subsequent calls within this duration.\n * @default 60_000 (1 minute)\n */\n keepAliveMs?: number;\n}\n\ninterface CachedClient {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n clientPromise: Promise<ReplaneClient<any>>;\n timeoutId: TimeoutId;\n}\n\nconst clientCache = new Map<string, CachedClient>();\n\nfunction getCacheKey<T extends object>(options: ReplaneClientOptions<T>): string {\n return `${options.baseUrl}:${options.sdkKey}`;\n}\n\ntype TimeoutId = ReturnType<typeof setTimeout>;\n\nfunction setupCleanupTimeout(cacheKey: string, keepAliveMs: number): TimeoutId {\n return setTimeout(() => {\n clientCache.delete(cacheKey);\n }, keepAliveMs);\n}\n\n/**\n * Creates a Replane client and returns a snapshot.\n * Useful for SSR/SSG scenarios where you need to fetch config once\n * and pass it to the client.\n *\n * @example\n * ```ts\n * const snapshot = await getReplaneSnapshot({\n * baseUrl: process.env.REPLANE_BASE_URL!,\n * sdkKey: process.env.REPLANE_SDK_KEY!,\n * });\n * ```\n */\nexport async function getReplaneSnapshot<T extends object>(\n options: GetReplaneSnapshotOptions<T>\n): Promise<ReplaneSnapshot<T>> {\n const { keepAliveMs = 60_000, ...clientOptions } = options;\n\n const cacheKey = getCacheKey(clientOptions);\n const cached = clientCache.get(cacheKey);\n\n // Return from cache if valid\n if (cached) {\n clearTimeout(cached.timeoutId);\n cached.timeoutId = setupCleanupTimeout(cacheKey, keepAliveMs);\n\n const client = await cached.clientPromise;\n return client.getSnapshot() as ReplaneSnapshot<T>;\n }\n\n // Create new client and cache it\n const clientPromise = createReplaneClient<T>(clientOptions);\n const entry: CachedClient = {\n clientPromise: clientPromise,\n timeoutId: setupCleanupTimeout(cacheKey, keepAliveMs),\n };\n clientCache.set(cacheKey, entry);\n\n const client = await clientPromise;\n\n return client.getSnapshot();\n}\n\n/**\n * Clears the client cache used by getReplaneSnapshot.\n * Useful for testing or when you need to force re-initialization.\n */\nexport async function clearSnapshotCache(): Promise<void> {\n const clientPromises = [...clientCache.values()].map((cached) => cached.clientPromise);\n clientCache.clear();\n for (const clientPromise of clientPromises) {\n const client = await clientPromise;\n client.close();\n }\n}\n"],"mappings":";;;;AAGA,IAAY,gEAAL;AACL;AACA;AACA;AACA;AACA;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