@coxwave/tap-kit-types 2.1.1 → 2.6.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.
package/dist/index.d.ts CHANGED
@@ -178,6 +178,58 @@ type ContainerConfig = {
178
178
  sidebarConfig?: SidebarConfig;
179
179
  };
180
180
 
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
+ * Feature flags object type
213
+ *
214
+ * All flags are optional - undefined means "use default behavior"
215
+ * false = explicitly disabled
216
+ * true = explicitly enabled
217
+ */
218
+ type FeatureFlags = Partial<Record<FeatureFlagKey, boolean>>;
219
+ /**
220
+ * Helper to check if a feature is enabled
221
+ *
222
+ * @param flags - Feature flags object
223
+ * @param key - Feature flag key to check
224
+ * @param defaultValue - Default value if flag is undefined (default: true)
225
+ * @returns Whether the feature is enabled
226
+ *
227
+ * @example
228
+ * const canDownload = isFeatureEnabled(flags, "material.pdf.download"); // default true
229
+ * const quizEnabled = isFeatureEnabled(flags, "quiz.enabled", false); // default false
230
+ */
231
+ declare function isFeatureEnabled(flags: FeatureFlags | undefined, key: FeatureFlagKey, defaultValue?: boolean): boolean;
232
+
181
233
  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";
182
234
  type TapMessage = TapReadyMessage | TapCloseMessage | TimelineSeekMessage | AlarmClickMessage | AlarmFadeInMessage | PopUpOpenMessage | PopUpCloseMessage | MaterialViewOpenMessage | MaterialViewCloseMessage | MaterialViewErrorMessage | HtmlViewOpenMessage | HtmlViewCloseMessage | ContainerModeChangeMessage | ContainerModeChangeAckMessage | ContainerLayoutStateChangedMessage | ViewportResizeMessage | ConfigUpdateMessage | ConfigRequestMessage | GAEventMessage | TutorInfoMessage;
183
235
  interface TapReadyMessage {
@@ -223,6 +275,10 @@ interface MaterialViewOpenMessage {
223
275
  pageStart: number;
224
276
  pageEnd: number;
225
277
  title?: string;
278
+ /** Text phrases to highlight in PDF (from reference_string parsing) */
279
+ highlightPhrases?: string[];
280
+ /** Feature flags for viewer behavior (e.g., "material.pdf.download": false) */
281
+ flags?: FeatureFlags;
226
282
  nonce?: string | number;
227
283
  }
228
284
  /**
@@ -367,6 +423,8 @@ interface ConfigUpdateMessage {
367
423
  minViewportWidth?: number;
368
424
  };
369
425
  };
426
+ /** SDK source for deprecation tracking (temporary - remove after monitoring period) */
427
+ sdkSource?: "tap-kit" | "tap-sdk";
370
428
  }
371
429
  /**
372
430
  * Config Request Message (iframe → parent, call/handle pattern)
@@ -2226,6 +2284,7 @@ declare const ConfigUpdateSchema: ObjectSchema<{
2226
2284
  readonly minViewportWidth: OptionalSchema<NumberSchema<undefined>, undefined>;
2227
2285
  }, undefined>, undefined>;
2228
2286
  }, undefined>, undefined>;
2287
+ readonly sdkSource: OptionalSchema<UnionSchema<[LiteralSchema<"tap-kit", undefined>, LiteralSchema<"tap-sdk", undefined>], undefined>, undefined>;
2229
2288
  }, undefined>;
2230
2289
  declare const ConfigRequestSchema: ObjectSchema<{
2231
2290
  readonly type: LiteralSchema<"config:request", undefined>;
@@ -2336,6 +2395,7 @@ declare const TapMessageSchema: UnionSchema<[ObjectSchema<{
2336
2395
  readonly minViewportWidth: OptionalSchema<NumberSchema<undefined>, undefined>;
2337
2396
  }, undefined>, undefined>;
2338
2397
  }, undefined>, undefined>;
2398
+ readonly sdkSource: OptionalSchema<UnionSchema<[LiteralSchema<"tap-kit", undefined>, LiteralSchema<"tap-sdk", undefined>], undefined>, undefined>;
2339
2399
  }, undefined>, ObjectSchema<{
2340
2400
  readonly type: LiteralSchema<"config:request", undefined>;
2341
2401
  readonly nonce: OptionalSchema<UnionSchema<[StringSchema<undefined>, NumberSchema<undefined>], undefined>, undefined>;
@@ -3655,6 +3715,12 @@ interface MaterialViewConfig {
3655
3715
  * Optional title for the viewer header
3656
3716
  */
3657
3717
  title?: string;
3718
+
3719
+ /**
3720
+ * Feature flags for viewer behavior
3721
+ * @example { "material.pdf.download": false } // Disable download button
3722
+ */
3723
+ flags?: FeatureFlags;
3658
3724
  }
3659
3725
 
3660
3726
  /**
@@ -3866,4 +3932,4 @@ declare global {
3866
3932
  function cancelIdleCallback(handle: number): void;
3867
3933
  }
3868
3934
 
3869
- 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 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 };
3935
+ 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 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
@@ -2,6 +2,12 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
 
5
+ // src/feature-flags.ts
6
+ function isFeatureEnabled(flags, key, defaultValue = true) {
7
+ if (!flags) return defaultValue;
8
+ return flags[key] ?? defaultValue;
9
+ }
10
+
5
11
  // src/errors.ts
6
12
  var TAP_ERROR_MARKER = "__tap_sdk_error__";
7
13
  var TapKitError = class _TapKitError extends Error {
@@ -878,7 +884,8 @@ var ConfigUpdateSchema = object({
878
884
  })
879
885
  )
880
886
  })
881
- )
887
+ ),
888
+ sdkSource: optional(union([literal("tap-kit"), literal("tap-sdk")]))
882
889
  });
883
890
  var ConfigRequestSchema = object({
884
891
  type: literal("config:request"),
@@ -919,6 +926,6 @@ var TapMessageSchema = union([
919
926
  // src/tap-button.d.ts
920
927
  var TAP_BUTTON_CLICK_EVENT = "tap-button:click";
921
928
 
922
- 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 };
929
+ 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 };
923
930
  //# sourceMappingURL=index.js.map
924
931
  //# sourceMappingURL=index.js.map