@dreamboard-games/sdk 0.5.0-alpha.19 → 0.5.0-alpha.20
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/{chunk-BNQF7QXR.js → chunk-DMSXVMYY.js} +46 -35
- package/dist/chunk-DMSXVMYY.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/react.js +2 -1
- package/dist/react.js.map +1 -1
- package/dist/reducer.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-BNQF7QXR.js.map +0 -1
|
@@ -3733,31 +3733,56 @@ function completeAssignment(context, assignment) {
|
|
|
3733
3733
|
return { status: "no" };
|
|
3734
3734
|
}
|
|
3735
3735
|
function valueSourceForCollector(context, inputKey, collector) {
|
|
3736
|
-
const
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3736
|
+
const hasFixedValue = Object.prototype.hasOwnProperty.call(
|
|
3737
|
+
context.initialValues,
|
|
3738
|
+
inputKey
|
|
3739
|
+
);
|
|
3740
3740
|
const fixedValue = context.initialValues[inputKey];
|
|
3741
|
+
if (!collector.domain) {
|
|
3742
|
+
return hasFixedValue ? fixedCollectorValueSource(context, collector, fixedValue) : incompleteValueSource();
|
|
3743
|
+
}
|
|
3744
|
+
const domain = collector.domain(
|
|
3745
|
+
context.domainState,
|
|
3746
|
+
context.playerId,
|
|
3747
|
+
context.queries()
|
|
3748
|
+
);
|
|
3749
|
+
const base = baseValuesForDomain(domain, collector, context);
|
|
3750
|
+
const selection = collector.selection ?? domain.selection;
|
|
3751
|
+
const selected = applySelection(base, selection);
|
|
3752
|
+
const resolved = collector.schema.safeParse(void 0).success ? withAbsentCollectorValue(selected) : selected;
|
|
3753
|
+
if (!hasFixedValue) return resolved;
|
|
3754
|
+
if (selection?.mode === "many" && Array.isArray(fixedValue) && base.complete) {
|
|
3755
|
+
const keys = fixedValue.map(canonicalJson);
|
|
3756
|
+
const valid = collector.schema.safeParse(fixedValue).success && fixedValue.length >= selection.min && (selection.max === void 0 || fixedValue.length <= selection.max) && (!selection.distinct || new Set(keys).size === keys.length) && fixedValue.every((value) => sourceContainsValue(base, value));
|
|
3757
|
+
return { complete: true, values: () => valid ? [fixedValue] : [] };
|
|
3758
|
+
}
|
|
3741
3759
|
if (!resolved.complete) {
|
|
3742
3760
|
return fixedCollectorValueSource(context, collector, fixedValue);
|
|
3743
3761
|
}
|
|
3744
|
-
if (
|
|
3745
|
-
const
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
)
|
|
3749
|
-
|
|
3750
|
-
|
|
3762
|
+
if (selection?.mode === "many" && !Array.isArray(fixedValue)) {
|
|
3763
|
+
const eligible = sourceContainsValue(base, fixedValue);
|
|
3764
|
+
return {
|
|
3765
|
+
complete: true,
|
|
3766
|
+
values: function* () {
|
|
3767
|
+
if (!eligible) return;
|
|
3768
|
+
for (const candidate of resolved.values()) {
|
|
3769
|
+
if (Array.isArray(candidate) && candidate.some(
|
|
3770
|
+
(value) => canonicalJson(value) === canonicalJson(fixedValue)
|
|
3771
|
+
))
|
|
3772
|
+
yield candidate;
|
|
3773
|
+
}
|
|
3774
|
+
}
|
|
3775
|
+
};
|
|
3751
3776
|
}
|
|
3752
|
-
const matches =
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3777
|
+
const matches = sourceContainsValue(resolved, fixedValue);
|
|
3778
|
+
return { complete: true, values: () => matches ? [fixedValue] : [] };
|
|
3779
|
+
}
|
|
3780
|
+
function sourceContainsValue(source, value) {
|
|
3781
|
+
const key = canonicalJson(value);
|
|
3782
|
+
for (const candidate of source.values()) {
|
|
3783
|
+
if (canonicalJson(candidate) === key) return true;
|
|
3784
|
+
}
|
|
3785
|
+
return false;
|
|
3761
3786
|
}
|
|
3762
3787
|
function fixedCollectorValueSource(context, collector, fixedValue) {
|
|
3763
3788
|
const schemaResult = collector.schema.safeParse(fixedValue);
|
|
@@ -3777,20 +3802,6 @@ function fixedCollectorValueSource(context, collector, fixedValue) {
|
|
|
3777
3802
|
}
|
|
3778
3803
|
};
|
|
3779
3804
|
}
|
|
3780
|
-
function resolveCollectorValueSource(context, collector) {
|
|
3781
|
-
if (!collector.domain) return incompleteValueSource();
|
|
3782
|
-
const domain = collector.domain(
|
|
3783
|
-
context.domainState,
|
|
3784
|
-
context.playerId,
|
|
3785
|
-
context.queries()
|
|
3786
|
-
);
|
|
3787
|
-
const base = baseValuesForDomain(domain, collector, context);
|
|
3788
|
-
const selected = applySelection(
|
|
3789
|
-
base,
|
|
3790
|
-
collector.selection ?? domain.selection
|
|
3791
|
-
);
|
|
3792
|
-
return collector.schema.safeParse(void 0).success ? withAbsentCollectorValue(selected) : selected;
|
|
3793
|
-
}
|
|
3794
3805
|
function withAbsentCollectorValue(source) {
|
|
3795
3806
|
return {
|
|
3796
3807
|
complete: source.complete,
|
|
@@ -7185,4 +7196,4 @@ export {
|
|
|
7185
7196
|
createProjectionBuilder,
|
|
7186
7197
|
createReducerBundle
|
|
7187
7198
|
};
|
|
7188
|
-
//# sourceMappingURL=chunk-
|
|
7199
|
+
//# sourceMappingURL=chunk-DMSXVMYY.js.map
|