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
@@ -20016,7 +20016,9 @@ var TangramPrepPlugin = (function (jspsych) {
20016
20016
 
20017
20017
  class InteractionTracker {
20018
20018
  constructor(controller, callbacks, trialParams) {
20019
- this.gridStep = CONFIG.layout.grid.stepPx;
20019
+ this.completionTimes = [];
20020
+ // Sector centers (set by GameBoard after layout computation)
20021
+ this.sectorCenters = {};
20020
20022
  // Interaction state
20021
20023
  this.interactionIndex = 0;
20022
20024
  this.currentPickup = null;
@@ -20026,14 +20028,13 @@ var TangramPrepPlugin = (function (jspsych) {
20026
20028
  this.mouseTracking = [];
20027
20029
  // Interaction history (for TrialEndData)
20028
20030
  this.interactions = [];
20029
- // Construction-specific tracking
20030
- this.completionTimes = [];
20031
20031
  // Prep-specific tracking
20032
20032
  this.createdMacros = [];
20033
20033
  this.controller = controller;
20034
20034
  this.callbacks = callbacks;
20035
20035
  this.trialParams = trialParams;
20036
20036
  this.trialStartTime = Date.now();
20037
+ this.gridStep = CONFIG.layout.grid.stepPx;
20037
20038
  this.controller.setTrackingCallbacks({
20038
20039
  onSectorCompleted: (sectorId) => this.recordSectorCompletion(sectorId)
20039
20040
  });
@@ -20163,7 +20164,13 @@ var TangramPrepPlugin = (function (jspsych) {
20163
20164
  });
20164
20165
  }
20165
20166
  /**
20166
- * Record sector completion
20167
+ * Set sector centers (for anchor alignment)
20168
+ */
20169
+ setSectorCenters(centers) {
20170
+ this.sectorCenters = centers;
20171
+ }
20172
+ /**
20173
+ * Record a sector completion event
20167
20174
  */
20168
20175
  recordSectorCompletion(sectorId) {
20169
20176
  this.completionTimes.push({
@@ -20340,7 +20347,8 @@ var TangramPrepPlugin = (function (jspsych) {
20340
20347
  sectorId: sector.id,
20341
20348
  completed,
20342
20349
  pieceCount: pieces.length,
20343
- pieces
20350
+ pieces,
20351
+ center: this.sectorCenters[sector.id] ? this.toAnchorPoint(this.sectorCenters[sector.id]) : void 0
20344
20352
  };
20345
20353
  if (sectorState?.completedAt !== void 0) {
20346
20354
  snapshot.completedAt = sectorState.completedAt;
@@ -20568,6 +20576,16 @@ var TangramPrepPlugin = (function (jspsych) {
20568
20576
  viewBox: { w: logicalBox.LOGICAL_W, h: logicalBox.LOGICAL_H }
20569
20577
  };
20570
20578
  }, [sectors, layoutMode, target, maxQuickstashSlots, primitives.length]);
20579
+ React.useEffect(() => {
20580
+ if (tracker && layout) {
20581
+ const centers = {};
20582
+ layout.sectors.forEach((s) => {
20583
+ const rect = rectForBand(layout, s, "silhouette", 1);
20584
+ centers[s.id] = { x: rect.cx, y: rect.cy };
20585
+ });
20586
+ tracker.setSectorCenters(centers);
20587
+ }
20588
+ }, [tracker, layout]);
20571
20589
  const [, force] = React.useReducer((x) => x + 1, 0);
20572
20590
  React.useEffect(() => {
20573
20591
  if (onControllerReady) {