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.
@@ -16840,7 +16840,6 @@ var TangramConstructPlugin = (function (jspsych) {
16840
16840
  const allDone = Object.values(this.state.sectors).every((s) => !!s.completedAt);
16841
16841
  if (allDone && !this.state.endedAt) {
16842
16842
  this.state.endedAt = NOW();
16843
- console.log("[BaseGameController] all sectors complete");
16844
16843
  }
16845
16844
  }
16846
16845
  // ===== Piece Operations =====
@@ -19864,7 +19863,9 @@ var TangramConstructPlugin = (function (jspsych) {
19864
19863
  if (allSectorsComplete && !gameCompleted) {
19865
19864
  setGameCompleted(true);
19866
19865
  if (tracker) {
19867
- tracker.finalizeTrial("auto_complete");
19866
+ setTimeout(() => {
19867
+ tracker.finalizeTrial("auto_complete");
19868
+ }, 0);
19868
19869
  }
19869
19870
  }
19870
19871
  };
@@ -20257,33 +20258,17 @@ var TangramConstructPlugin = (function (jspsych) {
20257
20258
  "medtriangle",
20258
20259
  "largetriangle"
20259
20260
  ]);
20260
- console.log("[ConstructionApp] Starting tangram conversion...");
20261
- console.log("[ConstructionApp] Received tangrams:", params.tangrams);
20262
- console.log("[ConstructionApp] Number of tangrams:", params.tangrams.length);
20263
20261
  const sectors = params.tangrams.map((tangramSpec, index) => {
20264
- console.log(`
20265
- [ConstructionApp] Processing tangram ${index}:`, tangramSpec);
20266
- console.log(`[ConstructionApp] tangramID: ${tangramSpec.tangramID}`);
20267
- console.log(`[ConstructionApp] setLabel: ${tangramSpec.setLabel}`);
20268
- console.log(`[ConstructionApp] solutionTans count: ${tangramSpec.solutionTans?.length}`);
20269
- console.log(`[ConstructionApp] solutionTans:`, tangramSpec.solutionTans);
20270
20262
  const filteredTans = tangramSpec.solutionTans.filter((tan) => {
20271
20263
  const tanName = tan.name ?? tan.kind;
20272
20264
  const isCanonical = CANON.has(tanName);
20273
- console.log(`[ConstructionApp] Tan "${tanName}": canonical=${isCanonical}, vertices count=${tan.vertices?.length}`);
20274
20265
  return isCanonical;
20275
20266
  });
20276
- console.log(`[ConstructionApp] Filtered to ${filteredTans.length} canonical pieces`);
20277
20267
  const mask = filteredTans.map((tan, tanIndex) => {
20278
- const tanName = tan.name ?? tan.kind;
20279
20268
  const polygon = tan.vertices.map(([x, y]) => ({ x: x ?? 0, y: -(y ?? 0) }));
20280
- console.log(`[ConstructionApp] Polygon ${tanIndex} (${tanName}): ${tan.vertices.length} vertices -> ${polygon.length} points`);
20281
- console.log(`[ConstructionApp] First vertex: [${tan.vertices[0]?.[0]}, ${tan.vertices[0]?.[1]}] -> {x: ${polygon[0]?.x}, y: ${polygon[0]?.y}}`);
20282
20269
  return polygon;
20283
20270
  });
20284
20271
  const sectorId = `sector${index}`;
20285
- console.log(`[ConstructionApp] Assigned sector ID: ${sectorId}`);
20286
- console.log(`[ConstructionApp] Final mask has ${mask.length} polygons`);
20287
20272
  const sector = {
20288
20273
  id: sectorId,
20289
20274
  tangramId: tangramSpec.tangramID,
@@ -20292,61 +20277,37 @@ var TangramConstructPlugin = (function (jspsych) {
20292
20277
  mask
20293
20278
  }
20294
20279
  };
20295
- console.log(`[ConstructionApp] Created sector:`, sector);
20296
20280
  return sector;
20297
20281
  });
20298
- console.log("\n[ConstructionApp] Final sectors array:", sectors);
20299
- console.log(`[ConstructionApp] Total sectors created: ${sectors.length}`);
20300
- console.log("\n[ConstructionApp] Processing quickstash macros...");
20301
- console.log("[ConstructionApp] quickstash_macros:", params.quickstash_macros);
20302
- console.log("[ConstructionApp] quickstash_macros count:", params.quickstash_macros?.length ?? 0);
20303
20282
  let quickstash = [];
20304
20283
  if (params.quickstash_macros && params.quickstash_macros.length > 0) {
20305
20284
  const firstMacro = params.quickstash_macros[0];
20306
- console.log("[ConstructionApp] First macro:", firstMacro);
20307
20285
  if (firstMacro && "parts" in firstMacro && firstMacro.parts && firstMacro.parts[0] && "anchorOffset" in firstMacro.parts[0]) {
20308
- console.log("[ConstructionApp] Detected anchor-based composites, converting to pixels...");
20309
20286
  const primsByKind = /* @__PURE__ */ new Map();
20310
20287
  PRIMITIVE_BLUEPRINTS.forEach((p) => primsByKind.set(p.kind, p));
20311
20288
  quickstash = params.quickstash_macros.map(
20312
20289
  (anchorComposite) => convertAnchorCompositeToPixels(anchorComposite, primsByKind, CONFIG.layout.grid.stepPx)
20313
20290
  // Use current CONFIG grid step
20314
20291
  );
20315
- console.log("[ConstructionApp] Converted to pixel-based blueprints:", quickstash);
20316
20292
  } else {
20317
- console.log("[ConstructionApp] Already pixel-based blueprints");
20318
20293
  quickstash = params.quickstash_macros;
20319
20294
  }
20320
- } else {
20321
- console.log("[ConstructionApp] No quickstash macros provided");
20322
20295
  }
20323
20296
  const gameBoardProps = {
20324
20297
  sectors,
20325
20298
  quickstash,
20326
20299
  primitives: PRIMITIVE_BLUEPRINTS,
20327
- layout: params.layout || "semicircle",
20328
- target: params.target || "silhouette",
20329
- input: params.input || "drag",
20330
- timeLimitMs: params.time_limit_ms || 0,
20300
+ layout: params.layout,
20301
+ target: params.target,
20302
+ input: params.input,
20303
+ timeLimitMs: params.time_limit_ms,
20331
20304
  maxQuickstashSlots: CONFIG.layout.defaults.maxQuickstashSlots,
20332
20305
  mode: "construction",
20333
- // Explicit construction mode
20334
20306
  ...params.onInteraction && { onInteraction: params.onInteraction },
20335
20307
  ...params.onTrialEnd && { onTrialEnd: params.onTrialEnd }
20336
20308
  };
20337
- console.log("\n[ConstructionApp] Final GameBoard props:");
20338
- console.log("[ConstructionApp] sectors count:", gameBoardProps.sectors.length);
20339
- console.log("[ConstructionApp] quickstash count:", gameBoardProps.quickstash.length);
20340
- console.log("[ConstructionApp] primitives count:", gameBoardProps.primitives.length);
20341
- console.log("[ConstructionApp] layout:", gameBoardProps.layout);
20342
- console.log("[ConstructionApp] target:", gameBoardProps.target);
20343
- console.log("[ConstructionApp] input:", gameBoardProps.input);
20344
- console.log("[ConstructionApp] timeLimitMs:", gameBoardProps.timeLimitMs);
20345
- console.log("[ConstructionApp] mode:", gameBoardProps.mode);
20346
- console.log("[ConstructionApp] Full props:", gameBoardProps);
20347
20309
  const root = clientExports.createRoot(display_element);
20348
20310
  root.render(React.createElement(GameBoard, gameBoardProps));
20349
- console.log("[ConstructionApp] GameBoard rendered successfully");
20350
20311
  return { root, display_element, jsPsych: _jsPsych };
20351
20312
  }
20352
20313
 
@@ -20470,7 +20431,7 @@ var TangramConstructPlugin = (function (jspsych) {
20470
20431
  target: trial.target,
20471
20432
  input: trial.input,
20472
20433
  layout: trial.layout,
20473
- time_limit_ms: trial.time_limit_ms || 0,
20434
+ time_limit_ms: trial.time_limit_ms,
20474
20435
  onInteraction: trial.onInteraction,
20475
20436
  onTrialEnd: wrappedOnTrialEnd
20476
20437
  };