jspsych-tangram 0.0.4 → 0.0.6
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/construct/index.browser.js +18 -49
- package/dist/construct/index.browser.js.map +1 -1
- package/dist/construct/index.browser.min.js +10 -14
- package/dist/construct/index.browser.min.js.map +1 -1
- package/dist/construct/index.cjs +18 -49
- package/dist/construct/index.cjs.map +1 -1
- package/dist/construct/index.d.ts +12 -0
- package/dist/construct/index.js +18 -49
- package/dist/construct/index.js.map +1 -1
- package/dist/index.cjs +30 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +24 -0
- package/dist/index.js +30 -52
- package/dist/index.js.map +1 -1
- package/dist/prep/index.browser.js +15 -5
- package/dist/prep/index.browser.js.map +1 -1
- package/dist/prep/index.browser.min.js +11 -11
- package/dist/prep/index.browser.min.js.map +1 -1
- package/dist/prep/index.cjs +15 -5
- package/dist/prep/index.cjs.map +1 -1
- package/dist/prep/index.d.ts +12 -0
- package/dist/prep/index.js +15 -5
- package/dist/prep/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/components/board/GameBoard.tsx +4 -1
- package/src/core/engine/state/BaseGameController.ts +0 -1
- package/src/plugins/tangram-construct/ConstructionApp.tsx +13 -53
- package/src/plugins/tangram-construct/index.ts +8 -1
- package/src/plugins/tangram-prep/PrepApp.tsx +8 -2
- package/src/plugins/tangram-prep/index.ts +8 -1
- package/tangram-construct.min.js +10 -14
- package/tangram-prep.min.js +11 -11
package/dist/prep/index.d.ts
CHANGED
|
@@ -40,6 +40,12 @@ declare const info: {
|
|
|
40
40
|
default: never[];
|
|
41
41
|
description: string;
|
|
42
42
|
};
|
|
43
|
+
/** Array of primitive names in the order they should be displayed */
|
|
44
|
+
primitive_order: {
|
|
45
|
+
type: ParameterType;
|
|
46
|
+
default: string[];
|
|
47
|
+
description: string;
|
|
48
|
+
};
|
|
43
49
|
/** Callback fired after each interaction (optional analytics hook) */
|
|
44
50
|
onInteraction: {
|
|
45
51
|
type: ParameterType;
|
|
@@ -109,6 +115,12 @@ declare class TangramPrepPlugin implements JsPsychPlugin<Info> {
|
|
|
109
115
|
default: never[];
|
|
110
116
|
description: string;
|
|
111
117
|
};
|
|
118
|
+
/** Array of primitive names in the order they should be displayed */
|
|
119
|
+
primitive_order: {
|
|
120
|
+
type: ParameterType;
|
|
121
|
+
default: string[];
|
|
122
|
+
description: string;
|
|
123
|
+
};
|
|
112
124
|
/** Callback fired after each interaction (optional analytics hook) */
|
|
113
125
|
onInteraction: {
|
|
114
126
|
type: ParameterType;
|
package/dist/prep/index.js
CHANGED
|
@@ -185,7 +185,6 @@ class BaseGameController {
|
|
|
185
185
|
const allDone = Object.values(this.state.sectors).every((s) => !!s.completedAt);
|
|
186
186
|
if (allDone && !this.state.endedAt) {
|
|
187
187
|
this.state.endedAt = NOW();
|
|
188
|
-
console.log("[BaseGameController] all sectors complete");
|
|
189
188
|
}
|
|
190
189
|
}
|
|
191
190
|
// ===== Piece Operations =====
|
|
@@ -3153,7 +3152,9 @@ function GameBoard(props) {
|
|
|
3153
3152
|
if (allSectorsComplete && !gameCompleted) {
|
|
3154
3153
|
setGameCompleted(true);
|
|
3155
3154
|
if (tracker) {
|
|
3156
|
-
|
|
3155
|
+
setTimeout(() => {
|
|
3156
|
+
tracker.finalizeTrial("auto_complete");
|
|
3157
|
+
}, 0);
|
|
3157
3158
|
}
|
|
3158
3159
|
}
|
|
3159
3160
|
};
|
|
@@ -3547,9 +3548,11 @@ function startPrepTrial(display_element, params, jsPsych) {
|
|
|
3547
3548
|
layoutMode,
|
|
3548
3549
|
requireAllSlots,
|
|
3549
3550
|
quickstashMacros,
|
|
3551
|
+
primitiveOrder,
|
|
3550
3552
|
onInteraction,
|
|
3551
3553
|
onTrialEnd
|
|
3552
3554
|
} = params;
|
|
3555
|
+
const PRIMITIVE_BLUEPRINTS_ORDERED = [...PRIMITIVE_BLUEPRINTS].sort((a, b) => primitiveOrder.indexOf(a.kind) - primitiveOrder.indexOf(b.kind));
|
|
3553
3556
|
const prepSectors = Array.from({ length: numQuickstashSlots }, (_, i) => ({
|
|
3554
3557
|
id: `prep-sector-${i}`,
|
|
3555
3558
|
tangramId: `prep-sector-${i}`,
|
|
@@ -3563,7 +3566,7 @@ function startPrepTrial(display_element, params, jsPsych) {
|
|
|
3563
3566
|
const handleControllerReady = (controller, layout, force) => {
|
|
3564
3567
|
if (quickstashMacros && quickstashMacros.length > 0 && layout) {
|
|
3565
3568
|
const primsByKind = /* @__PURE__ */ new Map();
|
|
3566
|
-
|
|
3569
|
+
PRIMITIVE_BLUEPRINTS_ORDERED.forEach((p) => primsByKind.set(p.kind, p));
|
|
3567
3570
|
quickstashMacros.forEach((anchorComposite, macroIndex) => {
|
|
3568
3571
|
const sectorId = `prep-sector-${macroIndex}`;
|
|
3569
3572
|
const compositeBlueprint = convertAnchorCompositeToPixels(
|
|
@@ -3620,7 +3623,7 @@ function startPrepTrial(display_element, params, jsPsych) {
|
|
|
3620
3623
|
sectors: prepSectors,
|
|
3621
3624
|
quickstash: [],
|
|
3622
3625
|
// No pre-made macros
|
|
3623
|
-
primitives:
|
|
3626
|
+
primitives: PRIMITIVE_BLUEPRINTS_ORDERED,
|
|
3624
3627
|
layout: layoutMode,
|
|
3625
3628
|
target: "workspace",
|
|
3626
3629
|
// Pieces go in sectors
|
|
@@ -3681,6 +3684,12 @@ const info = {
|
|
|
3681
3684
|
default: [],
|
|
3682
3685
|
description: "Array of AnchorComposite objects to edit as primitive pieces"
|
|
3683
3686
|
},
|
|
3687
|
+
/** Array of primitive names in the order they should be displayed */
|
|
3688
|
+
primitive_order: {
|
|
3689
|
+
type: ParameterType.OBJECT,
|
|
3690
|
+
default: ["square", "smalltriangle", "parallelogram", "medtriangle", "largetriangle"],
|
|
3691
|
+
description: "Array of primitive names in the order they should be displayed"
|
|
3692
|
+
},
|
|
3684
3693
|
/** Callback fired after each interaction (optional analytics hook) */
|
|
3685
3694
|
onInteraction: {
|
|
3686
3695
|
type: ParameterType.FUNCTION,
|
|
@@ -3724,13 +3733,14 @@ class TangramPrepPlugin {
|
|
|
3724
3733
|
this.jsPsych.finishTrial(data);
|
|
3725
3734
|
};
|
|
3726
3735
|
const params = {
|
|
3727
|
-
numQuickstashSlots: trial.num_quickstash_slots
|
|
3736
|
+
numQuickstashSlots: trial.num_quickstash_slots,
|
|
3728
3737
|
maxPiecesPerMacro: trial.max_pieces_per_macro,
|
|
3729
3738
|
minPiecesPerMacro: trial.min_pieces_per_macro,
|
|
3730
3739
|
inputMode: trial.input,
|
|
3731
3740
|
layoutMode: trial.layout,
|
|
3732
3741
|
requireAllSlots: trial.require_all_slots,
|
|
3733
3742
|
quickstashMacros: trial.quickstash_macros,
|
|
3743
|
+
primitiveOrder: trial.primitive_order,
|
|
3734
3744
|
onInteraction: trial.onInteraction,
|
|
3735
3745
|
onTrialEnd: wrappedOnTrialEnd
|
|
3736
3746
|
};
|