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.
@@ -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
- tracker.finalizeTrial("auto_complete");
3155
+ setTimeout(() => {
3156
+ tracker.finalizeTrial("auto_complete");
3157
+ }, 0);
3157
3158
  }
3158
3159
  }
3159
3160
  };
@@ -3546,33 +3547,17 @@ function startConstructionTrial(display_element, params, _jsPsych) {
3546
3547
  "medtriangle",
3547
3548
  "largetriangle"
3548
3549
  ]);
3549
- console.log("[ConstructionApp] Starting tangram conversion...");
3550
- console.log("[ConstructionApp] Received tangrams:", params.tangrams);
3551
- console.log("[ConstructionApp] Number of tangrams:", params.tangrams.length);
3552
3550
  const sectors = params.tangrams.map((tangramSpec, index) => {
3553
- console.log(`
3554
- [ConstructionApp] Processing tangram ${index}:`, tangramSpec);
3555
- console.log(`[ConstructionApp] tangramID: ${tangramSpec.tangramID}`);
3556
- console.log(`[ConstructionApp] setLabel: ${tangramSpec.setLabel}`);
3557
- console.log(`[ConstructionApp] solutionTans count: ${tangramSpec.solutionTans?.length}`);
3558
- console.log(`[ConstructionApp] solutionTans:`, tangramSpec.solutionTans);
3559
3551
  const filteredTans = tangramSpec.solutionTans.filter((tan) => {
3560
3552
  const tanName = tan.name ?? tan.kind;
3561
3553
  const isCanonical = CANON.has(tanName);
3562
- console.log(`[ConstructionApp] Tan "${tanName}": canonical=${isCanonical}, vertices count=${tan.vertices?.length}`);
3563
3554
  return isCanonical;
3564
3555
  });
3565
- console.log(`[ConstructionApp] Filtered to ${filteredTans.length} canonical pieces`);
3566
3556
  const mask = filteredTans.map((tan, tanIndex) => {
3567
- const tanName = tan.name ?? tan.kind;
3568
3557
  const polygon = tan.vertices.map(([x, y]) => ({ x: x ?? 0, y: -(y ?? 0) }));
3569
- console.log(`[ConstructionApp] Polygon ${tanIndex} (${tanName}): ${tan.vertices.length} vertices -> ${polygon.length} points`);
3570
- console.log(`[ConstructionApp] First vertex: [${tan.vertices[0]?.[0]}, ${tan.vertices[0]?.[1]}] -> {x: ${polygon[0]?.x}, y: ${polygon[0]?.y}}`);
3571
3558
  return polygon;
3572
3559
  });
3573
3560
  const sectorId = `sector${index}`;
3574
- console.log(`[ConstructionApp] Assigned sector ID: ${sectorId}`);
3575
- console.log(`[ConstructionApp] Final mask has ${mask.length} polygons`);
3576
3561
  const sector = {
3577
3562
  id: sectorId,
3578
3563
  tangramId: tangramSpec.tangramID,
@@ -3581,61 +3566,37 @@ function startConstructionTrial(display_element, params, _jsPsych) {
3581
3566
  mask
3582
3567
  }
3583
3568
  };
3584
- console.log(`[ConstructionApp] Created sector:`, sector);
3585
3569
  return sector;
3586
3570
  });
3587
- console.log("\n[ConstructionApp] Final sectors array:", sectors);
3588
- console.log(`[ConstructionApp] Total sectors created: ${sectors.length}`);
3589
- console.log("\n[ConstructionApp] Processing quickstash macros...");
3590
- console.log("[ConstructionApp] quickstash_macros:", params.quickstash_macros);
3591
- console.log("[ConstructionApp] quickstash_macros count:", params.quickstash_macros?.length ?? 0);
3592
3571
  let quickstash = [];
3593
3572
  if (params.quickstash_macros && params.quickstash_macros.length > 0) {
3594
3573
  const firstMacro = params.quickstash_macros[0];
3595
- console.log("[ConstructionApp] First macro:", firstMacro);
3596
3574
  if (firstMacro && "parts" in firstMacro && firstMacro.parts && firstMacro.parts[0] && "anchorOffset" in firstMacro.parts[0]) {
3597
- console.log("[ConstructionApp] Detected anchor-based composites, converting to pixels...");
3598
3575
  const primsByKind = /* @__PURE__ */ new Map();
3599
3576
  PRIMITIVE_BLUEPRINTS.forEach((p) => primsByKind.set(p.kind, p));
3600
3577
  quickstash = params.quickstash_macros.map(
3601
3578
  (anchorComposite) => convertAnchorCompositeToPixels(anchorComposite, primsByKind, CONFIG.layout.grid.stepPx)
3602
3579
  // Use current CONFIG grid step
3603
3580
  );
3604
- console.log("[ConstructionApp] Converted to pixel-based blueprints:", quickstash);
3605
3581
  } else {
3606
- console.log("[ConstructionApp] Already pixel-based blueprints");
3607
3582
  quickstash = params.quickstash_macros;
3608
3583
  }
3609
- } else {
3610
- console.log("[ConstructionApp] No quickstash macros provided");
3611
3584
  }
3612
3585
  const gameBoardProps = {
3613
3586
  sectors,
3614
3587
  quickstash,
3615
3588
  primitives: PRIMITIVE_BLUEPRINTS,
3616
- layout: params.layout || "semicircle",
3617
- target: params.target || "silhouette",
3618
- input: params.input || "drag",
3619
- timeLimitMs: params.time_limit_ms || 0,
3589
+ layout: params.layout,
3590
+ target: params.target,
3591
+ input: params.input,
3592
+ timeLimitMs: params.time_limit_ms,
3620
3593
  maxQuickstashSlots: CONFIG.layout.defaults.maxQuickstashSlots,
3621
3594
  mode: "construction",
3622
- // Explicit construction mode
3623
3595
  ...params.onInteraction && { onInteraction: params.onInteraction },
3624
3596
  ...params.onTrialEnd && { onTrialEnd: params.onTrialEnd }
3625
3597
  };
3626
- console.log("\n[ConstructionApp] Final GameBoard props:");
3627
- console.log("[ConstructionApp] sectors count:", gameBoardProps.sectors.length);
3628
- console.log("[ConstructionApp] quickstash count:", gameBoardProps.quickstash.length);
3629
- console.log("[ConstructionApp] primitives count:", gameBoardProps.primitives.length);
3630
- console.log("[ConstructionApp] layout:", gameBoardProps.layout);
3631
- console.log("[ConstructionApp] target:", gameBoardProps.target);
3632
- console.log("[ConstructionApp] input:", gameBoardProps.input);
3633
- console.log("[ConstructionApp] timeLimitMs:", gameBoardProps.timeLimitMs);
3634
- console.log("[ConstructionApp] mode:", gameBoardProps.mode);
3635
- console.log("[ConstructionApp] Full props:", gameBoardProps);
3636
3598
  const root = createRoot(display_element);
3637
3599
  root.render(React.createElement(GameBoard, gameBoardProps));
3638
- console.log("[ConstructionApp] GameBoard rendered successfully");
3639
3600
  return { root, display_element, jsPsych: _jsPsych };
3640
3601
  }
3641
3602
 
@@ -3759,7 +3720,7 @@ class TangramConstructPlugin {
3759
3720
  target: trial.target,
3760
3721
  input: trial.input,
3761
3722
  layout: trial.layout,
3762
- time_limit_ms: trial.time_limit_ms || 0,
3723
+ time_limit_ms: trial.time_limit_ms,
3763
3724
  onInteraction: trial.onInteraction,
3764
3725
  onTrialEnd: wrappedOnTrialEnd
3765
3726
  };