jspsych-tangram 0.0.5 → 0.0.7
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 +23 -14
- package/dist/construct/index.browser.js.map +1 -1
- package/dist/construct/index.browser.min.js +11 -11
- package/dist/construct/index.browser.min.js.map +1 -1
- package/dist/construct/index.cjs +23 -14
- package/dist/construct/index.cjs.map +1 -1
- package/dist/construct/index.d.ts +12 -0
- package/dist/construct/index.js +23 -14
- package/dist/construct/index.js.map +1 -1
- package/dist/index.cjs +34 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +24 -0
- package/dist/index.js +34 -16
- package/dist/index.js.map +1 -1
- package/dist/prep/index.browser.js +24 -14
- 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 +24 -14
- package/dist/prep/index.cjs.map +1 -1
- package/dist/prep/index.d.ts +12 -0
- package/dist/prep/index.js +24 -14
- package/dist/prep/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/config/config.ts +13 -12
- package/src/plugins/tangram-construct/ConstructionApp.tsx +6 -2
- package/src/plugins/tangram-construct/index.ts +7 -0
- package/src/plugins/tangram-prep/PrepApp.tsx +8 -2
- package/src/plugins/tangram-prep/index.ts +7 -0
- package/tangram-construct.min.js +11 -11
- package/tangram-prep.min.js +11 -11
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,12 @@ declare const info$1: {
|
|
|
16
16
|
default: never[];
|
|
17
17
|
description: string;
|
|
18
18
|
};
|
|
19
|
+
/** Array of primitive names in the order they should be displayed */
|
|
20
|
+
primitive_order: {
|
|
21
|
+
type: ParameterType;
|
|
22
|
+
default: string[];
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
19
25
|
/** Whether to place pieces in workspace or directly on silhouette */
|
|
20
26
|
target: {
|
|
21
27
|
type: ParameterType;
|
|
@@ -118,6 +124,12 @@ declare class TangramConstructPlugin implements JsPsychPlugin<Info$1> {
|
|
|
118
124
|
default: never[];
|
|
119
125
|
description: string;
|
|
120
126
|
};
|
|
127
|
+
/** Array of primitive names in the order they should be displayed */
|
|
128
|
+
primitive_order: {
|
|
129
|
+
type: ParameterType;
|
|
130
|
+
default: string[];
|
|
131
|
+
description: string;
|
|
132
|
+
};
|
|
121
133
|
/** Whether to place pieces in workspace or directly on silhouette */
|
|
122
134
|
target: {
|
|
123
135
|
type: ParameterType;
|
|
@@ -241,6 +253,12 @@ declare const info: {
|
|
|
241
253
|
default: never[];
|
|
242
254
|
description: string;
|
|
243
255
|
};
|
|
256
|
+
/** Array of primitive names in the order they should be displayed */
|
|
257
|
+
primitive_order: {
|
|
258
|
+
type: ParameterType;
|
|
259
|
+
default: string[];
|
|
260
|
+
description: string;
|
|
261
|
+
};
|
|
244
262
|
/** Callback fired after each interaction (optional analytics hook) */
|
|
245
263
|
onInteraction: {
|
|
246
264
|
type: ParameterType;
|
|
@@ -310,6 +328,12 @@ declare class TangramPrepPlugin implements JsPsychPlugin<Info> {
|
|
|
310
328
|
default: never[];
|
|
311
329
|
description: string;
|
|
312
330
|
};
|
|
331
|
+
/** Array of primitive names in the order they should be displayed */
|
|
332
|
+
primitive_order: {
|
|
333
|
+
type: ParameterType;
|
|
334
|
+
default: string[];
|
|
335
|
+
description: string;
|
|
336
|
+
};
|
|
313
337
|
/** Callback fired after each interaction (optional analytics hook) */
|
|
314
338
|
onInteraction: {
|
|
315
339
|
type: ParameterType;
|
package/dist/index.js
CHANGED
|
@@ -6,26 +6,27 @@ import { v4 } from 'uuid';
|
|
|
6
6
|
const CONFIG = {
|
|
7
7
|
color: {
|
|
8
8
|
bands: {
|
|
9
|
-
silhouette: { fillEven: "#
|
|
10
|
-
workspace: { fillEven: "#
|
|
9
|
+
silhouette: { fillEven: "#fff2ccff", fillOdd: "#fff2ccff", stroke: "#b1b1b1" },
|
|
10
|
+
workspace: { fillEven: "#fff2ccff", fillOdd: "#fff2ccff", stroke: "#b1b1b1" }
|
|
11
11
|
},
|
|
12
|
-
completion: { fill: "#
|
|
13
|
-
silhouetteMask: "#
|
|
12
|
+
completion: { fill: "#ccfff2", stroke: "#13da57" },
|
|
13
|
+
silhouetteMask: "#374151",
|
|
14
14
|
anchors: { invalid: "#7dd3fc", valid: "#475569" },
|
|
15
|
-
piece: { draggingFill: "#
|
|
15
|
+
piece: { draggingFill: "#8e7cc3ff", validFill: "#8e7cc3ff", invalidFill: "#ef4444", invalidStroke: "#dc2626", selectedStroke: "#674ea7", allGreenStroke: "#86efac", borderStroke: "#674ea7" },
|
|
16
16
|
ui: { light: "#60a5fa", dark: "#1d4ed8" },
|
|
17
|
-
blueprint: { fill: "#374151", selectedStroke: "#111827", badgeFill: "#
|
|
17
|
+
blueprint: { fill: "#374151", selectedStroke: "#111827", badgeFill: "#000000", labelFill: "#ffffff" }
|
|
18
18
|
},
|
|
19
19
|
opacity: {
|
|
20
|
-
blueprint: 0.
|
|
21
|
-
silhouetteMask: 0.
|
|
22
|
-
anchors: { valid: 0.
|
|
23
|
-
|
|
20
|
+
blueprint: 0.4,
|
|
21
|
+
silhouetteMask: 0.25,
|
|
22
|
+
//anchors: { valid: 0.80, invalid: 0.50 },
|
|
23
|
+
anchors: { invalid: 0, valid: 0 },
|
|
24
|
+
piece: { invalid: 0.35, dragging: 0.75, locked: 1, normal: 1 }
|
|
24
25
|
},
|
|
25
26
|
size: {
|
|
26
|
-
stroke: { bandPx:
|
|
27
|
+
stroke: { bandPx: 5, pieceSelectedPx: 3, allGreenStrokePx: 10, pieceBorderPx: 2 },
|
|
27
28
|
anchorRadiusPx: { valid: 1, invalid: 1 },
|
|
28
|
-
badgeFontPx:
|
|
29
|
+
badgeFontPx: 16,
|
|
29
30
|
centerBadge: { fractionOfOuterR: 0.15, minPx: 20, marginPx: 4 }
|
|
30
31
|
},
|
|
31
32
|
layout: {
|
|
@@ -3547,6 +3548,7 @@ function startConstructionTrial(display_element, params, _jsPsych) {
|
|
|
3547
3548
|
"medtriangle",
|
|
3548
3549
|
"largetriangle"
|
|
3549
3550
|
]);
|
|
3551
|
+
const PRIMITIVE_BLUEPRINTS_ORDERED = [...PRIMITIVE_BLUEPRINTS].sort((a, b) => params.primitiveOrder.indexOf(a.kind) - params.primitiveOrder.indexOf(b.kind));
|
|
3550
3552
|
const sectors = params.tangrams.map((tangramSpec, index) => {
|
|
3551
3553
|
const filteredTans = tangramSpec.solutionTans.filter((tan) => {
|
|
3552
3554
|
const tanName = tan.name ?? tan.kind;
|
|
@@ -3573,7 +3575,7 @@ function startConstructionTrial(display_element, params, _jsPsych) {
|
|
|
3573
3575
|
const firstMacro = params.quickstash_macros[0];
|
|
3574
3576
|
if (firstMacro && "parts" in firstMacro && firstMacro.parts && firstMacro.parts[0] && "anchorOffset" in firstMacro.parts[0]) {
|
|
3575
3577
|
const primsByKind = /* @__PURE__ */ new Map();
|
|
3576
|
-
|
|
3578
|
+
PRIMITIVE_BLUEPRINTS_ORDERED.forEach((p) => primsByKind.set(p.kind, p));
|
|
3577
3579
|
quickstash = params.quickstash_macros.map(
|
|
3578
3580
|
(anchorComposite) => convertAnchorCompositeToPixels(anchorComposite, primsByKind, CONFIG.layout.grid.stepPx)
|
|
3579
3581
|
// Use current CONFIG grid step
|
|
@@ -3585,7 +3587,7 @@ function startConstructionTrial(display_element, params, _jsPsych) {
|
|
|
3585
3587
|
const gameBoardProps = {
|
|
3586
3588
|
sectors,
|
|
3587
3589
|
quickstash,
|
|
3588
|
-
primitives:
|
|
3590
|
+
primitives: PRIMITIVE_BLUEPRINTS_ORDERED,
|
|
3589
3591
|
layout: params.layout,
|
|
3590
3592
|
target: params.target,
|
|
3591
3593
|
input: params.input,
|
|
@@ -3616,6 +3618,12 @@ const info$1 = {
|
|
|
3616
3618
|
default: [],
|
|
3617
3619
|
description: "Array of MacroSpec objects created in prep trial"
|
|
3618
3620
|
},
|
|
3621
|
+
/** Array of primitive names in the order they should be displayed */
|
|
3622
|
+
primitive_order: {
|
|
3623
|
+
type: ParameterType.OBJECT,
|
|
3624
|
+
default: ["square", "smalltriangle", "parallelogram", "medtriangle", "largetriangle"],
|
|
3625
|
+
description: "Array of primitive names in the order they should be displayed"
|
|
3626
|
+
},
|
|
3619
3627
|
/** Whether to place pieces in workspace or directly on silhouette */
|
|
3620
3628
|
target: {
|
|
3621
3629
|
type: ParameterType.SELECT,
|
|
@@ -3717,6 +3725,7 @@ class TangramConstructPlugin {
|
|
|
3717
3725
|
const params = {
|
|
3718
3726
|
tangrams: trial.tangrams,
|
|
3719
3727
|
quickstash_macros: trial.quickstash_macros,
|
|
3728
|
+
primitiveOrder: trial.primitive_order,
|
|
3720
3729
|
target: trial.target,
|
|
3721
3730
|
input: trial.input,
|
|
3722
3731
|
layout: trial.layout,
|
|
@@ -3738,9 +3747,11 @@ function startPrepTrial(display_element, params, jsPsych) {
|
|
|
3738
3747
|
layoutMode,
|
|
3739
3748
|
requireAllSlots,
|
|
3740
3749
|
quickstashMacros,
|
|
3750
|
+
primitiveOrder,
|
|
3741
3751
|
onInteraction,
|
|
3742
3752
|
onTrialEnd
|
|
3743
3753
|
} = params;
|
|
3754
|
+
const PRIMITIVE_BLUEPRINTS_ORDERED = [...PRIMITIVE_BLUEPRINTS].sort((a, b) => primitiveOrder.indexOf(a.kind) - primitiveOrder.indexOf(b.kind));
|
|
3744
3755
|
const prepSectors = Array.from({ length: numQuickstashSlots }, (_, i) => ({
|
|
3745
3756
|
id: `prep-sector-${i}`,
|
|
3746
3757
|
tangramId: `prep-sector-${i}`,
|
|
@@ -3754,7 +3765,7 @@ function startPrepTrial(display_element, params, jsPsych) {
|
|
|
3754
3765
|
const handleControllerReady = (controller, layout, force) => {
|
|
3755
3766
|
if (quickstashMacros && quickstashMacros.length > 0 && layout) {
|
|
3756
3767
|
const primsByKind = /* @__PURE__ */ new Map();
|
|
3757
|
-
|
|
3768
|
+
PRIMITIVE_BLUEPRINTS_ORDERED.forEach((p) => primsByKind.set(p.kind, p));
|
|
3758
3769
|
quickstashMacros.forEach((anchorComposite, macroIndex) => {
|
|
3759
3770
|
const sectorId = `prep-sector-${macroIndex}`;
|
|
3760
3771
|
const compositeBlueprint = convertAnchorCompositeToPixels(
|
|
@@ -3811,7 +3822,7 @@ function startPrepTrial(display_element, params, jsPsych) {
|
|
|
3811
3822
|
sectors: prepSectors,
|
|
3812
3823
|
quickstash: [],
|
|
3813
3824
|
// No pre-made macros
|
|
3814
|
-
primitives:
|
|
3825
|
+
primitives: PRIMITIVE_BLUEPRINTS_ORDERED,
|
|
3815
3826
|
layout: layoutMode,
|
|
3816
3827
|
target: "workspace",
|
|
3817
3828
|
// Pieces go in sectors
|
|
@@ -3872,6 +3883,12 @@ const info = {
|
|
|
3872
3883
|
default: [],
|
|
3873
3884
|
description: "Array of AnchorComposite objects to edit as primitive pieces"
|
|
3874
3885
|
},
|
|
3886
|
+
/** Array of primitive names in the order they should be displayed */
|
|
3887
|
+
primitive_order: {
|
|
3888
|
+
type: ParameterType.OBJECT,
|
|
3889
|
+
default: ["square", "smalltriangle", "parallelogram", "medtriangle", "largetriangle"],
|
|
3890
|
+
description: "Array of primitive names in the order they should be displayed"
|
|
3891
|
+
},
|
|
3875
3892
|
/** Callback fired after each interaction (optional analytics hook) */
|
|
3876
3893
|
onInteraction: {
|
|
3877
3894
|
type: ParameterType.FUNCTION,
|
|
@@ -3922,6 +3939,7 @@ class TangramPrepPlugin {
|
|
|
3922
3939
|
layoutMode: trial.layout,
|
|
3923
3940
|
requireAllSlots: trial.require_all_slots,
|
|
3924
3941
|
quickstashMacros: trial.quickstash_macros,
|
|
3942
|
+
primitiveOrder: trial.primitive_order,
|
|
3925
3943
|
onInteraction: trial.onInteraction,
|
|
3926
3944
|
onTrialEnd: wrappedOnTrialEnd
|
|
3927
3945
|
};
|