jspsych-tangram 0.0.16 → 0.0.17

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.
Files changed (44) hide show
  1. package/dist/afc/index.browser.js +3897 -4514
  2. package/dist/afc/index.browser.js.map +1 -1
  3. package/dist/afc/index.browser.min.js +12 -12
  4. package/dist/afc/index.browser.min.js.map +1 -1
  5. package/dist/afc/index.cjs +39 -4
  6. package/dist/afc/index.cjs.map +1 -1
  7. package/dist/afc/index.js +39 -4
  8. package/dist/afc/index.js.map +1 -1
  9. package/dist/construct/index.browser.js +3892 -4522
  10. package/dist/construct/index.browser.js.map +1 -1
  11. package/dist/construct/index.browser.min.js +13 -13
  12. package/dist/construct/index.browser.min.js.map +1 -1
  13. package/dist/construct/index.cjs +31 -9
  14. package/dist/construct/index.cjs.map +1 -1
  15. package/dist/construct/index.js +31 -9
  16. package/dist/construct/index.js.map +1 -1
  17. package/dist/index.cjs +31 -9
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.js +31 -9
  20. package/dist/index.js.map +1 -1
  21. package/dist/nback/index.browser.js +3897 -4514
  22. package/dist/nback/index.browser.js.map +1 -1
  23. package/dist/nback/index.browser.min.js +12 -12
  24. package/dist/nback/index.browser.min.js.map +1 -1
  25. package/dist/nback/index.cjs +39 -4
  26. package/dist/nback/index.cjs.map +1 -1
  27. package/dist/nback/index.js +39 -4
  28. package/dist/nback/index.js.map +1 -1
  29. package/dist/prep/index.browser.js +3163 -3791
  30. package/dist/prep/index.browser.js.map +1 -1
  31. package/dist/prep/index.browser.min.js +13 -13
  32. package/dist/prep/index.browser.min.js.map +1 -1
  33. package/dist/prep/index.cjs +34 -10
  34. package/dist/prep/index.cjs.map +1 -1
  35. package/dist/prep/index.js +34 -10
  36. package/dist/prep/index.js.map +1 -1
  37. package/package.json +1 -1
  38. package/src/core/components/board/GameBoard.tsx +12 -0
  39. package/src/core/io/InteractionTracker.ts +19 -7
  40. package/src/core/io/data-tracking.ts +5 -0
  41. package/tangram-afc.min.js +12 -12
  42. package/tangram-construct.min.js +13 -13
  43. package/tangram-nback.min.js +12 -12
  44. package/tangram-prep.min.js +13 -13
@@ -14,8 +14,9 @@ const CONFIG = {
14
14
  silhouetteMask: "#374151",
15
15
  anchors: { invalid: "#7dd3fc", valid: "#475569" },
16
16
  // validFill used here for placed composites
17
- piece: { draggingFill: "#8e7cc3", validFill: "#8e7cc3", invalidFill: "#d55c00", invalidStroke: "#dc2626", allGreenStroke: "#86efac"},
18
- blueprint: { fill: "#374151", badgeFill: "#000000", labelFill: "#ffffff" },
17
+ piece: { draggingFill: "#8e7cc3", validFill: "#8e7cc3", invalidFill: "#d55c00", invalidStroke: "#dc2626", selectedStroke: "#674ea7", allGreenStroke: "#86efac", borderStroke: "#674ea7" },
18
+ ui: { light: "#60a5fa", dark: "#1d4ed8" },
19
+ blueprint: { fill: "#374151", selectedStroke: "#111827", badgeFill: "#000000", labelFill: "#ffffff" },
19
20
  tangramDecomposition: { stroke: "#fef2cc" },
20
21
  primitiveColors: [
21
22
  // from seaborn "colorblind" palette, 6 colors, with red omitted
@@ -34,7 +35,7 @@ const CONFIG = {
34
35
  piece: { invalid: 1, dragging: 1, locked: 1, normal: 1 }
35
36
  },
36
37
  size: {
37
- stroke: { bandPx: 5, allGreenStrokePx: 10, tangramDecompositionPx: 1 },
38
+ stroke: { bandPx: 5, pieceSelectedPx: 5, allGreenStrokePx: 10, pieceBorderPx: 2, tangramDecompositionPx: 1 },
38
39
  anchorRadiusPx: { valid: 1, invalid: 1 },
39
40
  badgeFontPx: 16,
40
41
  centerBadge: { fractionOfOuterR: 0.15, minPx: 20, marginPx: 4 },
@@ -55,7 +56,10 @@ const CONFIG = {
55
56
  },
56
57
  game: {
57
58
  snapRadiusPx: 15,
58
- showBorders: false}
59
+ showBorders: false,
60
+ hideTouchingBorders: true,
61
+ silhouettesBelowPieces: true
62
+ }
59
63
  };
60
64
 
61
65
  function isComposite(bp) {
@@ -2655,7 +2659,9 @@ function useClickController(controller, layout, pieces, clickMode, draggingId, s
2655
2659
 
2656
2660
  class InteractionTracker {
2657
2661
  constructor(controller, callbacks, trialParams) {
2658
- this.gridStep = CONFIG.layout.grid.stepPx;
2662
+ this.completionTimes = [];
2663
+ // Sector centers (set by GameBoard after layout computation)
2664
+ this.sectorCenters = {};
2659
2665
  // Interaction state
2660
2666
  this.interactionIndex = 0;
2661
2667
  this.currentPickup = null;
@@ -2665,14 +2671,13 @@ class InteractionTracker {
2665
2671
  this.mouseTracking = [];
2666
2672
  // Interaction history (for TrialEndData)
2667
2673
  this.interactions = [];
2668
- // Construction-specific tracking
2669
- this.completionTimes = [];
2670
2674
  // Prep-specific tracking
2671
2675
  this.createdMacros = [];
2672
2676
  this.controller = controller;
2673
2677
  this.callbacks = callbacks;
2674
2678
  this.trialParams = trialParams;
2675
2679
  this.trialStartTime = Date.now();
2680
+ this.gridStep = CONFIG.layout.grid.stepPx;
2676
2681
  this.controller.setTrackingCallbacks({
2677
2682
  onSectorCompleted: (sectorId) => this.recordSectorCompletion(sectorId)
2678
2683
  });
@@ -2802,7 +2807,13 @@ class InteractionTracker {
2802
2807
  });
2803
2808
  }
2804
2809
  /**
2805
- * Record sector completion
2810
+ * Set sector centers (for anchor alignment)
2811
+ */
2812
+ setSectorCenters(centers) {
2813
+ this.sectorCenters = centers;
2814
+ }
2815
+ /**
2816
+ * Record a sector completion event
2806
2817
  */
2807
2818
  recordSectorCompletion(sectorId) {
2808
2819
  this.completionTimes.push({
@@ -2979,7 +2990,8 @@ class InteractionTracker {
2979
2990
  sectorId: sector.id,
2980
2991
  completed,
2981
2992
  pieceCount: pieces.length,
2982
- pieces
2993
+ pieces,
2994
+ center: this.sectorCenters[sector.id] ? this.toAnchorPoint(this.sectorCenters[sector.id]) : void 0
2983
2995
  };
2984
2996
  if (sectorState?.completedAt !== void 0) {
2985
2997
  snapshot.completedAt = sectorState.completedAt;
@@ -3207,6 +3219,16 @@ function GameBoard(props) {
3207
3219
  viewBox: { w: logicalBox.LOGICAL_W, h: logicalBox.LOGICAL_H }
3208
3220
  };
3209
3221
  }, [sectors, layoutMode, target, maxQuickstashSlots, primitives.length]);
3222
+ React.useEffect(() => {
3223
+ if (tracker && layout) {
3224
+ const centers = {};
3225
+ layout.sectors.forEach((s) => {
3226
+ const rect = rectForBand(layout, s, "silhouette", 1);
3227
+ centers[s.id] = { x: rect.cx, y: rect.cy };
3228
+ });
3229
+ tracker.setSectorCenters(centers);
3230
+ }
3231
+ }, [tracker, layout]);
3210
3232
  const [, force] = React.useReducer((x) => x + 1, 0);
3211
3233
  React.useEffect(() => {
3212
3234
  if (onControllerReady) {