@teacharium/widget 0.2.2 → 0.3.1
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/main.d.ts +1 -0
- package/dist/teacharium-custom-fields.d.ts +39 -23
- package/dist/teacharium-widget-api.d.ts +89 -28
- package/dist/teacharium-widget.d.ts +9 -0
- package/dist/teacharium-widget.es.js +191 -159
- package/dist/utils/actions.d.ts +39 -0
- package/package.json +5 -4
package/dist/main.d.ts
CHANGED
|
@@ -1,50 +1,66 @@
|
|
|
1
1
|
import { BaseField } from '@measured/puck';
|
|
2
|
-
export
|
|
2
|
+
export type TeachariumCustomFieldType = "imageMedia" | "videoMedia" | "audioMedia" | "voiceover" | "action" | "variable" | "numericExpression" | "stringExpression" | "placeholder" | "step" | "condition" | "textStyle" | "frame";
|
|
3
|
+
export type TeachariumCustomField = BaseField & {
|
|
4
|
+
type: TeachariumCustomFieldType;
|
|
5
|
+
label?: string;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
};
|
|
10
|
+
export type ImageMediaField = TeachariumCustomField & {
|
|
3
11
|
type: "imageMedia";
|
|
4
12
|
label: string;
|
|
5
|
-
}
|
|
6
|
-
export
|
|
13
|
+
};
|
|
14
|
+
export type VideoMediaField = TeachariumCustomField & {
|
|
7
15
|
type: "videoMedia";
|
|
8
16
|
label: string;
|
|
9
|
-
}
|
|
10
|
-
export
|
|
17
|
+
};
|
|
18
|
+
export type AudioMediaField = TeachariumCustomField & {
|
|
11
19
|
type: "audioMedia";
|
|
12
20
|
label: string;
|
|
13
|
-
}
|
|
14
|
-
export
|
|
21
|
+
};
|
|
22
|
+
export type VoiceoverField = TeachariumCustomField & {
|
|
15
23
|
type: "voiceover";
|
|
16
24
|
label?: string;
|
|
17
|
-
}
|
|
18
|
-
export
|
|
25
|
+
};
|
|
26
|
+
export type ActionField = TeachariumCustomField & {
|
|
19
27
|
type: "action";
|
|
20
28
|
label: string;
|
|
21
|
-
}
|
|
22
|
-
export
|
|
29
|
+
};
|
|
30
|
+
export type VariableField = TeachariumCustomField & {
|
|
23
31
|
type: "variable";
|
|
24
32
|
label: string;
|
|
25
|
-
}
|
|
26
|
-
export
|
|
33
|
+
};
|
|
34
|
+
export type NumericExpressionField = TeachariumCustomField & {
|
|
27
35
|
type: "numericExpression";
|
|
28
36
|
label: string;
|
|
29
|
-
}
|
|
30
|
-
export
|
|
37
|
+
};
|
|
38
|
+
export type StringExpressionField = TeachariumCustomField & {
|
|
31
39
|
type: "stringExpression";
|
|
32
40
|
label: string;
|
|
33
|
-
}
|
|
34
|
-
export
|
|
41
|
+
};
|
|
42
|
+
export type ConditionField = TeachariumCustomField & {
|
|
35
43
|
type: "condition";
|
|
36
44
|
label: string;
|
|
37
|
-
}
|
|
38
|
-
export
|
|
45
|
+
};
|
|
46
|
+
export type PlaceholderField = TeachariumCustomField & {
|
|
39
47
|
type: "placeholder";
|
|
40
48
|
label?: string;
|
|
41
49
|
description?: string;
|
|
42
50
|
value?: string;
|
|
43
|
-
}
|
|
44
|
-
export
|
|
51
|
+
};
|
|
52
|
+
export type StepField = TeachariumCustomField & {
|
|
45
53
|
type: "step";
|
|
46
54
|
label: string;
|
|
47
55
|
placeholder?: string;
|
|
48
56
|
description?: string;
|
|
49
|
-
}
|
|
50
|
-
export type
|
|
57
|
+
};
|
|
58
|
+
export type TextStyleField = TeachariumCustomField & {
|
|
59
|
+
type: "textStyle";
|
|
60
|
+
label?: string;
|
|
61
|
+
};
|
|
62
|
+
export type FrameField = TeachariumCustomField & {
|
|
63
|
+
type: "frame";
|
|
64
|
+
label?: string;
|
|
65
|
+
};
|
|
66
|
+
export type TeachariumCustomFields = TeachariumCustomField;
|
|
@@ -3,6 +3,7 @@ export type VoiceType = "alloy" | "ash" | "ballad" | "coral" | "echo" | "fable"
|
|
|
3
3
|
export interface VoiceoverData {
|
|
4
4
|
enabled: boolean;
|
|
5
5
|
voice: VoiceType;
|
|
6
|
+
speed?: number;
|
|
6
7
|
showPlayButton: boolean;
|
|
7
8
|
cached?: boolean;
|
|
8
9
|
content?: string;
|
|
@@ -17,21 +18,17 @@ export interface BaseEvent {
|
|
|
17
18
|
emittedBy?: string;
|
|
18
19
|
}
|
|
19
20
|
export type VariableValue = string | number | boolean;
|
|
20
|
-
export interface
|
|
21
|
-
(
|
|
22
|
-
(expression: string): number | null;
|
|
21
|
+
export interface UseNumberExpressions {
|
|
22
|
+
(expressions: string[], defaultValues?: number[]): (number)[];
|
|
23
23
|
}
|
|
24
|
-
export interface
|
|
25
|
-
(
|
|
26
|
-
}
|
|
27
|
-
export interface UseVariableValue {
|
|
28
|
-
(name: string | null | undefined): VariableValue | undefined;
|
|
24
|
+
export interface UseStringExpressions {
|
|
25
|
+
(expressions: (string | undefined)[], defaultValues?: string[]): string[];
|
|
29
26
|
}
|
|
30
27
|
export interface UseVariableValues {
|
|
31
28
|
(names: Array<string | null | undefined>): (VariableValue | undefined)[];
|
|
32
29
|
}
|
|
33
|
-
export interface
|
|
34
|
-
(
|
|
30
|
+
export interface UseUpdateVariables {
|
|
31
|
+
(values: Record<string, VariableValue>): void;
|
|
35
32
|
}
|
|
36
33
|
export interface UseMediaUrl {
|
|
37
34
|
(src: string, expiresIn?: number): {
|
|
@@ -69,25 +66,67 @@ export interface UseConditionEvaluationResult {
|
|
|
69
66
|
export interface UseConditionEvaluation {
|
|
70
67
|
(condition: ConditionValue): UseConditionEvaluationResult;
|
|
71
68
|
}
|
|
72
|
-
export
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
export type ItemType = "instructional" | "practice" | "scored";
|
|
70
|
+
export interface CurrentAnswer {
|
|
71
|
+
humanReadable: string;
|
|
72
|
+
machineReadable: string | number;
|
|
76
73
|
}
|
|
77
|
-
export interface
|
|
78
|
-
|
|
74
|
+
export interface ItemStatus {
|
|
75
|
+
correct: boolean;
|
|
76
|
+
attempted: boolean;
|
|
77
|
+
currentAnswer?: CurrentAnswer;
|
|
78
|
+
maxScore: number;
|
|
79
|
+
currentScore: number;
|
|
79
80
|
}
|
|
80
81
|
export interface ItemData {
|
|
81
82
|
widgetId: string;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
widgetName?: string;
|
|
84
|
+
stepId: string;
|
|
85
|
+
type: ItemType;
|
|
86
|
+
status: ItemStatus;
|
|
87
|
+
}
|
|
88
|
+
export interface ItemUpdateApi {
|
|
89
|
+
updateCorrect: (correct: boolean) => void;
|
|
90
|
+
updateAttempted: (attempted: boolean) => void;
|
|
91
|
+
updateAnswer: (answer: CurrentAnswer | undefined) => void;
|
|
92
|
+
updateStatus: (updates: Partial<ItemStatus>) => void;
|
|
93
|
+
updateScore: (currentScore: number, maxScore?: number) => void;
|
|
94
|
+
updateMaxScore: (maxScore: number) => void;
|
|
95
|
+
}
|
|
96
|
+
export interface UseIsItemOptions {
|
|
97
|
+
stepId: string;
|
|
98
|
+
type?: ItemType;
|
|
99
|
+
maxScore?: number;
|
|
100
|
+
widgetName?: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Hook for widgets to register as items and get the update API.
|
|
104
|
+
* When used via api.hooks.useIsItem (curried version), widgets can optionally pass configuration.
|
|
105
|
+
*/
|
|
106
|
+
export interface UseIsItem {
|
|
107
|
+
(options?: {
|
|
108
|
+
widgetId?: string;
|
|
109
|
+
options?: Omit<UseIsItemOptions, "stepId">;
|
|
110
|
+
}): ItemUpdateApi;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Hook for registering sub-items with custom IDs (e.g., rows in a matrix).
|
|
114
|
+
* Requires passing a custom widget ID and optional type.
|
|
115
|
+
*/
|
|
116
|
+
export interface UseIsItemWithId {
|
|
117
|
+
(customWidgetId: string, options?: {
|
|
118
|
+
type?: ItemType;
|
|
119
|
+
maxScore?: number;
|
|
120
|
+
widgetName?: string;
|
|
121
|
+
}): ItemUpdateApi;
|
|
85
122
|
}
|
|
86
123
|
export interface ItemsContextValue {
|
|
87
124
|
items: Map<string, ItemData>;
|
|
88
|
-
registerItem: (widgetId: string,
|
|
125
|
+
registerItem: (widgetId: string, stepId: string, type?: ItemType, maxScore?: number, widgetName?: string) => void;
|
|
89
126
|
unregisterItem: (widgetId: string) => void;
|
|
90
127
|
getItems: () => ItemData[];
|
|
128
|
+
getItemsByStepId: (stepId: string) => ItemData[];
|
|
129
|
+
getItemUpdateApi: (widgetId: string) => ItemUpdateApi;
|
|
91
130
|
}
|
|
92
131
|
export interface UseItemsContext {
|
|
93
132
|
(): ItemsContextValue;
|
|
@@ -101,6 +140,7 @@ export interface UseLessonEventSubscription {
|
|
|
101
140
|
export interface TeachariumWidgetApi {
|
|
102
141
|
isEditing: boolean;
|
|
103
142
|
playerMode: "editing" | "preview" | "playbook";
|
|
143
|
+
stepId: string | undefined;
|
|
104
144
|
events: {
|
|
105
145
|
/**
|
|
106
146
|
* Emit an event with type and params
|
|
@@ -111,29 +151,50 @@ export interface TeachariumWidgetApi {
|
|
|
111
151
|
unsubscribe(eventType: string, listener: EventListener): void;
|
|
112
152
|
};
|
|
113
153
|
React: any;
|
|
154
|
+
updateVariables: (values: Record<string, VariableValue>) => void;
|
|
114
155
|
hooks: {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
useVariableValue: UseVariableValue;
|
|
156
|
+
useNumberExpressions: UseNumberExpressions;
|
|
157
|
+
useStringExpressions: UseStringExpressions;
|
|
118
158
|
useVariableValues: UseVariableValues;
|
|
119
|
-
useUpdateVariable: (variableName: string) => UseUpdateVariable;
|
|
120
159
|
useMediaUrl: UseMediaUrl;
|
|
121
160
|
useVoiceoverUrl: UseVoiceoverUrl;
|
|
122
161
|
useConditionEvaluation: UseConditionEvaluation;
|
|
123
162
|
useIsItem: UseIsItem;
|
|
163
|
+
useIsItemWithId: UseIsItemWithId;
|
|
124
164
|
useItemsContext: UseItemsContext;
|
|
125
165
|
useLessonEventEmitter: UseLessonEventEmitter;
|
|
126
166
|
useLessonEventSubscription: UseLessonEventSubscription;
|
|
127
167
|
};
|
|
128
168
|
/**
|
|
129
|
-
* Create a
|
|
130
|
-
*
|
|
169
|
+
* Create a variable that can be either transient (runtime only) or persistent (lesson-wide)
|
|
170
|
+
* By default, creates a transient variable automatically prefixed with the widget ID
|
|
131
171
|
* Example: addVariable('selectedAnswer', 0) might create 'mcwidget1_selectedAnswer'
|
|
132
|
-
*
|
|
172
|
+
*
|
|
173
|
+
* For lesson-wide variables, pass { scope: "lesson", skipPrefix: true }
|
|
174
|
+
* Example: addVariable('TotalTime', 0, "number", { scope: "lesson", skipPrefix: true })
|
|
175
|
+
*
|
|
176
|
+
* @param name - Base name for the variable (will be prefixed with widget ID unless skipPrefix is true)
|
|
133
177
|
* @param initialValue - Initial value for the variable
|
|
134
178
|
* @param type - Optional type specification (auto-inferred if not provided)
|
|
179
|
+
* @param options - Optional configuration for the variable
|
|
135
180
|
* @returns The full variable name that was created
|
|
136
181
|
*/
|
|
137
|
-
addVariable: (name: string, initialValue: VariableValue, type?: "string" | "number" | "boolean"
|
|
182
|
+
addVariable: (name: string, initialValue: VariableValue, type?: "string" | "number" | "boolean", options?: {
|
|
183
|
+
scope?: "lesson" | "step";
|
|
184
|
+
skipPrefix?: boolean;
|
|
185
|
+
description?: string;
|
|
186
|
+
}) => string;
|
|
187
|
+
/**
|
|
188
|
+
* Increment a numeric variable by a specified amount
|
|
189
|
+
* @param name - Variable name to increment
|
|
190
|
+
* @param amount - Amount to increment by (default: 1)
|
|
191
|
+
*/
|
|
192
|
+
incrementVariable: (name: string, amount?: number) => void;
|
|
193
|
+
/**
|
|
194
|
+
* Decrement a numeric variable by a specified amount
|
|
195
|
+
* @param name - Variable name to decrement
|
|
196
|
+
* @param amount - Amount to decrement by (default: 1)
|
|
197
|
+
*/
|
|
198
|
+
decrementVariable: (name: string, amount?: number) => void;
|
|
138
199
|
}
|
|
139
200
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
1
2
|
import { DefaultComponentProps, Fields, PuckComponent } from '@measured/puck';
|
|
2
3
|
import { TeachariumWidgetApi } from './teacharium-widget-api';
|
|
3
4
|
import { TeachariumCustomFields } from './teacharium-custom-fields';
|
|
@@ -12,11 +13,19 @@ export interface TeachariumComponentConfig<T = {}> {
|
|
|
12
13
|
props: any;
|
|
13
14
|
changed: any;
|
|
14
15
|
}) => Promise<any>;
|
|
16
|
+
resolveFields?: (data: unknown, context: {
|
|
17
|
+
fields: Fields<DefaultComponentProps, TeachariumCustomFields>;
|
|
18
|
+
}) => Fields<DefaultComponentProps, TeachariumCustomFields>;
|
|
15
19
|
render: PuckComponent<T & TeachariumComponentProps>;
|
|
16
20
|
}
|
|
17
21
|
export interface TeachariumWidget<T> {
|
|
18
22
|
name: string;
|
|
19
23
|
category: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
aiPrompt?: string;
|
|
26
|
+
icon?: React.ComponentType<{
|
|
27
|
+
className?: string;
|
|
28
|
+
}> | string;
|
|
20
29
|
config: TeachariumComponentConfig<T>;
|
|
21
30
|
}
|
|
22
31
|
export declare const registerWidget: (widget: TeachariumWidget<any>) => void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as x from "react";
|
|
2
|
-
import
|
|
3
|
-
import { VolumeX as Q, Loader2 as
|
|
4
|
-
const
|
|
5
|
-
window.TeachariumComponents = window.TeachariumComponents || {}, window.TeachariumComponents[
|
|
6
|
-
}, Re = () => Object.values(window.TeachariumComponents || {}),
|
|
7
|
-
var M = { exports: {} },
|
|
2
|
+
import oe from "react";
|
|
3
|
+
import { VolumeX as Q, Loader2 as ae, Pause as se, Play as ce, Volume2 as ie } from "lucide-react";
|
|
4
|
+
const be = (n) => {
|
|
5
|
+
window.TeachariumComponents = window.TeachariumComponents || {}, window.TeachariumComponents[n.name] = n;
|
|
6
|
+
}, Re = () => Object.values(window.TeachariumComponents || {}), Te = "player", ye = "footer";
|
|
7
|
+
var M = { exports: {} }, k = {};
|
|
8
8
|
/**
|
|
9
9
|
* @license React
|
|
10
10
|
* react-jsx-runtime.production.js
|
|
@@ -15,28 +15,28 @@ var M = { exports: {} }, O = {};
|
|
|
15
15
|
* LICENSE file in the root directory of this source tree.
|
|
16
16
|
*/
|
|
17
17
|
var K;
|
|
18
|
-
function
|
|
19
|
-
if (K) return
|
|
18
|
+
function le() {
|
|
19
|
+
if (K) return k;
|
|
20
20
|
K = 1;
|
|
21
|
-
var
|
|
22
|
-
function
|
|
23
|
-
var
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
for (var
|
|
27
|
-
|
|
28
|
-
} else
|
|
29
|
-
return
|
|
30
|
-
$$typeof:
|
|
31
|
-
type:
|
|
32
|
-
key:
|
|
33
|
-
ref:
|
|
34
|
-
props:
|
|
21
|
+
var n = Symbol.for("react.transitional.element"), o = Symbol.for("react.fragment");
|
|
22
|
+
function t(m, i, l) {
|
|
23
|
+
var s = null;
|
|
24
|
+
if (l !== void 0 && (s = "" + l), i.key !== void 0 && (s = "" + i.key), "key" in i) {
|
|
25
|
+
l = {};
|
|
26
|
+
for (var E in i)
|
|
27
|
+
E !== "key" && (l[E] = i[E]);
|
|
28
|
+
} else l = i;
|
|
29
|
+
return i = l.ref, {
|
|
30
|
+
$$typeof: n,
|
|
31
|
+
type: m,
|
|
32
|
+
key: s,
|
|
33
|
+
ref: i !== void 0 ? i : null,
|
|
34
|
+
props: l
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return k.Fragment = o, k.jsx = t, k.jsxs = t, k;
|
|
38
38
|
}
|
|
39
|
-
var
|
|
39
|
+
var O = {};
|
|
40
40
|
/**
|
|
41
41
|
* @license React
|
|
42
42
|
* react-jsx-runtime.development.js
|
|
@@ -49,19 +49,19 @@ var k = {};
|
|
|
49
49
|
var ee;
|
|
50
50
|
function ue() {
|
|
51
51
|
return ee || (ee = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
52
|
-
function
|
|
52
|
+
function n(e) {
|
|
53
53
|
if (e == null) return null;
|
|
54
54
|
if (typeof e == "function")
|
|
55
55
|
return e.$$typeof === I ? null : e.displayName || e.name || null;
|
|
56
56
|
if (typeof e == "string") return e;
|
|
57
57
|
switch (e) {
|
|
58
|
-
case
|
|
58
|
+
case y:
|
|
59
59
|
return "Fragment";
|
|
60
|
-
case
|
|
60
|
+
case W:
|
|
61
61
|
return "Profiler";
|
|
62
62
|
case R:
|
|
63
63
|
return "StrictMode";
|
|
64
|
-
case
|
|
64
|
+
case _:
|
|
65
65
|
return "Suspense";
|
|
66
66
|
case N:
|
|
67
67
|
return "SuspenseList";
|
|
@@ -72,72 +72,72 @@ function ue() {
|
|
|
72
72
|
switch (typeof e.tag == "number" && console.error(
|
|
73
73
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
74
74
|
), e.$$typeof) {
|
|
75
|
-
case
|
|
75
|
+
case $:
|
|
76
76
|
return "Portal";
|
|
77
77
|
case S:
|
|
78
78
|
return (e.displayName || "Context") + ".Provider";
|
|
79
79
|
case D:
|
|
80
80
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
81
|
-
case
|
|
81
|
+
case c:
|
|
82
82
|
var r = e.render;
|
|
83
83
|
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
84
84
|
case L:
|
|
85
|
-
return r = e.displayName || null, r !== null ? r :
|
|
85
|
+
return r = e.displayName || null, r !== null ? r : n(e.type) || "Memo";
|
|
86
86
|
case j:
|
|
87
87
|
r = e._payload, e = e._init;
|
|
88
88
|
try {
|
|
89
|
-
return
|
|
89
|
+
return n(e(r));
|
|
90
90
|
} catch {
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
return null;
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function o(e) {
|
|
96
96
|
return "" + e;
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function t(e) {
|
|
99
99
|
try {
|
|
100
|
-
|
|
100
|
+
o(e);
|
|
101
101
|
var r = !1;
|
|
102
102
|
} catch {
|
|
103
103
|
r = !0;
|
|
104
104
|
}
|
|
105
105
|
if (r) {
|
|
106
106
|
r = console;
|
|
107
|
-
var a = r.error,
|
|
107
|
+
var a = r.error, u = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
108
108
|
return a.call(
|
|
109
109
|
r,
|
|
110
110
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
111
|
-
|
|
112
|
-
),
|
|
111
|
+
u
|
|
112
|
+
), o(e);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
function
|
|
116
|
-
if (e ===
|
|
115
|
+
function m(e) {
|
|
116
|
+
if (e === y) return "<>";
|
|
117
117
|
if (typeof e == "object" && e !== null && e.$$typeof === j)
|
|
118
118
|
return "<...>";
|
|
119
119
|
try {
|
|
120
|
-
var r =
|
|
120
|
+
var r = n(e);
|
|
121
121
|
return r ? "<" + r + ">" : "<...>";
|
|
122
122
|
} catch {
|
|
123
123
|
return "<...>";
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
var e =
|
|
126
|
+
function i() {
|
|
127
|
+
var e = h.A;
|
|
128
128
|
return e === null ? null : e.getOwner();
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function l() {
|
|
131
131
|
return Error("react-stack-top-frame");
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function s(e) {
|
|
134
134
|
if (G.call(e, "key")) {
|
|
135
135
|
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
136
136
|
if (r && r.isReactWarning) return !1;
|
|
137
137
|
}
|
|
138
138
|
return e.key !== void 0;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function E(e, r) {
|
|
141
141
|
function a() {
|
|
142
142
|
H || (H = !0, console.error(
|
|
143
143
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
@@ -150,18 +150,18 @@ function ue() {
|
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
152
|
function w() {
|
|
153
|
-
var e =
|
|
153
|
+
var e = n(this.type);
|
|
154
154
|
return z[e] || (z[e] = !0, console.error(
|
|
155
155
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
156
156
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
157
157
|
}
|
|
158
|
-
function A(e, r, a,
|
|
159
|
-
return a =
|
|
158
|
+
function A(e, r, a, u, T, p, V, J) {
|
|
159
|
+
return a = p.ref, e = {
|
|
160
160
|
$$typeof: C,
|
|
161
161
|
type: e,
|
|
162
162
|
key: r,
|
|
163
|
-
props:
|
|
164
|
-
_owner:
|
|
163
|
+
props: p,
|
|
164
|
+
_owner: T
|
|
165
165
|
}, (a !== void 0 ? a : null) !== null ? Object.defineProperty(e, "ref", {
|
|
166
166
|
enumerable: !1,
|
|
167
167
|
get: w
|
|
@@ -187,51 +187,51 @@ function ue() {
|
|
|
187
187
|
value: J
|
|
188
188
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
191
|
-
var
|
|
192
|
-
if (
|
|
193
|
-
if (
|
|
194
|
-
if (te(
|
|
195
|
-
for (
|
|
196
|
-
P(u
|
|
197
|
-
Object.freeze && Object.freeze(
|
|
190
|
+
function v(e, r, a, u, T, p, V, J) {
|
|
191
|
+
var d = r.children;
|
|
192
|
+
if (d !== void 0)
|
|
193
|
+
if (u)
|
|
194
|
+
if (te(d)) {
|
|
195
|
+
for (u = 0; u < d.length; u++)
|
|
196
|
+
P(d[u]);
|
|
197
|
+
Object.freeze && Object.freeze(d);
|
|
198
198
|
} else
|
|
199
199
|
console.error(
|
|
200
200
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
201
201
|
);
|
|
202
|
-
else P(
|
|
202
|
+
else P(d);
|
|
203
203
|
if (G.call(r, "key")) {
|
|
204
|
-
|
|
205
|
-
var
|
|
204
|
+
d = n(e);
|
|
205
|
+
var g = Object.keys(r).filter(function(ne) {
|
|
206
206
|
return ne !== "key";
|
|
207
207
|
});
|
|
208
|
-
|
|
208
|
+
u = 0 < g.length ? "{key: someKey, " + g.join(": ..., ") + ": ...}" : "{key: someKey}", Z[d + u] || (g = 0 < g.length ? "{" + g.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
209
209
|
`A props object containing a "key" prop is being spread into JSX:
|
|
210
210
|
let props = %s;
|
|
211
211
|
<%s {...props} />
|
|
212
212
|
React keys must be passed directly to JSX without using spread:
|
|
213
213
|
let props = %s;
|
|
214
214
|
<%s key={someKey} {...props} />`,
|
|
215
|
-
c,
|
|
216
215
|
u,
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
216
|
+
d,
|
|
217
|
+
g,
|
|
218
|
+
d
|
|
219
|
+
), Z[d + u] = !0);
|
|
220
220
|
}
|
|
221
|
-
if (
|
|
221
|
+
if (d = null, a !== void 0 && (t(a), d = "" + a), s(r) && (t(r.key), d = "" + r.key), "key" in r) {
|
|
222
222
|
a = {};
|
|
223
223
|
for (var q in r)
|
|
224
224
|
q !== "key" && (a[q] = r[q]);
|
|
225
225
|
} else a = r;
|
|
226
|
-
return
|
|
226
|
+
return d && E(
|
|
227
227
|
a,
|
|
228
228
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
229
229
|
), A(
|
|
230
230
|
e,
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
231
|
+
d,
|
|
232
|
+
p,
|
|
233
|
+
T,
|
|
234
|
+
i(),
|
|
235
235
|
a,
|
|
236
236
|
V,
|
|
237
237
|
J
|
|
@@ -240,48 +240,48 @@ React keys must be passed directly to JSX without using spread:
|
|
|
240
240
|
function P(e) {
|
|
241
241
|
typeof e == "object" && e !== null && e.$$typeof === C && e._store && (e._store.validated = 1);
|
|
242
242
|
}
|
|
243
|
-
var
|
|
243
|
+
var b = oe, C = Symbol.for("react.transitional.element"), $ = Symbol.for("react.portal"), y = Symbol.for("react.fragment"), R = Symbol.for("react.strict_mode"), W = Symbol.for("react.profiler"), D = Symbol.for("react.consumer"), S = Symbol.for("react.context"), c = Symbol.for("react.forward_ref"), _ = Symbol.for("react.suspense"), N = Symbol.for("react.suspense_list"), L = Symbol.for("react.memo"), j = Symbol.for("react.lazy"), Y = Symbol.for("react.activity"), I = Symbol.for("react.client.reference"), h = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, G = Object.prototype.hasOwnProperty, te = Array.isArray, U = console.createTask ? console.createTask : function() {
|
|
244
244
|
return null;
|
|
245
245
|
};
|
|
246
|
-
|
|
246
|
+
b = {
|
|
247
247
|
react_stack_bottom_frame: function(e) {
|
|
248
248
|
return e();
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
|
-
var H, z = {}, X =
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
)(), B = U(
|
|
255
|
-
|
|
256
|
-
var
|
|
257
|
-
return
|
|
251
|
+
var H, z = {}, X = b.react_stack_bottom_frame.bind(
|
|
252
|
+
b,
|
|
253
|
+
l
|
|
254
|
+
)(), B = U(m(l)), Z = {};
|
|
255
|
+
O.Fragment = y, O.jsx = function(e, r, a, u, T) {
|
|
256
|
+
var p = 1e4 > h.recentlyCreatedOwnerStacks++;
|
|
257
|
+
return v(
|
|
258
258
|
e,
|
|
259
259
|
r,
|
|
260
260
|
a,
|
|
261
261
|
!1,
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
262
|
+
u,
|
|
263
|
+
T,
|
|
264
|
+
p ? Error("react-stack-top-frame") : X,
|
|
265
|
+
p ? U(m(e)) : B
|
|
266
266
|
);
|
|
267
|
-
},
|
|
268
|
-
var
|
|
269
|
-
return
|
|
267
|
+
}, O.jsxs = function(e, r, a, u, T) {
|
|
268
|
+
var p = 1e4 > h.recentlyCreatedOwnerStacks++;
|
|
269
|
+
return v(
|
|
270
270
|
e,
|
|
271
271
|
r,
|
|
272
272
|
a,
|
|
273
273
|
!0,
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
274
|
+
u,
|
|
275
|
+
T,
|
|
276
|
+
p ? Error("react-stack-top-frame") : X,
|
|
277
|
+
p ? U(m(e)) : B
|
|
278
278
|
);
|
|
279
279
|
};
|
|
280
|
-
})()),
|
|
280
|
+
})()), O;
|
|
281
281
|
}
|
|
282
282
|
var re;
|
|
283
283
|
function de() {
|
|
284
|
-
return re || (re = 1, process.env.NODE_ENV === "production" ? M.exports =
|
|
284
|
+
return re || (re = 1, process.env.NODE_ENV === "production" ? M.exports = le() : M.exports = ue()), M.exports;
|
|
285
285
|
}
|
|
286
286
|
var f = de();
|
|
287
287
|
const fe = {
|
|
@@ -300,28 +300,28 @@ const fe = {
|
|
|
300
300
|
// { label: "Partial", value: "partial" },
|
|
301
301
|
// ],
|
|
302
302
|
// },
|
|
303
|
-
}, me = ({ margin:
|
|
304
|
-
const
|
|
305
|
-
return
|
|
306
|
-
},
|
|
307
|
-
const
|
|
303
|
+
}, me = ({ margin: n, children: o }) => {
|
|
304
|
+
const t = {};
|
|
305
|
+
return n && (t.padding = `${n}px`), /* @__PURE__ */ f.jsx("div", { style: t, children: o });
|
|
306
|
+
}, _e = (n) => {
|
|
307
|
+
const o = n.render;
|
|
308
308
|
return {
|
|
309
|
-
...
|
|
310
|
-
render: (
|
|
309
|
+
...n,
|
|
310
|
+
render: (t) => /* @__PURE__ */ f.jsx(me, { ...t, children: /* @__PURE__ */ f.jsx(o, { ...t }) }),
|
|
311
311
|
fields: {
|
|
312
|
-
...
|
|
312
|
+
...n.fields,
|
|
313
313
|
...fe
|
|
314
314
|
}
|
|
315
315
|
};
|
|
316
|
-
}, F = (...
|
|
317
|
-
audioUrl:
|
|
318
|
-
className:
|
|
319
|
-
size:
|
|
320
|
-
onPlay:
|
|
321
|
-
onPause:
|
|
322
|
-
onError:
|
|
316
|
+
}, F = (...n) => n.filter(Boolean).join(" "), he = ({
|
|
317
|
+
audioUrl: n,
|
|
318
|
+
className: o,
|
|
319
|
+
size: t = "sm",
|
|
320
|
+
onPlay: m,
|
|
321
|
+
onPause: i,
|
|
322
|
+
onError: l
|
|
323
323
|
}) => {
|
|
324
|
-
const
|
|
324
|
+
const s = x.useRef(null), [E, w] = x.useState(!1), [A, v] = x.useState(!1), [P, b] = x.useState(null), [C, $] = x.useState(!1), y = {
|
|
325
325
|
sm: "h-6 w-6",
|
|
326
326
|
md: "h-8 w-8",
|
|
327
327
|
lg: "h-10 w-10"
|
|
@@ -329,40 +329,40 @@ const fe = {
|
|
|
329
329
|
sm: 12,
|
|
330
330
|
md: 16,
|
|
331
331
|
lg: 20
|
|
332
|
-
},
|
|
333
|
-
if (
|
|
332
|
+
}, W = async () => {
|
|
333
|
+
if (s.current)
|
|
334
334
|
try {
|
|
335
|
-
|
|
336
|
-
} catch (
|
|
337
|
-
const
|
|
338
|
-
|
|
335
|
+
v(!0), b(null), E ? s.current.pause() : await s.current.play();
|
|
336
|
+
} catch (c) {
|
|
337
|
+
const _ = c instanceof Error ? c.message : "Failed to play audio";
|
|
338
|
+
b(_), l?.(_);
|
|
339
339
|
} finally {
|
|
340
|
-
|
|
340
|
+
v(!1);
|
|
341
341
|
}
|
|
342
342
|
}, D = () => {
|
|
343
|
-
|
|
343
|
+
s.current && (s.current.muted = !s.current.muted, $(s.current.muted));
|
|
344
344
|
};
|
|
345
345
|
x.useEffect(() => {
|
|
346
|
-
const
|
|
347
|
-
if (!
|
|
348
|
-
const
|
|
349
|
-
w(!0),
|
|
346
|
+
const c = s.current;
|
|
347
|
+
if (!c) return;
|
|
348
|
+
const _ = () => {
|
|
349
|
+
w(!0), m?.();
|
|
350
350
|
}, N = () => {
|
|
351
|
-
w(!1),
|
|
351
|
+
w(!1), i?.();
|
|
352
352
|
}, L = () => {
|
|
353
|
-
w(!1),
|
|
353
|
+
w(!1), i?.();
|
|
354
354
|
}, j = () => {
|
|
355
|
-
|
|
355
|
+
v(!0);
|
|
356
356
|
}, Y = () => {
|
|
357
|
-
|
|
357
|
+
v(!1);
|
|
358
358
|
}, I = () => {
|
|
359
|
-
const
|
|
360
|
-
|
|
359
|
+
const h = "Failed to load audio";
|
|
360
|
+
b(h), v(!1), l?.(h);
|
|
361
361
|
};
|
|
362
|
-
return
|
|
363
|
-
|
|
362
|
+
return c.addEventListener("play", _), c.addEventListener("pause", N), c.addEventListener("ended", L), c.addEventListener("loadstart", j), c.addEventListener("canplay", Y), c.addEventListener("error", I), () => {
|
|
363
|
+
c.removeEventListener("play", _), c.removeEventListener("pause", N), c.removeEventListener("ended", L), c.removeEventListener("loadstart", j), c.removeEventListener("canplay", Y), c.removeEventListener("error", I);
|
|
364
364
|
};
|
|
365
|
-
}, [
|
|
365
|
+
}, [m, i, l]);
|
|
366
366
|
const S = "inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 ring-offset-background bg-transparent hover:bg-gray-100";
|
|
367
367
|
return P ? /* @__PURE__ */ f.jsx(
|
|
368
368
|
"button",
|
|
@@ -370,55 +370,87 @@ const fe = {
|
|
|
370
370
|
type: "button",
|
|
371
371
|
className: F(
|
|
372
372
|
S,
|
|
373
|
-
|
|
373
|
+
y[t],
|
|
374
374
|
"text-red-500",
|
|
375
|
-
|
|
375
|
+
o
|
|
376
376
|
),
|
|
377
377
|
disabled: !0,
|
|
378
|
-
children: /* @__PURE__ */ f.jsx(Q, { size: R[
|
|
378
|
+
children: /* @__PURE__ */ f.jsx(Q, { size: R[t] })
|
|
379
379
|
}
|
|
380
|
-
) : /* @__PURE__ */ f.jsxs("div", { className: F("flex items-center gap-1",
|
|
381
|
-
/* @__PURE__ */ f.jsx("audio", { ref:
|
|
380
|
+
) : /* @__PURE__ */ f.jsxs("div", { className: F("flex items-center gap-1", o), children: [
|
|
381
|
+
/* @__PURE__ */ f.jsx("audio", { ref: s, src: n, preload: "metadata" }),
|
|
382
382
|
/* @__PURE__ */ f.jsx(
|
|
383
383
|
"button",
|
|
384
384
|
{
|
|
385
385
|
type: "button",
|
|
386
|
-
className: F(S,
|
|
387
|
-
onClick:
|
|
386
|
+
className: F(S, y[t]),
|
|
387
|
+
onClick: W,
|
|
388
388
|
disabled: A,
|
|
389
|
-
children: A ? /* @__PURE__ */ f.jsx(
|
|
389
|
+
children: A ? /* @__PURE__ */ f.jsx(ae, { size: R[t], className: "animate-spin" }) : E ? /* @__PURE__ */ f.jsx(se, { size: R[t] }) : /* @__PURE__ */ f.jsx(ce, { size: R[t] })
|
|
390
390
|
}
|
|
391
391
|
),
|
|
392
|
-
|
|
392
|
+
t !== "sm" && /* @__PURE__ */ f.jsx(
|
|
393
393
|
"button",
|
|
394
394
|
{
|
|
395
395
|
type: "button",
|
|
396
|
-
className: F(S,
|
|
396
|
+
className: F(S, y[t]),
|
|
397
397
|
onClick: D,
|
|
398
|
-
children: C ? /* @__PURE__ */ f.jsx(Q, { size: R[
|
|
398
|
+
children: C ? /* @__PURE__ */ f.jsx(Q, { size: R[t] }) : /* @__PURE__ */ f.jsx(ie, { size: R[t] })
|
|
399
399
|
}
|
|
400
400
|
)
|
|
401
401
|
] });
|
|
402
402
|
}, Ee = "SHA-256";
|
|
403
|
-
async function
|
|
404
|
-
const
|
|
405
|
-
if (!
|
|
403
|
+
async function ge(n) {
|
|
404
|
+
const o = globalThis.crypto?.subtle;
|
|
405
|
+
if (!o)
|
|
406
406
|
throw new Error("Web Crypto is not available to compute voiceover hashes");
|
|
407
|
-
const
|
|
408
|
-
let
|
|
409
|
-
for (let
|
|
410
|
-
|
|
411
|
-
return
|
|
407
|
+
const m = new TextEncoder().encode(n), i = await o.digest(Ee, m), l = new Uint8Array(i);
|
|
408
|
+
let s = "";
|
|
409
|
+
for (let E = 0; E < l.length; E += 1)
|
|
410
|
+
s += l[E].toString(16).padStart(2, "0");
|
|
411
|
+
return s;
|
|
412
|
+
}
|
|
413
|
+
function xe(n, o) {
|
|
414
|
+
!o || o.length === 0 || o.forEach((t) => {
|
|
415
|
+
if (!t.actionType) {
|
|
416
|
+
console.warn("Skipping action with no actionType:", t);
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
try {
|
|
420
|
+
n.events.emit({
|
|
421
|
+
type: t.actionType,
|
|
422
|
+
params: t.parameters || {}
|
|
423
|
+
});
|
|
424
|
+
} catch (m) {
|
|
425
|
+
console.error(`Error executing action ${t.actionType}:`, m);
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
function we(n, o) {
|
|
430
|
+
if (!o || !o.actionType) {
|
|
431
|
+
console.warn("Cannot execute action with no actionType:", o);
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
try {
|
|
435
|
+
n.events.emit({
|
|
436
|
+
type: o.actionType,
|
|
437
|
+
params: o.parameters || {}
|
|
438
|
+
});
|
|
439
|
+
} catch (t) {
|
|
440
|
+
console.error(`Error executing action ${o.actionType}:`, t);
|
|
441
|
+
}
|
|
412
442
|
}
|
|
413
|
-
const
|
|
443
|
+
const Se = "world";
|
|
414
444
|
export {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
445
|
+
he as AudioPlayer,
|
|
446
|
+
ye as EVENT_SOURCE_FOOTER,
|
|
447
|
+
Te as EVENT_SOURCE_PLAYER,
|
|
418
448
|
me as LayoutContainer,
|
|
419
|
-
|
|
420
|
-
|
|
449
|
+
_e as addStandardLayoutOptions,
|
|
450
|
+
we as executeAction,
|
|
451
|
+
xe as executeActions,
|
|
452
|
+
ge as getVoiceoverHash,
|
|
421
453
|
Re as getWidgets,
|
|
422
|
-
|
|
423
|
-
|
|
454
|
+
Se as hi,
|
|
455
|
+
be as registerWidget
|
|
424
456
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TeachariumWidgetApi } from '../teacharium-widget-api';
|
|
2
|
+
/**
|
|
3
|
+
* Action configuration type
|
|
4
|
+
*/
|
|
5
|
+
export interface ActionConfiguration {
|
|
6
|
+
actionType: string;
|
|
7
|
+
parameters: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Execute multiple actions in sequence
|
|
11
|
+
*
|
|
12
|
+
* @param api - The TeachariumWidgetApi instance
|
|
13
|
+
* @param actions - Array of action configurations to execute
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* executeActions(api, [
|
|
18
|
+
* { actionType: "setVariable", parameters: { variableName: "score", value: 10 } },
|
|
19
|
+
* { actionType: "showFeedback", parameters: { message: "Great!", variant: "correct" } },
|
|
20
|
+
* { actionType: "nextStep", parameters: {} }
|
|
21
|
+
* ]);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function executeActions(api: TeachariumWidgetApi, actions: ActionConfiguration[]): void;
|
|
25
|
+
/**
|
|
26
|
+
* Execute a single action
|
|
27
|
+
*
|
|
28
|
+
* @param api - The TeachariumWidgetApi instance
|
|
29
|
+
* @param action - Action configuration to execute
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* executeAction(api, {
|
|
34
|
+
* actionType: "nextStep",
|
|
35
|
+
* parameters: {}
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function executeAction(api: TeachariumWidgetApi, action: ActionConfiguration): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teacharium/widget",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"@measured/puck": "^0.20.2",
|
|
12
12
|
"@next/eslint-plugin-next": "^15.5.4",
|
|
13
13
|
"lucide-react": "^0.511.0",
|
|
14
|
-
"react": "
|
|
15
|
-
"react-dom": "
|
|
14
|
+
"react": "19.1.2",
|
|
15
|
+
"react-dom": "19.1.2"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@eslint/js": "^9.35.0",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"dev": "tsc -b && vite build --watch",
|
|
33
33
|
"build:watch": "tsc -b && vite build --watch",
|
|
34
34
|
"build": "tsc -b && vite build",
|
|
35
|
-
"lint": "eslint ."
|
|
35
|
+
"lint": "eslint .",
|
|
36
|
+
"type-check": "tsc --noEmit"
|
|
36
37
|
}
|
|
37
38
|
}
|