mirror of
https://github.com/vercel/flags.git
synced 2026-09-19 03:49:23 +08:00
e7360242b0
Lifts the per-request evaluation pipeline into src/shared/ and points both frameworks at it, so behavior is defined once. The Next-specific isInternalNextError check becomes an injected `isFrameworkError` hook on applyResult (Next passes it; SvelteKit defaults to none). - shared/evaluation.ts: evaluationCache (+ getUsedFlags accessor), getEntities + identify-args dedupe, and applyResult (cache -> override -> produce -> defaultValue/error -> report). - shared/flag-meta.ts: resolveAdapter, getDecide (with adapter validation), getIdentify, getOrigin. SvelteKit's flag() now runs through this pipeline. This is a behavior change that brings it to parity with Next — SvelteKit now: - falls back to defaultValue when decide throws or returns undefined - honors config.reportValue / adapter.config.reportValue - resolves adapter.origin (value or (key) => origin) - dedupes evaluation via the shared headers-keyed cache (replacing the per-store usedFlags/identifiers maps); createHandle's transformPageChunk reads used flags via getUsedFlags() - getProviderData emits defaultValue + declaredInCode Adds `defaultValue?` to the SvelteKit Flag type (additive) and 9 parity tests. Next's public .d.ts is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>