@guidelytech/react 0.15.0 → 0.17.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.
- package/README.md +40 -1
- package/dist/index.cjs +188 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +99 -4
- package/dist/index.d.ts +99 -4
- package/dist/index.js +171 -38
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx","../src/flags.tsx"],"sourcesContent":["import { createStaticFlags, stableStringify, type Attributes, type FlagDetails, type FlagsBootstrap, type FlagsClient } from \"@guidelytech/flags\";\nimport { createGuidely, type ChecklistProgressState, type GuidelyClient, type GuidelyEvents, type GuidelyOptions, type GuidelyUser, type PublishedGuide } from \"@guidelytech/sdk-core\";\nimport { createContext, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\nimport { FlagsContext, useBootstrap, type FlagsSource } from \"./flags\";\n\nexport type { GuidelyClient, GuidelyOptions, GuidelyEvents, GuidelyUser, ChecklistProgressState, PublishedGuide, AgentTurnInput, AgentTurnRedactor } from \"@guidelytech/sdk-core\";\nexport { useFlag, useFeatureValue, useFlagDetails, useFlags, useFlagsReady, useFlagsClient, Feature, FeatureFlag, FeatureValue, FlagsProvider } from \"./flags\";\nexport type { FeatureProps, FeatureValueProps, FlagsProviderProps } from \"./flags\";\nexport type { FlagsClient, FlagsClientOptions, FlagDetails, FlagsBootstrap, FlagsPayload, Attributes, JsonValue, EvaluationResult } from \"@guidelytech/flags\";\n\nconst GuidelyContext = createContext<GuidelyClient | null>(null);\n\nexport interface GuidelyProviderProps extends Omit<GuidelyOptions, \"user\"> {\n /** Identify this user as soon as the client is ready; `undefined` resets the identity. */\n user?: GuidelyUser | null;\n /**\n * Flags bootstrap from the server (`getFlagsBootstrap()` / `client.getPayload()`): flag hooks\n * render the same values on the server, during hydration and after.\n */\n flagsPayload?: FlagsBootstrap | null;\n /** Extra flag attributes (merged over the automatic identity, page and device attributes). */\n flagAttributes?: Attributes;\n children?: ReactNode;\n}\n\n/** The attributes the server knows about a user: what bootstrap snapshots evaluate with. */\nfunction userAttributes(user: GuidelyUser | null | undefined): Attributes {\n if (!user?.id) return {};\n return { ...(user.traits ?? {}), id: user.id, ...(user.account ? { account: { ...(user.account.traits ?? {}), id: user.account.id } } : {}) };\n}\n\n/**\n * Creates one Guidely client for the subtree. The client is created inside an effect (never\n * during SSR) and destroyed on unmount, so React Strict Mode's double-invoke is harmless.\n */\nexport function GuidelyProvider({ children, user, flagsPayload, flagAttributes, ...options }: GuidelyProviderProps) {\n const [client, setClient] = useState<GuidelyClient | null>(null);\n const optionsRef = useRef(options);\n optionsRef.current = options;\n const userRef = useRef(user);\n userRef.current = user;\n const flagsOpts = options.flags === false ? null : (options.flags ?? {});\n const payload = flagsPayload ?? flagsOpts?.payload ?? null;\n const payloadRef = useRef(payload);\n payloadRef.current = payload;\n const appAttributes = useMemo(() => ({ ...(flagsOpts?.attributes ?? {}), ...(flagAttributes ?? {}) }), [stableStringify(flagsOpts?.attributes ?? {}), stableStringify(flagAttributes ?? {})]);\n const appAttributesRef = useRef(appAttributes);\n appAttributesRef.current = appAttributes;\n const { projectId, environment, apiUrl } = options;\n\n useEffect(() => {\n if (typeof window === \"undefined\" || !projectId) return;\n const o = optionsRef.current;\n // The user is known up front so flags evaluate for them from the first render (no flicker).\n const c = createGuidely({ ...o, projectId, environment, apiUrl, user: userRef.current?.id ? userRef.current : undefined, flags: o.flags === false ? false : { ...(o.flags ?? {}), payload: payloadRef.current ?? undefined, attributes: appAttributesRef.current } });\n setClient(c);\n return () => {\n c.destroy();\n setClient((cur) => (cur === c ? null : cur));\n };\n }, [projectId, environment, apiUrl]);\n\n useEffect(() => {\n client?.flags.setAttributes(appAttributes);\n }, [client, appAttributes]);\n\n const userKey = user ? JSON.stringify([user.id, user.traits ?? null, user.account ?? null]) : \"\";\n const hadUser = useRef(false);\n useEffect(() => {\n if (!client) return;\n if (user && user.id) {\n hadUser.current = true;\n void client.identify(user.id, user.traits, user.account);\n } else if (hadUser.current) {\n hadUser.current = false;\n client.reset();\n }\n }, [client, userKey]);\n\n const bootstrap = useBootstrap(payload, { ...userAttributes(user), ...appAttributes });\n const flags = useMemo<FlagsSource>(() => ({ client: client?.flags ?? null, bootstrap }), [client, bootstrap]);\n return (\n <GuidelyContext.Provider value={client}>\n <FlagsContext.Provider value={flags}>{children}</FlagsContext.Provider>\n </GuidelyContext.Provider>\n );\n}\n\nconst NOOP_RESULTS: Record<string, unknown> = {\n init: Promise.resolve(),\n ready: Promise.resolve(),\n identify: Promise.resolve(),\n setAccount: Promise.resolve(),\n updateTraits: Promise.resolve(),\n refresh: Promise.resolve(),\n startGuide: false,\n getActiveGuide: null,\n getGuides: [],\n getChecklistProgress: { completedTaskIds: [], completedAt: null, dismissedAt: null },\n isGuideCompleted: false,\n on: () => {},\n getState: { ready: false, destroyed: false },\n getContext: null,\n getSessionId: \"\",\n isRecording: false,\n agentConversation: false,\n trackAgentTurn: false,\n};\n\n/** Flags that serve every fallback; `useGuidely().flags` before the provider has a client. */\nconst noopFlags = new Proxy(createStaticFlags() as unknown as FlagsClient, {\n get(target, prop, receiver) {\n if (prop in target) return Reflect.get(target, prop, receiver);\n if (prop === \"ready\" || prop === \"refresh\" || prop === \"flush\") return () => Promise.resolve();\n if (prop === \"getPayload\") return () => null;\n if (prop === \"forUser\") return () => target;\n return typeof prop === \"string\" ? () => undefined : undefined;\n },\n});\n\nconst missing = <T,>(key: string, fallback: T): FlagDetails<T> => ({ key, value: fallback, reason: \"FLAG_NOT_FOUND\", inExperiment: false, usedFallback: true });\n\n/** Methods whose no-op answer depends on the arguments (flag getters return the fallback). */\nconst NOOP_FUNCTIONS: Record<string, (...args: any[]) => unknown> = {\n isFeatureEnabled: (_key: string, fallback = false) => fallback,\n getFeatureValue: (_key: string, fallback: unknown) => fallback,\n getFeatureDetails: (key: string, fallback: unknown) => missing(key, fallback),\n onFlagsChange: () => () => {},\n};\n\n/** A client that ignores every call; returned by `useGuidely()` on the server and before the provider mounts. */\nexport const noopClient: GuidelyClient = new Proxy({} as GuidelyClient, {\n get(_target, prop) {\n if (prop === \"options\") return { projectId: \"\" };\n if (prop === \"flags\") return noopFlags;\n if (typeof prop !== \"string\") return undefined;\n return NOOP_FUNCTIONS[prop] ?? (() => NOOP_RESULTS[prop]);\n },\n});\n\n/** The Guidely client, or a no-op client during SSR / before the provider has mounted. */\nexport function useGuidely(): GuidelyClient {\n return useContext(GuidelyContext) ?? noopClient;\n}\n\n/** True once the client has loaded its configuration. */\nexport function useGuidelyReady(): boolean {\n const client = useContext(GuidelyContext);\n const [ready, setReady] = useState(false);\n useEffect(() => {\n if (!client) {\n setReady(false);\n return;\n }\n if (client.getState().ready) setReady(true);\n return client.on(\"ready\", () => setReady(true));\n }, [client]);\n return ready;\n}\n\n/** Identifies the user whenever the arguments change. */\nexport function useGuidelyIdentify(userId: string | null | undefined, traits?: Record<string, unknown>, account?: GuidelyUser[\"account\"]): void {\n const client = useContext(GuidelyContext);\n const key = JSON.stringify([userId ?? null, traits ?? null, account ?? null]);\n useEffect(() => {\n if (!client || !userId) return;\n void client.identify(userId, traits, account);\n }, [client, key]);\n}\n\n/** Subscribes to a client event for the lifetime of the component. */\nexport function useGuidelyEvent<K extends keyof GuidelyEvents>(event: K, handler: GuidelyEvents[K]): void {\n const client = useContext(GuidelyContext);\n const ref = useRef(handler);\n ref.current = handler;\n useEffect(() => {\n if (!client) return;\n const cb = ((...args: unknown[]) => (ref.current as (...a: unknown[]) => void)(...args)) as GuidelyEvents[K];\n return client.on(event, cb);\n }, [client, event]);\n}\n\n/** Live checklist progress for a checklist guide (by id or key). */\nexport function useChecklistProgress(idOrKey: string): ChecklistProgressState {\n const client = useContext(GuidelyContext);\n const [progress, setProgress] = useState<ChecklistProgressState>({ completedTaskIds: [], completedAt: null, dismissedAt: null });\n useEffect(() => {\n if (!client) return;\n const update = () => setProgress(client.getChecklistProgress(idOrKey));\n update();\n const offs = [client.on(\"ready\", update), client.on(\"identify\", update), client.on(\"checklist:task\", update), client.on(\"checklist:complete\", update)];\n return () => offs.forEach((off) => off());\n }, [client, idOrKey]);\n return progress;\n}\n\nexport interface GuideState {\n /** The guide is currently showing. */\n active: boolean;\n completed: boolean;\n stepId: string | null;\n stepIndex: number;\n guide: PublishedGuide | null;\n}\n\n/** Live state of a guide (by id or key): active, completed, current step. */\nexport function useGuideState(idOrKey: string): GuideState {\n const client = useContext(GuidelyContext);\n const [state, setState] = useState<GuideState>({ active: false, completed: false, stepId: null, stepIndex: -1, guide: null });\n useEffect(() => {\n if (!client) return;\n const matches = (g: PublishedGuide) => g.id === idOrKey || g.key === idOrKey;\n const compute = () => {\n const guide = client.getGuides().find(matches) ?? null;\n const active = client.getActiveGuide();\n const s = client.getState().activeGuide;\n setState({ active: !!active && matches(active), completed: client.isGuideCompleted(idOrKey), stepId: active && matches(active) ? ((s as { stepId?: string | null } | null)?.stepId ?? null) : null, stepIndex: active && matches(active) ? ((s as { stepIndex?: number } | null)?.stepIndex ?? -1) : -1, guide });\n };\n compute();\n const offs = ([\"ready\", \"identify\", \"guide:start\", \"guide:step\", \"guide:complete\", \"guide:dismiss\", \"guide:skip\"] as const).map((e) => client.on(e, compute));\n return () => offs.forEach((off) => off());\n }, [client, idOrKey]);\n return state;\n}\n","import { createFlagsClient, createStaticFlags, jsonEquals, stableStringify, type Attributes, type FlagDetails, type FlagValue, type FlagsBootstrap, type FlagsClient, type FlagsClientOptions, type FlagsReader, type JsonValue } from \"@guidelytech/flags\";\nimport { createContext, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode } from \"react\";\n\n/** What the flag hooks read: the live client once created, else a static snapshot of the bootstrap payload. */\nexport interface FlagsSource {\n client: FlagsClient | null;\n bootstrap: FlagsReader;\n}\n\nexport const FlagsContext = createContext<FlagsSource | null>(null);\n\nconst EMPTY = createStaticFlags();\n\nfunction useReader(): FlagsReader {\n const src = useContext(FlagsContext);\n return src?.client ?? src?.bootstrap ?? EMPTY;\n}\n\n/**\n * Subscribes to the flags with `useSyncExternalStore`. Values are compared deeply so object\n * flags keep their identity between renders. The server snapshot is the bootstrap payload, so\n * server-rendered HTML and hydration agree.\n */\nfunction useFlagsValue<T>(select: (reader: FlagsReader) => T): T {\n const reader = useReader();\n const cache = useRef<{ reader: FlagsReader; value: T } | null>(null);\n const get = () => {\n const value = select(reader);\n const c = cache.current;\n if (c && c.reader === reader && jsonEquals(c.value, value)) return c.value;\n cache.current = { reader, value };\n return value;\n };\n return useSyncExternalStore(reader.subscribe, get, get);\n}\n\n/** Is the boolean flag on? `fallback` (default `false`) until flags load, or when missing. */\nexport function useFlag(key: string, fallback = false): boolean {\n return useFlagsValue((r) => r.isEnabled(key, fallback));\n}\n\n/** A flag's value (string, number, JSON…); `fallback` when missing or of a different type. */\nexport function useFeatureValue<T extends JsonValue>(key: string, fallback: T): FlagValue<T> {\n return useFlagsValue((r) => r.getValue(key, fallback));\n}\n\n/** A flag's value plus why it was served (reason, rule, variation, experiment). */\nexport function useFlagDetails<T extends JsonValue>(key: string, fallback: T): FlagDetails<FlagValue<T>> {\n return useFlagsValue((r) => r.getDetails(key, fallback));\n}\n\n/** Every flag's value (records no exposures). */\nexport function useFlags(): Record<string, JsonValue> {\n return useFlagsValue((r) => r.getAll());\n}\n\n/** True once flags have loaded (or failed to and serve fallbacks); true from the start with a bootstrap payload. */\nexport function useFlagsReady(): boolean {\n return useFlagsValue((r) => r.isReady());\n}\n\n/** The flags client (`null` on the server and before the provider has created it). */\nexport function useFlagsClient(): FlagsClient | null {\n return useContext(FlagsContext)?.client ?? null;\n}\n\nexport interface FeatureProps {\n flag: string;\n children?: ReactNode;\n /** Rendered while the flag is off (default: nothing). */\n fallback?: ReactNode;\n}\n\n/** Renders `children` when the boolean flag is on, else `fallback`. */\nexport function Feature({ flag, children, fallback = null }: FeatureProps) {\n return <>{useFlag(flag) ? children : fallback}</>;\n}\n\n/** Alias of {@link Feature}. */\nexport const FeatureFlag = Feature;\n\nexport interface FeatureValueProps extends FeatureProps {\n /** Renders `children` when the flag's value equals this (deep equality). */\n value: JsonValue;\n}\n\n/** Renders `children` when the flag's value equals `value` (e.g. an experiment variation), else `fallback`. */\nexport function FeatureValue({ flag, value, children, fallback = null }: FeatureValueProps) {\n const current = useFeatureValue<JsonValue>(flag, null);\n return <>{jsonEquals(current, value) ? children : fallback}</>;\n}\n\n/** A static snapshot for SSR and hydration, rebuilt only when the payload or attributes change. */\nexport function useBootstrap(payload: FlagsBootstrap | null | undefined, attributes: Attributes): FlagsReader {\n const key = stableStringify(attributes);\n return useMemo(() => (payload ? createStaticFlags({ payload, attributes }) : EMPTY), [payload, key]);\n}\n\nexport interface FlagsProviderProps extends Omit<FlagsClientOptions, \"payload\"> {\n /** Bootstrap from the server (`getPayload()`): renders the same values on the server and in the browser. */\n payload?: FlagsBootstrap | null;\n /** Use an existing client instead of creating one. */\n client?: FlagsClient;\n children?: ReactNode;\n}\n\n/**\n * Feature flags only (no guides or analytics). Creates a flags client in an effect (never during\n * SSR) and destroys it on unmount; until then hooks read the `payload` snapshot. Changing\n * `attributes` re-evaluates without recreating the client.\n *\n * ```tsx\n * <FlagsProvider sdkKey=\"pk_prod_…\" attributes={{ id: user.id, plan: user.plan }} payload={bootstrap}>\n * ```\n */\nexport function FlagsProvider({ children, client: external, payload, ...options }: FlagsProviderProps) {\n const [created, setCreated] = useState<FlagsClient | null>(null);\n const optionsRef = useRef(options);\n optionsRef.current = options;\n const sdkKey = options.sdkKey ?? options.projectId;\n const { apiUrl, environment } = options;\n const payloadRef = useRef(payload);\n payloadRef.current = payload;\n\n useEffect(() => {\n if (external || !sdkKey || typeof window === \"undefined\") return;\n let c: FlagsClient;\n try {\n c = createFlagsClient({ ...optionsRef.current, sdkKey, payload: payloadRef.current ?? undefined });\n } catch (err) {\n optionsRef.current.onError?.(err instanceof Error ? err : new Error(String(err)));\n return;\n }\n setCreated(c);\n return () => {\n c.destroy();\n setCreated((cur) => (cur === c ? null : cur));\n };\n }, [external, sdkKey, apiUrl, environment]);\n\n const client = external ?? created;\n const attributes = options.attributes ?? {};\n const attrsKey = stableStringify(attributes);\n useEffect(() => {\n if (client && options.attributes) client.setAttributes(options.attributes);\n }, [client, attrsKey]);\n\n const bootstrap = useBootstrap(payload, attributes);\n const value = useMemo<FlagsSource>(() => ({ client, bootstrap }), [client, bootstrap]);\n return <FlagsContext.Provider value={value}>{children}</FlagsContext.Provider>;\n}\n"],"mappings":";;;AAAA,SAAS,qBAAAA,oBAAmB,mBAAAC,wBAAiG;AAC7H,SAAS,qBAAsJ;AAC/J,SAAS,iBAAAC,gBAAe,cAAAC,aAAY,aAAAC,YAAW,WAAAC,UAAS,UAAAC,SAAQ,YAAAC,iBAAgC;;;ACFhG,SAAS,mBAAmB,mBAAmB,YAAY,uBAA4K;AACvO,SAAS,eAAe,YAAY,WAAW,SAAS,QAAQ,UAAU,4BAA4C;AA0E7G;AAlEF,IAAM,eAAe,cAAkC,IAAI;AAElE,IAAM,QAAQ,kBAAkB;AAEhC,SAAS,YAAyB;AAChC,QAAM,MAAM,WAAW,YAAY;AACnC,SAAO,KAAK,UAAU,KAAK,aAAa;AAC1C;AAOA,SAAS,cAAiB,QAAuC;AAC/D,QAAM,SAAS,UAAU;AACzB,QAAM,QAAQ,OAAiD,IAAI;AACnE,QAAM,MAAM,MAAM;AAChB,UAAM,QAAQ,OAAO,MAAM;AAC3B,UAAM,IAAI,MAAM;AAChB,QAAI,KAAK,EAAE,WAAW,UAAU,WAAW,EAAE,OAAO,KAAK,EAAG,QAAO,EAAE;AACrE,UAAM,UAAU,EAAE,QAAQ,MAAM;AAChC,WAAO;AAAA,EACT;AACA,SAAO,qBAAqB,OAAO,WAAW,KAAK,GAAG;AACxD;AAGO,SAAS,QAAQ,KAAa,WAAW,OAAgB;AAC9D,SAAO,cAAc,CAAC,MAAM,EAAE,UAAU,KAAK,QAAQ,CAAC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;AACpB,SAAO;AACT;AAYO,SAAS,cAAc,SAA6B;AACzD,QAAM,SAASE,YAAW,cAAc;AACxC,QAAM,CAAC,OAAO,QAAQ,IAAIN,UAAqB,EAAE,QAAQ,OAAO,WAAW,OAAO,QAAQ,MAAM,WAAW,IAAI,OAAO,KAAK,CAAC;AAC5H,EAAAI,WAAU,MAAM;AACd,QAAI,CAAC,OAAQ;AACb,UAAM,UAAU,CAAC,MAAsB,EAAE,OAAO,WAAW,EAAE,QAAQ;AACrE,UAAM,UAAU,MAAM;AACpB,YAAM,QAAQ,OAAO,UAAU,EAAE,KAAK,OAAO,KAAK;AAClD,YAAM,SAAS,OAAO,eAAe;AACrC,YAAM,IAAI,OAAO,SAAS,EAAE;AAC5B,eAAS,EAAE,QAAQ,CAAC,CAAC,UAAU,QAAQ,MAAM,GAAG,WAAW,OAAO,iBAAiB,OAAO,GAAG,QAAQ,UAAU,QAAQ,MAAM,IAAM,GAAyC,UAAU,OAAQ,MAAM,WAAW,UAAU,QAAQ,MAAM,IAAM,GAAqC,aAAa,KAAM,IAAI,MAAM,CAAC;AAAA,IAClT;AACA,YAAQ;AACR,UAAM,OAAQ,CAAC,SAAS,YAAY,eAAe,cAAc,kBAAkB,iBAAiB,YAAY,EAAY,IAAI,CAAC,MAAM,OAAO,GAAG,GAAG,OAAO,CAAC;AAC5J,WAAO,MAAM,KAAK,QAAQ,CAAC,QAAQ,IAAI,CAAC;AAAA,EAC1C,GAAG,CAAC,QAAQ,OAAO,CAAC;AACpB,SAAO;AACT;","names":["createStaticFlags","stableStringify","createContext","useContext","useEffect","useMemo","useRef","useState","jsx","createContext","useState","useRef","useMemo","stableStringify","useEffect","createStaticFlags","useContext"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx","../src/context.ts","../src/errors.tsx","../src/flags.tsx"],"sourcesContent":["import { createStaticFlags, stableStringify, type Attributes, type FlagDetails, type FlagsBootstrap, type FlagsClient } from \"@guidelytech/flags\";\nimport { createGuidely, type ChecklistProgressState, type GuidelyClient, type GuidelyEvents, type GuidelyOptions, type GuidelyUser, type PublishedGuide } from \"@guidelytech/sdk-core\";\nimport { useContext, useEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\nimport { GuidelyContext } from \"./context\";\nimport { drainPendingErrors } from \"./errors\";\nimport { FlagsContext, useBootstrap, type FlagsSource } from \"./flags\";\n\nexport type { GuidelyClient, GuidelyOptions, GuidelyEvents, GuidelyUser, ChecklistProgressState, PublishedGuide, AgentTurnInput, AgentTurnRedactor } from \"@guidelytech/sdk-core\";\nexport { useFlag, useFeatureValue, useFlagDetails, useFlags, useFlagsReady, useFlagsClient, Feature, FeatureFlag, FeatureValue, FlagsProvider } from \"./flags\";\nexport type { FeatureProps, FeatureValueProps, FlagsProviderProps } from \"./flags\";\nexport type { FlagsClient, FlagsClientOptions, FlagDetails, FlagsBootstrap, FlagsPayload, Attributes, JsonValue, EvaluationResult } from \"@guidelytech/flags\";\nexport { GuidelyErrorBoundary, withGuidelyErrorBoundary, useCaptureException, guidelyReactErrorHandler } from \"./errors\";\nexport type { GuidelyErrorBoundaryProps, ErrorBoundaryFallbackProps, ReactErrorInfo } from \"./errors\";\nexport type { Breadcrumb, CaptureContext, ErrorEvent, ErrorLevelName, ErrorMonitoringOptions, ExceptionDetail } from \"@guidelytech/sdk-core\";\n\nexport interface GuidelyProviderProps extends Omit<GuidelyOptions, \"user\"> {\n /** Identify this user as soon as the client is ready; `undefined` resets the identity. */\n user?: GuidelyUser | null;\n /**\n * Flags bootstrap from the server (`getFlagsBootstrap()` / `client.getPayload()`): flag hooks\n * render the same values on the server, during hydration and after.\n */\n flagsPayload?: FlagsBootstrap | null;\n /** Extra flag attributes (merged over the automatic identity, page and device attributes). */\n flagAttributes?: Attributes;\n children?: ReactNode;\n}\n\n/** The attributes the server knows about a user: what bootstrap snapshots evaluate with. */\nfunction userAttributes(user: GuidelyUser | null | undefined): Attributes {\n if (!user?.id) return {};\n return { ...(user.traits ?? {}), id: user.id, ...(user.account ? { account: { ...(user.account.traits ?? {}), id: user.account.id } } : {}) };\n}\n\n/**\n * Creates one Guidely client for the subtree. The client is created inside an effect (never\n * during SSR) and destroyed on unmount, so React Strict Mode's double-invoke is harmless.\n */\nexport function GuidelyProvider({ children, user, flagsPayload, flagAttributes, ...options }: GuidelyProviderProps) {\n const [client, setClient] = useState<GuidelyClient | null>(null);\n const optionsRef = useRef(options);\n optionsRef.current = options;\n const userRef = useRef(user);\n userRef.current = user;\n const flagsOpts = options.flags === false ? null : (options.flags ?? {});\n const payload = flagsPayload ?? flagsOpts?.payload ?? null;\n const payloadRef = useRef(payload);\n payloadRef.current = payload;\n const appAttributes = useMemo(() => ({ ...(flagsOpts?.attributes ?? {}), ...(flagAttributes ?? {}) }), [stableStringify(flagsOpts?.attributes ?? {}), stableStringify(flagAttributes ?? {})]);\n const appAttributesRef = useRef(appAttributes);\n appAttributesRef.current = appAttributes;\n const { projectId, environment, apiUrl } = options;\n\n useEffect(() => {\n if (typeof window === \"undefined\" || !projectId) return;\n const o = optionsRef.current;\n // The user is known up front so flags evaluate for them from the first render (no flicker).\n const c = createGuidely({ ...o, projectId, environment, apiUrl, user: userRef.current?.id ? userRef.current : undefined, flags: o.flags === false ? false : { ...(o.flags ?? {}), payload: payloadRef.current ?? undefined, attributes: appAttributesRef.current } });\n setClient(c);\n // Render errors caught before the client existed (the first render) go out now.\n drainPendingErrors(c);\n return () => {\n c.destroy();\n setClient((cur) => (cur === c ? null : cur));\n };\n }, [projectId, environment, apiUrl]);\n\n useEffect(() => {\n client?.flags.setAttributes(appAttributes);\n }, [client, appAttributes]);\n\n const userKey = user ? JSON.stringify([user.id, user.traits ?? null, user.account ?? null]) : \"\";\n const hadUser = useRef(false);\n useEffect(() => {\n if (!client) return;\n if (user && user.id) {\n hadUser.current = true;\n void client.identify(user.id, user.traits, user.account);\n } else if (hadUser.current) {\n hadUser.current = false;\n client.reset();\n }\n }, [client, userKey]);\n\n const bootstrap = useBootstrap(payload, { ...userAttributes(user), ...appAttributes });\n const flags = useMemo<FlagsSource>(() => ({ client: client?.flags ?? null, bootstrap }), [client, bootstrap]);\n return (\n <GuidelyContext.Provider value={client}>\n <FlagsContext.Provider value={flags}>{children}</FlagsContext.Provider>\n </GuidelyContext.Provider>\n );\n}\n\nconst NOOP_RESULTS: Record<string, unknown> = {\n init: Promise.resolve(),\n ready: Promise.resolve(),\n identify: Promise.resolve(),\n setAccount: Promise.resolve(),\n updateTraits: Promise.resolve(),\n refresh: Promise.resolve(),\n startGuide: false,\n getActiveGuide: null,\n getGuides: [],\n getChecklistProgress: { completedTaskIds: [], completedAt: null, dismissedAt: null },\n isGuideCompleted: false,\n on: () => {},\n getState: { ready: false, destroyed: false },\n getContext: null,\n getSessionId: \"\",\n isRecording: false,\n agentConversation: false,\n trackAgentTurn: false,\n captureException: \"\",\n captureMessage: \"\",\n};\n\n/** Flags that serve every fallback; `useGuidely().flags` before the provider has a client. */\nconst noopFlags = new Proxy(createStaticFlags() as unknown as FlagsClient, {\n get(target, prop, receiver) {\n if (prop in target) return Reflect.get(target, prop, receiver);\n if (prop === \"ready\" || prop === \"refresh\" || prop === \"flush\") return () => Promise.resolve();\n if (prop === \"getPayload\") return () => null;\n if (prop === \"forUser\") return () => target;\n return typeof prop === \"string\" ? () => undefined : undefined;\n },\n});\n\nconst missing = <T,>(key: string, fallback: T): FlagDetails<T> => ({ key, value: fallback, reason: \"FLAG_NOT_FOUND\", inExperiment: false, usedFallback: true });\n\n/** Methods whose no-op answer depends on the arguments (flag getters return the fallback). */\nconst NOOP_FUNCTIONS: Record<string, (...args: any[]) => unknown> = {\n isFeatureEnabled: (_key: string, fallback = false) => fallback,\n getFeatureValue: (_key: string, fallback: unknown) => fallback,\n getFeatureDetails: (key: string, fallback: unknown) => missing(key, fallback),\n onFlagsChange: () => () => {},\n};\n\n/** A client that ignores every call; returned by `useGuidely()` on the server and before the provider mounts. */\nexport const noopClient: GuidelyClient = new Proxy({} as GuidelyClient, {\n get(_target, prop) {\n if (prop === \"options\") return { projectId: \"\" };\n if (prop === \"flags\") return noopFlags;\n if (typeof prop !== \"string\") return undefined;\n return NOOP_FUNCTIONS[prop] ?? (() => NOOP_RESULTS[prop]);\n },\n});\n\n/** The Guidely client, or a no-op client during SSR / before the provider has mounted. */\nexport function useGuidely(): GuidelyClient {\n return useContext(GuidelyContext) ?? noopClient;\n}\n\n/** True once the client has loaded its configuration. */\nexport function useGuidelyReady(): boolean {\n const client = useContext(GuidelyContext);\n const [ready, setReady] = useState(false);\n useEffect(() => {\n if (!client) {\n setReady(false);\n return;\n }\n if (client.getState().ready) setReady(true);\n return client.on(\"ready\", () => setReady(true));\n }, [client]);\n return ready;\n}\n\n/** Identifies the user whenever the arguments change. */\nexport function useGuidelyIdentify(userId: string | null | undefined, traits?: Record<string, unknown>, account?: GuidelyUser[\"account\"]): void {\n const client = useContext(GuidelyContext);\n const key = JSON.stringify([userId ?? null, traits ?? null, account ?? null]);\n useEffect(() => {\n if (!client || !userId) return;\n void client.identify(userId, traits, account);\n }, [client, key]);\n}\n\n/** Subscribes to a client event for the lifetime of the component. */\nexport function useGuidelyEvent<K extends keyof GuidelyEvents>(event: K, handler: GuidelyEvents[K]): void {\n const client = useContext(GuidelyContext);\n const ref = useRef(handler);\n ref.current = handler;\n useEffect(() => {\n if (!client) return;\n const cb = ((...args: unknown[]) => (ref.current as (...a: unknown[]) => void)(...args)) as GuidelyEvents[K];\n return client.on(event, cb);\n }, [client, event]);\n}\n\n/** Live checklist progress for a checklist guide (by id or key). */\nexport function useChecklistProgress(idOrKey: string): ChecklistProgressState {\n const client = useContext(GuidelyContext);\n const [progress, setProgress] = useState<ChecklistProgressState>({ completedTaskIds: [], completedAt: null, dismissedAt: null });\n useEffect(() => {\n if (!client) return;\n const update = () => setProgress(client.getChecklistProgress(idOrKey));\n update();\n const offs = [client.on(\"ready\", update), client.on(\"identify\", update), client.on(\"checklist:task\", update), client.on(\"checklist:complete\", update)];\n return () => offs.forEach((off) => off());\n }, [client, idOrKey]);\n return progress;\n}\n\nexport interface GuideState {\n /** The guide is currently showing. */\n active: boolean;\n completed: boolean;\n stepId: string | null;\n stepIndex: number;\n guide: PublishedGuide | null;\n}\n\n/** Live state of a guide (by id or key): active, completed, current step. */\nexport function useGuideState(idOrKey: string): GuideState {\n const client = useContext(GuidelyContext);\n const [state, setState] = useState<GuideState>({ active: false, completed: false, stepId: null, stepIndex: -1, guide: null });\n useEffect(() => {\n if (!client) return;\n const matches = (g: PublishedGuide) => g.id === idOrKey || g.key === idOrKey;\n const compute = () => {\n const guide = client.getGuides().find(matches) ?? null;\n const active = client.getActiveGuide();\n const s = client.getState().activeGuide;\n setState({ active: !!active && matches(active), completed: client.isGuideCompleted(idOrKey), stepId: active && matches(active) ? ((s as { stepId?: string | null } | null)?.stepId ?? null) : null, stepIndex: active && matches(active) ? ((s as { stepIndex?: number } | null)?.stepIndex ?? -1) : -1, guide });\n };\n compute();\n const offs = ([\"ready\", \"identify\", \"guide:start\", \"guide:step\", \"guide:complete\", \"guide:dismiss\", \"guide:skip\"] as const).map((e) => client.on(e, compute));\n return () => offs.forEach((off) => off());\n }, [client, idOrKey]);\n return state;\n}\n","import type { GuidelyClient } from \"@guidelytech/sdk-core\";\nimport { createContext } from \"react\";\n\n/** The provider's client (null outside a `GuidelyProvider` and before it has created one). */\nexport const GuidelyContext = createContext<GuidelyClient | null>(null);\n","import { GuidelyClient, type CaptureContext, type ErrorLevelName } from \"@guidelytech/sdk-core\";\nimport { Component, useContext, useEffect, useState, version, type ComponentType, type ErrorInfo, type ReactNode } from \"react\";\nimport { GuidelyContext } from \"./context\";\n\n/**\n * Error monitoring for React (Sentry's `ErrorBoundary`, `withErrorBoundary` and `reactErrorHandler`):\n * render errors become `exception` events with the component stack in `contexts.react`. Kept out\n * of index.tsx so the provider only re-exports it.\n */\n\n/** Errors already reported, so a boundary and a root error handler never send the same error twice. */\nconst reported = new WeakSet<object>();\n\n/** The component stack React reports, trimmed (it rides in the error's 64 KB detail). */\nconst stackOf = (info: { componentStack?: string | null } | undefined) => (info?.componentStack ?? \"\").slice(0, 8000);\n\n/** The given client, else the provider's, else the live client `createGuidely()` made. Null when none is usable. */\nfunction liveClient(client: GuidelyClient | null | undefined): GuidelyClient | null {\n try {\n if (client && !client.getState().destroyed) return client;\n const current = GuidelyClient.get();\n return current && !current.getState().destroyed ? current : null;\n } catch {\n return null;\n }\n}\n\n/** `captureException`'s second argument. */\ntype Hint = CaptureContext & Record<string, unknown>;\n\ninterface Pending {\n error: unknown;\n ctx: Hint;\n done?: (eventId: string) => void;\n}\n\n/**\n * Errors thrown before any client exists: a render error in the provider's first render is caught\n * before the provider's effect creates the client. Sent by the next client the provider creates.\n */\nconst pending: Pending[] = [];\n\n/** Sends the errors kept while no client existed (called by `GuidelyProvider` once it has one). */\nexport function drainPendingErrors(client: GuidelyClient): void {\n for (const p of pending.splice(0)) {\n let eventId = \"\";\n try {\n eventId = client.captureException(p.error, p.ctx) || \"\";\n } catch {\n // never throw into the app\n }\n if (eventId) p.done?.(eventId);\n }\n}\n\n/**\n * Captures without ever throwing into the app; returns the event id (\"\" when nothing was sent, or\n * when the error waits for a client, in which case `done` gets the id later).\n */\nfunction capture(client: GuidelyClient | null, error: unknown, ctx: Hint, done?: (eventId: string) => void): string {\n if (error && typeof error === \"object\") {\n if (reported.has(error)) return \"\";\n reported.add(error);\n }\n const c = liveClient(client);\n if (!c) {\n if (pending.length < 10) pending.push({ error, ctx, done });\n return \"\";\n }\n try {\n return c.captureException(error, ctx) || \"\";\n } catch {\n return \"\";\n }\n}\n\nexport interface ErrorBoundaryFallbackProps {\n error: unknown;\n componentStack: string;\n /** The Guidely event id (\"\" when nothing was sent: error tracking off, no consent, filtered). */\n eventId: string;\n /** Clears the error and renders the children again. */\n resetError(): void;\n}\n\nexport interface GuidelyErrorBoundaryProps {\n children?: ReactNode;\n /** Rendered instead of the children after an error (an element, or a function of the error). Nothing is rendered without one. */\n fallback?: ReactNode | ((props: ErrorBoundaryFallbackProps) => ReactNode);\n /** Called after the error is reported (`eventId` is \"\" when it waits for the provider's client, or was not sent). */\n onError?: (error: unknown, componentStack: string, eventId: string) => void;\n /** Edit what is sent (`context.tags.area = \"checkout\"`), like Sentry's `beforeCapture(scope, …)`. */\n beforeCapture?: (context: CaptureContext, error: unknown, componentStack: string) => void;\n /** Called by `resetError()`, before the children render again. */\n onReset?: (error: unknown, componentStack: string, eventId: string) => void;\n /** Opens the bug-report dialog for the event, when this SDK version has one. */\n showDialog?: boolean;\n tags?: CaptureContext[\"tags\"];\n extra?: CaptureContext[\"extra\"];\n fingerprint?: string[];\n /** Default `error`. */\n level?: ErrorLevelName;\n /** Marks the error handled (default: true when a `fallback` is given, as Sentry does). */\n handled?: boolean;\n /** The client to report to (default: the `GuidelyProvider`'s, else the live `createGuidely()` client). */\n client?: GuidelyClient | null;\n}\n\ninterface BoundaryState {\n error: unknown;\n componentStack: string;\n eventId: string;\n}\n\nconst EMPTY: BoundaryState = { error: null, componentStack: \"\", eventId: \"\" };\n\n/**\n * Catches render errors in its children, reports them (`mechanism: react.errorboundary`) and\n * renders `fallback`. Works without a provider when a client was made with `createGuidely()`.\n *\n * ```tsx\n * <GuidelyErrorBoundary fallback={({ resetError }) => <button onClick={resetError}>Try again</button>} tags={{ area: \"checkout\" }}>\n * <Checkout />\n * </GuidelyErrorBoundary>\n * ```\n */\nexport class GuidelyErrorBoundary extends Component<GuidelyErrorBoundaryProps, BoundaryState & { failed: boolean }> {\n static override contextType = GuidelyContext;\n declare context: GuidelyClient | null;\n override state = { ...EMPTY, failed: false };\n\n static getDerivedStateFromError(error: unknown): Partial<BoundaryState & { failed: boolean }> {\n return { error, failed: true };\n }\n\n override componentDidCatch(error: unknown, info: ErrorInfo): void {\n const { tags, extra, fingerprint, level, handled, fallback, beforeCapture, onError, showDialog } = this.props;\n const componentStack = stackOf(info);\n const ctx: Hint = {\n level: level ?? \"error\",\n ...(tags ? { tags: { ...tags } } : {}),\n ...(extra ? { extra: { ...extra } } : {}),\n ...(fingerprint ? { fingerprint } : {}),\n contexts: { react: { version, componentStack } },\n mechanism: { type: \"react.errorboundary\", handled: handled ?? !!fallback },\n };\n try {\n beforeCapture?.(ctx, error, componentStack);\n } catch {\n // A throwing hook still reports the error as it was.\n }\n const client = this.props.client ?? this.context;\n const eventId = capture(client, error, ctx, (id) => {\n // Sent later, once the provider created its client: show the id if this error is still up.\n if (this.state.error === error) this.setState({ eventId: id });\n });\n this.setState({ componentStack, eventId });\n onError?.(error, componentStack, eventId);\n if (showDialog && eventId) {\n try {\n // The \"Report a bug\" dialog links the report to the page's last exception: this one.\n (liveClient(client) as unknown as { showBugReport?: () => void } | null)?.showBugReport?.();\n } catch {\n // No dialog: the error is reported all the same.\n }\n }\n }\n\n resetError = (): void => {\n const { error, componentStack, eventId } = this.state;\n this.props.onReset?.(error, componentStack, eventId);\n this.setState({ ...EMPTY, failed: false });\n };\n\n override render(): ReactNode {\n if (!this.state.failed) return this.props.children;\n const { fallback } = this.props;\n if (typeof fallback === \"function\") return fallback({ error: this.state.error, componentStack: this.state.componentStack, eventId: this.state.eventId, resetError: this.resetError });\n return fallback ?? null;\n }\n}\n\n/** Wraps a component in a `GuidelyErrorBoundary` (Sentry's `withErrorBoundary`). */\nexport function withGuidelyErrorBoundary<P extends object>(Wrapped: ComponentType<P>, options: Omit<GuidelyErrorBoundaryProps, \"children\"> = {}): ComponentType<P> {\n const name = Wrapped.displayName || Wrapped.name || \"Component\";\n const WithBoundary = (props: P) => (\n <GuidelyErrorBoundary {...options}>\n <Wrapped {...props} />\n </GuidelyErrorBoundary>\n );\n WithBoundary.displayName = `guidelyErrorBoundary(${name})`;\n return WithBoundary;\n}\n\n/**\n * Reports `error` once (per error object) when it is set: for error pages that receive the error as\n * a prop, such as Next.js `error.tsx` or React Router's `errorElement`. Returns the event id.\n */\nexport function useCaptureException(error: unknown, hint?: Hint): string {\n const client = useContext(GuidelyContext);\n const [eventId, setEventId] = useState(\"\");\n useEffect(() => {\n if (error === null || error === undefined) return;\n const id = capture(client, error, { ...(hint ?? {}), mechanism: hint?.mechanism ?? { type: \"react.errorpage\", handled: true } }, setEventId);\n if (id) setEventId(id);\n // The hint is read once per error; changing it alone does not report again.\n }, [client, error]);\n return eventId;\n}\n\n/** What React 19 passes to `onUncaughtError` / `onCaughtError` / `onRecoverableError`. */\nexport interface ReactErrorInfo {\n componentStack?: string | null;\n /** `onCaughtError` only: the boundary that caught the error. */\n errorBoundary?: unknown;\n}\n\n/**\n * React 19 root error hooks (Sentry's `reactErrorHandler`):\n *\n * ```ts\n * createRoot(el, {\n * onUncaughtError: guidelyReactErrorHandler(),\n * onCaughtError: guidelyReactErrorHandler(),\n * onRecoverableError: guidelyReactErrorHandler(),\n * });\n * ```\n *\n * Errors caught by a boundary are reported as handled; errors a `GuidelyErrorBoundary` caught are\n * left to it. The client defaults to the live `createGuidely()` / provider client at the time of\n * the error. `callback` replaces React's default logging (the error is `console.error`ed without one).\n */\nexport function guidelyReactErrorHandler(client?: GuidelyClient | null, callback?: (error: unknown, errorInfo: ReactErrorInfo, eventId: string) => void): (error: unknown, errorInfo?: ReactErrorInfo) => void {\n return (error, errorInfo = {}) => {\n let eventId = \"\";\n if (!(errorInfo.errorBoundary instanceof GuidelyErrorBoundary)) {\n const caught = errorInfo.errorBoundary !== undefined && errorInfo.errorBoundary !== null;\n eventId = capture(client ?? null, error, { contexts: { react: { version, componentStack: stackOf(errorInfo) } }, mechanism: { type: \"react\", handled: caught } });\n }\n if (callback) callback(error, errorInfo, eventId);\n else console.error(error);\n };\n}\n","import { createFlagsClient, createStaticFlags, jsonEquals, stableStringify, type Attributes, type FlagDetails, type FlagValue, type FlagsBootstrap, type FlagsClient, type FlagsClientOptions, type FlagsReader, type JsonValue } from \"@guidelytech/flags\";\nimport { createContext, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode } from \"react\";\n\n/** What the flag hooks read: the live client once created, else a static snapshot of the bootstrap payload. */\nexport interface FlagsSource {\n client: FlagsClient | null;\n bootstrap: FlagsReader;\n}\n\nexport const FlagsContext = createContext<FlagsSource | null>(null);\n\nconst EMPTY = createStaticFlags();\n\nfunction useReader(): FlagsReader {\n const src = useContext(FlagsContext);\n return src?.client ?? src?.bootstrap ?? EMPTY;\n}\n\n/**\n * Subscribes to the flags with `useSyncExternalStore`. Values are compared deeply so object\n * flags keep their identity between renders. The server snapshot is the bootstrap payload, so\n * server-rendered HTML and hydration agree.\n */\nfunction useFlagsValue<T>(select: (reader: FlagsReader) => T): T {\n const reader = useReader();\n const cache = useRef<{ reader: FlagsReader; value: T } | null>(null);\n const get = () => {\n const value = select(reader);\n const c = cache.current;\n if (c && c.reader === reader && jsonEquals(c.value, value)) return c.value;\n cache.current = { reader, value };\n return value;\n };\n return useSyncExternalStore(reader.subscribe, get, get);\n}\n\n/** Is the boolean flag on? `fallback` (default `false`) until flags load, or when missing. */\nexport function useFlag(key: string, fallback = false): boolean {\n return useFlagsValue((r) => r.isEnabled(key, fallback));\n}\n\n/** A flag's value (string, number, JSON…); `fallback` when missing or of a different type. */\nexport function useFeatureValue<T extends JsonValue>(key: string, fallback: T): FlagValue<T> {\n return useFlagsValue((r) => r.getValue(key, fallback));\n}\n\n/** A flag's value plus why it was served (reason, rule, variation, experiment). */\nexport function useFlagDetails<T extends JsonValue>(key: string, fallback: T): FlagDetails<FlagValue<T>> {\n return useFlagsValue((r) => r.getDetails(key, fallback));\n}\n\n/** Every flag's value (records no exposures). */\nexport function useFlags(): Record<string, JsonValue> {\n return useFlagsValue((r) => r.getAll());\n}\n\n/** True once flags have loaded (or failed to and serve fallbacks); true from the start with a bootstrap payload. */\nexport function useFlagsReady(): boolean {\n return useFlagsValue((r) => r.isReady());\n}\n\n/** The flags client (`null` on the server and before the provider has created it). */\nexport function useFlagsClient(): FlagsClient | null {\n return useContext(FlagsContext)?.client ?? null;\n}\n\nexport interface FeatureProps {\n flag: string;\n children?: ReactNode;\n /** Rendered while the flag is off (default: nothing). */\n fallback?: ReactNode;\n}\n\n/** Renders `children` when the boolean flag is on, else `fallback`. */\nexport function Feature({ flag, children, fallback = null }: FeatureProps) {\n return <>{useFlag(flag) ? children : fallback}</>;\n}\n\n/** Alias of {@link Feature}. */\nexport const FeatureFlag = Feature;\n\nexport interface FeatureValueProps extends FeatureProps {\n /** Renders `children` when the flag's value equals this (deep equality). */\n value: JsonValue;\n}\n\n/** Renders `children` when the flag's value equals `value` (e.g. an experiment variation), else `fallback`. */\nexport function FeatureValue({ flag, value, children, fallback = null }: FeatureValueProps) {\n const current = useFeatureValue<JsonValue>(flag, null);\n return <>{jsonEquals(current, value) ? children : fallback}</>;\n}\n\n/** A static snapshot for SSR and hydration, rebuilt only when the payload or attributes change. */\nexport function useBootstrap(payload: FlagsBootstrap | null | undefined, attributes: Attributes): FlagsReader {\n const key = stableStringify(attributes);\n return useMemo(() => (payload ? createStaticFlags({ payload, attributes }) : EMPTY), [payload, key]);\n}\n\nexport interface FlagsProviderProps extends Omit<FlagsClientOptions, \"payload\"> {\n /** Bootstrap from the server (`getPayload()`): renders the same values on the server and in the browser. */\n payload?: FlagsBootstrap | null;\n /** Use an existing client instead of creating one. */\n client?: FlagsClient;\n children?: ReactNode;\n}\n\n/**\n * Feature flags only (no guides or analytics). Creates a flags client in an effect (never during\n * SSR) and destroys it on unmount; until then hooks read the `payload` snapshot. Changing\n * `attributes` re-evaluates without recreating the client.\n *\n * ```tsx\n * <FlagsProvider sdkKey=\"pk_prod_…\" attributes={{ id: user.id, plan: user.plan }} payload={bootstrap}>\n * ```\n */\nexport function FlagsProvider({ children, client: external, payload, ...options }: FlagsProviderProps) {\n const [created, setCreated] = useState<FlagsClient | null>(null);\n const optionsRef = useRef(options);\n optionsRef.current = options;\n const sdkKey = options.sdkKey ?? options.projectId;\n const { apiUrl, environment } = options;\n const payloadRef = useRef(payload);\n payloadRef.current = payload;\n\n useEffect(() => {\n if (external || !sdkKey || typeof window === \"undefined\") return;\n let c: FlagsClient;\n try {\n c = createFlagsClient({ ...optionsRef.current, sdkKey, payload: payloadRef.current ?? undefined });\n } catch (err) {\n optionsRef.current.onError?.(err instanceof Error ? err : new Error(String(err)));\n return;\n }\n setCreated(c);\n return () => {\n c.destroy();\n setCreated((cur) => (cur === c ? null : cur));\n };\n }, [external, sdkKey, apiUrl, environment]);\n\n const client = external ?? created;\n const attributes = options.attributes ?? {};\n const attrsKey = stableStringify(attributes);\n useEffect(() => {\n if (client && options.attributes) client.setAttributes(options.attributes);\n }, [client, attrsKey]);\n\n const bootstrap = useBootstrap(payload, attributes);\n const value = useMemo<FlagsSource>(() => ({ client, bootstrap }), [client, bootstrap]);\n return <FlagsContext.Provider value={value}>{children}</FlagsContext.Provider>;\n}\n"],"mappings":";;;;;;AAAA,SAAS,qBAAAA,oBAAmB,mBAAAC,wBAAiG;AAC7H,SAAS,qBAAsJ;AAC/J,SAAS,cAAAC,aAAY,aAAAC,YAAW,WAAAC,UAAS,UAAAC,SAAQ,YAAAC,iBAAgC;;;ACDjF,SAAS,qBAAqB;AAGvB,IAAM,iBAAiB,cAAoC,IAAI;;;ACJtE,SAAS,qBAA+D;AACxE,SAAS,WAAW,YAAY,WAAW,UAAU,eAAmE;AA0LlH;AAhLN,IAAM,WAAW,oBAAI,QAAgB;AAGrC,IAAM,UAAU,CAAC,UAA0D,MAAM,kBAAkB,IAAI,MAAM,GAAG,GAAI;AAGpH,SAAS,WAAW,QAAgE;AAClF,MAAI;AACF,QAAI,UAAU,CAAC,OAAO,SAAS,EAAE,UAAW,QAAO;AACnD,UAAM,UAAU,cAAc,IAAI;AAClC,WAAO,WAAW,CAAC,QAAQ,SAAS,EAAE,YAAY,UAAU;AAAA,EAC9D,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAeA,IAAM,UAAqB,CAAC;AAGrB,SAAS,mBAAmB,QAA6B;AAC9D,aAAW,KAAK,QAAQ,OAAO,CAAC,GAAG;AACjC,QAAI,UAAU;AACd,QAAI;AACF,gBAAU,OAAO,iBAAiB,EAAE,OAAO,EAAE,GAAG,KAAK;AAAA,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,eAAe,cAAc,kBAAkB,iBAAiB,YAAY,EAAY,IAAI,CAAC,MAAM,OAAO,GAAG,GAAG,OAAO,CAAC;AAC5J,WAAO,MAAM,KAAK,QAAQ,CAAC,QAAQ,IAAI,CAAC;AAAA,EAC1C,GAAG,CAAC,QAAQ,OAAO,CAAC;AACpB,SAAO;AACT;","names":["createStaticFlags","stableStringify","useContext","useEffect","useMemo","useRef","useState","createContext","useContext","useEffect","useState","jsx","EMPTY","jsx","useState","useRef","useMemo","stableStringify","useEffect","createStaticFlags","useContext"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guidelytech/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "React provider and hooks for Guidely",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -20,15 +20,15 @@
|
|
|
20
20
|
"README.md"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@guidelytech/flags": "0.
|
|
24
|
-
"@guidelytech/sdk-core": "0.
|
|
25
|
-
"@guidelytech/shared": "0.
|
|
23
|
+
"@guidelytech/flags": "0.17.0",
|
|
24
|
+
"@guidelytech/sdk-core": "0.17.0",
|
|
25
|
+
"@guidelytech/shared": "0.17.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"tsup": "^8.5.1",
|
|
29
29
|
"typescript": "^5.9.3",
|
|
30
|
-
"vitest": "^
|
|
31
|
-
"happy-dom": "^
|
|
30
|
+
"vitest": "^4.1.12",
|
|
31
|
+
"happy-dom": "^21.0.4",
|
|
32
32
|
"eslint": "^9.39.5",
|
|
33
33
|
"@eslint/js": "^9.39.5",
|
|
34
34
|
"typescript-eslint": "^8.46.0",
|