@m2c2kit/core 0.3.27 → 0.3.28

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
@@ -403,6 +403,32 @@ interface SceneOptions extends M2NodeOptions, DrawableOptions {
403
403
  backgroundColor?: RgbaColor;
404
404
  }
405
405
 
406
+ /**
407
+ * Describes an event on the device's built-in keyboard.
408
+ *
409
+ * @remarks The built-in keyboard is defined as the hardware keyboard on a
410
+ * desktop/laptop or the built-in soft keyboard on a tablet or phone. The
411
+ * latter is not used in m2c2kit. On tablet or phone, the `VirtualKeyboard`
412
+ * in the `@m2c2kit/addons` package should be used for key events.
413
+ * @remarks Key events can occur only on a `Scene` node.
414
+ */
415
+ interface M2KeyboardEvent extends M2NodeEvent {
416
+ /** String that is generated when key is pressed, with any modifiers (e.g., Shift) applied. */
417
+ key: string;
418
+ /** Code for the key, not taking into account any modifiers. */
419
+ code: string;
420
+ /** True if the Shift key is pressed. */
421
+ shiftKey: boolean;
422
+ /** True if the Control key is pressed. */
423
+ ctrlKey: boolean;
424
+ /** True if the Alt key is pressed. */
425
+ altKey: boolean;
426
+ /** True if the Meta key is pressed. */
427
+ metaKey: boolean;
428
+ /** True if the event is being repeated. */
429
+ repeat: boolean;
430
+ }
431
+
406
432
  declare class Scene extends M2Node implements IDrawable, SceneOptions {
407
433
  readonly type = M2NodeType.Scene;
408
434
  isDrawable: boolean;
@@ -485,6 +511,34 @@ declare class Scene extends M2Node implements IDrawable, SceneOptions {
485
511
  * @param options - {@link CallbackOptions}
486
512
  */
487
513
  onAppear(callback: (nodeEvent: M2NodeEvent) => void, options?: CallbackOptions): void;
514
+ /**
515
+ * Code that will be called after a key is pressed on the device's
516
+ * built-in keyboard.
517
+ *
518
+ * @remarks The built-in keyboard is defined as the hardware keyboard on a
519
+ * desktop/laptop or the built-in soft keyboard on a tablet or phone. The
520
+ * latter is not used in m2c2kit. On tablet or phone, the `VirtualKeyboard`
521
+ * in the `@m2c2kit/addons` package should be used for key events.
522
+ * @remarks Key events can occur only on a `Scene` node.
523
+ *
524
+ * @param callback - function to execute
525
+ * @param options - {@link CallbackOptions}
526
+ */
527
+ onKeyDown(callback: (m2KeyboardEvent: M2KeyboardEvent) => void, options?: CallbackOptions): void;
528
+ /**
529
+ * Code that will be called after a key is released on the device's
530
+ * built-in keyboard.
531
+ *
532
+ * @remarks The built-in keyboard is defined as the hardware keyboard on a
533
+ * desktop/laptop or the built-in soft keyboard on a tablet or phone. The
534
+ * latter is not used in m2c2kit. On tablet or phone, the `VirtualKeyboard`
535
+ * in the `@m2c2kit/addons` package should be used for key events.
536
+ * @remarks Key events can occur only on a `Scene` node.
537
+ *
538
+ * @param callback - function to execute
539
+ * @param options - {@link CallbackOptions}
540
+ */
541
+ onKeyUp(callback: (m2KeyboardEvent: M2KeyboardEvent) => void, options?: CallbackOptions): void;
488
542
  update(): void;
489
543
  draw(canvas: Canvas): void;
490
544
  warmup(canvas: Canvas): void;
@@ -2111,6 +2165,8 @@ declare class Game implements Activity {
2111
2165
  private htmlCanvasPointerUpHandler;
2112
2166
  private htmlCanvasPointerMoveHandler;
2113
2167
  private htmlCanvasPointerLeaveHandler;
2168
+ private documentKeyDownHandler;
2169
+ private documentKeyUpHandler;
2114
2170
  /**
2115
2171
  * Determines if/how m2c2kit nodes respond to the DOM PointerDown event
2116
2172
  *
@@ -2428,6 +2484,8 @@ declare const M2EventType: {
2428
2484
  readonly PointerUp: "PointerUp";
2429
2485
  readonly PointerMove: "PointerMove";
2430
2486
  readonly PointerLeave: "PointerLeave";
2487
+ readonly KeyDown: "KeyDown";
2488
+ readonly KeyUp: "KeyUp";
2431
2489
  readonly Drag: "Drag";
2432
2490
  readonly DragStart: "DragStart";
2433
2491
  readonly DragEnd: "DragEnd";
@@ -3676,8 +3734,8 @@ declare class Constants {
3676
3734
  /** Placeholder that will be populated during the build process. */
3677
3735
  static readonly MODULE_METADATA_PLACEHOLDER: ModuleMetadata;
3678
3736
  static readonly DEFAULT_ROOT_ELEMENT_ID = "m2c2kit";
3679
- static readonly ERUDA_URL = "https://cdn.jsdelivr.net/npm/eruda@3.2.3/eruda.js";
3680
- static readonly ERUDA_SRI = "sha384-KlRzgy/c+nZSV+eiFqoTkkbZ5pUqToho7HsNuebTbOsYTh4m0m/PAqkGsTMLXK14";
3737
+ static readonly ERUDA_URL = "https://cdn.jsdelivr.net/npm/eruda@3.4.1/eruda.js";
3738
+ static readonly ERUDA_SRI = "sha384-daS5bEfWdSq146t9c4BureB/fQWO3lHohseXBelPqKvbOUx2D6PE3TxcQ9jrKZDM";
3681
3739
  }
3682
3740
 
3683
3741
  /**
@@ -5283,4 +5341,4 @@ declare class WebGlInfo {
5283
5341
  static dispose(): void;
5284
5342
  }
5285
5343
 
5286
- export { Action, type Activity, type ActivityCallbacks, type ActivityEvent, type ActivityEventListener, type ActivityKeyValueData, type ActivityLifecycleEvent, type ActivityResultsEvent, ActivityType, type BrowserImage, type BrowserImageDataReadyEvent, type CallbackOptions, CanvasKitHelpers, ColorfulMutablePath, Composite, type CompositeEvent, type CompositeOptions, Constants, ConstraintType, type Constraints, CustomAction, type CustomActionOptions, type DefaultParameter, Dimensions, type DomPointerDownEvent, type DrawableOptions, type EasingFunction, Easings, Equal, Equals, EventStore, EventStoreMode, FadeAlphaAction, type FadeAlphaActionOptions, type FontAsset, type FontData, FontManager, Game, type GameData, type GameEvent, type GameOptions, type GameParameters, type GlobalVariables, GroupAction, I18n, type I18nDataReadyEvent, type IDataStore, type IDrawable, type IText, ImageManager, Label, LabelHorizontalAlignmentMode, type LabelOptions, type Layout, LayoutConstraint, LegacyTimer, type LocaleSvg, type M2ColorfulPath, type M2DragEvent, type M2Event, type M2EventListener, M2EventType, type M2Image, M2ImageStatus, M2Node, type M2NodeAddChildEvent, type M2NodeConstructor, type M2NodeEvent, type M2NodeEventListener, M2NodeFactory, type M2NodeNewEvent, type M2NodeOptions, type M2NodePropertyChangeEvent, type M2NodeRemoveChildEvent, M2NodeType, type M2Path, type M2PointerEvent, type M2Sound, M2SoundStatus, M2c2KitHelpers, MoveAction, type MoveActionOptions, MutablePath, NoneTransition, PlayAction, type PlayActionOptions, type Plugin, type PluginEvent, type Point, RandomDraws, type RectOptions, RepeatAction, RepeatForeverAction, type RgbaColor, RotateAction, ScaleAction, type ScaleActionOptions, Scene, type SceneOptions, type ScenePresentEvent, SceneTransition, type ScoringSchema, SequenceAction, Shape, type ShapeOptions, ShapeType, type Size, SlideTransition, type SlideTransitionOptions, type SoundAsset, SoundManager, SoundPlayer, type SoundPlayerOptions, SoundRecorder, type SoundRecorderOptions, type SoundRecorderResults, Sprite, type SpriteOptions, Story, type StoryOptions, type StringInterpolationMap, type TapEvent, type TextAndFont, TextLine, type TextLineOptions, type TextLocalizationResult, type TextOptions, type TextWithFontCustomization, Timer, Transition, TransitionDirection, TransitionType, type Translation, type TranslationConfiguration, type TranslationOptions, type TrialData, type TrialSchema, Uuid, WaitAction, type WaitActionOptions, WebColors, WebGlInfo, handleInterfaceOptions };
5344
+ export { Action, type Activity, type ActivityCallbacks, type ActivityEvent, type ActivityEventListener, type ActivityKeyValueData, type ActivityLifecycleEvent, type ActivityResultsEvent, ActivityType, type BrowserImage, type BrowserImageDataReadyEvent, type CallbackOptions, CanvasKitHelpers, ColorfulMutablePath, Composite, type CompositeEvent, type CompositeOptions, Constants, ConstraintType, type Constraints, CustomAction, type CustomActionOptions, type DefaultParameter, Dimensions, type DomPointerDownEvent, type DrawableOptions, type EasingFunction, Easings, Equal, Equals, EventStore, EventStoreMode, FadeAlphaAction, type FadeAlphaActionOptions, type FontAsset, type FontData, FontManager, Game, type GameData, type GameEvent, type GameOptions, type GameParameters, type GlobalVariables, GroupAction, I18n, type I18nDataReadyEvent, type IDataStore, type IDrawable, type IText, ImageManager, Label, LabelHorizontalAlignmentMode, type LabelOptions, type Layout, LayoutConstraint, LegacyTimer, type LocaleSvg, type M2ColorfulPath, type M2DragEvent, type M2Event, type M2EventListener, M2EventType, type M2Image, M2ImageStatus, type M2KeyboardEvent, M2Node, type M2NodeAddChildEvent, type M2NodeConstructor, type M2NodeEvent, type M2NodeEventListener, M2NodeFactory, type M2NodeNewEvent, type M2NodeOptions, type M2NodePropertyChangeEvent, type M2NodeRemoveChildEvent, M2NodeType, type M2Path, type M2PointerEvent, type M2Sound, M2SoundStatus, M2c2KitHelpers, MoveAction, type MoveActionOptions, MutablePath, NoneTransition, PlayAction, type PlayActionOptions, type Plugin, type PluginEvent, type Point, RandomDraws, type RectOptions, RepeatAction, RepeatForeverAction, type RgbaColor, RotateAction, ScaleAction, type ScaleActionOptions, Scene, type SceneOptions, type ScenePresentEvent, SceneTransition, type ScoringSchema, SequenceAction, Shape, type ShapeOptions, ShapeType, type Size, SlideTransition, type SlideTransitionOptions, type SoundAsset, SoundManager, SoundPlayer, type SoundPlayerOptions, SoundRecorder, type SoundRecorderOptions, type SoundRecorderResults, Sprite, type SpriteOptions, Story, type StoryOptions, type StringInterpolationMap, type TapEvent, type TextAndFont, TextLine, type TextLineOptions, type TextLocalizationResult, type TextOptions, type TextWithFontCustomization, Timer, Transition, TransitionDirection, TransitionType, type Translation, type TranslationConfiguration, type TranslationOptions, type TrialData, type TrialSchema, Uuid, WaitAction, type WaitActionOptions, WebColors, WebGlInfo, handleInterfaceOptions };