@dreamboard-games/sdk 0.5.0-alpha.34 → 0.5.0-alpha.36
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 +62 -41
- package/dist/{board-element-DCjHsEnF.d.ts → board-element-yXrGm5eP.d.ts} +1 -1
- package/dist/{chunk-BVWJS3AB.js → chunk-54U3ZCFA.js} +16 -7
- package/dist/chunk-54U3ZCFA.js.map +1 -0
- package/dist/{chunk-KYQQIFXN.js → chunk-75QTSYRZ.js} +317 -86
- package/dist/chunk-75QTSYRZ.js.map +1 -0
- package/dist/{chunk-CZRPUWCT.js → chunk-7GX27XU6.js} +23 -2
- package/dist/{chunk-CZRPUWCT.js.map → chunk-7GX27XU6.js.map} +1 -1
- package/dist/{chunk-BSS4ORU3.js → chunk-G4MY5YMA.js} +8 -5
- package/dist/chunk-G4MY5YMA.js.map +1 -0
- package/dist/{chunk-2GUPNL7A.js → chunk-RNR4M67F.js} +3 -3
- package/dist/{diagnostics-Cl8mSexe.d.ts → diagnostics-Bgu7w8LA.d.ts} +1 -1
- package/dist/{extract-CNUw9Q8C.d.ts → extract-_TyEXSCt.d.ts} +2 -1
- package/dist/index.d.ts +78 -78
- package/dist/index.js +5 -5
- package/dist/{model-BD0OKVEc.d.ts → model-U0F5B3cr.d.ts} +2 -2
- package/dist/react.d.ts +3 -3
- package/dist/react.js +2 -2
- package/dist/reducer.d.ts +130 -186
- package/dist/reducer.js +29 -26
- package/dist/reducer.js.map +1 -1
- package/dist/{shortcuts-Br5h9mEV.d.ts → shortcuts-DXkAlfNw.d.ts} +2 -2
- package/dist/testing.d.ts +10 -4
- package/dist/testing.js +4 -4
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-BSS4ORU3.js.map +0 -1
- package/dist/chunk-BVWJS3AB.js.map +0 -1
- package/dist/chunk-KYQQIFXN.js.map +0 -1
- /package/dist/{chunk-2GUPNL7A.js.map → chunk-RNR4M67F.js.map} +0 -0
|
@@ -1498,6 +1498,19 @@ function inputDomainErrors(domain, value, selection, options = {}) {
|
|
|
1498
1498
|
function inputValueInDomain(domain, value, selection, options = {}) {
|
|
1499
1499
|
return inputDomainErrors(domain, value, selection, options).length === 0;
|
|
1500
1500
|
}
|
|
1501
|
+
function canonicalizeInputSelection(value, selection, domain) {
|
|
1502
|
+
if (selection?.mode !== "many") return value;
|
|
1503
|
+
if (!Array.isArray(value)) return value;
|
|
1504
|
+
const values = value;
|
|
1505
|
+
const choices = domain?.type === "cardTarget" || domain?.type === "tileTarget" || domain?.type === "boardTarget" ? domain.eligibleTargets : domain?.type === "choice" ? domain.choices.map((choice) => choice.value) : [];
|
|
1506
|
+
const positions = /* @__PURE__ */ new Map();
|
|
1507
|
+
choices.forEach(
|
|
1508
|
+
(choice, index) => positions.set(inputValueKey(choice), index)
|
|
1509
|
+
);
|
|
1510
|
+
return values.map((item) => ({ item, key: inputValueKey(item) })).sort(
|
|
1511
|
+
(a, b) => (positions.get(a.key) ?? choices.length) - (positions.get(b.key) ?? choices.length) || (a.key < b.key ? -1 : a.key > b.key ? 1 : 0)
|
|
1512
|
+
).map(({ item }) => item);
|
|
1513
|
+
}
|
|
1501
1514
|
function inputTargetInDomain(domain, value) {
|
|
1502
1515
|
switch (domain.type) {
|
|
1503
1516
|
case "choice":
|
|
@@ -1545,7 +1558,14 @@ function inputValueKey(value) {
|
|
|
1545
1558
|
case "undefined":
|
|
1546
1559
|
return `${typeof value}:${String(value)}`;
|
|
1547
1560
|
default:
|
|
1548
|
-
return `json:${JSON.stringify(value)
|
|
1561
|
+
return `json:${JSON.stringify(value, (_key, item) => {
|
|
1562
|
+
if (item === null || typeof item !== "object" || Array.isArray(item))
|
|
1563
|
+
return item;
|
|
1564
|
+
const record3 = item;
|
|
1565
|
+
return Object.fromEntries(
|
|
1566
|
+
Object.keys(record3).sort().map((key) => [key, record3[key]])
|
|
1567
|
+
);
|
|
1568
|
+
})}`;
|
|
1549
1569
|
}
|
|
1550
1570
|
}
|
|
1551
1571
|
function pluralize(word, count) {
|
|
@@ -1596,7 +1616,8 @@ export {
|
|
|
1596
1616
|
sameBoardSpaceTarget,
|
|
1597
1617
|
inputDomainErrors,
|
|
1598
1618
|
inputValueInDomain,
|
|
1619
|
+
canonicalizeInputSelection,
|
|
1599
1620
|
inputTargetInDomain,
|
|
1600
1621
|
inputValueKey
|
|
1601
1622
|
};
|
|
1602
|
-
//# sourceMappingURL=chunk-
|
|
1623
|
+
//# sourceMappingURL=chunk-7GX27XU6.js.map
|