jspsych-tangram 0.0.3 → 0.0.4

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/index.cjs CHANGED
@@ -2928,8 +2928,7 @@ class InteractionTracker {
2928
2928
  }
2929
2929
  const sectorTangramMap = this.controller.state.cfg.sectors.map((s) => ({
2930
2930
  sectorId: s.id,
2931
- tangramId: s.id
2932
- // In our system, sector ID == tangram ID
2931
+ tangramId: s.tangramId
2933
2932
  }));
2934
2933
  const blueprintOrder = {
2935
2934
  primitives: this.controller.state.primitives.map((bp) => bp.id),
@@ -3434,10 +3433,10 @@ function constructFromSpec(sideLens, angles, firstEdgeUnits) {
3434
3433
  return pts;
3435
3434
  }
3436
3435
  const FIRST_EDGES_UNITS = {
3437
- "small-triangle": [P(0, 0), P(0.5, 0.5)],
3436
+ "smalltriangle": [P(0, 0), P(0.5, 0.5)],
3438
3437
  "parallelogram": [P(0, 0), P(0.5, 0)],
3439
- "large-triangle": [P(0, 0), P(0.5, -0.5)],
3440
- "med-triangle": [P(0, 0), P(0.5, 0)],
3438
+ "largetriangle": [P(0, 0), P(0.5, -0.5)],
3439
+ "medtriangle": [P(0, 0), P(0.5, 0)],
3441
3440
  "square": [P(0, 0), P(0.5, 0)]
3442
3441
  };
3443
3442
  const PRIMITIVE_BLUEPRINTS_CACHE = (() => {
@@ -3450,8 +3449,8 @@ const PRIMITIVE_BLUEPRINTS_CACHE = (() => {
3450
3449
  color: "#f43f5e"
3451
3450
  },
3452
3451
  {
3453
- id: "prim:small",
3454
- kind: "small-triangle",
3452
+ id: "prim:smalltriangle",
3453
+ kind: "smalltriangle",
3455
3454
  sideLens: [HALFDIAGONAL, HALFDIAGONAL, HALFUNIT, HALFUNIT, HALFUNIT, HALFUNIT],
3456
3455
  angles: [180, 45, 180, 90, 180, 45],
3457
3456
  color: "#f59e0b"
@@ -3464,15 +3463,15 @@ const PRIMITIVE_BLUEPRINTS_CACHE = (() => {
3464
3463
  color: "#10b981"
3465
3464
  },
3466
3465
  {
3467
- id: "prim:med",
3468
- kind: "med-triangle",
3466
+ id: "prim:medtriangle",
3467
+ kind: "medtriangle",
3469
3468
  sideLens: [HALFUNIT, HALFUNIT, HALFUNIT, HALFUNIT, HALFDIAGONAL, HALFDIAGONAL, HALFDIAGONAL, HALFDIAGONAL],
3470
3469
  angles: [180, 180, 180, 45, 180, 90, 180, 45],
3471
3470
  color: "#3b82f6"
3472
3471
  },
3473
3472
  {
3474
- id: "prim:large",
3475
- kind: "large-triangle",
3473
+ id: "prim:largetriangle",
3474
+ kind: "largetriangle",
3476
3475
  sideLens: [
3477
3476
  HALFDIAGONAL,
3478
3477
  HALFDIAGONAL,
@@ -3544,12 +3543,11 @@ function convertAnchorCompositeToPixels(anchorComposite, primsByKind, gridStepPx
3544
3543
  function startConstructionTrial(display_element, params, _jsPsych) {
3545
3544
  const CANON = /* @__PURE__ */ new Set([
3546
3545
  "square",
3547
- "small-triangle",
3546
+ "smalltriangle",
3548
3547
  "parallelogram",
3549
- "med-triangle",
3550
- "large-triangle"
3548
+ "medtriangle",
3549
+ "largetriangle"
3551
3550
  ]);
3552
- const SECTOR_IDS = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"];
3553
3551
  console.log("[ConstructionApp] Starting tangram conversion...");
3554
3552
  console.log("[ConstructionApp] Received tangrams:", params.tangrams);
3555
3553
  console.log("[ConstructionApp] Number of tangrams:", params.tangrams.length);
@@ -3574,11 +3572,12 @@ function startConstructionTrial(display_element, params, _jsPsych) {
3574
3572
  console.log(`[ConstructionApp] First vertex: [${tan.vertices[0]?.[0]}, ${tan.vertices[0]?.[1]}] -> {x: ${polygon[0]?.x}, y: ${polygon[0]?.y}}`);
3575
3573
  return polygon;
3576
3574
  });
3577
- const sectorId = SECTOR_IDS[index] ?? `S${index}`;
3575
+ const sectorId = `sector${index}`;
3578
3576
  console.log(`[ConstructionApp] Assigned sector ID: ${sectorId}`);
3579
3577
  console.log(`[ConstructionApp] Final mask has ${mask.length} polygons`);
3580
3578
  const sector = {
3581
3579
  id: sectorId,
3580
+ tangramId: tangramSpec.tangramID,
3582
3581
  silhouette: {
3583
3582
  id: sectorId,
3584
3583
  mask
@@ -3785,6 +3784,8 @@ function startPrepTrial(display_element, params, jsPsych) {
3785
3784
  } = params;
3786
3785
  const prepSectors = Array.from({ length: numQuickstashSlots }, (_, i) => ({
3787
3786
  id: `prep-sector-${i}`,
3787
+ tangramId: `prep-sector-${i}`,
3788
+ // dummy value since prep mode doesn't have tangrams
3788
3789
  silhouette: {
3789
3790
  id: `prep-silhouette-${i}`,
3790
3791
  mask: []