@coxwave/tap-kit-types 2.10.2 → 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 CHANGED
@@ -179,74 +179,36 @@ type ContainerConfig = {
179
179
  };
180
180
 
181
181
  /**
182
- * Feature Flags Type Definitions
183
- *
184
- * Extensible feature flag system using dot notation for namespacing.
185
- * Flags are optional booleans - undefined means "use default behavior".
186
- *
187
- * Naming convention: "domain.subdomain.feature"
188
- * Examples:
189
- * - "material.pdf.download" - PDF download in material viewer
190
- * - "quiz.enabled" - Quiz feature availability
191
- * - "chat.attachment" - File attachment in chat
192
- *
193
- * @example
194
- * const flags: FeatureFlags = {
195
- * "material.pdf.download": false, // Disable PDF download
196
- * };
197
- */
198
- /**
199
- * Known feature flag keys (for type safety and autocomplete)
200
- *
201
- * When adding new flags:
202
- * 1. Add the key to this union type
203
- * 2. Document the flag's purpose in JSDoc
204
- */
205
- type FeatureFlagKey =
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
- * Helper to check if a feature is enabled
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" | "featureFlags:update";
249
- type TapMessage = TapReadyMessage | TapCloseMessage | TimelineSeekMessage | AlarmClickMessage | AlarmFadeInMessage | PopUpOpenMessage | PopUpCloseMessage | MaterialViewOpenMessage | MaterialViewCloseMessage | MaterialViewErrorMessage | HtmlViewOpenMessage | HtmlViewCloseMessage | ContainerModeChangeMessage | ContainerModeChangeAckMessage | ContainerLayoutStateChangedMessage | ViewportResizeMessage | ConfigUpdateMessage | ConfigRequestMessage | GAEventMessage | TutorInfoMessage | FeatureFlagsUpdateMessage;
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., "material.pdf.download": false) */
257
+ /** Feature flags for viewer behavior (e.g., "allow.pdf-download": false) */
296
258
  flags?: FeatureFlags;
297
259
  nonce?: string | number;
298
260
  }
@@ -404,7 +366,7 @@ interface ConfigUpdateMessage {
404
366
  tapUrl?: string;
405
367
  apiUrl?: string;
406
368
  environment?: "dev" | "prod" | "demo" | "staging";
407
- language?: "ko" | "en" | (string & {});
369
+ language?: "ko" | "en" | "ja" | (string & {});
408
370
  userId?: string;
409
371
  courseId?: string;
410
372
  clipId?: string;
@@ -476,15 +438,6 @@ interface TutorInfoMessage {
476
438
  type: "tutor:info";
477
439
  tutorName: string;
478
440
  }
479
- /**
480
- * Feature Flags Update Message (iframe → parent)
481
- * Sent from edutap after tutor_setting API response with feature flags
482
- * Used to update feature flags store in tap-kit-core
483
- */
484
- interface FeatureFlagsUpdateMessage {
485
- type: "featureFlags:update";
486
- flags: FeatureFlags;
487
- }
488
441
 
489
442
  /**
490
443
  * Fallback type.
@@ -3375,7 +3328,7 @@ interface TapKitElement extends HTMLElement {
3375
3328
  clipPlayHead?: number;
3376
3329
 
3377
3330
  /** Language (optional, default: "ko") */
3378
- language?: "ko" | "en";
3331
+ language?: "ko" | "en" | "ja";
3379
3332
 
3380
3333
  /** TAP Frontend URL (optional, for testing) */
3381
3334
  tapUrl?: string;
@@ -3587,7 +3540,7 @@ interface TapKitAttributes {
3587
3540
  "clip-play-head"?: number;
3588
3541
 
3589
3542
  /** Language setting */
3590
- language?: "ko" | "en";
3543
+ language?: "ko" | "en" | "ja";
3591
3544
 
3592
3545
  /** TAP Frontend URL (for testing) */
3593
3546
  "tap-url"?: string;
@@ -3738,7 +3691,7 @@ interface MaterialViewConfig {
3738
3691
 
3739
3692
  /**
3740
3693
  * Feature flags for viewer behavior
3741
- * @example { "material.pdf.download": false } // Disable download button
3694
+ * @example { "allow.pdf-download": false } // Disable download button
3742
3695
  */
3743
3696
  flags?: FeatureFlags;
3744
3697
  }
@@ -3921,7 +3874,7 @@ declare global {
3921
3874
  courseId?: string;
3922
3875
  clipId?: string;
3923
3876
  clipPlayHead?: number;
3924
- language?: "ko" | "en";
3877
+ language?: "ko" | "en" | "ja";
3925
3878
  buttonId?: string;
3926
3879
  mode?: "inline" | "floating" | "sidebar";
3927
3880
  chatMode?: "NORMAL" | "EXAM" | "STUDY";
@@ -3950,4 +3903,4 @@ declare global {
3950
3903
  function cancelIdleCallback(handle: number): void;
3951
3904
  }
3952
3905
 
3953
- 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, type FeatureFlagKey, type FeatureFlags, type FeatureFlagsUpdateMessage, 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 };
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
- function isFeatureEnabled(flags, key, defaultValue = true) {
7
- if (!flags) return defaultValue;
8
- return flags[key] ?? defaultValue;
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
@@ -923,6 +934,6 @@ var TapMessageSchema = union([
923
934
  // src/tap-button.d.ts
924
935
  var TAP_BUTTON_CLICK_EVENT = "tap-button:click";
925
936
 
926
- 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 };
927
938
  //# sourceMappingURL=index.js.map
928
939
  //# sourceMappingURL=index.js.map