@verbumia/feedback 0.2.5 → 0.2.6
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/dist/{chunk-5DZUKJ4M.js → chunk-5RTFWOGT.js} +17 -1
- package/dist/chunk-5RTFWOGT.js.map +1 -0
- package/dist/{client-CYgwLkiA.d.cts → client-qgDSbz3A.d.cts} +12 -0
- package/dist/{client-CYgwLkiA.d.ts → client-qgDSbz3A.d.ts} +12 -0
- package/dist/core/index.cjs +16 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +1 -1
- package/dist/{keys-BQpczt84.d.cts → keys-BhuK_fy1.d.cts} +1 -1
- package/dist/{keys-BPAFf8xR.d.ts → keys-CEWu0Htb.d.ts} +1 -1
- package/dist/native/index.cjs +23 -1
- package/dist/native/index.cjs.map +1 -1
- package/dist/native/index.d.cts +11 -3
- package/dist/native/index.d.ts +11 -3
- package/dist/native/index.js +8 -2
- package/dist/native/index.js.map +1 -1
- package/dist/react/index.cjs +23 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +19 -4
- package/dist/react/index.d.ts +19 -4
- package/dist/react/index.js +8 -2
- package/dist/react/index.js.map +1 -1
- package/dist/svelte/index.cjs +16 -0
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.d.cts +2 -2
- package/dist/svelte/index.d.ts +2 -2
- package/dist/svelte/index.js +1 -1
- package/dist/vue/index.cjs +16 -0
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.cts +2 -2
- package/dist/vue/index.d.ts +2 -2
- package/dist/vue/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-5DZUKJ4M.js.map +0 -1
package/dist/native/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { F as FeedbackClient, D as DeclaredKey } from '../client-
|
|
3
|
-
export { B as BatchResponse, a as FeedbackConfig, b as FeedbackError, c as FeedbackString, R as RatingInput, S as StringsResponse, d as SuggestionInput, T as TokenBundle } from '../client-
|
|
2
|
+
import { F as FeedbackClient, D as DeclaredKey } from '../client-qgDSbz3A.cjs';
|
|
3
|
+
export { B as BatchResponse, a as FeedbackConfig, b as FeedbackError, c as FeedbackString, R as RatingInput, S as StringsResponse, d as SuggestionInput, T as TokenBundle } from '../client-qgDSbz3A.cjs';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
-
export { h as hasKeyRegistry, r as resolveKeys } from '../keys-
|
|
5
|
+
export { h as hasKeyRegistry, r as resolveKeys } from '../keys-BhuK_fy1.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* `@verbumia/feedback` (React Native / Expo) as a PLUGIN of the
|
|
@@ -14,11 +14,19 @@ export { h as hasKeyRegistry, r as resolveKeys } from '../keys-BQpczt84.cjs';
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
interface I18nPluginContext {
|
|
17
|
+
i18n?: {
|
|
18
|
+
language?: string;
|
|
19
|
+
};
|
|
17
20
|
config: {
|
|
18
21
|
apiBase?: string;
|
|
19
22
|
projectUuid: string;
|
|
20
23
|
defaultLocale: string;
|
|
21
24
|
};
|
|
25
|
+
/** #806 — subscribe to runtime language changes (see
|
|
26
|
+
* VerbumiaPluginContext in `@verbumia/react-i18next` ≥1.0.5). Returns
|
|
27
|
+
* an unsubscribe fn the plugin MUST call from teardown. Optional so a
|
|
28
|
+
* pre-1.0.5 react-i18next falls back gracefully. */
|
|
29
|
+
onLanguageChange?: (cb: (lng: string) => void) => () => void;
|
|
22
30
|
}
|
|
23
31
|
interface I18nPlugin {
|
|
24
32
|
name: string;
|
package/dist/native/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { F as FeedbackClient, D as DeclaredKey } from '../client-
|
|
3
|
-
export { B as BatchResponse, a as FeedbackConfig, b as FeedbackError, c as FeedbackString, R as RatingInput, S as StringsResponse, d as SuggestionInput, T as TokenBundle } from '../client-
|
|
2
|
+
import { F as FeedbackClient, D as DeclaredKey } from '../client-qgDSbz3A.js';
|
|
3
|
+
export { B as BatchResponse, a as FeedbackConfig, b as FeedbackError, c as FeedbackString, R as RatingInput, S as StringsResponse, d as SuggestionInput, T as TokenBundle } from '../client-qgDSbz3A.js';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
-
export { h as hasKeyRegistry, r as resolveKeys } from '../keys-
|
|
5
|
+
export { h as hasKeyRegistry, r as resolveKeys } from '../keys-CEWu0Htb.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* `@verbumia/feedback` (React Native / Expo) as a PLUGIN of the
|
|
@@ -14,11 +14,19 @@ export { h as hasKeyRegistry, r as resolveKeys } from '../keys-BPAFf8xR.js';
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
interface I18nPluginContext {
|
|
17
|
+
i18n?: {
|
|
18
|
+
language?: string;
|
|
19
|
+
};
|
|
17
20
|
config: {
|
|
18
21
|
apiBase?: string;
|
|
19
22
|
projectUuid: string;
|
|
20
23
|
defaultLocale: string;
|
|
21
24
|
};
|
|
25
|
+
/** #806 — subscribe to runtime language changes (see
|
|
26
|
+
* VerbumiaPluginContext in `@verbumia/react-i18next` ≥1.0.5). Returns
|
|
27
|
+
* an unsubscribe fn the plugin MUST call from teardown. Optional so a
|
|
28
|
+
* pre-1.0.5 react-i18next falls back gracefully. */
|
|
29
|
+
onLanguageChange?: (cb: (lng: string) => void) => () => void;
|
|
22
30
|
}
|
|
23
31
|
interface I18nPlugin {
|
|
24
32
|
name: string;
|
package/dist/native/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
__require,
|
|
6
6
|
hasKeyRegistry,
|
|
7
7
|
resolveKeys
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-5RTFWOGT.js";
|
|
9
9
|
|
|
10
10
|
// src/native/plugin.tsx
|
|
11
11
|
import { useSyncExternalStore } from "react";
|
|
@@ -323,13 +323,18 @@ function feedbackPlugin(options) {
|
|
|
323
323
|
return {
|
|
324
324
|
name: "@verbumia/feedback",
|
|
325
325
|
setup(ctx) {
|
|
326
|
+
const initialLanguage = options.language ?? ctx.i18n?.language ?? ctx.config.defaultLocale;
|
|
326
327
|
client = new FeedbackClient({
|
|
327
328
|
apiBase: options.apiBase ?? ctx.config.apiBase ?? "https://api.verbumia.dev",
|
|
328
329
|
projectId: options.projectId ?? ctx.config.projectUuid,
|
|
329
|
-
language:
|
|
330
|
+
language: initialLanguage,
|
|
330
331
|
endUserId: options.endUserId,
|
|
331
332
|
fetchImpl: options.fetchImpl
|
|
332
333
|
});
|
|
334
|
+
let langUnsub;
|
|
335
|
+
if (typeof ctx.onLanguageChange === "function") {
|
|
336
|
+
langUnsub = ctx.onLanguageChange((lng) => client?.setLanguage(lng));
|
|
337
|
+
}
|
|
333
338
|
const controller = {
|
|
334
339
|
open: () => store.set(true),
|
|
335
340
|
close: () => {
|
|
@@ -341,6 +346,7 @@ function feedbackPlugin(options) {
|
|
|
341
346
|
options.onReady?.(controller);
|
|
342
347
|
if (options.controllerRef) options.controllerRef.current = controller;
|
|
343
348
|
return () => {
|
|
349
|
+
langUnsub?.();
|
|
344
350
|
if (options.controllerRef) options.controllerRef.current = null;
|
|
345
351
|
void client?.flush();
|
|
346
352
|
};
|
package/dist/native/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/native/plugin.tsx","../../src/native/panel.tsx"],"sourcesContent":["/**\n * `@verbumia/feedback` (React Native / Expo) as a PLUGIN of the\n * `@verbumia/*-i18n` provider — same architecture as the web plugin\n * (task 599): no second context; isolated sibling outlet; imperative\n * controller for the host CTA; sessionId is server-minted. Native uses\n * an RN <Modal> (its own overlay) toggled by a private store, so the\n * host app never re-renders when feedback opens.\n */\nimport { useSyncExternalStore, type ReactNode } from \"react\";\n\nimport { FeedbackClient } from \"../core/client\";\nimport type { DeclaredKey } from \"../core/types\";\nimport { FeedbackModal } from \"./panel\";\n\nexport interface I18nPluginContext {\n config: {\n apiBase?: string;\n projectUuid: string;\n defaultLocale: string;\n };\n}\nexport interface I18nPlugin {\n name: string;\n setup?: (ctx: I18nPluginContext) => void | (() => void);\n render?: () => ReactNode;\n}\n\nexport interface FeedbackController {\n open: () => void;\n close: () => void;\n client: FeedbackClient;\n}\n\nexport interface FeedbackPluginOptions {\n // No `tosVersion` — SDK build-time constant (SDK_TOS_VERSION, task 616).\n language?: string;\n apiBase?: string;\n projectId?: string;\n endUserId?: string;\n keys?: DeclaredKey[];\n /** Optional namespace filter (CONTRACT v6, additive). Single ns or\n * list; applied AFTER rendered-scoping (`rendered ∩ namespace`).\n * Unset ⇒ all resolved keys (v5 behaviour). */\n namespace?: string | string[];\n onReady?: (controller: FeedbackController) => void;\n controllerRef?: { current: FeedbackController | null };\n fetchImpl?: typeof fetch;\n}\n\nfunction makeStore() {\n let open = false;\n const listeners = new Set<() => void>();\n return {\n isOpen: () => open,\n set(v: boolean) {\n if (open !== v) {\n open = v;\n listeners.forEach((l) => l());\n }\n },\n subscribe(l: () => void) {\n listeners.add(l);\n return () => listeners.delete(l);\n },\n };\n}\n\nexport function feedbackPlugin(options: FeedbackPluginOptions): I18nPlugin {\n const store = makeStore();\n let client: FeedbackClient | null = null;\n\n function Outlet() {\n const isOpen = useSyncExternalStore(\n store.subscribe,\n store.isOpen,\n store.isOpen,\n );\n if (!client) return null;\n const c = client;\n return (\n <FeedbackModal\n client={c}\n visible={isOpen}\n keys={options.keys}\n namespace={options.namespace}\n onClose={() => {\n store.set(false);\n void c.flush();\n }}\n />\n );\n }\n\n return {\n name: \"@verbumia/feedback\",\n setup(ctx) {\n client = new FeedbackClient({\n apiBase:\n options.apiBase ?? ctx.config.apiBase ?? \"https://api.verbumia.dev\",\n projectId: options.projectId ?? ctx.config.projectUuid,\n language: options.language ?? ctx.config.defaultLocale,\n endUserId: options.endUserId,\n fetchImpl: options.fetchImpl,\n });\n const controller: FeedbackController = {\n open: () => store.set(true),\n close: () => {\n store.set(false);\n void client?.flush();\n },\n client,\n };\n options.onReady?.(controller);\n if (options.controllerRef) options.controllerRef.current = controller;\n return () => {\n if (options.controllerRef) options.controllerRef.current = null;\n void client?.flush();\n };\n },\n render: () => <Outlet />,\n };\n}\n","import { createElement, useCallback, useEffect, useState, type ComponentType, type ReactNode } from \"react\";\nimport {\n KeyboardAvoidingView,\n Modal,\n Platform,\n ScrollView,\n Text,\n TextInput,\n TouchableOpacity,\n View,\n} from \"react-native\";\n\nimport type { FeedbackClient } from \"../core/client\";\nimport { resolveKeys } from \"../core/keys\";\nimport type { DeclaredKey, FeedbackString } from \"../core/types\";\n\n/**\n * Soft-resolve `react-native-safe-area-context`'s `SafeAreaView` (#806\n * SeedSower Android panel-layout bug). When the host installed it (Expo\n * apps ship it by default; bare RN apps that follow the standard setup do\n * too), the panel's bottom edge respects the system gesture bar / home\n * indicator. When it isn't installed (web bundles, RN apps that opted\n * out), fall back to a plain `View` — same children, same style, no\n * insets. The dependency is listed as an OPTIONAL `peerDependency` so the\n * npm install never warns on web-only consumers.\n */\ntype SafeAreaProps = { edges?: ReadonlyArray<string>; style?: unknown; children?: ReactNode };\n// Local `require` declaration so we don't pull @types/node into this\n// package. Metro / Node both inject `require` at module scope; in the\n// ESM build path tsup polyfills it via createRequire(import.meta.url).\ndeclare const require: (id: string) => unknown;\nlet SafeAreaView: ComponentType<SafeAreaProps>;\ntry {\n const mod = require(\"react-native-safe-area-context\") as {\n SafeAreaView: ComponentType<SafeAreaProps>;\n };\n SafeAreaView = mod.SafeAreaView;\n} catch {\n SafeAreaView = ({ children, style }: SafeAreaProps) =>\n createElement(\n View as ComponentType<{ style?: unknown; children?: ReactNode }>,\n { style },\n children,\n );\n}\n\nconst C = {\n bg: \"#0b0f0e\",\n panel: \"#111714\",\n border: \"#1f2a25\",\n text: \"#e7f5ef\",\n dim: \"#8aa79b\",\n emerald: \"#10b981\",\n emeraldSoft: \"#34d399\",\n};\n\nexport function FeedbackModal(props: {\n client: FeedbackClient;\n visible: boolean;\n keys?: DeclaredKey[];\n namespace?: string | string[];\n onClose: () => void;\n}) {\n const { client, visible, keys, namespace, onClose } = props;\n const [consented, setConsented] = useState(client.hasConsented);\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [strings, setStrings] = useState<FeedbackString[]>([]);\n\n const loadStrings = useCallback(async () => {\n setBusy(true);\n setError(null);\n try {\n // On-screen scoping is NORMATIVE (spec ltm 373, CONTRACT v5): show\n // ONLY rendered keys. Empty -> \"no strings on this view\"; never\n // fall back to fetching the whole project.\n const resolved = resolveKeys(keys, namespace);\n if (!resolved.length) {\n // #806 SeedSower P1 — same diagnostic as the web panel: an empty\n // registry resolve with no explicit `keys` prop almost always\n // means the host's `useTranslation` imports went to\n // `react-i18next` instead of `@verbumia/react-i18next`.\n if (!keys || keys.length === 0) {\n // eslint-disable-next-line no-console\n console.warn(\n \"[verbumia/feedback] registry empty — are your useTranslation imports coming from @verbumia/react-i18next?\",\n );\n }\n setStrings([]);\n return;\n }\n const res = await client.getStrings({ keys: resolved });\n setStrings(res.strings);\n } catch (e) {\n setError(e instanceof Error ? e.message : \"Failed to load strings\");\n } finally {\n setBusy(false);\n }\n }, [client, keys, namespace]);\n\n useEffect(() => {\n if (visible && consented) void loadStrings();\n }, [visible, consented, loadStrings]);\n\n const accept = useCallback(async () => {\n setBusy(true);\n try {\n await client.acceptTos();\n setConsented(true);\n } catch (e) {\n setError(e instanceof Error ? e.message : \"Could not accept the terms\");\n } finally {\n setBusy(false);\n }\n }, [client]);\n\n return (\n <Modal\n visible={visible}\n transparent\n animationType=\"slide\"\n onRequestClose={onClose}\n >\n {/*\n #806 SeedSower native panel layout — KeyboardAvoidingView wraps the\n whole overlay so the suggestion TextInput isn't covered by the soft\n keyboard. `padding` on iOS / `height` on Android matches the RN\n community convention; flex:1 keeps the overlay full-screen above\n the keyboard reservation.\n */}\n <KeyboardAvoidingView\n style={{ flex: 1 }}\n behavior={Platform.OS === \"ios\" ? \"padding\" : \"height\"}\n >\n <View style={{ flex: 1, backgroundColor: \"rgba(0,0,0,.55)\", justifyContent: \"flex-end\" }}>\n {/*\n Panel sizing — `height:'85%'` gives a CONCRETE 85% of the\n modal's parent (the full-screen overlay), which is what the\n ToS step / strings ScrollView need to flex against. The prior\n `maxHeight:'85%'` was a ceiling only: without a height/flex\n child, the panel collapsed to its ToS intrinsic content (~15%\n of screen) on RN 0.77.3 Android. `maxHeight` is kept as a\n backstop in case a future child wants to render shorter (it\n never exceeds 85%; it can render shorter if the content does).\n\n SafeAreaView edges={['bottom']} keeps the CTA off the Android\n gesture bar / iOS home indicator. Falls back to plain View\n when react-native-safe-area-context isn't installed.\n */}\n <SafeAreaView\n edges={[\"bottom\"]}\n style={{\n height: \"85%\",\n maxHeight: \"85%\",\n backgroundColor: C.bg,\n borderTopWidth: 1,\n borderColor: C.border,\n }}\n >\n <View style={{ flex: 1, padding: 18 }}>\n <View\n style={{\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 12,\n }}\n >\n <Text style={{ color: C.emeraldSoft, fontWeight: \"700\", fontSize: 16 }}>\n Translation feedback\n </Text>\n <TouchableOpacity onPress={onClose} accessibilityLabel=\"Close\">\n <Text style={{ color: C.dim, fontSize: 20 }}>×</Text>\n </TouchableOpacity>\n </View>\n\n {error ? (\n <Text style={{ color: \"#f87171\", marginBottom: 8 }}>{error}</Text>\n ) : null}\n\n {!consented ? (\n <View>\n <Text style={{ color: C.text, lineHeight: 21 }}>\n Help improve the translations in this app. Your ratings and\n suggestions are sent to the app owner via Verbumia. Don’t\n submit personal or sensitive information.\n </Text>\n <TouchableOpacity\n disabled={busy}\n onPress={accept}\n style={{\n marginTop: 14,\n backgroundColor: C.emerald,\n borderRadius: 8,\n padding: 14,\n }}\n >\n <Text style={{ color: \"#03110c\", fontWeight: \"700\", textAlign: \"center\" }}>\n {busy ? \"…\" : `I accept the terms (v${client.tosVersion})`}\n </Text>\n </TouchableOpacity>\n </View>\n ) : (\n // flex:1 makes the ScrollView fill the remaining panel\n // height after the header; without it the list collapsed\n // to its intrinsic height and the panel left a large empty\n // area below the last row (the second half of the\n // SeedSower repro).\n <ScrollView style={{ flex: 1 }}>\n {!strings.length ? (\n <Text style={{ color: C.dim }}>\n {busy ? \"Loading…\" : \"No strings to review on this view.\"}\n </Text>\n ) : (\n strings.map((s) => (\n <StringRow\n key={`${s.namespace}:${s.key}`}\n s={s}\n client={client}\n />\n ))\n )}\n </ScrollView>\n )}\n </View>\n </SafeAreaView>\n </View>\n </KeyboardAvoidingView>\n </Modal>\n );\n}\n\nfunction StringRow(props: { s: FeedbackString; client: FeedbackClient }) {\n const { s, client } = props;\n const [mine, setMine] = useState<number | null>(s.my_rating);\n const [show, setShow] = useState(false);\n const [text, setText] = useState(\"\");\n const [sent, setSent] = useState(false);\n\n return (\n <View\n style={{\n backgroundColor: C.panel,\n borderWidth: 1,\n borderColor: C.border,\n borderRadius: 10,\n padding: 12,\n marginBottom: 10,\n }}\n >\n <Text style={{ color: C.dim, fontSize: 12 }}>\n {s.namespace} · {s.key}\n </Text>\n <Text style={{ color: C.text, fontSize: 15, marginVertical: 6 }}>\n {s.value}\n </Text>\n <View style={{ flexDirection: \"row\" }}>\n {[1, 2, 3, 4, 5].map((n) => (\n <TouchableOpacity\n key={n}\n accessibilityLabel={`${n} stars`}\n onPress={() => {\n setMine(n);\n client.rate({\n namespace: s.namespace,\n key: s.key,\n language: client.language,\n translation_hash: s.translation_hash,\n stars: n,\n });\n }}\n >\n <Text\n style={{\n fontSize: 22,\n marginRight: 4,\n color: mine && n <= mine ? C.emeraldSoft : C.border,\n }}\n >\n ★\n </Text>\n </TouchableOpacity>\n ))}\n <TouchableOpacity\n onPress={() => setShow(!show)}\n style={{ marginLeft: \"auto\" }}\n >\n <Text style={{ color: C.emeraldSoft }}>\n {sent ? \"Suggested ✓\" : \"Suggest\"}\n </Text>\n </TouchableOpacity>\n </View>\n {show ? (\n <View style={{ marginTop: 10 }}>\n <TextInput\n value={text}\n onChangeText={setText}\n multiline\n numberOfLines={3}\n placeholder=\"Your suggested translation…\"\n placeholderTextColor={C.dim}\n style={{\n backgroundColor: C.bg,\n color: C.text,\n borderWidth: 1,\n borderColor: C.border,\n borderRadius: 6,\n padding: 8,\n }}\n />\n <TouchableOpacity\n onPress={() => {\n if (!text.trim()) return;\n client.suggest({\n namespace: s.namespace,\n key: s.key,\n language: client.language,\n translation_hash: s.translation_hash,\n suggested_text: text.trim(),\n });\n setSent(true);\n setShow(false);\n setText(\"\");\n }}\n style={{\n marginTop: 6,\n backgroundColor: C.emerald,\n borderRadius: 6,\n padding: 10,\n }}\n >\n <Text style={{ color: \"#03110c\", fontWeight: \"700\", textAlign: \"center\" }}>\n Send suggestion\n </Text>\n </TouchableOpacity>\n </View>\n ) : null}\n </View>\n );\n}\n"],"mappings":";;;;;;;;;;AAQA,SAAS,4BAA4C;;;ACRrD,SAAS,eAAe,aAAa,WAAW,gBAAoD;AACpG;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAsJO,SAOE,KAPF;AAjId,IAAI;AACJ,IAAI;AACF,QAAM,MAAM,UAAQ,gCAAgC;AAGpD,iBAAe,IAAI;AACrB,QAAQ;AACN,iBAAe,CAAC,EAAE,UAAU,MAAM,MAChC;AAAA,IACE;AAAA,IACA,EAAE,MAAM;AAAA,IACR;AAAA,EACF;AACJ;AAEA,IAAM,IAAI;AAAA,EACR,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,KAAK;AAAA,EACL,SAAS;AAAA,EACT,aAAa;AACf;AAEO,SAAS,cAAc,OAM3B;AACD,QAAM,EAAE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AAS,MAAM;AACb,gBAAM,IAAI,KAAK;AACf,eAAK,EAAE,MAAM;AAAA,QACf;AAAA;AAAA,IACF;AAAA,EAEJ;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,KAAK;AACT,eAAS,IAAI,eAAe;AAAA,QAC1B,SACE,QAAQ,WAAW,IAAI,OAAO,WAAW;AAAA,QAC3C,WAAW,QAAQ,aAAa,IAAI,OAAO;AAAA,QAC3C,UAAU,QAAQ,YAAY,IAAI,OAAO;AAAA,QACzC,WAAW,QAAQ;AAAA,QACnB,WAAW,QAAQ;AAAA,MACrB,CAAC;AACD,YAAM,aAAiC;AAAA,QACrC,MAAM,MAAM,MAAM,IAAI,IAAI;AAAA,QAC1B,OAAO,MAAM;AACX,gBAAM,IAAI,KAAK;AACf,eAAK,QAAQ,MAAM;AAAA,QACrB;AAAA,QACA;AAAA,MACF;AACA,cAAQ,UAAU,UAAU;AAC5B,UAAI,QAAQ,cAAe,SAAQ,cAAc,UAAU;AAC3D,aAAO,MAAM;AACX,YAAI,QAAQ,cAAe,SAAQ,cAAc,UAAU;AAC3D,aAAK,QAAQ,MAAM;AAAA,MACrB;AAAA,IACF;AAAA,IACA,QAAQ,MAAM,gBAAAA,KAAC,UAAO;AAAA,EACxB;AACF;","names":["jsx"]}
|
|
1
|
+
{"version":3,"sources":["../../src/native/plugin.tsx","../../src/native/panel.tsx"],"sourcesContent":["/**\n * `@verbumia/feedback` (React Native / Expo) as a PLUGIN of the\n * `@verbumia/*-i18n` provider — same architecture as the web plugin\n * (task 599): no second context; isolated sibling outlet; imperative\n * controller for the host CTA; sessionId is server-minted. Native uses\n * an RN <Modal> (its own overlay) toggled by a private store, so the\n * host app never re-renders when feedback opens.\n */\nimport { useSyncExternalStore, type ReactNode } from \"react\";\n\nimport { FeedbackClient } from \"../core/client\";\nimport type { DeclaredKey } from \"../core/types\";\nimport { FeedbackModal } from \"./panel\";\n\nexport interface I18nPluginContext {\n i18n?: { language?: string };\n config: {\n apiBase?: string;\n projectUuid: string;\n defaultLocale: string;\n };\n /** #806 — subscribe to runtime language changes (see\n * VerbumiaPluginContext in `@verbumia/react-i18next` ≥1.0.5). Returns\n * an unsubscribe fn the plugin MUST call from teardown. Optional so a\n * pre-1.0.5 react-i18next falls back gracefully. */\n onLanguageChange?: (cb: (lng: string) => void) => () => void;\n}\nexport interface I18nPlugin {\n name: string;\n setup?: (ctx: I18nPluginContext) => void | (() => void);\n render?: () => ReactNode;\n}\n\nexport interface FeedbackController {\n open: () => void;\n close: () => void;\n client: FeedbackClient;\n}\n\nexport interface FeedbackPluginOptions {\n // No `tosVersion` — SDK build-time constant (SDK_TOS_VERSION, task 616).\n language?: string;\n apiBase?: string;\n projectId?: string;\n endUserId?: string;\n keys?: DeclaredKey[];\n /** Optional namespace filter (CONTRACT v6, additive). Single ns or\n * list; applied AFTER rendered-scoping (`rendered ∩ namespace`).\n * Unset ⇒ all resolved keys (v5 behaviour). */\n namespace?: string | string[];\n onReady?: (controller: FeedbackController) => void;\n controllerRef?: { current: FeedbackController | null };\n fetchImpl?: typeof fetch;\n}\n\nfunction makeStore() {\n let open = false;\n const listeners = new Set<() => void>();\n return {\n isOpen: () => open,\n set(v: boolean) {\n if (open !== v) {\n open = v;\n listeners.forEach((l) => l());\n }\n },\n subscribe(l: () => void) {\n listeners.add(l);\n return () => listeners.delete(l);\n },\n };\n}\n\nexport function feedbackPlugin(options: FeedbackPluginOptions): I18nPlugin {\n const store = makeStore();\n let client: FeedbackClient | null = null;\n\n function Outlet() {\n const isOpen = useSyncExternalStore(\n store.subscribe,\n store.isOpen,\n store.isOpen,\n );\n if (!client) return null;\n const c = client;\n return (\n <FeedbackModal\n client={c}\n visible={isOpen}\n keys={options.keys}\n namespace={options.namespace}\n onClose={() => {\n store.set(false);\n void c.flush();\n }}\n />\n );\n }\n\n return {\n name: \"@verbumia/feedback\",\n setup(ctx) {\n // #806 SeedSower lang-change init source — same precedence as the\n // /react plugin: explicit option, then current i18n language,\n // then boot defaultLocale.\n const initialLanguage =\n options.language ?? ctx.i18n?.language ?? ctx.config.defaultLocale;\n client = new FeedbackClient({\n apiBase:\n options.apiBase ?? ctx.config.apiBase ?? \"https://api.verbumia.dev\",\n projectId: options.projectId ?? ctx.config.projectUuid,\n language: initialLanguage,\n endUserId: options.endUserId,\n fetchImpl: options.fetchImpl,\n });\n // #806 — re-sync the client on runtime language changes. Optional;\n // missing field on a non-Verbumia host falls back gracefully.\n let langUnsub: (() => void) | undefined;\n if (typeof ctx.onLanguageChange === \"function\") {\n langUnsub = ctx.onLanguageChange((lng) => client?.setLanguage(lng));\n }\n const controller: FeedbackController = {\n open: () => store.set(true),\n close: () => {\n store.set(false);\n void client?.flush();\n },\n client,\n };\n options.onReady?.(controller);\n if (options.controllerRef) options.controllerRef.current = controller;\n return () => {\n langUnsub?.();\n if (options.controllerRef) options.controllerRef.current = null;\n void client?.flush();\n };\n },\n render: () => <Outlet />,\n };\n}\n","import { createElement, useCallback, useEffect, useState, type ComponentType, type ReactNode } from \"react\";\nimport {\n KeyboardAvoidingView,\n Modal,\n Platform,\n ScrollView,\n Text,\n TextInput,\n TouchableOpacity,\n View,\n} from \"react-native\";\n\nimport type { FeedbackClient } from \"../core/client\";\nimport { resolveKeys } from \"../core/keys\";\nimport type { DeclaredKey, FeedbackString } from \"../core/types\";\n\n/**\n * Soft-resolve `react-native-safe-area-context`'s `SafeAreaView` (#806\n * SeedSower Android panel-layout bug). When the host installed it (Expo\n * apps ship it by default; bare RN apps that follow the standard setup do\n * too), the panel's bottom edge respects the system gesture bar / home\n * indicator. When it isn't installed (web bundles, RN apps that opted\n * out), fall back to a plain `View` — same children, same style, no\n * insets. The dependency is listed as an OPTIONAL `peerDependency` so the\n * npm install never warns on web-only consumers.\n */\ntype SafeAreaProps = { edges?: ReadonlyArray<string>; style?: unknown; children?: ReactNode };\n// Local `require` declaration so we don't pull @types/node into this\n// package. Metro / Node both inject `require` at module scope; in the\n// ESM build path tsup polyfills it via createRequire(import.meta.url).\ndeclare const require: (id: string) => unknown;\nlet SafeAreaView: ComponentType<SafeAreaProps>;\ntry {\n const mod = require(\"react-native-safe-area-context\") as {\n SafeAreaView: ComponentType<SafeAreaProps>;\n };\n SafeAreaView = mod.SafeAreaView;\n} catch {\n SafeAreaView = ({ children, style }: SafeAreaProps) =>\n createElement(\n View as ComponentType<{ style?: unknown; children?: ReactNode }>,\n { style },\n children,\n );\n}\n\nconst C = {\n bg: \"#0b0f0e\",\n panel: \"#111714\",\n border: \"#1f2a25\",\n text: \"#e7f5ef\",\n dim: \"#8aa79b\",\n emerald: \"#10b981\",\n emeraldSoft: \"#34d399\",\n};\n\nexport function FeedbackModal(props: {\n client: FeedbackClient;\n visible: boolean;\n keys?: DeclaredKey[];\n namespace?: string | string[];\n onClose: () => void;\n}) {\n const { client, visible, keys, namespace, onClose } = props;\n const [consented, setConsented] = useState(client.hasConsented);\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [strings, setStrings] = useState<FeedbackString[]>([]);\n\n const loadStrings = useCallback(async () => {\n setBusy(true);\n setError(null);\n try {\n // On-screen scoping is NORMATIVE (spec ltm 373, CONTRACT v5): show\n // ONLY rendered keys. Empty -> \"no strings on this view\"; never\n // fall back to fetching the whole project.\n const resolved = resolveKeys(keys, namespace);\n if (!resolved.length) {\n // #806 SeedSower P1 — same diagnostic as the web panel: an empty\n // registry resolve with no explicit `keys` prop almost always\n // means the host's `useTranslation` imports went to\n // `react-i18next` instead of `@verbumia/react-i18next`.\n if (!keys || keys.length === 0) {\n // eslint-disable-next-line no-console\n console.warn(\n \"[verbumia/feedback] registry empty — are your useTranslation imports coming from @verbumia/react-i18next?\",\n );\n }\n setStrings([]);\n return;\n }\n const res = await client.getStrings({ keys: resolved });\n setStrings(res.strings);\n } catch (e) {\n setError(e instanceof Error ? e.message : \"Failed to load strings\");\n } finally {\n setBusy(false);\n }\n }, [client, keys, namespace]);\n\n useEffect(() => {\n if (visible && consented) void loadStrings();\n }, [visible, consented, loadStrings]);\n\n const accept = useCallback(async () => {\n setBusy(true);\n try {\n await client.acceptTos();\n setConsented(true);\n } catch (e) {\n setError(e instanceof Error ? e.message : \"Could not accept the terms\");\n } finally {\n setBusy(false);\n }\n }, [client]);\n\n return (\n <Modal\n visible={visible}\n transparent\n animationType=\"slide\"\n onRequestClose={onClose}\n >\n {/*\n #806 SeedSower native panel layout — KeyboardAvoidingView wraps the\n whole overlay so the suggestion TextInput isn't covered by the soft\n keyboard. `padding` on iOS / `height` on Android matches the RN\n community convention; flex:1 keeps the overlay full-screen above\n the keyboard reservation.\n */}\n <KeyboardAvoidingView\n style={{ flex: 1 }}\n behavior={Platform.OS === \"ios\" ? \"padding\" : \"height\"}\n >\n <View style={{ flex: 1, backgroundColor: \"rgba(0,0,0,.55)\", justifyContent: \"flex-end\" }}>\n {/*\n Panel sizing — `height:'85%'` gives a CONCRETE 85% of the\n modal's parent (the full-screen overlay), which is what the\n ToS step / strings ScrollView need to flex against. The prior\n `maxHeight:'85%'` was a ceiling only: without a height/flex\n child, the panel collapsed to its ToS intrinsic content (~15%\n of screen) on RN 0.77.3 Android. `maxHeight` is kept as a\n backstop in case a future child wants to render shorter (it\n never exceeds 85%; it can render shorter if the content does).\n\n SafeAreaView edges={['bottom']} keeps the CTA off the Android\n gesture bar / iOS home indicator. Falls back to plain View\n when react-native-safe-area-context isn't installed.\n */}\n <SafeAreaView\n edges={[\"bottom\"]}\n style={{\n height: \"85%\",\n maxHeight: \"85%\",\n backgroundColor: C.bg,\n borderTopWidth: 1,\n borderColor: C.border,\n }}\n >\n <View style={{ flex: 1, padding: 18 }}>\n <View\n style={{\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n marginBottom: 12,\n }}\n >\n <Text style={{ color: C.emeraldSoft, fontWeight: \"700\", fontSize: 16 }}>\n Translation feedback\n </Text>\n <TouchableOpacity onPress={onClose} accessibilityLabel=\"Close\">\n <Text style={{ color: C.dim, fontSize: 20 }}>×</Text>\n </TouchableOpacity>\n </View>\n\n {error ? (\n <Text style={{ color: \"#f87171\", marginBottom: 8 }}>{error}</Text>\n ) : null}\n\n {!consented ? (\n <View>\n <Text style={{ color: C.text, lineHeight: 21 }}>\n Help improve the translations in this app. Your ratings and\n suggestions are sent to the app owner via Verbumia. Don’t\n submit personal or sensitive information.\n </Text>\n <TouchableOpacity\n disabled={busy}\n onPress={accept}\n style={{\n marginTop: 14,\n backgroundColor: C.emerald,\n borderRadius: 8,\n padding: 14,\n }}\n >\n <Text style={{ color: \"#03110c\", fontWeight: \"700\", textAlign: \"center\" }}>\n {busy ? \"…\" : `I accept the terms (v${client.tosVersion})`}\n </Text>\n </TouchableOpacity>\n </View>\n ) : (\n // flex:1 makes the ScrollView fill the remaining panel\n // height after the header; without it the list collapsed\n // to its intrinsic height and the panel left a large empty\n // area below the last row (the second half of the\n // SeedSower repro).\n <ScrollView style={{ flex: 1 }}>\n {!strings.length ? (\n <Text style={{ color: C.dim }}>\n {busy ? \"Loading…\" : \"No strings to review on this view.\"}\n </Text>\n ) : (\n strings.map((s) => (\n <StringRow\n key={`${s.namespace}:${s.key}`}\n s={s}\n client={client}\n />\n ))\n )}\n </ScrollView>\n )}\n </View>\n </SafeAreaView>\n </View>\n </KeyboardAvoidingView>\n </Modal>\n );\n}\n\nfunction StringRow(props: { s: FeedbackString; client: FeedbackClient }) {\n const { s, client } = props;\n const [mine, setMine] = useState<number | null>(s.my_rating);\n const [show, setShow] = useState(false);\n const [text, setText] = useState(\"\");\n const [sent, setSent] = useState(false);\n\n return (\n <View\n style={{\n backgroundColor: C.panel,\n borderWidth: 1,\n borderColor: C.border,\n borderRadius: 10,\n padding: 12,\n marginBottom: 10,\n }}\n >\n <Text style={{ color: C.dim, fontSize: 12 }}>\n {s.namespace} · {s.key}\n </Text>\n <Text style={{ color: C.text, fontSize: 15, marginVertical: 6 }}>\n {s.value}\n </Text>\n <View style={{ flexDirection: \"row\" }}>\n {[1, 2, 3, 4, 5].map((n) => (\n <TouchableOpacity\n key={n}\n accessibilityLabel={`${n} stars`}\n onPress={() => {\n setMine(n);\n client.rate({\n namespace: s.namespace,\n key: s.key,\n language: client.language,\n translation_hash: s.translation_hash,\n stars: n,\n });\n }}\n >\n <Text\n style={{\n fontSize: 22,\n marginRight: 4,\n color: mine && n <= mine ? C.emeraldSoft : C.border,\n }}\n >\n ★\n </Text>\n </TouchableOpacity>\n ))}\n <TouchableOpacity\n onPress={() => setShow(!show)}\n style={{ marginLeft: \"auto\" }}\n >\n <Text style={{ color: C.emeraldSoft }}>\n {sent ? \"Suggested ✓\" : \"Suggest\"}\n </Text>\n </TouchableOpacity>\n </View>\n {show ? (\n <View style={{ marginTop: 10 }}>\n <TextInput\n value={text}\n onChangeText={setText}\n multiline\n numberOfLines={3}\n placeholder=\"Your suggested translation…\"\n placeholderTextColor={C.dim}\n style={{\n backgroundColor: C.bg,\n color: C.text,\n borderWidth: 1,\n borderColor: C.border,\n borderRadius: 6,\n padding: 8,\n }}\n />\n <TouchableOpacity\n onPress={() => {\n if (!text.trim()) return;\n client.suggest({\n namespace: s.namespace,\n key: s.key,\n language: client.language,\n translation_hash: s.translation_hash,\n suggested_text: text.trim(),\n });\n setSent(true);\n setShow(false);\n setText(\"\");\n }}\n style={{\n marginTop: 6,\n backgroundColor: C.emerald,\n borderRadius: 6,\n padding: 10,\n }}\n >\n <Text style={{ color: \"#03110c\", fontWeight: \"700\", textAlign: \"center\" }}>\n Send suggestion\n </Text>\n </TouchableOpacity>\n </View>\n ) : null}\n </View>\n );\n}\n"],"mappings":";;;;;;;;;;AAQA,SAAS,4BAA4C;;;ACRrD,SAAS,eAAe,aAAa,WAAW,gBAAoD;AACpG;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAsJO,SAOE,KAPF;AAjId,IAAI;AACJ,IAAI;AACF,QAAM,MAAM,UAAQ,gCAAgC;AAGpD,iBAAe,IAAI;AACrB,QAAQ;AACN,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AAO;AAAA,EACxB;AACF;","names":["jsx"]}
|
package/dist/react/index.cjs
CHANGED
|
@@ -90,6 +90,22 @@ var FeedbackClient = class {
|
|
|
90
90
|
get language() {
|
|
91
91
|
return this.cfg.language;
|
|
92
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Re-target the widget's working language at runtime (#806 SeedSower
|
|
95
|
+
* lang-change propagation). Subsequent `getStrings` / `rate` /
|
|
96
|
+
* `suggest` use the new language without rebuilding the client. The
|
|
97
|
+
* server-minted ToS bundle has no `locale` field, so a language flip
|
|
98
|
+
* does NOT invalidate consent — only the next `?language=` query
|
|
99
|
+
* needs updating. The i18n provider plugin (feedback ≥0.2.6)
|
|
100
|
+
* subscribes to `@verbumia/react-i18next` ≥1.0.5's
|
|
101
|
+
* `VerbumiaPluginContext.onLanguageChange` and calls this on every
|
|
102
|
+
* runtime language change so the host never has to wire it manually.
|
|
103
|
+
*/
|
|
104
|
+
setLanguage(lang) {
|
|
105
|
+
if (typeof lang !== "string" || lang.length === 0) return;
|
|
106
|
+
if (lang === this.cfg.language) return;
|
|
107
|
+
this.cfg = { ...this.cfg, language: lang };
|
|
108
|
+
}
|
|
93
109
|
/** ToS version the end user is asked to accept — the SDK's
|
|
94
110
|
* build-time constant (task 616). NOT integrator/server set. */
|
|
95
111
|
get tosVersion() {
|
|
@@ -620,13 +636,18 @@ function feedbackPlugin(options) {
|
|
|
620
636
|
return {
|
|
621
637
|
name: "@verbumia/feedback",
|
|
622
638
|
setup(ctx) {
|
|
639
|
+
const initialLanguage = options.language ?? ctx.i18n?.language ?? ctx.config.defaultLocale;
|
|
623
640
|
client = new FeedbackClient({
|
|
624
641
|
apiBase: options.apiBase ?? ctx.config.apiBase ?? "https://api.verbumia.dev",
|
|
625
642
|
projectId: options.projectId ?? ctx.config.projectUuid,
|
|
626
|
-
language:
|
|
643
|
+
language: initialLanguage,
|
|
627
644
|
endUserId: options.endUserId,
|
|
628
645
|
fetchImpl: options.fetchImpl
|
|
629
646
|
});
|
|
647
|
+
let langUnsub;
|
|
648
|
+
if (typeof ctx.onLanguageChange === "function") {
|
|
649
|
+
langUnsub = ctx.onLanguageChange((lng) => client?.setLanguage(lng));
|
|
650
|
+
}
|
|
630
651
|
const controller = {
|
|
631
652
|
open: () => store.set(true),
|
|
632
653
|
close: () => {
|
|
@@ -638,6 +659,7 @@ function feedbackPlugin(options) {
|
|
|
638
659
|
options.onReady?.(controller);
|
|
639
660
|
if (options.controllerRef) options.controllerRef.current = controller;
|
|
640
661
|
return () => {
|
|
662
|
+
langUnsub?.();
|
|
641
663
|
if (options.controllerRef) options.controllerRef.current = null;
|
|
642
664
|
void client?.flush();
|
|
643
665
|
};
|
package/dist/react/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react/index.ts","../../src/react/plugin.tsx","../../src/core/types.ts","../../src/core/tos.ts","../../src/core/client.ts","../../src/react/panel.tsx","../../src/core/keys.ts"],"sourcesContent":["export {\n feedbackPlugin,\n type FeedbackController,\n type FeedbackPluginOptions,\n type I18nPlugin,\n type I18nPluginContext,\n} from \"./plugin\";\nexport { FeedbackPanel } from \"./panel\";\nexport {\n FeedbackClient,\n hasKeyRegistry,\n resolveKeys,\n type BatchResponse,\n type DeclaredKey,\n type FeedbackConfig,\n FeedbackError,\n type FeedbackString,\n type RatingInput,\n type StringsResponse,\n type SuggestionInput,\n type TokenBundle,\n} from \"../core\";\n","/**\n * `@verbumia/feedback` as a PLUGIN of the `@verbumia/*-i18n` provider.\n *\n * Architecture (task 599): NO second React context. The customer adds\n * `feedbackPlugin(...)` to the i18n provider's `plugins` slot. The\n * provider calls `setup({ i18n, config })` once (we reuse its apiBase /\n * projectUuid / locale — no re-config) and renders our `render()` as an\n * ISOLATED sibling leaf. The panel's open/close lives in a tiny private\n * store the outlet subscribes to via useSyncExternalStore, so toggling\n * feedback NEVER re-renders the host app. The customer triggers it via\n * their own CTA through the imperative controller.\n */\nimport { createPortal } from \"react-dom\";\nimport { useSyncExternalStore, type ReactNode } from \"react\";\n\nimport { FeedbackClient } from \"../core/client\";\nimport type { DeclaredKey } from \"../core/types\";\nimport { FeedbackPanel } from \"./panel\";\n\n/** Structural mirror of `@verbumia/react-i18next`'s VerbumiaPlugin —\n * kept local so feedback has no build-time dep on the i18n SDK. */\nexport interface I18nPluginContext {\n config: {\n apiBase?: string;\n projectUuid: string;\n defaultLocale: string;\n };\n}\nexport interface I18nPlugin {\n name: string;\n setup?: (ctx: I18nPluginContext) => void | (() => void);\n render?: () => ReactNode;\n}\n\nexport interface FeedbackController {\n open: () => void;\n close: () => void;\n /** The underlying client (advanced; usually unused). */\n client: FeedbackClient;\n}\n\nexport interface FeedbackPluginOptions {\n // NOTE: no `tosVersion` — it is an SDK build-time constant\n // (SDK_TOS_VERSION, task 616), sent automatically; never integrator-set.\n /** Override language; defaults to the i18n provider's defaultLocale. */\n language?: string;\n /** Override apiBase; defaults to the i18n provider's apiBase. */\n apiBase?: string;\n /** Override projectId; defaults to the i18n provider's projectUuid. */\n projectId?: string;\n /** Optional opaque end-user id (server generates one when absent). */\n endUserId?: string;\n /** Explicit on-screen keys (else the i18n key registry, if present). */\n keys?: DeclaredKey[];\n /** Optional namespace filter (CONTRACT v6, additive). When set (a\n * single namespace or a list) the panel shows only resolved keys in\n * that namespace — applied AFTER rendered-scoping (`rendered ∩\n * namespace`). Unset ⇒ all resolved keys (v5 behaviour). */\n namespace?: string | string[];\n /** Receives the imperative { open, close } handle for the host CTA. */\n onReady?: (controller: FeedbackController) => void;\n /** Alt delivery: a ref object that receives the controller. */\n controllerRef?: { current: FeedbackController | null };\n /** Injected fetch (tests / RN polyfills). */\n fetchImpl?: typeof fetch;\n}\n\nfunction makeStore() {\n let open = false;\n const listeners = new Set<() => void>();\n return {\n isOpen: () => open,\n set(v: boolean) {\n if (open !== v) {\n open = v;\n listeners.forEach((l) => l());\n }\n },\n subscribe(l: () => void) {\n listeners.add(l);\n return () => listeners.delete(l);\n },\n };\n}\n\nexport function feedbackPlugin(options: FeedbackPluginOptions): I18nPlugin {\n const store = makeStore();\n let client: FeedbackClient | null = null;\n\n function Outlet() {\n const isOpen = useSyncExternalStore(\n store.subscribe,\n store.isOpen,\n store.isOpen,\n );\n if (!isOpen || !client || typeof document === \"undefined\") return null;\n const c = client;\n return createPortal(\n <FeedbackPanel\n client={c}\n keys={options.keys}\n namespace={options.namespace}\n onClose={() => {\n store.set(false);\n void c.flush();\n }}\n />,\n document.body,\n );\n }\n\n return {\n name: \"@verbumia/feedback\",\n setup(ctx) {\n client = new FeedbackClient({\n apiBase:\n options.apiBase ?? ctx.config.apiBase ?? \"https://api.verbumia.dev\",\n projectId: options.projectId ?? ctx.config.projectUuid,\n language: options.language ?? ctx.config.defaultLocale,\n endUserId: options.endUserId,\n fetchImpl: options.fetchImpl,\n });\n const controller: FeedbackController = {\n open: () => store.set(true),\n close: () => {\n store.set(false);\n void client?.flush();\n },\n client,\n };\n options.onReady?.(controller);\n if (options.controllerRef) options.controllerRef.current = controller;\n return () => {\n if (options.controllerRef) options.controllerRef.current = null;\n void client?.flush();\n };\n },\n render: () => <Outlet />,\n };\n}\n","/**\n * Wire types for the Verbumia End-User Translation Evaluation API.\n * Canonical reference: ./CONTRACT.md (frozen). Backend task 591.\n */\n\nexport interface FeedbackConfig {\n /** API base, no trailing slash needed. e.g. https://api.verbumia.dev */\n apiBase: string;\n /** Public project UUID the widget targets. */\n projectId: string;\n /**\n * sessionId / grouping_key is MINTED SERVER-SIDE by the Verbumia\n * backend at POST /v1/feedback/tos and returned in the token bundle\n * (`TokenBundle.grouping_key`). The widget receives + sends it; it\n * MUST NOT self-generate it. There is intentionally no client config\n * field for it.\n */\n /**\n * NOTE: there is intentionally NO `tosVersion` field. The ToS version\n * is a BUILD-TIME constant baked into @verbumia/feedback at release\n * (`SDK_TOS_VERSION`, task 616) — integrators do not set it; the SDK\n * sends it automatically.\n */\n /** Optional opaque end-user id; server generates one when absent. */\n endUserId?: string;\n /** BCP-47 language the widget rates strings in (e.g. \"fr\"). */\n language: string;\n /** Optional locale tag stored for analytics. */\n locale?: string;\n /** Debounce window (ms) before a queued batch is flushed. Default 1500. */\n flushDebounceMs?: number;\n /** Max queued items before an immediate flush. Default 20. */\n maxBatch?: number;\n /** Injected fetch (tests / RN polyfills). Defaults to global fetch. */\n fetchImpl?: typeof fetch;\n}\n\nexport interface TokenBundle {\n access_token: string;\n token_type: \"Bearer\";\n expires_in: number;\n refresh_token: string;\n refresh_expires_in: number;\n end_user_id: string;\n tos_version: string;\n grouping_key: string;\n}\n\nexport interface FeedbackString {\n namespace: string;\n key: string;\n key_uuid: string;\n language_uuid: string;\n value: string;\n translation_hash: string;\n avg_stars: number | null;\n ratings_count: number;\n my_rating: number | null;\n}\n\nexport interface StringsResponse {\n project_id: string;\n language: string;\n strings: FeedbackString[];\n}\n\n/** A 5-star rating queued for a rendered string variant. */\nexport interface RatingInput {\n namespace: string;\n key: string;\n language: string;\n translation_hash: string;\n stars: number; // 1..5\n}\n\n/** A suggested alternative translation queued for moderation. */\nexport interface SuggestionInput {\n namespace: string;\n key: string;\n language: string;\n translation_hash: string;\n suggested_text: string;\n comment?: string;\n}\n\nexport interface BatchResponse {\n accepted: number;\n rejected: number;\n items: Array<Record<string, unknown>>;\n}\n\n/** A key the host app declares as on-screen. */\nexport interface DeclaredKey {\n namespace: string;\n key: string;\n}\n\nexport class FeedbackError extends Error {\n constructor(\n message: string,\n readonly status?: number,\n readonly code?: string,\n ) {\n super(message);\n this.name = \"FeedbackError\";\n }\n}\n","/**\n * BUILD-TIME ToS version constant (task 616, human decision option B).\n *\n * This is baked into the @verbumia/feedback PACKAGE at release. It is\n * NOT an integrator-set config field and NOT server-driven: a stale\n * (e.g. native) app must record consent to the ToS version IT shipped\n * and displayed, for legal correctness — never backend-latest.\n *\n * Releasing a ToS-TEXT change ⇒ bump this constant + cut a new\n * @verbumia/feedback release (per the human/real-CI publish handoff).\n * The backend accepts any version in its acceptable set and records it.\n */\nexport const SDK_TOS_VERSION = \"2026-05-18\";\n","/**\n * Framework-agnostic Verbumia feedback client.\n *\n * Responsibilities:\n * - versioned-ToS acceptance -> scoped end-user JWT bootstrap\n * - transparent access-token refresh (rotating refresh token)\n * - fetch on-screen strings for the widget\n * - debounced + size-capped batched POST of ratings / suggestions,\n * mirroring the missing-handler transport contract (ltm 280):\n * best-effort, never throws into the host app render path.\n *\n * The React and React Native entry points are thin UI shells over this.\n */\n\nimport {\n type BatchResponse,\n type FeedbackConfig,\n FeedbackError,\n type RatingInput,\n type StringsResponse,\n type SuggestionInput,\n type TokenBundle,\n} from \"./types\";\nimport { SDK_TOS_VERSION } from \"./tos\";\n\nconst SDK_LIB = \"@verbumia/feedback\";\nconst SDK_VER = \"0.2.0\";\n\ntype QueueItem =\n | { kind: \"rating\"; payload: RatingInput }\n | { kind: \"suggestion\"; payload: SuggestionInput };\n\nexport class FeedbackClient {\n private cfg: Required<\n Pick<FeedbackConfig, \"flushDebounceMs\" | \"maxBatch\">\n > &\n FeedbackConfig;\n private fetchImpl: typeof fetch;\n private tokens: TokenBundle | null = null;\n private queue: QueueItem[] = [];\n private timer: ReturnType<typeof setTimeout> | null = null;\n private bootstrapping: Promise<TokenBundle> | null = null;\n\n constructor(config: FeedbackConfig) {\n this.cfg = {\n flushDebounceMs: 1500,\n maxBatch: 20,\n ...config,\n };\n const f = config.fetchImpl ?? globalThis.fetch;\n if (!f) {\n throw new FeedbackError(\n \"no fetch implementation available; pass config.fetchImpl\",\n );\n }\n this.fetchImpl = f.bind(globalThis);\n }\n\n private base(): string {\n return this.cfg.apiBase.replace(/\\/+$/, \"\");\n }\n\n get endUserId(): string | undefined {\n return this.tokens?.end_user_id ?? this.cfg.endUserId;\n }\n\n get hasConsented(): boolean {\n return this.tokens !== null;\n }\n\n /** Server-minted sessionId / grouping_key (from the token bundle).\n * Available only after `acceptTos()`; never client-generated. */\n get sessionId(): string | undefined {\n return this.tokens?.grouping_key;\n }\n\n /** BCP-47 language the widget is rating strings in. */\n get language(): string {\n return this.cfg.language;\n }\n\n /** ToS version the end user is asked to accept — the SDK's\n * build-time constant (task 616). NOT integrator/server set. */\n get tosVersion(): string {\n return SDK_TOS_VERSION;\n }\n\n /**\n * Accept the ToS and bootstrap a scoped token. Idempotent: a second call\n * returns the in-flight / existing bundle rather than re-accepting.\n */\n async acceptTos(): Promise<TokenBundle> {\n if (this.tokens) return this.tokens;\n if (this.bootstrapping) return this.bootstrapping;\n this.bootstrapping = (async () => {\n const res = await this.fetchImpl(`${this.base()}/v1/feedback/tos`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n // NO grouping_key: server-minted (task 599). It comes back in\n // the token bundle and is bound into the JWT server-side.\n project_id: this.cfg.projectId,\n end_user_id: this.cfg.endUserId,\n tos_version: SDK_TOS_VERSION,\n locale: this.cfg.locale,\n }),\n });\n if (!res.ok) throw await this.problem(res, \"tos acceptance failed\");\n this.tokens = (await res.json()) as TokenBundle;\n return this.tokens;\n })();\n try {\n return await this.bootstrapping;\n } finally {\n this.bootstrapping = null;\n }\n }\n\n private async refresh(): Promise<void> {\n if (!this.tokens) throw new FeedbackError(\"not consented\");\n const res = await this.fetchImpl(\n `${this.base()}/v1/feedback/token/refresh`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ refresh_token: this.tokens.refresh_token }),\n },\n );\n if (!res.ok) {\n this.tokens = null; // force a fresh ToS step\n throw await this.problem(res, \"token refresh failed\");\n }\n this.tokens = (await res.json()) as TokenBundle;\n }\n\n /** Authenticated fetch with a single transparent refresh-on-401 retry. */\n private async authed(\n path: string,\n init: RequestInit,\n retry = true,\n ): Promise<Response> {\n if (!this.tokens) await this.acceptTos();\n const res = await this.fetchImpl(`${this.base()}${path}`, {\n ...init,\n headers: {\n ...(init.headers ?? {}),\n Authorization: `Bearer ${this.tokens!.access_token}`,\n },\n });\n if (res.status === 401 && retry) {\n await this.refresh();\n return this.authed(path, init, false);\n }\n return res;\n }\n\n /** Strings rendered on the current view, with this end user's prior rating. */\n async getStrings(opts?: {\n keys?: Array<{ namespace: string; key: string }>;\n namespace?: string;\n limit?: number;\n }): Promise<StringsResponse> {\n // #806 SeedSower P1 (Hermes URLSearchParams polyfill): React Native's\n // bundled URLSearchParams implements ONLY the constructor + toString().\n // `.set` / `.get` / `.append` / `.delete` / `.has` / `.entries` /\n // `.forEach` / `.keys` / `.values` / the iterator all throw on Hermes\n // (documented RN limitation since ~0.50, refused for bundle-size).\n // Build a plain Record<string, string> first, then pass to the\n // constructor — that variant is supported on Node + browser + Hermes\n // + JSC, and produces the same query string. NO mutation after\n // construction anywhere in the SDK.\n const params: Record<string, string> = { language: this.cfg.language };\n if (opts?.keys?.length) {\n params.keys = opts.keys.map((k) => `${k.namespace}:${k.key}`).join(\",\");\n }\n if (opts?.namespace) params.namespace = opts.namespace;\n if (opts?.limit) params.limit = String(opts.limit);\n const qs = new URLSearchParams(params);\n const res = await this.authed(`/v1/feedback/strings?${qs.toString()}`, {\n method: \"GET\",\n });\n if (!res.ok) throw await this.problem(res, \"failed to load strings\");\n return (await res.json()) as StringsResponse;\n }\n\n /** Queue a rating; flushed on debounce or when the batch fills. */\n rate(payload: RatingInput): void {\n this.enqueue({ kind: \"rating\", payload });\n }\n\n /** Queue a suggestion; flushed on debounce or when the batch fills. */\n suggest(payload: SuggestionInput): void {\n this.enqueue({ kind: \"suggestion\", payload });\n }\n\n private enqueue(item: QueueItem): void {\n this.queue.push(item);\n if (this.queue.length >= this.cfg.maxBatch) {\n void this.flush();\n return;\n }\n if (this.timer) clearTimeout(this.timer);\n this.timer = setTimeout(() => void this.flush(), this.cfg.flushDebounceMs);\n }\n\n /**\n * Flush queued items. Best-effort: a transport/auth failure re-queues the\n * batch once and swallows the error so the host app never sees a throw.\n */\n async flush(): Promise<void> {\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n if (!this.queue.length) return;\n const batch = this.queue;\n this.queue = [];\n const ratings = batch\n .filter((b) => b.kind === \"rating\")\n .map((b) => b.payload as RatingInput);\n const suggestions = batch\n .filter((b) => b.kind === \"suggestion\")\n .map((b) => b.payload as SuggestionInput);\n try {\n if (ratings.length) {\n await this.postBatch(\"/v1/feedback/ratings\", { ratings });\n }\n if (suggestions.length) {\n await this.postBatch(\"/v1/feedback/suggestions\", { suggestions });\n }\n } catch {\n // Re-queue once; feedback must never break the host app.\n this.queue.unshift(...batch);\n }\n }\n\n private async postBatch(\n path: string,\n body: unknown,\n ): Promise<BatchResponse> {\n const res = await this.authed(path, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", \"X-SDK\": `${SDK_LIB}@${SDK_VER}` },\n body: JSON.stringify(body),\n });\n if (!res.ok) throw await this.problem(res, \"batch post failed\");\n return (await res.json()) as BatchResponse;\n }\n\n private async problem(res: Response, fallback: string): Promise<FeedbackError> {\n let code: string | undefined;\n let detail = fallback;\n try {\n const body = (await res.json()) as { code?: string; detail?: string };\n code = body.code;\n if (body.detail) detail = body.detail;\n } catch {\n /* non-JSON body */\n }\n return new FeedbackError(detail, res.status, code);\n }\n}\n","import { useCallback, useEffect, useState } from \"react\";\n\nimport type { FeedbackClient } from \"../core/client\";\nimport { resolveKeys } from \"../core/keys\";\nimport type { DeclaredKey, FeedbackString } from \"../core/types\";\n\nconst C = {\n bg: \"#0b0f0e\",\n panel: \"#111714\",\n border: \"#1f2a25\",\n text: \"#e7f5ef\",\n dim: \"#8aa79b\",\n emerald: \"#10b981\",\n emeraldSoft: \"#34d399\",\n};\n\nexport function FeedbackPanel(props: {\n client: FeedbackClient;\n keys?: DeclaredKey[];\n namespace?: string | string[];\n onClose: () => void;\n}) {\n const { client, keys, namespace, onClose } = props;\n const [consented, setConsented] = useState(client.hasConsented);\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [strings, setStrings] = useState<FeedbackString[]>([]);\n\n const loadStrings = useCallback(async () => {\n setBusy(true);\n setError(null);\n try {\n // On-screen scoping is NORMATIVE (spec ltm 373, CONTRACT v5): show\n // ONLY rendered keys. Empty -> \"no strings on this view\"; never\n // fall back to fetching the whole project.\n const resolved = resolveKeys(keys, namespace);\n if (!resolved.length) {\n // #806 SeedSower P1 — when the panel opens with NO explicit\n // `keys` prop (i.e. it depended on the i18n SDK's on-screen\n // registry), an empty resolve almost always means the host's\n // `useTranslation` imports went to `react-i18next` instead of\n // `@verbumia/react-i18next`. Either way, the keys never fed the\n // registry. Log a single, actionable hint so the integrator\n // doesn't waste a debug cycle on \"the widget is broken\".\n if (!keys || keys.length === 0) {\n // eslint-disable-next-line no-console\n console.warn(\n \"[verbumia/feedback] registry empty — are your useTranslation imports coming from @verbumia/react-i18next?\",\n );\n }\n setStrings([]);\n return;\n }\n const res = await client.getStrings({ keys: resolved });\n setStrings(res.strings);\n } catch (e) {\n setError(e instanceof Error ? e.message : \"Failed to load strings\");\n } finally {\n setBusy(false);\n }\n }, [client, keys, namespace]);\n\n useEffect(() => {\n if (consented) void loadStrings();\n }, [consented, loadStrings]);\n\n const accept = useCallback(async () => {\n setBusy(true);\n setError(null);\n try {\n await client.acceptTos();\n setConsented(true);\n } catch (e) {\n setError(e instanceof Error ? e.message : \"Could not accept the terms\");\n } finally {\n setBusy(false);\n }\n }, [client]);\n\n return (\n <div\n role=\"dialog\"\n aria-label=\"Translation feedback\"\n style={{\n position: \"fixed\",\n inset: 0,\n zIndex: 2147483600,\n background: \"rgba(0,0,0,.55)\",\n display: \"flex\",\n justifyContent: \"flex-end\",\n }}\n onClick={onClose}\n >\n <div\n onClick={(e) => e.stopPropagation()}\n style={{\n width: \"min(420px, 100%)\",\n height: \"100%\",\n background: C.bg,\n color: C.text,\n borderLeft: `1px solid ${C.border}`,\n display: \"flex\",\n flexDirection: \"column\",\n fontFamily: \"system-ui, sans-serif\",\n }}\n >\n <header\n style={{\n padding: \"16px 18px\",\n borderBottom: `1px solid ${C.border}`,\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n }}\n >\n <strong style={{ color: C.emeraldSoft }}>Translation feedback</strong>\n <button\n type=\"button\"\n onClick={onClose}\n aria-label=\"Close\"\n style={{\n background: \"transparent\",\n color: C.dim,\n border: \"none\",\n fontSize: 20,\n cursor: \"pointer\",\n }}\n >\n ×\n </button>\n </header>\n\n <div style={{ padding: 18, overflowY: \"auto\", flex: 1 }}>\n {error && (\n <p style={{ color: \"#f87171\", fontSize: 13 }}>{error}</p>\n )}\n\n {!consented ? (\n <ConsentStep\n version={client.tosVersion}\n busy={busy}\n onAccept={accept}\n />\n ) : busy && !strings.length ? (\n <p style={{ color: C.dim }}>Loading…</p>\n ) : !strings.length ? (\n <p style={{ color: C.dim }}>No strings to review on this view.</p>\n ) : (\n strings.map((s) => (\n <StringRow key={`${s.namespace}:${s.key}`} s={s} client={client} />\n ))\n )}\n </div>\n <footer\n style={{\n padding: \"10px 18px\",\n borderTop: `1px solid ${C.border}`,\n color: C.dim,\n fontSize: 11,\n }}\n >\n Powered by Verbumia\n </footer>\n </div>\n </div>\n );\n}\n\nfunction ConsentStep(props: {\n version?: string;\n busy: boolean;\n onAccept: () => void;\n}) {\n return (\n <div>\n <p style={{ lineHeight: 1.5, fontSize: 14 }}>\n Help improve the translations in this app. Your ratings and\n suggestions are sent to the app owner via Verbumia. Don’t submit\n personal or sensitive information.\n </p>\n <button\n type=\"button\"\n disabled={props.busy}\n onClick={props.onAccept}\n style={{\n marginTop: 12,\n width: \"100%\",\n background: C.emerald,\n color: \"#03110c\",\n border: \"none\",\n borderRadius: 8,\n padding: \"12px 14px\",\n fontWeight: 700,\n cursor: props.busy ? \"default\" : \"pointer\",\n opacity: props.busy ? 0.6 : 1,\n }}\n >\n {props.busy\n ? \"…\"\n : `I accept the terms${props.version ? ` (v${props.version})` : \"\"}`}\n </button>\n </div>\n );\n}\n\nfunction StringRow(props: { s: FeedbackString; client: FeedbackClient }) {\n const { s, client } = props;\n const [mine, setMine] = useState<number | null>(s.my_rating);\n const [showSuggest, setShowSuggest] = useState(false);\n const [text, setText] = useState(\"\");\n const [sent, setSent] = useState(false);\n\n const rate = (stars: number) => {\n setMine(stars);\n client.rate({\n namespace: s.namespace,\n key: s.key,\n language: client.language,\n translation_hash: s.translation_hash,\n stars,\n });\n };\n\n const submitSuggestion = () => {\n if (!text.trim()) return;\n client.suggest({\n namespace: s.namespace,\n key: s.key,\n language: client.language,\n translation_hash: s.translation_hash,\n suggested_text: text.trim(),\n });\n setSent(true);\n setShowSuggest(false);\n setText(\"\");\n };\n\n return (\n <div\n style={{\n background: C.panel,\n border: `1px solid ${C.border}`,\n borderRadius: 10,\n padding: 12,\n marginBottom: 10,\n }}\n >\n <div style={{ fontSize: 12, color: C.dim }}>\n {s.namespace} · {s.key}\n </div>\n <div style={{ margin: \"6px 0 10px\", fontSize: 15 }}>{s.value}</div>\n <div style={{ display: \"flex\", gap: 4 }}>\n {[1, 2, 3, 4, 5].map((n) => (\n <button\n key={n}\n type=\"button\"\n aria-label={`${n} star${n > 1 ? \"s\" : \"\"}`}\n onClick={() => rate(n)}\n style={{\n background: \"transparent\",\n border: \"none\",\n cursor: \"pointer\",\n fontSize: 20,\n color: mine && n <= mine ? C.emeraldSoft : C.border,\n }}\n >\n ★\n </button>\n ))}\n <button\n type=\"button\"\n onClick={() => setShowSuggest((v) => !v)}\n style={{\n marginLeft: \"auto\",\n background: \"transparent\",\n color: C.emeraldSoft,\n border: `1px solid ${C.border}`,\n borderRadius: 6,\n padding: \"4px 10px\",\n fontSize: 12,\n cursor: \"pointer\",\n }}\n >\n {sent ? \"Suggested ✓\" : \"Suggest\"}\n </button>\n </div>\n {showSuggest && (\n <div style={{ marginTop: 10 }}>\n <textarea\n value={text}\n onChange={(e) => setText(e.target.value)}\n rows={3}\n placeholder=\"Your suggested translation…\"\n style={{\n width: \"100%\",\n background: C.bg,\n color: C.text,\n border: `1px solid ${C.border}`,\n borderRadius: 6,\n padding: 8,\n fontSize: 14,\n resize: \"vertical\",\n }}\n />\n <button\n type=\"button\"\n onClick={submitSuggestion}\n style={{\n marginTop: 6,\n background: C.emerald,\n color: \"#03110c\",\n border: \"none\",\n borderRadius: 6,\n padding: \"8px 12px\",\n fontWeight: 700,\n cursor: \"pointer\",\n }}\n >\n Send suggestion\n </button>\n </div>\n )}\n </div>\n );\n}\n","/**\n * On-screen key discovery.\n *\n * Preferred source: the `@verbumia/*-i18n` SDK exposes a lightweight key\n * registry of keys it has rendered. When that registry is present on the\n * global (the i18n SDK publishes `globalThis.__verbumia_key_registry__`),\n * we read the keys touched on the current view. Otherwise the host app\n * passes an explicit `keys` list — the always-available fallback.\n *\n * The registry contract is intentionally tiny so any framework port of the\n * i18n SDK can implement it without depending on this package.\n */\n\nimport type { DeclaredKey } from \"./types\";\n\nconst REGISTRY_GLOBAL = \"__verbumia_key_registry__\";\n\ninterface KeyRegistry {\n /** Returns the keys rendered since the last `reset()` (or ever). */\n snapshot(): DeclaredKey[];\n reset?(): void;\n}\n\nfunction getRegistry(): KeyRegistry | null {\n const g = globalThis as Record<string, unknown>;\n const reg = g[REGISTRY_GLOBAL];\n if (\n reg &&\n typeof (reg as KeyRegistry).snapshot === \"function\"\n ) {\n return reg as KeyRegistry;\n }\n return null;\n}\n\n/** True when a compatible `@verbumia/*-i18n` registry is detectable. */\nexport function hasKeyRegistry(): boolean {\n return getRegistry() !== null;\n}\n\n/**\n * Resolve the on-screen keys: explicit `keys` prop always wins (it is the\n * customer's authoritative declaration); otherwise fall back to the i18n\n * registry snapshot; otherwise an empty list (widget shows \"no strings\").\n *\n * Optional `namespace` filter (task 618, CONTRACT v6 — ADDITIVE): when\n * set (a single namespace or a list), the resolved set is narrowed to\n * keys whose `namespace` is in the filter. The filter is applied AFTER\n * resolution, so it composes with v5 rendered-scoping as\n * `rendered ∩ namespace`. UNSET / empty ⇒ unchanged v5 behaviour (all\n * resolved keys). Backward-compatible: `resolveKeys(keys)` is unaffected.\n */\nexport function resolveKeys(\n explicit?: DeclaredKey[],\n namespace?: string | string[],\n): DeclaredKey[] {\n const base =\n explicit && explicit.length\n ? dedupe(explicit)\n : getRegistry()\n ? dedupe(getRegistry()!.snapshot())\n : [];\n return filterByNamespace(base, namespace);\n}\n\n/** Narrow keys to those whose namespace is in `namespace`. An undefined\n * filter, an empty string, or an empty list means \"no filter\" (the\n * additive default — identical to v5). Exported so non-panel callers\n * (e.g. a custom /core integration) can apply the same semantics. */\nexport function filterByNamespace(\n keys: DeclaredKey[],\n namespace?: string | string[],\n): DeclaredKey[] {\n const list = (Array.isArray(namespace) ? namespace : namespace ? [namespace] : [])\n .map((n) => n.trim())\n .filter(Boolean);\n if (!list.length) return keys;\n const allow = new Set(list);\n return keys.filter((k) => allow.has(k.namespace));\n}\n\nfunction dedupe(keys: DeclaredKey[]): DeclaredKey[] {\n const seen = new Set<string>();\n const out: DeclaredKey[] = [];\n for (const k of keys) {\n const id = `${k.namespace}:${k.key}`;\n if (!seen.has(id)) {\n seen.add(id);\n out.push(k);\n }\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYA,uBAA6B;AAC7B,IAAAA,gBAAqD;;;ACoF9C,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YACE,SACS,QACA,MACT;AACA,UAAM,OAAO;AAHJ;AACA;AAGT,SAAK,OAAO;AAAA,EACd;AAAA,EALW;AAAA,EACA;AAKb;;;AC9FO,IAAM,kBAAkB;;;ACa/B,IAAM,UAAU;AAChB,IAAM,UAAU;AAMT,IAAM,iBAAN,MAAqB;AAAA,EAClB;AAAA,EAIA;AAAA,EACA,SAA6B;AAAA,EAC7B,QAAqB,CAAC;AAAA,EACtB,QAA8C;AAAA,EAC9C,gBAA6C;AAAA,EAErD,YAAY,QAAwB;AAClC,SAAK,MAAM;AAAA,MACT,iBAAiB;AAAA,MACjB,UAAU;AAAA,MACV,GAAG;AAAA,IACL;AACA,UAAM,IAAI,OAAO,aAAa,WAAW;AACzC,QAAI,CAAC,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/react/plugin.tsx","../../src/core/types.ts","../../src/core/tos.ts","../../src/core/client.ts","../../src/react/panel.tsx","../../src/core/keys.ts"],"sourcesContent":["export {\n feedbackPlugin,\n type FeedbackController,\n type FeedbackPluginOptions,\n type I18nPlugin,\n type I18nPluginContext,\n} from \"./plugin\";\nexport { FeedbackPanel } from \"./panel\";\nexport {\n FeedbackClient,\n hasKeyRegistry,\n resolveKeys,\n type BatchResponse,\n type DeclaredKey,\n type FeedbackConfig,\n FeedbackError,\n type FeedbackString,\n type RatingInput,\n type StringsResponse,\n type SuggestionInput,\n type TokenBundle,\n} from \"../core\";\n","/**\n * `@verbumia/feedback` as a PLUGIN of the `@verbumia/*-i18n` provider.\n *\n * Architecture (task 599): NO second React context. The customer adds\n * `feedbackPlugin(...)` to the i18n provider's `plugins` slot. The\n * provider calls `setup({ i18n, config })` once (we reuse its apiBase /\n * projectUuid / locale — no re-config) and renders our `render()` as an\n * ISOLATED sibling leaf. The panel's open/close lives in a tiny private\n * store the outlet subscribes to via useSyncExternalStore, so toggling\n * feedback NEVER re-renders the host app. The customer triggers it via\n * their own CTA through the imperative controller.\n */\nimport { createPortal } from \"react-dom\";\nimport { useSyncExternalStore, type ReactNode } from \"react\";\n\nimport { FeedbackClient } from \"../core/client\";\nimport type { DeclaredKey } from \"../core/types\";\nimport { FeedbackPanel } from \"./panel\";\n\n/** Structural mirror of `@verbumia/react-i18next`'s VerbumiaPlugin —\n * kept local so feedback has no build-time dep on the i18n SDK. The\n * `i18n` and `onLanguageChange` fields are optional so a plugin attached\n * to a non-Verbumia host (or to a pre-1.0.5 react-i18next) keeps\n * working — runtime language re-sync is just disabled. From feedback\n * ≥0.2.6, the peerDep on `@verbumia/react-i18next` is `>=1.0.5`, so the\n * lang-change subscription path is guaranteed available in matched\n * installs. */\nexport interface I18nPluginContext {\n i18n?: { language?: string };\n config: {\n apiBase?: string;\n projectUuid: string;\n defaultLocale: string;\n };\n /** #806 — subscribe to runtime language changes (see VerbumiaPluginContext\n * in `@verbumia/react-i18next` ≥1.0.5). Returns an unsubscribe fn the\n * plugin MUST call from teardown. Optional so attaching to a\n * pre-1.0.5 react-i18next falls back gracefully (no auto re-sync;\n * consumer can still pass `options.language` explicitly). */\n onLanguageChange?: (cb: (lng: string) => void) => () => void;\n}\nexport interface I18nPlugin {\n name: string;\n setup?: (ctx: I18nPluginContext) => void | (() => void);\n render?: () => ReactNode;\n}\n\nexport interface FeedbackController {\n open: () => void;\n close: () => void;\n /** The underlying client (advanced; usually unused). */\n client: FeedbackClient;\n}\n\nexport interface FeedbackPluginOptions {\n // NOTE: no `tosVersion` — it is an SDK build-time constant\n // (SDK_TOS_VERSION, task 616), sent automatically; never integrator-set.\n /** Override language; defaults to the i18n provider's defaultLocale. */\n language?: string;\n /** Override apiBase; defaults to the i18n provider's apiBase. */\n apiBase?: string;\n /** Override projectId; defaults to the i18n provider's projectUuid. */\n projectId?: string;\n /** Optional opaque end-user id (server generates one when absent). */\n endUserId?: string;\n /** Explicit on-screen keys (else the i18n key registry, if present). */\n keys?: DeclaredKey[];\n /** Optional namespace filter (CONTRACT v6, additive). When set (a\n * single namespace or a list) the panel shows only resolved keys in\n * that namespace — applied AFTER rendered-scoping (`rendered ∩\n * namespace`). Unset ⇒ all resolved keys (v5 behaviour). */\n namespace?: string | string[];\n /** Receives the imperative { open, close } handle for the host CTA. */\n onReady?: (controller: FeedbackController) => void;\n /** Alt delivery: a ref object that receives the controller. */\n controllerRef?: { current: FeedbackController | null };\n /** Injected fetch (tests / RN polyfills). */\n fetchImpl?: typeof fetch;\n}\n\nfunction makeStore() {\n let open = false;\n const listeners = new Set<() => void>();\n return {\n isOpen: () => open,\n set(v: boolean) {\n if (open !== v) {\n open = v;\n listeners.forEach((l) => l());\n }\n },\n subscribe(l: () => void) {\n listeners.add(l);\n return () => listeners.delete(l);\n },\n };\n}\n\nexport function feedbackPlugin(options: FeedbackPluginOptions): I18nPlugin {\n const store = makeStore();\n let client: FeedbackClient | null = null;\n\n function Outlet() {\n const isOpen = useSyncExternalStore(\n store.subscribe,\n store.isOpen,\n store.isOpen,\n );\n if (!isOpen || !client || typeof document === \"undefined\") return null;\n const c = client;\n return createPortal(\n <FeedbackPanel\n client={c}\n keys={options.keys}\n namespace={options.namespace}\n onClose={() => {\n store.set(false);\n void c.flush();\n }}\n />,\n document.body,\n );\n }\n\n return {\n name: \"@verbumia/feedback\",\n setup(ctx) {\n // #806 SeedSower lang-change init source: prefer an explicit\n // plugin option, then the i18n provider's CURRENT language (so\n // mounts that happen after a boot-time language flip get it\n // right), then the boot-snapshot defaultLocale as the floor.\n const initialLanguage =\n options.language ?? ctx.i18n?.language ?? ctx.config.defaultLocale;\n client = new FeedbackClient({\n apiBase:\n options.apiBase ?? ctx.config.apiBase ?? \"https://api.verbumia.dev\",\n projectId: options.projectId ?? ctx.config.projectUuid,\n language: initialLanguage,\n endUserId: options.endUserId,\n fetchImpl: options.fetchImpl,\n });\n // #806 — re-sync the client whenever the host changes the\n // language at runtime. Optional: if the host's i18n provider\n // predates the plugin-context `onLanguageChange` field (or the\n // plugin is mounted on a non-Verbumia host), this just no-ops\n // and the consumer can still pass `options.language` explicitly.\n let langUnsub: (() => void) | undefined;\n if (typeof ctx.onLanguageChange === \"function\") {\n langUnsub = ctx.onLanguageChange((lng) => client?.setLanguage(lng));\n }\n const controller: FeedbackController = {\n open: () => store.set(true),\n close: () => {\n store.set(false);\n void client?.flush();\n },\n client,\n };\n options.onReady?.(controller);\n if (options.controllerRef) options.controllerRef.current = controller;\n return () => {\n langUnsub?.();\n if (options.controllerRef) options.controllerRef.current = null;\n void client?.flush();\n };\n },\n render: () => <Outlet />,\n };\n}\n","/**\n * Wire types for the Verbumia End-User Translation Evaluation API.\n * Canonical reference: ./CONTRACT.md (frozen). Backend task 591.\n */\n\nexport interface FeedbackConfig {\n /** API base, no trailing slash needed. e.g. https://api.verbumia.dev */\n apiBase: string;\n /** Public project UUID the widget targets. */\n projectId: string;\n /**\n * sessionId / grouping_key is MINTED SERVER-SIDE by the Verbumia\n * backend at POST /v1/feedback/tos and returned in the token bundle\n * (`TokenBundle.grouping_key`). The widget receives + sends it; it\n * MUST NOT self-generate it. There is intentionally no client config\n * field for it.\n */\n /**\n * NOTE: there is intentionally NO `tosVersion` field. The ToS version\n * is a BUILD-TIME constant baked into @verbumia/feedback at release\n * (`SDK_TOS_VERSION`, task 616) — integrators do not set it; the SDK\n * sends it automatically.\n */\n /** Optional opaque end-user id; server generates one when absent. */\n endUserId?: string;\n /** BCP-47 language the widget rates strings in (e.g. \"fr\"). */\n language: string;\n /** Optional locale tag stored for analytics. */\n locale?: string;\n /** Debounce window (ms) before a queued batch is flushed. Default 1500. */\n flushDebounceMs?: number;\n /** Max queued items before an immediate flush. Default 20. */\n maxBatch?: number;\n /** Injected fetch (tests / RN polyfills). Defaults to global fetch. */\n fetchImpl?: typeof fetch;\n}\n\nexport interface TokenBundle {\n access_token: string;\n token_type: \"Bearer\";\n expires_in: number;\n refresh_token: string;\n refresh_expires_in: number;\n end_user_id: string;\n tos_version: string;\n grouping_key: string;\n}\n\nexport interface FeedbackString {\n namespace: string;\n key: string;\n key_uuid: string;\n language_uuid: string;\n value: string;\n translation_hash: string;\n avg_stars: number | null;\n ratings_count: number;\n my_rating: number | null;\n}\n\nexport interface StringsResponse {\n project_id: string;\n language: string;\n strings: FeedbackString[];\n}\n\n/** A 5-star rating queued for a rendered string variant. */\nexport interface RatingInput {\n namespace: string;\n key: string;\n language: string;\n translation_hash: string;\n stars: number; // 1..5\n}\n\n/** A suggested alternative translation queued for moderation. */\nexport interface SuggestionInput {\n namespace: string;\n key: string;\n language: string;\n translation_hash: string;\n suggested_text: string;\n comment?: string;\n}\n\nexport interface BatchResponse {\n accepted: number;\n rejected: number;\n items: Array<Record<string, unknown>>;\n}\n\n/** A key the host app declares as on-screen. */\nexport interface DeclaredKey {\n namespace: string;\n key: string;\n}\n\nexport class FeedbackError extends Error {\n constructor(\n message: string,\n readonly status?: number,\n readonly code?: string,\n ) {\n super(message);\n this.name = \"FeedbackError\";\n }\n}\n","/**\n * BUILD-TIME ToS version constant (task 616, human decision option B).\n *\n * This is baked into the @verbumia/feedback PACKAGE at release. It is\n * NOT an integrator-set config field and NOT server-driven: a stale\n * (e.g. native) app must record consent to the ToS version IT shipped\n * and displayed, for legal correctness — never backend-latest.\n *\n * Releasing a ToS-TEXT change ⇒ bump this constant + cut a new\n * @verbumia/feedback release (per the human/real-CI publish handoff).\n * The backend accepts any version in its acceptable set and records it.\n */\nexport const SDK_TOS_VERSION = \"2026-05-18\";\n","/**\n * Framework-agnostic Verbumia feedback client.\n *\n * Responsibilities:\n * - versioned-ToS acceptance -> scoped end-user JWT bootstrap\n * - transparent access-token refresh (rotating refresh token)\n * - fetch on-screen strings for the widget\n * - debounced + size-capped batched POST of ratings / suggestions,\n * mirroring the missing-handler transport contract (ltm 280):\n * best-effort, never throws into the host app render path.\n *\n * The React and React Native entry points are thin UI shells over this.\n */\n\nimport {\n type BatchResponse,\n type FeedbackConfig,\n FeedbackError,\n type RatingInput,\n type StringsResponse,\n type SuggestionInput,\n type TokenBundle,\n} from \"./types\";\nimport { SDK_TOS_VERSION } from \"./tos\";\n\nconst SDK_LIB = \"@verbumia/feedback\";\nconst SDK_VER = \"0.2.0\";\n\ntype QueueItem =\n | { kind: \"rating\"; payload: RatingInput }\n | { kind: \"suggestion\"; payload: SuggestionInput };\n\nexport class FeedbackClient {\n private cfg: Required<\n Pick<FeedbackConfig, \"flushDebounceMs\" | \"maxBatch\">\n > &\n FeedbackConfig;\n private fetchImpl: typeof fetch;\n private tokens: TokenBundle | null = null;\n private queue: QueueItem[] = [];\n private timer: ReturnType<typeof setTimeout> | null = null;\n private bootstrapping: Promise<TokenBundle> | null = null;\n\n constructor(config: FeedbackConfig) {\n this.cfg = {\n flushDebounceMs: 1500,\n maxBatch: 20,\n ...config,\n };\n const f = config.fetchImpl ?? globalThis.fetch;\n if (!f) {\n throw new FeedbackError(\n \"no fetch implementation available; pass config.fetchImpl\",\n );\n }\n this.fetchImpl = f.bind(globalThis);\n }\n\n private base(): string {\n return this.cfg.apiBase.replace(/\\/+$/, \"\");\n }\n\n get endUserId(): string | undefined {\n return this.tokens?.end_user_id ?? this.cfg.endUserId;\n }\n\n get hasConsented(): boolean {\n return this.tokens !== null;\n }\n\n /** Server-minted sessionId / grouping_key (from the token bundle).\n * Available only after `acceptTos()`; never client-generated. */\n get sessionId(): string | undefined {\n return this.tokens?.grouping_key;\n }\n\n /** BCP-47 language the widget is rating strings in. */\n get language(): string {\n return this.cfg.language;\n }\n\n /**\n * Re-target the widget's working language at runtime (#806 SeedSower\n * lang-change propagation). Subsequent `getStrings` / `rate` /\n * `suggest` use the new language without rebuilding the client. The\n * server-minted ToS bundle has no `locale` field, so a language flip\n * does NOT invalidate consent — only the next `?language=` query\n * needs updating. The i18n provider plugin (feedback ≥0.2.6)\n * subscribes to `@verbumia/react-i18next` ≥1.0.5's\n * `VerbumiaPluginContext.onLanguageChange` and calls this on every\n * runtime language change so the host never has to wire it manually.\n */\n setLanguage(lang: string): void {\n if (typeof lang !== \"string\" || lang.length === 0) return;\n if (lang === this.cfg.language) return;\n this.cfg = { ...this.cfg, language: lang };\n }\n\n /** ToS version the end user is asked to accept — the SDK's\n * build-time constant (task 616). NOT integrator/server set. */\n get tosVersion(): string {\n return SDK_TOS_VERSION;\n }\n\n /**\n * Accept the ToS and bootstrap a scoped token. Idempotent: a second call\n * returns the in-flight / existing bundle rather than re-accepting.\n */\n async acceptTos(): Promise<TokenBundle> {\n if (this.tokens) return this.tokens;\n if (this.bootstrapping) return this.bootstrapping;\n this.bootstrapping = (async () => {\n const res = await this.fetchImpl(`${this.base()}/v1/feedback/tos`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n // NO grouping_key: server-minted (task 599). It comes back in\n // the token bundle and is bound into the JWT server-side.\n project_id: this.cfg.projectId,\n end_user_id: this.cfg.endUserId,\n tos_version: SDK_TOS_VERSION,\n locale: this.cfg.locale,\n }),\n });\n if (!res.ok) throw await this.problem(res, \"tos acceptance failed\");\n this.tokens = (await res.json()) as TokenBundle;\n return this.tokens;\n })();\n try {\n return await this.bootstrapping;\n } finally {\n this.bootstrapping = null;\n }\n }\n\n private async refresh(): Promise<void> {\n if (!this.tokens) throw new FeedbackError(\"not consented\");\n const res = await this.fetchImpl(\n `${this.base()}/v1/feedback/token/refresh`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ refresh_token: this.tokens.refresh_token }),\n },\n );\n if (!res.ok) {\n this.tokens = null; // force a fresh ToS step\n throw await this.problem(res, \"token refresh failed\");\n }\n this.tokens = (await res.json()) as TokenBundle;\n }\n\n /** Authenticated fetch with a single transparent refresh-on-401 retry. */\n private async authed(\n path: string,\n init: RequestInit,\n retry = true,\n ): Promise<Response> {\n if (!this.tokens) await this.acceptTos();\n const res = await this.fetchImpl(`${this.base()}${path}`, {\n ...init,\n headers: {\n ...(init.headers ?? {}),\n Authorization: `Bearer ${this.tokens!.access_token}`,\n },\n });\n if (res.status === 401 && retry) {\n await this.refresh();\n return this.authed(path, init, false);\n }\n return res;\n }\n\n /** Strings rendered on the current view, with this end user's prior rating. */\n async getStrings(opts?: {\n keys?: Array<{ namespace: string; key: string }>;\n namespace?: string;\n limit?: number;\n }): Promise<StringsResponse> {\n // #806 SeedSower P1 (Hermes URLSearchParams polyfill): React Native's\n // bundled URLSearchParams implements ONLY the constructor + toString().\n // `.set` / `.get` / `.append` / `.delete` / `.has` / `.entries` /\n // `.forEach` / `.keys` / `.values` / the iterator all throw on Hermes\n // (documented RN limitation since ~0.50, refused for bundle-size).\n // Build a plain Record<string, string> first, then pass to the\n // constructor — that variant is supported on Node + browser + Hermes\n // + JSC, and produces the same query string. NO mutation after\n // construction anywhere in the SDK.\n const params: Record<string, string> = { language: this.cfg.language };\n if (opts?.keys?.length) {\n params.keys = opts.keys.map((k) => `${k.namespace}:${k.key}`).join(\",\");\n }\n if (opts?.namespace) params.namespace = opts.namespace;\n if (opts?.limit) params.limit = String(opts.limit);\n const qs = new URLSearchParams(params);\n const res = await this.authed(`/v1/feedback/strings?${qs.toString()}`, {\n method: \"GET\",\n });\n if (!res.ok) throw await this.problem(res, \"failed to load strings\");\n return (await res.json()) as StringsResponse;\n }\n\n /** Queue a rating; flushed on debounce or when the batch fills. */\n rate(payload: RatingInput): void {\n this.enqueue({ kind: \"rating\", payload });\n }\n\n /** Queue a suggestion; flushed on debounce or when the batch fills. */\n suggest(payload: SuggestionInput): void {\n this.enqueue({ kind: \"suggestion\", payload });\n }\n\n private enqueue(item: QueueItem): void {\n this.queue.push(item);\n if (this.queue.length >= this.cfg.maxBatch) {\n void this.flush();\n return;\n }\n if (this.timer) clearTimeout(this.timer);\n this.timer = setTimeout(() => void this.flush(), this.cfg.flushDebounceMs);\n }\n\n /**\n * Flush queued items. Best-effort: a transport/auth failure re-queues the\n * batch once and swallows the error so the host app never sees a throw.\n */\n async flush(): Promise<void> {\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n if (!this.queue.length) return;\n const batch = this.queue;\n this.queue = [];\n const ratings = batch\n .filter((b) => b.kind === \"rating\")\n .map((b) => b.payload as RatingInput);\n const suggestions = batch\n .filter((b) => b.kind === \"suggestion\")\n .map((b) => b.payload as SuggestionInput);\n try {\n if (ratings.length) {\n await this.postBatch(\"/v1/feedback/ratings\", { ratings });\n }\n if (suggestions.length) {\n await this.postBatch(\"/v1/feedback/suggestions\", { suggestions });\n }\n } catch {\n // Re-queue once; feedback must never break the host app.\n this.queue.unshift(...batch);\n }\n }\n\n private async postBatch(\n path: string,\n body: unknown,\n ): Promise<BatchResponse> {\n const res = await this.authed(path, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", \"X-SDK\": `${SDK_LIB}@${SDK_VER}` },\n body: JSON.stringify(body),\n });\n if (!res.ok) throw await this.problem(res, \"batch post failed\");\n return (await res.json()) as BatchResponse;\n }\n\n private async problem(res: Response, fallback: string): Promise<FeedbackError> {\n let code: string | undefined;\n let detail = fallback;\n try {\n const body = (await res.json()) as { code?: string; detail?: string };\n code = body.code;\n if (body.detail) detail = body.detail;\n } catch {\n /* non-JSON body */\n }\n return new FeedbackError(detail, res.status, code);\n }\n}\n","import { useCallback, useEffect, useState } from \"react\";\n\nimport type { FeedbackClient } from \"../core/client\";\nimport { resolveKeys } from \"../core/keys\";\nimport type { DeclaredKey, FeedbackString } from \"../core/types\";\n\nconst C = {\n bg: \"#0b0f0e\",\n panel: \"#111714\",\n border: \"#1f2a25\",\n text: \"#e7f5ef\",\n dim: \"#8aa79b\",\n emerald: \"#10b981\",\n emeraldSoft: \"#34d399\",\n};\n\nexport function FeedbackPanel(props: {\n client: FeedbackClient;\n keys?: DeclaredKey[];\n namespace?: string | string[];\n onClose: () => void;\n}) {\n const { client, keys, namespace, onClose } = props;\n const [consented, setConsented] = useState(client.hasConsented);\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [strings, setStrings] = useState<FeedbackString[]>([]);\n\n const loadStrings = useCallback(async () => {\n setBusy(true);\n setError(null);\n try {\n // On-screen scoping is NORMATIVE (spec ltm 373, CONTRACT v5): show\n // ONLY rendered keys. Empty -> \"no strings on this view\"; never\n // fall back to fetching the whole project.\n const resolved = resolveKeys(keys, namespace);\n if (!resolved.length) {\n // #806 SeedSower P1 — when the panel opens with NO explicit\n // `keys` prop (i.e. it depended on the i18n SDK's on-screen\n // registry), an empty resolve almost always means the host's\n // `useTranslation` imports went to `react-i18next` instead of\n // `@verbumia/react-i18next`. Either way, the keys never fed the\n // registry. Log a single, actionable hint so the integrator\n // doesn't waste a debug cycle on \"the widget is broken\".\n if (!keys || keys.length === 0) {\n // eslint-disable-next-line no-console\n console.warn(\n \"[verbumia/feedback] registry empty — are your useTranslation imports coming from @verbumia/react-i18next?\",\n );\n }\n setStrings([]);\n return;\n }\n const res = await client.getStrings({ keys: resolved });\n setStrings(res.strings);\n } catch (e) {\n setError(e instanceof Error ? e.message : \"Failed to load strings\");\n } finally {\n setBusy(false);\n }\n }, [client, keys, namespace]);\n\n useEffect(() => {\n if (consented) void loadStrings();\n }, [consented, loadStrings]);\n\n const accept = useCallback(async () => {\n setBusy(true);\n setError(null);\n try {\n await client.acceptTos();\n setConsented(true);\n } catch (e) {\n setError(e instanceof Error ? e.message : \"Could not accept the terms\");\n } finally {\n setBusy(false);\n }\n }, [client]);\n\n return (\n <div\n role=\"dialog\"\n aria-label=\"Translation feedback\"\n style={{\n position: \"fixed\",\n inset: 0,\n zIndex: 2147483600,\n background: \"rgba(0,0,0,.55)\",\n display: \"flex\",\n justifyContent: \"flex-end\",\n }}\n onClick={onClose}\n >\n <div\n onClick={(e) => e.stopPropagation()}\n style={{\n width: \"min(420px, 100%)\",\n height: \"100%\",\n background: C.bg,\n color: C.text,\n borderLeft: `1px solid ${C.border}`,\n display: \"flex\",\n flexDirection: \"column\",\n fontFamily: \"system-ui, sans-serif\",\n }}\n >\n <header\n style={{\n padding: \"16px 18px\",\n borderBottom: `1px solid ${C.border}`,\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n }}\n >\n <strong style={{ color: C.emeraldSoft }}>Translation feedback</strong>\n <button\n type=\"button\"\n onClick={onClose}\n aria-label=\"Close\"\n style={{\n background: \"transparent\",\n color: C.dim,\n border: \"none\",\n fontSize: 20,\n cursor: \"pointer\",\n }}\n >\n ×\n </button>\n </header>\n\n <div style={{ padding: 18, overflowY: \"auto\", flex: 1 }}>\n {error && (\n <p style={{ color: \"#f87171\", fontSize: 13 }}>{error}</p>\n )}\n\n {!consented ? (\n <ConsentStep\n version={client.tosVersion}\n busy={busy}\n onAccept={accept}\n />\n ) : busy && !strings.length ? (\n <p style={{ color: C.dim }}>Loading…</p>\n ) : !strings.length ? (\n <p style={{ color: C.dim }}>No strings to review on this view.</p>\n ) : (\n strings.map((s) => (\n <StringRow key={`${s.namespace}:${s.key}`} s={s} client={client} />\n ))\n )}\n </div>\n <footer\n style={{\n padding: \"10px 18px\",\n borderTop: `1px solid ${C.border}`,\n color: C.dim,\n fontSize: 11,\n }}\n >\n Powered by Verbumia\n </footer>\n </div>\n </div>\n );\n}\n\nfunction ConsentStep(props: {\n version?: string;\n busy: boolean;\n onAccept: () => void;\n}) {\n return (\n <div>\n <p style={{ lineHeight: 1.5, fontSize: 14 }}>\n Help improve the translations in this app. Your ratings and\n suggestions are sent to the app owner via Verbumia. Don’t submit\n personal or sensitive information.\n </p>\n <button\n type=\"button\"\n disabled={props.busy}\n onClick={props.onAccept}\n style={{\n marginTop: 12,\n width: \"100%\",\n background: C.emerald,\n color: \"#03110c\",\n border: \"none\",\n borderRadius: 8,\n padding: \"12px 14px\",\n fontWeight: 700,\n cursor: props.busy ? \"default\" : \"pointer\",\n opacity: props.busy ? 0.6 : 1,\n }}\n >\n {props.busy\n ? \"…\"\n : `I accept the terms${props.version ? ` (v${props.version})` : \"\"}`}\n </button>\n </div>\n );\n}\n\nfunction StringRow(props: { s: FeedbackString; client: FeedbackClient }) {\n const { s, client } = props;\n const [mine, setMine] = useState<number | null>(s.my_rating);\n const [showSuggest, setShowSuggest] = useState(false);\n const [text, setText] = useState(\"\");\n const [sent, setSent] = useState(false);\n\n const rate = (stars: number) => {\n setMine(stars);\n client.rate({\n namespace: s.namespace,\n key: s.key,\n language: client.language,\n translation_hash: s.translation_hash,\n stars,\n });\n };\n\n const submitSuggestion = () => {\n if (!text.trim()) return;\n client.suggest({\n namespace: s.namespace,\n key: s.key,\n language: client.language,\n translation_hash: s.translation_hash,\n suggested_text: text.trim(),\n });\n setSent(true);\n setShowSuggest(false);\n setText(\"\");\n };\n\n return (\n <div\n style={{\n background: C.panel,\n border: `1px solid ${C.border}`,\n borderRadius: 10,\n padding: 12,\n marginBottom: 10,\n }}\n >\n <div style={{ fontSize: 12, color: C.dim }}>\n {s.namespace} · {s.key}\n </div>\n <div style={{ margin: \"6px 0 10px\", fontSize: 15 }}>{s.value}</div>\n <div style={{ display: \"flex\", gap: 4 }}>\n {[1, 2, 3, 4, 5].map((n) => (\n <button\n key={n}\n type=\"button\"\n aria-label={`${n} star${n > 1 ? \"s\" : \"\"}`}\n onClick={() => rate(n)}\n style={{\n background: \"transparent\",\n border: \"none\",\n cursor: \"pointer\",\n fontSize: 20,\n color: mine && n <= mine ? C.emeraldSoft : C.border,\n }}\n >\n ★\n </button>\n ))}\n <button\n type=\"button\"\n onClick={() => setShowSuggest((v) => !v)}\n style={{\n marginLeft: \"auto\",\n background: \"transparent\",\n color: C.emeraldSoft,\n border: `1px solid ${C.border}`,\n borderRadius: 6,\n padding: \"4px 10px\",\n fontSize: 12,\n cursor: \"pointer\",\n }}\n >\n {sent ? \"Suggested ✓\" : \"Suggest\"}\n </button>\n </div>\n {showSuggest && (\n <div style={{ marginTop: 10 }}>\n <textarea\n value={text}\n onChange={(e) => setText(e.target.value)}\n rows={3}\n placeholder=\"Your suggested translation…\"\n style={{\n width: \"100%\",\n background: C.bg,\n color: C.text,\n border: `1px solid ${C.border}`,\n borderRadius: 6,\n padding: 8,\n fontSize: 14,\n resize: \"vertical\",\n }}\n />\n <button\n type=\"button\"\n onClick={submitSuggestion}\n style={{\n marginTop: 6,\n background: C.emerald,\n color: \"#03110c\",\n border: \"none\",\n borderRadius: 6,\n padding: \"8px 12px\",\n fontWeight: 700,\n cursor: \"pointer\",\n }}\n >\n Send suggestion\n </button>\n </div>\n )}\n </div>\n );\n}\n","/**\n * On-screen key discovery.\n *\n * Preferred source: the `@verbumia/*-i18n` SDK exposes a lightweight key\n * registry of keys it has rendered. When that registry is present on the\n * global (the i18n SDK publishes `globalThis.__verbumia_key_registry__`),\n * we read the keys touched on the current view. Otherwise the host app\n * passes an explicit `keys` list — the always-available fallback.\n *\n * The registry contract is intentionally tiny so any framework port of the\n * i18n SDK can implement it without depending on this package.\n */\n\nimport type { DeclaredKey } from \"./types\";\n\nconst REGISTRY_GLOBAL = \"__verbumia_key_registry__\";\n\ninterface KeyRegistry {\n /** Returns the keys rendered since the last `reset()` (or ever). */\n snapshot(): DeclaredKey[];\n reset?(): void;\n}\n\nfunction getRegistry(): KeyRegistry | null {\n const g = globalThis as Record<string, unknown>;\n const reg = g[REGISTRY_GLOBAL];\n if (\n reg &&\n typeof (reg as KeyRegistry).snapshot === \"function\"\n ) {\n return reg as KeyRegistry;\n }\n return null;\n}\n\n/** True when a compatible `@verbumia/*-i18n` registry is detectable. */\nexport function hasKeyRegistry(): boolean {\n return getRegistry() !== null;\n}\n\n/**\n * Resolve the on-screen keys: explicit `keys` prop always wins (it is the\n * customer's authoritative declaration); otherwise fall back to the i18n\n * registry snapshot; otherwise an empty list (widget shows \"no strings\").\n *\n * Optional `namespace` filter (task 618, CONTRACT v6 — ADDITIVE): when\n * set (a single namespace or a list), the resolved set is narrowed to\n * keys whose `namespace` is in the filter. The filter is applied AFTER\n * resolution, so it composes with v5 rendered-scoping as\n * `rendered ∩ namespace`. UNSET / empty ⇒ unchanged v5 behaviour (all\n * resolved keys). Backward-compatible: `resolveKeys(keys)` is unaffected.\n */\nexport function resolveKeys(\n explicit?: DeclaredKey[],\n namespace?: string | string[],\n): DeclaredKey[] {\n const base =\n explicit && explicit.length\n ? dedupe(explicit)\n : getRegistry()\n ? dedupe(getRegistry()!.snapshot())\n : [];\n return filterByNamespace(base, namespace);\n}\n\n/** Narrow keys to those whose namespace is in `namespace`. An undefined\n * filter, an empty string, or an empty list means \"no filter\" (the\n * additive default — identical to v5). Exported so non-panel callers\n * (e.g. a custom /core integration) can apply the same semantics. */\nexport function filterByNamespace(\n keys: DeclaredKey[],\n namespace?: string | string[],\n): DeclaredKey[] {\n const list = (Array.isArray(namespace) ? namespace : namespace ? [namespace] : [])\n .map((n) => n.trim())\n .filter(Boolean);\n if (!list.length) return keys;\n const allow = new Set(list);\n return keys.filter((k) => allow.has(k.namespace));\n}\n\nfunction dedupe(keys: DeclaredKey[]): DeclaredKey[] {\n const seen = new Set<string>();\n const out: DeclaredKey[] = [];\n for (const k of keys) {\n const id = `${k.namespace}:${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AAA,UACC,QAAQ;AAAA,UACR,MAAM,QAAQ;AAAA,UACd,WAAW,QAAQ;AAAA,UACnB,SAAS,MAAM;AACb,kBAAM,IAAI,KAAK;AACf,iBAAK,EAAE,MAAM;AAAA,UACf;AAAA;AAAA,MACF;AAAA,MACA,SAAS;AAAA,IACX;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,KAAK;AAKT,YAAM,kBACJ,QAAQ,YAAY,IAAI,MAAM,YAAY,IAAI,OAAO;AACvD,eAAS,IAAI,eAAe;AAAA,QAC1B,SACE,QAAQ,WAAW,IAAI,OAAO,WAAW;AAAA,QAC3C,WAAW,QAAQ,aAAa,IAAI,OAAO;AAAA,QAC3C,UAAU;AAAA,QACV,WAAW,QAAQ;AAAA,QACnB,WAAW,QAAQ;AAAA,MACrB,CAAC;AAMD,UAAI;AACJ,UAAI,OAAO,IAAI,qBAAqB,YAAY;AAC9C,oBAAY,IAAI,iBAAiB,CAAC,QAAQ,QAAQ,YAAY,GAAG,CAAC;AAAA,MACpE;AACA,YAAM,aAAiC;AAAA,QACrC,MAAM,MAAM,MAAM,IAAI,IAAI;AAAA,QAC1B,OAAO,MAAM;AACX,gBAAM,IAAI,KAAK;AACf,eAAK,QAAQ,MAAM;AAAA,QACrB;AAAA,QACA;AAAA,MACF;AACA,cAAQ,UAAU,UAAU;AAC5B,UAAI,QAAQ,cAAe,SAAQ,cAAc,UAAU;AAC3D,aAAO,MAAM;AACX,oBAAY;AACZ,YAAI,QAAQ,cAAe,SAAQ,cAAc,UAAU;AAC3D,aAAK,QAAQ,MAAM;AAAA,MACrB;AAAA,IACF;AAAA,IACA,QAAQ,MAAM,6CAAC,UAAO;AAAA,EACxB;AACF;","names":["import_react","import_jsx_runtime"]}
|
package/dist/react/index.d.cts
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { F as FeedbackClient, D as DeclaredKey } from '../client-
|
|
3
|
-
export { B as BatchResponse, a as FeedbackConfig, b as FeedbackError, c as FeedbackString, R as RatingInput, S as StringsResponse, d as SuggestionInput, T as TokenBundle } from '../client-
|
|
2
|
+
import { F as FeedbackClient, D as DeclaredKey } from '../client-qgDSbz3A.cjs';
|
|
3
|
+
export { B as BatchResponse, a as FeedbackConfig, b as FeedbackError, c as FeedbackString, R as RatingInput, S as StringsResponse, d as SuggestionInput, T as TokenBundle } from '../client-qgDSbz3A.cjs';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
-
export { h as hasKeyRegistry, r as resolveKeys } from '../keys-
|
|
5
|
+
export { h as hasKeyRegistry, r as resolveKeys } from '../keys-BhuK_fy1.cjs';
|
|
6
6
|
|
|
7
7
|
/** Structural mirror of `@verbumia/react-i18next`'s VerbumiaPlugin —
|
|
8
|
-
* kept local so feedback has no build-time dep on the i18n SDK.
|
|
8
|
+
* kept local so feedback has no build-time dep on the i18n SDK. The
|
|
9
|
+
* `i18n` and `onLanguageChange` fields are optional so a plugin attached
|
|
10
|
+
* to a non-Verbumia host (or to a pre-1.0.5 react-i18next) keeps
|
|
11
|
+
* working — runtime language re-sync is just disabled. From feedback
|
|
12
|
+
* ≥0.2.6, the peerDep on `@verbumia/react-i18next` is `>=1.0.5`, so the
|
|
13
|
+
* lang-change subscription path is guaranteed available in matched
|
|
14
|
+
* installs. */
|
|
9
15
|
interface I18nPluginContext {
|
|
16
|
+
i18n?: {
|
|
17
|
+
language?: string;
|
|
18
|
+
};
|
|
10
19
|
config: {
|
|
11
20
|
apiBase?: string;
|
|
12
21
|
projectUuid: string;
|
|
13
22
|
defaultLocale: string;
|
|
14
23
|
};
|
|
24
|
+
/** #806 — subscribe to runtime language changes (see VerbumiaPluginContext
|
|
25
|
+
* in `@verbumia/react-i18next` ≥1.0.5). Returns an unsubscribe fn the
|
|
26
|
+
* plugin MUST call from teardown. Optional so attaching to a
|
|
27
|
+
* pre-1.0.5 react-i18next falls back gracefully (no auto re-sync;
|
|
28
|
+
* consumer can still pass `options.language` explicitly). */
|
|
29
|
+
onLanguageChange?: (cb: (lng: string) => void) => () => void;
|
|
15
30
|
}
|
|
16
31
|
interface I18nPlugin {
|
|
17
32
|
name: string;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { F as FeedbackClient, D as DeclaredKey } from '../client-
|
|
3
|
-
export { B as BatchResponse, a as FeedbackConfig, b as FeedbackError, c as FeedbackString, R as RatingInput, S as StringsResponse, d as SuggestionInput, T as TokenBundle } from '../client-
|
|
2
|
+
import { F as FeedbackClient, D as DeclaredKey } from '../client-qgDSbz3A.js';
|
|
3
|
+
export { B as BatchResponse, a as FeedbackConfig, b as FeedbackError, c as FeedbackString, R as RatingInput, S as StringsResponse, d as SuggestionInput, T as TokenBundle } from '../client-qgDSbz3A.js';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
-
export { h as hasKeyRegistry, r as resolveKeys } from '../keys-
|
|
5
|
+
export { h as hasKeyRegistry, r as resolveKeys } from '../keys-CEWu0Htb.js';
|
|
6
6
|
|
|
7
7
|
/** Structural mirror of `@verbumia/react-i18next`'s VerbumiaPlugin —
|
|
8
|
-
* kept local so feedback has no build-time dep on the i18n SDK.
|
|
8
|
+
* kept local so feedback has no build-time dep on the i18n SDK. The
|
|
9
|
+
* `i18n` and `onLanguageChange` fields are optional so a plugin attached
|
|
10
|
+
* to a non-Verbumia host (or to a pre-1.0.5 react-i18next) keeps
|
|
11
|
+
* working — runtime language re-sync is just disabled. From feedback
|
|
12
|
+
* ≥0.2.6, the peerDep on `@verbumia/react-i18next` is `>=1.0.5`, so the
|
|
13
|
+
* lang-change subscription path is guaranteed available in matched
|
|
14
|
+
* installs. */
|
|
9
15
|
interface I18nPluginContext {
|
|
16
|
+
i18n?: {
|
|
17
|
+
language?: string;
|
|
18
|
+
};
|
|
10
19
|
config: {
|
|
11
20
|
apiBase?: string;
|
|
12
21
|
projectUuid: string;
|
|
13
22
|
defaultLocale: string;
|
|
14
23
|
};
|
|
24
|
+
/** #806 — subscribe to runtime language changes (see VerbumiaPluginContext
|
|
25
|
+
* in `@verbumia/react-i18next` ≥1.0.5). Returns an unsubscribe fn the
|
|
26
|
+
* plugin MUST call from teardown. Optional so attaching to a
|
|
27
|
+
* pre-1.0.5 react-i18next falls back gracefully (no auto re-sync;
|
|
28
|
+
* consumer can still pass `options.language` explicitly). */
|
|
29
|
+
onLanguageChange?: (cb: (lng: string) => void) => () => void;
|
|
15
30
|
}
|
|
16
31
|
interface I18nPlugin {
|
|
17
32
|
name: string;
|
package/dist/react/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
FeedbackError,
|
|
5
5
|
hasKeyRegistry,
|
|
6
6
|
resolveKeys
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-5RTFWOGT.js";
|
|
8
8
|
|
|
9
9
|
// src/react/plugin.tsx
|
|
10
10
|
import { createPortal } from "react-dom";
|
|
@@ -356,13 +356,18 @@ function feedbackPlugin(options) {
|
|
|
356
356
|
return {
|
|
357
357
|
name: "@verbumia/feedback",
|
|
358
358
|
setup(ctx) {
|
|
359
|
+
const initialLanguage = options.language ?? ctx.i18n?.language ?? ctx.config.defaultLocale;
|
|
359
360
|
client = new FeedbackClient({
|
|
360
361
|
apiBase: options.apiBase ?? ctx.config.apiBase ?? "https://api.verbumia.dev",
|
|
361
362
|
projectId: options.projectId ?? ctx.config.projectUuid,
|
|
362
|
-
language:
|
|
363
|
+
language: initialLanguage,
|
|
363
364
|
endUserId: options.endUserId,
|
|
364
365
|
fetchImpl: options.fetchImpl
|
|
365
366
|
});
|
|
367
|
+
let langUnsub;
|
|
368
|
+
if (typeof ctx.onLanguageChange === "function") {
|
|
369
|
+
langUnsub = ctx.onLanguageChange((lng) => client?.setLanguage(lng));
|
|
370
|
+
}
|
|
366
371
|
const controller = {
|
|
367
372
|
open: () => store.set(true),
|
|
368
373
|
close: () => {
|
|
@@ -374,6 +379,7 @@ function feedbackPlugin(options) {
|
|
|
374
379
|
options.onReady?.(controller);
|
|
375
380
|
if (options.controllerRef) options.controllerRef.current = controller;
|
|
376
381
|
return () => {
|
|
382
|
+
langUnsub?.();
|
|
377
383
|
if (options.controllerRef) options.controllerRef.current = null;
|
|
378
384
|
void client?.flush();
|
|
379
385
|
};
|