@m2c2kit/core 0.3.23 → 0.3.24
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 +23 -3
- package/dist/index.js +15 -7
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -220,10 +220,12 @@ type JsonSchemaDataTypeScriptTypes = string | number | object | boolean | null |
|
|
|
220
220
|
* All the data created by an activity.
|
|
221
221
|
*/
|
|
222
222
|
interface ActivityResults {
|
|
223
|
-
/** All the data created by the activity. */
|
|
223
|
+
/** All the data of the specified data type created thus far by the activity. */
|
|
224
224
|
data: ActivityKeyValueData;
|
|
225
225
|
/** JSON schema describing the structure of the data. */
|
|
226
226
|
dataSchema: JsonSchema;
|
|
227
|
+
/** Type of data. */
|
|
228
|
+
dataType: "Trial" | "Scoring" | "Survey";
|
|
227
229
|
/** Parameters under which the activity was run. */
|
|
228
230
|
activityConfiguration: unknown;
|
|
229
231
|
/** JSON schema describing the activity parameters. */
|
|
@@ -733,7 +735,8 @@ interface SoundAsset {
|
|
|
733
735
|
* `OK_BUTTON` uses the game's default font for all locales. Because hi-IN
|
|
734
736
|
* specified a font name, the `overrideFontName` property with a value of
|
|
735
737
|
* `default` is used to specify that the game's default font should be used
|
|
736
|
-
* instead of the locale's font, devanagari.
|
|
738
|
+
* instead of the locale's font, devanagari. In addition, hi-IN specifies a
|
|
739
|
+
* different font size for the `OK_BUTTON` text.
|
|
737
740
|
*
|
|
738
741
|
* `BYE` uses interpolation. `{{name}}` is a placeholder that will be replaced,
|
|
739
742
|
* at runtime, with the value of the `name` key in the `options` object passed
|
|
@@ -784,6 +787,7 @@ interface SoundAsset {
|
|
|
784
787
|
* },
|
|
785
788
|
* "OK_BUTTON": {
|
|
786
789
|
* text: "OK",
|
|
790
|
+
* fontSize: 12,
|
|
787
791
|
* overrideFontName: "default"
|
|
788
792
|
* },
|
|
789
793
|
* "BYE": "अलविदा {{name}}."
|
|
@@ -843,6 +847,8 @@ type LocaleTranslationMap = {
|
|
|
843
847
|
interface TextWithFontCustomization {
|
|
844
848
|
/** The translated string. */
|
|
845
849
|
text: string;
|
|
850
|
+
/** Font size to use when displaying the text. */
|
|
851
|
+
fontSize?: number;
|
|
846
852
|
/** Font name(s) to _add to_ the locale's font name(s) when displaying text. */
|
|
847
853
|
additionalFontName?: string | Array<string>;
|
|
848
854
|
/** Font name(s) to use _in place of_ the locale's font name(s) when
|
|
@@ -853,6 +859,8 @@ interface TextWithFontCustomization {
|
|
|
853
859
|
interface TextAndFont {
|
|
854
860
|
/** The translated string. */
|
|
855
861
|
text?: string;
|
|
862
|
+
/** Font size to use when displaying the text. */
|
|
863
|
+
fontSize?: number;
|
|
856
864
|
/** Font name to use when displaying the text. */
|
|
857
865
|
fontName?: string;
|
|
858
866
|
/** Font names to use when displaying the text. */
|
|
@@ -2200,6 +2208,7 @@ interface TranslationOptions {
|
|
|
2200
2208
|
}
|
|
2201
2209
|
interface TextLocalizationResult {
|
|
2202
2210
|
text: string;
|
|
2211
|
+
fontSize?: number;
|
|
2203
2212
|
fontName?: string;
|
|
2204
2213
|
fontNames?: string[];
|
|
2205
2214
|
isFallbackOrMissingTranslation: boolean;
|
|
@@ -4158,6 +4167,7 @@ declare class Label extends M2Node implements IDrawable, IText, LabelOptions {
|
|
|
4158
4167
|
private builder?;
|
|
4159
4168
|
private _fontPaint?;
|
|
4160
4169
|
private _backgroundPaint?;
|
|
4170
|
+
private localizedFontSize;
|
|
4161
4171
|
private localizedFontName;
|
|
4162
4172
|
private localizedFontNames;
|
|
4163
4173
|
/**
|
|
@@ -4440,6 +4450,15 @@ declare class RandomDraws {
|
|
|
4440
4450
|
}>;
|
|
4441
4451
|
}
|
|
4442
4452
|
|
|
4453
|
+
/**
|
|
4454
|
+
* ScoringSchema defines the data that are generated by the scoring code. They
|
|
4455
|
+
* are key-value pairs in which the key is the variable name, and the value is
|
|
4456
|
+
* JSON Schema that defines the type of the variable.
|
|
4457
|
+
*/
|
|
4458
|
+
interface ScoringSchema {
|
|
4459
|
+
[key: string]: JsonSchema;
|
|
4460
|
+
}
|
|
4461
|
+
|
|
4443
4462
|
declare enum ShapeType {
|
|
4444
4463
|
Undefined = "Undefined",
|
|
4445
4464
|
Rectangle = "Rectangle",
|
|
@@ -4828,6 +4847,7 @@ declare class TextLine extends M2Node implements IDrawable, IText, TextLineOptio
|
|
|
4828
4847
|
private tryMissingTranslationPaint;
|
|
4829
4848
|
private textForDraw;
|
|
4830
4849
|
private fontForDraw?;
|
|
4850
|
+
private localizedFontSize;
|
|
4831
4851
|
private localizedFontName;
|
|
4832
4852
|
private localizedFontNames;
|
|
4833
4853
|
/**
|
|
@@ -5192,4 +5212,4 @@ declare class WebGlInfo {
|
|
|
5192
5212
|
static dispose(): void;
|
|
5193
5213
|
}
|
|
5194
5214
|
|
|
5195
|
-
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, 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 };
|
|
5215
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -4562,6 +4562,7 @@ class I18n {
|
|
|
4562
4562
|
}
|
|
4563
4563
|
return {
|
|
4564
4564
|
text: localizedText,
|
|
4565
|
+
fontSize: tf?.fontSize,
|
|
4565
4566
|
fontName: tf?.fontName,
|
|
4566
4567
|
fontNames: tf?.fontNames,
|
|
4567
4568
|
isFallbackOrMissingTranslation
|
|
@@ -4667,6 +4668,7 @@ class I18n {
|
|
|
4667
4668
|
return t;
|
|
4668
4669
|
}
|
|
4669
4670
|
getKeyTextAndFont(t, locale) {
|
|
4671
|
+
let fontSize = void 0;
|
|
4670
4672
|
let fontNames = new Array();
|
|
4671
4673
|
if (this.isString(this.translation[locale]?.fontName)) {
|
|
4672
4674
|
fontNames.push(this.translation[locale].fontName);
|
|
@@ -4678,6 +4680,7 @@ class I18n {
|
|
|
4678
4680
|
let text;
|
|
4679
4681
|
if (this.isTextWithFontCustomization(t)) {
|
|
4680
4682
|
text = t.text;
|
|
4683
|
+
fontSize = t.fontSize;
|
|
4681
4684
|
if (this.isString(t.additionalFontName)) {
|
|
4682
4685
|
fontNames.push(t.additionalFontName);
|
|
4683
4686
|
}
|
|
@@ -4699,11 +4702,11 @@ class I18n {
|
|
|
4699
4702
|
fontNames = fontNames.filter((f) => f !== "default");
|
|
4700
4703
|
switch (fontNames.length) {
|
|
4701
4704
|
case 0:
|
|
4702
|
-
return { text };
|
|
4705
|
+
return { text, fontSize };
|
|
4703
4706
|
case 1:
|
|
4704
|
-
return { text, fontName: fontNames[0] };
|
|
4707
|
+
return { text, fontSize, fontName: fontNames[0] };
|
|
4705
4708
|
default:
|
|
4706
|
-
return { text, fontNames };
|
|
4709
|
+
return { text, fontSize, fontNames };
|
|
4707
4710
|
}
|
|
4708
4711
|
}
|
|
4709
4712
|
insertInterpolations(text, options) {
|
|
@@ -5060,6 +5063,7 @@ class Label extends M2Node {
|
|
|
5060
5063
|
this.interpolation
|
|
5061
5064
|
);
|
|
5062
5065
|
textForParagraph = textLocalization.text;
|
|
5066
|
+
this.localizedFontSize = textLocalization.fontSize;
|
|
5063
5067
|
this.localizedFontName = textLocalization.fontName;
|
|
5064
5068
|
this.localizedFontNames = textLocalization.fontNames ?? [];
|
|
5065
5069
|
if (textLocalization.isFallbackOrMissingTranslation && i18n.missingLocalizationColor) {
|
|
@@ -5115,7 +5119,7 @@ class Label extends M2Node {
|
|
|
5115
5119
|
this.builder.pushPaintStyle(
|
|
5116
5120
|
{
|
|
5117
5121
|
fontFamilies: requiredFonts.map((font) => font.fontName),
|
|
5118
|
-
fontSize: this.fontSize * m2c2Globals.canvasScale,
|
|
5122
|
+
fontSize: (this.localizedFontSize ?? this.fontSize) * m2c2Globals.canvasScale,
|
|
5119
5123
|
// set default values for below properties as well.
|
|
5120
5124
|
fontStyle: {
|
|
5121
5125
|
weight: this.canvasKit.FontWeight.Normal,
|
|
@@ -6440,7 +6444,7 @@ class TextLine extends M2Node {
|
|
|
6440
6444
|
this.textForDraw = "";
|
|
6441
6445
|
this.localizedFontNames = [];
|
|
6442
6446
|
handleInterfaceOptions(this, options);
|
|
6443
|
-
this.size.height = this.fontSize;
|
|
6447
|
+
this.size.height = this.localizedFontSize ?? this.fontSize;
|
|
6444
6448
|
this.size.width = options.width ?? NaN;
|
|
6445
6449
|
this.saveNodeNewEvent();
|
|
6446
6450
|
}
|
|
@@ -6462,6 +6466,7 @@ class TextLine extends M2Node {
|
|
|
6462
6466
|
this.interpolation
|
|
6463
6467
|
);
|
|
6464
6468
|
this.textForDraw = textLocalization.text;
|
|
6469
|
+
this.localizedFontSize = textLocalization.fontSize;
|
|
6465
6470
|
this.localizedFontName = textLocalization.fontName;
|
|
6466
6471
|
this.localizedFontNames = textLocalization.fontNames ?? [];
|
|
6467
6472
|
if (textLocalization.isFallbackOrMissingTranslation) {
|
|
@@ -6554,7 +6559,7 @@ class TextLine extends M2Node {
|
|
|
6554
6559
|
}
|
|
6555
6560
|
this.font = new this.canvasKit.Font(
|
|
6556
6561
|
this.typeface,
|
|
6557
|
-
this.fontSize * m2c2Globals.canvasScale
|
|
6562
|
+
(this.localizedFontSize ?? this.fontSize) * m2c2Globals.canvasScale
|
|
6558
6563
|
);
|
|
6559
6564
|
}
|
|
6560
6565
|
get text() {
|
|
@@ -9992,6 +9997,7 @@ class Game {
|
|
|
9992
9997
|
/** data is all the data collected so far in the game */
|
|
9993
9998
|
data: this.data,
|
|
9994
9999
|
dataSchema: this.makeGameDataSchema(),
|
|
10000
|
+
dataType: "Trial",
|
|
9995
10001
|
activityConfiguration: this.makeGameActivityConfiguration(
|
|
9996
10002
|
this.options.parameters ?? {}
|
|
9997
10003
|
),
|
|
@@ -10123,6 +10129,7 @@ class Game {
|
|
|
10123
10129
|
const results = {
|
|
10124
10130
|
data: this.data,
|
|
10125
10131
|
dataSchema: this.makeGameDataSchema(),
|
|
10132
|
+
dataType: "Trial",
|
|
10126
10133
|
activityConfiguration: this.makeGameActivityConfiguration(
|
|
10127
10134
|
this.options.parameters ?? {}
|
|
10128
10135
|
),
|
|
@@ -10152,6 +10159,7 @@ class Game {
|
|
|
10152
10159
|
const results = {
|
|
10153
10160
|
data: this.data,
|
|
10154
10161
|
dataSchema: this.makeGameDataSchema(),
|
|
10162
|
+
dataType: "Trial",
|
|
10155
10163
|
activityConfiguration: this.makeGameActivityConfiguration(
|
|
10156
10164
|
this.options.parameters ?? {}
|
|
10157
10165
|
),
|
|
@@ -12037,7 +12045,7 @@ class Story {
|
|
|
12037
12045
|
}
|
|
12038
12046
|
}
|
|
12039
12047
|
|
|
12040
|
-
console.log("\u26AA @m2c2kit/core version 0.3.
|
|
12048
|
+
console.log("\u26AA @m2c2kit/core version 0.3.24 (63d6720d)");
|
|
12041
12049
|
|
|
12042
12050
|
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 };
|
|
12043
12051
|
//# sourceMappingURL=index.js.map
|