jspsych-tangram 0.0.3 → 0.0.5
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/dist/construct/index.browser.js +23 -63
- package/dist/construct/index.browser.js.map +1 -1
- package/dist/construct/index.browser.min.js +11 -15
- package/dist/construct/index.browser.min.js.map +1 -1
- package/dist/construct/index.cjs +23 -63
- package/dist/construct/index.cjs.map +1 -1
- package/dist/construct/index.js +23 -63
- package/dist/construct/index.js.map +1 -1
- package/dist/index.cjs +26 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -64
- package/dist/index.js.map +1 -1
- package/dist/prep/index.browser.js +16 -14
- package/dist/prep/index.browser.js.map +1 -1
- package/dist/prep/index.browser.min.js +1 -1
- package/dist/prep/index.browser.min.js.map +1 -1
- package/dist/prep/index.cjs +16 -14
- package/dist/prep/index.cjs.map +1 -1
- package/dist/prep/index.js +16 -14
- package/dist/prep/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/components/board/GameBoard.tsx +4 -1
- package/src/core/domain/primitives.ts +9 -10
- package/src/core/domain/types.ts +4 -3
- package/src/core/engine/state/BaseGameController.ts +0 -1
- package/src/core/io/InteractionTracker.ts +1 -1
- package/src/core/io/quickstash.ts +3 -29
- package/src/core/types/plugin-interfaces.ts +1 -1
- package/src/plugins/tangram-construct/ConstructionApp.tsx +13 -58
- package/src/plugins/tangram-construct/index.ts +1 -1
- package/src/plugins/tangram-prep/PrepApp.tsx +1 -0
- package/src/plugins/tangram-prep/index.ts +1 -1
- package/tangram-construct.min.js +11 -15
- package/tangram-prep.min.js +1 -1
- package/src/core/io/stims.ts +0 -107
|
@@ -16840,7 +16840,6 @@ var TangramConstructPlugin = (function (jspsych) {
|
|
|
16840
16840
|
const allDone = Object.values(this.state.sectors).every((s) => !!s.completedAt);
|
|
16841
16841
|
if (allDone && !this.state.endedAt) {
|
|
16842
16842
|
this.state.endedAt = NOW();
|
|
16843
|
-
console.log("[BaseGameController] all sectors complete");
|
|
16844
16843
|
}
|
|
16845
16844
|
}
|
|
16846
16845
|
// ===== Piece Operations =====
|
|
@@ -19637,8 +19636,7 @@ var TangramConstructPlugin = (function (jspsych) {
|
|
|
19637
19636
|
}
|
|
19638
19637
|
const sectorTangramMap = this.controller.state.cfg.sectors.map((s) => ({
|
|
19639
19638
|
sectorId: s.id,
|
|
19640
|
-
tangramId: s.
|
|
19641
|
-
// In our system, sector ID == tangram ID
|
|
19639
|
+
tangramId: s.tangramId
|
|
19642
19640
|
}));
|
|
19643
19641
|
const blueprintOrder = {
|
|
19644
19642
|
primitives: this.controller.state.primitives.map((bp) => bp.id),
|
|
@@ -19865,7 +19863,9 @@ var TangramConstructPlugin = (function (jspsych) {
|
|
|
19865
19863
|
if (allSectorsComplete && !gameCompleted) {
|
|
19866
19864
|
setGameCompleted(true);
|
|
19867
19865
|
if (tracker) {
|
|
19868
|
-
|
|
19866
|
+
setTimeout(() => {
|
|
19867
|
+
tracker.finalizeTrial("auto_complete");
|
|
19868
|
+
}, 0);
|
|
19869
19869
|
}
|
|
19870
19870
|
}
|
|
19871
19871
|
};
|
|
@@ -20143,10 +20143,10 @@ var TangramConstructPlugin = (function (jspsych) {
|
|
|
20143
20143
|
return pts;
|
|
20144
20144
|
}
|
|
20145
20145
|
const FIRST_EDGES_UNITS = {
|
|
20146
|
-
"
|
|
20146
|
+
"smalltriangle": [P(0, 0), P(0.5, 0.5)],
|
|
20147
20147
|
"parallelogram": [P(0, 0), P(0.5, 0)],
|
|
20148
|
-
"
|
|
20149
|
-
"
|
|
20148
|
+
"largetriangle": [P(0, 0), P(0.5, -0.5)],
|
|
20149
|
+
"medtriangle": [P(0, 0), P(0.5, 0)],
|
|
20150
20150
|
"square": [P(0, 0), P(0.5, 0)]
|
|
20151
20151
|
};
|
|
20152
20152
|
const PRIMITIVE_BLUEPRINTS_CACHE = (() => {
|
|
@@ -20159,8 +20159,8 @@ var TangramConstructPlugin = (function (jspsych) {
|
|
|
20159
20159
|
color: "#f43f5e"
|
|
20160
20160
|
},
|
|
20161
20161
|
{
|
|
20162
|
-
id: "prim:
|
|
20163
|
-
kind: "
|
|
20162
|
+
id: "prim:smalltriangle",
|
|
20163
|
+
kind: "smalltriangle",
|
|
20164
20164
|
sideLens: [HALFDIAGONAL, HALFDIAGONAL, HALFUNIT, HALFUNIT, HALFUNIT, HALFUNIT],
|
|
20165
20165
|
angles: [180, 45, 180, 90, 180, 45],
|
|
20166
20166
|
color: "#f59e0b"
|
|
@@ -20173,15 +20173,15 @@ var TangramConstructPlugin = (function (jspsych) {
|
|
|
20173
20173
|
color: "#10b981"
|
|
20174
20174
|
},
|
|
20175
20175
|
{
|
|
20176
|
-
id: "prim:
|
|
20177
|
-
kind: "
|
|
20176
|
+
id: "prim:medtriangle",
|
|
20177
|
+
kind: "medtriangle",
|
|
20178
20178
|
sideLens: [HALFUNIT, HALFUNIT, HALFUNIT, HALFUNIT, HALFDIAGONAL, HALFDIAGONAL, HALFDIAGONAL, HALFDIAGONAL],
|
|
20179
20179
|
angles: [180, 180, 180, 45, 180, 90, 180, 45],
|
|
20180
20180
|
color: "#3b82f6"
|
|
20181
20181
|
},
|
|
20182
20182
|
{
|
|
20183
|
-
id: "prim:
|
|
20184
|
-
kind: "
|
|
20183
|
+
id: "prim:largetriangle",
|
|
20184
|
+
kind: "largetriangle",
|
|
20185
20185
|
sideLens: [
|
|
20186
20186
|
HALFDIAGONAL,
|
|
20187
20187
|
HALFDIAGONAL,
|
|
@@ -20253,101 +20253,61 @@ var TangramConstructPlugin = (function (jspsych) {
|
|
|
20253
20253
|
function startConstructionTrial(display_element, params, _jsPsych) {
|
|
20254
20254
|
const CANON = /* @__PURE__ */ new Set([
|
|
20255
20255
|
"square",
|
|
20256
|
-
"
|
|
20256
|
+
"smalltriangle",
|
|
20257
20257
|
"parallelogram",
|
|
20258
|
-
"
|
|
20259
|
-
"
|
|
20258
|
+
"medtriangle",
|
|
20259
|
+
"largetriangle"
|
|
20260
20260
|
]);
|
|
20261
|
-
const SECTOR_IDS = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"];
|
|
20262
|
-
console.log("[ConstructionApp] Starting tangram conversion...");
|
|
20263
|
-
console.log("[ConstructionApp] Received tangrams:", params.tangrams);
|
|
20264
|
-
console.log("[ConstructionApp] Number of tangrams:", params.tangrams.length);
|
|
20265
20261
|
const sectors = params.tangrams.map((tangramSpec, index) => {
|
|
20266
|
-
console.log(`
|
|
20267
|
-
[ConstructionApp] Processing tangram ${index}:`, tangramSpec);
|
|
20268
|
-
console.log(`[ConstructionApp] tangramID: ${tangramSpec.tangramID}`);
|
|
20269
|
-
console.log(`[ConstructionApp] setLabel: ${tangramSpec.setLabel}`);
|
|
20270
|
-
console.log(`[ConstructionApp] solutionTans count: ${tangramSpec.solutionTans?.length}`);
|
|
20271
|
-
console.log(`[ConstructionApp] solutionTans:`, tangramSpec.solutionTans);
|
|
20272
20262
|
const filteredTans = tangramSpec.solutionTans.filter((tan) => {
|
|
20273
20263
|
const tanName = tan.name ?? tan.kind;
|
|
20274
20264
|
const isCanonical = CANON.has(tanName);
|
|
20275
|
-
console.log(`[ConstructionApp] Tan "${tanName}": canonical=${isCanonical}, vertices count=${tan.vertices?.length}`);
|
|
20276
20265
|
return isCanonical;
|
|
20277
20266
|
});
|
|
20278
|
-
console.log(`[ConstructionApp] Filtered to ${filteredTans.length} canonical pieces`);
|
|
20279
20267
|
const mask = filteredTans.map((tan, tanIndex) => {
|
|
20280
|
-
const tanName = tan.name ?? tan.kind;
|
|
20281
20268
|
const polygon = tan.vertices.map(([x, y]) => ({ x: x ?? 0, y: -(y ?? 0) }));
|
|
20282
|
-
console.log(`[ConstructionApp] Polygon ${tanIndex} (${tanName}): ${tan.vertices.length} vertices -> ${polygon.length} points`);
|
|
20283
|
-
console.log(`[ConstructionApp] First vertex: [${tan.vertices[0]?.[0]}, ${tan.vertices[0]?.[1]}] -> {x: ${polygon[0]?.x}, y: ${polygon[0]?.y}}`);
|
|
20284
20269
|
return polygon;
|
|
20285
20270
|
});
|
|
20286
|
-
const sectorId =
|
|
20287
|
-
console.log(`[ConstructionApp] Assigned sector ID: ${sectorId}`);
|
|
20288
|
-
console.log(`[ConstructionApp] Final mask has ${mask.length} polygons`);
|
|
20271
|
+
const sectorId = `sector${index}`;
|
|
20289
20272
|
const sector = {
|
|
20290
20273
|
id: sectorId,
|
|
20274
|
+
tangramId: tangramSpec.tangramID,
|
|
20291
20275
|
silhouette: {
|
|
20292
20276
|
id: sectorId,
|
|
20293
20277
|
mask
|
|
20294
20278
|
}
|
|
20295
20279
|
};
|
|
20296
|
-
console.log(`[ConstructionApp] Created sector:`, sector);
|
|
20297
20280
|
return sector;
|
|
20298
20281
|
});
|
|
20299
|
-
console.log("\n[ConstructionApp] Final sectors array:", sectors);
|
|
20300
|
-
console.log(`[ConstructionApp] Total sectors created: ${sectors.length}`);
|
|
20301
|
-
console.log("\n[ConstructionApp] Processing quickstash macros...");
|
|
20302
|
-
console.log("[ConstructionApp] quickstash_macros:", params.quickstash_macros);
|
|
20303
|
-
console.log("[ConstructionApp] quickstash_macros count:", params.quickstash_macros?.length ?? 0);
|
|
20304
20282
|
let quickstash = [];
|
|
20305
20283
|
if (params.quickstash_macros && params.quickstash_macros.length > 0) {
|
|
20306
20284
|
const firstMacro = params.quickstash_macros[0];
|
|
20307
|
-
console.log("[ConstructionApp] First macro:", firstMacro);
|
|
20308
20285
|
if (firstMacro && "parts" in firstMacro && firstMacro.parts && firstMacro.parts[0] && "anchorOffset" in firstMacro.parts[0]) {
|
|
20309
|
-
console.log("[ConstructionApp] Detected anchor-based composites, converting to pixels...");
|
|
20310
20286
|
const primsByKind = /* @__PURE__ */ new Map();
|
|
20311
20287
|
PRIMITIVE_BLUEPRINTS.forEach((p) => primsByKind.set(p.kind, p));
|
|
20312
20288
|
quickstash = params.quickstash_macros.map(
|
|
20313
20289
|
(anchorComposite) => convertAnchorCompositeToPixels(anchorComposite, primsByKind, CONFIG.layout.grid.stepPx)
|
|
20314
20290
|
// Use current CONFIG grid step
|
|
20315
20291
|
);
|
|
20316
|
-
console.log("[ConstructionApp] Converted to pixel-based blueprints:", quickstash);
|
|
20317
20292
|
} else {
|
|
20318
|
-
console.log("[ConstructionApp] Already pixel-based blueprints");
|
|
20319
20293
|
quickstash = params.quickstash_macros;
|
|
20320
20294
|
}
|
|
20321
|
-
} else {
|
|
20322
|
-
console.log("[ConstructionApp] No quickstash macros provided");
|
|
20323
20295
|
}
|
|
20324
20296
|
const gameBoardProps = {
|
|
20325
20297
|
sectors,
|
|
20326
20298
|
quickstash,
|
|
20327
20299
|
primitives: PRIMITIVE_BLUEPRINTS,
|
|
20328
|
-
layout: params.layout
|
|
20329
|
-
target: params.target
|
|
20330
|
-
input: params.input
|
|
20331
|
-
timeLimitMs: params.time_limit_ms
|
|
20300
|
+
layout: params.layout,
|
|
20301
|
+
target: params.target,
|
|
20302
|
+
input: params.input,
|
|
20303
|
+
timeLimitMs: params.time_limit_ms,
|
|
20332
20304
|
maxQuickstashSlots: CONFIG.layout.defaults.maxQuickstashSlots,
|
|
20333
20305
|
mode: "construction",
|
|
20334
|
-
// Explicit construction mode
|
|
20335
20306
|
...params.onInteraction && { onInteraction: params.onInteraction },
|
|
20336
20307
|
...params.onTrialEnd && { onTrialEnd: params.onTrialEnd }
|
|
20337
20308
|
};
|
|
20338
|
-
console.log("\n[ConstructionApp] Final GameBoard props:");
|
|
20339
|
-
console.log("[ConstructionApp] sectors count:", gameBoardProps.sectors.length);
|
|
20340
|
-
console.log("[ConstructionApp] quickstash count:", gameBoardProps.quickstash.length);
|
|
20341
|
-
console.log("[ConstructionApp] primitives count:", gameBoardProps.primitives.length);
|
|
20342
|
-
console.log("[ConstructionApp] layout:", gameBoardProps.layout);
|
|
20343
|
-
console.log("[ConstructionApp] target:", gameBoardProps.target);
|
|
20344
|
-
console.log("[ConstructionApp] input:", gameBoardProps.input);
|
|
20345
|
-
console.log("[ConstructionApp] timeLimitMs:", gameBoardProps.timeLimitMs);
|
|
20346
|
-
console.log("[ConstructionApp] mode:", gameBoardProps.mode);
|
|
20347
|
-
console.log("[ConstructionApp] Full props:", gameBoardProps);
|
|
20348
20309
|
const root = clientExports.createRoot(display_element);
|
|
20349
20310
|
root.render(React.createElement(GameBoard, gameBoardProps));
|
|
20350
|
-
console.log("[ConstructionApp] GameBoard rendered successfully");
|
|
20351
20311
|
return { root, display_element, jsPsych: _jsPsych };
|
|
20352
20312
|
}
|
|
20353
20313
|
|
|
@@ -20471,7 +20431,7 @@ var TangramConstructPlugin = (function (jspsych) {
|
|
|
20471
20431
|
target: trial.target,
|
|
20472
20432
|
input: trial.input,
|
|
20473
20433
|
layout: trial.layout,
|
|
20474
|
-
time_limit_ms: trial.time_limit_ms
|
|
20434
|
+
time_limit_ms: trial.time_limit_ms,
|
|
20475
20435
|
onInteraction: trial.onInteraction,
|
|
20476
20436
|
onTrialEnd: wrappedOnTrialEnd
|
|
20477
20437
|
};
|