@m2c2kit/core 0.3.9 → 0.3.11
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 +21 -0
- package/README.md +18 -1
- package/assets/canvaskit.wasm +0 -0
- package/dist/index.d.ts +78 -46
- package/dist/index.js +771 -464
- package/package.json +18 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Scott T. Yabiku
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
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:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @m2c2kit/core
|
|
2
2
|
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://github.com/m2c2-project/m2c2kit/actions/workflows/ci.yml)
|
|
5
|
+
[](https://www.npmjs.com/package/@m2c2kit/core)
|
|
6
|
+
|
|
3
7
|
This package implements the m2c2kit core functionality.
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
**m2c2kit** is a library for cross-platform cognitive assessments. Features:
|
|
10
|
+
|
|
11
|
+
- **Mobile first**. Optimized for touch and mobile devices while also usable on desktops.
|
|
12
|
+
- **Portable**. Use on browsers, compile within native apps using web views, or embed in products like Qualtrics. A shared assessment codebase reduces development time and promotes experiment standardization across devices and services.
|
|
13
|
+
- **Rapid iteration**. Quickly develop and test new assessments with the JavaScript-based library and deploy them in studies.
|
|
14
|
+
|
|
15
|
+
## Resources
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
- [Website](https://m2c2-project.github.io/m2c2kit/)
|
|
20
|
+
- [Live Examples](https://m2c2-project.github.io/m2c2kit/docs/category/examples)
|
|
21
|
+
- [Getting Started](https://m2c2-project.github.io/m2c2kit/docs/getting-started)
|
|
22
|
+
- [Interactive Tutorials](https://m2c2-project.github.io/m2c2kit/docs/category/tutorials)
|
package/assets/canvaskit.wasm
CHANGED
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -720,6 +720,15 @@ interface CallbackOptions {
|
|
|
720
720
|
key?: string;
|
|
721
721
|
}
|
|
722
722
|
|
|
723
|
+
/**
|
|
724
|
+
* Notifies when events in the Frame cycle occur on a Game.
|
|
725
|
+
*/
|
|
726
|
+
interface FrameCycleEvent extends EventBase {
|
|
727
|
+
target: Game;
|
|
728
|
+
/** difference in milliseconds since the last Frame lifecycle began */
|
|
729
|
+
deltaTime: number;
|
|
730
|
+
}
|
|
731
|
+
|
|
723
732
|
interface TrialData {
|
|
724
733
|
[key: string]: string | number | boolean | object | undefined | null;
|
|
725
734
|
}
|
|
@@ -742,7 +751,7 @@ declare class Game implements Activity {
|
|
|
742
751
|
i18n?: I18n;
|
|
743
752
|
private warmupFunctionQueue;
|
|
744
753
|
private loaderElementsRemoved;
|
|
745
|
-
private
|
|
754
|
+
private _dataStores?;
|
|
746
755
|
additionalParameters?: unknown;
|
|
747
756
|
staticTrialSchema: {
|
|
748
757
|
[key: string]: JsonSchemaDataTypeScriptTypes;
|
|
@@ -760,12 +769,13 @@ declare class Game implements Activity {
|
|
|
760
769
|
* Saves an item to the activity's key-value store.
|
|
761
770
|
*
|
|
762
771
|
* @remarks The underlying persistence provider of the key-value store must
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
*
|
|
766
|
-
* session
|
|
767
|
-
*
|
|
768
|
-
*
|
|
772
|
+
* have been previously provided in `SessionOptions`.
|
|
773
|
+
* @example
|
|
774
|
+
* import { LocalDatabase } from "@m2c2kit/db";
|
|
775
|
+
* const session = new Session({
|
|
776
|
+
* dataStores: [new LocalDatabase()]
|
|
777
|
+
* ...
|
|
778
|
+
* });
|
|
769
779
|
* @param key - item key
|
|
770
780
|
* @param value - item value
|
|
771
781
|
* @param globalStore - if true, treat the item as "global" and not
|
|
@@ -778,12 +788,13 @@ declare class Game implements Activity {
|
|
|
778
788
|
* Gets an item value from the activity's key-value store.
|
|
779
789
|
*
|
|
780
790
|
* @remarks The underlying persistence provider of the key-value store must
|
|
781
|
-
*
|
|
782
|
-
*
|
|
783
|
-
*
|
|
784
|
-
* session
|
|
785
|
-
*
|
|
786
|
-
*
|
|
791
|
+
* have been previously provided in `SessionOptions`.
|
|
792
|
+
* @example
|
|
793
|
+
* import { LocalDatabase } from "@m2c2kit/db";
|
|
794
|
+
* const session = new Session({
|
|
795
|
+
* dataStores: [new LocalDatabase()]
|
|
796
|
+
* ...
|
|
797
|
+
* });
|
|
787
798
|
* @param key - item key
|
|
788
799
|
* @param globalStore - if true, treat the item as "global" and not
|
|
789
800
|
* associated with a specific activity; global items can be accessed
|
|
@@ -795,12 +806,13 @@ declare class Game implements Activity {
|
|
|
795
806
|
* Deletes an item value from the activity's key-value store.
|
|
796
807
|
*
|
|
797
808
|
* @remarks The underlying persistence provider of the key-value store must
|
|
798
|
-
*
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
* session
|
|
802
|
-
*
|
|
803
|
-
*
|
|
809
|
+
* have been previously provided in `SessionOptions`.
|
|
810
|
+
* @example
|
|
811
|
+
* import { LocalDatabase } from "@m2c2kit/db";
|
|
812
|
+
* const session = new Session({
|
|
813
|
+
* dataStores: [new LocalDatabase()]
|
|
814
|
+
* ...
|
|
815
|
+
* });
|
|
804
816
|
* @param key - item key
|
|
805
817
|
* @param globalStore - if true, treat the item as "global" and not
|
|
806
818
|
* associated with a specific activity; global items can be accessed
|
|
@@ -811,24 +823,26 @@ declare class Game implements Activity {
|
|
|
811
823
|
* Deletes all items from the activity's key-value store.
|
|
812
824
|
*
|
|
813
825
|
* @remarks The underlying persistence provider of the key-value store must
|
|
814
|
-
*
|
|
815
|
-
*
|
|
816
|
-
*
|
|
817
|
-
* session
|
|
818
|
-
*
|
|
819
|
-
*
|
|
826
|
+
* have been previously provided in `SessionOptions`.
|
|
827
|
+
* @example
|
|
828
|
+
* import { LocalDatabase } from "@m2c2kit/db";
|
|
829
|
+
* const session = new Session({
|
|
830
|
+
* dataStores: [new LocalDatabase()]
|
|
831
|
+
* ...
|
|
832
|
+
* });
|
|
820
833
|
*/
|
|
821
834
|
storeClearItems(): Promise<void>;
|
|
822
835
|
/**
|
|
823
836
|
* Returns keys of all items in the activity's key-value store.
|
|
824
837
|
*
|
|
825
838
|
* @remarks The underlying persistence provider of the key-value store must
|
|
826
|
-
*
|
|
827
|
-
*
|
|
828
|
-
*
|
|
829
|
-
* session
|
|
830
|
-
*
|
|
831
|
-
*
|
|
839
|
+
* have been previously provided in `SessionOptions`.
|
|
840
|
+
* @example
|
|
841
|
+
* import { LocalDatabase } from "@m2c2kit/db";
|
|
842
|
+
* const session = new Session({
|
|
843
|
+
* dataStores: [new LocalDatabase()]
|
|
844
|
+
* ...
|
|
845
|
+
* });
|
|
832
846
|
* @param globalStore - if true, treat the item as "global" and not
|
|
833
847
|
* associated with a specific activity; global items can be accessed
|
|
834
848
|
* by any activity. Default is false.
|
|
@@ -838,12 +852,13 @@ declare class Game implements Activity {
|
|
|
838
852
|
* Determines if a key exists in the activity's key-value store.
|
|
839
853
|
*
|
|
840
854
|
* @remarks The underlying persistence provider of the key-value store must
|
|
841
|
-
*
|
|
842
|
-
*
|
|
843
|
-
*
|
|
844
|
-
* session
|
|
845
|
-
*
|
|
846
|
-
*
|
|
855
|
+
* have been previously provided in `SessionOptions`.
|
|
856
|
+
* @example
|
|
857
|
+
* import { LocalDatabase } from "@m2c2kit/db";
|
|
858
|
+
* const session = new Session({
|
|
859
|
+
* dataStores: [new LocalDatabase()]
|
|
860
|
+
* ...
|
|
861
|
+
* });
|
|
847
862
|
* @param key - item key
|
|
848
863
|
* @param globalStore - if true, treat the item as "global" and not
|
|
849
864
|
* associated with a specific activity; global items can be accessed
|
|
@@ -851,8 +866,8 @@ declare class Game implements Activity {
|
|
|
851
866
|
* @returns true if the key exists, false otherwise
|
|
852
867
|
*/
|
|
853
868
|
storeItemExists(key: string, globalStore?: boolean): Promise<boolean>;
|
|
854
|
-
get
|
|
855
|
-
set
|
|
869
|
+
get dataStores(): IDataStore[];
|
|
870
|
+
set dataStores(dataStores: IDataStore[]);
|
|
856
871
|
private getLocalizationOptionsFromGameParameters;
|
|
857
872
|
private isLocalizationRequested;
|
|
858
873
|
setParameters(additionalParameters: unknown): void;
|
|
@@ -1150,6 +1165,13 @@ declare class Game implements Activity {
|
|
|
1150
1165
|
* @returns - the scene with the screen shot
|
|
1151
1166
|
*/
|
|
1152
1167
|
private createOutgoingScene;
|
|
1168
|
+
/**
|
|
1169
|
+
* Executes a callback when the frame has finished simulating physics.
|
|
1170
|
+
*
|
|
1171
|
+
* @param callback - function to execute.
|
|
1172
|
+
* @param options - options for the callback.
|
|
1173
|
+
*/
|
|
1174
|
+
onFrameDidSimulatePhysics(callback: (frameCycleEvent: FrameCycleEvent) => void, options?: CallbackOptions): void;
|
|
1153
1175
|
private update;
|
|
1154
1176
|
private draw;
|
|
1155
1177
|
private calculateFps;
|
|
@@ -1373,6 +1395,8 @@ interface SessionOptions {
|
|
|
1373
1395
|
sessionUuid?: string;
|
|
1374
1396
|
/** URL of session assets folder (which contains wasm binary), if not the default location of "assets" */
|
|
1375
1397
|
assetsUrl?: string;
|
|
1398
|
+
/** Array of one or more optional databases that implement the IDataStore interface for persisting data. For store item operations, the first data store will be used. */
|
|
1399
|
+
dataStores?: IDataStore[];
|
|
1376
1400
|
/** After the session initializes, should the session automatically start? Default is true */
|
|
1377
1401
|
autoStartAfterInit?: boolean;
|
|
1378
1402
|
/** When an activity ends or is canceled, should the session automatically go to the next activity? Default is true */
|
|
@@ -1389,7 +1413,7 @@ declare class Session {
|
|
|
1389
1413
|
imageManager: ImageManager;
|
|
1390
1414
|
currentActivity?: Activity;
|
|
1391
1415
|
uuid: string;
|
|
1392
|
-
|
|
1416
|
+
dataStores?: IDataStore[];
|
|
1393
1417
|
private eventListeners;
|
|
1394
1418
|
private sessionDictionary;
|
|
1395
1419
|
private canvasKit?;
|
|
@@ -1645,8 +1669,8 @@ interface Activity {
|
|
|
1645
1669
|
setParameters(additionalParameters: unknown): void;
|
|
1646
1670
|
/** Additional activity parameters that were set. */
|
|
1647
1671
|
readonly additionalParameters?: unknown;
|
|
1648
|
-
/** Optional
|
|
1649
|
-
|
|
1672
|
+
/** Optional stores to use for saving data. The implementation of the store is not provided by the \@m2c2kit/core library. */
|
|
1673
|
+
dataStores?: IDataStore[];
|
|
1650
1674
|
}
|
|
1651
1675
|
|
|
1652
1676
|
/**
|
|
@@ -1684,7 +1708,8 @@ declare enum EventType {
|
|
|
1684
1708
|
Drag = "Drag",
|
|
1685
1709
|
DragStart = "DragStart",
|
|
1686
1710
|
DragEnd = "DragEnd",
|
|
1687
|
-
CompositeCustom = "CompositeCustom"
|
|
1711
|
+
CompositeCustom = "CompositeCustom",
|
|
1712
|
+
FrameDidSimulatePhysics = "FrameDidSimulatePhysics"
|
|
1688
1713
|
}
|
|
1689
1714
|
|
|
1690
1715
|
interface EntityEventListener {
|
|
@@ -1807,6 +1832,12 @@ declare abstract class Entity implements EntityOptions {
|
|
|
1807
1832
|
* @remarks Throws error if entity is not part of the game object.
|
|
1808
1833
|
*/
|
|
1809
1834
|
get game(): Game;
|
|
1835
|
+
/**
|
|
1836
|
+
* Determines if the entity has been added to the game object.
|
|
1837
|
+
*
|
|
1838
|
+
* @returns true if entity has been added
|
|
1839
|
+
*/
|
|
1840
|
+
private isPartOfGame;
|
|
1810
1841
|
/**
|
|
1811
1842
|
* Overrides toString() and returns a human-friendly description of the entity.
|
|
1812
1843
|
*
|
|
@@ -1815,7 +1846,8 @@ declare abstract class Entity implements EntityOptions {
|
|
|
1815
1846
|
toString: () => string;
|
|
1816
1847
|
/**
|
|
1817
1848
|
* Adds a child to this parent entity. Throws exception if the child's name
|
|
1818
|
-
* is not unique with respect to other children of this parent
|
|
1849
|
+
* is not unique with respect to other children of this parent, or if the
|
|
1850
|
+
* child has already been added to another parent.
|
|
1819
1851
|
*
|
|
1820
1852
|
* @param child - The child entity to add
|
|
1821
1853
|
*/
|
|
@@ -2608,7 +2640,7 @@ declare enum ShapeType {
|
|
|
2608
2640
|
*/
|
|
2609
2641
|
interface SvgStringPath {
|
|
2610
2642
|
/** SVG string from which to create te path */
|
|
2611
|
-
|
|
2643
|
+
svgPathString?: string;
|
|
2612
2644
|
/** If provided, scale the SVG path to this height, and scale the width to keep the original SVG proportions */
|
|
2613
2645
|
height?: number;
|
|
2614
2646
|
/** If provided, scale the SVG path to this width, and scale the height to keep the original SVG proportions */
|
|
@@ -3100,4 +3132,4 @@ declare class WebGlInfo {
|
|
|
3100
3132
|
static dispose(): void;
|
|
3101
3133
|
}
|
|
3102
3134
|
|
|
3103
|
-
export { Action, Activity, ActivityKeyValueData, ActivityLifecycleEvent, ActivityResultsEvent, ActivityType, BrowserImage, CallbackOptions, CanvasKitHelpers, Composite, CompositeOptions, Constants, ConstraintType, Constraints, CustomAction, CustomActionOptions, DefaultParameter, Dimensions, DrawableOptions, EasingFunction, Easings, Entity, EntityEvent, EntityEventListener, EntityOptions, EntityType, Equals, EventBase, EventListenerBase, EventType, FontData, FontManager, Game, GameData, GameOptions, GameParameters, GlobalVariables, GoToActivityOptions, GroupAction, I18n, IDataStore, IDrawable, IText, ImageManager, Label, LabelHorizontalAlignmentMode, LabelOptions, Layout, LayoutConstraint, LoadedImage, M2DragEvent, M2Path, MoveAction, MoveActionOptions, MutablePath, NoneTransition, Point, RandomDraws, RectOptions, RgbaColor, ScaleAction, ScaleActionOptions, Scene, SceneOptions, SceneTransition, SequenceAction, Session, SessionDictionaryValues, SessionLifecycleEvent, SessionOptions, Shape, ShapeOptions, ShapeType, Size, SlideTransition, SlideTransitionOptions, Sprite, SpriteOptions, Story, StoryOptions, TextLine, TextLineOptions, TextOptions, Timer, Transition, TransitionDirection, TransitionType, Translations, TrialData, TrialSchema, Uuid, WaitAction, WaitActionOptions, WebColors, WebGlInfo, handleInterfaceOptions };
|
|
3135
|
+
export { Action, Activity, ActivityKeyValueData, ActivityLifecycleEvent, ActivityResultsEvent, ActivityType, BrowserImage, CallbackOptions, CanvasKitHelpers, Composite, CompositeOptions, Constants, ConstraintType, Constraints, CustomAction, CustomActionOptions, DefaultParameter, Dimensions, DrawableOptions, EasingFunction, Easings, Entity, EntityEvent, EntityEventListener, EntityOptions, EntityType, Equals, EventBase, EventListenerBase, EventType, FontData, FontManager, Game, GameData, GameOptions, GameParameters, GlobalVariables, GoToActivityOptions, GroupAction, I18n, IDataStore, IDrawable, IText, ImageManager, Label, LabelHorizontalAlignmentMode, LabelOptions, Layout, LayoutConstraint, LoadedImage, M2DragEvent, M2Path, MoveAction, MoveActionOptions, MutablePath, NoneTransition, Point, RandomDraws, RectOptions, RgbaColor, ScaleAction, ScaleActionOptions, Scene, SceneOptions, SceneTransition, SequenceAction, Session, SessionDictionaryValues, SessionLifecycleEvent, SessionOptions, Shape, ShapeOptions, ShapeType, Size, SlideTransition, SlideTransitionOptions, Sprite, SpriteOptions, Story, StoryOptions, TapEvent, TextLine, TextLineOptions, TextOptions, Timer, Transition, TransitionDirection, TransitionType, Translations, TrialData, TrialSchema, Uuid, WaitAction, WaitActionOptions, WebColors, WebGlInfo, handleInterfaceOptions };
|