@coxwave/tap-kit-types 2.10.1 → 2.10.3
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/index.d.ts +44 -82
- package/dist/index.js +16 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -179,74 +179,36 @@ type ContainerConfig = {
|
|
|
179
179
|
};
|
|
180
180
|
|
|
181
181
|
/**
|
|
182
|
-
* Feature Flags
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
type
|
|
206
|
-
/**
|
|
207
|
-
* Enable/disable PDF download button in material viewer
|
|
208
|
-
* @default true (download enabled)
|
|
209
|
-
*/
|
|
210
|
-
"material.pdf.download"
|
|
211
|
-
/**
|
|
212
|
-
* Enable/disable streak widget on home page
|
|
213
|
-
* @default false (disabled, feature in development)
|
|
214
|
-
*/
|
|
215
|
-
| "home.streak.enabled"
|
|
216
|
-
/**
|
|
217
|
-
* Enable/disable flashcard widget on home page
|
|
218
|
-
* @default false (disabled, feature in development)
|
|
219
|
-
*/
|
|
220
|
-
| "home.flashcard.enabled"
|
|
221
|
-
/**
|
|
222
|
-
* Enable/disable activity buttons on home page
|
|
223
|
-
* @default true (enabled by default)
|
|
224
|
-
*/
|
|
225
|
-
| "home.activity.enabled";
|
|
226
|
-
/**
|
|
227
|
-
* Feature flags object type
|
|
228
|
-
*
|
|
229
|
-
* All flags are optional - undefined means "use default behavior"
|
|
230
|
-
* false = explicitly disabled
|
|
231
|
-
* true = explicitly enabled
|
|
232
|
-
*/
|
|
182
|
+
* Feature Flags — Single Source of Truth
|
|
183
|
+
*
|
|
184
|
+
* FLAG_DEFAULTS is the sole authority.
|
|
185
|
+
* FeatureFlagKey is derived — never define keys separately.
|
|
186
|
+
* Server values always override: { ...FLAG_DEFAULTS, ...serverFlags }
|
|
187
|
+
*
|
|
188
|
+
* Naming: LaunchDarkly-style {action}.{subject}
|
|
189
|
+
* - show.* — UI visibility toggle
|
|
190
|
+
* - allow.* — capability/permission gate
|
|
191
|
+
*/
|
|
192
|
+
/** Every flag and its default. Add new flags here — types update automatically. */
|
|
193
|
+
declare const FLAG_DEFAULTS: {
|
|
194
|
+
readonly "show.tutor-profile": true;
|
|
195
|
+
readonly "show.streak": false;
|
|
196
|
+
readonly "show.activity": true;
|
|
197
|
+
readonly "show.quicktaps": true;
|
|
198
|
+
readonly "show.flashcard": false;
|
|
199
|
+
readonly "show.exam-activity": false;
|
|
200
|
+
readonly "show.chat-mode-chip": false;
|
|
201
|
+
readonly "allow.pdf-download": true;
|
|
202
|
+
};
|
|
203
|
+
/** Derived union of all known flag keys. */
|
|
204
|
+
type FeatureFlagKey = keyof typeof FLAG_DEFAULTS;
|
|
205
|
+
/** Partial flags — API boundary type (server may omit keys). */
|
|
233
206
|
type FeatureFlags = Partial<Record<FeatureFlagKey, boolean>>;
|
|
234
|
-
/**
|
|
235
|
-
|
|
236
|
-
*
|
|
237
|
-
* @param flags - Feature flags object
|
|
238
|
-
* @param key - Feature flag key to check
|
|
239
|
-
* @param defaultValue - Default value if flag is undefined (default: true)
|
|
240
|
-
* @returns Whether the feature is enabled
|
|
241
|
-
*
|
|
242
|
-
* @example
|
|
243
|
-
* const canDownload = isFeatureEnabled(flags, "material.pdf.download"); // default true
|
|
244
|
-
* const quizEnabled = isFeatureEnabled(flags, "quiz.enabled", false); // default false
|
|
245
|
-
*/
|
|
246
|
-
declare function isFeatureEnabled(flags: FeatureFlags | undefined, key: FeatureFlagKey, defaultValue?: boolean): boolean;
|
|
207
|
+
/** Check if a feature is enabled. Falls back to FLAG_DEFAULTS. */
|
|
208
|
+
declare function isFeatureEnabled(flags: FeatureFlags | undefined, key: FeatureFlagKey): boolean;
|
|
247
209
|
|
|
248
|
-
type TapMessageType = "tap:ready" | "tap:close" | "timeline:seek" | "alarm:click" | "alarm:fadeIn" | "popUp:open" | "popUp:close" | "material:view:open" | "material:view:close" | "material:view:error" | "html:view:open" | "html:view:close" | "container:mode:change" | "container:mode:change:ack" | "container:layout:state:changed" | "viewport:resize" | "config:update" | "config:request" | "GA_EVENT" | "tutor:info"
|
|
249
|
-
type TapMessage = TapReadyMessage | TapCloseMessage | TimelineSeekMessage | AlarmClickMessage | AlarmFadeInMessage | PopUpOpenMessage | PopUpCloseMessage | MaterialViewOpenMessage | MaterialViewCloseMessage | MaterialViewErrorMessage | HtmlViewOpenMessage | HtmlViewCloseMessage | ContainerModeChangeMessage | ContainerModeChangeAckMessage | ContainerLayoutStateChangedMessage | ViewportResizeMessage | ConfigUpdateMessage | ConfigRequestMessage | GAEventMessage | TutorInfoMessage
|
|
210
|
+
type TapMessageType = "tap:ready" | "tap:close" | "timeline:seek" | "alarm:click" | "alarm:fadeIn" | "popUp:open" | "popUp:close" | "material:view:open" | "material:view:close" | "material:view:error" | "html:view:open" | "html:view:close" | "container:mode:change" | "container:mode:change:ack" | "container:layout:state:changed" | "viewport:resize" | "config:update" | "config:request" | "GA_EVENT" | "tutor:info";
|
|
211
|
+
type TapMessage = TapReadyMessage | TapCloseMessage | TimelineSeekMessage | AlarmClickMessage | AlarmFadeInMessage | PopUpOpenMessage | PopUpCloseMessage | MaterialViewOpenMessage | MaterialViewCloseMessage | MaterialViewErrorMessage | HtmlViewOpenMessage | HtmlViewCloseMessage | ContainerModeChangeMessage | ContainerModeChangeAckMessage | ContainerLayoutStateChangedMessage | ViewportResizeMessage | ConfigUpdateMessage | ConfigRequestMessage | GAEventMessage | TutorInfoMessage;
|
|
250
212
|
interface TapReadyMessage {
|
|
251
213
|
type: "tap:ready";
|
|
252
214
|
gaId: string;
|
|
@@ -292,7 +254,7 @@ interface MaterialViewOpenMessage {
|
|
|
292
254
|
title?: string;
|
|
293
255
|
/** Text phrases to highlight in PDF (from reference_string parsing) */
|
|
294
256
|
highlightPhrases?: string[];
|
|
295
|
-
/** Feature flags for viewer behavior (e.g., "
|
|
257
|
+
/** Feature flags for viewer behavior (e.g., "allow.pdf-download": false) */
|
|
296
258
|
flags?: FeatureFlags;
|
|
297
259
|
nonce?: string | number;
|
|
298
260
|
}
|
|
@@ -396,6 +358,7 @@ interface ViewportResizeMessage {
|
|
|
396
358
|
* - This message protocol mirrors the structure for serialization
|
|
397
359
|
* - When updating ContainerConfig, update this structure accordingly
|
|
398
360
|
*/
|
|
361
|
+
type ChatMode = "NORMAL" | "EXAM" | "STUDY";
|
|
399
362
|
interface ConfigUpdateMessage {
|
|
400
363
|
type: "config:update";
|
|
401
364
|
apiKey?: string;
|
|
@@ -403,12 +366,14 @@ interface ConfigUpdateMessage {
|
|
|
403
366
|
tapUrl?: string;
|
|
404
367
|
apiUrl?: string;
|
|
405
368
|
environment?: "dev" | "prod" | "demo" | "staging";
|
|
406
|
-
language?: "ko" | "en" | (string & {});
|
|
369
|
+
language?: "ko" | "en" | "ja" | (string & {});
|
|
407
370
|
userId?: string;
|
|
408
371
|
courseId?: string;
|
|
409
372
|
clipId?: string;
|
|
410
373
|
clipPlayHead?: number;
|
|
411
374
|
mode?: DisplayMode;
|
|
375
|
+
/** Chat interaction mode (staging feature: per-message override) */
|
|
376
|
+
chatMode?: ChatMode;
|
|
412
377
|
/**
|
|
413
378
|
* Allow user to toggle between floating and sidebar layouts
|
|
414
379
|
* @default true
|
|
@@ -473,15 +438,6 @@ interface TutorInfoMessage {
|
|
|
473
438
|
type: "tutor:info";
|
|
474
439
|
tutorName: string;
|
|
475
440
|
}
|
|
476
|
-
/**
|
|
477
|
-
* Feature Flags Update Message (iframe → parent)
|
|
478
|
-
* Sent from edutap after tutor_setting API response with feature flags
|
|
479
|
-
* Used to update feature flags store in tap-kit-core
|
|
480
|
-
*/
|
|
481
|
-
interface FeatureFlagsUpdateMessage {
|
|
482
|
-
type: "featureFlags:update";
|
|
483
|
-
flags: FeatureFlags;
|
|
484
|
-
}
|
|
485
441
|
|
|
486
442
|
/**
|
|
487
443
|
* Fallback type.
|
|
@@ -2290,6 +2246,7 @@ declare const ConfigUpdateSchema: ObjectSchema<{
|
|
|
2290
2246
|
readonly clipId: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
2291
2247
|
readonly clipPlayHead: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
2292
2248
|
readonly mode: OptionalSchema<UnionSchema<[LiteralSchema<"inline", undefined>, LiteralSchema<"floating", undefined>, LiteralSchema<"sidebar", undefined>], undefined>, undefined>;
|
|
2249
|
+
readonly chatMode: OptionalSchema<UnionSchema<[LiteralSchema<"NORMAL", undefined>, LiteralSchema<"EXAM", undefined>, LiteralSchema<"STUDY", undefined>], undefined>, undefined>;
|
|
2293
2250
|
readonly allowLayoutToggle: OptionalSchema<BooleanSchema<undefined>, undefined>;
|
|
2294
2251
|
readonly container: OptionalSchema<ObjectSchema<{
|
|
2295
2252
|
readonly floatingConfig: OptionalSchema<ObjectSchema<{
|
|
@@ -2401,6 +2358,7 @@ declare const TapMessageSchema: UnionSchema<[ObjectSchema<{
|
|
|
2401
2358
|
readonly clipId: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
2402
2359
|
readonly clipPlayHead: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
2403
2360
|
readonly mode: OptionalSchema<UnionSchema<[LiteralSchema<"inline", undefined>, LiteralSchema<"floating", undefined>, LiteralSchema<"sidebar", undefined>], undefined>, undefined>;
|
|
2361
|
+
readonly chatMode: OptionalSchema<UnionSchema<[LiteralSchema<"NORMAL", undefined>, LiteralSchema<"EXAM", undefined>, LiteralSchema<"STUDY", undefined>], undefined>, undefined>;
|
|
2404
2362
|
readonly allowLayoutToggle: OptionalSchema<BooleanSchema<undefined>, undefined>;
|
|
2405
2363
|
readonly container: OptionalSchema<ObjectSchema<{
|
|
2406
2364
|
readonly floatingConfig: OptionalSchema<ObjectSchema<{
|
|
@@ -3370,7 +3328,7 @@ interface TapKitElement extends HTMLElement {
|
|
|
3370
3328
|
clipPlayHead?: number;
|
|
3371
3329
|
|
|
3372
3330
|
/** Language (optional, default: "ko") */
|
|
3373
|
-
language?: "ko" | "en";
|
|
3331
|
+
language?: "ko" | "en" | "ja";
|
|
3374
3332
|
|
|
3375
3333
|
/** TAP Frontend URL (optional, for testing) */
|
|
3376
3334
|
tapUrl?: string;
|
|
@@ -3582,7 +3540,7 @@ interface TapKitAttributes {
|
|
|
3582
3540
|
"clip-play-head"?: number;
|
|
3583
3541
|
|
|
3584
3542
|
/** Language setting */
|
|
3585
|
-
language?: "ko" | "en";
|
|
3543
|
+
language?: "ko" | "en" | "ja";
|
|
3586
3544
|
|
|
3587
3545
|
/** TAP Frontend URL (for testing) */
|
|
3588
3546
|
"tap-url"?: string;
|
|
@@ -3607,6 +3565,9 @@ interface TapKitAttributes {
|
|
|
3607
3565
|
*/
|
|
3608
3566
|
mode?: "inline" | "floating" | "sidebar";
|
|
3609
3567
|
|
|
3568
|
+
/** Chat interaction mode (staging feature: per-message override) */
|
|
3569
|
+
"chat-mode"?: "NORMAL" | "EXAM" | "STUDY";
|
|
3570
|
+
|
|
3610
3571
|
/**
|
|
3611
3572
|
* Allow user to toggle between floating and sidebar layouts
|
|
3612
3573
|
* Only applies when mode is "floating" or "sidebar"
|
|
@@ -3730,7 +3691,7 @@ interface MaterialViewConfig {
|
|
|
3730
3691
|
|
|
3731
3692
|
/**
|
|
3732
3693
|
* Feature flags for viewer behavior
|
|
3733
|
-
* @example { "
|
|
3694
|
+
* @example { "allow.pdf-download": false } // Disable download button
|
|
3734
3695
|
*/
|
|
3735
3696
|
flags?: FeatureFlags;
|
|
3736
3697
|
}
|
|
@@ -3913,9 +3874,10 @@ declare global {
|
|
|
3913
3874
|
courseId?: string;
|
|
3914
3875
|
clipId?: string;
|
|
3915
3876
|
clipPlayHead?: number;
|
|
3916
|
-
language?: "ko" | "en";
|
|
3877
|
+
language?: "ko" | "en" | "ja";
|
|
3917
3878
|
buttonId?: string;
|
|
3918
3879
|
mode?: "inline" | "floating" | "sidebar";
|
|
3880
|
+
chatMode?: "NORMAL" | "EXAM" | "STUDY";
|
|
3919
3881
|
debug?: boolean;
|
|
3920
3882
|
apiUrl?: string;
|
|
3921
3883
|
tapUrl?: string;
|
|
@@ -3941,4 +3903,4 @@ declare global {
|
|
|
3941
3903
|
function cancelIdleCallback(handle: number): void;
|
|
3942
3904
|
}
|
|
3943
3905
|
|
|
3944
|
-
export { ALARM_DURATION, type AlarmClickMessage, AlarmClickSchema, type AlarmElement, type AlarmElementProps, AlarmElementPropsSchema, AlarmElementSchema, type AlarmFadeInMessage, AlarmFadeInSchema, AlarmMessageInstanceSchema, type AlarmMessageInstanceType, type AlarmPayload, type AlarmType, type CSSStyle, CSSStyleSchema, type ConfigRequestMessage, ConfigRequestSchema, type ConfigUpdateKey, type ConfigUpdateMessage, type ConfigUpdateOptions, type ConfigUpdatePayload, ConfigUpdateSchema, type ContainerConfig, type ContainerLayoutStateChangedMessage, ContainerLayoutStateChangedSchema, type ContainerModeChangeAckMessage, ContainerModeChangeAckSchema, type ContainerModeChangeMessage, ContainerModeChangeSchema, type ContainerVisibility, type Course, type DisplayMode, type EventManager, type FeatureFlagKey, type FeatureFlags, type
|
|
3906
|
+
export { ALARM_DURATION, type AlarmClickMessage, AlarmClickSchema, type AlarmElement, type AlarmElementProps, AlarmElementPropsSchema, AlarmElementSchema, type AlarmFadeInMessage, AlarmFadeInSchema, AlarmMessageInstanceSchema, type AlarmMessageInstanceType, type AlarmPayload, type AlarmType, type CSSStyle, CSSStyleSchema, type ChatMode, type ConfigRequestMessage, ConfigRequestSchema, type ConfigUpdateKey, type ConfigUpdateMessage, type ConfigUpdateOptions, type ConfigUpdatePayload, ConfigUpdateSchema, type ContainerConfig, type ContainerLayoutStateChangedMessage, ContainerLayoutStateChangedSchema, type ContainerModeChangeAckMessage, ContainerModeChangeAckSchema, type ContainerModeChangeMessage, ContainerModeChangeSchema, type ContainerVisibility, type Course, type DisplayMode, type EventManager, FLAG_DEFAULTS, type FeatureFlagKey, type FeatureFlags, type FloatingConfig, type GAEventMessage, GAEventSchema, type HtmlViewCloseMessage, HtmlViewCloseSchema, type HtmlViewConfig, type HtmlViewOpenMessage, HtmlViewOpenSchema, type ITapButtonElement, type ITapContainerElement, type ITapHtmlViewerElement, type ITapKitElement, type ITapMaterialViewerElement, TapKitInitializationError as InitializationError, type LayoutMode, type MaterialViewCloseMessage, MaterialViewCloseSchema, type MaterialViewConfig, type MaterialViewErrorMessage, MaterialViewErrorSchema, type MaterialViewOpenMessage, MaterialViewOpenSchema, MaterialViewerError, type PopUpCloseMessage, PopUpCloseSchema, type PopUpOpenMessage, PopUpOpenSchema, type PositionType, type SeekTimelineParamsType, type ShortcutKeyPropertiesType, type SidebarConfig, type SyncableConfigKey, TAP_BUTTON_CLICK_EVENT, TAP_ERROR_MARKER, type TapButtonAttributes, type TapButtonClickEventDetail, type TapCloseMessage, TapCloseSchema, type TapContainerAttributes, type TapErrorOptions, type TapHtmlViewerAttributes, type TapKitConfig, TapKitConfigurationError, type TapKitConstructor, type TapKitElement, type TapKitElementEventMap, TapKitError, TapKitIframeError, type TapKitInitParams, TapKitInitializationError, type TapKitInstance, TapKitLoaderError, TapKitMessageError, type TapMaterialViewerAttributes, type TapMessage, type TapMessageRecord, TapMessageSchema, type TapMessageType, type TapReadyMessage, TapReadySchema, type TimelineSeekMessage, TimelineSeekSchema, type TutorInfoMessage, TutorInfoSchema, type VideoController, type VideoPlayerAdapter, type VideoPlayerConfig, type ViewportResizeMessage, ViewportResizeSchema, isFeatureEnabled };
|
package/dist/index.js
CHANGED
|
@@ -3,9 +3,20 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
|
|
5
5
|
// src/feature-flags.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
var FLAG_DEFAULTS = {
|
|
7
|
+
// Home screen (top → bottom, matches preview order)
|
|
8
|
+
"show.tutor-profile": true,
|
|
9
|
+
"show.streak": false,
|
|
10
|
+
"show.activity": true,
|
|
11
|
+
"show.quicktaps": true,
|
|
12
|
+
"show.flashcard": false,
|
|
13
|
+
"show.exam-activity": false,
|
|
14
|
+
"show.chat-mode-chip": false,
|
|
15
|
+
// Capabilities (not in preview)
|
|
16
|
+
"allow.pdf-download": true
|
|
17
|
+
};
|
|
18
|
+
function isFeatureEnabled(flags, key) {
|
|
19
|
+
return flags?.[key] ?? FLAG_DEFAULTS[key];
|
|
9
20
|
}
|
|
10
21
|
|
|
11
22
|
// src/errors.ts
|
|
@@ -855,6 +866,7 @@ var ConfigUpdateSchema = object({
|
|
|
855
866
|
clipId: optional(string()),
|
|
856
867
|
clipPlayHead: optional(number()),
|
|
857
868
|
mode: optional(union([literal("inline"), literal("floating"), literal("sidebar")])),
|
|
869
|
+
chatMode: optional(union([literal("NORMAL"), literal("EXAM"), literal("STUDY")])),
|
|
858
870
|
allowLayoutToggle: optional(boolean()),
|
|
859
871
|
container: optional(
|
|
860
872
|
object({
|
|
@@ -922,6 +934,6 @@ var TapMessageSchema = union([
|
|
|
922
934
|
// src/tap-button.d.ts
|
|
923
935
|
var TAP_BUTTON_CLICK_EVENT = "tap-button:click";
|
|
924
936
|
|
|
925
|
-
export { ALARM_DURATION, AlarmClickSchema, AlarmElementPropsSchema, AlarmElementSchema, AlarmFadeInSchema, AlarmMessageInstanceSchema, CSSStyleSchema, ConfigRequestSchema, ConfigUpdateSchema, ContainerLayoutStateChangedSchema, ContainerModeChangeAckSchema, ContainerModeChangeSchema, GAEventSchema, HtmlViewCloseSchema, HtmlViewOpenSchema, TapKitInitializationError as InitializationError, MaterialViewCloseSchema, MaterialViewErrorSchema, MaterialViewOpenSchema, MaterialViewerError, PopUpCloseSchema, PopUpOpenSchema, TAP_BUTTON_CLICK_EVENT, TAP_ERROR_MARKER, TapCloseSchema, TapKitConfigurationError, TapKitError, TapKitIframeError, TapKitInitializationError, TapKitLoaderError, TapKitMessageError, TapMessageSchema, TapReadySchema, TimelineSeekSchema, TutorInfoSchema, ViewportResizeSchema, isFeatureEnabled };
|
|
937
|
+
export { ALARM_DURATION, AlarmClickSchema, AlarmElementPropsSchema, AlarmElementSchema, AlarmFadeInSchema, AlarmMessageInstanceSchema, CSSStyleSchema, ConfigRequestSchema, ConfigUpdateSchema, ContainerLayoutStateChangedSchema, ContainerModeChangeAckSchema, ContainerModeChangeSchema, FLAG_DEFAULTS, GAEventSchema, HtmlViewCloseSchema, HtmlViewOpenSchema, TapKitInitializationError as InitializationError, MaterialViewCloseSchema, MaterialViewErrorSchema, MaterialViewOpenSchema, MaterialViewerError, PopUpCloseSchema, PopUpOpenSchema, TAP_BUTTON_CLICK_EVENT, TAP_ERROR_MARKER, TapCloseSchema, TapKitConfigurationError, TapKitError, TapKitIframeError, TapKitInitializationError, TapKitLoaderError, TapKitMessageError, TapMessageSchema, TapReadySchema, TimelineSeekSchema, TutorInfoSchema, ViewportResizeSchema, isFeatureEnabled };
|
|
926
938
|
//# sourceMappingURL=index.js.map
|
|
927
939
|
//# sourceMappingURL=index.js.map
|