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