jspsych-tangram 0.0.1
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.
- package/README.md +25 -0
- package/dist/construct/index.browser.js +20431 -0
- package/dist/construct/index.browser.js.map +1 -0
- package/dist/construct/index.browser.min.js +42 -0
- package/dist/construct/index.browser.min.js.map +1 -0
- package/dist/construct/index.cjs +3720 -0
- package/dist/construct/index.cjs.map +1 -0
- package/dist/construct/index.d.ts +204 -0
- package/dist/construct/index.js +3718 -0
- package/dist/construct/index.js.map +1 -0
- package/dist/index.cjs +3920 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +340 -0
- package/dist/index.js +3917 -0
- package/dist/index.js.map +1 -0
- package/dist/prep/index.browser.js +20455 -0
- package/dist/prep/index.browser.js.map +1 -0
- package/dist/prep/index.browser.min.js +42 -0
- package/dist/prep/index.browser.min.js.map +1 -0
- package/dist/prep/index.cjs +3744 -0
- package/dist/prep/index.cjs.map +1 -0
- package/dist/prep/index.d.ts +139 -0
- package/dist/prep/index.js +3742 -0
- package/dist/prep/index.js.map +1 -0
- package/package.json +77 -0
- package/src/core/components/README.md +249 -0
- package/src/core/components/board/BoardView.tsx +352 -0
- package/src/core/components/board/GameBoard.tsx +682 -0
- package/src/core/components/board/index.ts +70 -0
- package/src/core/components/board/useAnchorGrid.ts +110 -0
- package/src/core/components/board/useClickController.ts +436 -0
- package/src/core/components/board/useDragController.ts +1051 -0
- package/src/core/components/board/usePieceState.ts +178 -0
- package/src/core/components/board/utils.ts +76 -0
- package/src/core/components/index.ts +33 -0
- package/src/core/components/pieces/BlueprintRing.tsx +238 -0
- package/src/core/config/config.ts +85 -0
- package/src/core/domain/blueprints.ts +25 -0
- package/src/core/domain/layout.ts +159 -0
- package/src/core/domain/primitives.ts +159 -0
- package/src/core/domain/solve.ts +184 -0
- package/src/core/domain/types.ts +111 -0
- package/src/core/engine/collision/grid-snapping.ts +283 -0
- package/src/core/engine/collision/index.ts +4 -0
- package/src/core/engine/collision/sat-collision.ts +46 -0
- package/src/core/engine/collision/validation.ts +166 -0
- package/src/core/engine/geometry/bounds.ts +91 -0
- package/src/core/engine/geometry/collision.ts +64 -0
- package/src/core/engine/geometry/index.ts +19 -0
- package/src/core/engine/geometry/math.ts +101 -0
- package/src/core/engine/geometry/pieces.ts +290 -0
- package/src/core/engine/geometry/polygons.ts +43 -0
- package/src/core/engine/state/BaseGameController.ts +368 -0
- package/src/core/engine/validation/border-rendering.ts +318 -0
- package/src/core/engine/validation/complete.ts +102 -0
- package/src/core/engine/validation/face-to-face.ts +217 -0
- package/src/core/index.ts +3 -0
- package/src/core/io/InteractionTracker.ts +742 -0
- package/src/core/io/data-tracking.ts +271 -0
- package/src/core/io/json-to-tangram-spec.ts +110 -0
- package/src/core/io/quickstash.ts +141 -0
- package/src/core/io/stims.ts +110 -0
- package/src/core/types/index.ts +5 -0
- package/src/core/types/plugin-interfaces.ts +101 -0
- package/src/index.spec.ts +19 -0
- package/src/index.ts +2 -0
- package/src/plugins/tangram-construct/ConstructionApp.tsx +105 -0
- package/src/plugins/tangram-construct/index.ts +156 -0
- package/src/plugins/tangram-prep/PrepApp.tsx +182 -0
- package/src/plugins/tangram-prep/index.ts +122 -0
- package/tangram-construct.min.js +42 -0
- package/tangram-prep.min.js +42 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { JsPsychPlugin, ParameterType, JsPsych, TrialType } from 'jspsych';
|
|
2
|
+
|
|
3
|
+
declare const info$1: {
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
parameters: {
|
|
7
|
+
/** Array of tangram specifications defining the puzzles to solve */
|
|
8
|
+
tangrams: {
|
|
9
|
+
type: ParameterType;
|
|
10
|
+
default: undefined;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
/** Array of pre-made macro pieces from prep plugin */
|
|
14
|
+
quickstash_macros: {
|
|
15
|
+
type: ParameterType;
|
|
16
|
+
default: never[];
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
/** Whether to place pieces in workspace or directly on silhouette */
|
|
20
|
+
target: {
|
|
21
|
+
type: ParameterType;
|
|
22
|
+
options: string[];
|
|
23
|
+
default: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
/** Input method for piece manipulation */
|
|
27
|
+
input: {
|
|
28
|
+
type: ParameterType;
|
|
29
|
+
options: string[];
|
|
30
|
+
default: string;
|
|
31
|
+
description: string;
|
|
32
|
+
};
|
|
33
|
+
/** Layout style for piece arrangement */
|
|
34
|
+
layout: {
|
|
35
|
+
type: ParameterType;
|
|
36
|
+
options: string[];
|
|
37
|
+
default: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
/** Maximum time allowed for trial in milliseconds */
|
|
41
|
+
time_limit_ms: {
|
|
42
|
+
type: ParameterType;
|
|
43
|
+
default: number;
|
|
44
|
+
description: string;
|
|
45
|
+
};
|
|
46
|
+
/** Snap radius for piece placement in pixels */
|
|
47
|
+
snap_radius_px: {
|
|
48
|
+
type: ParameterType;
|
|
49
|
+
default: number;
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
/** Callback fired after each interaction (piece pickup + placedown) */
|
|
53
|
+
onInteraction: {
|
|
54
|
+
type: ParameterType;
|
|
55
|
+
default: undefined;
|
|
56
|
+
description: string;
|
|
57
|
+
};
|
|
58
|
+
/** Callback fired when trial ends */
|
|
59
|
+
onTrialEnd: {
|
|
60
|
+
type: ParameterType;
|
|
61
|
+
default: undefined;
|
|
62
|
+
description: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
data: {
|
|
66
|
+
/** Array of all interaction events during trial */
|
|
67
|
+
events: {
|
|
68
|
+
type: ParameterType;
|
|
69
|
+
description: string;
|
|
70
|
+
};
|
|
71
|
+
/** Completion time for each sector/tangram */
|
|
72
|
+
completion_times: {
|
|
73
|
+
type: ParameterType;
|
|
74
|
+
description: string;
|
|
75
|
+
};
|
|
76
|
+
/** Final completion state of each sector */
|
|
77
|
+
final_state: {
|
|
78
|
+
type: ParameterType;
|
|
79
|
+
description: string;
|
|
80
|
+
};
|
|
81
|
+
/** Usage statistics for macro pieces */
|
|
82
|
+
macros_used: {
|
|
83
|
+
type: ParameterType;
|
|
84
|
+
description: string;
|
|
85
|
+
};
|
|
86
|
+
/** Total trial duration in milliseconds */
|
|
87
|
+
trial_duration_ms: {
|
|
88
|
+
type: ParameterType;
|
|
89
|
+
description: string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
citations: string;
|
|
93
|
+
};
|
|
94
|
+
type Info$1 = typeof info$1;
|
|
95
|
+
/**
|
|
96
|
+
* **tangram-construct**
|
|
97
|
+
*
|
|
98
|
+
* A jsPsych wrapper around the React-based construction interface.
|
|
99
|
+
*
|
|
100
|
+
* @author Justin Yang & Sean Paul Anderson
|
|
101
|
+
* @see {@link https://github.com/cogtoolslab/tangram_construction.git/tree/main/experiments/jspsych-tangram-prep}
|
|
102
|
+
*/
|
|
103
|
+
declare class TangramConstructPlugin implements JsPsychPlugin<Info$1> {
|
|
104
|
+
private jsPsych;
|
|
105
|
+
static info: {
|
|
106
|
+
name: string;
|
|
107
|
+
version: string;
|
|
108
|
+
parameters: {
|
|
109
|
+
/** Array of tangram specifications defining the puzzles to solve */
|
|
110
|
+
tangrams: {
|
|
111
|
+
type: ParameterType;
|
|
112
|
+
default: undefined;
|
|
113
|
+
description: string;
|
|
114
|
+
};
|
|
115
|
+
/** Array of pre-made macro pieces from prep plugin */
|
|
116
|
+
quickstash_macros: {
|
|
117
|
+
type: ParameterType;
|
|
118
|
+
default: never[];
|
|
119
|
+
description: string;
|
|
120
|
+
};
|
|
121
|
+
/** Whether to place pieces in workspace or directly on silhouette */
|
|
122
|
+
target: {
|
|
123
|
+
type: ParameterType;
|
|
124
|
+
options: string[];
|
|
125
|
+
default: string;
|
|
126
|
+
description: string;
|
|
127
|
+
};
|
|
128
|
+
/** Input method for piece manipulation */
|
|
129
|
+
input: {
|
|
130
|
+
type: ParameterType;
|
|
131
|
+
options: string[];
|
|
132
|
+
default: string;
|
|
133
|
+
description: string;
|
|
134
|
+
};
|
|
135
|
+
/** Layout style for piece arrangement */
|
|
136
|
+
layout: {
|
|
137
|
+
type: ParameterType;
|
|
138
|
+
options: string[];
|
|
139
|
+
default: string;
|
|
140
|
+
description: string;
|
|
141
|
+
};
|
|
142
|
+
/** Maximum time allowed for trial in milliseconds */
|
|
143
|
+
time_limit_ms: {
|
|
144
|
+
type: ParameterType;
|
|
145
|
+
default: number;
|
|
146
|
+
description: string;
|
|
147
|
+
};
|
|
148
|
+
/** Snap radius for piece placement in pixels */
|
|
149
|
+
snap_radius_px: {
|
|
150
|
+
type: ParameterType;
|
|
151
|
+
default: number;
|
|
152
|
+
description: string;
|
|
153
|
+
};
|
|
154
|
+
/** Callback fired after each interaction (piece pickup + placedown) */
|
|
155
|
+
onInteraction: {
|
|
156
|
+
type: ParameterType;
|
|
157
|
+
default: undefined;
|
|
158
|
+
description: string;
|
|
159
|
+
};
|
|
160
|
+
/** Callback fired when trial ends */
|
|
161
|
+
onTrialEnd: {
|
|
162
|
+
type: ParameterType;
|
|
163
|
+
default: undefined;
|
|
164
|
+
description: string;
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
data: {
|
|
168
|
+
/** Array of all interaction events during trial */
|
|
169
|
+
events: {
|
|
170
|
+
type: ParameterType;
|
|
171
|
+
description: string;
|
|
172
|
+
};
|
|
173
|
+
/** Completion time for each sector/tangram */
|
|
174
|
+
completion_times: {
|
|
175
|
+
type: ParameterType;
|
|
176
|
+
description: string;
|
|
177
|
+
};
|
|
178
|
+
/** Final completion state of each sector */
|
|
179
|
+
final_state: {
|
|
180
|
+
type: ParameterType;
|
|
181
|
+
description: string;
|
|
182
|
+
};
|
|
183
|
+
/** Usage statistics for macro pieces */
|
|
184
|
+
macros_used: {
|
|
185
|
+
type: ParameterType;
|
|
186
|
+
description: string;
|
|
187
|
+
};
|
|
188
|
+
/** Total trial duration in milliseconds */
|
|
189
|
+
trial_duration_ms: {
|
|
190
|
+
type: ParameterType;
|
|
191
|
+
description: string;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
citations: string;
|
|
195
|
+
};
|
|
196
|
+
constructor(jsPsych: JsPsych);
|
|
197
|
+
/**
|
|
198
|
+
* Launches the trial by invoking startConstructionTrial
|
|
199
|
+
* with the display element, parameters, and jsPsych instance.
|
|
200
|
+
*/
|
|
201
|
+
trial(display_element: HTMLElement, trial: TrialType<Info$1>): void;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare const info: {
|
|
205
|
+
name: string;
|
|
206
|
+
version: string;
|
|
207
|
+
parameters: {
|
|
208
|
+
/** Number of quickstash slots for macro creation */
|
|
209
|
+
num_quickstash_slots: {
|
|
210
|
+
type: ParameterType;
|
|
211
|
+
default: undefined;
|
|
212
|
+
};
|
|
213
|
+
/** Maximum pieces allowed per macro */
|
|
214
|
+
max_pieces_per_macro: {
|
|
215
|
+
type: ParameterType;
|
|
216
|
+
default: number;
|
|
217
|
+
};
|
|
218
|
+
/** Minimum pieces required per macro */
|
|
219
|
+
min_pieces_per_macro: {
|
|
220
|
+
type: ParameterType;
|
|
221
|
+
default: number;
|
|
222
|
+
};
|
|
223
|
+
/** Input mode: click or drag */
|
|
224
|
+
input: {
|
|
225
|
+
type: ParameterType;
|
|
226
|
+
default: string;
|
|
227
|
+
};
|
|
228
|
+
/** Layout mode: circle or semicircle */
|
|
229
|
+
layout: {
|
|
230
|
+
type: ParameterType;
|
|
231
|
+
default: string;
|
|
232
|
+
};
|
|
233
|
+
/** Whether all slots must be filled to complete trial */
|
|
234
|
+
require_all_slots: {
|
|
235
|
+
type: ParameterType;
|
|
236
|
+
default: undefined;
|
|
237
|
+
};
|
|
238
|
+
/** Array of pre-made macro pieces to edit */
|
|
239
|
+
quickstash_macros: {
|
|
240
|
+
type: ParameterType;
|
|
241
|
+
default: never[];
|
|
242
|
+
description: string;
|
|
243
|
+
};
|
|
244
|
+
/** Callback fired after each interaction (optional analytics hook) */
|
|
245
|
+
onInteraction: {
|
|
246
|
+
type: ParameterType;
|
|
247
|
+
default: undefined;
|
|
248
|
+
};
|
|
249
|
+
/** Callback fired when prep trial ends */
|
|
250
|
+
onTrialEnd: {
|
|
251
|
+
type: ParameterType;
|
|
252
|
+
default: undefined;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
data: {
|
|
256
|
+
/** Completion status */
|
|
257
|
+
completed: {
|
|
258
|
+
type: ParameterType;
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
citations: string;
|
|
262
|
+
};
|
|
263
|
+
type Info = typeof info;
|
|
264
|
+
/**
|
|
265
|
+
* **tangram-prep**
|
|
266
|
+
*
|
|
267
|
+
* A jsPsych wrapper around the React-based prep interface.
|
|
268
|
+
*
|
|
269
|
+
* @author Justin Yang & Sean Paul Anderson
|
|
270
|
+
*/
|
|
271
|
+
declare class TangramPrepPlugin implements JsPsychPlugin<Info> {
|
|
272
|
+
private jsPsych;
|
|
273
|
+
static info: {
|
|
274
|
+
name: string;
|
|
275
|
+
version: string;
|
|
276
|
+
parameters: {
|
|
277
|
+
/** Number of quickstash slots for macro creation */
|
|
278
|
+
num_quickstash_slots: {
|
|
279
|
+
type: ParameterType;
|
|
280
|
+
default: undefined;
|
|
281
|
+
};
|
|
282
|
+
/** Maximum pieces allowed per macro */
|
|
283
|
+
max_pieces_per_macro: {
|
|
284
|
+
type: ParameterType;
|
|
285
|
+
default: number;
|
|
286
|
+
};
|
|
287
|
+
/** Minimum pieces required per macro */
|
|
288
|
+
min_pieces_per_macro: {
|
|
289
|
+
type: ParameterType;
|
|
290
|
+
default: number;
|
|
291
|
+
};
|
|
292
|
+
/** Input mode: click or drag */
|
|
293
|
+
input: {
|
|
294
|
+
type: ParameterType;
|
|
295
|
+
default: string;
|
|
296
|
+
};
|
|
297
|
+
/** Layout mode: circle or semicircle */
|
|
298
|
+
layout: {
|
|
299
|
+
type: ParameterType;
|
|
300
|
+
default: string;
|
|
301
|
+
};
|
|
302
|
+
/** Whether all slots must be filled to complete trial */
|
|
303
|
+
require_all_slots: {
|
|
304
|
+
type: ParameterType;
|
|
305
|
+
default: undefined;
|
|
306
|
+
};
|
|
307
|
+
/** Array of pre-made macro pieces to edit */
|
|
308
|
+
quickstash_macros: {
|
|
309
|
+
type: ParameterType;
|
|
310
|
+
default: never[];
|
|
311
|
+
description: string;
|
|
312
|
+
};
|
|
313
|
+
/** Callback fired after each interaction (optional analytics hook) */
|
|
314
|
+
onInteraction: {
|
|
315
|
+
type: ParameterType;
|
|
316
|
+
default: undefined;
|
|
317
|
+
};
|
|
318
|
+
/** Callback fired when prep trial ends */
|
|
319
|
+
onTrialEnd: {
|
|
320
|
+
type: ParameterType;
|
|
321
|
+
default: undefined;
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
data: {
|
|
325
|
+
/** Completion status */
|
|
326
|
+
completed: {
|
|
327
|
+
type: ParameterType;
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
citations: string;
|
|
331
|
+
};
|
|
332
|
+
constructor(jsPsych: JsPsych);
|
|
333
|
+
/**
|
|
334
|
+
* Launches the trial by invoking startPrepTrial
|
|
335
|
+
* with the display element, parameters, and jsPsych instance.
|
|
336
|
+
*/
|
|
337
|
+
trial(display_element: HTMLElement, trial: TrialType<Info>): void;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export { TangramConstructPlugin, TangramPrepPlugin };
|