jspsych-tangram 0.0.5 → 0.0.6

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.
@@ -40,6 +40,12 @@ declare const info: {
40
40
  default: never[];
41
41
  description: string;
42
42
  };
43
+ /** Array of primitive names in the order they should be displayed */
44
+ primitive_order: {
45
+ type: ParameterType;
46
+ default: string[];
47
+ description: string;
48
+ };
43
49
  /** Callback fired after each interaction (optional analytics hook) */
44
50
  onInteraction: {
45
51
  type: ParameterType;
@@ -109,6 +115,12 @@ declare class TangramPrepPlugin implements JsPsychPlugin<Info> {
109
115
  default: never[];
110
116
  description: string;
111
117
  };
118
+ /** Array of primitive names in the order they should be displayed */
119
+ primitive_order: {
120
+ type: ParameterType;
121
+ default: string[];
122
+ description: string;
123
+ };
112
124
  /** Callback fired after each interaction (optional analytics hook) */
113
125
  onInteraction: {
114
126
  type: ParameterType;
@@ -3548,9 +3548,11 @@ function startPrepTrial(display_element, params, jsPsych) {
3548
3548
  layoutMode,
3549
3549
  requireAllSlots,
3550
3550
  quickstashMacros,
3551
+ primitiveOrder,
3551
3552
  onInteraction,
3552
3553
  onTrialEnd
3553
3554
  } = params;
3555
+ const PRIMITIVE_BLUEPRINTS_ORDERED = [...PRIMITIVE_BLUEPRINTS].sort((a, b) => primitiveOrder.indexOf(a.kind) - primitiveOrder.indexOf(b.kind));
3554
3556
  const prepSectors = Array.from({ length: numQuickstashSlots }, (_, i) => ({
3555
3557
  id: `prep-sector-${i}`,
3556
3558
  tangramId: `prep-sector-${i}`,
@@ -3564,7 +3566,7 @@ function startPrepTrial(display_element, params, jsPsych) {
3564
3566
  const handleControllerReady = (controller, layout, force) => {
3565
3567
  if (quickstashMacros && quickstashMacros.length > 0 && layout) {
3566
3568
  const primsByKind = /* @__PURE__ */ new Map();
3567
- PRIMITIVE_BLUEPRINTS.forEach((p) => primsByKind.set(p.kind, p));
3569
+ PRIMITIVE_BLUEPRINTS_ORDERED.forEach((p) => primsByKind.set(p.kind, p));
3568
3570
  quickstashMacros.forEach((anchorComposite, macroIndex) => {
3569
3571
  const sectorId = `prep-sector-${macroIndex}`;
3570
3572
  const compositeBlueprint = convertAnchorCompositeToPixels(
@@ -3621,7 +3623,7 @@ function startPrepTrial(display_element, params, jsPsych) {
3621
3623
  sectors: prepSectors,
3622
3624
  quickstash: [],
3623
3625
  // No pre-made macros
3624
- primitives: PRIMITIVE_BLUEPRINTS,
3626
+ primitives: PRIMITIVE_BLUEPRINTS_ORDERED,
3625
3627
  layout: layoutMode,
3626
3628
  target: "workspace",
3627
3629
  // Pieces go in sectors
@@ -3682,6 +3684,12 @@ const info = {
3682
3684
  default: [],
3683
3685
  description: "Array of AnchorComposite objects to edit as primitive pieces"
3684
3686
  },
3687
+ /** Array of primitive names in the order they should be displayed */
3688
+ primitive_order: {
3689
+ type: ParameterType.OBJECT,
3690
+ default: ["square", "smalltriangle", "parallelogram", "medtriangle", "largetriangle"],
3691
+ description: "Array of primitive names in the order they should be displayed"
3692
+ },
3685
3693
  /** Callback fired after each interaction (optional analytics hook) */
3686
3694
  onInteraction: {
3687
3695
  type: ParameterType.FUNCTION,
@@ -3732,6 +3740,7 @@ class TangramPrepPlugin {
3732
3740
  layoutMode: trial.layout,
3733
3741
  requireAllSlots: trial.require_all_slots,
3734
3742
  quickstashMacros: trial.quickstash_macros,
3743
+ primitiveOrder: trial.primitive_order,
3735
3744
  onInteraction: trial.onInteraction,
3736
3745
  onTrialEnd: wrappedOnTrialEnd
3737
3746
  };