@intellectif/lk-react 6.0.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +386 -0
  2. package/README.md +45 -12
  3. package/dist/{WrittenResponse-BfpzfLlR.d.cts → WrittenResponse-BJL4dGsR.d.ts} +6 -2
  4. package/dist/{WrittenResponse-C3GIWErG.d.ts → WrittenResponse-zWT-Go1g.d.cts} +6 -2
  5. package/dist/{chunk-E4MNA2IQ.js → chunk-2TW6WLBC.js} +3 -2
  6. package/dist/chunk-2TW6WLBC.js.map +1 -0
  7. package/dist/chunk-6F4X2NKL.js +1 -0
  8. package/dist/chunk-6N43WDVG.js +1 -0
  9. package/dist/chunk-6ZKVJAO6.js +540 -0
  10. package/dist/chunk-6ZKVJAO6.js.map +1 -0
  11. package/dist/chunk-A572N5G7.cjs +542 -0
  12. package/dist/chunk-A572N5G7.cjs.map +1 -0
  13. package/dist/{chunk-CPF2JJG6.cjs → chunk-AMGK7DDM.cjs} +32 -2
  14. package/dist/chunk-AMGK7DDM.cjs.map +1 -0
  15. package/dist/{chunk-UQ3BBEIT.js → chunk-BG456EM3.js} +22 -5
  16. package/dist/chunk-BG456EM3.js.map +1 -0
  17. package/dist/{chunk-YXG3UJVG.cjs → chunk-BNESCXJ5.cjs} +17 -4
  18. package/dist/chunk-BNESCXJ5.cjs.map +1 -0
  19. package/dist/{chunk-BQHDQ33H.js → chunk-CMZGT26S.js} +22 -4
  20. package/dist/chunk-CMZGT26S.js.map +1 -0
  21. package/dist/{chunk-B3FUUKZ2.js → chunk-DQNVAXG6.js} +32 -3
  22. package/dist/chunk-DQNVAXG6.js.map +1 -0
  23. package/dist/{chunk-57E3E2H4.js → chunk-J23XVR2B.js} +17 -4
  24. package/dist/chunk-J23XVR2B.js.map +1 -0
  25. package/dist/{chunk-PBVMEOWI.cjs → chunk-J4LP4CLY.cjs} +110 -29
  26. package/dist/chunk-J4LP4CLY.cjs.map +1 -0
  27. package/dist/{chunk-NEWGUDA5.cjs → chunk-KK4WGW2V.cjs} +22 -5
  28. package/dist/chunk-KK4WGW2V.cjs.map +1 -0
  29. package/dist/{chunk-R3OZ6JHQ.cjs → chunk-KPI335JJ.cjs} +22 -4
  30. package/dist/chunk-KPI335JJ.cjs.map +1 -0
  31. package/dist/{chunk-5TUTJ4R3.js → chunk-MB532SXM.js} +17 -4
  32. package/dist/chunk-MB532SXM.js.map +1 -0
  33. package/dist/chunk-PGEG7UZJ.cjs +1 -0
  34. package/dist/{chunk-IYLQSNLE.cjs → chunk-PNNUPUH4.cjs} +3 -2
  35. package/dist/chunk-PNNUPUH4.cjs.map +1 -0
  36. package/dist/{chunk-NPY2F7F6.cjs → chunk-VXOOGQ6W.cjs} +17 -4
  37. package/dist/chunk-VXOOGQ6W.cjs.map +1 -0
  38. package/dist/chunk-XOR4MPEN.cjs +1 -0
  39. package/dist/{chunk-OQGBAQL2.js → chunk-ZPVMB3LH.js} +108 -27
  40. package/dist/chunk-ZPVMB3LH.js.map +1 -0
  41. package/dist/components/ActivitySequence.cjs +8 -7
  42. package/dist/components/ActivitySequence.d.cts +29 -23
  43. package/dist/components/ActivitySequence.d.ts +29 -23
  44. package/dist/components/ActivitySequence.js +7 -6
  45. package/dist/components/FillInTheBlanks.cjs +4 -3
  46. package/dist/components/FillInTheBlanks.d.cts +1 -1
  47. package/dist/components/FillInTheBlanks.d.ts +1 -1
  48. package/dist/components/FillInTheBlanks.js +3 -2
  49. package/dist/components/MultipleChoice.cjs +4 -3
  50. package/dist/components/MultipleChoice.d.cts +2 -2
  51. package/dist/components/MultipleChoice.d.ts +2 -2
  52. package/dist/components/MultipleChoice.js +3 -2
  53. package/dist/components/StimulusPanel.cjs +4 -3
  54. package/dist/components/StimulusPanel.d.cts +19 -3
  55. package/dist/components/StimulusPanel.d.ts +19 -3
  56. package/dist/components/StimulusPanel.js +3 -2
  57. package/dist/components/WrittenResponse.cjs +4 -3
  58. package/dist/components/WrittenResponse.d.cts +3 -3
  59. package/dist/components/WrittenResponse.d.ts +3 -3
  60. package/dist/components/WrittenResponse.js +3 -2
  61. package/dist/hooks/useActivityState.cjs +1 -0
  62. package/dist/hooks/useActivityState.js +1 -0
  63. package/dist/hooks/useXAPI.cjs +3 -2
  64. package/dist/hooks/useXAPI.d.cts +31 -0
  65. package/dist/hooks/useXAPI.d.ts +31 -0
  66. package/dist/hooks/useXAPI.js +2 -1
  67. package/dist/index.cjs +23 -18
  68. package/dist/index.cjs.map +1 -1
  69. package/dist/index.d.cts +3 -3
  70. package/dist/index.d.ts +3 -3
  71. package/dist/index.js +9 -8
  72. package/dist/index.js.map +1 -1
  73. package/dist/theme/ThemeProvider.cjs +10 -5
  74. package/dist/theme/ThemeProvider.d.cts +21 -1
  75. package/dist/theme/ThemeProvider.d.ts +21 -1
  76. package/dist/theme/ThemeProvider.js +2 -1
  77. package/dist/theme/skin.css +211 -8
  78. package/dist/types-eXX4hzSj.d.cts +307 -0
  79. package/dist/types-eXX4hzSj.d.ts +307 -0
  80. package/package.json +28 -5
  81. package/dist/chunk-4HZ7LQIH.cjs +0 -40
  82. package/dist/chunk-4HZ7LQIH.cjs.map +0 -1
  83. package/dist/chunk-57E3E2H4.js.map +0 -1
  84. package/dist/chunk-5TUTJ4R3.js.map +0 -1
  85. package/dist/chunk-B3FUUKZ2.js.map +0 -1
  86. package/dist/chunk-BQHDQ33H.js.map +0 -1
  87. package/dist/chunk-CPF2JJG6.cjs.map +0 -1
  88. package/dist/chunk-E4MNA2IQ.js.map +0 -1
  89. package/dist/chunk-GB5URWM4.js +0 -38
  90. package/dist/chunk-GB5URWM4.js.map +0 -1
  91. package/dist/chunk-IYLQSNLE.cjs.map +0 -1
  92. package/dist/chunk-NEWGUDA5.cjs.map +0 -1
  93. package/dist/chunk-NPY2F7F6.cjs.map +0 -1
  94. package/dist/chunk-OQGBAQL2.js.map +0 -1
  95. package/dist/chunk-PBVMEOWI.cjs.map +0 -1
  96. package/dist/chunk-R3OZ6JHQ.cjs.map +0 -1
  97. package/dist/chunk-UQ3BBEIT.js.map +0 -1
  98. package/dist/chunk-YXG3UJVG.cjs.map +0 -1
  99. package/dist/types-DlHmPLbD.d.cts +0 -165
  100. package/dist/types-DlHmPLbD.d.ts +0 -165
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  export { useActivityState } from '../chunk-6N43WDVG.js';
2
3
  //# sourceMappingURL=useActivityState.js.map
3
4
  //# sourceMappingURL=useActivityState.js.map
@@ -1,12 +1,13 @@
1
+ 'use client';
1
2
  'use strict';
2
3
 
3
- var chunkIYLQSNLE_cjs = require('../chunk-IYLQSNLE.cjs');
4
+ var chunkPNNUPUH4_cjs = require('../chunk-PNNUPUH4.cjs');
4
5
 
5
6
 
6
7
 
7
8
  Object.defineProperty(exports, "useXAPI", {
8
9
  enumerable: true,
9
- get: function () { return chunkIYLQSNLE_cjs.useXAPI; }
10
+ get: function () { return chunkPNNUPUH4_cjs.useXAPI; }
10
11
  });
11
12
  //# sourceMappingURL=useXAPI.cjs.map
12
13
  //# sourceMappingURL=useXAPI.cjs.map
@@ -10,6 +10,37 @@ interface UseXAPIResult {
10
10
  */
11
11
  sendStatement: (statement: XAPIStatement) => Promise<void>;
12
12
  }
13
+ /**
14
+ * Delivers xAPI statements to a Learning Record Store, fire-and-forget.
15
+ *
16
+ * Telemetry must never break the learner's attempt, so
17
+ * {@link UseXAPIResult.sendStatement} **never rejects**: network errors and 5xx
18
+ * responses are retried (backoff 1s / 2s / 4s, up to 3 retries), a 4xx fails
19
+ * immediately, and any final failure is reported to `config.onError` instead of
20
+ * throwing. See `XAPIConfig` in `@intellectif/lk-core` for the options.
21
+ *
22
+ * The hook is also where learner identity is applied. Activity components
23
+ * cannot know who the learner is, so they emit an anonymous placeholder actor
24
+ * and a `urn:learning-kit:activity:*` object id; this hook substitutes
25
+ * `config.actor` and `config.activityId` on the way out — and only while those
26
+ * placeholders are still in place, so a statement you rewrote yourself is left
27
+ * alone.
28
+ *
29
+ * `sendStatement` keeps a stable identity across renders even when `config` is
30
+ * an inline object, so it is safe in a dependency array.
31
+ *
32
+ * ```tsx
33
+ * const { sendStatement } = useXAPI({
34
+ * endpoint: 'https://your-lrs.example/xapi/statements',
35
+ * auth: { type: 'bearer', token: 'YOUR_TOKEN' },
36
+ * activityId: 'https://your-app.example/quiz/capital-jp',
37
+ * actor: { objectType: 'Agent', mbox: 'mailto:learner@example.com' },
38
+ * onError: (e) => console.error('xAPI send failed', e),
39
+ * });
40
+ *
41
+ * <MultipleChoice data={quiz} onComplete={(r) => void sendStatement(r.xapiStatement)} />
42
+ * ```
43
+ */
13
44
  declare function useXAPI(config: XAPIConfig): UseXAPIResult;
14
45
 
15
46
  export { type UseXAPIResult, useXAPI };
@@ -10,6 +10,37 @@ interface UseXAPIResult {
10
10
  */
11
11
  sendStatement: (statement: XAPIStatement) => Promise<void>;
12
12
  }
13
+ /**
14
+ * Delivers xAPI statements to a Learning Record Store, fire-and-forget.
15
+ *
16
+ * Telemetry must never break the learner's attempt, so
17
+ * {@link UseXAPIResult.sendStatement} **never rejects**: network errors and 5xx
18
+ * responses are retried (backoff 1s / 2s / 4s, up to 3 retries), a 4xx fails
19
+ * immediately, and any final failure is reported to `config.onError` instead of
20
+ * throwing. See `XAPIConfig` in `@intellectif/lk-core` for the options.
21
+ *
22
+ * The hook is also where learner identity is applied. Activity components
23
+ * cannot know who the learner is, so they emit an anonymous placeholder actor
24
+ * and a `urn:learning-kit:activity:*` object id; this hook substitutes
25
+ * `config.actor` and `config.activityId` on the way out — and only while those
26
+ * placeholders are still in place, so a statement you rewrote yourself is left
27
+ * alone.
28
+ *
29
+ * `sendStatement` keeps a stable identity across renders even when `config` is
30
+ * an inline object, so it is safe in a dependency array.
31
+ *
32
+ * ```tsx
33
+ * const { sendStatement } = useXAPI({
34
+ * endpoint: 'https://your-lrs.example/xapi/statements',
35
+ * auth: { type: 'bearer', token: 'YOUR_TOKEN' },
36
+ * activityId: 'https://your-app.example/quiz/capital-jp',
37
+ * actor: { objectType: 'Agent', mbox: 'mailto:learner@example.com' },
38
+ * onError: (e) => console.error('xAPI send failed', e),
39
+ * });
40
+ *
41
+ * <MultipleChoice data={quiz} onComplete={(r) => void sendStatement(r.xapiStatement)} />
42
+ * ```
43
+ */
13
44
  declare function useXAPI(config: XAPIConfig): UseXAPIResult;
14
45
 
15
46
  export { type UseXAPIResult, useXAPI };
@@ -1,3 +1,4 @@
1
- export { useXAPI } from '../chunk-E4MNA2IQ.js';
1
+ 'use client';
2
+ export { useXAPI } from '../chunk-2TW6WLBC.js';
2
3
  //# sourceMappingURL=useXAPI.js.map
3
4
  //# sourceMappingURL=useXAPI.js.map
package/dist/index.cjs CHANGED
@@ -1,15 +1,16 @@
1
+ 'use client';
1
2
  'use strict';
2
3
 
3
- var chunkCPF2JJG6_cjs = require('./chunk-CPF2JJG6.cjs');
4
- var chunkPBVMEOWI_cjs = require('./chunk-PBVMEOWI.cjs');
5
- var chunkYXG3UJVG_cjs = require('./chunk-YXG3UJVG.cjs');
6
- var chunkNPY2F7F6_cjs = require('./chunk-NPY2F7F6.cjs');
7
- var chunkR3OZ6JHQ_cjs = require('./chunk-R3OZ6JHQ.cjs');
4
+ var chunkAMGK7DDM_cjs = require('./chunk-AMGK7DDM.cjs');
5
+ var chunkJ4LP4CLY_cjs = require('./chunk-J4LP4CLY.cjs');
6
+ var chunkBNESCXJ5_cjs = require('./chunk-BNESCXJ5.cjs');
7
+ var chunkVXOOGQ6W_cjs = require('./chunk-VXOOGQ6W.cjs');
8
+ var chunkKPI335JJ_cjs = require('./chunk-KPI335JJ.cjs');
8
9
  require('./chunk-PGEG7UZJ.cjs');
9
- var chunkNEWGUDA5_cjs = require('./chunk-NEWGUDA5.cjs');
10
- require('./chunk-4HZ7LQIH.cjs');
10
+ var chunkKK4WGW2V_cjs = require('./chunk-KK4WGW2V.cjs');
11
+ require('./chunk-A572N5G7.cjs');
11
12
  var chunkXOR4MPEN_cjs = require('./chunk-XOR4MPEN.cjs');
12
- var chunkIYLQSNLE_cjs = require('./chunk-IYLQSNLE.cjs');
13
+ var chunkPNNUPUH4_cjs = require('./chunk-PNNUPUH4.cjs');
13
14
 
14
15
  // src/components/types.ts
15
16
  function asRenderable(redacted) {
@@ -21,39 +22,43 @@ function asRenderableSequence(entries) {
21
22
 
22
23
  Object.defineProperty(exports, "ThemeProvider", {
23
24
  enumerable: true,
24
- get: function () { return chunkCPF2JJG6_cjs.ThemeProvider; }
25
+ get: function () { return chunkAMGK7DDM_cjs.ThemeProvider; }
26
+ });
27
+ Object.defineProperty(exports, "createTailwindTheme", {
28
+ enumerable: true,
29
+ get: function () { return chunkAMGK7DDM_cjs.createTailwindTheme; }
25
30
  });
26
31
  Object.defineProperty(exports, "darkTheme", {
27
32
  enumerable: true,
28
- get: function () { return chunkCPF2JJG6_cjs.darkTheme; }
33
+ get: function () { return chunkAMGK7DDM_cjs.darkTheme; }
29
34
  });
30
35
  Object.defineProperty(exports, "defaultTheme", {
31
36
  enumerable: true,
32
- get: function () { return chunkCPF2JJG6_cjs.defaultTheme; }
37
+ get: function () { return chunkAMGK7DDM_cjs.defaultTheme; }
33
38
  });
34
39
  Object.defineProperty(exports, "useTheme", {
35
40
  enumerable: true,
36
- get: function () { return chunkCPF2JJG6_cjs.useTheme; }
41
+ get: function () { return chunkAMGK7DDM_cjs.useTheme; }
37
42
  });
38
43
  Object.defineProperty(exports, "ActivitySequence", {
39
44
  enumerable: true,
40
- get: function () { return chunkPBVMEOWI_cjs.ActivitySequence; }
45
+ get: function () { return chunkJ4LP4CLY_cjs.ActivitySequence; }
41
46
  });
42
47
  Object.defineProperty(exports, "MultipleChoice", {
43
48
  enumerable: true,
44
- get: function () { return chunkYXG3UJVG_cjs.MultipleChoice; }
49
+ get: function () { return chunkBNESCXJ5_cjs.MultipleChoice; }
45
50
  });
46
51
  Object.defineProperty(exports, "FillInTheBlanks", {
47
52
  enumerable: true,
48
- get: function () { return chunkNPY2F7F6_cjs.FillInTheBlanks; }
53
+ get: function () { return chunkVXOOGQ6W_cjs.FillInTheBlanks; }
49
54
  });
50
55
  Object.defineProperty(exports, "WrittenResponse", {
51
56
  enumerable: true,
52
- get: function () { return chunkR3OZ6JHQ_cjs.WrittenResponse; }
57
+ get: function () { return chunkKPI335JJ_cjs.WrittenResponse; }
53
58
  });
54
59
  Object.defineProperty(exports, "StimulusPanel", {
55
60
  enumerable: true,
56
- get: function () { return chunkNEWGUDA5_cjs.StimulusPanel; }
61
+ get: function () { return chunkKK4WGW2V_cjs.StimulusPanel; }
57
62
  });
58
63
  Object.defineProperty(exports, "useActivityState", {
59
64
  enumerable: true,
@@ -61,7 +66,7 @@ Object.defineProperty(exports, "useActivityState", {
61
66
  });
62
67
  Object.defineProperty(exports, "useXAPI", {
63
68
  enumerable: true,
64
- get: function () { return chunkIYLQSNLE_cjs.useXAPI; }
69
+ get: function () { return chunkPNNUPUH4_cjs.useXAPI; }
65
70
  });
66
71
  exports.asRenderable = asRenderable;
67
72
  exports.asRenderableSequence = asRenderableSequence;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAoJO,SAAS,aACd,QAAA,EACmB;AACnB,EAAA,OAAO,QAAA;AACT;AA4BO,SAAS,qBACd,OAAA,EAC8C;AAC9C,EAAA,OAAO,OAAA;AACT","file":"index.cjs","sourcesContent":["import type {\n ActivityData,\n ActivityResult,\n InteractionEvent,\n ItemGroup,\n ItemOutcome,\n LearnerResponse,\n RedactedActivityData,\n SequenceEntry,\n ThemeTokens,\n} from '@intellectif/lk-core';\n\n/**\n * How an activity is being presented. This is the single switch that decides\n * whether the component may grade, reveal, or submit — the three things a\n * summative exam must take away from the client.\n *\n * - `practice` (default, v1 behaviour): the component owns the attempt. It\n * scores locally on submit, reveals correctness and feedback, and calls\n * `onComplete` with a full {@link ActivityResult}.\n * - `exam`: the component NEVER scores and NEVER reveals correctness. Submit\n * emits the raw learner response through `onSubmit`; the server grades it.\n * Safe to render redacted data, because nothing here needs the answer key.\n * - `review`: read-only. Renders the learner's submitted answer, and marks\n * correctness only from an `outcome` the caller supplies (which the server\n * computed). Nothing is submittable.\n */\nexport type RenderMode = 'practice' | 'exam' | 'review';\n\n/**\n * Makes the answer-key-bearing parts of an activity optional, so a component\n * can render either full activity data OR a `redact()` projection with the\n * same props. Fields the SDK classifies `answer-key` become optional here;\n * a component in `exam` mode must not read them at all.\n */\nexport type Renderable<TData> = Omit<TData, 'scoringStrategy'> & {\n scoringStrategy?: unknown;\n /** Present on a `redact()` projection. */\n redacted?: true;\n};\n\n/**\n * {@link Renderable} DISTRIBUTED over a union of activity types.\n *\n * This distinction is load-bearing, not cosmetic. `Renderable<T>` is built on\n * `Omit`, and `Omit` does not distribute: `Omit<A | B, K>` collapses to the\n * keys A and B have IN COMMON, so `Renderable<ActivityData>` is a single\n * object type carrying only the fields every activity shares. Narrowing it\n * dies with it — after `if (data.type === 'multiple-choice')` the compiler\n * still refuses `data.options`, because the union it would narrow to no\n * longer exists.\n *\n * The conditional below re-distributes, so `RenderableActivity` is a real\n * union of per-type renderables and `.type` narrows again. Anything that\n * accepts \"some renderable activity, I don't know which\" — a custom renderer,\n * a sequence entry — must use THIS, not `Renderable<ActivityData>`.\n */\nexport type RenderableActivity<TData extends ActivityData = ActivityData> = TData extends unknown\n ? Renderable<TData>\n : never;\n\n/**\n * Sanitiser for author-supplied rich text (`questionHtml`, `passageHtml`,\n * `promptHtml`). The SDK deliberately ships NO sanitiser — that would add a\n * dependency and, worse, a false promise. Rich text is rendered only when you\n * supply this function; without it the component falls back to the plain-text\n * field, which is always escaped. Fail-safe by construction: the SDK never\n * injects HTML it was not explicitly given a sanitiser for.\n */\nexport type HtmlSanitizer = (html: string) => string;\n\n/**\n * The prop contract shared by every activity component (Req 3.1). Defined\n * here (React-specific) rather than in lk-core, which is React-free.\n *\n * Controlled / uncontrolled follows the React convention: pass `value` +\n * `onChange` to own the learner's answer (restore an in-progress attempt,\n * autosave a delta, drive a review); pass `defaultValue` to seed an\n * uncontrolled component; pass neither for the v1 behaviour.\n */\nexport interface ActivityProps<TData extends ActivityData = ActivityData> {\n /** Activity content. Accepts a `redact()` projection in `exam` mode. */\n data: RenderableActivity<TData>;\n /**\n * Called when the component scored the attempt itself. Only ever fires in\n * `practice` mode — in `exam` mode the client does not grade, so there is\n * no `ActivityResult` to give you; use `onSubmit`.\n */\n onComplete?: (result: ActivityResult) => void;\n /**\n * Called on submit with the raw learner response and no grade. Fires in\n * every mode, before `onComplete`, so an exam runner can persist the\n * response and let the server score it.\n */\n onSubmit?: (response: LearnerResponse) => void;\n /** Controlled value: the learner's current response. */\n value?: LearnerResponse;\n /** Initial response for an uncontrolled component (ignored when `value` is set). */\n defaultValue?: LearnerResponse;\n /**\n * Mount the component as already submitted — read at mount only, like any\n * `default*` prop.\n *\n * Restoring an attempt without it reopens a question the learner had already\n * submitted as answerable, so on a summative paper they can change and\n * re-submit it. `AttemptState.submittedSlotIds` is what this consumes.\n */\n defaultSubmitted?: boolean;\n /** Fires on every change to the learner's response. Required for a controlled component. */\n onChange?: (response: LearnerResponse) => void;\n /** Presentation mode. Defaults to `practice`. */\n renderMode?: RenderMode;\n /**\n * Server-computed outcome, used by `review` mode to mark correctness\n * without the client ever scoring. Ignored in other modes.\n */\n outcome?: ItemOutcome;\n /** Renders author-supplied rich text when provided. See {@link HtmlSanitizer}. */\n sanitizeHtml?: HtmlSanitizer;\n onInteraction?: (event: InteractionEvent) => void;\n /** Per-instance token overrides, applied as inline CSS vars on the root. */\n theme?: Partial<ThemeTokens>;\n locale?: string;\n disabled?: boolean;\n}\n\n/**\n * Bridges a server-produced `redact()` projection into the `data` prop.\n *\n * `RedactedActivityData` is deliberately index-signature typed in lk-core — it\n * proves a payload is learner-safe, not what shape it has — so TypeScript\n * cannot know it still carries the public fields a renderer needs. This is the\n * SDK's single, documented crossing of that gap, so an exam runner does not\n * have to write `as unknown as` at every call site:\n *\n * ```tsx\n * <MultipleChoice\n * data={asRenderable<MultipleChoiceData>(redactedFromServer)}\n * renderMode=\"exam\"\n * onSubmit={persist}\n * />\n * ```\n *\n * Safe because `exam` mode reads only public fields; the answer-key fields the\n * type claims are exactly the ones the component is forbidden to touch there.\n * A future release will derive per-type redacted interfaces so this becomes\n * unnecessary.\n */\nexport function asRenderable<TData extends ActivityData>(\n redacted: RedactedActivityData,\n): Renderable<TData> {\n return redacted as unknown as Renderable<TData>;\n}\n\n/**\n * The same bridge as {@link asRenderable}, for a whole sequence: activities\n * and item groups as a server hands them over, ready for `<ActivitySequence>`.\n *\n * Needed for the same reason and no other. `redactItemGroup` returns\n * `ItemGroup<RedactedActivityData>`, and `RedactedActivityData` is an\n * index-signature type whose fields are all `unknown` — so its `question` is\n * not a `string` and it satisfies no per-type renderable, however the prop is\n * widened. Widening alone cannot fix this; a crossing point is required, and\n * having exactly one keeps `as unknown as` out of consumer code.\n *\n * ```tsx\n * const entries = await fetchExam(); // redacted, server-side\n * <ActivitySequence\n * activities={asRenderableSequence(entries)}\n * renderMode=\"exam\" // REQUIRED: see below\n * shuffleSeed={attemptId}\n * onSubmit={persist}\n * />\n * ```\n *\n * Pass `renderMode=\"exam\"` (or `\"review\"`). Redacted data has no answer key,\n * and the default `practice` mode grades locally — the built-in components\n * throw at render rather than fail at submit time, so a mis-wired exam item is\n * loud, not silent.\n */\nexport function asRenderableSequence(\n entries: readonly (RedactedActivityData | RedactedItemGroupData)[],\n): readonly SequenceEntry<RenderableActivity>[] {\n return entries as unknown as readonly SequenceEntry<RenderableActivity>[];\n}\n\n/** Structural shape of a `redactItemGroup()` projection, as it arrives from a server. */\ntype RedactedItemGroupData = ItemGroup<RedactedActivityData> & { redacted: true };\n"]}
1
+ {"version":3,"sources":["../src/components/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AA2KO,SAAS,aACd,QAAA,EACmB;AACnB,EAAA,OAAO,QAAA;AACT;AAgCO,SAAS,qBACd,OAAA,EAC8C;AAC9C,EAAA,OAAO,OAAA;AACT","file":"index.cjs","sourcesContent":["import type {\n ActivityData,\n ActivityResult,\n InteractionEvent,\n ItemGroup,\n ItemOutcome,\n LearnerResponse,\n MediaPlayClaim,\n MediaPlayGrant,\n MediaPlayLedgerEntry,\n RedactedActivityData,\n SequenceEntry,\n ThemeTokens,\n} from '@intellectif/lk-core';\n\n/**\n * How an activity is being presented. This is the single switch that decides\n * whether the component may grade, reveal, or submit — the three things a\n * summative exam must take away from the client.\n *\n * - `practice` (default, and the only behaviour before `renderMode` existed):\n * the component owns the attempt. It\n * scores locally on submit, reveals correctness and feedback, and calls\n * `onComplete` with a full {@link ActivityResult}.\n * - `exam`: the component NEVER scores and NEVER reveals correctness. Submit\n * emits the raw learner response through `onSubmit`; the server grades it.\n * Safe to render redacted data, because nothing here needs the answer key.\n * - `review`: read-only. Renders the learner's submitted answer, and marks\n * correctness only from an `outcome` the caller supplies (which the server\n * computed). Nothing is submittable.\n */\nexport type RenderMode = 'practice' | 'exam' | 'review';\n\n/**\n * Makes the answer-key-bearing parts of an activity optional, so a component\n * can render either full activity data OR a `redact()` projection with the\n * same props. Fields the SDK classifies `answer-key` become optional here;\n * a component in `exam` mode must not read them at all.\n */\nexport type Renderable<TData> = Omit<TData, 'scoringStrategy'> & {\n scoringStrategy?: unknown;\n /** Present on a `redact()` projection. */\n redacted?: true;\n};\n\n/**\n * {@link Renderable} DISTRIBUTED over a union of activity types.\n *\n * This distinction is load-bearing, not cosmetic. `Renderable<T>` is built on\n * `Omit`, and `Omit` does not distribute: `Omit<A | B, K>` collapses to the\n * keys A and B have IN COMMON, so `Renderable<ActivityData>` is a single\n * object type carrying only the fields every activity shares. Narrowing it\n * dies with it — after `if (data.type === 'multiple-choice')` the compiler\n * still refuses `data.options`, because the union it would narrow to no\n * longer exists.\n *\n * The conditional below re-distributes, so `RenderableActivity` is a real\n * union of per-type renderables and `.type` narrows again. Anything that\n * accepts \"some renderable activity, I don't know which\" — a custom renderer,\n * a sequence entry — must use THIS, not `Renderable<ActivityData>`.\n */\nexport type RenderableActivity<TData extends ActivityData = ActivityData> = TData extends unknown\n ? Renderable<TData>\n : never;\n\n/**\n * Sanitiser for author-supplied rich text (`questionHtml`, `promptHtml`, and a\n * stimulus's `bodyHtml`). The SDK deliberately ships NO sanitiser — that would\n * add a dependency and, worse, a false promise. Rich text is rendered only when\n * you supply this function; without it the component falls back to the\n * plain-text field, which is always escaped. Fail-safe by construction: the SDK\n * never injects HTML it was not explicitly given a sanitiser for.\n *\n * `FillInTheBlanks.passageHtml` is the one exception, and is **never**\n * rendered: the passage hosts the answer inputs, so it cannot be split at the\n * `{{blank}}` placeholders without voiding the sanitiser. The plain `passage`\n * is always used, and passing `passageHtml` warns in development.\n */\nexport type HtmlSanitizer = (html: string) => string;\n\n/**\n * The prop contract shared by every activity component (Req 3.1). Defined\n * here (React-specific) rather than in lk-core, which is React-free.\n *\n * Controlled / uncontrolled follows the React convention: pass `value` +\n * `onChange` to own the learner's answer (restore an in-progress attempt,\n * autosave a delta, drive a review); pass `defaultValue` to seed an\n * uncontrolled component; pass neither to keep the pre-2.1.0 behaviour, where\n * the component owns the answer outright.\n */\nexport interface ActivityProps<TData extends ActivityData = ActivityData> {\n /** Activity content. Accepts a `redact()` projection in `exam` mode. */\n data: RenderableActivity<TData>;\n /**\n * Called when the component scored the attempt itself. Only ever fires in\n * `practice` mode — in `exam` mode the client does not grade, so there is\n * no `ActivityResult` to give you; use `onSubmit`.\n */\n onComplete?: (result: ActivityResult) => void;\n /**\n * Called on submit with the raw learner response and no grade. Fires in\n * every mode, before `onComplete`, so an exam runner can persist the\n * response and let the server score it.\n */\n onSubmit?: (response: LearnerResponse) => void;\n /** Controlled value: the learner's current response. */\n value?: LearnerResponse;\n /** Initial response for an uncontrolled component (ignored when `value` is set). */\n defaultValue?: LearnerResponse;\n /**\n * Mount the component as already submitted — read at mount only, like any\n * `default*` prop.\n *\n * Restoring an attempt without it reopens a question the learner had already\n * submitted as answerable, so on a summative paper they can change and\n * re-submit it. `AttemptState.submittedSlotIds` is what this consumes.\n */\n defaultSubmitted?: boolean;\n /** Fires on every change to the learner's response. Required for a controlled component. */\n onChange?: (response: LearnerResponse) => void;\n /** Presentation mode. Defaults to `practice`. */\n renderMode?: RenderMode;\n /**\n * Server-computed outcome, used by `review` mode to mark correctness\n * without the client ever scoring. Ignored in other modes.\n */\n outcome?: ItemOutcome;\n /** Renders author-supplied rich text when provided. See {@link HtmlSanitizer}. */\n sanitizeHtml?: HtmlSanitizer;\n /**\n * Binds this activity's own `data.media` to a play budget the consumer\n * persists. Usually supplied by `<ActivitySequence mediaBudget={…}>`; pass it\n * yourself when rendering an activity standalone.\n */\n mediaBudget?: MediaBudgetBinding;\n /** Translations for the audio transport chrome. See {@link MediaTransportStrings}. */\n mediaStrings?: Partial<MediaTransportStrings>;\n onInteraction?: (event: InteractionEvent) => void;\n /** Per-instance token overrides, applied as inline CSS vars on the root. */\n theme?: Partial<ThemeTokens>;\n locale?: string;\n disabled?: boolean;\n}\n\n/**\n * Bridges a server-produced `redact()` projection into the `data` prop.\n *\n * `RedactedActivityData` is deliberately index-signature typed in lk-core — it\n * proves a payload is learner-safe, not what shape it has — so TypeScript\n * cannot know it still carries the public fields a renderer needs. This is the\n * SDK's single, documented crossing of that gap, so an exam runner does not\n * have to write `as unknown as` at every call site:\n *\n * ```tsx\n * <MultipleChoice\n * data={asRenderable<MultipleChoiceData>(redactedFromServer)}\n * renderMode=\"exam\"\n * onSubmit={persist}\n * />\n * ```\n *\n * Safe because `exam` mode reads only public fields; the answer-key fields the\n * type claims are exactly the ones the component is forbidden to touch there.\n *\n * Per-type redacted interfaces (`RedactedMultipleChoiceData`, …) ship from\n * lk-core since 0.6.0, but they are not yet *assignable* to `data`:\n * {@link Renderable} widens `scoringStrategy` and leaves nested answer-key\n * fields (`options[].isCorrect`, `blanks[].acceptedAnswers`) required, so a\n * real redacted payload still needs this bridge. Closing that gap is tracked\n * in the roadmap.\n */\nexport function asRenderable<TData extends ActivityData>(\n redacted: RedactedActivityData,\n): Renderable<TData> {\n return redacted as unknown as Renderable<TData>;\n}\n\n/**\n * The same bridge as {@link asRenderable}, for a whole sequence: activities\n * and item groups as a server hands them over, ready for `<ActivitySequence>`.\n *\n * Needed for the same reason and no other. `redactItemGroup` returns\n * `ItemGroup<RedactedActivityData>`, and `RedactedActivityData` is an\n * index-signature type whose fields are all `unknown` — so its `question` is\n * not a `string` and it satisfies no per-type renderable, however the prop is\n * widened. Widening alone cannot fix this; a crossing point is required, and\n * having exactly one keeps `as unknown as` out of consumer code.\n *\n * ```tsx\n * const entries = await fetchExam(); // redacted, server-side\n * <ActivitySequence\n * activities={asRenderableSequence(entries)}\n * renderMode=\"exam\" // REQUIRED: see below\n * shuffleSeed={attemptId}\n * onSubmit={persist}\n * />\n * ```\n *\n * Pass `renderMode=\"exam\"` (or `\"review\"`). Redacted data has no answer key,\n * and the default `practice` mode grades locally — so `<MultipleChoice>` and\n * `<FillInTheBlanks>` throw at render rather than fail at submit time.\n *\n * `<WrittenResponse>` is the exception: it never grades on the client and has\n * no such guard, so a redacted essay renders and stays answerable in\n * `practice`. A mis-wired essay item is therefore SILENT — set `renderMode`\n * explicitly rather than relying on the throw.\n */\nexport function asRenderableSequence(\n entries: readonly (RedactedActivityData | RedactedItemGroupData)[],\n): readonly SequenceEntry<RenderableActivity>[] {\n return entries as unknown as readonly SequenceEntry<RenderableActivity>[];\n}\n\n/** Structural shape of a `redactItemGroup()` projection, as it arrives from a server. */\ntype RedactedItemGroupData = ItemGroup<RedactedActivityData> & { redacted: true };\n\n/**\n * Every English string the SDK's audio transport renders.\n *\n * Supply them to translate it. These are the highest-stakes strings on a\n * listening paper — \"No plays remaining\" decides whether a learner believes\n * they may try again — so shipping them as untranslatable English inside a\n * Spanish panel was not acceptable. Supplying any of them also sets `lang` on\n * the transport chrome, so a screen reader does not read the SDK's own words\n * with the passage's phonetics.\n */\nexport interface MediaTransportStrings {\n play: string;\n pause: string;\n preparing: string;\n mute: string;\n unmute: string;\n volume: string;\n speed: string;\n seek: string;\n /** e.g. `(1, 2) => '1 of 2 plays remaining'`. */\n playsRemaining: (remaining: number, max: number) => string;\n noPlaysRemaining: string;\n /** Shown before the LAST play is spent, so a stray press cannot cost it. */\n lastPlayConfirm: string;\n lastPlayStart: string;\n lastPlayCancel: string;\n seekBlocked: string;\n rateBlocked: string;\n playFailed: string;\n}\n\n/**\n * Binds ONE media block to a play budget the consumer persists.\n *\n * The SDK refuses a play; it does not remember one. Everything durable here is\n * the consuming application's — see {@link SequenceMediaBudget.onPlayConsumed}.\n */\nexport interface MediaBudgetBinding {\n /** From `slotMediaKey(slotId)` / `stimulusMediaKey(slotId)` in lk-core. */\n key: string;\n /** Plays already spent, and where playback stood. Read at mount only. */\n entry?: MediaPlayLedgerEntry;\n /** Defaults to `renderMode !== 'review'`. An explicit boolean wins either way. */\n enforced?: boolean;\n /** Slot context stamped onto the claim and the interaction event. */\n slotId: string;\n index: number;\n activityId?: string;\n onPlayConsumed?: (claim: MediaPlayClaim) => undefined | Promise<MediaPlayGrant | undefined>;\n onPlayRefunded?: (claim: MediaPlayClaim) => void;\n onPosition?: (key: string, seconds: number) => void;\n /** Translations for the transport chrome. */\n strings?: Partial<MediaTransportStrings>;\n}\n\n/**\n * The pager-level half of a play budget. One prop, because it is one concept.\n */\nexport interface SequenceMediaBudget {\n /**\n * `MediaPlayLedger.entries` goes straight in. An absent key means nothing\n * spent. Read at mount, like `responses`.\n */\n plays?: Readonly<Record<string, MediaPlayLedgerEntry>>;\n /**\n * Re-seed token. Change this string and the budgets re-seed from `plays`\n * WITHOUT remounting the pager — the invigilator path (\"the audio never\n * started, give her the play back\") that would otherwise cost the learner\n * their focus, their scroll position and an unsaved answer.\n */\n resumeKey?: string;\n /** Explicit override of the default (`renderMode !== 'review'`). */\n enforced?: boolean;\n /**\n * Called the instant a play is claimed, BEFORE any audio is audible.\n *\n * Two tiers, chosen by what you return:\n *\n * - **Return nothing (optimistic).** Playback starts immediately and the\n * count is only as durable as your write. **Do not debounce this, and do\n * not batch it with the answer autosave** — an eight-second debounce is\n * exactly long enough to start a third play and hard-reload. A `pagehide`\n * beacon is a backstop, not the mechanism. A crash between this call and\n * your write landing RETURNS the play to the learner; that is the honest\n * description of what you are buying.\n * - **Return a promise (confirmed).** Playback is held — the button reads\n * \"Preparing…\" and is `aria-busy` — until it settles. Resolve with\n * `{ playsUsed }` from an ATOMIC server write (`UPDATE … SET plays = plays\n * + 1 … RETURNING plays`, or a compare-and-set on\n * `claim.previousPlaysUsed`). A resolved count above `maxPlays` refuses the\n * play, which is how a second tab is caught: two mounts both seeded at 0\n * both claim 1, and only an atomic increment can tell them apart. A\n * rejection charges nothing and lets the learner retry. This is the only\n * tier in which \"consumed before audible\" is true of storage rather than\n * only of memory; use it for summative papers.\n *\n * Never settle the promise and the learner cannot play at all: settle it.\n */\n onPlayConsumed?: (claim: MediaPlayClaim) => undefined | Promise<MediaPlayGrant | undefined>;\n /**\n * Called when a charged play produced no audio — the element errored before\n * playback advanced past 0.25 s, an expired signed URL being the realistic\n * cause. Supply it to give the play back, decrementing with a compare-and-set\n * on `claim.playsUsed`. Omit it and the play stays spent: the SDK will not\n * decrement a ledger it has no channel to correct.\n */\n onPlayRefunded?: (claim: MediaPlayClaim) => void;\n /**\n * Position reports, so a refresh resumes the play the learner already paid\n * for instead of charging them again. Fires on pause, on end (with 0), and at\n * most once per whole second of playback.\n *\n * **This one you MAY throttle** — the granularity you persist is the\n * granularity of the replay a crash grants. Three seconds is sane; three\n * minutes is not.\n */\n onPosition?: (key: string, seconds: number) => void;\n /** Translations for the transport chrome. Defaults are English. */\n strings?: Partial<MediaTransportStrings>;\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -2,12 +2,12 @@ export { ActivityRenderer, ActivitySequence, ActivitySequenceProps, SequenceItem
2
2
  export { FillInTheBlanks, FillInTheBlanksProps } from './components/FillInTheBlanks.cjs';
3
3
  export { MultipleChoice, MultipleChoiceProps } from './components/MultipleChoice.cjs';
4
4
  export { StimulusPanel, StimulusPanelProps } from './components/StimulusPanel.cjs';
5
- export { A as ActivityProps, H as HtmlSanitizer, R as RenderMode, a as Renderable, b as RenderableActivity, c as asRenderable, d as asRenderableSequence } from './types-DlHmPLbD.cjs';
5
+ export { A as ActivityProps, H as HtmlSanitizer, M as MediaBudgetBinding, a as MediaTransportStrings, R as RenderMode, b as Renderable, c as RenderableActivity, S as SequenceMediaBudget, d as asRenderable, e as asRenderableSequence } from './types-eXX4hzSj.cjs';
6
6
  export { WrittenResponse } from './components/WrittenResponse.cjs';
7
7
  export { ActivityState, UseActivityStateResult, useActivityState } from './hooks/useActivityState.cjs';
8
8
  export { UseXAPIResult, useXAPI } from './hooks/useXAPI.cjs';
9
- export { ThemeProvider, ThemeProviderProps, darkTheme, defaultTheme, useTheme } from './theme/ThemeProvider.cjs';
10
- export { W as WrittenResponseProps, a as WrittenResponseSubmission } from './WrittenResponse-BfpzfLlR.cjs';
9
+ export { TailwindThemeExtension, ThemeProvider, ThemeProviderProps, createTailwindTheme, darkTheme, defaultTheme, useTheme } from './theme/ThemeProvider.cjs';
10
+ export { W as WrittenResponseProps, a as WrittenResponseSubmission } from './WrittenResponse-zWT-Go1g.cjs';
11
11
  import '@intellectif/lk-core';
12
12
  import 'react';
13
13
  import 'react/jsx-runtime';
package/dist/index.d.ts CHANGED
@@ -2,12 +2,12 @@ export { ActivityRenderer, ActivitySequence, ActivitySequenceProps, SequenceItem
2
2
  export { FillInTheBlanks, FillInTheBlanksProps } from './components/FillInTheBlanks.js';
3
3
  export { MultipleChoice, MultipleChoiceProps } from './components/MultipleChoice.js';
4
4
  export { StimulusPanel, StimulusPanelProps } from './components/StimulusPanel.js';
5
- export { A as ActivityProps, H as HtmlSanitizer, R as RenderMode, a as Renderable, b as RenderableActivity, c as asRenderable, d as asRenderableSequence } from './types-DlHmPLbD.js';
5
+ export { A as ActivityProps, H as HtmlSanitizer, M as MediaBudgetBinding, a as MediaTransportStrings, R as RenderMode, b as Renderable, c as RenderableActivity, S as SequenceMediaBudget, d as asRenderable, e as asRenderableSequence } from './types-eXX4hzSj.js';
6
6
  export { WrittenResponse } from './components/WrittenResponse.js';
7
7
  export { ActivityState, UseActivityStateResult, useActivityState } from './hooks/useActivityState.js';
8
8
  export { UseXAPIResult, useXAPI } from './hooks/useXAPI.js';
9
- export { ThemeProvider, ThemeProviderProps, darkTheme, defaultTheme, useTheme } from './theme/ThemeProvider.js';
10
- export { W as WrittenResponseProps, a as WrittenResponseSubmission } from './WrittenResponse-C3GIWErG.js';
9
+ export { TailwindThemeExtension, ThemeProvider, ThemeProviderProps, createTailwindTheme, darkTheme, defaultTheme, useTheme } from './theme/ThemeProvider.js';
10
+ export { W as WrittenResponseProps, a as WrittenResponseSubmission } from './WrittenResponse-BJL4dGsR.js';
11
11
  import '@intellectif/lk-core';
12
12
  import 'react';
13
13
  import 'react/jsx-runtime';
package/dist/index.js CHANGED
@@ -1,13 +1,14 @@
1
- export { ThemeProvider, darkTheme, defaultTheme, useTheme } from './chunk-B3FUUKZ2.js';
2
- export { ActivitySequence } from './chunk-OQGBAQL2.js';
3
- export { MultipleChoice } from './chunk-5TUTJ4R3.js';
4
- export { FillInTheBlanks } from './chunk-57E3E2H4.js';
5
- export { WrittenResponse } from './chunk-BQHDQ33H.js';
1
+ 'use client';
2
+ export { ThemeProvider, createTailwindTheme, darkTheme, defaultTheme, useTheme } from './chunk-DQNVAXG6.js';
3
+ export { ActivitySequence } from './chunk-ZPVMB3LH.js';
4
+ export { MultipleChoice } from './chunk-MB532SXM.js';
5
+ export { FillInTheBlanks } from './chunk-J23XVR2B.js';
6
+ export { WrittenResponse } from './chunk-CMZGT26S.js';
6
7
  import './chunk-6F4X2NKL.js';
7
- export { StimulusPanel } from './chunk-UQ3BBEIT.js';
8
- import './chunk-GB5URWM4.js';
8
+ export { StimulusPanel } from './chunk-BG456EM3.js';
9
+ import './chunk-6ZKVJAO6.js';
9
10
  export { useActivityState } from './chunk-6N43WDVG.js';
10
- export { useXAPI } from './chunk-E4MNA2IQ.js';
11
+ export { useXAPI } from './chunk-2TW6WLBC.js';
11
12
 
12
13
  // src/components/types.ts
13
14
  function asRenderable(redacted) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/types.ts"],"names":[],"mappings":";;;;;;;;;;;;AAoJO,SAAS,aACd,QAAA,EACmB;AACnB,EAAA,OAAO,QAAA;AACT;AA4BO,SAAS,qBACd,OAAA,EAC8C;AAC9C,EAAA,OAAO,OAAA;AACT","file":"index.js","sourcesContent":["import type {\n ActivityData,\n ActivityResult,\n InteractionEvent,\n ItemGroup,\n ItemOutcome,\n LearnerResponse,\n RedactedActivityData,\n SequenceEntry,\n ThemeTokens,\n} from '@intellectif/lk-core';\n\n/**\n * How an activity is being presented. This is the single switch that decides\n * whether the component may grade, reveal, or submit — the three things a\n * summative exam must take away from the client.\n *\n * - `practice` (default, v1 behaviour): the component owns the attempt. It\n * scores locally on submit, reveals correctness and feedback, and calls\n * `onComplete` with a full {@link ActivityResult}.\n * - `exam`: the component NEVER scores and NEVER reveals correctness. Submit\n * emits the raw learner response through `onSubmit`; the server grades it.\n * Safe to render redacted data, because nothing here needs the answer key.\n * - `review`: read-only. Renders the learner's submitted answer, and marks\n * correctness only from an `outcome` the caller supplies (which the server\n * computed). Nothing is submittable.\n */\nexport type RenderMode = 'practice' | 'exam' | 'review';\n\n/**\n * Makes the answer-key-bearing parts of an activity optional, so a component\n * can render either full activity data OR a `redact()` projection with the\n * same props. Fields the SDK classifies `answer-key` become optional here;\n * a component in `exam` mode must not read them at all.\n */\nexport type Renderable<TData> = Omit<TData, 'scoringStrategy'> & {\n scoringStrategy?: unknown;\n /** Present on a `redact()` projection. */\n redacted?: true;\n};\n\n/**\n * {@link Renderable} DISTRIBUTED over a union of activity types.\n *\n * This distinction is load-bearing, not cosmetic. `Renderable<T>` is built on\n * `Omit`, and `Omit` does not distribute: `Omit<A | B, K>` collapses to the\n * keys A and B have IN COMMON, so `Renderable<ActivityData>` is a single\n * object type carrying only the fields every activity shares. Narrowing it\n * dies with it — after `if (data.type === 'multiple-choice')` the compiler\n * still refuses `data.options`, because the union it would narrow to no\n * longer exists.\n *\n * The conditional below re-distributes, so `RenderableActivity` is a real\n * union of per-type renderables and `.type` narrows again. Anything that\n * accepts \"some renderable activity, I don't know which\" — a custom renderer,\n * a sequence entry — must use THIS, not `Renderable<ActivityData>`.\n */\nexport type RenderableActivity<TData extends ActivityData = ActivityData> = TData extends unknown\n ? Renderable<TData>\n : never;\n\n/**\n * Sanitiser for author-supplied rich text (`questionHtml`, `passageHtml`,\n * `promptHtml`). The SDK deliberately ships NO sanitiser — that would add a\n * dependency and, worse, a false promise. Rich text is rendered only when you\n * supply this function; without it the component falls back to the plain-text\n * field, which is always escaped. Fail-safe by construction: the SDK never\n * injects HTML it was not explicitly given a sanitiser for.\n */\nexport type HtmlSanitizer = (html: string) => string;\n\n/**\n * The prop contract shared by every activity component (Req 3.1). Defined\n * here (React-specific) rather than in lk-core, which is React-free.\n *\n * Controlled / uncontrolled follows the React convention: pass `value` +\n * `onChange` to own the learner's answer (restore an in-progress attempt,\n * autosave a delta, drive a review); pass `defaultValue` to seed an\n * uncontrolled component; pass neither for the v1 behaviour.\n */\nexport interface ActivityProps<TData extends ActivityData = ActivityData> {\n /** Activity content. Accepts a `redact()` projection in `exam` mode. */\n data: RenderableActivity<TData>;\n /**\n * Called when the component scored the attempt itself. Only ever fires in\n * `practice` mode — in `exam` mode the client does not grade, so there is\n * no `ActivityResult` to give you; use `onSubmit`.\n */\n onComplete?: (result: ActivityResult) => void;\n /**\n * Called on submit with the raw learner response and no grade. Fires in\n * every mode, before `onComplete`, so an exam runner can persist the\n * response and let the server score it.\n */\n onSubmit?: (response: LearnerResponse) => void;\n /** Controlled value: the learner's current response. */\n value?: LearnerResponse;\n /** Initial response for an uncontrolled component (ignored when `value` is set). */\n defaultValue?: LearnerResponse;\n /**\n * Mount the component as already submitted — read at mount only, like any\n * `default*` prop.\n *\n * Restoring an attempt without it reopens a question the learner had already\n * submitted as answerable, so on a summative paper they can change and\n * re-submit it. `AttemptState.submittedSlotIds` is what this consumes.\n */\n defaultSubmitted?: boolean;\n /** Fires on every change to the learner's response. Required for a controlled component. */\n onChange?: (response: LearnerResponse) => void;\n /** Presentation mode. Defaults to `practice`. */\n renderMode?: RenderMode;\n /**\n * Server-computed outcome, used by `review` mode to mark correctness\n * without the client ever scoring. Ignored in other modes.\n */\n outcome?: ItemOutcome;\n /** Renders author-supplied rich text when provided. See {@link HtmlSanitizer}. */\n sanitizeHtml?: HtmlSanitizer;\n onInteraction?: (event: InteractionEvent) => void;\n /** Per-instance token overrides, applied as inline CSS vars on the root. */\n theme?: Partial<ThemeTokens>;\n locale?: string;\n disabled?: boolean;\n}\n\n/**\n * Bridges a server-produced `redact()` projection into the `data` prop.\n *\n * `RedactedActivityData` is deliberately index-signature typed in lk-core — it\n * proves a payload is learner-safe, not what shape it has — so TypeScript\n * cannot know it still carries the public fields a renderer needs. This is the\n * SDK's single, documented crossing of that gap, so an exam runner does not\n * have to write `as unknown as` at every call site:\n *\n * ```tsx\n * <MultipleChoice\n * data={asRenderable<MultipleChoiceData>(redactedFromServer)}\n * renderMode=\"exam\"\n * onSubmit={persist}\n * />\n * ```\n *\n * Safe because `exam` mode reads only public fields; the answer-key fields the\n * type claims are exactly the ones the component is forbidden to touch there.\n * A future release will derive per-type redacted interfaces so this becomes\n * unnecessary.\n */\nexport function asRenderable<TData extends ActivityData>(\n redacted: RedactedActivityData,\n): Renderable<TData> {\n return redacted as unknown as Renderable<TData>;\n}\n\n/**\n * The same bridge as {@link asRenderable}, for a whole sequence: activities\n * and item groups as a server hands them over, ready for `<ActivitySequence>`.\n *\n * Needed for the same reason and no other. `redactItemGroup` returns\n * `ItemGroup<RedactedActivityData>`, and `RedactedActivityData` is an\n * index-signature type whose fields are all `unknown` — so its `question` is\n * not a `string` and it satisfies no per-type renderable, however the prop is\n * widened. Widening alone cannot fix this; a crossing point is required, and\n * having exactly one keeps `as unknown as` out of consumer code.\n *\n * ```tsx\n * const entries = await fetchExam(); // redacted, server-side\n * <ActivitySequence\n * activities={asRenderableSequence(entries)}\n * renderMode=\"exam\" // REQUIRED: see below\n * shuffleSeed={attemptId}\n * onSubmit={persist}\n * />\n * ```\n *\n * Pass `renderMode=\"exam\"` (or `\"review\"`). Redacted data has no answer key,\n * and the default `practice` mode grades locally — the built-in components\n * throw at render rather than fail at submit time, so a mis-wired exam item is\n * loud, not silent.\n */\nexport function asRenderableSequence(\n entries: readonly (RedactedActivityData | RedactedItemGroupData)[],\n): readonly SequenceEntry<RenderableActivity>[] {\n return entries as unknown as readonly SequenceEntry<RenderableActivity>[];\n}\n\n/** Structural shape of a `redactItemGroup()` projection, as it arrives from a server. */\ntype RedactedItemGroupData = ItemGroup<RedactedActivityData> & { redacted: true };\n"]}
1
+ {"version":3,"sources":["../src/components/types.ts"],"names":[],"mappings":";;;;;;;;;;;;AA2KO,SAAS,aACd,QAAA,EACmB;AACnB,EAAA,OAAO,QAAA;AACT;AAgCO,SAAS,qBACd,OAAA,EAC8C;AAC9C,EAAA,OAAO,OAAA;AACT","file":"index.js","sourcesContent":["import type {\n ActivityData,\n ActivityResult,\n InteractionEvent,\n ItemGroup,\n ItemOutcome,\n LearnerResponse,\n MediaPlayClaim,\n MediaPlayGrant,\n MediaPlayLedgerEntry,\n RedactedActivityData,\n SequenceEntry,\n ThemeTokens,\n} from '@intellectif/lk-core';\n\n/**\n * How an activity is being presented. This is the single switch that decides\n * whether the component may grade, reveal, or submit — the three things a\n * summative exam must take away from the client.\n *\n * - `practice` (default, and the only behaviour before `renderMode` existed):\n * the component owns the attempt. It\n * scores locally on submit, reveals correctness and feedback, and calls\n * `onComplete` with a full {@link ActivityResult}.\n * - `exam`: the component NEVER scores and NEVER reveals correctness. Submit\n * emits the raw learner response through `onSubmit`; the server grades it.\n * Safe to render redacted data, because nothing here needs the answer key.\n * - `review`: read-only. Renders the learner's submitted answer, and marks\n * correctness only from an `outcome` the caller supplies (which the server\n * computed). Nothing is submittable.\n */\nexport type RenderMode = 'practice' | 'exam' | 'review';\n\n/**\n * Makes the answer-key-bearing parts of an activity optional, so a component\n * can render either full activity data OR a `redact()` projection with the\n * same props. Fields the SDK classifies `answer-key` become optional here;\n * a component in `exam` mode must not read them at all.\n */\nexport type Renderable<TData> = Omit<TData, 'scoringStrategy'> & {\n scoringStrategy?: unknown;\n /** Present on a `redact()` projection. */\n redacted?: true;\n};\n\n/**\n * {@link Renderable} DISTRIBUTED over a union of activity types.\n *\n * This distinction is load-bearing, not cosmetic. `Renderable<T>` is built on\n * `Omit`, and `Omit` does not distribute: `Omit<A | B, K>` collapses to the\n * keys A and B have IN COMMON, so `Renderable<ActivityData>` is a single\n * object type carrying only the fields every activity shares. Narrowing it\n * dies with it — after `if (data.type === 'multiple-choice')` the compiler\n * still refuses `data.options`, because the union it would narrow to no\n * longer exists.\n *\n * The conditional below re-distributes, so `RenderableActivity` is a real\n * union of per-type renderables and `.type` narrows again. Anything that\n * accepts \"some renderable activity, I don't know which\" — a custom renderer,\n * a sequence entry — must use THIS, not `Renderable<ActivityData>`.\n */\nexport type RenderableActivity<TData extends ActivityData = ActivityData> = TData extends unknown\n ? Renderable<TData>\n : never;\n\n/**\n * Sanitiser for author-supplied rich text (`questionHtml`, `promptHtml`, and a\n * stimulus's `bodyHtml`). The SDK deliberately ships NO sanitiser — that would\n * add a dependency and, worse, a false promise. Rich text is rendered only when\n * you supply this function; without it the component falls back to the\n * plain-text field, which is always escaped. Fail-safe by construction: the SDK\n * never injects HTML it was not explicitly given a sanitiser for.\n *\n * `FillInTheBlanks.passageHtml` is the one exception, and is **never**\n * rendered: the passage hosts the answer inputs, so it cannot be split at the\n * `{{blank}}` placeholders without voiding the sanitiser. The plain `passage`\n * is always used, and passing `passageHtml` warns in development.\n */\nexport type HtmlSanitizer = (html: string) => string;\n\n/**\n * The prop contract shared by every activity component (Req 3.1). Defined\n * here (React-specific) rather than in lk-core, which is React-free.\n *\n * Controlled / uncontrolled follows the React convention: pass `value` +\n * `onChange` to own the learner's answer (restore an in-progress attempt,\n * autosave a delta, drive a review); pass `defaultValue` to seed an\n * uncontrolled component; pass neither to keep the pre-2.1.0 behaviour, where\n * the component owns the answer outright.\n */\nexport interface ActivityProps<TData extends ActivityData = ActivityData> {\n /** Activity content. Accepts a `redact()` projection in `exam` mode. */\n data: RenderableActivity<TData>;\n /**\n * Called when the component scored the attempt itself. Only ever fires in\n * `practice` mode — in `exam` mode the client does not grade, so there is\n * no `ActivityResult` to give you; use `onSubmit`.\n */\n onComplete?: (result: ActivityResult) => void;\n /**\n * Called on submit with the raw learner response and no grade. Fires in\n * every mode, before `onComplete`, so an exam runner can persist the\n * response and let the server score it.\n */\n onSubmit?: (response: LearnerResponse) => void;\n /** Controlled value: the learner's current response. */\n value?: LearnerResponse;\n /** Initial response for an uncontrolled component (ignored when `value` is set). */\n defaultValue?: LearnerResponse;\n /**\n * Mount the component as already submitted — read at mount only, like any\n * `default*` prop.\n *\n * Restoring an attempt without it reopens a question the learner had already\n * submitted as answerable, so on a summative paper they can change and\n * re-submit it. `AttemptState.submittedSlotIds` is what this consumes.\n */\n defaultSubmitted?: boolean;\n /** Fires on every change to the learner's response. Required for a controlled component. */\n onChange?: (response: LearnerResponse) => void;\n /** Presentation mode. Defaults to `practice`. */\n renderMode?: RenderMode;\n /**\n * Server-computed outcome, used by `review` mode to mark correctness\n * without the client ever scoring. Ignored in other modes.\n */\n outcome?: ItemOutcome;\n /** Renders author-supplied rich text when provided. See {@link HtmlSanitizer}. */\n sanitizeHtml?: HtmlSanitizer;\n /**\n * Binds this activity's own `data.media` to a play budget the consumer\n * persists. Usually supplied by `<ActivitySequence mediaBudget={…}>`; pass it\n * yourself when rendering an activity standalone.\n */\n mediaBudget?: MediaBudgetBinding;\n /** Translations for the audio transport chrome. See {@link MediaTransportStrings}. */\n mediaStrings?: Partial<MediaTransportStrings>;\n onInteraction?: (event: InteractionEvent) => void;\n /** Per-instance token overrides, applied as inline CSS vars on the root. */\n theme?: Partial<ThemeTokens>;\n locale?: string;\n disabled?: boolean;\n}\n\n/**\n * Bridges a server-produced `redact()` projection into the `data` prop.\n *\n * `RedactedActivityData` is deliberately index-signature typed in lk-core — it\n * proves a payload is learner-safe, not what shape it has — so TypeScript\n * cannot know it still carries the public fields a renderer needs. This is the\n * SDK's single, documented crossing of that gap, so an exam runner does not\n * have to write `as unknown as` at every call site:\n *\n * ```tsx\n * <MultipleChoice\n * data={asRenderable<MultipleChoiceData>(redactedFromServer)}\n * renderMode=\"exam\"\n * onSubmit={persist}\n * />\n * ```\n *\n * Safe because `exam` mode reads only public fields; the answer-key fields the\n * type claims are exactly the ones the component is forbidden to touch there.\n *\n * Per-type redacted interfaces (`RedactedMultipleChoiceData`, …) ship from\n * lk-core since 0.6.0, but they are not yet *assignable* to `data`:\n * {@link Renderable} widens `scoringStrategy` and leaves nested answer-key\n * fields (`options[].isCorrect`, `blanks[].acceptedAnswers`) required, so a\n * real redacted payload still needs this bridge. Closing that gap is tracked\n * in the roadmap.\n */\nexport function asRenderable<TData extends ActivityData>(\n redacted: RedactedActivityData,\n): Renderable<TData> {\n return redacted as unknown as Renderable<TData>;\n}\n\n/**\n * The same bridge as {@link asRenderable}, for a whole sequence: activities\n * and item groups as a server hands them over, ready for `<ActivitySequence>`.\n *\n * Needed for the same reason and no other. `redactItemGroup` returns\n * `ItemGroup<RedactedActivityData>`, and `RedactedActivityData` is an\n * index-signature type whose fields are all `unknown` — so its `question` is\n * not a `string` and it satisfies no per-type renderable, however the prop is\n * widened. Widening alone cannot fix this; a crossing point is required, and\n * having exactly one keeps `as unknown as` out of consumer code.\n *\n * ```tsx\n * const entries = await fetchExam(); // redacted, server-side\n * <ActivitySequence\n * activities={asRenderableSequence(entries)}\n * renderMode=\"exam\" // REQUIRED: see below\n * shuffleSeed={attemptId}\n * onSubmit={persist}\n * />\n * ```\n *\n * Pass `renderMode=\"exam\"` (or `\"review\"`). Redacted data has no answer key,\n * and the default `practice` mode grades locally — so `<MultipleChoice>` and\n * `<FillInTheBlanks>` throw at render rather than fail at submit time.\n *\n * `<WrittenResponse>` is the exception: it never grades on the client and has\n * no such guard, so a redacted essay renders and stays answerable in\n * `practice`. A mis-wired essay item is therefore SILENT — set `renderMode`\n * explicitly rather than relying on the throw.\n */\nexport function asRenderableSequence(\n entries: readonly (RedactedActivityData | RedactedItemGroupData)[],\n): readonly SequenceEntry<RenderableActivity>[] {\n return entries as unknown as readonly SequenceEntry<RenderableActivity>[];\n}\n\n/** Structural shape of a `redactItemGroup()` projection, as it arrives from a server. */\ntype RedactedItemGroupData = ItemGroup<RedactedActivityData> & { redacted: true };\n\n/**\n * Every English string the SDK's audio transport renders.\n *\n * Supply them to translate it. These are the highest-stakes strings on a\n * listening paper — \"No plays remaining\" decides whether a learner believes\n * they may try again — so shipping them as untranslatable English inside a\n * Spanish panel was not acceptable. Supplying any of them also sets `lang` on\n * the transport chrome, so a screen reader does not read the SDK's own words\n * with the passage's phonetics.\n */\nexport interface MediaTransportStrings {\n play: string;\n pause: string;\n preparing: string;\n mute: string;\n unmute: string;\n volume: string;\n speed: string;\n seek: string;\n /** e.g. `(1, 2) => '1 of 2 plays remaining'`. */\n playsRemaining: (remaining: number, max: number) => string;\n noPlaysRemaining: string;\n /** Shown before the LAST play is spent, so a stray press cannot cost it. */\n lastPlayConfirm: string;\n lastPlayStart: string;\n lastPlayCancel: string;\n seekBlocked: string;\n rateBlocked: string;\n playFailed: string;\n}\n\n/**\n * Binds ONE media block to a play budget the consumer persists.\n *\n * The SDK refuses a play; it does not remember one. Everything durable here is\n * the consuming application's — see {@link SequenceMediaBudget.onPlayConsumed}.\n */\nexport interface MediaBudgetBinding {\n /** From `slotMediaKey(slotId)` / `stimulusMediaKey(slotId)` in lk-core. */\n key: string;\n /** Plays already spent, and where playback stood. Read at mount only. */\n entry?: MediaPlayLedgerEntry;\n /** Defaults to `renderMode !== 'review'`. An explicit boolean wins either way. */\n enforced?: boolean;\n /** Slot context stamped onto the claim and the interaction event. */\n slotId: string;\n index: number;\n activityId?: string;\n onPlayConsumed?: (claim: MediaPlayClaim) => undefined | Promise<MediaPlayGrant | undefined>;\n onPlayRefunded?: (claim: MediaPlayClaim) => void;\n onPosition?: (key: string, seconds: number) => void;\n /** Translations for the transport chrome. */\n strings?: Partial<MediaTransportStrings>;\n}\n\n/**\n * The pager-level half of a play budget. One prop, because it is one concept.\n */\nexport interface SequenceMediaBudget {\n /**\n * `MediaPlayLedger.entries` goes straight in. An absent key means nothing\n * spent. Read at mount, like `responses`.\n */\n plays?: Readonly<Record<string, MediaPlayLedgerEntry>>;\n /**\n * Re-seed token. Change this string and the budgets re-seed from `plays`\n * WITHOUT remounting the pager — the invigilator path (\"the audio never\n * started, give her the play back\") that would otherwise cost the learner\n * their focus, their scroll position and an unsaved answer.\n */\n resumeKey?: string;\n /** Explicit override of the default (`renderMode !== 'review'`). */\n enforced?: boolean;\n /**\n * Called the instant a play is claimed, BEFORE any audio is audible.\n *\n * Two tiers, chosen by what you return:\n *\n * - **Return nothing (optimistic).** Playback starts immediately and the\n * count is only as durable as your write. **Do not debounce this, and do\n * not batch it with the answer autosave** — an eight-second debounce is\n * exactly long enough to start a third play and hard-reload. A `pagehide`\n * beacon is a backstop, not the mechanism. A crash between this call and\n * your write landing RETURNS the play to the learner; that is the honest\n * description of what you are buying.\n * - **Return a promise (confirmed).** Playback is held — the button reads\n * \"Preparing…\" and is `aria-busy` — until it settles. Resolve with\n * `{ playsUsed }` from an ATOMIC server write (`UPDATE … SET plays = plays\n * + 1 … RETURNING plays`, or a compare-and-set on\n * `claim.previousPlaysUsed`). A resolved count above `maxPlays` refuses the\n * play, which is how a second tab is caught: two mounts both seeded at 0\n * both claim 1, and only an atomic increment can tell them apart. A\n * rejection charges nothing and lets the learner retry. This is the only\n * tier in which \"consumed before audible\" is true of storage rather than\n * only of memory; use it for summative papers.\n *\n * Never settle the promise and the learner cannot play at all: settle it.\n */\n onPlayConsumed?: (claim: MediaPlayClaim) => undefined | Promise<MediaPlayGrant | undefined>;\n /**\n * Called when a charged play produced no audio — the element errored before\n * playback advanced past 0.25 s, an expired signed URL being the realistic\n * cause. Supply it to give the play back, decrementing with a compare-and-set\n * on `claim.playsUsed`. Omit it and the play stays spent: the SDK will not\n * decrement a ledger it has no channel to correct.\n */\n onPlayRefunded?: (claim: MediaPlayClaim) => void;\n /**\n * Position reports, so a refresh resumes the play the learner already paid\n * for instead of charging them again. Fires on pause, on end (with 0), and at\n * most once per whole second of playback.\n *\n * **This one you MAY throttle** — the granularity you persist is the\n * granularity of the replay a crash grants. Three seconds is sane; three\n * minutes is not.\n */\n onPosition?: (key: string, seconds: number) => void;\n /** Translations for the transport chrome. Defaults are English. */\n strings?: Partial<MediaTransportStrings>;\n}\n"]}
@@ -1,24 +1,29 @@
1
+ 'use client';
1
2
  'use strict';
2
3
 
3
- var chunkCPF2JJG6_cjs = require('../chunk-CPF2JJG6.cjs');
4
+ var chunkAMGK7DDM_cjs = require('../chunk-AMGK7DDM.cjs');
4
5
 
5
6
 
6
7
 
7
8
  Object.defineProperty(exports, "ThemeProvider", {
8
9
  enumerable: true,
9
- get: function () { return chunkCPF2JJG6_cjs.ThemeProvider; }
10
+ get: function () { return chunkAMGK7DDM_cjs.ThemeProvider; }
11
+ });
12
+ Object.defineProperty(exports, "createTailwindTheme", {
13
+ enumerable: true,
14
+ get: function () { return chunkAMGK7DDM_cjs.createTailwindTheme; }
10
15
  });
11
16
  Object.defineProperty(exports, "darkTheme", {
12
17
  enumerable: true,
13
- get: function () { return chunkCPF2JJG6_cjs.darkTheme; }
18
+ get: function () { return chunkAMGK7DDM_cjs.darkTheme; }
14
19
  });
15
20
  Object.defineProperty(exports, "defaultTheme", {
16
21
  enumerable: true,
17
- get: function () { return chunkCPF2JJG6_cjs.defaultTheme; }
22
+ get: function () { return chunkAMGK7DDM_cjs.defaultTheme; }
18
23
  });
19
24
  Object.defineProperty(exports, "useTheme", {
20
25
  enumerable: true,
21
- get: function () { return chunkCPF2JJG6_cjs.useTheme; }
26
+ get: function () { return chunkAMGK7DDM_cjs.useTheme; }
22
27
  });
23
28
  //# sourceMappingURL=ThemeProvider.cjs.map
24
29
  //# sourceMappingURL=ThemeProvider.cjs.map
@@ -9,6 +9,26 @@ import { ReactNode } from 'react';
9
9
  */
10
10
  declare const darkTheme: Partial<ThemeTokens>;
11
11
 
12
+ /**
13
+ * Shape consumed by a Tailwind config's `theme.extend`. Every entry is a
14
+ * `var(--lk-token, <fallback>)` reference: the var keeps utilities live
15
+ * (ThemeProvider / dark-mode override at runtime); the fallback makes them
16
+ * work with zero setup (no provider, no `defaults.css` import).
17
+ */
18
+ interface TailwindThemeExtension {
19
+ colors: Record<string, string>;
20
+ spacing: Record<string, string>;
21
+ borderRadius: Record<string, string>;
22
+ fontFamily: Record<string, string>;
23
+ fontSize: Record<string, string>;
24
+ }
25
+ /**
26
+ * Converts SDK theme tokens into a Tailwind `theme.extend` object so Tailwind
27
+ * projects consume the same `--lk-*` tokens as the components — one shared
28
+ * source of truth rather than a parallel, conflicting palette.
29
+ */
30
+ declare function createTailwindTheme(theme: Partial<ThemeTokens>): TailwindThemeExtension;
31
+
12
32
  /**
13
33
  * Canonical default theme token values. `defaults.css` mirrors these exactly.
14
34
  * Palette is a neutral monochrome (ElevenLabs-like) so the SDK is brand-neutral
@@ -36,4 +56,4 @@ declare function ThemeProvider({ theme, children }: ThemeProviderProps): react_j
36
56
  /** Returns the currently active theme tokens (defaults when no provider). */
37
57
  declare function useTheme(): ThemeTokens;
38
58
 
39
- export { ThemeProvider, type ThemeProviderProps, darkTheme, defaultTheme, useTheme };
59
+ export { type TailwindThemeExtension, ThemeProvider, type ThemeProviderProps, createTailwindTheme, darkTheme, defaultTheme, useTheme };
@@ -9,6 +9,26 @@ import { ReactNode } from 'react';
9
9
  */
10
10
  declare const darkTheme: Partial<ThemeTokens>;
11
11
 
12
+ /**
13
+ * Shape consumed by a Tailwind config's `theme.extend`. Every entry is a
14
+ * `var(--lk-token, <fallback>)` reference: the var keeps utilities live
15
+ * (ThemeProvider / dark-mode override at runtime); the fallback makes them
16
+ * work with zero setup (no provider, no `defaults.css` import).
17
+ */
18
+ interface TailwindThemeExtension {
19
+ colors: Record<string, string>;
20
+ spacing: Record<string, string>;
21
+ borderRadius: Record<string, string>;
22
+ fontFamily: Record<string, string>;
23
+ fontSize: Record<string, string>;
24
+ }
25
+ /**
26
+ * Converts SDK theme tokens into a Tailwind `theme.extend` object so Tailwind
27
+ * projects consume the same `--lk-*` tokens as the components — one shared
28
+ * source of truth rather than a parallel, conflicting palette.
29
+ */
30
+ declare function createTailwindTheme(theme: Partial<ThemeTokens>): TailwindThemeExtension;
31
+
12
32
  /**
13
33
  * Canonical default theme token values. `defaults.css` mirrors these exactly.
14
34
  * Palette is a neutral monochrome (ElevenLabs-like) so the SDK is brand-neutral
@@ -36,4 +56,4 @@ declare function ThemeProvider({ theme, children }: ThemeProviderProps): react_j
36
56
  /** Returns the currently active theme tokens (defaults when no provider). */
37
57
  declare function useTheme(): ThemeTokens;
38
58
 
39
- export { ThemeProvider, type ThemeProviderProps, darkTheme, defaultTheme, useTheme };
59
+ export { type TailwindThemeExtension, ThemeProvider, type ThemeProviderProps, createTailwindTheme, darkTheme, defaultTheme, useTheme };
@@ -1,3 +1,4 @@
1
- export { ThemeProvider, darkTheme, defaultTheme, useTheme } from '../chunk-B3FUUKZ2.js';
1
+ 'use client';
2
+ export { ThemeProvider, createTailwindTheme, darkTheme, defaultTheme, useTheme } from '../chunk-DQNVAXG6.js';
2
3
  //# sourceMappingURL=ThemeProvider.js.map
3
4
  //# sourceMappingURL=ThemeProvider.js.map