@doenet/v06-to-v07 0.7.20-dev.319 → 0.7.20-dev.321
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/{index-CyEKEyxP.js → index-D7QB7nkv.js} +1933 -1877
- package/{index-CyEKEyxP.js.map → index-D7QB7nkv.js.map} +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/{sha256-C0vj3HDn-BN2lLQ1h-1QSWShIW.js → sha256-C0vj3HDn-BWgi3hyU-CUhpeiV-.js} +2 -2
- package/{sha256-C0vj3HDn-BN2lLQ1h-1QSWShIW.js.map → sha256-C0vj3HDn-BWgi3hyU-CUhpeiV-.js.map} +1 -1
|
@@ -40963,7 +40963,7 @@ async function cidFromArrayBuffer(data) {
|
|
|
40963
40963
|
await crypto.subtle.digest("SHA-256", new Uint8Array());
|
|
40964
40964
|
digest = (data2) => crypto.subtle.digest("SHA-256", data2);
|
|
40965
40965
|
} catch (e22) {
|
|
40966
|
-
const sha256 = (await import("./sha256-C0vj3HDn-
|
|
40966
|
+
const sha256 = (await import("./sha256-C0vj3HDn-BWgi3hyU-CUhpeiV-.js").then((n2) => n2.s)).default;
|
|
40967
40967
|
digest = (data2) => sha256(data2, {
|
|
40968
40968
|
asBytes: true
|
|
40969
40969
|
});
|
|
@@ -49611,1088 +49611,6 @@ function recursivelyReplaceCompositesWithReplacements({
|
|
|
49611
49611
|
unexpandedCompositesNotReady
|
|
49612
49612
|
};
|
|
49613
49613
|
}
|
|
49614
|
-
const PRIMITIVE_TO_COMPONENT_TYPE = {
|
|
49615
|
-
string: "text",
|
|
49616
|
-
stringArray: "textList",
|
|
49617
|
-
numberArray: "numberList"
|
|
49618
|
-
};
|
|
49619
|
-
const SHARED_STATE_VARIABLE_DEFINITIONS = /* @__PURE__ */ Symbol(
|
|
49620
|
-
"sharedStateVariableDefinitions"
|
|
49621
|
-
);
|
|
49622
|
-
const classStateVariableDefinitionsCache = /* @__PURE__ */ new WeakMap();
|
|
49623
|
-
function getClassStateVariableDefinitions(core2, componentClass) {
|
|
49624
|
-
let perCore = classStateVariableDefinitionsCache.get(core2);
|
|
49625
|
-
if (!perCore) {
|
|
49626
|
-
perCore = /* @__PURE__ */ new Map();
|
|
49627
|
-
classStateVariableDefinitionsCache.set(core2, perCore);
|
|
49628
|
-
}
|
|
49629
|
-
let entry = perCore.get(componentClass);
|
|
49630
|
-
if (!entry) {
|
|
49631
|
-
const combined = {};
|
|
49632
|
-
createAttributeStateVariableDefinitions({
|
|
49633
|
-
core: core2,
|
|
49634
|
-
stateVariableDefinitions: combined,
|
|
49635
|
-
componentClass
|
|
49636
|
-
});
|
|
49637
|
-
const normalized = componentClass.returnNormalizedStateVariableDefinitions(
|
|
49638
|
-
core2.numerics
|
|
49639
|
-
);
|
|
49640
|
-
Object.assign(combined, normalized);
|
|
49641
|
-
combined[SHARED_STATE_VARIABLE_DEFINITIONS] = true;
|
|
49642
|
-
entry = { combined, normalized };
|
|
49643
|
-
perCore.set(componentClass, entry);
|
|
49644
|
-
}
|
|
49645
|
-
return entry;
|
|
49646
|
-
}
|
|
49647
|
-
function cloneStateVariableDefinition(def) {
|
|
49648
|
-
const clone2 = Object.assign({}, def);
|
|
49649
|
-
if (clone2.shadowingInstructions) {
|
|
49650
|
-
clone2.shadowingInstructions = Object.assign(
|
|
49651
|
-
{},
|
|
49652
|
-
clone2.shadowingInstructions
|
|
49653
|
-
);
|
|
49654
|
-
}
|
|
49655
|
-
if (clone2.additionalStateVariablesDefined) {
|
|
49656
|
-
clone2.additionalStateVariablesDefined = [
|
|
49657
|
-
...clone2.additionalStateVariablesDefined
|
|
49658
|
-
];
|
|
49659
|
-
}
|
|
49660
|
-
if (clone2.stateVariablesDeterminingDependencies) {
|
|
49661
|
-
clone2.stateVariablesDeterminingDependencies = [
|
|
49662
|
-
...clone2.stateVariablesDeterminingDependencies
|
|
49663
|
-
];
|
|
49664
|
-
}
|
|
49665
|
-
return clone2;
|
|
49666
|
-
}
|
|
49667
|
-
async function createStateVariableDefinitions({
|
|
49668
|
-
core: core2,
|
|
49669
|
-
componentClass,
|
|
49670
|
-
prescribedDependencies,
|
|
49671
|
-
componentIdx
|
|
49672
|
-
}) {
|
|
49673
|
-
let redefineDependencies;
|
|
49674
|
-
if (prescribedDependencies) {
|
|
49675
|
-
for (const idxStr in prescribedDependencies) {
|
|
49676
|
-
const idx = Number(idxStr);
|
|
49677
|
-
let depArray = prescribedDependencies[idx];
|
|
49678
|
-
for (let dep of depArray) {
|
|
49679
|
-
if (dep.dependencyType === "referenceShadow") {
|
|
49680
|
-
if (idx === componentIdx) {
|
|
49681
|
-
throw Error(
|
|
49682
|
-
`Circular dependency involving ${componentIdx}.`
|
|
49683
|
-
);
|
|
49684
|
-
}
|
|
49685
|
-
redefineDependencies = {
|
|
49686
|
-
linkSource: "referenceShadow",
|
|
49687
|
-
targetIdx: idx,
|
|
49688
|
-
compositeIdx: dep.compositeIdx,
|
|
49689
|
-
propVariable: dep.propVariable,
|
|
49690
|
-
fromImplicitProp: dep.fromImplicitProp,
|
|
49691
|
-
arrayStateVariable: dep.arrayStateVariable,
|
|
49692
|
-
arrayKey: dep.arrayKey,
|
|
49693
|
-
ignorePrimaryStateVariable: dep.ignorePrimaryStateVariable,
|
|
49694
|
-
substituteForPrimaryStateVariable: dep.substituteForPrimaryStateVariable,
|
|
49695
|
-
firstLevelReplacement: dep.firstLevelReplacement,
|
|
49696
|
-
additionalStateVariableShadowing: dep.additionalStateVariableShadowing
|
|
49697
|
-
};
|
|
49698
|
-
} else if (dep.dependencyType === "adapter") {
|
|
49699
|
-
redefineDependencies = {
|
|
49700
|
-
linkSource: "adapter",
|
|
49701
|
-
adapterTargetIdentity: dep.adapterTargetIdentity,
|
|
49702
|
-
adapterVariable: dep.adapterVariable,
|
|
49703
|
-
substituteForPrimaryStateVariable: dep.substituteForPrimaryStateVariable,
|
|
49704
|
-
stateVariablesToShadow: dep.stateVariablesToShadow
|
|
49705
|
-
};
|
|
49706
|
-
}
|
|
49707
|
-
}
|
|
49708
|
-
}
|
|
49709
|
-
}
|
|
49710
|
-
const classDefinitions = getClassStateVariableDefinitions(
|
|
49711
|
-
core2,
|
|
49712
|
-
componentClass
|
|
49713
|
-
);
|
|
49714
|
-
if (!redefineDependencies) {
|
|
49715
|
-
return classDefinitions.combined;
|
|
49716
|
-
}
|
|
49717
|
-
let stateVariableDefinitions = {};
|
|
49718
|
-
for (const varName in classDefinitions.normalized) {
|
|
49719
|
-
stateVariableDefinitions[varName] = cloneStateVariableDefinition(
|
|
49720
|
-
classDefinitions.normalized[varName]
|
|
49721
|
-
);
|
|
49722
|
-
}
|
|
49723
|
-
if (redefineDependencies.linkSource === "adapter") {
|
|
49724
|
-
createAdapterStateVariableDefinitions({
|
|
49725
|
-
core: core2,
|
|
49726
|
-
redefineDependencies,
|
|
49727
|
-
stateVariableDefinitions,
|
|
49728
|
-
componentClass
|
|
49729
|
-
});
|
|
49730
|
-
} else {
|
|
49731
|
-
await createReferenceShadowStateVariableDefinitions({
|
|
49732
|
-
core: core2,
|
|
49733
|
-
redefineDependencies,
|
|
49734
|
-
stateVariableDefinitions,
|
|
49735
|
-
componentClass
|
|
49736
|
-
});
|
|
49737
|
-
}
|
|
49738
|
-
return stateVariableDefinitions;
|
|
49739
|
-
}
|
|
49740
|
-
function createAttributeStateVariableDefinitions({
|
|
49741
|
-
core: core2,
|
|
49742
|
-
componentClass,
|
|
49743
|
-
stateVariableDefinitions
|
|
49744
|
-
}) {
|
|
49745
|
-
let attributes = preprocessAttributesObject(
|
|
49746
|
-
componentClass.createAttributesObject()
|
|
49747
|
-
);
|
|
49748
|
-
for (let attrName in attributes) {
|
|
49749
|
-
let attributeSpecification = attributes[attrName];
|
|
49750
|
-
if (!attributeSpecification.createStateVariable) {
|
|
49751
|
-
continue;
|
|
49752
|
-
}
|
|
49753
|
-
let varName = attributeSpecification.createStateVariable;
|
|
49754
|
-
let stateVarDef = stateVariableDefinitions[varName] = {
|
|
49755
|
-
isAttribute: true,
|
|
49756
|
-
hasEssential: true,
|
|
49757
|
-
provideEssentialValuesInDefinition: true
|
|
49758
|
-
};
|
|
49759
|
-
if (attributeSpecification.public) {
|
|
49760
|
-
_setShadowingInstructionsFromAttribute(
|
|
49761
|
-
stateVarDef,
|
|
49762
|
-
attributeSpecification
|
|
49763
|
-
);
|
|
49764
|
-
}
|
|
49765
|
-
let stateVariableForAttributeValue = _resolveAttributeValueVariable(
|
|
49766
|
-
core2,
|
|
49767
|
-
attributeSpecification,
|
|
49768
|
-
attrName,
|
|
49769
|
-
componentClass
|
|
49770
|
-
);
|
|
49771
|
-
stateVarDef.returnDependencies = function() {
|
|
49772
|
-
return {
|
|
49773
|
-
..._buildAttributeFallbackDependencies(attributeSpecification),
|
|
49774
|
-
..._buildAttributeValueDependency(
|
|
49775
|
-
attributeSpecification,
|
|
49776
|
-
attrName,
|
|
49777
|
-
stateVariableForAttributeValue
|
|
49778
|
-
)
|
|
49779
|
-
};
|
|
49780
|
-
};
|
|
49781
|
-
const { definition, inverseDefinition } = _buildAttributeDerivedDefinitions({
|
|
49782
|
-
varName,
|
|
49783
|
-
stateVariableForAttributeValue,
|
|
49784
|
-
attributeSpecification,
|
|
49785
|
-
attrName
|
|
49786
|
-
});
|
|
49787
|
-
stateVarDef.definition = definition;
|
|
49788
|
-
if (!attributeSpecification.noInverse) {
|
|
49789
|
-
stateVarDef.inverseDefinition = inverseDefinition;
|
|
49790
|
-
}
|
|
49791
|
-
_copyPassthroughAttributes(stateVarDef, attributeSpecification, {
|
|
49792
|
-
includeTriggerActionOnChange: true
|
|
49793
|
-
});
|
|
49794
|
-
}
|
|
49795
|
-
}
|
|
49796
|
-
function createAdapterStateVariableDefinitions({
|
|
49797
|
-
core: core2,
|
|
49798
|
-
redefineDependencies,
|
|
49799
|
-
stateVariableDefinitions,
|
|
49800
|
-
componentClass
|
|
49801
|
-
}) {
|
|
49802
|
-
let adapterTargetComponent = core2._components[redefineDependencies.adapterTargetIdentity.componentIdx];
|
|
49803
|
-
let attributes = preprocessAttributesObject(
|
|
49804
|
-
componentClass.createAttributesObject()
|
|
49805
|
-
);
|
|
49806
|
-
for (let attrName in attributes) {
|
|
49807
|
-
let attributeSpecification = attributes[attrName];
|
|
49808
|
-
if (!attributeSpecification.createStateVariable) {
|
|
49809
|
-
continue;
|
|
49810
|
-
}
|
|
49811
|
-
let varName = attributeSpecification.createStateVariable;
|
|
49812
|
-
let stateVarDef = stateVariableDefinitions[varName] = {
|
|
49813
|
-
isAttribute: true,
|
|
49814
|
-
hasEssential: true
|
|
49815
|
-
};
|
|
49816
|
-
if (attributeSpecification.public) {
|
|
49817
|
-
_setShadowingInstructionsFromAttribute(
|
|
49818
|
-
stateVarDef,
|
|
49819
|
-
attributeSpecification
|
|
49820
|
-
);
|
|
49821
|
-
}
|
|
49822
|
-
if (varName in adapterTargetComponent.state) {
|
|
49823
|
-
stateVarDef.returnDependencies = () => ({
|
|
49824
|
-
adapterTargetVariable: {
|
|
49825
|
-
dependencyType: "stateVariable",
|
|
49826
|
-
componentIdx: redefineDependencies.adapterTargetIdentity.componentIdx,
|
|
49827
|
-
variableName: varName
|
|
49828
|
-
}
|
|
49829
|
-
});
|
|
49830
|
-
} else {
|
|
49831
|
-
stateVarDef.returnDependencies = () => ({});
|
|
49832
|
-
}
|
|
49833
|
-
stateVarDef.definition = function({ dependencyValues, usedDefault }) {
|
|
49834
|
-
if (dependencyValues.adapterTargetVariable === void 0 || usedDefault.adapterTargetVariable) {
|
|
49835
|
-
return {
|
|
49836
|
-
useEssentialOrDefaultValue: {
|
|
49837
|
-
[varName]: true
|
|
49838
|
-
},
|
|
49839
|
-
checkForActualChange: { [varName]: true }
|
|
49840
|
-
};
|
|
49841
|
-
} else {
|
|
49842
|
-
return {
|
|
49843
|
-
setValue: {
|
|
49844
|
-
[varName]: dependencyValues.adapterTargetVariable
|
|
49845
|
-
},
|
|
49846
|
-
checkForActualChange: { [varName]: true }
|
|
49847
|
-
};
|
|
49848
|
-
}
|
|
49849
|
-
};
|
|
49850
|
-
if (!attributeSpecification.noInverse) {
|
|
49851
|
-
stateVarDef.inverseDefinition = async function({
|
|
49852
|
-
desiredStateVariableValues,
|
|
49853
|
-
dependencyValues
|
|
49854
|
-
}) {
|
|
49855
|
-
if (dependencyValues.adapterTargetVariable === void 0) {
|
|
49856
|
-
return {
|
|
49857
|
-
success: true,
|
|
49858
|
-
instructions: [
|
|
49859
|
-
{
|
|
49860
|
-
setEssentialValue: varName,
|
|
49861
|
-
value: desiredStateVariableValues[varName]
|
|
49862
|
-
}
|
|
49863
|
-
]
|
|
49864
|
-
};
|
|
49865
|
-
} else {
|
|
49866
|
-
return {
|
|
49867
|
-
success: true,
|
|
49868
|
-
instructions: [
|
|
49869
|
-
{
|
|
49870
|
-
setDependency: "adapterTargetVariable",
|
|
49871
|
-
desiredValue: desiredStateVariableValues[varName]
|
|
49872
|
-
}
|
|
49873
|
-
]
|
|
49874
|
-
};
|
|
49875
|
-
}
|
|
49876
|
-
};
|
|
49877
|
-
}
|
|
49878
|
-
_copyPassthroughAttributes(stateVarDef, attributeSpecification);
|
|
49879
|
-
}
|
|
49880
|
-
const { name: primaryStateVariableForDefinition, stateDef } = _resolvePrimaryStateVariableForDefinition({
|
|
49881
|
-
redefineDependencies,
|
|
49882
|
-
componentClass,
|
|
49883
|
-
stateVariableDefinitions,
|
|
49884
|
-
throwIfMissing: false
|
|
49885
|
-
});
|
|
49886
|
-
stateDef.isShadow = true;
|
|
49887
|
-
stateDef.returnDependencies = () => ({
|
|
49888
|
-
adapterTargetVariable: {
|
|
49889
|
-
dependencyType: "stateVariable",
|
|
49890
|
-
componentIdx: redefineDependencies.adapterTargetIdentity.componentIdx,
|
|
49891
|
-
variableName: redefineDependencies.adapterVariable
|
|
49892
|
-
}
|
|
49893
|
-
});
|
|
49894
|
-
if (stateDef.set) {
|
|
49895
|
-
stateDef.definition = function({ dependencyValues }) {
|
|
49896
|
-
return {
|
|
49897
|
-
setValue: {
|
|
49898
|
-
[primaryStateVariableForDefinition]: stateDef.set(
|
|
49899
|
-
dependencyValues.adapterTargetVariable
|
|
49900
|
-
)
|
|
49901
|
-
}
|
|
49902
|
-
};
|
|
49903
|
-
};
|
|
49904
|
-
} else {
|
|
49905
|
-
stateDef.definition = function({ dependencyValues }) {
|
|
49906
|
-
return {
|
|
49907
|
-
setValue: {
|
|
49908
|
-
[primaryStateVariableForDefinition]: dependencyValues.adapterTargetVariable
|
|
49909
|
-
}
|
|
49910
|
-
};
|
|
49911
|
-
};
|
|
49912
|
-
}
|
|
49913
|
-
stateDef.inverseDefinition = function({ desiredStateVariableValues }) {
|
|
49914
|
-
return {
|
|
49915
|
-
success: true,
|
|
49916
|
-
instructions: [
|
|
49917
|
-
{
|
|
49918
|
-
setDependency: "adapterTargetVariable",
|
|
49919
|
-
desiredValue: desiredStateVariableValues[primaryStateVariableForDefinition]
|
|
49920
|
-
}
|
|
49921
|
-
]
|
|
49922
|
-
};
|
|
49923
|
-
};
|
|
49924
|
-
if (redefineDependencies.stateVariablesToShadow) {
|
|
49925
|
-
modifyStateDefsToBeShadows({
|
|
49926
|
-
stateVariablesToShadow: redefineDependencies.stateVariablesToShadow,
|
|
49927
|
-
stateVariableDefinitions,
|
|
49928
|
-
targetComponent: adapterTargetComponent
|
|
49929
|
-
});
|
|
49930
|
-
}
|
|
49931
|
-
}
|
|
49932
|
-
async function createReferenceShadowStateVariableDefinitions({
|
|
49933
|
-
core: core2,
|
|
49934
|
-
redefineDependencies,
|
|
49935
|
-
stateVariableDefinitions,
|
|
49936
|
-
componentClass
|
|
49937
|
-
}) {
|
|
49938
|
-
let targetComponent = core2._components[redefineDependencies.targetIdx];
|
|
49939
|
-
if (redefineDependencies.propVariable) {
|
|
49940
|
-
if (!targetComponent.state[redefineDependencies.propVariable] && core2.checkIfArrayEntry({
|
|
49941
|
-
stateVariable: redefineDependencies.propVariable,
|
|
49942
|
-
component: targetComponent
|
|
49943
|
-
}).isArrayEntry) {
|
|
49944
|
-
await core2.createFromArrayEntry({
|
|
49945
|
-
stateVariable: redefineDependencies.propVariable,
|
|
49946
|
-
component: targetComponent
|
|
49947
|
-
});
|
|
49948
|
-
}
|
|
49949
|
-
}
|
|
49950
|
-
let attributes = preprocessAttributesObject(
|
|
49951
|
-
componentClass.createAttributesObject()
|
|
49952
|
-
);
|
|
49953
|
-
for (let attrName in attributes) {
|
|
49954
|
-
let attributeSpecification = attributes[attrName];
|
|
49955
|
-
let varName = attributeSpecification.createStateVariable;
|
|
49956
|
-
if (!varName) {
|
|
49957
|
-
continue;
|
|
49958
|
-
}
|
|
49959
|
-
let stateVarDef = stateVariableDefinitions[varName] = {
|
|
49960
|
-
isAttribute: true,
|
|
49961
|
-
hasEssential: true,
|
|
49962
|
-
provideEssentialValuesInDefinition: true
|
|
49963
|
-
};
|
|
49964
|
-
!attributeSpecification.createComponentOfType;
|
|
49965
|
-
if (attributeSpecification.public) {
|
|
49966
|
-
_setShadowingInstructionsFromAttribute(
|
|
49967
|
-
stateVarDef,
|
|
49968
|
-
attributeSpecification
|
|
49969
|
-
);
|
|
49970
|
-
}
|
|
49971
|
-
let stateVariableForAttributeValue = _resolveAttributeValueVariable(
|
|
49972
|
-
core2,
|
|
49973
|
-
attributeSpecification,
|
|
49974
|
-
attrName,
|
|
49975
|
-
componentClass
|
|
49976
|
-
);
|
|
49977
|
-
const thisDependencies = {
|
|
49978
|
-
..._buildAttributeValueDependency(
|
|
49979
|
-
attributeSpecification,
|
|
49980
|
-
attrName,
|
|
49981
|
-
stateVariableForAttributeValue
|
|
49982
|
-
),
|
|
49983
|
-
..._buildAttributeFallbackDependencies(attributeSpecification)
|
|
49984
|
-
};
|
|
49985
|
-
stateVarDef.returnDependencies = () => thisDependencies;
|
|
49986
|
-
const { definition, inverseDefinition } = _buildAttributeDerivedDefinitions({
|
|
49987
|
-
varName,
|
|
49988
|
-
stateVariableForAttributeValue,
|
|
49989
|
-
attributeSpecification,
|
|
49990
|
-
attrName
|
|
49991
|
-
});
|
|
49992
|
-
stateVarDef.definition = definition;
|
|
49993
|
-
if (!attributeSpecification.noInverse) {
|
|
49994
|
-
stateVarDef.inverseDefinition = inverseDefinition;
|
|
49995
|
-
}
|
|
49996
|
-
_copyPassthroughAttributes(stateVarDef, attributeSpecification);
|
|
49997
|
-
}
|
|
49998
|
-
if (redefineDependencies.propVariable) {
|
|
49999
|
-
if (!redefineDependencies.ignorePrimaryStateVariable) {
|
|
50000
|
-
const { name: primaryStateVariableForDefinition, stateDef } = _resolvePrimaryStateVariableForDefinition({
|
|
50001
|
-
redefineDependencies,
|
|
50002
|
-
componentClass,
|
|
50003
|
-
stateVariableDefinitions,
|
|
50004
|
-
throwIfMissing: true
|
|
50005
|
-
});
|
|
50006
|
-
stateDef.isShadow = true;
|
|
50007
|
-
stateDef.returnDependencies = () => ({
|
|
50008
|
-
targetVariable: {
|
|
50009
|
-
dependencyType: "stateVariable",
|
|
50010
|
-
componentIdx: targetComponent.componentIdx,
|
|
50011
|
-
variableName: redefineDependencies.propVariable
|
|
50012
|
-
}
|
|
50013
|
-
});
|
|
50014
|
-
let setDefault = false;
|
|
50015
|
-
if (targetComponent.state[redefineDependencies.propVariable].defaultValue !== void 0) {
|
|
50016
|
-
stateDef.defaultValue = targetComponent.state[redefineDependencies.propVariable].defaultValue;
|
|
50017
|
-
if (stateDef.set) {
|
|
50018
|
-
stateDef.defaultValue = stateDef.set(stateDef.defaultValue);
|
|
50019
|
-
}
|
|
50020
|
-
stateDef.hasEssential = true;
|
|
50021
|
-
setDefault = true;
|
|
50022
|
-
}
|
|
50023
|
-
let targetVariableIsArray = targetComponent.state[redefineDependencies.propVariable].isArray;
|
|
50024
|
-
if (stateDef.set) {
|
|
50025
|
-
stateDef.definition = function({
|
|
50026
|
-
dependencyValues,
|
|
50027
|
-
usedDefault
|
|
50028
|
-
}) {
|
|
50029
|
-
let targetVariable = dependencyValues.targetVariable;
|
|
50030
|
-
if (targetVariable === void 0 || targetVariableIsArray && targetVariable.length === 0) {
|
|
50031
|
-
return {
|
|
50032
|
-
useEssentialOrDefaultValue: {
|
|
50033
|
-
[primaryStateVariableForDefinition]: true
|
|
50034
|
-
}
|
|
50035
|
-
};
|
|
50036
|
-
}
|
|
50037
|
-
let valueFromTarget = stateDef.set(targetVariable);
|
|
50038
|
-
if (setDefault && usedDefault.targetVariable) {
|
|
50039
|
-
return {
|
|
50040
|
-
useEssentialOrDefaultValue: {
|
|
50041
|
-
[primaryStateVariableForDefinition]: {
|
|
50042
|
-
defaultValue: valueFromTarget
|
|
50043
|
-
}
|
|
50044
|
-
}
|
|
50045
|
-
};
|
|
50046
|
-
}
|
|
50047
|
-
return {
|
|
50048
|
-
setValue: {
|
|
50049
|
-
[primaryStateVariableForDefinition]: valueFromTarget
|
|
50050
|
-
}
|
|
50051
|
-
};
|
|
50052
|
-
};
|
|
50053
|
-
} else {
|
|
50054
|
-
stateDef.definition = function({
|
|
50055
|
-
dependencyValues,
|
|
50056
|
-
usedDefault
|
|
50057
|
-
}) {
|
|
50058
|
-
let targetVariable = dependencyValues.targetVariable;
|
|
50059
|
-
if (targetVariable === void 0 || targetVariableIsArray && targetVariable.length === 0) {
|
|
50060
|
-
return {
|
|
50061
|
-
useEssentialOrDefaultValue: {
|
|
50062
|
-
[primaryStateVariableForDefinition]: true
|
|
50063
|
-
}
|
|
50064
|
-
};
|
|
50065
|
-
}
|
|
50066
|
-
if (setDefault && usedDefault.targetVariable) {
|
|
50067
|
-
return {
|
|
50068
|
-
useEssentialOrDefaultValue: {
|
|
50069
|
-
[primaryStateVariableForDefinition]: {
|
|
50070
|
-
defaultValue: targetVariable
|
|
50071
|
-
}
|
|
50072
|
-
}
|
|
50073
|
-
};
|
|
50074
|
-
}
|
|
50075
|
-
return {
|
|
50076
|
-
setValue: {
|
|
50077
|
-
[primaryStateVariableForDefinition]: targetVariable
|
|
50078
|
-
}
|
|
50079
|
-
};
|
|
50080
|
-
};
|
|
50081
|
-
}
|
|
50082
|
-
stateDef.inverseDefinition = function({
|
|
50083
|
-
desiredStateVariableValues
|
|
50084
|
-
}) {
|
|
50085
|
-
return {
|
|
50086
|
-
success: true,
|
|
50087
|
-
instructions: [
|
|
50088
|
-
{
|
|
50089
|
-
setDependency: "targetVariable",
|
|
50090
|
-
desiredValue: desiredStateVariableValues[primaryStateVariableForDefinition]
|
|
50091
|
-
}
|
|
50092
|
-
]
|
|
50093
|
-
};
|
|
50094
|
-
};
|
|
50095
|
-
}
|
|
50096
|
-
let shadowStandardVariables = false;
|
|
50097
|
-
let stateVariablesToShadow2 = [];
|
|
50098
|
-
if (targetComponent.constructor.implicitPropReturnsSameType) {
|
|
50099
|
-
if (redefineDependencies.fromImplicitProp) {
|
|
50100
|
-
shadowStandardVariables = true;
|
|
50101
|
-
}
|
|
50102
|
-
for (let varName in targetComponent.state) {
|
|
50103
|
-
let stateObj = targetComponent.state[varName];
|
|
50104
|
-
if (stateObj.shadowVariable || stateObj.isShadow) {
|
|
50105
|
-
stateVariablesToShadow2.push(varName);
|
|
50106
|
-
}
|
|
50107
|
-
}
|
|
50108
|
-
}
|
|
50109
|
-
if (redefineDependencies.additionalStateVariableShadowing) {
|
|
50110
|
-
let differentStateVariablesInTarget = Array(
|
|
50111
|
-
stateVariablesToShadow2.length
|
|
50112
|
-
);
|
|
50113
|
-
for (let varName in redefineDependencies.additionalStateVariableShadowing) {
|
|
50114
|
-
if (!stateVariablesToShadow2.includes(varName)) {
|
|
50115
|
-
stateVariablesToShadow2.push(varName);
|
|
50116
|
-
differentStateVariablesInTarget.push(
|
|
50117
|
-
redefineDependencies.additionalStateVariableShadowing[varName].stateVariableToShadow
|
|
50118
|
-
);
|
|
50119
|
-
}
|
|
50120
|
-
}
|
|
50121
|
-
modifyStateDefsToBeShadows({
|
|
50122
|
-
stateVariablesToShadow: stateVariablesToShadow2,
|
|
50123
|
-
stateVariableDefinitions,
|
|
50124
|
-
targetComponent,
|
|
50125
|
-
differentStateVariablesInTarget
|
|
50126
|
-
});
|
|
50127
|
-
} else if (shadowStandardVariables) {
|
|
50128
|
-
modifyStateDefsToBeShadows({
|
|
50129
|
-
stateVariablesToShadow: stateVariablesToShadow2,
|
|
50130
|
-
stateVariableDefinitions,
|
|
50131
|
-
targetComponent
|
|
50132
|
-
});
|
|
50133
|
-
}
|
|
50134
|
-
return;
|
|
50135
|
-
}
|
|
50136
|
-
let foundReadyToExpandWhenResolved = false;
|
|
50137
|
-
if ("readyToExpandWhenResolved" in stateVariableDefinitions) {
|
|
50138
|
-
foundReadyToExpandWhenResolved = true;
|
|
50139
|
-
let stateDef = stateVariableDefinitions.readyToExpandWhenResolved;
|
|
50140
|
-
let originalReturnDependencies = stateDef.returnDependencies.bind(stateDef);
|
|
50141
|
-
let originalDefinition = stateDef.definition;
|
|
50142
|
-
stateDef.returnDependencies = function(args) {
|
|
50143
|
-
let dependencies2 = originalReturnDependencies(args);
|
|
50144
|
-
dependencies2.targetReadyToExpandWhenResolved = {
|
|
50145
|
-
dependencyType: "stateVariable",
|
|
50146
|
-
componentIdx: targetComponent.componentIdx,
|
|
50147
|
-
variableName: "readyToExpandWhenResolved"
|
|
50148
|
-
};
|
|
50149
|
-
return dependencies2;
|
|
50150
|
-
};
|
|
50151
|
-
stateDef.definition = function(args) {
|
|
50152
|
-
let result2 = originalDefinition(args);
|
|
50153
|
-
if (result2.setValue && result2.setValue.readyToExpandWhenResolved) {
|
|
50154
|
-
if (!args.dependencyValues.targetReadyToExpandWhenResolved) {
|
|
50155
|
-
result2.setValue.readyToExpandWhenResolved = false;
|
|
50156
|
-
}
|
|
50157
|
-
}
|
|
50158
|
-
return result2;
|
|
50159
|
-
};
|
|
50160
|
-
}
|
|
50161
|
-
let stateVariablesToShadow = [];
|
|
50162
|
-
for (let varName in targetComponent.state) {
|
|
50163
|
-
let stateObj = targetComponent.state[varName];
|
|
50164
|
-
if (stateObj.shadowVariable || stateObj.isShadow) {
|
|
50165
|
-
stateVariablesToShadow.push(varName);
|
|
50166
|
-
}
|
|
50167
|
-
}
|
|
50168
|
-
modifyStateDefsToBeShadows({
|
|
50169
|
-
stateVariablesToShadow,
|
|
50170
|
-
stateVariableDefinitions,
|
|
50171
|
-
foundReadyToExpandWhenResolved,
|
|
50172
|
-
targetComponent
|
|
50173
|
-
});
|
|
50174
|
-
}
|
|
50175
|
-
function shadowReturnDependencies(args) {
|
|
50176
|
-
let dependencies2 = Object.assign(
|
|
50177
|
-
{},
|
|
50178
|
-
this.shadowOriginalReturnDependencies?.(args)
|
|
50179
|
-
);
|
|
50180
|
-
dependencies2.targetVariable = {
|
|
50181
|
-
dependencyType: "stateVariable",
|
|
50182
|
-
componentIdx: this.shadowOfComponentIdx,
|
|
50183
|
-
variableName: this.shadowVarNameInTarget
|
|
50184
|
-
};
|
|
50185
|
-
if (this.shadowCopyComponentType) {
|
|
50186
|
-
dependencies2.targetVariableComponentType = {
|
|
50187
|
-
dependencyType: "stateVariableComponentType",
|
|
50188
|
-
componentIdx: this.shadowOfComponentIdx,
|
|
50189
|
-
variableName: this.shadowVarNameInTarget
|
|
50190
|
-
};
|
|
50191
|
-
}
|
|
50192
|
-
return dependencies2;
|
|
50193
|
-
}
|
|
50194
|
-
function shadowDefinition({ dependencyValues, usedDefault }) {
|
|
50195
|
-
const varName = this.shadowVarName;
|
|
50196
|
-
let result2 = {};
|
|
50197
|
-
if ("targetVariableComponentType" in dependencyValues) {
|
|
50198
|
-
result2.setCreateComponentOfType = {
|
|
50199
|
-
[varName]: dependencyValues.targetVariableComponentType
|
|
50200
|
-
};
|
|
50201
|
-
}
|
|
50202
|
-
if (usedDefault.targetVariable && "defaultValue" in this && this.hasEssential) {
|
|
50203
|
-
result2.useEssentialOrDefaultValue = {
|
|
50204
|
-
[varName]: {
|
|
50205
|
-
defaultValue: dependencyValues.targetVariable
|
|
50206
|
-
}
|
|
50207
|
-
};
|
|
50208
|
-
} else {
|
|
50209
|
-
result2.setValue = {
|
|
50210
|
-
[varName]: dependencyValues.targetVariable
|
|
50211
|
-
};
|
|
50212
|
-
}
|
|
50213
|
-
return result2;
|
|
50214
|
-
}
|
|
50215
|
-
function shadowInverseDefinition({ desiredStateVariableValues }) {
|
|
50216
|
-
return {
|
|
50217
|
-
success: true,
|
|
50218
|
-
instructions: [
|
|
50219
|
-
{
|
|
50220
|
-
setDependency: "targetVariable",
|
|
50221
|
-
desiredValue: desiredStateVariableValues[this.shadowVarName],
|
|
50222
|
-
shadowedVariable: true
|
|
50223
|
-
}
|
|
50224
|
-
]
|
|
50225
|
-
};
|
|
50226
|
-
}
|
|
50227
|
-
function shadowReturnArrayDependenciesByKey({ arrayKeys }) {
|
|
50228
|
-
let dependenciesByKey = {};
|
|
50229
|
-
for (let key of arrayKeys) {
|
|
50230
|
-
dependenciesByKey[key] = {
|
|
50231
|
-
targetVariable: {
|
|
50232
|
-
dependencyType: "stateVariable",
|
|
50233
|
-
componentIdx: this.shadowOfComponentIdx,
|
|
50234
|
-
variableName: this.shadowOverrideVarName || this.arrayVarNameFromArrayKey(key)
|
|
50235
|
-
}
|
|
50236
|
-
};
|
|
50237
|
-
}
|
|
50238
|
-
let globalDependencies = {};
|
|
50239
|
-
if (this.shadowCopyComponentType) {
|
|
50240
|
-
globalDependencies.targetVariableComponentType = {
|
|
50241
|
-
dependencyType: "stateVariableComponentType",
|
|
50242
|
-
componentIdx: this.shadowOfComponentIdx,
|
|
50243
|
-
variableName: this.shadowVarName
|
|
50244
|
-
};
|
|
50245
|
-
}
|
|
50246
|
-
if (this.inverseShadowToSetEntireArray) {
|
|
50247
|
-
globalDependencies.targetArray = {
|
|
50248
|
-
dependencyType: "stateVariable",
|
|
50249
|
-
componentIdx: this.shadowOfComponentIdx,
|
|
50250
|
-
variableName: this.shadowVarName
|
|
50251
|
-
};
|
|
50252
|
-
}
|
|
50253
|
-
return { globalDependencies, dependenciesByKey };
|
|
50254
|
-
}
|
|
50255
|
-
function shadowArrayDefinitionByKey({ globalDependencyValues, dependencyValuesByKey, arrayKeys }) {
|
|
50256
|
-
const varName = this.shadowVarName;
|
|
50257
|
-
let newEntries = {};
|
|
50258
|
-
for (let arrayKey of arrayKeys) {
|
|
50259
|
-
if ("targetVariable" in dependencyValuesByKey[arrayKey]) {
|
|
50260
|
-
newEntries[arrayKey] = dependencyValuesByKey[arrayKey].targetVariable;
|
|
50261
|
-
} else {
|
|
50262
|
-
newEntries[arrayKey] = this.defaultValueByArrayKey?.(arrayKey);
|
|
50263
|
-
}
|
|
50264
|
-
}
|
|
50265
|
-
let result2 = {
|
|
50266
|
-
setValue: { [varName]: newEntries }
|
|
50267
|
-
};
|
|
50268
|
-
if ("targetVariableComponentType" in globalDependencyValues) {
|
|
50269
|
-
result2.setCreateComponentOfType = {
|
|
50270
|
-
[varName]: globalDependencyValues.targetVariableComponentType
|
|
50271
|
-
};
|
|
50272
|
-
}
|
|
50273
|
-
return result2;
|
|
50274
|
-
}
|
|
50275
|
-
function shadowInverseArrayDefinitionByKey({
|
|
50276
|
-
desiredStateVariableValues,
|
|
50277
|
-
dependencyValuesByKey,
|
|
50278
|
-
dependencyNamesByKey,
|
|
50279
|
-
arraySize: arraySize2,
|
|
50280
|
-
initialChange
|
|
50281
|
-
}) {
|
|
50282
|
-
const varName = this.shadowVarName;
|
|
50283
|
-
if (this.inverseShadowToSetEntireArray) {
|
|
50284
|
-
return {
|
|
50285
|
-
success: true,
|
|
50286
|
-
instructions: [
|
|
50287
|
-
{
|
|
50288
|
-
setDependency: "targetArray",
|
|
50289
|
-
desiredValue: desiredStateVariableValues[varName],
|
|
50290
|
-
treatAsInitialChange: initialChange
|
|
50291
|
-
}
|
|
50292
|
-
]
|
|
50293
|
-
};
|
|
50294
|
-
}
|
|
50295
|
-
let instructions = [];
|
|
50296
|
-
for (let key in desiredStateVariableValues[varName]) {
|
|
50297
|
-
if (!dependencyValuesByKey[key]) {
|
|
50298
|
-
continue;
|
|
50299
|
-
}
|
|
50300
|
-
instructions.push({
|
|
50301
|
-
setDependency: dependencyNamesByKey[key].targetVariable,
|
|
50302
|
-
desiredValue: desiredStateVariableValues[varName][key],
|
|
50303
|
-
shadowedVariable: true
|
|
50304
|
-
});
|
|
50305
|
-
}
|
|
50306
|
-
return {
|
|
50307
|
-
success: true,
|
|
50308
|
-
instructions
|
|
50309
|
-
};
|
|
50310
|
-
}
|
|
50311
|
-
function modifyStateDefsToBeShadows({
|
|
50312
|
-
stateVariablesToShadow,
|
|
50313
|
-
stateVariableDefinitions,
|
|
50314
|
-
foundReadyToExpandWhenResolved,
|
|
50315
|
-
targetComponent,
|
|
50316
|
-
differentStateVariablesInTarget = []
|
|
50317
|
-
}) {
|
|
50318
|
-
let deleteStateVariablesFromDefinition = {};
|
|
50319
|
-
for (let [varInd, varName] of stateVariablesToShadow.entries()) {
|
|
50320
|
-
let stateDef = stateVariableDefinitions[varName];
|
|
50321
|
-
if (stateDef === void 0) {
|
|
50322
|
-
if (varName.slice(0, 8) === "__array_") {
|
|
50323
|
-
stateDef = stateVariableDefinitions[varName] = {};
|
|
50324
|
-
} else {
|
|
50325
|
-
continue;
|
|
50326
|
-
}
|
|
50327
|
-
}
|
|
50328
|
-
stateDef.isShadow = true;
|
|
50329
|
-
if (stateDef.additionalStateVariablesDefined) {
|
|
50330
|
-
for (let varName2 of stateDef.additionalStateVariablesDefined) {
|
|
50331
|
-
if (!stateVariablesToShadow.includes(varName2)) {
|
|
50332
|
-
if (!deleteStateVariablesFromDefinition[varName2]) {
|
|
50333
|
-
deleteStateVariablesFromDefinition[varName2] = [];
|
|
50334
|
-
}
|
|
50335
|
-
deleteStateVariablesFromDefinition[varName2].push(varName);
|
|
50336
|
-
}
|
|
50337
|
-
}
|
|
50338
|
-
}
|
|
50339
|
-
delete stateDef.additionalStateVariablesDefined;
|
|
50340
|
-
if (!foundReadyToExpandWhenResolved) {
|
|
50341
|
-
delete stateDef.stateVariablesDeterminingDependencies;
|
|
50342
|
-
}
|
|
50343
|
-
let copyComponentType = stateDef.public && stateDef.shadowingInstructions.hasVariableComponentType;
|
|
50344
|
-
stateDef.shadowOfComponentIdx = targetComponent.componentIdx;
|
|
50345
|
-
stateDef.shadowVarName = varName;
|
|
50346
|
-
stateDef.shadowCopyComponentType = copyComponentType;
|
|
50347
|
-
if (stateDef.isArray) {
|
|
50348
|
-
stateDef.shadowOverrideVarName = differentStateVariablesInTarget[varInd];
|
|
50349
|
-
stateDef.returnArrayDependenciesByKey = shadowReturnArrayDependenciesByKey;
|
|
50350
|
-
stateDef.arrayDefinitionByKey = shadowArrayDefinitionByKey;
|
|
50351
|
-
stateDef.inverseArrayDefinitionByKey = shadowInverseArrayDefinitionByKey;
|
|
50352
|
-
} else {
|
|
50353
|
-
if (foundReadyToExpandWhenResolved) {
|
|
50354
|
-
stateDef.shadowOriginalReturnDependencies = stateDef.returnDependencies.bind(stateDef);
|
|
50355
|
-
}
|
|
50356
|
-
stateDef.shadowVarNameInTarget = differentStateVariablesInTarget[varInd] || varName;
|
|
50357
|
-
stateDef.returnDependencies = shadowReturnDependencies;
|
|
50358
|
-
stateDef.definition = shadowDefinition;
|
|
50359
|
-
stateDef.excludeDependencyValuesInInverseDefinition = true;
|
|
50360
|
-
stateDef.inverseDefinition = shadowInverseDefinition;
|
|
50361
|
-
}
|
|
50362
|
-
}
|
|
50363
|
-
for (let varName in deleteStateVariablesFromDefinition) {
|
|
50364
|
-
modifyStateDefToDeleteVariableReferences({
|
|
50365
|
-
varNamesToDelete: deleteStateVariablesFromDefinition[varName],
|
|
50366
|
-
stateDef: stateVariableDefinitions[varName]
|
|
50367
|
-
});
|
|
50368
|
-
}
|
|
50369
|
-
}
|
|
50370
|
-
function modifyStateDefToDeleteVariableReferences({
|
|
50371
|
-
varNamesToDelete,
|
|
50372
|
-
stateDef
|
|
50373
|
-
}) {
|
|
50374
|
-
for (let varName2 of varNamesToDelete) {
|
|
50375
|
-
let ind = stateDef.additionalStateVariablesDefined.indexOf(varName2);
|
|
50376
|
-
stateDef.additionalStateVariablesDefined.splice(ind, 1);
|
|
50377
|
-
}
|
|
50378
|
-
let originalDefinition = stateDef.definition;
|
|
50379
|
-
stateDef.definition = function(args) {
|
|
50380
|
-
let results = originalDefinition(args);
|
|
50381
|
-
for (let key in results) {
|
|
50382
|
-
if (Array.isArray(results[key])) {
|
|
50383
|
-
for (let varName2 of varNamesToDelete) {
|
|
50384
|
-
let ind = results[key].indexOf(varName2);
|
|
50385
|
-
if (ind !== -1) {
|
|
50386
|
-
results[key].splice(ind, 1);
|
|
50387
|
-
}
|
|
50388
|
-
}
|
|
50389
|
-
} else {
|
|
50390
|
-
for (let varName2 of varNamesToDelete) {
|
|
50391
|
-
delete results[key][varName2];
|
|
50392
|
-
}
|
|
50393
|
-
}
|
|
50394
|
-
}
|
|
50395
|
-
return results;
|
|
50396
|
-
};
|
|
50397
|
-
}
|
|
50398
|
-
function _buildAttributeValueDependency(attributeSpecification, attrName, stateVariableForAttributeValue) {
|
|
50399
|
-
if (attributeSpecification.createPrimitiveOfType) {
|
|
50400
|
-
return {
|
|
50401
|
-
attributePrimitive: {
|
|
50402
|
-
dependencyType: "attributePrimitive",
|
|
50403
|
-
attributeName: attrName
|
|
50404
|
-
}
|
|
50405
|
-
};
|
|
50406
|
-
} else if (attributeSpecification.createReferences) {
|
|
50407
|
-
return {
|
|
50408
|
-
attributeRefResolutions: {
|
|
50409
|
-
dependencyType: "attributeRefResolutions",
|
|
50410
|
-
attributeName: attrName
|
|
50411
|
-
}
|
|
50412
|
-
};
|
|
50413
|
-
} else {
|
|
50414
|
-
return {
|
|
50415
|
-
attributeComponent: {
|
|
50416
|
-
dependencyType: "attributeComponent",
|
|
50417
|
-
attributeName: attrName,
|
|
50418
|
-
variableNames: [stateVariableForAttributeValue]
|
|
50419
|
-
}
|
|
50420
|
-
};
|
|
50421
|
-
}
|
|
50422
|
-
}
|
|
50423
|
-
function _buildAttributeFallbackDependencies(attributeSpecification) {
|
|
50424
|
-
const deps = {};
|
|
50425
|
-
if (attributeSpecification.fallBackToParentStateVariable) {
|
|
50426
|
-
deps.parentValue = {
|
|
50427
|
-
dependencyType: "parentStateVariable",
|
|
50428
|
-
variableName: attributeSpecification.fallBackToParentStateVariable
|
|
50429
|
-
};
|
|
50430
|
-
}
|
|
50431
|
-
if (attributeSpecification.fallBackToSourceCompositeStateVariable) {
|
|
50432
|
-
deps.sourceCompositeValue = {
|
|
50433
|
-
dependencyType: "sourceCompositeStateVariable",
|
|
50434
|
-
variableName: attributeSpecification.fallBackToSourceCompositeStateVariable
|
|
50435
|
-
};
|
|
50436
|
-
}
|
|
50437
|
-
return deps;
|
|
50438
|
-
}
|
|
50439
|
-
function _resolvePrimaryStateVariableForDefinition({
|
|
50440
|
-
redefineDependencies,
|
|
50441
|
-
componentClass,
|
|
50442
|
-
stateVariableDefinitions,
|
|
50443
|
-
throwIfMissing
|
|
50444
|
-
}) {
|
|
50445
|
-
let name2 = "value";
|
|
50446
|
-
if (redefineDependencies.substituteForPrimaryStateVariable) {
|
|
50447
|
-
name2 = redefineDependencies.substituteForPrimaryStateVariable;
|
|
50448
|
-
} else if (componentClass.primaryStateVariableForDefinition) {
|
|
50449
|
-
name2 = componentClass.primaryStateVariableForDefinition;
|
|
50450
|
-
}
|
|
50451
|
-
const stateDef = stateVariableDefinitions[name2];
|
|
50452
|
-
if (throwIfMissing && !stateDef) {
|
|
50453
|
-
if (redefineDependencies.substituteForPrimaryStateVariable) {
|
|
50454
|
-
throw Error(
|
|
50455
|
-
`Invalid public state variable of componentType ${componentClass.componentType}: substituteForPrimaryStateVariable ${redefineDependencies.substituteForPrimaryStateVariable} does not exist`
|
|
50456
|
-
);
|
|
50457
|
-
} else {
|
|
50458
|
-
throw Error(
|
|
50459
|
-
`Cannot have a public state variable with componentType ${componentClass.componentType} as the class doesn't have a primary state variable for definition`
|
|
50460
|
-
);
|
|
50461
|
-
}
|
|
50462
|
-
}
|
|
50463
|
-
return { name: name2, stateDef };
|
|
50464
|
-
}
|
|
50465
|
-
function _setShadowingInstructionsFromAttribute(stateVarDef, attributeSpecification) {
|
|
50466
|
-
stateVarDef.public = true;
|
|
50467
|
-
stateVarDef.shadowingInstructions = {};
|
|
50468
|
-
if (attributeSpecification.createPrimitiveOfType) {
|
|
50469
|
-
const primitive = attributeSpecification.createPrimitiveOfType;
|
|
50470
|
-
stateVarDef.shadowingInstructions.createComponentOfType = PRIMITIVE_TO_COMPONENT_TYPE[primitive] ?? primitive;
|
|
50471
|
-
} else if (attributeSpecification.createReferences) {
|
|
50472
|
-
throw Error(
|
|
50473
|
-
"Cannot make a public state variable from an attribute with createReferences"
|
|
50474
|
-
);
|
|
50475
|
-
} else {
|
|
50476
|
-
stateVarDef.shadowingInstructions.createComponentOfType = attributeSpecification.createComponentOfType;
|
|
50477
|
-
}
|
|
50478
|
-
}
|
|
50479
|
-
function _resolveAttributeValueVariable(core2, attributeSpecification, attrName, componentClass) {
|
|
50480
|
-
if (!attributeSpecification.createComponentOfType) {
|
|
50481
|
-
return void 0;
|
|
50482
|
-
}
|
|
50483
|
-
const attributeClass = core2.componentInfoObjects.allComponentClasses[attributeSpecification.createComponentOfType];
|
|
50484
|
-
if (!attributeClass) {
|
|
50485
|
-
throw Error(
|
|
50486
|
-
`Component type ${attributeSpecification.createComponentOfType} does not exist so cannot create state variable for attribute ${attrName} of componentType ${componentClass.componentType}.`
|
|
50487
|
-
);
|
|
50488
|
-
}
|
|
50489
|
-
let stateVariableForAttributeValue = attributeSpecification.componentStateVariableForAttributeValue;
|
|
50490
|
-
if (stateVariableForAttributeValue === void 0) {
|
|
50491
|
-
stateVariableForAttributeValue = attributeClass.stateVariableToBeShadowed;
|
|
50492
|
-
if (stateVariableForAttributeValue === void 0) {
|
|
50493
|
-
stateVariableForAttributeValue = "value";
|
|
50494
|
-
}
|
|
50495
|
-
}
|
|
50496
|
-
return stateVariableForAttributeValue;
|
|
50497
|
-
}
|
|
50498
|
-
function _copyPassthroughAttributes(stateVarDef, attributeSpecification, { includeTriggerActionOnChange = false } = {}) {
|
|
50499
|
-
const attributesToCopy = [
|
|
50500
|
-
"forRenderer",
|
|
50501
|
-
"defaultValue",
|
|
50502
|
-
"propagateToProps",
|
|
50503
|
-
...includeTriggerActionOnChange ? ["triggerActionOnChange"] : [],
|
|
50504
|
-
"ignoreFixed",
|
|
50505
|
-
"isLocation",
|
|
50506
|
-
"essentialVarName"
|
|
50507
|
-
];
|
|
50508
|
-
for (const attrName2 of attributesToCopy) {
|
|
50509
|
-
if (attrName2 in attributeSpecification) {
|
|
50510
|
-
stateVarDef[attrName2] = attributeSpecification[attrName2];
|
|
50511
|
-
}
|
|
50512
|
-
}
|
|
50513
|
-
}
|
|
50514
|
-
function _buildAttributeDerivedDefinitions({
|
|
50515
|
-
varName,
|
|
50516
|
-
stateVariableForAttributeValue,
|
|
50517
|
-
attributeSpecification,
|
|
50518
|
-
attrName
|
|
50519
|
-
}) {
|
|
50520
|
-
const definition = function({
|
|
50521
|
-
dependencyValues,
|
|
50522
|
-
usedDefault,
|
|
50523
|
-
essentialValues
|
|
50524
|
-
}) {
|
|
50525
|
-
let attributeValue;
|
|
50526
|
-
if (dependencyValues.attributeComponent) {
|
|
50527
|
-
attributeValue = dependencyValues.attributeComponent.stateValues[stateVariableForAttributeValue];
|
|
50528
|
-
} else if (dependencyValues.attributePrimitive != null) {
|
|
50529
|
-
attributeValue = dependencyValues.attributePrimitive;
|
|
50530
|
-
} else if (dependencyValues.attributeRefResolutions != null && !usedDefault.attributeRefResolutions) {
|
|
50531
|
-
attributeValue = dependencyValues.attributeRefResolutions;
|
|
50532
|
-
} else {
|
|
50533
|
-
let haveSourceCompositeValue = dependencyValues.sourceCompositeValue != null;
|
|
50534
|
-
if (haveSourceCompositeValue && !usedDefault.sourceCompositeValue && essentialValues[varName] === void 0) {
|
|
50535
|
-
return {
|
|
50536
|
-
setValue: {
|
|
50537
|
-
[varName]: dependencyValues.sourceCompositeValue
|
|
50538
|
-
},
|
|
50539
|
-
checkForActualChange: { [varName]: true }
|
|
50540
|
-
};
|
|
50541
|
-
} else {
|
|
50542
|
-
let haveParentValue = dependencyValues.parentValue != null;
|
|
50543
|
-
if (haveParentValue && !usedDefault.parentValue && essentialValues[varName] === void 0) {
|
|
50544
|
-
return {
|
|
50545
|
-
setValue: {
|
|
50546
|
-
[varName]: dependencyValues.parentValue
|
|
50547
|
-
},
|
|
50548
|
-
checkForActualChange: { [varName]: true }
|
|
50549
|
-
};
|
|
50550
|
-
} else {
|
|
50551
|
-
return {
|
|
50552
|
-
useEssentialOrDefaultValue: {
|
|
50553
|
-
[varName]: true
|
|
50554
|
-
},
|
|
50555
|
-
checkForActualChange: { [varName]: true }
|
|
50556
|
-
};
|
|
50557
|
-
}
|
|
50558
|
-
}
|
|
50559
|
-
}
|
|
50560
|
-
const res = validateAttributeValue({
|
|
50561
|
-
value: attributeValue,
|
|
50562
|
-
attributeSpecification,
|
|
50563
|
-
attribute: attrName
|
|
50564
|
-
});
|
|
50565
|
-
return {
|
|
50566
|
-
setValue: { [varName]: res.value },
|
|
50567
|
-
checkForActualChange: { [varName]: true },
|
|
50568
|
-
sendDiagnostics: res.diagnostics
|
|
50569
|
-
};
|
|
50570
|
-
};
|
|
50571
|
-
const inverseDefinition = async function({
|
|
50572
|
-
desiredStateVariableValues,
|
|
50573
|
-
dependencyValues,
|
|
50574
|
-
usedDefault,
|
|
50575
|
-
essentialValues
|
|
50576
|
-
}) {
|
|
50577
|
-
if (!dependencyValues.attributeComponent) {
|
|
50578
|
-
if (dependencyValues.attributePrimitive != null) {
|
|
50579
|
-
return { success: false };
|
|
50580
|
-
}
|
|
50581
|
-
if (dependencyValues.attributeRefResolutions != null) {
|
|
50582
|
-
return { success: false };
|
|
50583
|
-
}
|
|
50584
|
-
let haveSourceCompositeValue = dependencyValues.sourceCompositeValue != null;
|
|
50585
|
-
if (haveSourceCompositeValue && !usedDefault.sourceCompositeValue && essentialValues[varName] === void 0) {
|
|
50586
|
-
return {
|
|
50587
|
-
success: true,
|
|
50588
|
-
instructions: [
|
|
50589
|
-
{
|
|
50590
|
-
setDependency: "sourceCompositeValue",
|
|
50591
|
-
desiredValue: desiredStateVariableValues[varName]
|
|
50592
|
-
}
|
|
50593
|
-
]
|
|
50594
|
-
};
|
|
50595
|
-
} else {
|
|
50596
|
-
let haveParentValue = dependencyValues.parentValue != null;
|
|
50597
|
-
if (haveParentValue && !usedDefault.parentValue && essentialValues[varName] === void 0) {
|
|
50598
|
-
return {
|
|
50599
|
-
success: true,
|
|
50600
|
-
instructions: [
|
|
50601
|
-
{
|
|
50602
|
-
setDependency: "parentValue",
|
|
50603
|
-
desiredValue: desiredStateVariableValues[varName]
|
|
50604
|
-
}
|
|
50605
|
-
]
|
|
50606
|
-
};
|
|
50607
|
-
} else {
|
|
50608
|
-
const res = validateAttributeValue({
|
|
50609
|
-
value: desiredStateVariableValues[varName],
|
|
50610
|
-
attributeSpecification,
|
|
50611
|
-
attribute: attrName
|
|
50612
|
-
});
|
|
50613
|
-
return {
|
|
50614
|
-
success: true,
|
|
50615
|
-
instructions: [
|
|
50616
|
-
{
|
|
50617
|
-
setEssentialValue: varName,
|
|
50618
|
-
value: res.value
|
|
50619
|
-
}
|
|
50620
|
-
],
|
|
50621
|
-
sendDiagnostics: res.diagnostics
|
|
50622
|
-
};
|
|
50623
|
-
}
|
|
50624
|
-
}
|
|
50625
|
-
}
|
|
50626
|
-
return {
|
|
50627
|
-
success: true,
|
|
50628
|
-
instructions: [
|
|
50629
|
-
{
|
|
50630
|
-
setDependency: "attributeComponent",
|
|
50631
|
-
desiredValue: desiredStateVariableValues[varName],
|
|
50632
|
-
variableIndex: 0
|
|
50633
|
-
}
|
|
50634
|
-
]
|
|
50635
|
-
};
|
|
50636
|
-
};
|
|
50637
|
-
return { definition, inverseDefinition };
|
|
50638
|
-
}
|
|
50639
|
-
function validateAttributeValue({
|
|
50640
|
-
value,
|
|
50641
|
-
attributeSpecification,
|
|
50642
|
-
attribute
|
|
50643
|
-
}) {
|
|
50644
|
-
let diagnostics = [];
|
|
50645
|
-
const valueOrig = value;
|
|
50646
|
-
if (attributeSpecification.transformNonFiniteTo !== void 0 && !Number.isFinite(value)) {
|
|
50647
|
-
value = attributeSpecification.transformNonFiniteTo;
|
|
50648
|
-
}
|
|
50649
|
-
if (attributeSpecification.validValues && Array.isArray(value)) {
|
|
50650
|
-
const res = validateListItemsAgainstValidValues({
|
|
50651
|
-
items: value,
|
|
50652
|
-
validValues: attributeSpecification.validValues,
|
|
50653
|
-
toLowerCase: attributeSpecification.toLowerCase,
|
|
50654
|
-
attribute
|
|
50655
|
-
});
|
|
50656
|
-
diagnostics.push(...res.diagnostics);
|
|
50657
|
-
return { value: res.value, diagnostics };
|
|
50658
|
-
}
|
|
50659
|
-
if (attributeSpecification.toLowerCase) {
|
|
50660
|
-
value = value.toLowerCase();
|
|
50661
|
-
}
|
|
50662
|
-
if (attributeSpecification.trim || attributeSpecification.validValues) {
|
|
50663
|
-
value = value.trim();
|
|
50664
|
-
}
|
|
50665
|
-
if (attributeSpecification.validValues) {
|
|
50666
|
-
const allowed = attributeSpecification.validValues.map((v2) => v2.value);
|
|
50667
|
-
if (!allowed.includes(value)) {
|
|
50668
|
-
let defaultValue = attributeSpecification.defaultValue;
|
|
50669
|
-
if (defaultValue === void 0) {
|
|
50670
|
-
if (attributeSpecification.createPrimitiveOfType) {
|
|
50671
|
-
defaultValue = attributeSpecification.defaultPrimitiveValue;
|
|
50672
|
-
}
|
|
50673
|
-
if (defaultValue === void 0) {
|
|
50674
|
-
throw Error(
|
|
50675
|
-
"Invalid attribute specification: no default value specified"
|
|
50676
|
-
);
|
|
50677
|
-
}
|
|
50678
|
-
}
|
|
50679
|
-
diagnostics.push({
|
|
50680
|
-
message: `Invalid value \`${valueOrig}\` for attribute \`${attribute}\`, using value \`${defaultValue}\``,
|
|
50681
|
-
type: "info"
|
|
50682
|
-
});
|
|
50683
|
-
value = defaultValue;
|
|
50684
|
-
}
|
|
50685
|
-
} else if (attributeSpecification.clamp) {
|
|
50686
|
-
if (value < attributeSpecification.clamp[0]) {
|
|
50687
|
-
value = attributeSpecification.clamp[0];
|
|
50688
|
-
} else if (value > attributeSpecification.clamp[1]) {
|
|
50689
|
-
value = attributeSpecification.clamp[1];
|
|
50690
|
-
} else if (!Number.isFinite(value)) {
|
|
50691
|
-
value = attributeSpecification.defaultValue;
|
|
50692
|
-
}
|
|
50693
|
-
}
|
|
50694
|
-
return { value, diagnostics };
|
|
50695
|
-
}
|
|
50696
49614
|
function renameStateVariable({
|
|
50697
49615
|
stateVariableDefinitions,
|
|
50698
49616
|
oldName,
|
|
@@ -50750,46 +49668,52 @@ function renameStateVariable({
|
|
|
50750
49668
|
};
|
|
50751
49669
|
}
|
|
50752
49670
|
}
|
|
50753
|
-
function
|
|
50754
|
-
|
|
50755
|
-
|
|
50756
|
-
|
|
50757
|
-
|
|
50758
|
-
|
|
50759
|
-
|
|
50760
|
-
|
|
50761
|
-
|
|
50762
|
-
if (indices.
|
|
50763
|
-
|
|
50764
|
-
if (indices.every((x2, i2) => x2 < arraySize2[i2])) {
|
|
50765
|
-
return [String(indices)];
|
|
50766
|
-
} else {
|
|
50767
|
-
return [];
|
|
50768
|
-
}
|
|
50769
|
-
} else {
|
|
50770
|
-
return [String(indices)];
|
|
50771
|
-
}
|
|
49671
|
+
function defaultGetArrayKeysFromVarNameMultiDim({
|
|
49672
|
+
arrayEntryPrefix,
|
|
49673
|
+
varEnding,
|
|
49674
|
+
arraySize: arraySize2,
|
|
49675
|
+
numDimensions
|
|
49676
|
+
}) {
|
|
49677
|
+
let indices = varEnding.split("_").map((x2) => Number(x2) - 1);
|
|
49678
|
+
if (indices.length === numDimensions && indices.every((x2, i2) => Number.isInteger(x2) && x2 >= 0)) {
|
|
49679
|
+
if (arraySize2) {
|
|
49680
|
+
if (indices.every((x2, i2) => x2 < arraySize2[i2])) {
|
|
49681
|
+
return [String(indices)];
|
|
50772
49682
|
} else {
|
|
50773
49683
|
return [];
|
|
50774
49684
|
}
|
|
50775
|
-
}
|
|
49685
|
+
} else {
|
|
49686
|
+
return [String(indices)];
|
|
49687
|
+
}
|
|
50776
49688
|
} else {
|
|
50777
|
-
return
|
|
50778
|
-
|
|
50779
|
-
|
|
50780
|
-
|
|
50781
|
-
|
|
50782
|
-
|
|
50783
|
-
|
|
50784
|
-
|
|
50785
|
-
|
|
50786
|
-
|
|
50787
|
-
|
|
50788
|
-
|
|
49689
|
+
return [];
|
|
49690
|
+
}
|
|
49691
|
+
}
|
|
49692
|
+
function defaultGetArrayKeysFromVarNameOneDim({
|
|
49693
|
+
arrayEntryPrefix,
|
|
49694
|
+
varEnding,
|
|
49695
|
+
arraySize: arraySize2
|
|
49696
|
+
}) {
|
|
49697
|
+
let index2 = Number(varEnding) - 1;
|
|
49698
|
+
if (Number.isInteger(index2) && index2 >= 0) {
|
|
49699
|
+
if (arraySize2) {
|
|
49700
|
+
if (index2 < arraySize2[0]) {
|
|
49701
|
+
return [String(index2)];
|
|
50789
49702
|
} else {
|
|
50790
49703
|
return [];
|
|
50791
49704
|
}
|
|
50792
|
-
}
|
|
49705
|
+
} else {
|
|
49706
|
+
return [String(index2)];
|
|
49707
|
+
}
|
|
49708
|
+
} else {
|
|
49709
|
+
return [];
|
|
49710
|
+
}
|
|
49711
|
+
}
|
|
49712
|
+
function returnDefaultGetArrayKeysFromVarName(numDim) {
|
|
49713
|
+
if (numDim > 1) {
|
|
49714
|
+
return defaultGetArrayKeysFromVarNameMultiDim;
|
|
49715
|
+
} else {
|
|
49716
|
+
return defaultGetArrayKeysFromVarNameOneDim;
|
|
50793
49717
|
}
|
|
50794
49718
|
}
|
|
50795
49719
|
function returnDefaultArrayVarNameFromPropIndex(numDim, arrayEntryPrefix) {
|
|
@@ -51005,895 +49929,2027 @@ function multiDimGetArrayValue({ arrayKey, arrayValues = this.arrayValues }) {
|
|
|
51005
49929
|
return void 0;
|
|
51006
49930
|
}
|
|
51007
49931
|
}
|
|
51008
|
-
return aVals[index2[index2.length - 1]];
|
|
51009
|
-
}
|
|
51010
|
-
function oneDimGetArrayValue({ arrayKey, arrayValues = this.arrayValues }) {
|
|
51011
|
-
return arrayValues[arrayKey];
|
|
49932
|
+
return aVals[index2[index2.length - 1]];
|
|
49933
|
+
}
|
|
49934
|
+
function oneDimGetArrayValue({ arrayKey, arrayValues = this.arrayValues }) {
|
|
49935
|
+
return arrayValues[arrayKey];
|
|
49936
|
+
}
|
|
49937
|
+
function multiDimGetAllArrayKeys(arraySize2, flatten2 = true, desiredSize) {
|
|
49938
|
+
function prependToAllKeys(keys2, newStuff) {
|
|
49939
|
+
for (let [ind, key] of keys2.entries()) {
|
|
49940
|
+
if (Array.isArray(key)) {
|
|
49941
|
+
prependToAllKeys(key, newStuff);
|
|
49942
|
+
} else {
|
|
49943
|
+
keys2[ind] = newStuff + "," + key;
|
|
49944
|
+
}
|
|
49945
|
+
}
|
|
49946
|
+
}
|
|
49947
|
+
function getAllArrayKeysSub(subArraySize) {
|
|
49948
|
+
if (subArraySize.length === 1) {
|
|
49949
|
+
return Array.from(Array(subArraySize[0]), (_2, i2) => String(i2));
|
|
49950
|
+
} else {
|
|
49951
|
+
let currentSize = subArraySize[0];
|
|
49952
|
+
let subSubKeys = getAllArrayKeysSub(subArraySize.slice(1));
|
|
49953
|
+
let subKeys = [];
|
|
49954
|
+
for (let ind = 0; ind < currentSize; ind++) {
|
|
49955
|
+
if (flatten2) {
|
|
49956
|
+
subKeys.push(...subSubKeys.map((x2) => ind + "," + x2));
|
|
49957
|
+
} else {
|
|
49958
|
+
let newSubSubKeys = deepClone(subSubKeys);
|
|
49959
|
+
prependToAllKeys(newSubSubKeys, ind);
|
|
49960
|
+
subKeys.push(newSubSubKeys);
|
|
49961
|
+
}
|
|
49962
|
+
}
|
|
49963
|
+
return subKeys;
|
|
49964
|
+
}
|
|
49965
|
+
}
|
|
49966
|
+
if (desiredSize) {
|
|
49967
|
+
if (desiredSize.length === 0) {
|
|
49968
|
+
return [];
|
|
49969
|
+
} else {
|
|
49970
|
+
return getAllArrayKeysSub(desiredSize);
|
|
49971
|
+
}
|
|
49972
|
+
} else if (!arraySize2 || arraySize2.length === 0) {
|
|
49973
|
+
return [];
|
|
49974
|
+
} else {
|
|
49975
|
+
return getAllArrayKeysSub(arraySize2);
|
|
49976
|
+
}
|
|
49977
|
+
}
|
|
49978
|
+
function oneDimGetAllArrayKeys(arraySize2, flatten2, desiredSize) {
|
|
49979
|
+
if (desiredSize) {
|
|
49980
|
+
if (desiredSize.length === 0) {
|
|
49981
|
+
return [];
|
|
49982
|
+
} else {
|
|
49983
|
+
return Array.from(Array(desiredSize[0]), (_2, i2) => String(i2));
|
|
49984
|
+
}
|
|
49985
|
+
} else if (!arraySize2 || arraySize2.length === 0) {
|
|
49986
|
+
return [];
|
|
49987
|
+
} else {
|
|
49988
|
+
return Array.from(Array(arraySize2[0]), (_2, i2) => String(i2));
|
|
49989
|
+
}
|
|
49990
|
+
}
|
|
49991
|
+
function defaultMultiDimArrayVarNameFromArrayKey(arrayKey) {
|
|
49992
|
+
return this.entryPrefixes[0] + arrayKey.split(",").map((x2) => Number(x2) + 1).join("_");
|
|
49993
|
+
}
|
|
49994
|
+
function defaultOneDimArrayVarNameFromArrayKey(arrayKey) {
|
|
49995
|
+
return this.entryPrefixes[0] + String(Number(arrayKey) + 1);
|
|
49996
|
+
}
|
|
49997
|
+
async function multiDimAdjustArrayToNewArraySize() {
|
|
49998
|
+
function resizeSubArray(subArray, subArraySize) {
|
|
49999
|
+
subArray.length = subArraySize[0];
|
|
50000
|
+
if (subArraySize.length > 1) {
|
|
50001
|
+
let subSubArraySize = subArraySize.slice(1);
|
|
50002
|
+
for (let [ind, subSubArray] of subArray.entries()) {
|
|
50003
|
+
if (!subSubArray) {
|
|
50004
|
+
subSubArray = subArray[ind] = [];
|
|
50005
|
+
}
|
|
50006
|
+
resizeSubArray(subSubArray, subSubArraySize);
|
|
50007
|
+
}
|
|
50008
|
+
}
|
|
50009
|
+
}
|
|
50010
|
+
let arraySize2 = await this.arraySize;
|
|
50011
|
+
resizeSubArray(this.arrayValues, arraySize2);
|
|
50012
|
+
}
|
|
50013
|
+
async function oneDimAdjustArrayToNewArraySize() {
|
|
50014
|
+
let arraySize2 = await this.arraySize;
|
|
50015
|
+
this.arrayValues.length = arraySize2[0];
|
|
50016
|
+
}
|
|
50017
|
+
function resolveArrayStateVarObj(svObj) {
|
|
50018
|
+
return svObj.isArrayEntry ? svObj.svComponent.state[svObj.arrayStateVariable] : svObj;
|
|
50019
|
+
}
|
|
50020
|
+
function defaultReturnWrappingComponents(prefix) {
|
|
50021
|
+
return [];
|
|
50022
|
+
}
|
|
50023
|
+
async function arrayReturnDependencies(args) {
|
|
50024
|
+
const arrayStateVarObj = resolveArrayStateVarObj(this);
|
|
50025
|
+
const component = arrayStateVarObj.svComponent;
|
|
50026
|
+
const arrayVarName = arrayStateVarObj.svVarName;
|
|
50027
|
+
args.arraySize = await arrayStateVarObj.arraySize;
|
|
50028
|
+
for (let key in args.stateValues) {
|
|
50029
|
+
if (key.slice(0, 8) === "__array_") {
|
|
50030
|
+
delete args.stateValues[key];
|
|
50031
|
+
}
|
|
50032
|
+
}
|
|
50033
|
+
if (args.arrayKeys === void 0) {
|
|
50034
|
+
args.arrayKeys = arrayStateVarObj.getAllArrayKeys(args.arraySize);
|
|
50035
|
+
}
|
|
50036
|
+
if (!arrayStateVarObj.dependencyNames) {
|
|
50037
|
+
arrayStateVarObj.dependencyNames = {
|
|
50038
|
+
namesByKey: {},
|
|
50039
|
+
keysByName: {},
|
|
50040
|
+
global: []
|
|
50041
|
+
};
|
|
50042
|
+
if (arrayStateVarObj.additionalStateVariablesDefined) {
|
|
50043
|
+
for (let vName of arrayStateVarObj.additionalStateVariablesDefined) {
|
|
50044
|
+
component.state[vName].dependencyNames = arrayStateVarObj.dependencyNames;
|
|
50045
|
+
}
|
|
50046
|
+
}
|
|
50047
|
+
}
|
|
50048
|
+
let dependencies2 = {};
|
|
50049
|
+
if (arrayStateVarObj.basedOnArrayKeyStateVariables && args.arrayKeys.length > 1) {
|
|
50050
|
+
const allStateVariablesAffected = [
|
|
50051
|
+
arrayVarName,
|
|
50052
|
+
...arrayStateVarObj.additionalStateVariablesDefined ?? []
|
|
50053
|
+
];
|
|
50054
|
+
for (let arrayKey of args.arrayKeys) {
|
|
50055
|
+
for (let vName of allStateVariablesAffected) {
|
|
50056
|
+
let sObj = component.state[vName];
|
|
50057
|
+
dependencies2[vName + "_" + arrayKey] = {
|
|
50058
|
+
dependencyType: "stateVariable",
|
|
50059
|
+
variableName: sObj.arrayVarNameFromArrayKey(arrayKey)
|
|
50060
|
+
};
|
|
50061
|
+
}
|
|
50062
|
+
}
|
|
50063
|
+
} else {
|
|
50064
|
+
let arrayDependencies = arrayStateVarObj.returnArrayDependenciesByKey(args);
|
|
50065
|
+
if (arrayDependencies.globalDependencies) {
|
|
50066
|
+
arrayStateVarObj.dependencyNames.global = Object.keys(
|
|
50067
|
+
arrayDependencies.globalDependencies
|
|
50068
|
+
);
|
|
50069
|
+
Object.assign(dependencies2, arrayDependencies.globalDependencies);
|
|
50070
|
+
}
|
|
50071
|
+
if (!arrayDependencies.dependenciesByKey) {
|
|
50072
|
+
arrayDependencies.dependenciesByKey = {};
|
|
50073
|
+
}
|
|
50074
|
+
for (let arrayKey of args.arrayKeys) {
|
|
50075
|
+
if (!(arrayKey in arrayStateVarObj.dependencyNames.namesByKey)) {
|
|
50076
|
+
args.changedDependency = true;
|
|
50077
|
+
}
|
|
50078
|
+
arrayStateVarObj.dependencyNames.namesByKey[arrayKey] = {};
|
|
50079
|
+
for (let depName in arrayDependencies.dependenciesByKey[arrayKey]) {
|
|
50080
|
+
let extendedDepName = "__" + arrayKey + "_" + depName;
|
|
50081
|
+
dependencies2[extendedDepName] = arrayDependencies.dependenciesByKey[arrayKey][depName];
|
|
50082
|
+
arrayStateVarObj.dependencyNames.namesByKey[arrayKey][depName] = extendedDepName;
|
|
50083
|
+
if (!arrayStateVarObj.dependencyNames.keysByName[extendedDepName]) {
|
|
50084
|
+
arrayStateVarObj.dependencyNames.keysByName[extendedDepName] = [];
|
|
50085
|
+
}
|
|
50086
|
+
if (!arrayStateVarObj.dependencyNames.keysByName[extendedDepName].includes(arrayKey)) {
|
|
50087
|
+
arrayStateVarObj.dependencyNames.keysByName[extendedDepName].push(arrayKey);
|
|
50088
|
+
}
|
|
50089
|
+
}
|
|
50090
|
+
}
|
|
50091
|
+
arrayStateVarObj.dependencyNames.global.push("__array_size");
|
|
50092
|
+
}
|
|
50093
|
+
dependencies2.__array_size = {
|
|
50094
|
+
dependencyType: "stateVariable",
|
|
50095
|
+
variableName: arrayStateVarObj.arraySizeStateVariable
|
|
50096
|
+
};
|
|
50097
|
+
return dependencies2;
|
|
50098
|
+
}
|
|
50099
|
+
function arrayGetCurrentFreshness({ freshnessInfo, arrayKeys, arraySize: arraySize2 }) {
|
|
50100
|
+
const arrayStateVarObj = resolveArrayStateVarObj(this);
|
|
50101
|
+
const arrayVarName = arrayStateVarObj.svVarName;
|
|
50102
|
+
if (arrayKeys === void 0) {
|
|
50103
|
+
arrayKeys = arrayStateVarObj.getAllArrayKeys(arraySize2);
|
|
50104
|
+
}
|
|
50105
|
+
let freshByKey = freshnessInfo.freshByKey;
|
|
50106
|
+
let numberFresh = freshnessInfo.freshArraySize ? 1 : 0;
|
|
50107
|
+
for (let arrayKey of arrayKeys) {
|
|
50108
|
+
if (freshByKey[arrayKey]) {
|
|
50109
|
+
numberFresh += 1;
|
|
50110
|
+
}
|
|
50111
|
+
}
|
|
50112
|
+
if (numberFresh > 0) {
|
|
50113
|
+
if (numberFresh === arrayKeys.length + 1) {
|
|
50114
|
+
return { fresh: { [arrayVarName]: true } };
|
|
50115
|
+
} else {
|
|
50116
|
+
return { partiallyFresh: { [arrayVarName]: numberFresh } };
|
|
50117
|
+
}
|
|
50118
|
+
} else {
|
|
50119
|
+
return { fresh: { [arrayVarName]: false } };
|
|
50120
|
+
}
|
|
50121
|
+
}
|
|
50122
|
+
function arrayMarkStale({ freshnessInfo, changes, arrayKeys, arraySize: arraySize2 }) {
|
|
50123
|
+
const arrayStateVarObj = resolveArrayStateVarObj(this);
|
|
50124
|
+
const arrayVarName = arrayStateVarObj.svVarName;
|
|
50125
|
+
let result2 = {};
|
|
50126
|
+
if (arrayKeys === void 0) {
|
|
50127
|
+
arrayKeys = arrayStateVarObj.getAllArrayKeys(arraySize2);
|
|
50128
|
+
}
|
|
50129
|
+
if (arrayStateVarObj.markStaleByKey) {
|
|
50130
|
+
result2 = arrayStateVarObj.markStaleByKey({ arrayKeys, changes });
|
|
50131
|
+
}
|
|
50132
|
+
let freshByKey = freshnessInfo.freshByKey;
|
|
50133
|
+
if (changes.__array_size) {
|
|
50134
|
+
freshnessInfo.freshArraySize = false;
|
|
50135
|
+
freshnessInfo.freshByKey = {};
|
|
50136
|
+
result2.fresh = { [arrayVarName]: false };
|
|
50137
|
+
return result2;
|
|
50138
|
+
}
|
|
50139
|
+
if (Object.keys(freshByKey).length === 0) {
|
|
50140
|
+
freshnessInfo.freshByKey = {};
|
|
50141
|
+
if (freshnessInfo.freshArraySize) {
|
|
50142
|
+
result2.partiallyFresh = { [arrayVarName]: 1 };
|
|
50143
|
+
return result2;
|
|
50144
|
+
} else {
|
|
50145
|
+
result2.fresh = { [arrayVarName]: false };
|
|
50146
|
+
return result2;
|
|
50147
|
+
}
|
|
50148
|
+
}
|
|
50149
|
+
for (let changeName in changes) {
|
|
50150
|
+
if (arrayStateVarObj.dependencyNames.global.includes(changeName)) {
|
|
50151
|
+
freshnessInfo.freshByKey = {};
|
|
50152
|
+
if (freshnessInfo.freshArraySize) {
|
|
50153
|
+
result2.partiallyFresh = { [arrayVarName]: 1 };
|
|
50154
|
+
return result2;
|
|
50155
|
+
} else {
|
|
50156
|
+
result2.fresh = { [arrayVarName]: false };
|
|
50157
|
+
return result2;
|
|
50158
|
+
}
|
|
50159
|
+
}
|
|
50160
|
+
if (arrayStateVarObj.basedOnArrayKeyStateVariables && arrayKeys.length > 1) {
|
|
50161
|
+
delete freshByKey[changeName];
|
|
50162
|
+
} else {
|
|
50163
|
+
for (let key of arrayStateVarObj.dependencyNames.keysByName[changeName]) {
|
|
50164
|
+
delete freshByKey[key];
|
|
50165
|
+
}
|
|
50166
|
+
}
|
|
50167
|
+
}
|
|
50168
|
+
let numberFresh = freshnessInfo.freshArraySize ? 1 : 0;
|
|
50169
|
+
for (let arrayKey of arrayKeys) {
|
|
50170
|
+
if (freshByKey[arrayKey]) {
|
|
50171
|
+
numberFresh += 1;
|
|
50172
|
+
}
|
|
50173
|
+
}
|
|
50174
|
+
if (numberFresh > 0) {
|
|
50175
|
+
if (numberFresh === arrayKeys.length + 1) {
|
|
50176
|
+
result2.fresh = { [arrayVarName]: true };
|
|
50177
|
+
return result2;
|
|
50178
|
+
} else {
|
|
50179
|
+
result2.partiallyFresh = { [arrayVarName]: numberFresh };
|
|
50180
|
+
return result2;
|
|
50181
|
+
}
|
|
50182
|
+
} else {
|
|
50183
|
+
result2.fresh = { [arrayVarName]: false };
|
|
50184
|
+
return result2;
|
|
50185
|
+
}
|
|
50186
|
+
}
|
|
50187
|
+
function arrayFreshenOnNoChanges({ arrayKeys, freshnessInfo, arraySize: arraySize2 }) {
|
|
50188
|
+
const arrayStateVarObj = resolveArrayStateVarObj(this);
|
|
50189
|
+
let freshByKey = freshnessInfo.freshByKey;
|
|
50190
|
+
if (arrayKeys === void 0) {
|
|
50191
|
+
arrayKeys = arrayStateVarObj.getAllArrayKeys(arraySize2);
|
|
50192
|
+
}
|
|
50193
|
+
for (let arrayKey of arrayKeys) {
|
|
50194
|
+
freshByKey[arrayKey] = true;
|
|
50195
|
+
}
|
|
50196
|
+
}
|
|
50197
|
+
function extractArrayDependencies(arrayStateVarObj, dependencyValues, arrayKeys, usedDefault) {
|
|
50198
|
+
let globalDependencyValues = {};
|
|
50199
|
+
let globalUsedDefault = {};
|
|
50200
|
+
for (let dependencyName of arrayStateVarObj.dependencyNames.global) {
|
|
50201
|
+
globalDependencyValues[dependencyName] = dependencyValues[dependencyName];
|
|
50202
|
+
globalUsedDefault[dependencyName] = usedDefault[dependencyName];
|
|
50203
|
+
}
|
|
50204
|
+
let dependencyValuesByKey = {};
|
|
50205
|
+
let usedDefaultByKey = {};
|
|
50206
|
+
let foundAllDependencyValuesForKey = {};
|
|
50207
|
+
for (let arrayKey of arrayKeys) {
|
|
50208
|
+
dependencyValuesByKey[arrayKey] = {};
|
|
50209
|
+
usedDefaultByKey[arrayKey] = {};
|
|
50210
|
+
if (arrayKey in arrayStateVarObj.dependencyNames.namesByKey) {
|
|
50211
|
+
foundAllDependencyValuesForKey[arrayKey] = true;
|
|
50212
|
+
for (let dependencyName in arrayStateVarObj.dependencyNames.namesByKey[arrayKey]) {
|
|
50213
|
+
let extendedDepName = arrayStateVarObj.dependencyNames.namesByKey[arrayKey][dependencyName];
|
|
50214
|
+
if (extendedDepName in dependencyValues) {
|
|
50215
|
+
dependencyValuesByKey[arrayKey][dependencyName] = dependencyValues[extendedDepName];
|
|
50216
|
+
usedDefaultByKey[arrayKey][dependencyName] = usedDefault[extendedDepName];
|
|
50217
|
+
} else {
|
|
50218
|
+
foundAllDependencyValuesForKey[arrayKey] = false;
|
|
50219
|
+
}
|
|
50220
|
+
}
|
|
50221
|
+
}
|
|
50222
|
+
}
|
|
50223
|
+
return {
|
|
50224
|
+
globalDependencyValues,
|
|
50225
|
+
globalUsedDefault,
|
|
50226
|
+
dependencyValuesByKey,
|
|
50227
|
+
usedDefaultByKey,
|
|
50228
|
+
foundAllDependencyValuesForKey
|
|
50229
|
+
};
|
|
50230
|
+
}
|
|
50231
|
+
function arrayDefinition(args) {
|
|
50232
|
+
const arrayStateVarObj = resolveArrayStateVarObj(this);
|
|
50233
|
+
const arrayVarName = arrayStateVarObj.svVarName;
|
|
50234
|
+
const component = arrayStateVarObj.svComponent;
|
|
50235
|
+
if (args.arrayKeys === void 0) {
|
|
50236
|
+
args.arrayKeys = arrayStateVarObj.getAllArrayKeys(args.arraySize);
|
|
50237
|
+
}
|
|
50238
|
+
if (arrayStateVarObj.basedOnArrayKeyStateVariables && args.arrayKeys.length > 1) {
|
|
50239
|
+
return {};
|
|
50240
|
+
} else {
|
|
50241
|
+
let extractedDeps = extractArrayDependencies(
|
|
50242
|
+
arrayStateVarObj,
|
|
50243
|
+
args.dependencyValues,
|
|
50244
|
+
args.arrayKeys,
|
|
50245
|
+
args.usedDefault
|
|
50246
|
+
);
|
|
50247
|
+
let globalDependencyValues = extractedDeps.globalDependencyValues;
|
|
50248
|
+
let globalUsedDefault = extractedDeps.globalUsedDefault;
|
|
50249
|
+
let dependencyValuesByKey = extractedDeps.dependencyValuesByKey;
|
|
50250
|
+
let usedDefaultByKey = extractedDeps.usedDefaultByKey;
|
|
50251
|
+
let foundAllDependencyValuesForKey = extractedDeps.foundAllDependencyValuesForKey;
|
|
50252
|
+
delete args.dependencyValues;
|
|
50253
|
+
args.globalDependencyValues = globalDependencyValues;
|
|
50254
|
+
args.globalUsedDefault = globalUsedDefault;
|
|
50255
|
+
args.dependencyValuesByKey = dependencyValuesByKey;
|
|
50256
|
+
args.usedDefaultByKey = usedDefaultByKey;
|
|
50257
|
+
let arrayKeysToRecalculate = [];
|
|
50258
|
+
let freshByKey = args.freshnessInfo.freshByKey;
|
|
50259
|
+
for (let arrayKey of args.arrayKeys) {
|
|
50260
|
+
if (!freshByKey[arrayKey] && foundAllDependencyValuesForKey[arrayKey]) {
|
|
50261
|
+
freshByKey[arrayKey] = true;
|
|
50262
|
+
arrayKeysToRecalculate.push(arrayKey);
|
|
50263
|
+
}
|
|
50264
|
+
}
|
|
50265
|
+
let result2;
|
|
50266
|
+
if (arrayKeysToRecalculate.length === 0) {
|
|
50267
|
+
result2 = {};
|
|
50268
|
+
} else {
|
|
50269
|
+
args.arrayKeys = arrayKeysToRecalculate;
|
|
50270
|
+
if (!arrayStateVarObj.arrayDefinitionByKey) {
|
|
50271
|
+
throw Error(
|
|
50272
|
+
`For ${arrayVarName} of ${component.componentType}, arrayDefinitionByKey must be a function`
|
|
50273
|
+
);
|
|
50274
|
+
}
|
|
50275
|
+
result2 = arrayStateVarObj.arrayDefinitionByKey(args);
|
|
50276
|
+
if (result2.setValue && result2.setValue[arrayVarName]) {
|
|
50277
|
+
for (let arrayKey in result2.setValue[arrayVarName]) {
|
|
50278
|
+
freshByKey[arrayKey] = true;
|
|
50279
|
+
}
|
|
50280
|
+
}
|
|
50281
|
+
if (result2.useEssentialOrDefaultValue && result2.useEssentialOrDefaultValue[arrayVarName]) {
|
|
50282
|
+
for (let arrayKey in result2.useEssentialOrDefaultValue[arrayVarName]) {
|
|
50283
|
+
freshByKey[arrayKey] = true;
|
|
50284
|
+
}
|
|
50285
|
+
}
|
|
50286
|
+
}
|
|
50287
|
+
if (!args.freshnessInfo.freshArraySize) {
|
|
50288
|
+
if (args.changes.__array_size) {
|
|
50289
|
+
result2.arraySizeChanged = [arrayVarName];
|
|
50290
|
+
if (arrayStateVarObj.additionalStateVariablesDefined) {
|
|
50291
|
+
for (let varName of arrayStateVarObj.additionalStateVariablesDefined) {
|
|
50292
|
+
if (component.state[varName].isArray) {
|
|
50293
|
+
result2.arraySizeChanged.push(varName);
|
|
50294
|
+
}
|
|
50295
|
+
}
|
|
50296
|
+
}
|
|
50297
|
+
}
|
|
50298
|
+
args.freshnessInfo.freshArraySize = true;
|
|
50299
|
+
}
|
|
50300
|
+
return result2;
|
|
50301
|
+
}
|
|
50302
|
+
}
|
|
50303
|
+
function arrayInverseDefinition(args) {
|
|
50304
|
+
const arrayStateVarObj = resolveArrayStateVarObj(this);
|
|
50305
|
+
const arrayVarName = arrayStateVarObj.svVarName;
|
|
50306
|
+
if (!arrayStateVarObj.inverseArrayDefinitionByKey) {
|
|
50307
|
+
return { success: false };
|
|
50308
|
+
}
|
|
50309
|
+
if (args.arrayKeys === void 0) {
|
|
50310
|
+
args.arrayKeys = arrayStateVarObj.getAllArrayKeys(args.arraySize);
|
|
50311
|
+
}
|
|
50312
|
+
if (arrayStateVarObj.basedOnArrayKeyStateVariables && args.arrayKeys.length > 1) {
|
|
50313
|
+
const allStateVariablesAffected = [
|
|
50314
|
+
arrayVarName,
|
|
50315
|
+
...arrayStateVarObj.additionalStateVariablesDefined ?? []
|
|
50316
|
+
];
|
|
50317
|
+
let instructions = [];
|
|
50318
|
+
for (let vName of allStateVariablesAffected) {
|
|
50319
|
+
for (let key in args.desiredStateVariableValues[vName]) {
|
|
50320
|
+
let depName = vName + "_" + key;
|
|
50321
|
+
if (depName in args.dependencyValues) {
|
|
50322
|
+
instructions.push({
|
|
50323
|
+
setDependency: depName,
|
|
50324
|
+
desiredValue: args.desiredStateVariableValues[vName][key],
|
|
50325
|
+
treatAsInitialChange: args.initialChange
|
|
50326
|
+
});
|
|
50327
|
+
}
|
|
50328
|
+
}
|
|
50329
|
+
}
|
|
50330
|
+
return {
|
|
50331
|
+
success: true,
|
|
50332
|
+
instructions
|
|
50333
|
+
};
|
|
50334
|
+
} else {
|
|
50335
|
+
let extractedDeps = extractArrayDependencies(
|
|
50336
|
+
arrayStateVarObj,
|
|
50337
|
+
args.dependencyValues,
|
|
50338
|
+
args.arrayKeys,
|
|
50339
|
+
args.usedDefault
|
|
50340
|
+
);
|
|
50341
|
+
let globalDependencyValues = extractedDeps.globalDependencyValues;
|
|
50342
|
+
let globalUsedDefault = extractedDeps.globalUsedDefault;
|
|
50343
|
+
let dependencyValuesByKey = extractedDeps.dependencyValuesByKey;
|
|
50344
|
+
let usedDefaultByKey = extractedDeps.usedDefaultByKey;
|
|
50345
|
+
delete args.dependencyValues;
|
|
50346
|
+
args.globalDependencyValues = globalDependencyValues;
|
|
50347
|
+
args.globalUsedDefault = globalUsedDefault;
|
|
50348
|
+
args.dependencyValuesByKey = dependencyValuesByKey;
|
|
50349
|
+
args.usedDefaultByKey = usedDefaultByKey;
|
|
50350
|
+
args.dependencyNamesByKey = arrayStateVarObj.dependencyNames.namesByKey;
|
|
50351
|
+
if (!arrayStateVarObj.allowExtraArrayKeysInInverse) {
|
|
50352
|
+
let newDesiredStateVariableValues = {};
|
|
50353
|
+
for (let vName in args.desiredStateVariableValues) {
|
|
50354
|
+
newDesiredStateVariableValues[vName] = {};
|
|
50355
|
+
for (let key in args.desiredStateVariableValues[vName]) {
|
|
50356
|
+
if (args.arrayKeys.includes(key)) {
|
|
50357
|
+
newDesiredStateVariableValues[vName][key] = args.desiredStateVariableValues[vName][key];
|
|
50358
|
+
}
|
|
50359
|
+
}
|
|
50360
|
+
}
|
|
50361
|
+
args.desiredStateVariableValues = newDesiredStateVariableValues;
|
|
50362
|
+
}
|
|
50363
|
+
let result2 = arrayStateVarObj.inverseArrayDefinitionByKey(args);
|
|
50364
|
+
return result2;
|
|
50365
|
+
}
|
|
50366
|
+
}
|
|
50367
|
+
function getArrayArraySize() {
|
|
50368
|
+
return (async () => {
|
|
50369
|
+
if (!this.svComponent.state[this.arraySizeStateVariable].initiallyResolved) {
|
|
50370
|
+
return [];
|
|
50371
|
+
}
|
|
50372
|
+
if (this.arraySizeStale) {
|
|
50373
|
+
await this.recalculateArraySizeDependentQuantities();
|
|
50374
|
+
}
|
|
50375
|
+
return await this.svComponent.stateValues[this.arraySizeStateVariable];
|
|
50376
|
+
})();
|
|
50377
|
+
}
|
|
50378
|
+
const ARRAY_ARRAY_SIZE_DESCRIPTOR = Object.freeze({
|
|
50379
|
+
get: getArrayArraySize
|
|
50380
|
+
});
|
|
50381
|
+
function normalizeArrayStateVariableDefaults(def, varName) {
|
|
50382
|
+
if (!def.isArray) {
|
|
50383
|
+
return;
|
|
50384
|
+
}
|
|
50385
|
+
if (def.numDimensions === void 0) {
|
|
50386
|
+
def.numDimensions = 1;
|
|
50387
|
+
}
|
|
50388
|
+
if (!def.entryPrefixes) {
|
|
50389
|
+
def.entryPrefixes = [varName];
|
|
50390
|
+
}
|
|
50391
|
+
const multiDim = def.numDimensions > 1;
|
|
50392
|
+
if (!def.keyToIndex) {
|
|
50393
|
+
def.keyToIndex = multiDim ? multiDimKeyToIndex : oneDimKeyToIndex;
|
|
50394
|
+
}
|
|
50395
|
+
if (!def.indexToKey) {
|
|
50396
|
+
def.indexToKey = arrayIndexToKey;
|
|
50397
|
+
}
|
|
50398
|
+
if (!def.getAllArrayKeys) {
|
|
50399
|
+
def.getAllArrayKeys = multiDim ? multiDimGetAllArrayKeys : oneDimGetAllArrayKeys;
|
|
50400
|
+
}
|
|
50401
|
+
if (!def.getArrayKeysFromVarName) {
|
|
50402
|
+
def.getArrayKeysFromVarName = returnDefaultGetArrayKeysFromVarName(
|
|
50403
|
+
def.numDimensions
|
|
50404
|
+
);
|
|
50405
|
+
}
|
|
50406
|
+
if (!def.arrayVarNameFromArrayKey) {
|
|
50407
|
+
def.arrayVarNameFromArrayKey = multiDim ? defaultMultiDimArrayVarNameFromArrayKey : defaultOneDimArrayVarNameFromArrayKey;
|
|
50408
|
+
}
|
|
50409
|
+
if (!def.arrayVarNameFromPropIndex) {
|
|
50410
|
+
def.arrayVarNameFromPropIndex = returnDefaultArrayVarNameFromPropIndex(
|
|
50411
|
+
def.numDimensions,
|
|
50412
|
+
def.entryPrefixes[0]
|
|
50413
|
+
);
|
|
50414
|
+
}
|
|
50415
|
+
if (!def.returnEntryDimensions) {
|
|
50416
|
+
def.returnEntryDimensions = defaultReturnEntryDimensions;
|
|
50417
|
+
}
|
|
50418
|
+
if (def.shadowingInstructions && !def.shadowingInstructions.returnWrappingComponents) {
|
|
50419
|
+
def.shadowingInstructions.returnWrappingComponents = defaultReturnWrappingComponents;
|
|
50420
|
+
}
|
|
50421
|
+
}
|
|
50422
|
+
function arraySizeDefinition({ dependencyValues }) {
|
|
50423
|
+
let arraySize2 = this.svComponent.state[this.arraySizeSourceVarName].returnArraySize({
|
|
50424
|
+
dependencyValues
|
|
50425
|
+
});
|
|
50426
|
+
for (let [ind, value] of arraySize2.entries()) {
|
|
50427
|
+
if (!(Number.isInteger(value) && value >= 0)) {
|
|
50428
|
+
arraySize2[ind] = 0;
|
|
50429
|
+
}
|
|
50430
|
+
}
|
|
50431
|
+
return { setValue: { [this.svVarName]: arraySize2 } };
|
|
50432
|
+
}
|
|
50433
|
+
function arraySizeMarkStale() {
|
|
50434
|
+
for (let varName of this.arraySizeVarNamesAffected) {
|
|
50435
|
+
this.svComponent.state[varName].arraySizeStale = true;
|
|
50436
|
+
}
|
|
50437
|
+
return {};
|
|
50438
|
+
}
|
|
50439
|
+
async function arrayRecalculateArraySizeDependentQuantities() {
|
|
50440
|
+
const component = this.svComponent;
|
|
50441
|
+
let newArraySize = await component.stateValues[this.arraySizeStateVariable];
|
|
50442
|
+
if (this.previousArraySize.length !== newArraySize.length || this.previousArraySize.some((v2, i2) => v2 != newArraySize[i2])) {
|
|
50443
|
+
this.previousArraySize = [...newArraySize];
|
|
50444
|
+
let varNamesIncluding = this.varNamesIncludingArrayKeys = {};
|
|
50445
|
+
for (let entryName of this.arrayEntryNames) {
|
|
50446
|
+
let entryStateVarObj = component.state[entryName];
|
|
50447
|
+
let arrayKeys = this.getArrayKeysFromVarName({
|
|
50448
|
+
arrayEntryPrefix: entryStateVarObj.entryPrefix,
|
|
50449
|
+
varEnding: entryStateVarObj.varEnding,
|
|
50450
|
+
arraySize: newArraySize,
|
|
50451
|
+
numDimensions: this.numDimensions
|
|
50452
|
+
});
|
|
50453
|
+
entryStateVarObj._unflattenedArrayKeys = arrayKeys;
|
|
50454
|
+
entryStateVarObj._arrayKeys = flattenDeep(arrayKeys);
|
|
50455
|
+
for (let arrayKey of entryStateVarObj._arrayKeys) {
|
|
50456
|
+
if (!varNamesIncluding[arrayKey]) {
|
|
50457
|
+
varNamesIncluding[arrayKey] = [];
|
|
50458
|
+
}
|
|
50459
|
+
varNamesIncluding[arrayKey].push(entryName);
|
|
50460
|
+
}
|
|
50461
|
+
}
|
|
50462
|
+
}
|
|
50463
|
+
this.arraySizeStale = false;
|
|
50464
|
+
}
|
|
50465
|
+
async function entryReturnDependencies(args) {
|
|
50466
|
+
const arrayStateVarObj = this.svComponent.state[this.arrayStateVariable];
|
|
50467
|
+
args.arraySize = await this.arraySize;
|
|
50468
|
+
args.arrayKeys = await this.arrayKeys;
|
|
50469
|
+
let dependencies2 = await arrayStateVarObj.returnDependencies(args);
|
|
50470
|
+
let numNames = Object.keys(
|
|
50471
|
+
arrayStateVarObj.dependencyNames.namesByKey
|
|
50472
|
+
).length;
|
|
50473
|
+
if (this.numberNamesInPreviousReturnDep !== numNames) {
|
|
50474
|
+
args.changedDependency = true;
|
|
50475
|
+
}
|
|
50476
|
+
this.numberNamesInPreviousReturnDep = numNames;
|
|
50477
|
+
return dependencies2;
|
|
50478
|
+
}
|
|
50479
|
+
async function initializeComponentStateVariables({
|
|
50480
|
+
core: core2,
|
|
50481
|
+
component
|
|
50482
|
+
}) {
|
|
50483
|
+
for (let stateVariable in component.state) {
|
|
50484
|
+
if (component.state[stateVariable].isAlias) {
|
|
50485
|
+
if (!component.stateVarAliases) {
|
|
50486
|
+
component.stateVarAliases = {};
|
|
50487
|
+
}
|
|
50488
|
+
component.stateVarAliases[stateVariable] = component.state[stateVariable].targetVariableName;
|
|
50489
|
+
delete component.state[stateVariable];
|
|
50490
|
+
} else {
|
|
50491
|
+
await initializeStateVariable({
|
|
50492
|
+
core: core2,
|
|
50493
|
+
component,
|
|
50494
|
+
stateVariable
|
|
50495
|
+
});
|
|
50496
|
+
}
|
|
50497
|
+
}
|
|
50498
|
+
}
|
|
50499
|
+
async function initializeStateVariable({
|
|
50500
|
+
core: core2,
|
|
50501
|
+
component,
|
|
50502
|
+
stateVariable,
|
|
50503
|
+
arrayStateVariable,
|
|
50504
|
+
arrayEntryPrefix
|
|
50505
|
+
}) {
|
|
50506
|
+
if (!component.state[stateVariable]) {
|
|
50507
|
+
component.state[stateVariable] = {};
|
|
50508
|
+
}
|
|
50509
|
+
let stateVarObj = component.state[stateVariable];
|
|
50510
|
+
stateVarObj.svComponent = component;
|
|
50511
|
+
stateVarObj.svVarName = stateVariable;
|
|
50512
|
+
stateVarObj.isResolved = false;
|
|
50513
|
+
installStaleValueGetter(stateVarObj);
|
|
50514
|
+
if (arrayEntryPrefix !== void 0) {
|
|
50515
|
+
await initializeArrayEntryStateVariable({
|
|
50516
|
+
stateVarObj,
|
|
50517
|
+
arrayStateVariable,
|
|
50518
|
+
arrayEntryPrefix,
|
|
50519
|
+
component,
|
|
50520
|
+
stateVariable
|
|
50521
|
+
});
|
|
50522
|
+
} else if (stateVarObj.isArray) {
|
|
50523
|
+
await initializeArrayStateVariable({
|
|
50524
|
+
core: core2,
|
|
50525
|
+
stateVarObj,
|
|
50526
|
+
component,
|
|
50527
|
+
stateVariable
|
|
50528
|
+
});
|
|
50529
|
+
}
|
|
50530
|
+
if (stateVarObj.triggerActionOnChange) {
|
|
50531
|
+
let componentTriggers = core2.stateVariableChangeTriggers[component.componentIdx];
|
|
50532
|
+
if (!componentTriggers) {
|
|
50533
|
+
componentTriggers = core2.stateVariableChangeTriggers[component.componentIdx] = {};
|
|
50534
|
+
}
|
|
50535
|
+
componentTriggers[stateVariable] = {
|
|
50536
|
+
action: stateVarObj.triggerActionOnChange
|
|
50537
|
+
};
|
|
50538
|
+
}
|
|
51012
50539
|
}
|
|
51013
|
-
function
|
|
51014
|
-
|
|
51015
|
-
|
|
51016
|
-
|
|
51017
|
-
|
|
50540
|
+
async function initializeArrayEntryStateVariable({
|
|
50541
|
+
stateVarObj,
|
|
50542
|
+
arrayStateVariable,
|
|
50543
|
+
arrayEntryPrefix,
|
|
50544
|
+
component,
|
|
50545
|
+
stateVariable
|
|
50546
|
+
}) {
|
|
50547
|
+
stateVarObj.isArrayEntry = true;
|
|
50548
|
+
stateVarObj.arrayStateVariable = arrayStateVariable;
|
|
50549
|
+
let arrayStateVarObj = component.state[arrayStateVariable];
|
|
50550
|
+
stateVarObj.definition = arrayStateVarObj.definition;
|
|
50551
|
+
stateVarObj.inverseDefinition = arrayStateVarObj.inverseDefinition;
|
|
50552
|
+
stateVarObj.markStale = arrayStateVarObj.markStale;
|
|
50553
|
+
stateVarObj.freshnessInfo = arrayStateVarObj.freshnessInfo;
|
|
50554
|
+
stateVarObj.getPreviousDependencyValuesForMarkStale = arrayStateVarObj.getPreviousDependencyValuesForMarkStale;
|
|
50555
|
+
stateVarObj.provideEssentialValuesInDefinition = arrayStateVarObj.provideEssentialValuesInDefinition;
|
|
50556
|
+
stateVarObj.providePreviousValuesInDefinition = arrayStateVarObj.providePreviousValuesInDefinition;
|
|
50557
|
+
stateVarObj.isLocation = arrayStateVarObj.isLocation;
|
|
50558
|
+
stateVarObj.numDimensions = arrayStateVarObj.returnEntryDimensions(arrayEntryPrefix);
|
|
50559
|
+
stateVarObj.entryPrefix = arrayEntryPrefix;
|
|
50560
|
+
stateVarObj.varEnding = stateVariable.slice(arrayEntryPrefix.length);
|
|
50561
|
+
if (arrayStateVarObj.createWorkspace) {
|
|
50562
|
+
stateVarObj.createWorkspace = true;
|
|
50563
|
+
stateVarObj.workspace = arrayStateVarObj.workspace;
|
|
50564
|
+
}
|
|
50565
|
+
if (arrayStateVarObj.basedOnArrayKeyStateVariables) {
|
|
50566
|
+
stateVarObj.basedOnArrayKeyStateVariables = true;
|
|
50567
|
+
}
|
|
50568
|
+
if (arrayStateVarObj.additionalStateVariablesDefined) {
|
|
50569
|
+
stateVarObj.additionalStateVariablesDefined = [];
|
|
50570
|
+
let entryPrefixInd = arrayStateVarObj.entryPrefixes.indexOf(arrayEntryPrefix);
|
|
50571
|
+
for (let varName of arrayStateVarObj.additionalStateVariablesDefined) {
|
|
50572
|
+
let sObj = component.state[varName];
|
|
50573
|
+
if (sObj.isArray) {
|
|
50574
|
+
let newArrayEntryPrefix = sObj.entryPrefixes[entryPrefixInd];
|
|
50575
|
+
let arrayEntryVarName = newArrayEntryPrefix + stateVarObj.varEnding;
|
|
50576
|
+
stateVarObj.additionalStateVariablesDefined.push(
|
|
50577
|
+
arrayEntryVarName
|
|
50578
|
+
);
|
|
51018
50579
|
} else {
|
|
51019
|
-
|
|
50580
|
+
stateVarObj.additionalStateVariablesDefined.push(varName);
|
|
51020
50581
|
}
|
|
51021
50582
|
}
|
|
51022
50583
|
}
|
|
51023
|
-
|
|
51024
|
-
|
|
51025
|
-
|
|
51026
|
-
|
|
51027
|
-
|
|
51028
|
-
|
|
51029
|
-
|
|
51030
|
-
|
|
51031
|
-
|
|
51032
|
-
|
|
51033
|
-
|
|
51034
|
-
|
|
51035
|
-
|
|
51036
|
-
|
|
51037
|
-
}
|
|
50584
|
+
if (arrayStateVarObj.shadowingInstructions) {
|
|
50585
|
+
stateVarObj.shadowingInstructions = {};
|
|
50586
|
+
stateVarObj.wrappingComponents = arrayStateVarObj.shadowingInstructions.returnWrappingComponents(
|
|
50587
|
+
arrayEntryPrefix
|
|
50588
|
+
);
|
|
50589
|
+
if (arrayStateVarObj.shadowingInstructions.attributesToShadow) {
|
|
50590
|
+
stateVarObj.shadowingInstructions.attributesToShadow = arrayStateVarObj.shadowingInstructions.attributesToShadow;
|
|
50591
|
+
}
|
|
50592
|
+
if (arrayStateVarObj.shadowingInstructions.createComponentOfType) {
|
|
50593
|
+
let entryPrefixInd = arrayStateVarObj.entryPrefixes.indexOf(arrayEntryPrefix);
|
|
50594
|
+
if (arrayStateVarObj.shadowingInstructions.createComponentOfType[entryPrefixInd]) {
|
|
50595
|
+
stateVarObj.shadowingInstructions.createComponentOfType = [
|
|
50596
|
+
arrayStateVarObj.shadowingInstructions.createComponentOfType[entryPrefixInd]
|
|
50597
|
+
];
|
|
51038
50598
|
}
|
|
51039
|
-
return subKeys;
|
|
51040
50599
|
}
|
|
51041
50600
|
}
|
|
51042
|
-
if (
|
|
51043
|
-
|
|
51044
|
-
return [];
|
|
51045
|
-
} else {
|
|
51046
|
-
return getAllArrayKeysSub(desiredSize);
|
|
51047
|
-
}
|
|
51048
|
-
} else if (!arraySize2 || arraySize2.length === 0) {
|
|
51049
|
-
return [];
|
|
50601
|
+
if (arrayStateVarObj.getEntryValues) {
|
|
50602
|
+
stateVarObj.getValueFromArrayValues = entryGetValueViaGetEntryValues;
|
|
51050
50603
|
} else {
|
|
51051
|
-
|
|
50604
|
+
stateVarObj.getValueFromArrayValues = entryGetValueFromArrayValues;
|
|
51052
50605
|
}
|
|
51053
|
-
|
|
51054
|
-
|
|
51055
|
-
|
|
51056
|
-
|
|
51057
|
-
|
|
51058
|
-
|
|
51059
|
-
|
|
50606
|
+
stateVarObj.arraySizeStateVariable = arrayStateVarObj.arraySizeStateVariable;
|
|
50607
|
+
stateVarObj._arrayKeys = [];
|
|
50608
|
+
stateVarObj._unflattenedArrayKeys = [];
|
|
50609
|
+
Object.defineProperty(
|
|
50610
|
+
stateVarObj,
|
|
50611
|
+
"arrayKeys",
|
|
50612
|
+
ENTRY_ARRAY_KEYS_DESCRIPTOR
|
|
50613
|
+
);
|
|
50614
|
+
Object.defineProperty(
|
|
50615
|
+
stateVarObj,
|
|
50616
|
+
"unflattenedArrayKeys",
|
|
50617
|
+
ENTRY_UNFLATTENED_ARRAY_KEYS_DESCRIPTOR
|
|
50618
|
+
);
|
|
50619
|
+
if (component.state[stateVarObj.arraySizeStateVariable].initiallyResolved) {
|
|
50620
|
+
let arraySize2 = await arrayStateVarObj.arraySize;
|
|
50621
|
+
let arrayKeys = arrayStateVarObj.getArrayKeysFromVarName({
|
|
50622
|
+
arrayEntryPrefix: stateVarObj.entryPrefix,
|
|
50623
|
+
varEnding: stateVarObj.varEnding,
|
|
50624
|
+
arraySize: arraySize2,
|
|
50625
|
+
numDimensions: arrayStateVarObj.numDimensions
|
|
50626
|
+
});
|
|
50627
|
+
stateVarObj._unflattenedArrayKeys = arrayKeys;
|
|
50628
|
+
stateVarObj._arrayKeys = flattenDeep(arrayKeys);
|
|
50629
|
+
let varNamesIncluding = arrayStateVarObj.varNamesIncludingArrayKeys;
|
|
50630
|
+
for (let arrayKey of stateVarObj._arrayKeys) {
|
|
50631
|
+
if (!varNamesIncluding[arrayKey]) {
|
|
50632
|
+
varNamesIncluding[arrayKey] = [];
|
|
50633
|
+
}
|
|
50634
|
+
varNamesIncluding[arrayKey].push(stateVariable);
|
|
51060
50635
|
}
|
|
51061
|
-
} else if (!arraySize2 || arraySize2.length === 0) {
|
|
51062
|
-
return [];
|
|
51063
|
-
} else {
|
|
51064
|
-
return Array.from(Array(arraySize2[0]), (_2, i2) => String(i2));
|
|
51065
50636
|
}
|
|
51066
|
-
|
|
51067
|
-
|
|
51068
|
-
|
|
51069
|
-
|
|
51070
|
-
|
|
51071
|
-
|
|
51072
|
-
|
|
51073
|
-
|
|
51074
|
-
|
|
51075
|
-
|
|
51076
|
-
|
|
51077
|
-
|
|
51078
|
-
|
|
51079
|
-
|
|
51080
|
-
|
|
51081
|
-
|
|
51082
|
-
|
|
50637
|
+
arrayStateVarObj.arrayEntryNames.push(stateVariable);
|
|
50638
|
+
Object.defineProperty(
|
|
50639
|
+
stateVarObj,
|
|
50640
|
+
"arraySize",
|
|
50641
|
+
ENTRY_ARRAY_SIZE_DESCRIPTOR
|
|
50642
|
+
);
|
|
50643
|
+
Object.defineProperty(
|
|
50644
|
+
stateVarObj,
|
|
50645
|
+
"arrayEntrySize",
|
|
50646
|
+
ENTRY_ARRAY_ENTRY_SIZE_DESCRIPTOR
|
|
50647
|
+
);
|
|
50648
|
+
if (arrayStateVarObj.stateVariablesDeterminingDependencies) {
|
|
50649
|
+
if (!stateVarObj.stateVariablesDeterminingDependencies) {
|
|
50650
|
+
stateVarObj.stateVariablesDeterminingDependencies = [];
|
|
50651
|
+
}
|
|
50652
|
+
for (let varName of arrayStateVarObj.stateVariablesDeterminingDependencies) {
|
|
50653
|
+
if (!stateVarObj.stateVariablesDeterminingDependencies.includes(
|
|
50654
|
+
varName
|
|
50655
|
+
)) {
|
|
50656
|
+
stateVarObj.stateVariablesDeterminingDependencies.push(varName);
|
|
51083
50657
|
}
|
|
51084
50658
|
}
|
|
51085
50659
|
}
|
|
51086
|
-
|
|
51087
|
-
resizeSubArray(this.arrayValues, arraySize2);
|
|
51088
|
-
}
|
|
51089
|
-
async function oneDimAdjustArrayToNewArraySize() {
|
|
51090
|
-
let arraySize2 = await this.arraySize;
|
|
51091
|
-
this.arrayValues.length = arraySize2[0];
|
|
51092
|
-
}
|
|
51093
|
-
function resolveArrayStateVarObj(svObj) {
|
|
51094
|
-
return svObj.isArrayEntry ? svObj.svComponent.state[svObj.arrayStateVariable] : svObj;
|
|
51095
|
-
}
|
|
51096
|
-
function defaultReturnWrappingComponents(prefix) {
|
|
51097
|
-
return [];
|
|
50660
|
+
stateVarObj.returnDependencies = entryReturnDependencies;
|
|
51098
50661
|
}
|
|
51099
|
-
async function
|
|
51100
|
-
|
|
51101
|
-
|
|
51102
|
-
|
|
51103
|
-
|
|
51104
|
-
|
|
51105
|
-
|
|
51106
|
-
|
|
51107
|
-
|
|
50662
|
+
async function initializeArrayStateVariable({
|
|
50663
|
+
core: core2,
|
|
50664
|
+
stateVarObj,
|
|
50665
|
+
component,
|
|
50666
|
+
stateVariable
|
|
50667
|
+
}) {
|
|
50668
|
+
stateVarObj.arrayValues = [];
|
|
50669
|
+
if (stateVarObj.numDimensions === void 0) {
|
|
50670
|
+
stateVarObj.numDimensions = 1;
|
|
51108
50671
|
}
|
|
51109
|
-
|
|
51110
|
-
|
|
50672
|
+
let entryPrefixes = stateVarObj.entryPrefixes;
|
|
50673
|
+
if (!entryPrefixes) {
|
|
50674
|
+
entryPrefixes = stateVarObj.entryPrefixes = [stateVariable];
|
|
51111
50675
|
}
|
|
51112
|
-
if (!
|
|
51113
|
-
|
|
51114
|
-
namesByKey: {},
|
|
51115
|
-
keysByName: {},
|
|
51116
|
-
global: []
|
|
51117
|
-
};
|
|
51118
|
-
if (arrayStateVarObj.additionalStateVariablesDefined) {
|
|
51119
|
-
for (let vName of arrayStateVarObj.additionalStateVariablesDefined) {
|
|
51120
|
-
component.state[vName].dependencyNames = arrayStateVarObj.dependencyNames;
|
|
51121
|
-
}
|
|
51122
|
-
}
|
|
50676
|
+
if (!component.arrayEntryPrefixes) {
|
|
50677
|
+
component.arrayEntryPrefixes = {};
|
|
51123
50678
|
}
|
|
51124
|
-
let
|
|
51125
|
-
|
|
51126
|
-
|
|
51127
|
-
|
|
51128
|
-
|
|
51129
|
-
|
|
51130
|
-
for (let arrayKey of args.arrayKeys) {
|
|
51131
|
-
for (let vName of allStateVariablesAffected) {
|
|
51132
|
-
let sObj = component.state[vName];
|
|
51133
|
-
dependencies2[vName + "_" + arrayKey] = {
|
|
51134
|
-
dependencyType: "stateVariable",
|
|
51135
|
-
variableName: sObj.arrayVarNameFromArrayKey(arrayKey)
|
|
51136
|
-
};
|
|
51137
|
-
}
|
|
50679
|
+
for (let prefix of entryPrefixes) {
|
|
50680
|
+
component.arrayEntryPrefixes[prefix] = stateVariable;
|
|
50681
|
+
}
|
|
50682
|
+
if (stateVarObj.numDimensions > 1) {
|
|
50683
|
+
if (!stateVarObj.keyToIndex) {
|
|
50684
|
+
stateVarObj.keyToIndex = multiDimKeyToIndex;
|
|
51138
50685
|
}
|
|
51139
|
-
|
|
51140
|
-
|
|
51141
|
-
if (
|
|
51142
|
-
|
|
51143
|
-
|
|
50686
|
+
stateVarObj.setArrayValue = multiDimSetArrayValue;
|
|
50687
|
+
stateVarObj.getArrayValue = multiDimGetArrayValue;
|
|
50688
|
+
if (!stateVarObj.getAllArrayKeys) {
|
|
50689
|
+
stateVarObj.getAllArrayKeys = multiDimGetAllArrayKeys;
|
|
50690
|
+
}
|
|
50691
|
+
if (!stateVarObj.arrayVarNameFromArrayKey) {
|
|
50692
|
+
stateVarObj.arrayVarNameFromArrayKey = defaultMultiDimArrayVarNameFromArrayKey;
|
|
50693
|
+
}
|
|
50694
|
+
if (!stateVarObj.arrayVarNameFromPropIndex) {
|
|
50695
|
+
stateVarObj.arrayVarNameFromPropIndex = returnDefaultArrayVarNameFromPropIndex(
|
|
50696
|
+
stateVarObj.numDimensions,
|
|
50697
|
+
entryPrefixes[0]
|
|
51144
50698
|
);
|
|
51145
|
-
Object.assign(dependencies2, arrayDependencies.globalDependencies);
|
|
51146
50699
|
}
|
|
51147
|
-
|
|
51148
|
-
|
|
50700
|
+
stateVarObj.adjustArrayToNewArraySize = multiDimAdjustArrayToNewArraySize;
|
|
50701
|
+
} else {
|
|
50702
|
+
if (!stateVarObj.keyToIndex) {
|
|
50703
|
+
stateVarObj.keyToIndex = oneDimKeyToIndex;
|
|
51149
50704
|
}
|
|
51150
|
-
|
|
51151
|
-
|
|
51152
|
-
|
|
51153
|
-
|
|
51154
|
-
arrayStateVarObj.dependencyNames.namesByKey[arrayKey] = {};
|
|
51155
|
-
for (let depName in arrayDependencies.dependenciesByKey[arrayKey]) {
|
|
51156
|
-
let extendedDepName = "__" + arrayKey + "_" + depName;
|
|
51157
|
-
dependencies2[extendedDepName] = arrayDependencies.dependenciesByKey[arrayKey][depName];
|
|
51158
|
-
arrayStateVarObj.dependencyNames.namesByKey[arrayKey][depName] = extendedDepName;
|
|
51159
|
-
if (!arrayStateVarObj.dependencyNames.keysByName[extendedDepName]) {
|
|
51160
|
-
arrayStateVarObj.dependencyNames.keysByName[extendedDepName] = [];
|
|
51161
|
-
}
|
|
51162
|
-
if (!arrayStateVarObj.dependencyNames.keysByName[extendedDepName].includes(arrayKey)) {
|
|
51163
|
-
arrayStateVarObj.dependencyNames.keysByName[extendedDepName].push(arrayKey);
|
|
51164
|
-
}
|
|
51165
|
-
}
|
|
50705
|
+
stateVarObj.setArrayValue = oneDimSetArrayValue;
|
|
50706
|
+
stateVarObj.getArrayValue = oneDimGetArrayValue;
|
|
50707
|
+
if (!stateVarObj.getAllArrayKeys) {
|
|
50708
|
+
stateVarObj.getAllArrayKeys = oneDimGetAllArrayKeys;
|
|
51166
50709
|
}
|
|
51167
|
-
|
|
50710
|
+
if (!stateVarObj.arrayVarNameFromArrayKey) {
|
|
50711
|
+
stateVarObj.arrayVarNameFromArrayKey = defaultOneDimArrayVarNameFromArrayKey;
|
|
50712
|
+
}
|
|
50713
|
+
if (!stateVarObj.arrayVarNameFromPropIndex) {
|
|
50714
|
+
stateVarObj.arrayVarNameFromPropIndex = returnDefaultArrayVarNameFromPropIndex(1, entryPrefixes[0]);
|
|
50715
|
+
}
|
|
50716
|
+
stateVarObj.adjustArrayToNewArraySize = oneDimAdjustArrayToNewArraySize;
|
|
51168
50717
|
}
|
|
51169
|
-
|
|
51170
|
-
|
|
51171
|
-
variableName: arrayStateVarObj.arraySizeStateVariable
|
|
51172
|
-
};
|
|
51173
|
-
return dependencies2;
|
|
51174
|
-
}
|
|
51175
|
-
function arrayGetCurrentFreshness({ freshnessInfo, arrayKeys, arraySize: arraySize2 }) {
|
|
51176
|
-
const arrayStateVarObj = resolveArrayStateVarObj(this);
|
|
51177
|
-
const arrayVarName = arrayStateVarObj.svVarName;
|
|
51178
|
-
if (arrayKeys === void 0) {
|
|
51179
|
-
arrayKeys = arrayStateVarObj.getAllArrayKeys(arraySize2);
|
|
50718
|
+
if (!stateVarObj.getArrayKeysFromVarName) {
|
|
50719
|
+
stateVarObj.getArrayKeysFromVarName = returnDefaultGetArrayKeysFromVarName(stateVarObj.numDimensions);
|
|
51180
50720
|
}
|
|
51181
|
-
|
|
51182
|
-
|
|
51183
|
-
|
|
51184
|
-
|
|
51185
|
-
|
|
50721
|
+
if (!stateVarObj.indexToKey) {
|
|
50722
|
+
stateVarObj.indexToKey = arrayIndexToKey;
|
|
50723
|
+
}
|
|
50724
|
+
if (!stateVarObj.returnEntryDimensions) {
|
|
50725
|
+
stateVarObj.returnEntryDimensions = defaultReturnEntryDimensions;
|
|
50726
|
+
}
|
|
50727
|
+
if (stateVarObj.shadowingInstructions) {
|
|
50728
|
+
if (!stateVarObj.shadowingInstructions.returnWrappingComponents) {
|
|
50729
|
+
stateVarObj.shadowingInstructions.returnWrappingComponents = defaultReturnWrappingComponents;
|
|
51186
50730
|
}
|
|
50731
|
+
stateVarObj.wrappingComponents = stateVarObj.shadowingInstructions.returnWrappingComponents();
|
|
51187
50732
|
}
|
|
51188
|
-
|
|
51189
|
-
|
|
51190
|
-
|
|
51191
|
-
|
|
51192
|
-
|
|
50733
|
+
stateVarObj.usedDefaultByArrayKey = {};
|
|
50734
|
+
stateVarObj.arrayEntryNames = [];
|
|
50735
|
+
stateVarObj.varNamesIncludingArrayKeys = {};
|
|
50736
|
+
stateVarObj.returnDependencies = arrayReturnDependencies;
|
|
50737
|
+
stateVarObj.getCurrentFreshness = arrayGetCurrentFreshness;
|
|
50738
|
+
stateVarObj.markStale = arrayMarkStale;
|
|
50739
|
+
stateVarObj.freshenOnNoChanges = arrayFreshenOnNoChanges;
|
|
50740
|
+
stateVarObj.definition = arrayDefinition;
|
|
50741
|
+
stateVarObj.inverseDefinition = arrayInverseDefinition;
|
|
50742
|
+
await createArraySizeStateVariable({
|
|
50743
|
+
core: core2,
|
|
50744
|
+
stateVarObj,
|
|
50745
|
+
component,
|
|
50746
|
+
stateVariable
|
|
50747
|
+
});
|
|
50748
|
+
stateVarObj.arraySizeStale = true;
|
|
50749
|
+
stateVarObj.previousArraySize = [];
|
|
50750
|
+
Object.defineProperty(
|
|
50751
|
+
stateVarObj,
|
|
50752
|
+
"arraySize",
|
|
50753
|
+
ARRAY_ARRAY_SIZE_DESCRIPTOR
|
|
50754
|
+
);
|
|
50755
|
+
stateVarObj.recalculateArraySizeDependentQuantities = arrayRecalculateArraySizeDependentQuantities;
|
|
50756
|
+
if (!stateVarObj.freshnessInfo) {
|
|
50757
|
+
stateVarObj.freshnessInfo = { freshByKey: {} };
|
|
50758
|
+
if (stateVarObj.additionalStateVariablesDefined) {
|
|
50759
|
+
for (let vName of stateVarObj.additionalStateVariablesDefined) {
|
|
50760
|
+
if (!component.state[vName]) {
|
|
50761
|
+
component.state[vName] = {};
|
|
50762
|
+
}
|
|
50763
|
+
component.state[vName].freshnessInfo = stateVarObj.freshnessInfo;
|
|
50764
|
+
}
|
|
51193
50765
|
}
|
|
51194
|
-
} else {
|
|
51195
|
-
return { fresh: { [arrayVarName]: false } };
|
|
51196
50766
|
}
|
|
51197
50767
|
}
|
|
51198
|
-
function
|
|
51199
|
-
|
|
51200
|
-
|
|
51201
|
-
|
|
51202
|
-
|
|
51203
|
-
|
|
51204
|
-
|
|
51205
|
-
if (
|
|
51206
|
-
|
|
50768
|
+
async function createArraySizeStateVariable({
|
|
50769
|
+
core: core2,
|
|
50770
|
+
stateVarObj,
|
|
50771
|
+
component,
|
|
50772
|
+
stateVariable
|
|
50773
|
+
}) {
|
|
50774
|
+
let allStateVariablesAffected = [stateVariable];
|
|
50775
|
+
if (stateVarObj.additionalStateVariablesDefined) {
|
|
50776
|
+
allStateVariablesAffected.push(
|
|
50777
|
+
...stateVarObj.additionalStateVariablesDefined
|
|
50778
|
+
);
|
|
51207
50779
|
}
|
|
51208
|
-
|
|
51209
|
-
|
|
51210
|
-
|
|
51211
|
-
|
|
51212
|
-
|
|
51213
|
-
|
|
50780
|
+
allStateVariablesAffected.sort();
|
|
50781
|
+
let arraySizeStateVar = `__array_size_` + allStateVariablesAffected.join("_");
|
|
50782
|
+
stateVarObj.arraySizeStateVariable = arraySizeStateVar;
|
|
50783
|
+
if (stateVarObj.stateVariablesDeterminingDependencies) {
|
|
50784
|
+
stateVarObj.stateVariablesDeterminingDependencies.push(
|
|
50785
|
+
arraySizeStateVar
|
|
50786
|
+
);
|
|
50787
|
+
} else {
|
|
50788
|
+
stateVarObj.stateVariablesDeterminingDependencies = [arraySizeStateVar];
|
|
51214
50789
|
}
|
|
51215
|
-
if (
|
|
51216
|
-
|
|
51217
|
-
|
|
51218
|
-
|
|
51219
|
-
|
|
51220
|
-
} else {
|
|
51221
|
-
result2.fresh = { [arrayVarName]: false };
|
|
51222
|
-
return result2;
|
|
50790
|
+
if (component.state[arraySizeStateVar]) {
|
|
50791
|
+
if (component.state[arraySizeStateVar].isShadow) {
|
|
50792
|
+
let arraySizeStateVarObj = component.state[arraySizeStateVar];
|
|
50793
|
+
arraySizeStateVarObj.arraySizeVarNamesAffected = allStateVariablesAffected;
|
|
50794
|
+
arraySizeStateVarObj.markStale = arraySizeMarkStale;
|
|
51223
50795
|
}
|
|
50796
|
+
return;
|
|
51224
50797
|
}
|
|
51225
|
-
|
|
51226
|
-
|
|
51227
|
-
|
|
51228
|
-
|
|
51229
|
-
|
|
51230
|
-
|
|
51231
|
-
|
|
51232
|
-
|
|
51233
|
-
|
|
50798
|
+
component.state[arraySizeStateVar] = {
|
|
50799
|
+
returnDependencies: stateVarObj.returnArraySizeDependencies,
|
|
50800
|
+
definition: arraySizeDefinition,
|
|
50801
|
+
markStale: arraySizeMarkStale,
|
|
50802
|
+
arraySizeVarNamesAffected: allStateVariablesAffected,
|
|
50803
|
+
arraySizeSourceVarName: stateVariable
|
|
50804
|
+
};
|
|
50805
|
+
if (stateVarObj.stateVariablesDeterminingArraySizeDependencies) {
|
|
50806
|
+
component.state[arraySizeStateVar].stateVariablesDeterminingDependencies = stateVarObj.stateVariablesDeterminingArraySizeDependencies;
|
|
50807
|
+
}
|
|
50808
|
+
await initializeStateVariable({
|
|
50809
|
+
core: core2,
|
|
50810
|
+
component,
|
|
50811
|
+
stateVariable: arraySizeStateVar
|
|
50812
|
+
});
|
|
50813
|
+
}
|
|
50814
|
+
async function arrayEntryNamesFromPropIndex({
|
|
50815
|
+
core: core2,
|
|
50816
|
+
stateVariables,
|
|
50817
|
+
component,
|
|
50818
|
+
propIndex
|
|
50819
|
+
}) {
|
|
50820
|
+
let newVarNames = [];
|
|
50821
|
+
for (let varName of stateVariables) {
|
|
50822
|
+
let stateVarObj = component.state[varName];
|
|
50823
|
+
if (!stateVarObj) {
|
|
50824
|
+
if (!core2.checkIfArrayEntry({
|
|
50825
|
+
stateVariable: varName,
|
|
50826
|
+
component
|
|
50827
|
+
}).isArrayEntry) {
|
|
50828
|
+
newVarNames.push(varName);
|
|
50829
|
+
continue;
|
|
51234
50830
|
}
|
|
50831
|
+
await core2.createFromArrayEntry({
|
|
50832
|
+
stateVariable: varName,
|
|
50833
|
+
component
|
|
50834
|
+
});
|
|
50835
|
+
stateVarObj = component.state[varName];
|
|
51235
50836
|
}
|
|
51236
|
-
|
|
51237
|
-
|
|
50837
|
+
let newName;
|
|
50838
|
+
if (stateVarObj.isArray) {
|
|
50839
|
+
newName = stateVarObj.arrayVarNameFromPropIndex(propIndex, varName);
|
|
50840
|
+
} else if (stateVarObj.isArrayEntry) {
|
|
50841
|
+
let arrayStateVarObj = component.state[stateVarObj.arrayStateVariable];
|
|
50842
|
+
newName = arrayStateVarObj.arrayVarNameFromPropIndex(
|
|
50843
|
+
propIndex,
|
|
50844
|
+
varName
|
|
50845
|
+
);
|
|
51238
50846
|
} else {
|
|
51239
|
-
|
|
51240
|
-
|
|
51241
|
-
|
|
50847
|
+
core2.addDiagnostic({
|
|
50848
|
+
type: "warning",
|
|
50849
|
+
message: `Cannot get propIndex from ${varName} of ${component.componentIdx} as it is not an array or array entry state variable`,
|
|
50850
|
+
position: component.position,
|
|
50851
|
+
sourceDoc: component.sourceDoc
|
|
50852
|
+
});
|
|
50853
|
+
newName = varName;
|
|
51242
50854
|
}
|
|
51243
|
-
|
|
51244
|
-
|
|
51245
|
-
|
|
51246
|
-
|
|
51247
|
-
|
|
50855
|
+
if (newName) {
|
|
50856
|
+
newVarNames.push(newName);
|
|
50857
|
+
} else {
|
|
50858
|
+
core2.addDiagnostic({
|
|
50859
|
+
type: "warning",
|
|
50860
|
+
message: `Cannot get propIndex from ${varName} of ${component.componentIdx}`,
|
|
50861
|
+
position: component.position,
|
|
50862
|
+
sourceDoc: component.sourceDoc
|
|
50863
|
+
});
|
|
50864
|
+
newVarNames.push(varName);
|
|
51248
50865
|
}
|
|
51249
50866
|
}
|
|
51250
|
-
|
|
51251
|
-
|
|
51252
|
-
|
|
51253
|
-
|
|
51254
|
-
|
|
51255
|
-
|
|
51256
|
-
|
|
50867
|
+
return newVarNames;
|
|
50868
|
+
}
|
|
50869
|
+
const PRIMITIVE_TO_COMPONENT_TYPE = {
|
|
50870
|
+
string: "text",
|
|
50871
|
+
stringArray: "textList",
|
|
50872
|
+
numberArray: "numberList"
|
|
50873
|
+
};
|
|
50874
|
+
const SHARED_STATE_VARIABLE_DEFINITIONS = /* @__PURE__ */ Symbol(
|
|
50875
|
+
"sharedStateVariableDefinitions"
|
|
50876
|
+
);
|
|
50877
|
+
const classStateVariableDefinitionsCache = /* @__PURE__ */ new WeakMap();
|
|
50878
|
+
function getClassStateVariableDefinitions(core2, componentClass) {
|
|
50879
|
+
let perCore = classStateVariableDefinitionsCache.get(core2);
|
|
50880
|
+
if (!perCore) {
|
|
50881
|
+
perCore = /* @__PURE__ */ new Map();
|
|
50882
|
+
classStateVariableDefinitionsCache.set(core2, perCore);
|
|
50883
|
+
}
|
|
50884
|
+
let entry = perCore.get(componentClass);
|
|
50885
|
+
if (!entry) {
|
|
50886
|
+
const combined = {};
|
|
50887
|
+
createAttributeStateVariableDefinitions({
|
|
50888
|
+
core: core2,
|
|
50889
|
+
stateVariableDefinitions: combined,
|
|
50890
|
+
componentClass
|
|
50891
|
+
});
|
|
50892
|
+
const normalized = componentClass.returnNormalizedStateVariableDefinitions(
|
|
50893
|
+
core2.numerics
|
|
50894
|
+
);
|
|
50895
|
+
Object.assign(combined, normalized);
|
|
50896
|
+
for (const varName in combined) {
|
|
50897
|
+
normalizeArrayStateVariableDefaults(combined[varName], varName);
|
|
51257
50898
|
}
|
|
51258
|
-
|
|
51259
|
-
|
|
51260
|
-
|
|
50899
|
+
combined[SHARED_STATE_VARIABLE_DEFINITIONS] = true;
|
|
50900
|
+
entry = { combined, normalized };
|
|
50901
|
+
perCore.set(componentClass, entry);
|
|
51261
50902
|
}
|
|
50903
|
+
return entry;
|
|
51262
50904
|
}
|
|
51263
|
-
function
|
|
51264
|
-
const
|
|
51265
|
-
|
|
51266
|
-
|
|
51267
|
-
|
|
50905
|
+
function cloneStateVariableDefinition(def) {
|
|
50906
|
+
const clone2 = Object.assign({}, def);
|
|
50907
|
+
if (clone2.shadowingInstructions) {
|
|
50908
|
+
clone2.shadowingInstructions = Object.assign(
|
|
50909
|
+
{},
|
|
50910
|
+
clone2.shadowingInstructions
|
|
50911
|
+
);
|
|
51268
50912
|
}
|
|
51269
|
-
|
|
51270
|
-
|
|
50913
|
+
if (clone2.additionalStateVariablesDefined) {
|
|
50914
|
+
clone2.additionalStateVariablesDefined = [
|
|
50915
|
+
...clone2.additionalStateVariablesDefined
|
|
50916
|
+
];
|
|
50917
|
+
}
|
|
50918
|
+
if (clone2.stateVariablesDeterminingDependencies) {
|
|
50919
|
+
clone2.stateVariablesDeterminingDependencies = [
|
|
50920
|
+
...clone2.stateVariablesDeterminingDependencies
|
|
50921
|
+
];
|
|
51271
50922
|
}
|
|
50923
|
+
return clone2;
|
|
51272
50924
|
}
|
|
51273
|
-
function
|
|
51274
|
-
|
|
51275
|
-
|
|
51276
|
-
|
|
51277
|
-
|
|
51278
|
-
|
|
50925
|
+
async function createStateVariableDefinitions({
|
|
50926
|
+
core: core2,
|
|
50927
|
+
componentClass,
|
|
50928
|
+
prescribedDependencies,
|
|
50929
|
+
componentIdx
|
|
50930
|
+
}) {
|
|
50931
|
+
let redefineDependencies;
|
|
50932
|
+
if (prescribedDependencies) {
|
|
50933
|
+
for (const idxStr in prescribedDependencies) {
|
|
50934
|
+
const idx = Number(idxStr);
|
|
50935
|
+
let depArray = prescribedDependencies[idx];
|
|
50936
|
+
for (let dep of depArray) {
|
|
50937
|
+
if (dep.dependencyType === "referenceShadow") {
|
|
50938
|
+
if (idx === componentIdx) {
|
|
50939
|
+
throw Error(
|
|
50940
|
+
`Circular dependency involving ${componentIdx}.`
|
|
50941
|
+
);
|
|
50942
|
+
}
|
|
50943
|
+
redefineDependencies = {
|
|
50944
|
+
linkSource: "referenceShadow",
|
|
50945
|
+
targetIdx: idx,
|
|
50946
|
+
compositeIdx: dep.compositeIdx,
|
|
50947
|
+
propVariable: dep.propVariable,
|
|
50948
|
+
fromImplicitProp: dep.fromImplicitProp,
|
|
50949
|
+
arrayStateVariable: dep.arrayStateVariable,
|
|
50950
|
+
arrayKey: dep.arrayKey,
|
|
50951
|
+
ignorePrimaryStateVariable: dep.ignorePrimaryStateVariable,
|
|
50952
|
+
substituteForPrimaryStateVariable: dep.substituteForPrimaryStateVariable,
|
|
50953
|
+
firstLevelReplacement: dep.firstLevelReplacement,
|
|
50954
|
+
additionalStateVariableShadowing: dep.additionalStateVariableShadowing
|
|
50955
|
+
};
|
|
50956
|
+
} else if (dep.dependencyType === "adapter") {
|
|
50957
|
+
redefineDependencies = {
|
|
50958
|
+
linkSource: "adapter",
|
|
50959
|
+
adapterTargetIdentity: dep.adapterTargetIdentity,
|
|
50960
|
+
adapterVariable: dep.adapterVariable,
|
|
50961
|
+
substituteForPrimaryStateVariable: dep.substituteForPrimaryStateVariable,
|
|
50962
|
+
stateVariablesToShadow: dep.stateVariablesToShadow
|
|
50963
|
+
};
|
|
50964
|
+
}
|
|
50965
|
+
}
|
|
50966
|
+
}
|
|
51279
50967
|
}
|
|
51280
|
-
|
|
51281
|
-
|
|
51282
|
-
|
|
51283
|
-
|
|
51284
|
-
|
|
51285
|
-
|
|
51286
|
-
|
|
51287
|
-
|
|
51288
|
-
|
|
51289
|
-
|
|
51290
|
-
|
|
51291
|
-
|
|
51292
|
-
|
|
51293
|
-
|
|
51294
|
-
|
|
50968
|
+
const classDefinitions = getClassStateVariableDefinitions(
|
|
50969
|
+
core2,
|
|
50970
|
+
componentClass
|
|
50971
|
+
);
|
|
50972
|
+
if (!redefineDependencies) {
|
|
50973
|
+
return classDefinitions.combined;
|
|
50974
|
+
}
|
|
50975
|
+
let stateVariableDefinitions = {};
|
|
50976
|
+
for (const varName in classDefinitions.normalized) {
|
|
50977
|
+
stateVariableDefinitions[varName] = cloneStateVariableDefinition(
|
|
50978
|
+
classDefinitions.normalized[varName]
|
|
50979
|
+
);
|
|
50980
|
+
}
|
|
50981
|
+
if (redefineDependencies.linkSource === "adapter") {
|
|
50982
|
+
createAdapterStateVariableDefinitions({
|
|
50983
|
+
core: core2,
|
|
50984
|
+
redefineDependencies,
|
|
50985
|
+
stateVariableDefinitions,
|
|
50986
|
+
componentClass
|
|
50987
|
+
});
|
|
50988
|
+
} else {
|
|
50989
|
+
await createReferenceShadowStateVariableDefinitions({
|
|
50990
|
+
core: core2,
|
|
50991
|
+
redefineDependencies,
|
|
50992
|
+
stateVariableDefinitions,
|
|
50993
|
+
componentClass
|
|
50994
|
+
});
|
|
50995
|
+
}
|
|
50996
|
+
return stateVariableDefinitions;
|
|
50997
|
+
}
|
|
50998
|
+
function createAttributeStateVariableDefinitions({
|
|
50999
|
+
core: core2,
|
|
51000
|
+
componentClass,
|
|
51001
|
+
stateVariableDefinitions
|
|
51002
|
+
}) {
|
|
51003
|
+
let attributes = preprocessAttributesObject(
|
|
51004
|
+
componentClass.createAttributesObject()
|
|
51005
|
+
);
|
|
51006
|
+
for (let attrName in attributes) {
|
|
51007
|
+
let attributeSpecification = attributes[attrName];
|
|
51008
|
+
if (!attributeSpecification.createStateVariable) {
|
|
51009
|
+
continue;
|
|
51010
|
+
}
|
|
51011
|
+
let varName = attributeSpecification.createStateVariable;
|
|
51012
|
+
let stateVarDef = stateVariableDefinitions[varName] = {
|
|
51013
|
+
isAttribute: true,
|
|
51014
|
+
hasEssential: true,
|
|
51015
|
+
provideEssentialValuesInDefinition: true
|
|
51016
|
+
};
|
|
51017
|
+
if (attributeSpecification.public) {
|
|
51018
|
+
_setShadowingInstructionsFromAttribute(
|
|
51019
|
+
stateVarDef,
|
|
51020
|
+
attributeSpecification
|
|
51021
|
+
);
|
|
51022
|
+
}
|
|
51023
|
+
let stateVariableForAttributeValue = _resolveAttributeValueVariable(
|
|
51024
|
+
core2,
|
|
51025
|
+
attributeSpecification,
|
|
51026
|
+
attrName,
|
|
51027
|
+
componentClass
|
|
51028
|
+
);
|
|
51029
|
+
stateVarDef.returnDependencies = function() {
|
|
51030
|
+
return {
|
|
51031
|
+
..._buildAttributeFallbackDependencies(attributeSpecification),
|
|
51032
|
+
..._buildAttributeValueDependency(
|
|
51033
|
+
attributeSpecification,
|
|
51034
|
+
attrName,
|
|
51035
|
+
stateVariableForAttributeValue
|
|
51036
|
+
)
|
|
51037
|
+
};
|
|
51038
|
+
};
|
|
51039
|
+
const { definition, inverseDefinition } = _buildAttributeDerivedDefinitions({
|
|
51040
|
+
varName,
|
|
51041
|
+
stateVariableForAttributeValue,
|
|
51042
|
+
attributeSpecification,
|
|
51043
|
+
attrName
|
|
51044
|
+
});
|
|
51045
|
+
stateVarDef.definition = definition;
|
|
51046
|
+
if (!attributeSpecification.noInverse) {
|
|
51047
|
+
stateVarDef.inverseDefinition = inverseDefinition;
|
|
51048
|
+
}
|
|
51049
|
+
_copyPassthroughAttributes(stateVarDef, attributeSpecification, {
|
|
51050
|
+
includeTriggerActionOnChange: true
|
|
51051
|
+
});
|
|
51052
|
+
}
|
|
51053
|
+
}
|
|
51054
|
+
function createAdapterStateVariableDefinitions({
|
|
51055
|
+
core: core2,
|
|
51056
|
+
redefineDependencies,
|
|
51057
|
+
stateVariableDefinitions,
|
|
51058
|
+
componentClass
|
|
51059
|
+
}) {
|
|
51060
|
+
let adapterTargetComponent = core2._components[redefineDependencies.adapterTargetIdentity.componentIdx];
|
|
51061
|
+
let attributes = preprocessAttributesObject(
|
|
51062
|
+
componentClass.createAttributesObject()
|
|
51063
|
+
);
|
|
51064
|
+
for (let attrName in attributes) {
|
|
51065
|
+
let attributeSpecification = attributes[attrName];
|
|
51066
|
+
if (!attributeSpecification.createStateVariable) {
|
|
51067
|
+
continue;
|
|
51068
|
+
}
|
|
51069
|
+
let varName = attributeSpecification.createStateVariable;
|
|
51070
|
+
let stateVarDef = stateVariableDefinitions[varName] = {
|
|
51071
|
+
isAttribute: true,
|
|
51072
|
+
hasEssential: true
|
|
51073
|
+
};
|
|
51074
|
+
if (attributeSpecification.public) {
|
|
51075
|
+
_setShadowingInstructionsFromAttribute(
|
|
51076
|
+
stateVarDef,
|
|
51077
|
+
attributeSpecification
|
|
51078
|
+
);
|
|
51079
|
+
}
|
|
51080
|
+
if (varName in adapterTargetComponent.state) {
|
|
51081
|
+
stateVarDef.returnDependencies = () => ({
|
|
51082
|
+
adapterTargetVariable: {
|
|
51083
|
+
dependencyType: "stateVariable",
|
|
51084
|
+
componentIdx: redefineDependencies.adapterTargetIdentity.componentIdx,
|
|
51085
|
+
variableName: varName
|
|
51295
51086
|
}
|
|
51087
|
+
});
|
|
51088
|
+
} else {
|
|
51089
|
+
stateVarDef.returnDependencies = () => ({});
|
|
51090
|
+
}
|
|
51091
|
+
stateVarDef.definition = function({ dependencyValues, usedDefault }) {
|
|
51092
|
+
if (dependencyValues.adapterTargetVariable === void 0 || usedDefault.adapterTargetVariable) {
|
|
51093
|
+
return {
|
|
51094
|
+
useEssentialOrDefaultValue: {
|
|
51095
|
+
[varName]: true
|
|
51096
|
+
},
|
|
51097
|
+
checkForActualChange: { [varName]: true }
|
|
51098
|
+
};
|
|
51099
|
+
} else {
|
|
51100
|
+
return {
|
|
51101
|
+
setValue: {
|
|
51102
|
+
[varName]: dependencyValues.adapterTargetVariable
|
|
51103
|
+
},
|
|
51104
|
+
checkForActualChange: { [varName]: true }
|
|
51105
|
+
};
|
|
51296
51106
|
}
|
|
51107
|
+
};
|
|
51108
|
+
if (!attributeSpecification.noInverse) {
|
|
51109
|
+
stateVarDef.inverseDefinition = async function({
|
|
51110
|
+
desiredStateVariableValues,
|
|
51111
|
+
dependencyValues
|
|
51112
|
+
}) {
|
|
51113
|
+
if (dependencyValues.adapterTargetVariable === void 0) {
|
|
51114
|
+
return {
|
|
51115
|
+
success: true,
|
|
51116
|
+
instructions: [
|
|
51117
|
+
{
|
|
51118
|
+
setEssentialValue: varName,
|
|
51119
|
+
value: desiredStateVariableValues[varName]
|
|
51120
|
+
}
|
|
51121
|
+
]
|
|
51122
|
+
};
|
|
51123
|
+
} else {
|
|
51124
|
+
return {
|
|
51125
|
+
success: true,
|
|
51126
|
+
instructions: [
|
|
51127
|
+
{
|
|
51128
|
+
setDependency: "adapterTargetVariable",
|
|
51129
|
+
desiredValue: desiredStateVariableValues[varName]
|
|
51130
|
+
}
|
|
51131
|
+
]
|
|
51132
|
+
};
|
|
51133
|
+
}
|
|
51134
|
+
};
|
|
51297
51135
|
}
|
|
51136
|
+
_copyPassthroughAttributes(stateVarDef, attributeSpecification);
|
|
51298
51137
|
}
|
|
51299
|
-
|
|
51300
|
-
|
|
51301
|
-
|
|
51302
|
-
|
|
51303
|
-
|
|
51304
|
-
|
|
51138
|
+
const { name: primaryStateVariableForDefinition, stateDef } = _resolvePrimaryStateVariableForDefinition({
|
|
51139
|
+
redefineDependencies,
|
|
51140
|
+
componentClass,
|
|
51141
|
+
stateVariableDefinitions,
|
|
51142
|
+
throwIfMissing: false
|
|
51143
|
+
});
|
|
51144
|
+
stateDef.isShadow = true;
|
|
51145
|
+
stateDef.returnDependencies = () => ({
|
|
51146
|
+
adapterTargetVariable: {
|
|
51147
|
+
dependencyType: "stateVariable",
|
|
51148
|
+
componentIdx: redefineDependencies.adapterTargetIdentity.componentIdx,
|
|
51149
|
+
variableName: redefineDependencies.adapterVariable
|
|
51150
|
+
}
|
|
51151
|
+
});
|
|
51152
|
+
if (stateDef.set) {
|
|
51153
|
+
stateDef.definition = function({ dependencyValues }) {
|
|
51154
|
+
return {
|
|
51155
|
+
setValue: {
|
|
51156
|
+
[primaryStateVariableForDefinition]: stateDef.set(
|
|
51157
|
+
dependencyValues.adapterTargetVariable
|
|
51158
|
+
)
|
|
51159
|
+
}
|
|
51160
|
+
};
|
|
51161
|
+
};
|
|
51162
|
+
} else {
|
|
51163
|
+
stateDef.definition = function({ dependencyValues }) {
|
|
51164
|
+
return {
|
|
51165
|
+
setValue: {
|
|
51166
|
+
[primaryStateVariableForDefinition]: dependencyValues.adapterTargetVariable
|
|
51167
|
+
}
|
|
51168
|
+
};
|
|
51169
|
+
};
|
|
51170
|
+
}
|
|
51171
|
+
stateDef.inverseDefinition = function({ desiredStateVariableValues }) {
|
|
51172
|
+
return {
|
|
51173
|
+
success: true,
|
|
51174
|
+
instructions: [
|
|
51175
|
+
{
|
|
51176
|
+
setDependency: "adapterTargetVariable",
|
|
51177
|
+
desiredValue: desiredStateVariableValues[primaryStateVariableForDefinition]
|
|
51178
|
+
}
|
|
51179
|
+
]
|
|
51180
|
+
};
|
|
51305
51181
|
};
|
|
51182
|
+
if (redefineDependencies.stateVariablesToShadow) {
|
|
51183
|
+
modifyStateDefsToBeShadows({
|
|
51184
|
+
stateVariablesToShadow: redefineDependencies.stateVariablesToShadow,
|
|
51185
|
+
stateVariableDefinitions,
|
|
51186
|
+
targetComponent: adapterTargetComponent
|
|
51187
|
+
});
|
|
51188
|
+
}
|
|
51306
51189
|
}
|
|
51307
|
-
function
|
|
51308
|
-
|
|
51309
|
-
|
|
51310
|
-
|
|
51311
|
-
|
|
51312
|
-
|
|
51190
|
+
async function createReferenceShadowStateVariableDefinitions({
|
|
51191
|
+
core: core2,
|
|
51192
|
+
redefineDependencies,
|
|
51193
|
+
stateVariableDefinitions,
|
|
51194
|
+
componentClass
|
|
51195
|
+
}) {
|
|
51196
|
+
let targetComponent = core2._components[redefineDependencies.targetIdx];
|
|
51197
|
+
if (redefineDependencies.propVariable) {
|
|
51198
|
+
if (!targetComponent.state[redefineDependencies.propVariable] && core2.checkIfArrayEntry({
|
|
51199
|
+
stateVariable: redefineDependencies.propVariable,
|
|
51200
|
+
component: targetComponent
|
|
51201
|
+
}).isArrayEntry) {
|
|
51202
|
+
await core2.createFromArrayEntry({
|
|
51203
|
+
stateVariable: redefineDependencies.propVariable,
|
|
51204
|
+
component: targetComponent
|
|
51205
|
+
});
|
|
51206
|
+
}
|
|
51313
51207
|
}
|
|
51314
|
-
|
|
51315
|
-
|
|
51316
|
-
|
|
51317
|
-
|
|
51318
|
-
|
|
51319
|
-
|
|
51320
|
-
|
|
51321
|
-
|
|
51208
|
+
let attributes = preprocessAttributesObject(
|
|
51209
|
+
componentClass.createAttributesObject()
|
|
51210
|
+
);
|
|
51211
|
+
for (let attrName in attributes) {
|
|
51212
|
+
let attributeSpecification = attributes[attrName];
|
|
51213
|
+
let varName = attributeSpecification.createStateVariable;
|
|
51214
|
+
if (!varName) {
|
|
51215
|
+
continue;
|
|
51216
|
+
}
|
|
51217
|
+
let stateVarDef = stateVariableDefinitions[varName] = {
|
|
51218
|
+
isAttribute: true,
|
|
51219
|
+
hasEssential: true,
|
|
51220
|
+
provideEssentialValuesInDefinition: true
|
|
51221
|
+
};
|
|
51222
|
+
!attributeSpecification.createComponentOfType;
|
|
51223
|
+
if (attributeSpecification.public) {
|
|
51224
|
+
_setShadowingInstructionsFromAttribute(
|
|
51225
|
+
stateVarDef,
|
|
51226
|
+
attributeSpecification
|
|
51227
|
+
);
|
|
51228
|
+
}
|
|
51229
|
+
let stateVariableForAttributeValue = _resolveAttributeValueVariable(
|
|
51230
|
+
core2,
|
|
51231
|
+
attributeSpecification,
|
|
51232
|
+
attrName,
|
|
51233
|
+
componentClass
|
|
51322
51234
|
);
|
|
51323
|
-
|
|
51324
|
-
|
|
51325
|
-
|
|
51326
|
-
|
|
51327
|
-
|
|
51328
|
-
|
|
51329
|
-
|
|
51330
|
-
|
|
51331
|
-
|
|
51332
|
-
|
|
51333
|
-
|
|
51334
|
-
|
|
51335
|
-
|
|
51336
|
-
|
|
51337
|
-
|
|
51338
|
-
|
|
51235
|
+
const thisDependencies = {
|
|
51236
|
+
..._buildAttributeValueDependency(
|
|
51237
|
+
attributeSpecification,
|
|
51238
|
+
attrName,
|
|
51239
|
+
stateVariableForAttributeValue
|
|
51240
|
+
),
|
|
51241
|
+
..._buildAttributeFallbackDependencies(attributeSpecification)
|
|
51242
|
+
};
|
|
51243
|
+
stateVarDef.returnDependencies = () => thisDependencies;
|
|
51244
|
+
const { definition, inverseDefinition } = _buildAttributeDerivedDefinitions({
|
|
51245
|
+
varName,
|
|
51246
|
+
stateVariableForAttributeValue,
|
|
51247
|
+
attributeSpecification,
|
|
51248
|
+
attrName
|
|
51249
|
+
});
|
|
51250
|
+
stateVarDef.definition = definition;
|
|
51251
|
+
if (!attributeSpecification.noInverse) {
|
|
51252
|
+
stateVarDef.inverseDefinition = inverseDefinition;
|
|
51253
|
+
}
|
|
51254
|
+
_copyPassthroughAttributes(stateVarDef, attributeSpecification);
|
|
51255
|
+
}
|
|
51256
|
+
if (redefineDependencies.propVariable) {
|
|
51257
|
+
if (!redefineDependencies.ignorePrimaryStateVariable) {
|
|
51258
|
+
const { name: primaryStateVariableForDefinition, stateDef } = _resolvePrimaryStateVariableForDefinition({
|
|
51259
|
+
redefineDependencies,
|
|
51260
|
+
componentClass,
|
|
51261
|
+
stateVariableDefinitions,
|
|
51262
|
+
throwIfMissing: true
|
|
51263
|
+
});
|
|
51264
|
+
stateDef.isShadow = true;
|
|
51265
|
+
stateDef.returnDependencies = () => ({
|
|
51266
|
+
targetVariable: {
|
|
51267
|
+
dependencyType: "stateVariable",
|
|
51268
|
+
componentIdx: targetComponent.componentIdx,
|
|
51269
|
+
variableName: redefineDependencies.propVariable
|
|
51270
|
+
}
|
|
51271
|
+
});
|
|
51272
|
+
let setDefault = false;
|
|
51273
|
+
if (targetComponent.state[redefineDependencies.propVariable].defaultValue !== void 0) {
|
|
51274
|
+
stateDef.defaultValue = targetComponent.state[redefineDependencies.propVariable].defaultValue;
|
|
51275
|
+
if (stateDef.set) {
|
|
51276
|
+
stateDef.defaultValue = stateDef.set(stateDef.defaultValue);
|
|
51277
|
+
}
|
|
51278
|
+
stateDef.hasEssential = true;
|
|
51279
|
+
setDefault = true;
|
|
51280
|
+
}
|
|
51281
|
+
let targetVariableIsArray = targetComponent.state[redefineDependencies.propVariable].isArray;
|
|
51282
|
+
if (stateDef.set) {
|
|
51283
|
+
stateDef.definition = function({
|
|
51284
|
+
dependencyValues,
|
|
51285
|
+
usedDefault
|
|
51286
|
+
}) {
|
|
51287
|
+
let targetVariable = dependencyValues.targetVariable;
|
|
51288
|
+
if (targetVariable === void 0 || targetVariableIsArray && targetVariable.length === 0) {
|
|
51289
|
+
return {
|
|
51290
|
+
useEssentialOrDefaultValue: {
|
|
51291
|
+
[primaryStateVariableForDefinition]: true
|
|
51292
|
+
}
|
|
51293
|
+
};
|
|
51294
|
+
}
|
|
51295
|
+
let valueFromTarget = stateDef.set(targetVariable);
|
|
51296
|
+
if (setDefault && usedDefault.targetVariable) {
|
|
51297
|
+
return {
|
|
51298
|
+
useEssentialOrDefaultValue: {
|
|
51299
|
+
[primaryStateVariableForDefinition]: {
|
|
51300
|
+
defaultValue: valueFromTarget
|
|
51301
|
+
}
|
|
51302
|
+
}
|
|
51303
|
+
};
|
|
51304
|
+
}
|
|
51305
|
+
return {
|
|
51306
|
+
setValue: {
|
|
51307
|
+
[primaryStateVariableForDefinition]: valueFromTarget
|
|
51308
|
+
}
|
|
51309
|
+
};
|
|
51310
|
+
};
|
|
51311
|
+
} else {
|
|
51312
|
+
stateDef.definition = function({
|
|
51313
|
+
dependencyValues,
|
|
51314
|
+
usedDefault
|
|
51315
|
+
}) {
|
|
51316
|
+
let targetVariable = dependencyValues.targetVariable;
|
|
51317
|
+
if (targetVariable === void 0 || targetVariableIsArray && targetVariable.length === 0) {
|
|
51318
|
+
return {
|
|
51319
|
+
useEssentialOrDefaultValue: {
|
|
51320
|
+
[primaryStateVariableForDefinition]: true
|
|
51321
|
+
}
|
|
51322
|
+
};
|
|
51323
|
+
}
|
|
51324
|
+
if (setDefault && usedDefault.targetVariable) {
|
|
51325
|
+
return {
|
|
51326
|
+
useEssentialOrDefaultValue: {
|
|
51327
|
+
[primaryStateVariableForDefinition]: {
|
|
51328
|
+
defaultValue: targetVariable
|
|
51329
|
+
}
|
|
51330
|
+
}
|
|
51331
|
+
};
|
|
51332
|
+
}
|
|
51333
|
+
return {
|
|
51334
|
+
setValue: {
|
|
51335
|
+
[primaryStateVariableForDefinition]: targetVariable
|
|
51336
|
+
}
|
|
51337
|
+
};
|
|
51338
|
+
};
|
|
51339
51339
|
}
|
|
51340
|
+
stateDef.inverseDefinition = function({
|
|
51341
|
+
desiredStateVariableValues
|
|
51342
|
+
}) {
|
|
51343
|
+
return {
|
|
51344
|
+
success: true,
|
|
51345
|
+
instructions: [
|
|
51346
|
+
{
|
|
51347
|
+
setDependency: "targetVariable",
|
|
51348
|
+
desiredValue: desiredStateVariableValues[primaryStateVariableForDefinition]
|
|
51349
|
+
}
|
|
51350
|
+
]
|
|
51351
|
+
};
|
|
51352
|
+
};
|
|
51340
51353
|
}
|
|
51341
|
-
let
|
|
51342
|
-
|
|
51343
|
-
|
|
51344
|
-
|
|
51345
|
-
|
|
51346
|
-
if (!arrayStateVarObj.arrayDefinitionByKey) {
|
|
51347
|
-
throw Error(
|
|
51348
|
-
`For ${arrayVarName} of ${component.componentType}, arrayDefinitionByKey must be a function`
|
|
51349
|
-
);
|
|
51354
|
+
let shadowStandardVariables = false;
|
|
51355
|
+
let stateVariablesToShadow2 = [];
|
|
51356
|
+
if (targetComponent.constructor.implicitPropReturnsSameType) {
|
|
51357
|
+
if (redefineDependencies.fromImplicitProp) {
|
|
51358
|
+
shadowStandardVariables = true;
|
|
51350
51359
|
}
|
|
51351
|
-
|
|
51352
|
-
|
|
51353
|
-
|
|
51354
|
-
|
|
51360
|
+
for (let varName in targetComponent.state) {
|
|
51361
|
+
let stateObj = targetComponent.state[varName];
|
|
51362
|
+
if (stateObj.shadowVariable || stateObj.isShadow) {
|
|
51363
|
+
stateVariablesToShadow2.push(varName);
|
|
51355
51364
|
}
|
|
51356
51365
|
}
|
|
51357
|
-
|
|
51358
|
-
|
|
51359
|
-
|
|
51366
|
+
}
|
|
51367
|
+
if (redefineDependencies.additionalStateVariableShadowing) {
|
|
51368
|
+
let differentStateVariablesInTarget = Array(
|
|
51369
|
+
stateVariablesToShadow2.length
|
|
51370
|
+
);
|
|
51371
|
+
for (let varName in redefineDependencies.additionalStateVariableShadowing) {
|
|
51372
|
+
if (!stateVariablesToShadow2.includes(varName)) {
|
|
51373
|
+
stateVariablesToShadow2.push(varName);
|
|
51374
|
+
differentStateVariablesInTarget.push(
|
|
51375
|
+
redefineDependencies.additionalStateVariableShadowing[varName].stateVariableToShadow
|
|
51376
|
+
);
|
|
51360
51377
|
}
|
|
51361
51378
|
}
|
|
51379
|
+
modifyStateDefsToBeShadows({
|
|
51380
|
+
stateVariablesToShadow: stateVariablesToShadow2,
|
|
51381
|
+
stateVariableDefinitions,
|
|
51382
|
+
targetComponent,
|
|
51383
|
+
differentStateVariablesInTarget
|
|
51384
|
+
});
|
|
51385
|
+
} else if (shadowStandardVariables) {
|
|
51386
|
+
modifyStateDefsToBeShadows({
|
|
51387
|
+
stateVariablesToShadow: stateVariablesToShadow2,
|
|
51388
|
+
stateVariableDefinitions,
|
|
51389
|
+
targetComponent
|
|
51390
|
+
});
|
|
51362
51391
|
}
|
|
51363
|
-
|
|
51364
|
-
|
|
51365
|
-
|
|
51366
|
-
|
|
51367
|
-
|
|
51368
|
-
|
|
51369
|
-
|
|
51370
|
-
|
|
51371
|
-
|
|
51392
|
+
return;
|
|
51393
|
+
}
|
|
51394
|
+
let foundReadyToExpandWhenResolved = false;
|
|
51395
|
+
if ("readyToExpandWhenResolved" in stateVariableDefinitions) {
|
|
51396
|
+
foundReadyToExpandWhenResolved = true;
|
|
51397
|
+
let stateDef = stateVariableDefinitions.readyToExpandWhenResolved;
|
|
51398
|
+
let originalReturnDependencies = stateDef.returnDependencies.bind(stateDef);
|
|
51399
|
+
let originalDefinition = stateDef.definition;
|
|
51400
|
+
stateDef.returnDependencies = function(args) {
|
|
51401
|
+
let dependencies2 = originalReturnDependencies(args);
|
|
51402
|
+
dependencies2.targetReadyToExpandWhenResolved = {
|
|
51403
|
+
dependencyType: "stateVariable",
|
|
51404
|
+
componentIdx: targetComponent.componentIdx,
|
|
51405
|
+
variableName: "readyToExpandWhenResolved"
|
|
51406
|
+
};
|
|
51407
|
+
return dependencies2;
|
|
51408
|
+
};
|
|
51409
|
+
stateDef.definition = function(args) {
|
|
51410
|
+
let result2 = originalDefinition(args);
|
|
51411
|
+
if (result2.setValue && result2.setValue.readyToExpandWhenResolved) {
|
|
51412
|
+
if (!args.dependencyValues.targetReadyToExpandWhenResolved) {
|
|
51413
|
+
result2.setValue.readyToExpandWhenResolved = false;
|
|
51372
51414
|
}
|
|
51373
51415
|
}
|
|
51374
|
-
|
|
51416
|
+
return result2;
|
|
51417
|
+
};
|
|
51418
|
+
}
|
|
51419
|
+
let stateVariablesToShadow = [];
|
|
51420
|
+
for (let varName in targetComponent.state) {
|
|
51421
|
+
let stateObj = targetComponent.state[varName];
|
|
51422
|
+
if (stateObj.shadowVariable || stateObj.isShadow) {
|
|
51423
|
+
stateVariablesToShadow.push(varName);
|
|
51375
51424
|
}
|
|
51376
|
-
return result2;
|
|
51377
51425
|
}
|
|
51426
|
+
modifyStateDefsToBeShadows({
|
|
51427
|
+
stateVariablesToShadow,
|
|
51428
|
+
stateVariableDefinitions,
|
|
51429
|
+
foundReadyToExpandWhenResolved,
|
|
51430
|
+
targetComponent
|
|
51431
|
+
});
|
|
51378
51432
|
}
|
|
51379
|
-
function
|
|
51380
|
-
|
|
51381
|
-
|
|
51382
|
-
|
|
51383
|
-
|
|
51433
|
+
function shadowReturnDependencies(args) {
|
|
51434
|
+
let dependencies2 = Object.assign(
|
|
51435
|
+
{},
|
|
51436
|
+
this.shadowOriginalReturnDependencies?.(args)
|
|
51437
|
+
);
|
|
51438
|
+
dependencies2.targetVariable = {
|
|
51439
|
+
dependencyType: "stateVariable",
|
|
51440
|
+
componentIdx: this.shadowOfComponentIdx,
|
|
51441
|
+
variableName: this.shadowVarNameInTarget
|
|
51442
|
+
};
|
|
51443
|
+
if (this.shadowCopyComponentType) {
|
|
51444
|
+
dependencies2.targetVariableComponentType = {
|
|
51445
|
+
dependencyType: "stateVariableComponentType",
|
|
51446
|
+
componentIdx: this.shadowOfComponentIdx,
|
|
51447
|
+
variableName: this.shadowVarNameInTarget
|
|
51448
|
+
};
|
|
51384
51449
|
}
|
|
51385
|
-
|
|
51386
|
-
|
|
51450
|
+
return dependencies2;
|
|
51451
|
+
}
|
|
51452
|
+
function shadowDefinition({ dependencyValues, usedDefault }) {
|
|
51453
|
+
const varName = this.shadowVarName;
|
|
51454
|
+
let result2 = {};
|
|
51455
|
+
if ("targetVariableComponentType" in dependencyValues) {
|
|
51456
|
+
result2.setCreateComponentOfType = {
|
|
51457
|
+
[varName]: dependencyValues.targetVariableComponentType
|
|
51458
|
+
};
|
|
51387
51459
|
}
|
|
51388
|
-
if (
|
|
51389
|
-
|
|
51390
|
-
|
|
51391
|
-
|
|
51392
|
-
];
|
|
51393
|
-
let instructions = [];
|
|
51394
|
-
for (let vName of allStateVariablesAffected) {
|
|
51395
|
-
for (let key in args.desiredStateVariableValues[vName]) {
|
|
51396
|
-
let depName = vName + "_" + key;
|
|
51397
|
-
if (depName in args.dependencyValues) {
|
|
51398
|
-
instructions.push({
|
|
51399
|
-
setDependency: depName,
|
|
51400
|
-
desiredValue: args.desiredStateVariableValues[vName][key],
|
|
51401
|
-
treatAsInitialChange: args.initialChange
|
|
51402
|
-
});
|
|
51403
|
-
}
|
|
51460
|
+
if (usedDefault.targetVariable && "defaultValue" in this && this.hasEssential) {
|
|
51461
|
+
result2.useEssentialOrDefaultValue = {
|
|
51462
|
+
[varName]: {
|
|
51463
|
+
defaultValue: dependencyValues.targetVariable
|
|
51404
51464
|
}
|
|
51405
|
-
}
|
|
51406
|
-
return {
|
|
51407
|
-
success: true,
|
|
51408
|
-
instructions
|
|
51409
51465
|
};
|
|
51410
51466
|
} else {
|
|
51411
|
-
|
|
51412
|
-
|
|
51413
|
-
|
|
51414
|
-
args.arrayKeys,
|
|
51415
|
-
args.usedDefault
|
|
51416
|
-
);
|
|
51417
|
-
let globalDependencyValues = extractedDeps.globalDependencyValues;
|
|
51418
|
-
let globalUsedDefault = extractedDeps.globalUsedDefault;
|
|
51419
|
-
let dependencyValuesByKey = extractedDeps.dependencyValuesByKey;
|
|
51420
|
-
let usedDefaultByKey = extractedDeps.usedDefaultByKey;
|
|
51421
|
-
delete args.dependencyValues;
|
|
51422
|
-
args.globalDependencyValues = globalDependencyValues;
|
|
51423
|
-
args.globalUsedDefault = globalUsedDefault;
|
|
51424
|
-
args.dependencyValuesByKey = dependencyValuesByKey;
|
|
51425
|
-
args.usedDefaultByKey = usedDefaultByKey;
|
|
51426
|
-
args.dependencyNamesByKey = arrayStateVarObj.dependencyNames.namesByKey;
|
|
51427
|
-
if (!arrayStateVarObj.allowExtraArrayKeysInInverse) {
|
|
51428
|
-
let newDesiredStateVariableValues = {};
|
|
51429
|
-
for (let vName in args.desiredStateVariableValues) {
|
|
51430
|
-
newDesiredStateVariableValues[vName] = {};
|
|
51431
|
-
for (let key in args.desiredStateVariableValues[vName]) {
|
|
51432
|
-
if (args.arrayKeys.includes(key)) {
|
|
51433
|
-
newDesiredStateVariableValues[vName][key] = args.desiredStateVariableValues[vName][key];
|
|
51434
|
-
}
|
|
51435
|
-
}
|
|
51436
|
-
}
|
|
51437
|
-
args.desiredStateVariableValues = newDesiredStateVariableValues;
|
|
51438
|
-
}
|
|
51439
|
-
let result2 = arrayStateVarObj.inverseArrayDefinitionByKey(args);
|
|
51440
|
-
return result2;
|
|
51441
|
-
}
|
|
51442
|
-
}
|
|
51443
|
-
function getArrayArraySize() {
|
|
51444
|
-
return (async () => {
|
|
51445
|
-
if (!this.svComponent.state[this.arraySizeStateVariable].initiallyResolved) {
|
|
51446
|
-
return [];
|
|
51447
|
-
}
|
|
51448
|
-
if (this.arraySizeStale) {
|
|
51449
|
-
await this.recalculateArraySizeDependentQuantities();
|
|
51450
|
-
}
|
|
51451
|
-
return await this.svComponent.stateValues[this.arraySizeStateVariable];
|
|
51452
|
-
})();
|
|
51453
|
-
}
|
|
51454
|
-
const ARRAY_ARRAY_SIZE_DESCRIPTOR = Object.freeze({
|
|
51455
|
-
get: getArrayArraySize
|
|
51456
|
-
});
|
|
51457
|
-
function arraySizeDefinition({ dependencyValues }) {
|
|
51458
|
-
let arraySize2 = this.svComponent.state[this.arraySizeSourceVarName].returnArraySize({
|
|
51459
|
-
dependencyValues
|
|
51460
|
-
});
|
|
51461
|
-
for (let [ind, value] of arraySize2.entries()) {
|
|
51462
|
-
if (!(Number.isInteger(value) && value >= 0)) {
|
|
51463
|
-
arraySize2[ind] = 0;
|
|
51464
|
-
}
|
|
51467
|
+
result2.setValue = {
|
|
51468
|
+
[varName]: dependencyValues.targetVariable
|
|
51469
|
+
};
|
|
51465
51470
|
}
|
|
51466
|
-
return
|
|
51471
|
+
return result2;
|
|
51467
51472
|
}
|
|
51468
|
-
function
|
|
51469
|
-
|
|
51470
|
-
|
|
51471
|
-
|
|
51472
|
-
|
|
51473
|
+
function shadowInverseDefinition({ desiredStateVariableValues }) {
|
|
51474
|
+
return {
|
|
51475
|
+
success: true,
|
|
51476
|
+
instructions: [
|
|
51477
|
+
{
|
|
51478
|
+
setDependency: "targetVariable",
|
|
51479
|
+
desiredValue: desiredStateVariableValues[this.shadowVarName],
|
|
51480
|
+
shadowedVariable: true
|
|
51481
|
+
}
|
|
51482
|
+
]
|
|
51483
|
+
};
|
|
51473
51484
|
}
|
|
51474
|
-
|
|
51475
|
-
|
|
51476
|
-
let
|
|
51477
|
-
|
|
51478
|
-
|
|
51479
|
-
|
|
51480
|
-
|
|
51481
|
-
|
|
51482
|
-
let arrayKeys = this.getArrayKeysFromVarName({
|
|
51483
|
-
arrayEntryPrefix: entryStateVarObj.entryPrefix,
|
|
51484
|
-
varEnding: entryStateVarObj.varEnding,
|
|
51485
|
-
arraySize: newArraySize,
|
|
51486
|
-
numDimensions: this.numDimensions
|
|
51487
|
-
});
|
|
51488
|
-
entryStateVarObj._unflattenedArrayKeys = arrayKeys;
|
|
51489
|
-
entryStateVarObj._arrayKeys = flattenDeep(arrayKeys);
|
|
51490
|
-
for (let arrayKey of entryStateVarObj._arrayKeys) {
|
|
51491
|
-
if (!varNamesIncluding[arrayKey]) {
|
|
51492
|
-
varNamesIncluding[arrayKey] = [];
|
|
51493
|
-
}
|
|
51494
|
-
varNamesIncluding[arrayKey].push(entryName);
|
|
51485
|
+
function shadowReturnArrayDependenciesByKey({ arrayKeys }) {
|
|
51486
|
+
let dependenciesByKey = {};
|
|
51487
|
+
for (let key of arrayKeys) {
|
|
51488
|
+
dependenciesByKey[key] = {
|
|
51489
|
+
targetVariable: {
|
|
51490
|
+
dependencyType: "stateVariable",
|
|
51491
|
+
componentIdx: this.shadowOfComponentIdx,
|
|
51492
|
+
variableName: this.shadowOverrideVarName || this.arrayVarNameFromArrayKey(key)
|
|
51495
51493
|
}
|
|
51496
|
-
}
|
|
51494
|
+
};
|
|
51497
51495
|
}
|
|
51498
|
-
|
|
51499
|
-
|
|
51500
|
-
|
|
51501
|
-
|
|
51502
|
-
|
|
51503
|
-
|
|
51504
|
-
|
|
51505
|
-
let numNames = Object.keys(
|
|
51506
|
-
arrayStateVarObj.dependencyNames.namesByKey
|
|
51507
|
-
).length;
|
|
51508
|
-
if (this.numberNamesInPreviousReturnDep !== numNames) {
|
|
51509
|
-
args.changedDependency = true;
|
|
51496
|
+
let globalDependencies = {};
|
|
51497
|
+
if (this.shadowCopyComponentType) {
|
|
51498
|
+
globalDependencies.targetVariableComponentType = {
|
|
51499
|
+
dependencyType: "stateVariableComponentType",
|
|
51500
|
+
componentIdx: this.shadowOfComponentIdx,
|
|
51501
|
+
variableName: this.shadowVarName
|
|
51502
|
+
};
|
|
51510
51503
|
}
|
|
51511
|
-
this.
|
|
51512
|
-
|
|
51504
|
+
if (this.inverseShadowToSetEntireArray) {
|
|
51505
|
+
globalDependencies.targetArray = {
|
|
51506
|
+
dependencyType: "stateVariable",
|
|
51507
|
+
componentIdx: this.shadowOfComponentIdx,
|
|
51508
|
+
variableName: this.shadowVarName
|
|
51509
|
+
};
|
|
51510
|
+
}
|
|
51511
|
+
return { globalDependencies, dependenciesByKey };
|
|
51513
51512
|
}
|
|
51514
|
-
|
|
51515
|
-
|
|
51516
|
-
|
|
51517
|
-
|
|
51518
|
-
|
|
51519
|
-
|
|
51520
|
-
if (!component.stateVarAliases) {
|
|
51521
|
-
component.stateVarAliases = {};
|
|
51522
|
-
}
|
|
51523
|
-
component.stateVarAliases[stateVariable] = component.state[stateVariable].targetVariableName;
|
|
51524
|
-
delete component.state[stateVariable];
|
|
51513
|
+
function shadowArrayDefinitionByKey({ globalDependencyValues, dependencyValuesByKey, arrayKeys }) {
|
|
51514
|
+
const varName = this.shadowVarName;
|
|
51515
|
+
let newEntries = {};
|
|
51516
|
+
for (let arrayKey of arrayKeys) {
|
|
51517
|
+
if ("targetVariable" in dependencyValuesByKey[arrayKey]) {
|
|
51518
|
+
newEntries[arrayKey] = dependencyValuesByKey[arrayKey].targetVariable;
|
|
51525
51519
|
} else {
|
|
51526
|
-
|
|
51527
|
-
core: core2,
|
|
51528
|
-
component,
|
|
51529
|
-
stateVariable
|
|
51530
|
-
});
|
|
51520
|
+
newEntries[arrayKey] = this.defaultValueByArrayKey?.(arrayKey);
|
|
51531
51521
|
}
|
|
51532
51522
|
}
|
|
51523
|
+
let result2 = {
|
|
51524
|
+
setValue: { [varName]: newEntries }
|
|
51525
|
+
};
|
|
51526
|
+
if ("targetVariableComponentType" in globalDependencyValues) {
|
|
51527
|
+
result2.setCreateComponentOfType = {
|
|
51528
|
+
[varName]: globalDependencyValues.targetVariableComponentType
|
|
51529
|
+
};
|
|
51530
|
+
}
|
|
51531
|
+
return result2;
|
|
51533
51532
|
}
|
|
51534
|
-
|
|
51535
|
-
|
|
51536
|
-
|
|
51537
|
-
|
|
51538
|
-
|
|
51539
|
-
|
|
51533
|
+
function shadowInverseArrayDefinitionByKey({
|
|
51534
|
+
desiredStateVariableValues,
|
|
51535
|
+
dependencyValuesByKey,
|
|
51536
|
+
dependencyNamesByKey,
|
|
51537
|
+
arraySize: arraySize2,
|
|
51538
|
+
initialChange
|
|
51540
51539
|
}) {
|
|
51541
|
-
|
|
51542
|
-
|
|
51543
|
-
|
|
51544
|
-
|
|
51545
|
-
|
|
51546
|
-
|
|
51547
|
-
|
|
51548
|
-
|
|
51549
|
-
|
|
51550
|
-
|
|
51551
|
-
|
|
51552
|
-
|
|
51553
|
-
arrayEntryPrefix,
|
|
51554
|
-
component,
|
|
51555
|
-
stateVariable
|
|
51556
|
-
});
|
|
51557
|
-
} else if (stateVarObj.isArray) {
|
|
51558
|
-
await initializeArrayStateVariable({
|
|
51559
|
-
core: core2,
|
|
51560
|
-
stateVarObj,
|
|
51561
|
-
component,
|
|
51562
|
-
stateVariable
|
|
51563
|
-
});
|
|
51540
|
+
const varName = this.shadowVarName;
|
|
51541
|
+
if (this.inverseShadowToSetEntireArray) {
|
|
51542
|
+
return {
|
|
51543
|
+
success: true,
|
|
51544
|
+
instructions: [
|
|
51545
|
+
{
|
|
51546
|
+
setDependency: "targetArray",
|
|
51547
|
+
desiredValue: desiredStateVariableValues[varName],
|
|
51548
|
+
treatAsInitialChange: initialChange
|
|
51549
|
+
}
|
|
51550
|
+
]
|
|
51551
|
+
};
|
|
51564
51552
|
}
|
|
51565
|
-
|
|
51566
|
-
|
|
51567
|
-
if (!
|
|
51568
|
-
|
|
51553
|
+
let instructions = [];
|
|
51554
|
+
for (let key in desiredStateVariableValues[varName]) {
|
|
51555
|
+
if (!dependencyValuesByKey[key]) {
|
|
51556
|
+
continue;
|
|
51569
51557
|
}
|
|
51570
|
-
|
|
51571
|
-
|
|
51572
|
-
|
|
51558
|
+
instructions.push({
|
|
51559
|
+
setDependency: dependencyNamesByKey[key].targetVariable,
|
|
51560
|
+
desiredValue: desiredStateVariableValues[varName][key],
|
|
51561
|
+
shadowedVariable: true
|
|
51562
|
+
});
|
|
51573
51563
|
}
|
|
51564
|
+
return {
|
|
51565
|
+
success: true,
|
|
51566
|
+
instructions
|
|
51567
|
+
};
|
|
51574
51568
|
}
|
|
51575
|
-
|
|
51576
|
-
|
|
51577
|
-
|
|
51578
|
-
|
|
51579
|
-
|
|
51580
|
-
|
|
51569
|
+
function modifyStateDefsToBeShadows({
|
|
51570
|
+
stateVariablesToShadow,
|
|
51571
|
+
stateVariableDefinitions,
|
|
51572
|
+
foundReadyToExpandWhenResolved,
|
|
51573
|
+
targetComponent,
|
|
51574
|
+
differentStateVariablesInTarget = []
|
|
51581
51575
|
}) {
|
|
51582
|
-
|
|
51583
|
-
|
|
51584
|
-
|
|
51585
|
-
|
|
51586
|
-
|
|
51587
|
-
|
|
51588
|
-
stateVarObj.freshnessInfo = arrayStateVarObj.freshnessInfo;
|
|
51589
|
-
stateVarObj.getPreviousDependencyValuesForMarkStale = arrayStateVarObj.getPreviousDependencyValuesForMarkStale;
|
|
51590
|
-
stateVarObj.provideEssentialValuesInDefinition = arrayStateVarObj.provideEssentialValuesInDefinition;
|
|
51591
|
-
stateVarObj.providePreviousValuesInDefinition = arrayStateVarObj.providePreviousValuesInDefinition;
|
|
51592
|
-
stateVarObj.isLocation = arrayStateVarObj.isLocation;
|
|
51593
|
-
stateVarObj.numDimensions = arrayStateVarObj.returnEntryDimensions(arrayEntryPrefix);
|
|
51594
|
-
stateVarObj.entryPrefix = arrayEntryPrefix;
|
|
51595
|
-
stateVarObj.varEnding = stateVariable.slice(arrayEntryPrefix.length);
|
|
51596
|
-
if (arrayStateVarObj.createWorkspace) {
|
|
51597
|
-
stateVarObj.createWorkspace = true;
|
|
51598
|
-
stateVarObj.workspace = arrayStateVarObj.workspace;
|
|
51599
|
-
}
|
|
51600
|
-
if (arrayStateVarObj.basedOnArrayKeyStateVariables) {
|
|
51601
|
-
stateVarObj.basedOnArrayKeyStateVariables = true;
|
|
51602
|
-
}
|
|
51603
|
-
if (arrayStateVarObj.additionalStateVariablesDefined) {
|
|
51604
|
-
stateVarObj.additionalStateVariablesDefined = [];
|
|
51605
|
-
let entryPrefixInd = arrayStateVarObj.entryPrefixes.indexOf(arrayEntryPrefix);
|
|
51606
|
-
for (let varName of arrayStateVarObj.additionalStateVariablesDefined) {
|
|
51607
|
-
let sObj = component.state[varName];
|
|
51608
|
-
if (sObj.isArray) {
|
|
51609
|
-
let newArrayEntryPrefix = sObj.entryPrefixes[entryPrefixInd];
|
|
51610
|
-
let arrayEntryVarName = newArrayEntryPrefix + stateVarObj.varEnding;
|
|
51611
|
-
stateVarObj.additionalStateVariablesDefined.push(
|
|
51612
|
-
arrayEntryVarName
|
|
51613
|
-
);
|
|
51576
|
+
let deleteStateVariablesFromDefinition = {};
|
|
51577
|
+
for (let [varInd, varName] of stateVariablesToShadow.entries()) {
|
|
51578
|
+
let stateDef = stateVariableDefinitions[varName];
|
|
51579
|
+
if (stateDef === void 0) {
|
|
51580
|
+
if (varName.slice(0, 8) === "__array_") {
|
|
51581
|
+
stateDef = stateVariableDefinitions[varName] = {};
|
|
51614
51582
|
} else {
|
|
51615
|
-
|
|
51583
|
+
continue;
|
|
51616
51584
|
}
|
|
51617
51585
|
}
|
|
51618
|
-
|
|
51619
|
-
|
|
51620
|
-
|
|
51621
|
-
|
|
51622
|
-
|
|
51623
|
-
|
|
51624
|
-
|
|
51625
|
-
|
|
51586
|
+
stateDef.isShadow = true;
|
|
51587
|
+
if (stateDef.additionalStateVariablesDefined) {
|
|
51588
|
+
for (let varName2 of stateDef.additionalStateVariablesDefined) {
|
|
51589
|
+
if (!stateVariablesToShadow.includes(varName2)) {
|
|
51590
|
+
if (!deleteStateVariablesFromDefinition[varName2]) {
|
|
51591
|
+
deleteStateVariablesFromDefinition[varName2] = [];
|
|
51592
|
+
}
|
|
51593
|
+
deleteStateVariablesFromDefinition[varName2].push(varName);
|
|
51594
|
+
}
|
|
51595
|
+
}
|
|
51626
51596
|
}
|
|
51627
|
-
|
|
51628
|
-
|
|
51629
|
-
|
|
51630
|
-
|
|
51631
|
-
|
|
51632
|
-
|
|
51597
|
+
delete stateDef.additionalStateVariablesDefined;
|
|
51598
|
+
if (!foundReadyToExpandWhenResolved) {
|
|
51599
|
+
delete stateDef.stateVariablesDeterminingDependencies;
|
|
51600
|
+
}
|
|
51601
|
+
let copyComponentType = stateDef.public && stateDef.shadowingInstructions.hasVariableComponentType;
|
|
51602
|
+
stateDef.shadowOfComponentIdx = targetComponent.componentIdx;
|
|
51603
|
+
stateDef.shadowVarName = varName;
|
|
51604
|
+
stateDef.shadowCopyComponentType = copyComponentType;
|
|
51605
|
+
if (stateDef.isArray) {
|
|
51606
|
+
stateDef.shadowOverrideVarName = differentStateVariablesInTarget[varInd];
|
|
51607
|
+
stateDef.returnArrayDependenciesByKey = shadowReturnArrayDependenciesByKey;
|
|
51608
|
+
stateDef.arrayDefinitionByKey = shadowArrayDefinitionByKey;
|
|
51609
|
+
stateDef.inverseArrayDefinitionByKey = shadowInverseArrayDefinitionByKey;
|
|
51610
|
+
} else {
|
|
51611
|
+
if (foundReadyToExpandWhenResolved) {
|
|
51612
|
+
stateDef.shadowOriginalReturnDependencies = stateDef.returnDependencies.bind(stateDef);
|
|
51633
51613
|
}
|
|
51614
|
+
stateDef.shadowVarNameInTarget = differentStateVariablesInTarget[varInd] || varName;
|
|
51615
|
+
stateDef.returnDependencies = shadowReturnDependencies;
|
|
51616
|
+
stateDef.definition = shadowDefinition;
|
|
51617
|
+
stateDef.excludeDependencyValuesInInverseDefinition = true;
|
|
51618
|
+
stateDef.inverseDefinition = shadowInverseDefinition;
|
|
51634
51619
|
}
|
|
51635
51620
|
}
|
|
51636
|
-
|
|
51637
|
-
|
|
51638
|
-
|
|
51639
|
-
|
|
51640
|
-
}
|
|
51641
|
-
stateVarObj.arraySizeStateVariable = arrayStateVarObj.arraySizeStateVariable;
|
|
51642
|
-
stateVarObj._arrayKeys = [];
|
|
51643
|
-
stateVarObj._unflattenedArrayKeys = [];
|
|
51644
|
-
Object.defineProperty(
|
|
51645
|
-
stateVarObj,
|
|
51646
|
-
"arrayKeys",
|
|
51647
|
-
ENTRY_ARRAY_KEYS_DESCRIPTOR
|
|
51648
|
-
);
|
|
51649
|
-
Object.defineProperty(
|
|
51650
|
-
stateVarObj,
|
|
51651
|
-
"unflattenedArrayKeys",
|
|
51652
|
-
ENTRY_UNFLATTENED_ARRAY_KEYS_DESCRIPTOR
|
|
51653
|
-
);
|
|
51654
|
-
if (component.state[stateVarObj.arraySizeStateVariable].initiallyResolved) {
|
|
51655
|
-
let arraySize2 = await arrayStateVarObj.arraySize;
|
|
51656
|
-
let arrayKeys = arrayStateVarObj.getArrayKeysFromVarName({
|
|
51657
|
-
arrayEntryPrefix: stateVarObj.entryPrefix,
|
|
51658
|
-
varEnding: stateVarObj.varEnding,
|
|
51659
|
-
arraySize: arraySize2,
|
|
51660
|
-
numDimensions: arrayStateVarObj.numDimensions
|
|
51621
|
+
for (let varName in deleteStateVariablesFromDefinition) {
|
|
51622
|
+
modifyStateDefToDeleteVariableReferences({
|
|
51623
|
+
varNamesToDelete: deleteStateVariablesFromDefinition[varName],
|
|
51624
|
+
stateDef: stateVariableDefinitions[varName]
|
|
51661
51625
|
});
|
|
51662
|
-
stateVarObj._unflattenedArrayKeys = arrayKeys;
|
|
51663
|
-
stateVarObj._arrayKeys = flattenDeep(arrayKeys);
|
|
51664
|
-
let varNamesIncluding = arrayStateVarObj.varNamesIncludingArrayKeys;
|
|
51665
|
-
for (let arrayKey of stateVarObj._arrayKeys) {
|
|
51666
|
-
if (!varNamesIncluding[arrayKey]) {
|
|
51667
|
-
varNamesIncluding[arrayKey] = [];
|
|
51668
|
-
}
|
|
51669
|
-
varNamesIncluding[arrayKey].push(stateVariable);
|
|
51670
|
-
}
|
|
51671
51626
|
}
|
|
51672
|
-
|
|
51673
|
-
|
|
51674
|
-
|
|
51675
|
-
|
|
51676
|
-
|
|
51677
|
-
)
|
|
51678
|
-
|
|
51679
|
-
|
|
51680
|
-
|
|
51681
|
-
|
|
51682
|
-
)
|
|
51683
|
-
|
|
51684
|
-
|
|
51685
|
-
|
|
51686
|
-
|
|
51687
|
-
|
|
51688
|
-
|
|
51689
|
-
|
|
51690
|
-
|
|
51691
|
-
|
|
51627
|
+
}
|
|
51628
|
+
function modifyStateDefToDeleteVariableReferences({
|
|
51629
|
+
varNamesToDelete,
|
|
51630
|
+
stateDef
|
|
51631
|
+
}) {
|
|
51632
|
+
for (let varName2 of varNamesToDelete) {
|
|
51633
|
+
let ind = stateDef.additionalStateVariablesDefined.indexOf(varName2);
|
|
51634
|
+
stateDef.additionalStateVariablesDefined.splice(ind, 1);
|
|
51635
|
+
}
|
|
51636
|
+
let originalDefinition = stateDef.definition;
|
|
51637
|
+
stateDef.definition = function(args) {
|
|
51638
|
+
let results = originalDefinition(args);
|
|
51639
|
+
for (let key in results) {
|
|
51640
|
+
if (Array.isArray(results[key])) {
|
|
51641
|
+
for (let varName2 of varNamesToDelete) {
|
|
51642
|
+
let ind = results[key].indexOf(varName2);
|
|
51643
|
+
if (ind !== -1) {
|
|
51644
|
+
results[key].splice(ind, 1);
|
|
51645
|
+
}
|
|
51646
|
+
}
|
|
51647
|
+
} else {
|
|
51648
|
+
for (let varName2 of varNamesToDelete) {
|
|
51649
|
+
delete results[key][varName2];
|
|
51650
|
+
}
|
|
51692
51651
|
}
|
|
51693
51652
|
}
|
|
51694
|
-
|
|
51695
|
-
|
|
51653
|
+
return results;
|
|
51654
|
+
};
|
|
51696
51655
|
}
|
|
51697
|
-
|
|
51698
|
-
|
|
51699
|
-
|
|
51700
|
-
|
|
51701
|
-
|
|
51702
|
-
|
|
51703
|
-
|
|
51704
|
-
|
|
51705
|
-
|
|
51656
|
+
function _buildAttributeValueDependency(attributeSpecification, attrName, stateVariableForAttributeValue) {
|
|
51657
|
+
if (attributeSpecification.createPrimitiveOfType) {
|
|
51658
|
+
return {
|
|
51659
|
+
attributePrimitive: {
|
|
51660
|
+
dependencyType: "attributePrimitive",
|
|
51661
|
+
attributeName: attrName
|
|
51662
|
+
}
|
|
51663
|
+
};
|
|
51664
|
+
} else if (attributeSpecification.createReferences) {
|
|
51665
|
+
return {
|
|
51666
|
+
attributeRefResolutions: {
|
|
51667
|
+
dependencyType: "attributeRefResolutions",
|
|
51668
|
+
attributeName: attrName
|
|
51669
|
+
}
|
|
51670
|
+
};
|
|
51671
|
+
} else {
|
|
51672
|
+
return {
|
|
51673
|
+
attributeComponent: {
|
|
51674
|
+
dependencyType: "attributeComponent",
|
|
51675
|
+
attributeName: attrName,
|
|
51676
|
+
variableNames: [stateVariableForAttributeValue]
|
|
51677
|
+
}
|
|
51678
|
+
};
|
|
51706
51679
|
}
|
|
51707
|
-
|
|
51708
|
-
|
|
51709
|
-
|
|
51680
|
+
}
|
|
51681
|
+
function _buildAttributeFallbackDependencies(attributeSpecification) {
|
|
51682
|
+
const deps = {};
|
|
51683
|
+
if (attributeSpecification.fallBackToParentStateVariable) {
|
|
51684
|
+
deps.parentValue = {
|
|
51685
|
+
dependencyType: "parentStateVariable",
|
|
51686
|
+
variableName: attributeSpecification.fallBackToParentStateVariable
|
|
51687
|
+
};
|
|
51710
51688
|
}
|
|
51711
|
-
if (
|
|
51712
|
-
|
|
51689
|
+
if (attributeSpecification.fallBackToSourceCompositeStateVariable) {
|
|
51690
|
+
deps.sourceCompositeValue = {
|
|
51691
|
+
dependencyType: "sourceCompositeStateVariable",
|
|
51692
|
+
variableName: attributeSpecification.fallBackToSourceCompositeStateVariable
|
|
51693
|
+
};
|
|
51713
51694
|
}
|
|
51714
|
-
|
|
51715
|
-
|
|
51695
|
+
return deps;
|
|
51696
|
+
}
|
|
51697
|
+
function _resolvePrimaryStateVariableForDefinition({
|
|
51698
|
+
redefineDependencies,
|
|
51699
|
+
componentClass,
|
|
51700
|
+
stateVariableDefinitions,
|
|
51701
|
+
throwIfMissing
|
|
51702
|
+
}) {
|
|
51703
|
+
let name2 = "value";
|
|
51704
|
+
if (redefineDependencies.substituteForPrimaryStateVariable) {
|
|
51705
|
+
name2 = redefineDependencies.substituteForPrimaryStateVariable;
|
|
51706
|
+
} else if (componentClass.primaryStateVariableForDefinition) {
|
|
51707
|
+
name2 = componentClass.primaryStateVariableForDefinition;
|
|
51716
51708
|
}
|
|
51717
|
-
|
|
51718
|
-
|
|
51719
|
-
|
|
51720
|
-
|
|
51721
|
-
|
|
51722
|
-
|
|
51723
|
-
}
|
|
51724
|
-
|
|
51725
|
-
|
|
51726
|
-
}
|
|
51727
|
-
if (!stateVarObj.arrayVarNameFromPropIndex) {
|
|
51728
|
-
stateVarObj.arrayVarNameFromPropIndex = returnDefaultArrayVarNameFromPropIndex(
|
|
51729
|
-
stateVarObj.numDimensions,
|
|
51730
|
-
entryPrefixes[0]
|
|
51709
|
+
const stateDef = stateVariableDefinitions[name2];
|
|
51710
|
+
if (throwIfMissing && !stateDef) {
|
|
51711
|
+
if (redefineDependencies.substituteForPrimaryStateVariable) {
|
|
51712
|
+
throw Error(
|
|
51713
|
+
`Invalid public state variable of componentType ${componentClass.componentType}: substituteForPrimaryStateVariable ${redefineDependencies.substituteForPrimaryStateVariable} does not exist`
|
|
51714
|
+
);
|
|
51715
|
+
} else {
|
|
51716
|
+
throw Error(
|
|
51717
|
+
`Cannot have a public state variable with componentType ${componentClass.componentType} as the class doesn't have a primary state variable for definition`
|
|
51731
51718
|
);
|
|
51732
51719
|
}
|
|
51733
|
-
|
|
51720
|
+
}
|
|
51721
|
+
return { name: name2, stateDef };
|
|
51722
|
+
}
|
|
51723
|
+
function _setShadowingInstructionsFromAttribute(stateVarDef, attributeSpecification) {
|
|
51724
|
+
stateVarDef.public = true;
|
|
51725
|
+
stateVarDef.shadowingInstructions = {};
|
|
51726
|
+
if (attributeSpecification.createPrimitiveOfType) {
|
|
51727
|
+
const primitive = attributeSpecification.createPrimitiveOfType;
|
|
51728
|
+
stateVarDef.shadowingInstructions.createComponentOfType = PRIMITIVE_TO_COMPONENT_TYPE[primitive] ?? primitive;
|
|
51729
|
+
} else if (attributeSpecification.createReferences) {
|
|
51730
|
+
throw Error(
|
|
51731
|
+
"Cannot make a public state variable from an attribute with createReferences"
|
|
51732
|
+
);
|
|
51734
51733
|
} else {
|
|
51735
|
-
|
|
51736
|
-
stateVarObj.setArrayValue = oneDimSetArrayValue;
|
|
51737
|
-
stateVarObj.getArrayValue = oneDimGetArrayValue;
|
|
51738
|
-
if (!stateVarObj.getAllArrayKeys) {
|
|
51739
|
-
stateVarObj.getAllArrayKeys = oneDimGetAllArrayKeys;
|
|
51740
|
-
}
|
|
51741
|
-
if (!stateVarObj.arrayVarNameFromArrayKey) {
|
|
51742
|
-
stateVarObj.arrayVarNameFromArrayKey = defaultOneDimArrayVarNameFromArrayKey;
|
|
51743
|
-
}
|
|
51744
|
-
if (!stateVarObj.arrayVarNameFromPropIndex) {
|
|
51745
|
-
stateVarObj.arrayVarNameFromPropIndex = returnDefaultArrayVarNameFromPropIndex(1, entryPrefixes[0]);
|
|
51746
|
-
}
|
|
51747
|
-
stateVarObj.adjustArrayToNewArraySize = oneDimAdjustArrayToNewArraySize;
|
|
51734
|
+
stateVarDef.shadowingInstructions.createComponentOfType = attributeSpecification.createComponentOfType;
|
|
51748
51735
|
}
|
|
51749
|
-
|
|
51750
|
-
|
|
51736
|
+
}
|
|
51737
|
+
function _resolveAttributeValueVariable(core2, attributeSpecification, attrName, componentClass) {
|
|
51738
|
+
if (!attributeSpecification.createComponentOfType) {
|
|
51739
|
+
return void 0;
|
|
51751
51740
|
}
|
|
51752
|
-
|
|
51753
|
-
if (!
|
|
51754
|
-
|
|
51741
|
+
const attributeClass = core2.componentInfoObjects.allComponentClasses[attributeSpecification.createComponentOfType];
|
|
51742
|
+
if (!attributeClass) {
|
|
51743
|
+
throw Error(
|
|
51744
|
+
`Component type ${attributeSpecification.createComponentOfType} does not exist so cannot create state variable for attribute ${attrName} of componentType ${componentClass.componentType}.`
|
|
51745
|
+
);
|
|
51755
51746
|
}
|
|
51756
|
-
|
|
51757
|
-
|
|
51758
|
-
|
|
51747
|
+
let stateVariableForAttributeValue = attributeSpecification.componentStateVariableForAttributeValue;
|
|
51748
|
+
if (stateVariableForAttributeValue === void 0) {
|
|
51749
|
+
stateVariableForAttributeValue = attributeClass.stateVariableToBeShadowed;
|
|
51750
|
+
if (stateVariableForAttributeValue === void 0) {
|
|
51751
|
+
stateVariableForAttributeValue = "value";
|
|
51759
51752
|
}
|
|
51760
|
-
stateVarObj.wrappingComponents = stateVarObj.shadowingInstructions.returnWrappingComponents();
|
|
51761
51753
|
}
|
|
51762
|
-
|
|
51763
|
-
|
|
51764
|
-
|
|
51765
|
-
|
|
51766
|
-
|
|
51767
|
-
|
|
51768
|
-
|
|
51769
|
-
|
|
51770
|
-
|
|
51771
|
-
|
|
51772
|
-
|
|
51773
|
-
|
|
51774
|
-
|
|
51775
|
-
|
|
51776
|
-
|
|
51777
|
-
|
|
51778
|
-
|
|
51779
|
-
|
|
51780
|
-
|
|
51781
|
-
|
|
51782
|
-
|
|
51783
|
-
|
|
51784
|
-
|
|
51785
|
-
|
|
51786
|
-
|
|
51787
|
-
|
|
51788
|
-
|
|
51789
|
-
|
|
51790
|
-
|
|
51754
|
+
return stateVariableForAttributeValue;
|
|
51755
|
+
}
|
|
51756
|
+
function _copyPassthroughAttributes(stateVarDef, attributeSpecification, { includeTriggerActionOnChange = false } = {}) {
|
|
51757
|
+
const attributesToCopy = [
|
|
51758
|
+
"forRenderer",
|
|
51759
|
+
"defaultValue",
|
|
51760
|
+
"propagateToProps",
|
|
51761
|
+
...includeTriggerActionOnChange ? ["triggerActionOnChange"] : [],
|
|
51762
|
+
"ignoreFixed",
|
|
51763
|
+
"isLocation",
|
|
51764
|
+
"essentialVarName"
|
|
51765
|
+
];
|
|
51766
|
+
for (const attrName2 of attributesToCopy) {
|
|
51767
|
+
if (attrName2 in attributeSpecification) {
|
|
51768
|
+
stateVarDef[attrName2] = attributeSpecification[attrName2];
|
|
51769
|
+
}
|
|
51770
|
+
}
|
|
51771
|
+
}
|
|
51772
|
+
function _buildAttributeDerivedDefinitions({
|
|
51773
|
+
varName,
|
|
51774
|
+
stateVariableForAttributeValue,
|
|
51775
|
+
attributeSpecification,
|
|
51776
|
+
attrName
|
|
51777
|
+
}) {
|
|
51778
|
+
const definition = function({
|
|
51779
|
+
dependencyValues,
|
|
51780
|
+
usedDefault,
|
|
51781
|
+
essentialValues
|
|
51782
|
+
}) {
|
|
51783
|
+
let attributeValue;
|
|
51784
|
+
if (dependencyValues.attributeComponent) {
|
|
51785
|
+
attributeValue = dependencyValues.attributeComponent.stateValues[stateVariableForAttributeValue];
|
|
51786
|
+
} else if (dependencyValues.attributePrimitive != null) {
|
|
51787
|
+
attributeValue = dependencyValues.attributePrimitive;
|
|
51788
|
+
} else if (dependencyValues.attributeRefResolutions != null && !usedDefault.attributeRefResolutions) {
|
|
51789
|
+
attributeValue = dependencyValues.attributeRefResolutions;
|
|
51790
|
+
} else {
|
|
51791
|
+
let haveSourceCompositeValue = dependencyValues.sourceCompositeValue != null;
|
|
51792
|
+
if (haveSourceCompositeValue && !usedDefault.sourceCompositeValue && essentialValues[varName] === void 0) {
|
|
51793
|
+
return {
|
|
51794
|
+
setValue: {
|
|
51795
|
+
[varName]: dependencyValues.sourceCompositeValue
|
|
51796
|
+
},
|
|
51797
|
+
checkForActualChange: { [varName]: true }
|
|
51798
|
+
};
|
|
51799
|
+
} else {
|
|
51800
|
+
let haveParentValue = dependencyValues.parentValue != null;
|
|
51801
|
+
if (haveParentValue && !usedDefault.parentValue && essentialValues[varName] === void 0) {
|
|
51802
|
+
return {
|
|
51803
|
+
setValue: {
|
|
51804
|
+
[varName]: dependencyValues.parentValue
|
|
51805
|
+
},
|
|
51806
|
+
checkForActualChange: { [varName]: true }
|
|
51807
|
+
};
|
|
51808
|
+
} else {
|
|
51809
|
+
return {
|
|
51810
|
+
useEssentialOrDefaultValue: {
|
|
51811
|
+
[varName]: true
|
|
51812
|
+
},
|
|
51813
|
+
checkForActualChange: { [varName]: true }
|
|
51814
|
+
};
|
|
51791
51815
|
}
|
|
51792
|
-
component.state[vName].freshnessInfo = stateVarObj.freshnessInfo;
|
|
51793
51816
|
}
|
|
51794
51817
|
}
|
|
51795
|
-
|
|
51818
|
+
const res = validateAttributeValue({
|
|
51819
|
+
value: attributeValue,
|
|
51820
|
+
attributeSpecification,
|
|
51821
|
+
attribute: attrName
|
|
51822
|
+
});
|
|
51823
|
+
return {
|
|
51824
|
+
setValue: { [varName]: res.value },
|
|
51825
|
+
checkForActualChange: { [varName]: true },
|
|
51826
|
+
sendDiagnostics: res.diagnostics
|
|
51827
|
+
};
|
|
51828
|
+
};
|
|
51829
|
+
const inverseDefinition = async function({
|
|
51830
|
+
desiredStateVariableValues,
|
|
51831
|
+
dependencyValues,
|
|
51832
|
+
usedDefault,
|
|
51833
|
+
essentialValues
|
|
51834
|
+
}) {
|
|
51835
|
+
if (!dependencyValues.attributeComponent) {
|
|
51836
|
+
if (dependencyValues.attributePrimitive != null) {
|
|
51837
|
+
return { success: false };
|
|
51838
|
+
}
|
|
51839
|
+
if (dependencyValues.attributeRefResolutions != null) {
|
|
51840
|
+
return { success: false };
|
|
51841
|
+
}
|
|
51842
|
+
let haveSourceCompositeValue = dependencyValues.sourceCompositeValue != null;
|
|
51843
|
+
if (haveSourceCompositeValue && !usedDefault.sourceCompositeValue && essentialValues[varName] === void 0) {
|
|
51844
|
+
return {
|
|
51845
|
+
success: true,
|
|
51846
|
+
instructions: [
|
|
51847
|
+
{
|
|
51848
|
+
setDependency: "sourceCompositeValue",
|
|
51849
|
+
desiredValue: desiredStateVariableValues[varName]
|
|
51850
|
+
}
|
|
51851
|
+
]
|
|
51852
|
+
};
|
|
51853
|
+
} else {
|
|
51854
|
+
let haveParentValue = dependencyValues.parentValue != null;
|
|
51855
|
+
if (haveParentValue && !usedDefault.parentValue && essentialValues[varName] === void 0) {
|
|
51856
|
+
return {
|
|
51857
|
+
success: true,
|
|
51858
|
+
instructions: [
|
|
51859
|
+
{
|
|
51860
|
+
setDependency: "parentValue",
|
|
51861
|
+
desiredValue: desiredStateVariableValues[varName]
|
|
51862
|
+
}
|
|
51863
|
+
]
|
|
51864
|
+
};
|
|
51865
|
+
} else {
|
|
51866
|
+
const res = validateAttributeValue({
|
|
51867
|
+
value: desiredStateVariableValues[varName],
|
|
51868
|
+
attributeSpecification,
|
|
51869
|
+
attribute: attrName
|
|
51870
|
+
});
|
|
51871
|
+
return {
|
|
51872
|
+
success: true,
|
|
51873
|
+
instructions: [
|
|
51874
|
+
{
|
|
51875
|
+
setEssentialValue: varName,
|
|
51876
|
+
value: res.value
|
|
51877
|
+
}
|
|
51878
|
+
],
|
|
51879
|
+
sendDiagnostics: res.diagnostics
|
|
51880
|
+
};
|
|
51881
|
+
}
|
|
51882
|
+
}
|
|
51883
|
+
}
|
|
51884
|
+
return {
|
|
51885
|
+
success: true,
|
|
51886
|
+
instructions: [
|
|
51887
|
+
{
|
|
51888
|
+
setDependency: "attributeComponent",
|
|
51889
|
+
desiredValue: desiredStateVariableValues[varName],
|
|
51890
|
+
variableIndex: 0
|
|
51891
|
+
}
|
|
51892
|
+
]
|
|
51893
|
+
};
|
|
51894
|
+
};
|
|
51895
|
+
return { definition, inverseDefinition };
|
|
51796
51896
|
}
|
|
51797
|
-
|
|
51798
|
-
|
|
51799
|
-
|
|
51800
|
-
|
|
51801
|
-
stateVariable
|
|
51897
|
+
function validateAttributeValue({
|
|
51898
|
+
value,
|
|
51899
|
+
attributeSpecification,
|
|
51900
|
+
attribute
|
|
51802
51901
|
}) {
|
|
51803
|
-
let
|
|
51804
|
-
|
|
51805
|
-
|
|
51806
|
-
|
|
51807
|
-
);
|
|
51902
|
+
let diagnostics = [];
|
|
51903
|
+
const valueOrig = value;
|
|
51904
|
+
if (attributeSpecification.transformNonFiniteTo !== void 0 && !Number.isFinite(value)) {
|
|
51905
|
+
value = attributeSpecification.transformNonFiniteTo;
|
|
51808
51906
|
}
|
|
51809
|
-
|
|
51810
|
-
|
|
51811
|
-
|
|
51812
|
-
|
|
51813
|
-
|
|
51814
|
-
|
|
51815
|
-
);
|
|
51816
|
-
|
|
51817
|
-
|
|
51907
|
+
if (attributeSpecification.validValues && Array.isArray(value)) {
|
|
51908
|
+
const res = validateListItemsAgainstValidValues({
|
|
51909
|
+
items: value,
|
|
51910
|
+
validValues: attributeSpecification.validValues,
|
|
51911
|
+
toLowerCase: attributeSpecification.toLowerCase,
|
|
51912
|
+
attribute
|
|
51913
|
+
});
|
|
51914
|
+
diagnostics.push(...res.diagnostics);
|
|
51915
|
+
return { value: res.value, diagnostics };
|
|
51818
51916
|
}
|
|
51819
|
-
if (
|
|
51820
|
-
|
|
51821
|
-
let arraySizeStateVarObj = component.state[arraySizeStateVar];
|
|
51822
|
-
arraySizeStateVarObj.arraySizeVarNamesAffected = allStateVariablesAffected;
|
|
51823
|
-
arraySizeStateVarObj.markStale = arraySizeMarkStale;
|
|
51824
|
-
}
|
|
51825
|
-
return;
|
|
51917
|
+
if (attributeSpecification.toLowerCase) {
|
|
51918
|
+
value = value.toLowerCase();
|
|
51826
51919
|
}
|
|
51827
|
-
|
|
51828
|
-
|
|
51829
|
-
definition: arraySizeDefinition,
|
|
51830
|
-
markStale: arraySizeMarkStale,
|
|
51831
|
-
arraySizeVarNamesAffected: allStateVariablesAffected,
|
|
51832
|
-
arraySizeSourceVarName: stateVariable
|
|
51833
|
-
};
|
|
51834
|
-
if (stateVarObj.stateVariablesDeterminingArraySizeDependencies) {
|
|
51835
|
-
component.state[arraySizeStateVar].stateVariablesDeterminingDependencies = stateVarObj.stateVariablesDeterminingArraySizeDependencies;
|
|
51920
|
+
if (attributeSpecification.trim || attributeSpecification.validValues) {
|
|
51921
|
+
value = value.trim();
|
|
51836
51922
|
}
|
|
51837
|
-
|
|
51838
|
-
|
|
51839
|
-
|
|
51840
|
-
|
|
51841
|
-
|
|
51842
|
-
|
|
51843
|
-
|
|
51844
|
-
|
|
51845
|
-
|
|
51846
|
-
|
|
51847
|
-
|
|
51848
|
-
|
|
51849
|
-
|
|
51850
|
-
for (let varName of stateVariables) {
|
|
51851
|
-
let stateVarObj = component.state[varName];
|
|
51852
|
-
if (!stateVarObj) {
|
|
51853
|
-
if (!core2.checkIfArrayEntry({
|
|
51854
|
-
stateVariable: varName,
|
|
51855
|
-
component
|
|
51856
|
-
}).isArrayEntry) {
|
|
51857
|
-
newVarNames.push(varName);
|
|
51858
|
-
continue;
|
|
51923
|
+
if (attributeSpecification.validValues) {
|
|
51924
|
+
const allowed = attributeSpecification.validValues.map((v2) => v2.value);
|
|
51925
|
+
if (!allowed.includes(value)) {
|
|
51926
|
+
let defaultValue = attributeSpecification.defaultValue;
|
|
51927
|
+
if (defaultValue === void 0) {
|
|
51928
|
+
if (attributeSpecification.createPrimitiveOfType) {
|
|
51929
|
+
defaultValue = attributeSpecification.defaultPrimitiveValue;
|
|
51930
|
+
}
|
|
51931
|
+
if (defaultValue === void 0) {
|
|
51932
|
+
throw Error(
|
|
51933
|
+
"Invalid attribute specification: no default value specified"
|
|
51934
|
+
);
|
|
51935
|
+
}
|
|
51859
51936
|
}
|
|
51860
|
-
|
|
51861
|
-
|
|
51862
|
-
|
|
51863
|
-
});
|
|
51864
|
-
stateVarObj = component.state[varName];
|
|
51865
|
-
}
|
|
51866
|
-
let newName;
|
|
51867
|
-
if (stateVarObj.isArray) {
|
|
51868
|
-
newName = stateVarObj.arrayVarNameFromPropIndex(propIndex, varName);
|
|
51869
|
-
} else if (stateVarObj.isArrayEntry) {
|
|
51870
|
-
let arrayStateVarObj = component.state[stateVarObj.arrayStateVariable];
|
|
51871
|
-
newName = arrayStateVarObj.arrayVarNameFromPropIndex(
|
|
51872
|
-
propIndex,
|
|
51873
|
-
varName
|
|
51874
|
-
);
|
|
51875
|
-
} else {
|
|
51876
|
-
core2.addDiagnostic({
|
|
51877
|
-
type: "warning",
|
|
51878
|
-
message: `Cannot get propIndex from ${varName} of ${component.componentIdx} as it is not an array or array entry state variable`,
|
|
51879
|
-
position: component.position,
|
|
51880
|
-
sourceDoc: component.sourceDoc
|
|
51937
|
+
diagnostics.push({
|
|
51938
|
+
message: `Invalid value \`${valueOrig}\` for attribute \`${attribute}\`, using value \`${defaultValue}\``,
|
|
51939
|
+
type: "info"
|
|
51881
51940
|
});
|
|
51882
|
-
|
|
51941
|
+
value = defaultValue;
|
|
51883
51942
|
}
|
|
51884
|
-
|
|
51885
|
-
|
|
51886
|
-
|
|
51887
|
-
|
|
51888
|
-
|
|
51889
|
-
|
|
51890
|
-
|
|
51891
|
-
sourceDoc: component.sourceDoc
|
|
51892
|
-
});
|
|
51893
|
-
newVarNames.push(varName);
|
|
51943
|
+
} else if (attributeSpecification.clamp) {
|
|
51944
|
+
if (value < attributeSpecification.clamp[0]) {
|
|
51945
|
+
value = attributeSpecification.clamp[0];
|
|
51946
|
+
} else if (value > attributeSpecification.clamp[1]) {
|
|
51947
|
+
value = attributeSpecification.clamp[1];
|
|
51948
|
+
} else if (!Number.isFinite(value)) {
|
|
51949
|
+
value = attributeSpecification.defaultValue;
|
|
51894
51950
|
}
|
|
51895
51951
|
}
|
|
51896
|
-
return
|
|
51952
|
+
return { value, diagnostics };
|
|
51897
51953
|
}
|
|
51898
51954
|
const EMPTY_SERIALIZED_CHILDREN = Object.freeze([]);
|
|
51899
51955
|
function ancestorsForChild(parent) {
|
|
@@ -229243,4 +229299,4 @@ export {
|
|
|
229243
229299
|
getDefaultExportFromCjs as g,
|
|
229244
229300
|
updateSyntaxFromV06toV07 as u
|
|
229245
229301
|
};
|
|
229246
|
-
//# sourceMappingURL=index-
|
|
229302
|
+
//# sourceMappingURL=index-D7QB7nkv.js.map
|