@m2c2kit/core 0.3.27 → 0.3.29
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/LICENSE +10 -18
- package/README.md +1 -1
- package/dist/index.d.ts +90 -5
- package/dist/index.js +437 -99
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +4 -3
- package/package.json +12 -13
package/LICENSE
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
Copyright 2023 Scott T. Yabiku
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @m2c2kit/core
|
|
2
2
|
|
|
3
|
-
[](https://opensource.org/license/apache-2-0)
|
|
4
4
|
[](https://github.com/m2c2-project/m2c2kit/actions/workflows/ci.yml)
|
|
5
5
|
[](https://www.npmjs.com/package/@m2c2kit/core)
|
|
6
6
|
|
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;
|
|
@@ -1792,7 +1846,9 @@ declare class Game implements Activity {
|
|
|
1792
1846
|
/**
|
|
1793
1847
|
* Adds a scene to the game.
|
|
1794
1848
|
*
|
|
1795
|
-
* @remarks A scene, and its children nodes, cannot be presented unless it
|
|
1849
|
+
* @remarks A scene, and its children nodes, cannot be presented unless it
|
|
1850
|
+
* has been added to the game object. A scene can be added to the game
|
|
1851
|
+
* only once.
|
|
1796
1852
|
*
|
|
1797
1853
|
* @param scene
|
|
1798
1854
|
*/
|
|
@@ -2111,6 +2167,8 @@ declare class Game implements Activity {
|
|
|
2111
2167
|
private htmlCanvasPointerUpHandler;
|
|
2112
2168
|
private htmlCanvasPointerMoveHandler;
|
|
2113
2169
|
private htmlCanvasPointerLeaveHandler;
|
|
2170
|
+
private documentKeyDownHandler;
|
|
2171
|
+
private documentKeyUpHandler;
|
|
2114
2172
|
/**
|
|
2115
2173
|
* Determines if/how m2c2kit nodes respond to the DOM PointerDown event
|
|
2116
2174
|
*
|
|
@@ -2428,6 +2486,8 @@ declare const M2EventType: {
|
|
|
2428
2486
|
readonly PointerUp: "PointerUp";
|
|
2429
2487
|
readonly PointerMove: "PointerMove";
|
|
2430
2488
|
readonly PointerLeave: "PointerLeave";
|
|
2489
|
+
readonly KeyDown: "KeyDown";
|
|
2490
|
+
readonly KeyUp: "KeyUp";
|
|
2431
2491
|
readonly Drag: "Drag";
|
|
2432
2492
|
readonly DragStart: "DragStart";
|
|
2433
2493
|
readonly DragEnd: "DragEnd";
|
|
@@ -3676,8 +3736,8 @@ declare class Constants {
|
|
|
3676
3736
|
/** Placeholder that will be populated during the build process. */
|
|
3677
3737
|
static readonly MODULE_METADATA_PLACEHOLDER: ModuleMetadata;
|
|
3678
3738
|
static readonly DEFAULT_ROOT_ELEMENT_ID = "m2c2kit";
|
|
3679
|
-
static readonly ERUDA_URL = "https://cdn.jsdelivr.net/npm/eruda@3.
|
|
3680
|
-
static readonly ERUDA_SRI = "sha384-
|
|
3739
|
+
static readonly ERUDA_URL = "https://cdn.jsdelivr.net/npm/eruda@3.4.1/eruda.js";
|
|
3740
|
+
static readonly ERUDA_SRI = "sha384-daS5bEfWdSq146t9c4BureB/fQWO3lHohseXBelPqKvbOUx2D6PE3TxcQ9jrKZDM";
|
|
3681
3741
|
}
|
|
3682
3742
|
|
|
3683
3743
|
/**
|
|
@@ -4137,6 +4197,8 @@ declare enum LabelHorizontalAlignmentMode {
|
|
|
4137
4197
|
}
|
|
4138
4198
|
|
|
4139
4199
|
interface LabelOptions extends M2NodeOptions, DrawableOptions, TextOptions {
|
|
4200
|
+
/** Text to be displayed. Tags for bold, italic, and underline are supported, e.g., `<b><u>Bold and underline</u></b>`. */
|
|
4201
|
+
text?: string;
|
|
4140
4202
|
/** Horizontal alignment of label text. see {@link LabelHorizontalAlignmentMode}. Default is LabelHorizontalAlignmentMode.center */
|
|
4141
4203
|
horizontalAlignmentMode?: LabelHorizontalAlignmentMode;
|
|
4142
4204
|
/** Maximum width of label text before wrapping occurs. Default is the canvas width */
|
|
@@ -4168,13 +4230,19 @@ declare class Label extends M2Node implements IDrawable, IText, LabelOptions {
|
|
|
4168
4230
|
private builder?;
|
|
4169
4231
|
private _fontPaint?;
|
|
4170
4232
|
private _backgroundPaint?;
|
|
4233
|
+
private _underlinePaint?;
|
|
4171
4234
|
private localizedFontSize;
|
|
4172
4235
|
private localizedFontName;
|
|
4173
4236
|
private localizedFontNames;
|
|
4237
|
+
private plainText;
|
|
4238
|
+
private styleSegments;
|
|
4239
|
+
private underlinedRanges;
|
|
4240
|
+
private currentBuilderPosition;
|
|
4174
4241
|
/**
|
|
4175
4242
|
* Single or multi-line text formatted and rendered on the screen.
|
|
4176
4243
|
*
|
|
4177
|
-
* @remarks Label (in contrast to TextLine) has enhanced text support for
|
|
4244
|
+
* @remarks Label (in contrast to TextLine) has enhanced text support for
|
|
4245
|
+
* line wrapping, centering/alignment, and background colors.
|
|
4178
4246
|
*
|
|
4179
4247
|
* @param options - {@link LabelOptions}
|
|
4180
4248
|
*/
|
|
@@ -4205,6 +4273,19 @@ declare class Label extends M2Node implements IDrawable, IText, LabelOptions {
|
|
|
4205
4273
|
suppressEvents?: boolean;
|
|
4206
4274
|
};
|
|
4207
4275
|
initialize(): void;
|
|
4276
|
+
/**
|
|
4277
|
+
* Parses text with formatting tags and returns plain text and style segments.
|
|
4278
|
+
* Supports <b> for bold, <i> for italics, and <u> for underline.
|
|
4279
|
+
* Properly handles nested tags like <b><u>bold and underlined</u></b>.
|
|
4280
|
+
* Throws errors for malformed tags, but treats unknown tags as plain text.
|
|
4281
|
+
*
|
|
4282
|
+
* @param text - The text with formatting tags
|
|
4283
|
+
* @returns The parsed text result
|
|
4284
|
+
* @throws Error if tags are improperly nested or unclosed
|
|
4285
|
+
*/
|
|
4286
|
+
private parseFormattedText;
|
|
4287
|
+
private addTextWithStylesToParagraphBuilder;
|
|
4288
|
+
private addTextWithStyle;
|
|
4208
4289
|
/**
|
|
4209
4290
|
* Determines the M2Font objects that need to be ready in order to draw
|
|
4210
4291
|
* the Label.
|
|
@@ -4245,6 +4326,8 @@ declare class Label extends M2Node implements IDrawable, IText, LabelOptions {
|
|
|
4245
4326
|
private set backgroundPaint(value);
|
|
4246
4327
|
private get fontPaint();
|
|
4247
4328
|
private set fontPaint(value);
|
|
4329
|
+
private get underlinePaint();
|
|
4330
|
+
private set underlinePaint(value);
|
|
4248
4331
|
/**
|
|
4249
4332
|
* Duplicates a node using deep copy.
|
|
4250
4333
|
*
|
|
@@ -4258,6 +4341,7 @@ declare class Label extends M2Node implements IDrawable, IText, LabelOptions {
|
|
|
4258
4341
|
duplicate(newName?: string): Label;
|
|
4259
4342
|
update(): void;
|
|
4260
4343
|
draw(canvas: Canvas): void;
|
|
4344
|
+
private drawUnderlines;
|
|
4261
4345
|
warmup(canvas: Canvas): void;
|
|
4262
4346
|
}
|
|
4263
4347
|
|
|
@@ -5283,4 +5367,5 @@ declare class WebGlInfo {
|
|
|
5283
5367
|
static dispose(): void;
|
|
5284
5368
|
}
|
|
5285
5369
|
|
|
5286
|
-
export { Action,
|
|
5370
|
+
export { Action, ActivityType, CanvasKitHelpers, ColorfulMutablePath, Composite, Constants, ConstraintType, CustomAction, Dimensions, Easings, Equal, Equals, EventStore, EventStoreMode, FadeAlphaAction, FontManager, Game, GroupAction, I18n, ImageManager, Label, LabelHorizontalAlignmentMode, LayoutConstraint, LegacyTimer, M2EventType, M2ImageStatus, M2Node, M2NodeFactory, M2NodeType, M2SoundStatus, M2c2KitHelpers, MoveAction, MutablePath, NoneTransition, PlayAction, RandomDraws, RepeatAction, RepeatForeverAction, RotateAction, ScaleAction, Scene, SceneTransition, SequenceAction, Shape, ShapeType, SlideTransition, SoundManager, SoundPlayer, SoundRecorder, Sprite, Story, TextLine, Timer, Transition, TransitionDirection, TransitionType, Uuid, WaitAction, WebColors, WebGlInfo, handleInterfaceOptions };
|
|
5371
|
+
export type { Activity, ActivityCallbacks, ActivityEvent, ActivityEventListener, ActivityKeyValueData, ActivityLifecycleEvent, ActivityResultsEvent, BrowserImage, BrowserImageDataReadyEvent, CallbackOptions, CompositeEvent, CompositeOptions, Constraints, CustomActionOptions, DefaultParameter, DomPointerDownEvent, DrawableOptions, EasingFunction, FadeAlphaActionOptions, FontAsset, FontData, GameData, GameEvent, GameOptions, GameParameters, GlobalVariables, I18nDataReadyEvent, IDataStore, IDrawable, IText, LabelOptions, Layout, LocaleSvg, M2ColorfulPath, M2DragEvent, M2Event, M2EventListener, M2Image, M2KeyboardEvent, M2NodeAddChildEvent, M2NodeConstructor, M2NodeEvent, M2NodeEventListener, M2NodeNewEvent, M2NodeOptions, M2NodePropertyChangeEvent, M2NodeRemoveChildEvent, M2Path, M2PointerEvent, M2Sound, MoveActionOptions, PlayActionOptions, Plugin, PluginEvent, Point, RectOptions, RgbaColor, ScaleActionOptions, SceneOptions, ScenePresentEvent, ScoringSchema, ShapeOptions, Size, SlideTransitionOptions, SoundAsset, SoundPlayerOptions, SoundRecorderOptions, SoundRecorderResults, SpriteOptions, StoryOptions, StringInterpolationMap, TapEvent, TextAndFont, TextLineOptions, TextLocalizationResult, TextOptions, TextWithFontCustomization, Translation, TranslationConfiguration, TranslationOptions, TrialData, TrialSchema, WaitActionOptions };
|