jspsych-tangram 0.0.4 → 0.0.5
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 +8 -47
- package/dist/construct/index.browser.js.map +1 -1
- package/dist/construct/index.browser.min.js +11 -15
- package/dist/construct/index.browser.min.js.map +1 -1
- package/dist/construct/index.cjs +8 -47
- package/dist/construct/index.cjs.map +1 -1
- package/dist/construct/index.js +8 -47
- package/dist/construct/index.js.map +1 -1
- package/dist/index.cjs +9 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -48
- package/dist/index.js.map +1 -1
- package/dist/prep/index.browser.js +4 -3
- package/dist/prep/index.browser.js.map +1 -1
- package/dist/prep/index.browser.min.js +1 -1
- package/dist/prep/index.browser.min.js.map +1 -1
- package/dist/prep/index.cjs +4 -3
- package/dist/prep/index.cjs.map +1 -1
- package/dist/prep/index.js +4 -3
- 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 +7 -51
- package/src/plugins/tangram-construct/index.ts +1 -1
- package/src/plugins/tangram-prep/index.ts +1 -1
- package/tangram-construct.min.js +11 -15
- package/tangram-prep.min.js +1 -1
package/dist/index.cjs
CHANGED
|
@@ -187,7 +187,6 @@ class BaseGameController {
|
|
|
187
187
|
const allDone = Object.values(this.state.sectors).every((s) => !!s.completedAt);
|
|
188
188
|
if (allDone && !this.state.endedAt) {
|
|
189
189
|
this.state.endedAt = NOW();
|
|
190
|
-
console.log("[BaseGameController] all sectors complete");
|
|
191
190
|
}
|
|
192
191
|
}
|
|
193
192
|
// ===== Piece Operations =====
|
|
@@ -3155,7 +3154,9 @@ function GameBoard(props) {
|
|
|
3155
3154
|
if (allSectorsComplete && !gameCompleted) {
|
|
3156
3155
|
setGameCompleted(true);
|
|
3157
3156
|
if (tracker) {
|
|
3158
|
-
|
|
3157
|
+
setTimeout(() => {
|
|
3158
|
+
tracker.finalizeTrial("auto_complete");
|
|
3159
|
+
}, 0);
|
|
3159
3160
|
}
|
|
3160
3161
|
}
|
|
3161
3162
|
};
|
|
@@ -3548,33 +3549,17 @@ function startConstructionTrial(display_element, params, _jsPsych) {
|
|
|
3548
3549
|
"medtriangle",
|
|
3549
3550
|
"largetriangle"
|
|
3550
3551
|
]);
|
|
3551
|
-
console.log("[ConstructionApp] Starting tangram conversion...");
|
|
3552
|
-
console.log("[ConstructionApp] Received tangrams:", params.tangrams);
|
|
3553
|
-
console.log("[ConstructionApp] Number of tangrams:", params.tangrams.length);
|
|
3554
3552
|
const sectors = params.tangrams.map((tangramSpec, index) => {
|
|
3555
|
-
console.log(`
|
|
3556
|
-
[ConstructionApp] Processing tangram ${index}:`, tangramSpec);
|
|
3557
|
-
console.log(`[ConstructionApp] tangramID: ${tangramSpec.tangramID}`);
|
|
3558
|
-
console.log(`[ConstructionApp] setLabel: ${tangramSpec.setLabel}`);
|
|
3559
|
-
console.log(`[ConstructionApp] solutionTans count: ${tangramSpec.solutionTans?.length}`);
|
|
3560
|
-
console.log(`[ConstructionApp] solutionTans:`, tangramSpec.solutionTans);
|
|
3561
3553
|
const filteredTans = tangramSpec.solutionTans.filter((tan) => {
|
|
3562
3554
|
const tanName = tan.name ?? tan.kind;
|
|
3563
3555
|
const isCanonical = CANON.has(tanName);
|
|
3564
|
-
console.log(`[ConstructionApp] Tan "${tanName}": canonical=${isCanonical}, vertices count=${tan.vertices?.length}`);
|
|
3565
3556
|
return isCanonical;
|
|
3566
3557
|
});
|
|
3567
|
-
console.log(`[ConstructionApp] Filtered to ${filteredTans.length} canonical pieces`);
|
|
3568
3558
|
const mask = filteredTans.map((tan, tanIndex) => {
|
|
3569
|
-
const tanName = tan.name ?? tan.kind;
|
|
3570
3559
|
const polygon = tan.vertices.map(([x, y]) => ({ x: x ?? 0, y: -(y ?? 0) }));
|
|
3571
|
-
console.log(`[ConstructionApp] Polygon ${tanIndex} (${tanName}): ${tan.vertices.length} vertices -> ${polygon.length} points`);
|
|
3572
|
-
console.log(`[ConstructionApp] First vertex: [${tan.vertices[0]?.[0]}, ${tan.vertices[0]?.[1]}] -> {x: ${polygon[0]?.x}, y: ${polygon[0]?.y}}`);
|
|
3573
3560
|
return polygon;
|
|
3574
3561
|
});
|
|
3575
3562
|
const sectorId = `sector${index}`;
|
|
3576
|
-
console.log(`[ConstructionApp] Assigned sector ID: ${sectorId}`);
|
|
3577
|
-
console.log(`[ConstructionApp] Final mask has ${mask.length} polygons`);
|
|
3578
3563
|
const sector = {
|
|
3579
3564
|
id: sectorId,
|
|
3580
3565
|
tangramId: tangramSpec.tangramID,
|
|
@@ -3583,61 +3568,37 @@ function startConstructionTrial(display_element, params, _jsPsych) {
|
|
|
3583
3568
|
mask
|
|
3584
3569
|
}
|
|
3585
3570
|
};
|
|
3586
|
-
console.log(`[ConstructionApp] Created sector:`, sector);
|
|
3587
3571
|
return sector;
|
|
3588
3572
|
});
|
|
3589
|
-
console.log("\n[ConstructionApp] Final sectors array:", sectors);
|
|
3590
|
-
console.log(`[ConstructionApp] Total sectors created: ${sectors.length}`);
|
|
3591
|
-
console.log("\n[ConstructionApp] Processing quickstash macros...");
|
|
3592
|
-
console.log("[ConstructionApp] quickstash_macros:", params.quickstash_macros);
|
|
3593
|
-
console.log("[ConstructionApp] quickstash_macros count:", params.quickstash_macros?.length ?? 0);
|
|
3594
3573
|
let quickstash = [];
|
|
3595
3574
|
if (params.quickstash_macros && params.quickstash_macros.length > 0) {
|
|
3596
3575
|
const firstMacro = params.quickstash_macros[0];
|
|
3597
|
-
console.log("[ConstructionApp] First macro:", firstMacro);
|
|
3598
3576
|
if (firstMacro && "parts" in firstMacro && firstMacro.parts && firstMacro.parts[0] && "anchorOffset" in firstMacro.parts[0]) {
|
|
3599
|
-
console.log("[ConstructionApp] Detected anchor-based composites, converting to pixels...");
|
|
3600
3577
|
const primsByKind = /* @__PURE__ */ new Map();
|
|
3601
3578
|
PRIMITIVE_BLUEPRINTS.forEach((p) => primsByKind.set(p.kind, p));
|
|
3602
3579
|
quickstash = params.quickstash_macros.map(
|
|
3603
3580
|
(anchorComposite) => convertAnchorCompositeToPixels(anchorComposite, primsByKind, CONFIG.layout.grid.stepPx)
|
|
3604
3581
|
// Use current CONFIG grid step
|
|
3605
3582
|
);
|
|
3606
|
-
console.log("[ConstructionApp] Converted to pixel-based blueprints:", quickstash);
|
|
3607
3583
|
} else {
|
|
3608
|
-
console.log("[ConstructionApp] Already pixel-based blueprints");
|
|
3609
3584
|
quickstash = params.quickstash_macros;
|
|
3610
3585
|
}
|
|
3611
|
-
} else {
|
|
3612
|
-
console.log("[ConstructionApp] No quickstash macros provided");
|
|
3613
3586
|
}
|
|
3614
3587
|
const gameBoardProps = {
|
|
3615
3588
|
sectors,
|
|
3616
3589
|
quickstash,
|
|
3617
3590
|
primitives: PRIMITIVE_BLUEPRINTS,
|
|
3618
|
-
layout: params.layout
|
|
3619
|
-
target: params.target
|
|
3620
|
-
input: params.input
|
|
3621
|
-
timeLimitMs: params.time_limit_ms
|
|
3591
|
+
layout: params.layout,
|
|
3592
|
+
target: params.target,
|
|
3593
|
+
input: params.input,
|
|
3594
|
+
timeLimitMs: params.time_limit_ms,
|
|
3622
3595
|
maxQuickstashSlots: CONFIG.layout.defaults.maxQuickstashSlots,
|
|
3623
3596
|
mode: "construction",
|
|
3624
|
-
// Explicit construction mode
|
|
3625
3597
|
...params.onInteraction && { onInteraction: params.onInteraction },
|
|
3626
3598
|
...params.onTrialEnd && { onTrialEnd: params.onTrialEnd }
|
|
3627
3599
|
};
|
|
3628
|
-
console.log("\n[ConstructionApp] Final GameBoard props:");
|
|
3629
|
-
console.log("[ConstructionApp] sectors count:", gameBoardProps.sectors.length);
|
|
3630
|
-
console.log("[ConstructionApp] quickstash count:", gameBoardProps.quickstash.length);
|
|
3631
|
-
console.log("[ConstructionApp] primitives count:", gameBoardProps.primitives.length);
|
|
3632
|
-
console.log("[ConstructionApp] layout:", gameBoardProps.layout);
|
|
3633
|
-
console.log("[ConstructionApp] target:", gameBoardProps.target);
|
|
3634
|
-
console.log("[ConstructionApp] input:", gameBoardProps.input);
|
|
3635
|
-
console.log("[ConstructionApp] timeLimitMs:", gameBoardProps.timeLimitMs);
|
|
3636
|
-
console.log("[ConstructionApp] mode:", gameBoardProps.mode);
|
|
3637
|
-
console.log("[ConstructionApp] Full props:", gameBoardProps);
|
|
3638
3600
|
const root = client.createRoot(display_element);
|
|
3639
3601
|
root.render(React.createElement(GameBoard, gameBoardProps));
|
|
3640
|
-
console.log("[ConstructionApp] GameBoard rendered successfully");
|
|
3641
3602
|
return { root, display_element, jsPsych: _jsPsych };
|
|
3642
3603
|
}
|
|
3643
3604
|
|
|
@@ -3761,7 +3722,7 @@ class TangramConstructPlugin {
|
|
|
3761
3722
|
target: trial.target,
|
|
3762
3723
|
input: trial.input,
|
|
3763
3724
|
layout: trial.layout,
|
|
3764
|
-
time_limit_ms: trial.time_limit_ms
|
|
3725
|
+
time_limit_ms: trial.time_limit_ms,
|
|
3765
3726
|
onInteraction: trial.onInteraction,
|
|
3766
3727
|
onTrialEnd: wrappedOnTrialEnd
|
|
3767
3728
|
};
|
|
@@ -3956,7 +3917,7 @@ class TangramPrepPlugin {
|
|
|
3956
3917
|
this.jsPsych.finishTrial(data);
|
|
3957
3918
|
};
|
|
3958
3919
|
const params = {
|
|
3959
|
-
numQuickstashSlots: trial.num_quickstash_slots
|
|
3920
|
+
numQuickstashSlots: trial.num_quickstash_slots,
|
|
3960
3921
|
maxPiecesPerMacro: trial.max_pieces_per_macro,
|
|
3961
3922
|
minPiecesPerMacro: trial.min_pieces_per_macro,
|
|
3962
3923
|
inputMode: trial.input,
|