jspsych-tangram 0.0.16 → 0.0.18

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 (39) hide show
  1. package/dist/construct/index.browser.js +23 -5
  2. package/dist/construct/index.browser.js.map +1 -1
  3. package/dist/construct/index.browser.min.js +8 -8
  4. package/dist/construct/index.browser.min.js.map +1 -1
  5. package/dist/construct/index.cjs +23 -5
  6. package/dist/construct/index.cjs.map +1 -1
  7. package/dist/construct/index.js +23 -5
  8. package/dist/construct/index.js.map +1 -1
  9. package/dist/grid/index.browser.js +17855 -0
  10. package/dist/grid/index.browser.js.map +1 -0
  11. package/dist/grid/index.browser.min.js +47 -0
  12. package/dist/grid/index.browser.min.js.map +1 -0
  13. package/dist/grid/index.cjs +547 -0
  14. package/dist/grid/index.cjs.map +1 -0
  15. package/dist/grid/index.d.ts +174 -0
  16. package/dist/grid/index.js +545 -0
  17. package/dist/grid/index.js.map +1 -0
  18. package/dist/index.cjs +548 -13
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.ts +187 -16
  21. package/dist/index.js +549 -15
  22. package/dist/index.js.map +1 -1
  23. package/dist/prep/index.browser.js +23 -5
  24. package/dist/prep/index.browser.js.map +1 -1
  25. package/dist/prep/index.browser.min.js +6 -6
  26. package/dist/prep/index.browser.min.js.map +1 -1
  27. package/dist/prep/index.cjs +23 -5
  28. package/dist/prep/index.cjs.map +1 -1
  29. package/dist/prep/index.js +23 -5
  30. package/dist/prep/index.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/core/components/board/GameBoard.tsx +12 -0
  33. package/src/core/io/InteractionTracker.ts +19 -7
  34. package/src/core/io/data-tracking.ts +5 -0
  35. package/src/index.ts +2 -1
  36. package/src/plugins/tangram-grid/GridApp.tsx +522 -0
  37. package/src/plugins/tangram-grid/index.ts +154 -0
  38. package/tangram-construct.min.js +8 -8
  39. package/tangram-prep.min.js +6 -6
@@ -2653,7 +2653,9 @@ function useClickController(controller, layout, pieces, clickMode, draggingId, s
2653
2653
 
2654
2654
  class InteractionTracker {
2655
2655
  constructor(controller, callbacks, trialParams) {
2656
- this.gridStep = CONFIG.layout.grid.stepPx;
2656
+ this.completionTimes = [];
2657
+ // Sector centers (set by GameBoard after layout computation)
2658
+ this.sectorCenters = {};
2657
2659
  // Interaction state
2658
2660
  this.interactionIndex = 0;
2659
2661
  this.currentPickup = null;
@@ -2663,14 +2665,13 @@ class InteractionTracker {
2663
2665
  this.mouseTracking = [];
2664
2666
  // Interaction history (for TrialEndData)
2665
2667
  this.interactions = [];
2666
- // Construction-specific tracking
2667
- this.completionTimes = [];
2668
2668
  // Prep-specific tracking
2669
2669
  this.createdMacros = [];
2670
2670
  this.controller = controller;
2671
2671
  this.callbacks = callbacks;
2672
2672
  this.trialParams = trialParams;
2673
2673
  this.trialStartTime = Date.now();
2674
+ this.gridStep = CONFIG.layout.grid.stepPx;
2674
2675
  this.controller.setTrackingCallbacks({
2675
2676
  onSectorCompleted: (sectorId) => this.recordSectorCompletion(sectorId)
2676
2677
  });
@@ -2800,7 +2801,13 @@ class InteractionTracker {
2800
2801
  });
2801
2802
  }
2802
2803
  /**
2803
- * Record sector completion
2804
+ * Set sector centers (for anchor alignment)
2805
+ */
2806
+ setSectorCenters(centers) {
2807
+ this.sectorCenters = centers;
2808
+ }
2809
+ /**
2810
+ * Record a sector completion event
2804
2811
  */
2805
2812
  recordSectorCompletion(sectorId) {
2806
2813
  this.completionTimes.push({
@@ -2977,7 +2984,8 @@ class InteractionTracker {
2977
2984
  sectorId: sector.id,
2978
2985
  completed,
2979
2986
  pieceCount: pieces.length,
2980
- pieces
2987
+ pieces,
2988
+ center: this.sectorCenters[sector.id] ? this.toAnchorPoint(this.sectorCenters[sector.id]) : void 0
2981
2989
  };
2982
2990
  if (sectorState?.completedAt !== void 0) {
2983
2991
  snapshot.completedAt = sectorState.completedAt;
@@ -3205,6 +3213,16 @@ function GameBoard(props) {
3205
3213
  viewBox: { w: logicalBox.LOGICAL_W, h: logicalBox.LOGICAL_H }
3206
3214
  };
3207
3215
  }, [sectors, layoutMode, target, maxQuickstashSlots, primitives.length]);
3216
+ React.useEffect(() => {
3217
+ if (tracker && layout) {
3218
+ const centers = {};
3219
+ layout.sectors.forEach((s) => {
3220
+ const rect = rectForBand(layout, s, "silhouette", 1);
3221
+ centers[s.id] = { x: rect.cx, y: rect.cy };
3222
+ });
3223
+ tracker.setSectorCenters(centers);
3224
+ }
3225
+ }, [tracker, layout]);
3208
3226
  const [, force] = React.useReducer((x) => x + 1, 0);
3209
3227
  React.useEffect(() => {
3210
3228
  if (onControllerReady) {