jspsych-tangram 0.0.4 → 0.0.6

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,18 @@ 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);
20261
+ const PRIMITIVE_BLUEPRINTS_ORDERED = [...PRIMITIVE_BLUEPRINTS].sort((a, b) => params.primitiveOrder.indexOf(a.kind) - params.primitiveOrder.indexOf(b.kind));
20263
20262
  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
20263
  const filteredTans = tangramSpec.solutionTans.filter((tan) => {
20271
20264
  const tanName = tan.name ?? tan.kind;
20272
20265
  const isCanonical = CANON.has(tanName);
20273
- console.log(`[ConstructionApp] Tan "${tanName}": canonical=${isCanonical}, vertices count=${tan.vertices?.length}`);
20274
20266
  return isCanonical;
20275
20267
  });
20276
- console.log(`[ConstructionApp] Filtered to ${filteredTans.length} canonical pieces`);
20277
20268
  const mask = filteredTans.map((tan, tanIndex) => {
20278
- const tanName = tan.name ?? tan.kind;
20279
20269
  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
20270
  return polygon;
20283
20271
  });
20284
20272
  const sectorId = `sector${index}`;
20285
- console.log(`[ConstructionApp] Assigned sector ID: ${sectorId}`);
20286
- console.log(`[ConstructionApp] Final mask has ${mask.length} polygons`);
20287
20273
  const sector = {
20288
20274
  id: sectorId,
20289
20275
  tangramId: tangramSpec.tangramID,
@@ -20292,61 +20278,37 @@ var TangramConstructPlugin = (function (jspsych) {
20292
20278
  mask
20293
20279
  }
20294
20280
  };
20295
- console.log(`[ConstructionApp] Created sector:`, sector);
20296
20281
  return sector;
20297
20282
  });
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
20283
  let quickstash = [];
20304
20284
  if (params.quickstash_macros && params.quickstash_macros.length > 0) {
20305
20285
  const firstMacro = params.quickstash_macros[0];
20306
- console.log("[ConstructionApp] First macro:", firstMacro);
20307
20286
  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
20287
  const primsByKind = /* @__PURE__ */ new Map();
20310
- PRIMITIVE_BLUEPRINTS.forEach((p) => primsByKind.set(p.kind, p));
20288
+ PRIMITIVE_BLUEPRINTS_ORDERED.forEach((p) => primsByKind.set(p.kind, p));
20311
20289
  quickstash = params.quickstash_macros.map(
20312
20290
  (anchorComposite) => convertAnchorCompositeToPixels(anchorComposite, primsByKind, CONFIG.layout.grid.stepPx)
20313
20291
  // Use current CONFIG grid step
20314
20292
  );
20315
- console.log("[ConstructionApp] Converted to pixel-based blueprints:", quickstash);
20316
20293
  } else {
20317
- console.log("[ConstructionApp] Already pixel-based blueprints");
20318
20294
  quickstash = params.quickstash_macros;
20319
20295
  }
20320
- } else {
20321
- console.log("[ConstructionApp] No quickstash macros provided");
20322
20296
  }
20323
20297
  const gameBoardProps = {
20324
20298
  sectors,
20325
20299
  quickstash,
20326
- 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
+ primitives: PRIMITIVE_BLUEPRINTS_ORDERED,
20301
+ layout: params.layout,
20302
+ target: params.target,
20303
+ input: params.input,
20304
+ timeLimitMs: params.time_limit_ms,
20331
20305
  maxQuickstashSlots: CONFIG.layout.defaults.maxQuickstashSlots,
20332
20306
  mode: "construction",
20333
- // Explicit construction mode
20334
20307
  ...params.onInteraction && { onInteraction: params.onInteraction },
20335
20308
  ...params.onTrialEnd && { onTrialEnd: params.onTrialEnd }
20336
20309
  };
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
20310
  const root = clientExports.createRoot(display_element);
20348
20311
  root.render(React.createElement(GameBoard, gameBoardProps));
20349
- console.log("[ConstructionApp] GameBoard rendered successfully");
20350
20312
  return { root, display_element, jsPsych: _jsPsych };
20351
20313
  }
20352
20314
 
@@ -20366,6 +20328,12 @@ var TangramConstructPlugin = (function (jspsych) {
20366
20328
  default: [],
20367
20329
  description: "Array of MacroSpec objects created in prep trial"
20368
20330
  },
20331
+ /** Array of primitive names in the order they should be displayed */
20332
+ primitive_order: {
20333
+ type: jspsych.ParameterType.OBJECT,
20334
+ default: ["square", "smalltriangle", "parallelogram", "medtriangle", "largetriangle"],
20335
+ description: "Array of primitive names in the order they should be displayed"
20336
+ },
20369
20337
  /** Whether to place pieces in workspace or directly on silhouette */
20370
20338
  target: {
20371
20339
  type: jspsych.ParameterType.SELECT,
@@ -20467,10 +20435,11 @@ var TangramConstructPlugin = (function (jspsych) {
20467
20435
  const params = {
20468
20436
  tangrams: trial.tangrams,
20469
20437
  quickstash_macros: trial.quickstash_macros,
20438
+ primitiveOrder: trial.primitive_order,
20470
20439
  target: trial.target,
20471
20440
  input: trial.input,
20472
20441
  layout: trial.layout,
20473
- time_limit_ms: trial.time_limit_ms || 0,
20442
+ time_limit_ms: trial.time_limit_ms,
20474
20443
  onInteraction: trial.onInteraction,
20475
20444
  onTrialEnd: wrappedOnTrialEnd
20476
20445
  };