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.cjs
CHANGED
|
@@ -8,26 +8,27 @@ var uuid = require('uuid');
|
|
|
8
8
|
const CONFIG = {
|
|
9
9
|
color: {
|
|
10
10
|
bands: {
|
|
11
|
-
silhouette: { fillEven: "#
|
|
12
|
-
workspace: { fillEven: "#
|
|
11
|
+
silhouette: { fillEven: "#fff2ccff", fillOdd: "#fff2ccff", stroke: "#b1b1b1" },
|
|
12
|
+
workspace: { fillEven: "#fff2ccff", fillOdd: "#fff2ccff", stroke: "#b1b1b1" }
|
|
13
13
|
},
|
|
14
|
-
completion: { fill: "#
|
|
15
|
-
silhouetteMask: "#
|
|
14
|
+
completion: { fill: "#ccfff2", stroke: "#13da57" },
|
|
15
|
+
silhouetteMask: "#374151",
|
|
16
16
|
anchors: { invalid: "#7dd3fc", valid: "#475569" },
|
|
17
|
-
piece: { draggingFill: "#
|
|
17
|
+
piece: { draggingFill: "#8e7cc3ff", validFill: "#8e7cc3ff", invalidFill: "#ef4444", invalidStroke: "#dc2626", selectedStroke: "#674ea7", allGreenStroke: "#86efac", borderStroke: "#674ea7" },
|
|
18
18
|
ui: { light: "#60a5fa", dark: "#1d4ed8" },
|
|
19
|
-
blueprint: { fill: "#374151", selectedStroke: "#111827", badgeFill: "#
|
|
19
|
+
blueprint: { fill: "#374151", selectedStroke: "#111827", badgeFill: "#000000", labelFill: "#ffffff" }
|
|
20
20
|
},
|
|
21
21
|
opacity: {
|
|
22
|
-
blueprint: 0.
|
|
23
|
-
silhouetteMask: 0.
|
|
24
|
-
anchors: { valid: 0.
|
|
25
|
-
|
|
22
|
+
blueprint: 0.4,
|
|
23
|
+
silhouetteMask: 0.25,
|
|
24
|
+
//anchors: { valid: 0.80, invalid: 0.50 },
|
|
25
|
+
anchors: { invalid: 0, valid: 0 },
|
|
26
|
+
piece: { invalid: 0.35, dragging: 0.75, locked: 1, normal: 1 }
|
|
26
27
|
},
|
|
27
28
|
size: {
|
|
28
|
-
stroke: { bandPx:
|
|
29
|
+
stroke: { bandPx: 5, pieceSelectedPx: 3, allGreenStrokePx: 10, pieceBorderPx: 2 },
|
|
29
30
|
anchorRadiusPx: { valid: 1, invalid: 1 },
|
|
30
|
-
badgeFontPx:
|
|
31
|
+
badgeFontPx: 16,
|
|
31
32
|
centerBadge: { fractionOfOuterR: 0.15, minPx: 20, marginPx: 4 }
|
|
32
33
|
},
|
|
33
34
|
layout: {
|
|
@@ -3549,6 +3550,7 @@ function startConstructionTrial(display_element, params, _jsPsych) {
|
|
|
3549
3550
|
"medtriangle",
|
|
3550
3551
|
"largetriangle"
|
|
3551
3552
|
]);
|
|
3553
|
+
const PRIMITIVE_BLUEPRINTS_ORDERED = [...PRIMITIVE_BLUEPRINTS].sort((a, b) => params.primitiveOrder.indexOf(a.kind) - params.primitiveOrder.indexOf(b.kind));
|
|
3552
3554
|
const sectors = params.tangrams.map((tangramSpec, index) => {
|
|
3553
3555
|
const filteredTans = tangramSpec.solutionTans.filter((tan) => {
|
|
3554
3556
|
const tanName = tan.name ?? tan.kind;
|
|
@@ -3575,7 +3577,7 @@ function startConstructionTrial(display_element, params, _jsPsych) {
|
|
|
3575
3577
|
const firstMacro = params.quickstash_macros[0];
|
|
3576
3578
|
if (firstMacro && "parts" in firstMacro && firstMacro.parts && firstMacro.parts[0] && "anchorOffset" in firstMacro.parts[0]) {
|
|
3577
3579
|
const primsByKind = /* @__PURE__ */ new Map();
|
|
3578
|
-
|
|
3580
|
+
PRIMITIVE_BLUEPRINTS_ORDERED.forEach((p) => primsByKind.set(p.kind, p));
|
|
3579
3581
|
quickstash = params.quickstash_macros.map(
|
|
3580
3582
|
(anchorComposite) => convertAnchorCompositeToPixels(anchorComposite, primsByKind, CONFIG.layout.grid.stepPx)
|
|
3581
3583
|
// Use current CONFIG grid step
|
|
@@ -3587,7 +3589,7 @@ function startConstructionTrial(display_element, params, _jsPsych) {
|
|
|
3587
3589
|
const gameBoardProps = {
|
|
3588
3590
|
sectors,
|
|
3589
3591
|
quickstash,
|
|
3590
|
-
primitives:
|
|
3592
|
+
primitives: PRIMITIVE_BLUEPRINTS_ORDERED,
|
|
3591
3593
|
layout: params.layout,
|
|
3592
3594
|
target: params.target,
|
|
3593
3595
|
input: params.input,
|
|
@@ -3618,6 +3620,12 @@ const info$1 = {
|
|
|
3618
3620
|
default: [],
|
|
3619
3621
|
description: "Array of MacroSpec objects created in prep trial"
|
|
3620
3622
|
},
|
|
3623
|
+
/** Array of primitive names in the order they should be displayed */
|
|
3624
|
+
primitive_order: {
|
|
3625
|
+
type: jspsych.ParameterType.OBJECT,
|
|
3626
|
+
default: ["square", "smalltriangle", "parallelogram", "medtriangle", "largetriangle"],
|
|
3627
|
+
description: "Array of primitive names in the order they should be displayed"
|
|
3628
|
+
},
|
|
3621
3629
|
/** Whether to place pieces in workspace or directly on silhouette */
|
|
3622
3630
|
target: {
|
|
3623
3631
|
type: jspsych.ParameterType.SELECT,
|
|
@@ -3719,6 +3727,7 @@ class TangramConstructPlugin {
|
|
|
3719
3727
|
const params = {
|
|
3720
3728
|
tangrams: trial.tangrams,
|
|
3721
3729
|
quickstash_macros: trial.quickstash_macros,
|
|
3730
|
+
primitiveOrder: trial.primitive_order,
|
|
3722
3731
|
target: trial.target,
|
|
3723
3732
|
input: trial.input,
|
|
3724
3733
|
layout: trial.layout,
|
|
@@ -3740,9 +3749,11 @@ function startPrepTrial(display_element, params, jsPsych) {
|
|
|
3740
3749
|
layoutMode,
|
|
3741
3750
|
requireAllSlots,
|
|
3742
3751
|
quickstashMacros,
|
|
3752
|
+
primitiveOrder,
|
|
3743
3753
|
onInteraction,
|
|
3744
3754
|
onTrialEnd
|
|
3745
3755
|
} = params;
|
|
3756
|
+
const PRIMITIVE_BLUEPRINTS_ORDERED = [...PRIMITIVE_BLUEPRINTS].sort((a, b) => primitiveOrder.indexOf(a.kind) - primitiveOrder.indexOf(b.kind));
|
|
3746
3757
|
const prepSectors = Array.from({ length: numQuickstashSlots }, (_, i) => ({
|
|
3747
3758
|
id: `prep-sector-${i}`,
|
|
3748
3759
|
tangramId: `prep-sector-${i}`,
|
|
@@ -3756,7 +3767,7 @@ function startPrepTrial(display_element, params, jsPsych) {
|
|
|
3756
3767
|
const handleControllerReady = (controller, layout, force) => {
|
|
3757
3768
|
if (quickstashMacros && quickstashMacros.length > 0 && layout) {
|
|
3758
3769
|
const primsByKind = /* @__PURE__ */ new Map();
|
|
3759
|
-
|
|
3770
|
+
PRIMITIVE_BLUEPRINTS_ORDERED.forEach((p) => primsByKind.set(p.kind, p));
|
|
3760
3771
|
quickstashMacros.forEach((anchorComposite, macroIndex) => {
|
|
3761
3772
|
const sectorId = `prep-sector-${macroIndex}`;
|
|
3762
3773
|
const compositeBlueprint = convertAnchorCompositeToPixels(
|
|
@@ -3813,7 +3824,7 @@ function startPrepTrial(display_element, params, jsPsych) {
|
|
|
3813
3824
|
sectors: prepSectors,
|
|
3814
3825
|
quickstash: [],
|
|
3815
3826
|
// No pre-made macros
|
|
3816
|
-
primitives:
|
|
3827
|
+
primitives: PRIMITIVE_BLUEPRINTS_ORDERED,
|
|
3817
3828
|
layout: layoutMode,
|
|
3818
3829
|
target: "workspace",
|
|
3819
3830
|
// Pieces go in sectors
|
|
@@ -3874,6 +3885,12 @@ const info = {
|
|
|
3874
3885
|
default: [],
|
|
3875
3886
|
description: "Array of AnchorComposite objects to edit as primitive pieces"
|
|
3876
3887
|
},
|
|
3888
|
+
/** Array of primitive names in the order they should be displayed */
|
|
3889
|
+
primitive_order: {
|
|
3890
|
+
type: jspsych.ParameterType.OBJECT,
|
|
3891
|
+
default: ["square", "smalltriangle", "parallelogram", "medtriangle", "largetriangle"],
|
|
3892
|
+
description: "Array of primitive names in the order they should be displayed"
|
|
3893
|
+
},
|
|
3877
3894
|
/** Callback fired after each interaction (optional analytics hook) */
|
|
3878
3895
|
onInteraction: {
|
|
3879
3896
|
type: jspsych.ParameterType.FUNCTION,
|
|
@@ -3924,6 +3941,7 @@ class TangramPrepPlugin {
|
|
|
3924
3941
|
layoutMode: trial.layout,
|
|
3925
3942
|
requireAllSlots: trial.require_all_slots,
|
|
3926
3943
|
quickstashMacros: trial.quickstash_macros,
|
|
3944
|
+
primitiveOrder: trial.primitive_order,
|
|
3927
3945
|
onInteraction: trial.onInteraction,
|
|
3928
3946
|
onTrialEnd: wrappedOnTrialEnd
|
|
3929
3947
|
};
|