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
@@ -2655,7 +2655,9 @@ function useClickController(controller, layout, pieces, clickMode, draggingId, s
2655
2655
 
2656
2656
  class InteractionTracker {
2657
2657
  constructor(controller, callbacks, trialParams) {
2658
- this.gridStep = CONFIG.layout.grid.stepPx;
2658
+ this.completionTimes = [];
2659
+ // Sector centers (set by GameBoard after layout computation)
2660
+ this.sectorCenters = {};
2659
2661
  // Interaction state
2660
2662
  this.interactionIndex = 0;
2661
2663
  this.currentPickup = null;
@@ -2665,14 +2667,13 @@ class InteractionTracker {
2665
2667
  this.mouseTracking = [];
2666
2668
  // Interaction history (for TrialEndData)
2667
2669
  this.interactions = [];
2668
- // Construction-specific tracking
2669
- this.completionTimes = [];
2670
2670
  // Prep-specific tracking
2671
2671
  this.createdMacros = [];
2672
2672
  this.controller = controller;
2673
2673
  this.callbacks = callbacks;
2674
2674
  this.trialParams = trialParams;
2675
2675
  this.trialStartTime = Date.now();
2676
+ this.gridStep = CONFIG.layout.grid.stepPx;
2676
2677
  this.controller.setTrackingCallbacks({
2677
2678
  onSectorCompleted: (sectorId) => this.recordSectorCompletion(sectorId)
2678
2679
  });
@@ -2802,7 +2803,13 @@ class InteractionTracker {
2802
2803
  });
2803
2804
  }
2804
2805
  /**
2805
- * Record sector completion
2806
+ * Set sector centers (for anchor alignment)
2807
+ */
2808
+ setSectorCenters(centers) {
2809
+ this.sectorCenters = centers;
2810
+ }
2811
+ /**
2812
+ * Record a sector completion event
2806
2813
  */
2807
2814
  recordSectorCompletion(sectorId) {
2808
2815
  this.completionTimes.push({
@@ -2979,7 +2986,8 @@ class InteractionTracker {
2979
2986
  sectorId: sector.id,
2980
2987
  completed,
2981
2988
  pieceCount: pieces.length,
2982
- pieces
2989
+ pieces,
2990
+ center: this.sectorCenters[sector.id] ? this.toAnchorPoint(this.sectorCenters[sector.id]) : void 0
2983
2991
  };
2984
2992
  if (sectorState?.completedAt !== void 0) {
2985
2993
  snapshot.completedAt = sectorState.completedAt;
@@ -3207,6 +3215,16 @@ function GameBoard(props) {
3207
3215
  viewBox: { w: logicalBox.LOGICAL_W, h: logicalBox.LOGICAL_H }
3208
3216
  };
3209
3217
  }, [sectors, layoutMode, target, maxQuickstashSlots, primitives.length]);
3218
+ React.useEffect(() => {
3219
+ if (tracker && layout) {
3220
+ const centers = {};
3221
+ layout.sectors.forEach((s) => {
3222
+ const rect = rectForBand(layout, s, "silhouette", 1);
3223
+ centers[s.id] = { x: rect.cx, y: rect.cy };
3224
+ });
3225
+ tracker.setSectorCenters(centers);
3226
+ }
3227
+ }, [tracker, layout]);
3210
3228
  const [, force] = React.useReducer((x) => x + 1, 0);
3211
3229
  React.useEffect(() => {
3212
3230
  if (onControllerReady) {