Files
Dominik Ferber e7360242b0 feat(flags): share the evaluation pipeline and bring SvelteKit to parity
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>
2026-06-25 16:15:18 +03:00
..
2024-12-12 13:01:06 +02:00