@fluid-experimental/property-properties 0.54.2 → 0.56.0-49831
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/properties/arrayProperty.d.ts.map +1 -1
- package/dist/properties/arrayProperty.js +4 -4
- package/dist/properties/arrayProperty.js.map +1 -1
- package/dist/properties/baseProperty.d.ts +1 -1
- package/dist/properties/baseProperty.d.ts.map +1 -1
- package/dist/properties/baseProperty.js +13 -12
- package/dist/properties/baseProperty.js.map +1 -1
- package/dist/properties/boolProperty.d.ts.map +1 -1
- package/dist/properties/boolProperty.js +3 -2
- package/dist/properties/boolProperty.js.map +1 -1
- package/dist/properties/containerProperty.d.ts +1 -1
- package/dist/properties/containerProperty.d.ts.map +1 -1
- package/dist/properties/containerProperty.js +12 -3
- package/dist/properties/containerProperty.js.map +1 -1
- package/dist/properties/enumArrayProperty.js +2 -1
- package/dist/properties/enumArrayProperty.js.map +1 -1
- package/dist/properties/enumProperty.d.ts.map +1 -1
- package/dist/properties/enumProperty.js +2 -1
- package/dist/properties/enumProperty.js.map +1 -1
- package/dist/properties/floatProperties.d.ts.map +1 -1
- package/dist/properties/floatProperties.js +6 -4
- package/dist/properties/floatProperties.js.map +1 -1
- package/dist/properties/indexedCollectionBaseProperty.d.ts +2 -2
- package/dist/properties/indexedCollectionBaseProperty.d.ts.map +1 -1
- package/dist/properties/indexedCollectionBaseProperty.js +2 -2
- package/dist/properties/indexedCollectionBaseProperty.js.map +1 -1
- package/dist/properties/intProperties.d.ts.map +1 -1
- package/dist/properties/intProperties.js +15 -10
- package/dist/properties/intProperties.js.map +1 -1
- package/dist/properties/mapProperty.d.ts.map +1 -1
- package/dist/properties/mapProperty.js +2 -1
- package/dist/properties/mapProperty.js.map +1 -1
- package/dist/properties/namedNodeProperty.js +2 -1
- package/dist/properties/namedNodeProperty.js.map +1 -1
- package/dist/properties/namedProperty.js +2 -1
- package/dist/properties/namedProperty.js.map +1 -1
- package/dist/properties/nodeProperty.d.ts.map +1 -1
- package/dist/properties/nodeProperty.js +3 -1
- package/dist/properties/nodeProperty.js.map +1 -1
- package/dist/properties/referenceArrayProperty.js +2 -1
- package/dist/properties/referenceArrayProperty.js.map +1 -1
- package/dist/properties/referenceMapProperty.js +2 -1
- package/dist/properties/referenceMapProperty.js.map +1 -1
- package/dist/properties/referenceProperty.d.ts +1 -1
- package/dist/properties/referenceProperty.d.ts.map +1 -1
- package/dist/properties/referenceProperty.js +3 -2
- package/dist/properties/referenceProperty.js.map +1 -1
- package/dist/properties/setProperty.d.ts.map +1 -1
- package/dist/properties/setProperty.js +3 -2
- package/dist/properties/setProperty.js.map +1 -1
- package/dist/properties/stringProperty.d.ts.map +1 -1
- package/dist/properties/stringProperty.js +12 -3
- package/dist/properties/stringProperty.js.map +1 -1
- package/dist/properties/uintProperties.d.ts.map +1 -1
- package/dist/properties/uintProperties.js +9 -6
- package/dist/properties/uintProperties.js.map +1 -1
- package/dist/properties/valueArrayProperty.d.ts +1 -1
- package/dist/properties/valueArrayProperty.d.ts.map +1 -1
- package/dist/properties/valueArrayProperty.js +25 -13
- package/dist/properties/valueArrayProperty.js.map +1 -1
- package/dist/properties/valueMapProperty.d.ts.map +1 -1
- package/dist/properties/valueMapProperty.js +38 -26
- package/dist/properties/valueMapProperty.js.map +1 -1
- package/dist/propertyFactory.d.ts.map +1 -1
- package/dist/propertyFactory.js +442 -86
- package/dist/propertyFactory.js.map +1 -1
- package/dist/propertyTemplateWrapper.d.ts +0 -34
- package/dist/propertyTemplateWrapper.d.ts.map +1 -1
- package/dist/propertyTemplateWrapper.js +0 -108
- package/dist/propertyTemplateWrapper.js.map +1 -1
- package/dist/test/propertyFactory.spec.js +5 -2
- package/dist/test/propertyFactory.spec.js.map +1 -1
- package/dist/test/tsconfig.tsbuildinfo +11 -11
- package/lib/properties/arrayProperty.js +4 -4
- package/lib/properties/arrayProperty.js.map +1 -1
- package/lib/properties/baseProperty.js +13 -12
- package/lib/properties/baseProperty.js.map +1 -1
- package/lib/properties/boolProperty.js +3 -2
- package/lib/properties/boolProperty.js.map +1 -1
- package/lib/properties/containerProperty.js +12 -3
- package/lib/properties/containerProperty.js.map +1 -1
- package/lib/properties/enumArrayProperty.js +2 -1
- package/lib/properties/enumArrayProperty.js.map +1 -1
- package/lib/properties/enumProperty.js +2 -1
- package/lib/properties/enumProperty.js.map +1 -1
- package/lib/properties/floatProperties.js +6 -4
- package/lib/properties/floatProperties.js.map +1 -1
- package/lib/properties/indexedCollectionBaseProperty.js +2 -2
- package/lib/properties/indexedCollectionBaseProperty.js.map +1 -1
- package/lib/properties/intProperties.js +15 -10
- package/lib/properties/intProperties.js.map +1 -1
- package/lib/properties/mapProperty.js +2 -1
- package/lib/properties/mapProperty.js.map +1 -1
- package/lib/properties/namedNodeProperty.js +2 -1
- package/lib/properties/namedNodeProperty.js.map +1 -1
- package/lib/properties/namedProperty.js +2 -1
- package/lib/properties/namedProperty.js.map +1 -1
- package/lib/properties/nodeProperty.js +3 -1
- package/lib/properties/nodeProperty.js.map +1 -1
- package/lib/properties/referenceArrayProperty.js +2 -1
- package/lib/properties/referenceArrayProperty.js.map +1 -1
- package/lib/properties/referenceMapProperty.js +2 -1
- package/lib/properties/referenceMapProperty.js.map +1 -1
- package/lib/properties/referenceProperty.js +3 -2
- package/lib/properties/referenceProperty.js.map +1 -1
- package/lib/properties/setProperty.js +3 -2
- package/lib/properties/setProperty.js.map +1 -1
- package/lib/properties/stringProperty.js +12 -3
- package/lib/properties/stringProperty.js.map +1 -1
- package/lib/properties/uintProperties.js +9 -6
- package/lib/properties/uintProperties.js.map +1 -1
- package/lib/properties/valueArrayProperty.js +25 -13
- package/lib/properties/valueArrayProperty.js.map +1 -1
- package/lib/properties/valueMapProperty.js +38 -26
- package/lib/properties/valueMapProperty.js.map +1 -1
- package/lib/propertyFactory.js +442 -86
- package/lib/propertyFactory.js.map +1 -1
- package/lib/propertyTemplateWrapper.js +0 -108
- package/lib/propertyTemplateWrapper.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intProperties.js","sourceRoot":"","sources":["../../src/properties/intProperties.js"],"names":[],"mappings":";AAAA;;;GAGG;AACH,2BAA2B;AAC3B;;GAEG;;;AAEH,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACrD,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAC1D,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACxE,MAAM,EACF,YAAY,EACZ,SAAS,EAAE,EAAE,GAAG,EAAE,EAClB,MAAM,EACN,KAAK,EACR,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AAEnD,MAAM,KAAK,GAAG,UAAU,CAAC;AAEzB,MAAa,YAAa,SAAQ,aAAa;IAC3C;;;;;;;;OAQG;IACH,YAAY,SAAS;QACjB,KAAK,iCAAM,SAAS,KAAE,MAAM,EAAE,MAAM,IAAG,CAAC;QAI5C,iBAAY,GAAG,aAAa,CAAC,IAAI,CAAC;QAH9B,wCAAwC;QACxC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,CAAC;IAAA,CAAC;CAEL;AAhBD,oCAgBC;AAGD;;GAEG;AACH,MAAa,aAAc,SAAQ,aAAa;IAC5C;;;;;;;OAOG;IACH,YAAY,SAAS;QACjB,KAAK,iCAAM,SAAS,KAAE,MAAM,EAAE,OAAO,IAAG,CAAC;QAK7C,iBAAY,GAAG,aAAa,CAAC,KAAK,CAAC;QAJ/B,wCAAwC;QACxC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IAEnB,CAAC;IAAA,CAAC;CAGL;AAjBD,sCAiBC;AAED;;GAEG;AACH,MAAa,aAAc,SAAQ,aAAa;IAC5C;;;;;;;OAOG;IACH,YAAY,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CAAM,SAAS,KAAE,MAAM,EAAE,QAAQ,KAAI,MAAM,CAAC,CAAC;QAGtD,iBAAY,GAAG,aAAa,CAAC,MAAM,CAAC;IAFpC,CAAC;IAAA,CAAC;CAGL;AAdD,wCAcC;AAAA,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/* eslint-disable new-cap*/\n/**\n * @fileoverview Definition of the Int*Property classes\n */\n\nconst _ = require('lodash');\nconst { ValueProperty } = require('./valueProperty');\nconst { _castFunctors } = require('./primitiveTypeCasts');\nconst { ChangeSet } = require('@fluid-experimental/property-changeset');\nconst {\n ConsoleUtils,\n constants: { MSG },\n Uint64,\n Int64\n} = require('@fluid-experimental/property-common');\n\nconst BIT32 = 4294967296;\n\nexport class Int8Property extends ValueProperty {\n /**\n * A primitive property for an signed 8 bit integer value.\n * @param {Object=} in_params - the parameters\n * @constructor\n * @protected\n * @extends property-properties.ValueProperty\n * @alias property-properties.Int8Property\n * @category Value Properties\n */\n constructor(in_params) {\n super({ ...in_params, typeid: 'Int8' });\n // default for this property type is '0'\n this._data = 0;\n };\n _castFunctor = _castFunctors.Int8;\n}\n\n\n/**\n * A primitive property for an signed 16 bit integer value.\n */\nexport class Int16Property extends ValueProperty {\n /**\n * @param {Object=} in_params - the parameters\n * @constructor\n * @protected\n * @extends property-properties.ValueProperty\n * @alias property-properties.Int16Property\n * @category Value Properties\n */\n constructor(in_params) {\n super({ ...in_params, typeid: 'Int16' });\n // default for this property type is '0'\n this._data = 0;\n\n };\n _castFunctor = _castFunctors.Int16;\n\n}\n\n/**\n * A primitive property for an signed 32 bit integer value.\n */\nexport class Int32Property extends ValueProperty {\n /**\n * @param {Object=} in_params - the parameters\n * @constructor\n * @protected\n * @extends property-properties.ValueProperty\n * @alias property-properties.Int32Property\n * @category Value Properties\n */\n constructor(in_params) {\n super({ typeid: 'Int32', ...in_params });\n // default for this property type is '0'\n this._data = 0;\n\n };\n _castFunctor = _castFunctors.Int32;\n}\n/**\n * A primitive property base class for big integer values.\n */\nexport class Integer64Property extends ValueProperty {\n /**\n * @param {Object=} in_params - the parameters\n * @constructor\n * @protected\n * @extends property-properties.ValueProperty\n * @alias property-properties.Integer64Property\n * @protected\n * @abstract\n * @category Value Properties\n */\n constructor(in_params, dataConstructor) {\n super(in_params);\n this.DataConstructor = dataConstructor\n // default for this property type is '0, 0'\n this._data = new this.DataConstructor();\n };\n\n\n /**\n * Internal function to update the value of the Integer64Property\n *\n * @param {Int64|String|Number} in_value the new value\n * @param {boolean} [in_reportToView = true] - By default, the dirtying will always be reported to the checkout view\n * and trigger a modified event there. When batching updates, this\n * can be prevented via this flag.\n * @return {boolean} true if the value was actually changed\n * @throws if in_value is a string that contains characters other than numbers\n */\n _setValue(in_value, in_reportToView) {\n var oldLowValue = this._data.getValueLow();\n var oldHighValue = this._data.getValueHigh();\n\n in_value = this._castFunctor(in_value);\n\n var newHighValue = in_value.getValueHigh();\n var newLowValue = in_value.getValueLow();\n\n var changed = oldHighValue !== newHighValue || oldLowValue !== newLowValue;\n\n if (changed) {\n this._data = in_value.clone();\n this._setDirty(in_reportToView);\n }\n return changed;\n };\n\n /**\n * @return {number} the higher 32 bit integer part\n */\n getValueHigh() {\n return this._data.getValueHigh();\n };\n\n /**\n * @return {number} the lower 32 bit integer part\n */\n getValueLow() {\n return this._data.getValueLow();\n };\n\n /**\n * @param {number} in_high set the higher 32 bit integer part\n * @throws if in_high is not a number\n * @return {boolen} true if the value was actually changed\n */\n setValueHigh(in_high) {\n ConsoleUtils.assert(_.isNumber(in_high), MSG.IN_HIGH_MUST_BE_NUMBER + in_high);\n var changed = this._data.getValueHigh() !== in_high;\n\n if (changed) {\n var newData = new this.DataConstructor(this.getValueLow(), in_high);\n this._data = newData;\n this._setDirty();\n }\n return changed;\n };\n\n /**\n * @param {number} in_low set the lower 32 bit integer part\n * @throws if in_low is not a number\n * @return {boolen} true if the value was actually changed\n */\n setValueLow(in_low) {\n ConsoleUtils.assert(_.isNumber(in_low), MSG.IN_LOW_MUST_BE_NUMBER + in_low);\n var changed = this._data.getValueLow() !== in_low;\n\n if (changed) {\n var newData = new this.DataConstructor(in_low, this.getValueHigh());\n this._data = newData;\n this._setDirty();\n }\n return changed;\n };\n\n /**\n * @inheritdoc\n */\n _deserialize(in_serializedObj, in_reportToView,\n in_filteringOptions, in_createChangeSet) {\n if (ChangeSet.isEmptyChangeSet(in_serializedObj)) {\n return undefined;\n } else {\n ConsoleUtils.assert(_.isArray(in_serializedObj) && in_serializedObj.length === 2, MSG.INVALID_INT64_CHANGESET);\n var readValue = new this.DataConstructor(in_serializedObj[0], in_serializedObj[1]);\n var changed = this._setValue(readValue, in_reportToView);\n return changed ? this.serialize() : undefined;\n }\n };\n\n /**\n * @inheritdoc\n */\n _applyChangeset(in_changeSet, in_reportToView, in_filteringOptions) {\n if (!ChangeSet.isEmptyChangeSet(in_changeSet)) {\n if (!_.isArray(in_changeSet)) {\n in_changeSet = in_changeSet.value;\n }\n ConsoleUtils.assert(_.isArray(in_changeSet) && in_changeSet.length === 2, MSG.INVALID_INT64_CHANGESET);\n var newVal = new this.DataConstructor(in_changeSet[0], in_changeSet[1]);\n this._setValue(newVal, in_reportToView);\n }\n };\n\n /**\n * Serialize the property\n *\n * @param {boolean} in_dirtyOnly -\n * Only include dirty entries in the serialization\n * @param {boolean} in_includeRootTypeid -\n * Include the typeid of the root of the hierarchy - has no effect for value properties\n * @param {property-properties.BaseProperty.MODIFIED_STATE_FLAGS} [in_dirtinessType] -\n * The type of dirtiness to use when reporting dirty changes. By default this is\n * PENDING_CHANGE * @return {*} The serialized representation of this property\n * @param {boolean} [in_includeReferencedRepositories=false] - If this is set to true, the serialize\n * function will descend into referenced repositories. WARNING: if there are loops in the references\n * this can result in an infinite loop\n * @return {*} The serialized representation of this property\n * @private\n */\n _serialize(in_dirtyOnly, in_includeRootTypeid,\n in_dirtinessType, in_includeReferencedRepositories) {\n if (in_dirtyOnly) {\n if (this._isDirty(in_dirtinessType)) {\n return [this._data.getValueLow(), this._data.getValueHigh()];\n } else {\n return {};\n }\n } else {\n return [this._data.getValueLow(), this._data.getValueHigh()];\n }\n };\n\n\n\n /**\n * The toString() method returns a string representing the specified Integer64 object.\n *\n * @param {number} [in_radix = 10] An integer between 2 and 36 specifying\n * the base to use for representing numeric values.\n * @return {string} A string representing the specified Integer64 object.\n */\n toString(in_radix) {\n return this._data.toString(in_radix);\n };\n\n /**\n * The Integer64.fromString() method parses a string argument updates object's lower and higher 32 bit integer parts.\n *\n * @param {string} in_string The value to parse. Leading whitespace in the string argument is ignored.\n * @param {number} [in_radix = 10] An integer between 2 and 36 that represents the\n * radix (the base in mathematical numeral systems) of the above mentioned string.\n * @throws if in_string is not a string\n * @throws if in_radix is entered but is not a number between 2 and 36\n * @throws if the property is a Uint64 property and in_string is a negative number\n * @throws if in_string contains characters other than numbers\n */\n fromString(in_string, in_radix) {\n ConsoleUtils.assert(_.isString(in_string), MSG.IN_STRING_MUST_BE_STRING + in_string);\n var int = this._castFunctor(in_string, in_radix);\n\n this.setValueHigh(int.getValueHigh());\n this.setValueLow(int.getValueLow());\n };\n\n}\n\n/**\n * A primitive property class for big signed integer values.\n */\nexport class Int64Property extends Integer64Property {\n /**\n * @param {Object=} in_params - the parameters\n * @constructor\n * @protected\n * @extends property-properties.Integer64Property\n * @alias property-properties.Int64Property\n * @category Value Properties\n */\n constructor(in_params) {\n super({ ...in_params, typeid: 'Int64' }, Int64);\n };\n\n _castFunctor = _castFunctors.Int64;\n}\n\n/**\n * A primitive property class for big unsingned integer values.\n */\nexport class Uint64Property extends Integer64Property {\n /**\n * @param {Object=} in_params - the parameters\n * @constructor\n * @protected\n * @extends property-properties.Integer64Property\n * @alias property-properties.Uint64Property\n * @category Value Properties\n */\n constructor(in_params) {\n super({ ...in_params, typeid: 'Uint64' }, Uint64);\n };\n\n _castFunctor = _castFunctors.Uint64;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"intProperties.js","sourceRoot":"","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AC,KAAK,CAAC;AAE3D;;GAEG;AACH,MAAa,cAAe,SAAQ,iBAAiB;IACjD;;;;;;;OAOG;IACH,YAAY,SAAS;QACjB,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC;IAAA,CAAC;CACL;AAZD,wCAYC;AAAA,CAAC;AACF,cAAc,CAAC,SAAS,CAAC,OAAO,GAAG,QAAQ,CAAC;AAC5C,cAAc,CAAC,SAAS,CAAC,YAAY,GAAG,aAAa,CAAC,MAAM,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/* eslint-disable new-cap*/\n/**\n * @fileoverview Definition of the Int*Property classes\n */\n\nconst _ = require('lodash');\nconst { ValueProperty } = require('./valueProperty');\nconst { _castFunctors } = require('./primitiveTypeCasts');\nconst { ChangeSet } = require('@fluid-experimental/property-changeset');\nconst {\n ConsoleUtils,\n constants: { MSG },\n Uint64,\n Int64\n} = require('@fluid-experimental/property-common');\n\nconst BIT32 = 4294967296;\n\nexport class Int8Property extends ValueProperty {\n /**\n * A primitive property for an signed 8 bit integer value.\n * @param {Object=} in_params - the parameters\n * @constructor\n * @protected\n * @extends property-properties.ValueProperty\n * @alias property-properties.Int8Property\n * @category Value Properties\n */\n constructor(in_params) {\n super(in_params);\n // default for this property type is '0'\n this._data = 0;\n };\n}\nInt8Property.prototype._typeid = 'Int8';\nInt8Property.prototype._castFunctor = _castFunctors.Int8;\n\n/**\n * A primitive property for an signed 16 bit integer value.\n */\nexport class Int16Property extends ValueProperty {\n /**\n * @param {Object=} in_params - the parameters\n * @constructor\n * @protected\n * @extends property-properties.ValueProperty\n * @alias property-properties.Int16Property\n * @category Value Properties\n */\n constructor(in_params) {\n super(in_params);\n // default for this property type is '0'\n this._data = 0;\n\n };\n}\nInt16Property.prototype._typeid = 'Int16';\nInt16Property.prototype._castFunctor = _castFunctors.Int16;\n\n/**\n * A primitive property for an signed 32 bit integer value.\n */\nexport class Int32Property extends ValueProperty {\n /**\n * @param {Object=} in_params - the parameters\n * @constructor\n * @protected\n * @extends property-properties.ValueProperty\n * @alias property-properties.Int32Property\n * @category Value Properties\n */\n constructor(in_params) {\n super(in_params);\n // default for this property type is '0'\n this._data = 0;\n\n };\n}\nInt32Property.prototype._typeid = 'Int32';\nInt32Property.prototype._castFunctor = _castFunctors.Int32;\n\n/**\n * A primitive property base class for big integer values.\n */\nexport class Integer64Property extends ValueProperty {\n /**\n * @param {Object=} in_params - the parameters\n * @constructor\n * @protected\n * @extends property-properties.ValueProperty\n * @alias property-properties.Integer64Property\n * @protected\n * @abstract\n * @category Value Properties\n */\n constructor(in_params, dataConstructor) {\n super(in_params);\n this.DataConstructor = dataConstructor\n // default for this property type is '0, 0'\n this._data = new this.DataConstructor();\n };\n\n\n /**\n * Internal function to update the value of the Integer64Property\n *\n * @param {Int64|String|Number} in_value the new value\n * @param {boolean} [in_reportToView = true] - By default, the dirtying will always be reported to the checkout view\n * and trigger a modified event there. When batching updates, this\n * can be prevented via this flag.\n * @return {boolean} true if the value was actually changed\n * @throws if in_value is a string that contains characters other than numbers\n */\n _setValue(in_value, in_reportToView) {\n var oldLowValue = this._data.getValueLow();\n var oldHighValue = this._data.getValueHigh();\n\n in_value = this._castFunctor(in_value);\n\n var newHighValue = in_value.getValueHigh();\n var newLowValue = in_value.getValueLow();\n\n var changed = oldHighValue !== newHighValue || oldLowValue !== newLowValue;\n\n if (changed) {\n this._data = in_value.clone();\n this._setDirty(in_reportToView);\n }\n return changed;\n };\n\n /**\n * @return {number} the higher 32 bit integer part\n */\n getValueHigh() {\n return this._data.getValueHigh();\n };\n\n /**\n * @return {number} the lower 32 bit integer part\n */\n getValueLow() {\n return this._data.getValueLow();\n };\n\n /**\n * @param {number} in_high set the higher 32 bit integer part\n * @throws if in_high is not a number\n * @return {boolen} true if the value was actually changed\n */\n setValueHigh(in_high) {\n ConsoleUtils.assert(_.isNumber(in_high), MSG.IN_HIGH_MUST_BE_NUMBER + in_high);\n var changed = this._data.getValueHigh() !== in_high;\n\n if (changed) {\n var newData = new this.DataConstructor(this.getValueLow(), in_high);\n this._data = newData;\n this._setDirty();\n }\n return changed;\n };\n\n /**\n * @param {number} in_low set the lower 32 bit integer part\n * @throws if in_low is not a number\n * @return {boolen} true if the value was actually changed\n */\n setValueLow(in_low) {\n ConsoleUtils.assert(_.isNumber(in_low), MSG.IN_LOW_MUST_BE_NUMBER + in_low);\n var changed = this._data.getValueLow() !== in_low;\n\n if (changed) {\n var newData = new this.DataConstructor(in_low, this.getValueHigh());\n this._data = newData;\n this._setDirty();\n }\n return changed;\n };\n\n /**\n * @inheritdoc\n */\n _deserialize(in_serializedObj, in_reportToView,\n in_filteringOptions, in_createChangeSet) {\n if (ChangeSet.isEmptyChangeSet(in_serializedObj)) {\n return undefined;\n } else {\n ConsoleUtils.assert(_.isArray(in_serializedObj) && in_serializedObj.length === 2, MSG.INVALID_INT64_CHANGESET);\n var readValue = new this.DataConstructor(in_serializedObj[0], in_serializedObj[1]);\n var changed = this._setValue(readValue, in_reportToView);\n return changed ? this.serialize() : undefined;\n }\n };\n\n /**\n * @inheritdoc\n */\n _applyChangeset(in_changeSet, in_reportToView, in_filteringOptions) {\n if (!ChangeSet.isEmptyChangeSet(in_changeSet)) {\n if (!_.isArray(in_changeSet)) {\n in_changeSet = in_changeSet.value;\n }\n ConsoleUtils.assert(_.isArray(in_changeSet) && in_changeSet.length === 2, MSG.INVALID_INT64_CHANGESET);\n var newVal = new this.DataConstructor(in_changeSet[0], in_changeSet[1]);\n this._setValue(newVal, in_reportToView);\n }\n };\n\n /**\n * Serialize the property\n *\n * @param {boolean} in_dirtyOnly -\n * Only include dirty entries in the serialization\n * @param {boolean} in_includeRootTypeid -\n * Include the typeid of the root of the hierarchy - has no effect for value properties\n * @param {property-properties.BaseProperty.MODIFIED_STATE_FLAGS} [in_dirtinessType] -\n * The type of dirtiness to use when reporting dirty changes. By default this is\n * PENDING_CHANGE * @return {*} The serialized representation of this property\n * @param {boolean} [in_includeReferencedRepositories=false] - If this is set to true, the serialize\n * function will descend into referenced repositories. WARNING: if there are loops in the references\n * this can result in an infinite loop\n * @return {*} The serialized representation of this property\n * @private\n */\n _serialize(in_dirtyOnly, in_includeRootTypeid,\n in_dirtinessType, in_includeReferencedRepositories) {\n if (in_dirtyOnly) {\n if (this._isDirty(in_dirtinessType)) {\n return [this._data.getValueLow(), this._data.getValueHigh()];\n } else {\n return {};\n }\n } else {\n return [this._data.getValueLow(), this._data.getValueHigh()];\n }\n };\n\n\n\n /**\n * The toString() method returns a string representing the specified Integer64 object.\n *\n * @param {number} [in_radix = 10] An integer between 2 and 36 specifying\n * the base to use for representing numeric values.\n * @return {string} A string representing the specified Integer64 object.\n */\n toString(in_radix) {\n return this._data.toString(in_radix);\n };\n\n /**\n * The Integer64.fromString() method parses a string argument updates object's lower and higher 32 bit integer parts.\n *\n * @param {string} in_string The value to parse. Leading whitespace in the string argument is ignored.\n * @param {number} [in_radix = 10] An integer between 2 and 36 that represents the\n * radix (the base in mathematical numeral systems) of the above mentioned string.\n * @throws if in_string is not a string\n * @throws if in_radix is entered but is not a number between 2 and 36\n * @throws if the property is a Uint64 property and in_string is a negative number\n * @throws if in_string contains characters other than numbers\n */\n fromString(in_string, in_radix) {\n ConsoleUtils.assert(_.isString(in_string), MSG.IN_STRING_MUST_BE_STRING + in_string);\n var int = this._castFunctor(in_string, in_radix);\n\n this.setValueHigh(int.getValueHigh());\n this.setValueLow(int.getValueLow());\n };\n\n}\n\n/**\n * A primitive property class for big signed integer values.\n */\nexport class Int64Property extends Integer64Property {\n /**\n * @param {Object=} in_params - the parameters\n * @constructor\n * @protected\n * @extends property-properties.Integer64Property\n * @alias property-properties.Int64Property\n * @category Value Properties\n */\n constructor(in_params) {\n super(in_params, Int64);\n };\n}\nInt64Property.prototype._typeid = 'Int64';\nInt64Property.prototype._castFunctor = _castFunctors.Int64;\n\n/**\n * A primitive property class for big unsingned integer values.\n */\nexport class Uint64Property extends Integer64Property {\n /**\n * @param {Object=} in_params - the parameters\n * @constructor\n * @protected\n * @extends property-properties.Integer64Property\n * @alias property-properties.Uint64Property\n * @category Value Properties\n */\n constructor(in_params) {\n super(in_params, Uint64);\n };\n};\nUint64Property.prototype._typeid = 'Uint64';\nUint64Property.prototype._castFunctor = _castFunctors.Uint64;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapProperty.d.ts","sourceRoot":"","sources":["../../src/properties/mapProperty.js"],"names":[],"mappings":"AAmBA;;;;;GAKG;AAEH;;GAEG;AACH;IAEI;;;;;;;;OAQG;IACH,wBAQC;IALG,eAAsB;IACtB,qBAA2D;IAE3D,6CAA6C;IAC7C,qBAA0B;
|
|
1
|
+
{"version":3,"file":"mapProperty.d.ts","sourceRoot":"","sources":["../../src/properties/mapProperty.js"],"names":[],"mappings":"AAmBA;;;;;GAKG;AAEH;;GAEG;AACH;IAEI;;;;;;;;OAQG;IACH,wBAQC;IALG,eAAsB;IACtB,qBAA2D;IAE3D,6CAA6C;IAC7C,qBAA0B;IA2B9B;;;;;;;;OAQG;IACH,2BAsCC;IA+FD;;;;;;;;;;;;OAYG;IACH,eAPW,MAAM,0BAuBhB;IAED;;;;;;OAMG;IACH,eAJW,MAAM,OAQhB;IAED;;;;;;;;;;OAUG;IACH,YANW,MAAM,0BAwBhB;IAwED;;;;;;;OAOG;IACH,cAHY,UAAe,CAK1B;IA8BD;;OAEG;IACH,cAKC;CAEJ"}
|
|
@@ -44,7 +44,6 @@ class MapProperty extends IndexedCollectionBaseProperty {
|
|
|
44
44
|
this._dynamicChildren = {};
|
|
45
45
|
}
|
|
46
46
|
;
|
|
47
|
-
get _context() { return 'map'; }
|
|
48
47
|
/**
|
|
49
48
|
* Returns the full property type identifier for the ChangeSet including the enum type id
|
|
50
49
|
* @param {boolean} [in_hideCollection=false] - if true the collection type (if applicable) will be omitted
|
|
@@ -413,4 +412,6 @@ class MapProperty extends IndexedCollectionBaseProperty {
|
|
|
413
412
|
;
|
|
414
413
|
}
|
|
415
414
|
exports.MapProperty = MapProperty;
|
|
415
|
+
MapProperty.prototype._typeid = 'BaseProperty';
|
|
416
|
+
MapProperty.prototype._context = 'map';
|
|
416
417
|
//# sourceMappingURL=mapProperty.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapProperty.js","sourceRoot":"","sources":["../../src/properties/mapProperty.js"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AACH,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACnD,MAAM,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAC3F,MAAM,EAAE,6BAA6B,EAAE,GAAG,OAAO,CAAC,iCAAiC,CAAC,CAAC;AACrF,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACxE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACvF,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC,SAAS,CAAC;AACzE,MAAM,EAAE,oBAAoB,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAE7E,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC;AAE7C;;;;;GAKG;AAEH;;GAEG;AACH,MAAa,WAAY,SAAQ,6BAA6B;IAE1D;;;;;;;;OAQG;IACH,YAAY,SAAS,EAAE,QAAQ;QAC3B,KAAK,CAAC,SAAS,CAAC,CAAC;QAEjB,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC;QACvB,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC,cAAc,IAAI,QAAQ,CAAC;QAE5D,6CAA6C;QAC7C,IAAI,CAAC,gBAA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ACL,CAAC;IAAA,CAAC;IAEF;;OAEG;IACH,KAAK;QACD,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE;YAC9B,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC;IAAA,CAAC;CAEL;AAhYD,kCAgYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * @fileoverview Definition of the map property class\n */\nconst _ = require('lodash');\nconst { BaseProperty } = require('./baseProperty');\nconst { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty');\nconst { IndexedCollectionBaseProperty } = require('./indexedCollectionBaseProperty');\nconst { ConsoleUtils } = require('@fluid-experimental/property-common');\nconst { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\nconst { LazyLoadedProperties: Property } = require('./lazyLoadedProperties');\n\nconst PATH_TOKENS = BaseProperty.PATH_TOKENS;\n\n/**\n * typedef {property-properties.BaseProperty|string|number|boolean} property-properties.MapProperty~MapValueType\n *\n * The type of the values that are set/inserted into the map. Depending on the type of the map, these can either\n * be property objects or primitive values\n */\n\n/**\n * A MapProperty is a collection class that can contain an dictionary that maps from strings to properties.\n */\nexport class MapProperty extends IndexedCollectionBaseProperty {\n\n /**\n * @param {Object} in_params - Input parameters for property creation\n * @param {string|undefined} in_scope - The scope in which the map typeid is defined\n * @constructor\n * @protected\n * @extends property-properties.IndexedCollectionBaseProperty\n * @alias property-properties.MapProperty\n * @category Maps\n */\n constructor(in_params, in_scope) {\n super(in_params);\n\n this._scope = in_scope;\n this._contextKeyType = in_params.contextKeyType || 'string';\n\n /** Contains the actual entries of the map */\n this._dynamicChildren = {};\n };\n\n get _context() { return 'map'; }\n\n /**\n * Returns the full property type identifier for the ChangeSet including the enum type id\n * @param {boolean} [in_hideCollection=false] - if true the collection type (if applicable) will be omitted\n * @return {string} The typeid\n */\n getFullTypeid(in_hideCollection = false) {\n if (in_hideCollection) {\n return this._typeid;\n } else {\n return TypeIdHelper.createSerializationTypeId(this._typeid, 'map');\n }\n };\n\n /**\n * Is this property a leaf node with regard to flattening?\n *\n * TODO: Which semantics should flattening have? It stops at primitive types and collections?\n *\n * @return {boolean} Is it a leaf with regard to flattening?\n */\n _isFlattenLeaf() {\n return true;\n };\n\n /**\n * Sets multiple values in a map.\n *\n * @param {object} in_values to assign to the collection\n * @param {Boolean} in_typed - If the map's items have a typeid and a value then create the\n * properties with that typeid, else use the set's typeid (support polymorphic items).\n * @see {setValues}\n * @private\n */\n _setValuesInternal(in_values, in_typed) {\n if (this._containsPrimitiveTypes) {\n var that = this;\n _.each(in_values, function (value, key) {\n if (that.has(key)) {\n that.remove(key);\n }\n\n that.insert(key, value);\n });\n } else {\n var that = this;\n _.each(in_values, function (value, key) {\n var property = that.get(String(key), { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER });\n // if key exists in set replace its value else insert a new key/value\n if (property) {\n if (property instanceof Property.ValueProperty || property instanceof Property.StringProperty) {\n property.setValue(value);\n } else if (property instanceof BaseProperty && _.isObject(value)) {\n property._setValues(value, false, false);\n } else {\n throw new Error(MSG.SET_VALUES_PATH_INVALID + key);\n }\n } else {\n if (value instanceof BaseProperty) {\n that.insert(key, value);\n } else {\n if (in_typed) {\n that.insert(key, Property.PropertyFactory._createProperty(\n value.typeid || that._typeid, null, value.value, that._getScope()));\n } else {\n that.insert(key, Property.PropertyFactory._createProperty(\n that._typeid, null, value, that._getScope()));\n }\n }\n }\n });\n }\n };\n\n /**\n * Sets multiple values in a map.\n *\n * @param {object} in_values to assign to the collection\n * @param {Bool} in_typed - Whether the values are typed/polymorphic.\n * @param {Bool} in_initial - Whether we are setting default/initial values\n * or if the function is called directly with the values to set.\n * @see {setValues}\n * @override\n */\n _setValues(in_values, in_typed, in_initial) {\n if (in_initial) {\n this.clear();\n }\n\n this._setValuesInternal(in_values, in_typed);\n };\n\n /**\n * Sets multiple values in a map.\n *\n * @param {object} in_values to assign to the collection\n * @throws if one of the path in in_values does not exist in this property\n * @throws if trying to set a value to a path that leads to a Property other than ValueProperty or StringProperty\n * @override\n */\n setValues(in_values) {\n var checkoutView = this._getCheckoutView();\n if (checkoutView !== undefined) {\n checkoutView.pushNotificationDelayScope();\n this._setValues(in_values, false, false);\n checkoutView.popNotificationDelayScope();\n } else {\n this._setValues(in_values, false, false);\n }\n };\n\n /**\n * Returns an object with all the nested values contained in this property\n * @return {object} an object representing the values of your property\n * for example: {\n 'firstString': {\n 'stringValue': 'test1'\n },\n 'secondString': {\n 'stringValue': 'test2'\n }\n }\n */\n getValues() {\n var ids = this.getIds();\n var result = {};\n for (var i = 0; i < ids.length; i++) {\n var child = this.get(ids[i]);\n if (child.isPrimitiveType()) {\n result[ids[i]] = this.get(ids[i]).getValue();\n } else {\n result[ids[i]] = child.getValues();\n }\n }\n return result;\n };\n\n /**\n * Returns the path segment for a child\n *\n * @param {property-properties.BaseProperty} in_childNode - The child for which the path is returned\n *\n * @return {string} The path segment to resolve the child property under this property\n * @protected\n */\n _getPathSegmentForChildNode(in_childNode) {\n return '[' + PathHelper.quotePathSegmentIfNeeded(in_childNode._id) + ']';\n };\n\n /**\n * Resolves a direct child node based on the given path segment\n *\n * @param {String} in_segment - The path segment to resolve\n * @param {property-properties.PathHelper.TOKEN_TYPES} in_segmentType - The type of segment in the tokenized path\n *\n * @return {property-properties.BaseProperty|undefined} The child property that has been resolved\n * @protected\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n // Base Properties only support paths separated via dots\n if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN) {\n return this._dynamicChildren[in_segment];\n } else {\n return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType);\n }\n };\n\n /**\n * Inserts a property or value into the map\n *\n * Note: This will trigger an exception when this key already exists in the map. If you want to overwrite\n * existing entries you can use the set function.\n *\n * @param {string} in_key - The key under which the entry is added\n * @param {property-properties.Property} in_property - The property to insert\n * @throws if the property already exists\n * @throws if the property already has a parent\n * @throws if in_key is not a string\n * @throws if the property is a root property\n */\n insert(in_key, in_property) {\n ConsoleUtils.assert(_.isString(in_key), MSG.KEY_NOT_STRING + in_key);\n if (this._dynamicChildren[in_key] !== undefined) {\n throw new Error(MSG.PROPERTY_ALREADY_EXISTS + in_key);\n }\n if (in_property instanceof BaseProperty) {\n in_property._validateInsertIn(this);\n // Set the ID of the entry, to make sure it corresponds to the used key\n in_property._setId(in_key);\n\n // Insert the entry into the collection\n this._insert(in_key, in_property, true);\n\n } else {\n throw new Error(MSG.NONVALUE_MAP_INSERT_PROP);\n }\n };\n\n /**\n * Removes the entry with the given key from the map\n *\n * @param {string} in_key - The key of the entry to remove from the map\n * @throws if trying to remove an entry that does not exist\n * @return {*} the item removed\n */\n remove(in_key) {\n var item = this.get(in_key);\n this._removeByKey(in_key, true);\n return item;\n };\n\n /**\n * Sets the entry with the given key to the property passed in\n *\n * Note: this will overwrite an already existing value\n *\n * @param {string} in_key - The key under which the entry is stored\n * @param {property-properties.MapProperty~MapValueType} in_property - The property to store in the map\n * @throws if in_property is not a property\n * @throws if trying to insert a property that has a parent\n * @throws if in_key is not a string or a number\n */\n set(in_key, in_property) {\n this._checkIsNotReadOnly(true);\n if (this._dynamicChildren[in_key] !== in_property) {\n if (this._containsPrimitiveTypes === false && in_property.getParent() !== undefined) {\n throw new Error(MSG.INSERTED_ENTRY_WITH_PARENT);\n }\n if (this._dynamicChildren[in_key] !== undefined) {\n this._removeByKey(in_key, false);\n }\n // Set the ID of the entry, to make sure it corresponds to the used key\n if (this._containsPrimitiveTypes === false) {\n in_property._setId(in_key);\n }\n this._insert(in_key, in_property, false);\n\n // Make one final report\n this._reportDirtinessToView();\n }\n };\n\n /**\n * Returns an Object with all the entries of the map.\n * Contrary ot .getValues, for Property Maps, this will return the Property, not an object with their nested values.\n * WARNING: This is a direct access to the internal data-structure and the collection MUST NOT be modified. It is\n * read only for fast access and iteration. Insertion and deletion MUST be done via the insert and remove functions\n * of this class.\n *\n * @return {Object} The map with all entries in the map.\n */\n getEntriesReadOnly() {\n return this._dynamicChildren;\n };\n\n /**\n * Returns the collection entry with the given key\n *\n * @param {string|array<string>} in_ids - key of the entry to return or an array of keys\n * if an array is passed, the .get function will be performed on each id in sequence\n * for example .get(['position','x']) is equivalent to .get('position').get('x').\n * If .get resolves to a ReferenceProperty, it will return the property that the ReferenceProperty\n * refers to.\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n *\n * @return {property-properties.Property|*|undefined} The entry in the collection or undefined\n * if none could be found\n */\n get(in_ids, in_options) {\n if (_.isArray(in_ids)) {\n // Forward handling of arrays to the BaseProperty function\n return AbstractStaticCollectionProperty.prototype.get.call(this, in_ids, in_options);\n } else {\n in_options = in_options || {};\n in_options.referenceResolutionMode =\n in_options.referenceResolutionMode === undefined ? BaseProperty.REFERENCE_RESOLUTION.ALWAYS :\n in_options.referenceResolutionMode;\n\n var prop = this;\n if (in_ids === PATH_TOKENS.ROOT) {\n prop = prop.getRoot();\n } else if (in_ids === PATH_TOKENS.UP) {\n prop = prop.getParent();\n } else if (in_ids === PATH_TOKENS.REF) {\n throw new Error(MSG.NO_GET_DEREFERENCE_ONLY);\n } else {\n prop = prop._dynamicChildren[in_ids];\n }\n\n // Handle automatic reference resolution\n if (in_options.referenceResolutionMode === BaseProperty.REFERENCE_RESOLUTION.ALWAYS) {\n if (prop instanceof Property.ReferenceProperty) {\n prop = prop.ref;\n }\n }\n\n return prop;\n }\n };\n\n /**\n * Checks whether an entry with the given name exists\n *\n * @param {string} in_id - Name of the property\n * @return {boolean} True if the property exists, otherwise false.\n */\n has(in_id) {\n return this._dynamicChildren[in_id] !== undefined;\n };\n\n /**\n * Returns all entries of the map as an array.\n *\n * NOTE: This function creates a copy and thus is less efficient as getEntriesReadOnly.\n *\n * @return {Array.<property-properties.BaseProperty | *>} Array with all entries of the map. This array\n * is a shallow copy which can be modified by the caller without effects on the map.\n */\n getAsArray() {\n return _.values(this._dynamicChildren);\n };\n\n /**\n * Returns all keys found in the map\n *\n * NOTE: This function creates a copy and thus is less efficient as getEntriesReadOnly.\n *\n * @return {Array.<string>} The keys\n */\n getIds() {\n return Object.keys(this._dynamicChildren);\n };\n\n /**\n * Get the scope to which this property belongs to.\n * @return {string|undefined} The guid representing the scope in which the\n * map belongs to. If there is a workspace scope return it, else return the scope of this map.\n * @override\n * @private\n */\n _getScope() {\n var scope = IndexedCollectionBaseProperty.prototype._getScope.call(this);\n\n if (scope !== undefined) {\n return scope;\n } else {\n return this._scope;\n }\n };\n\n /**\n * Deletes all values from the Map\n */\n clear() {\n var that = this;\n this.getIds().forEach(function (id) {\n that.remove(id);\n });\n };\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mapProperty.js","sourceRoot":"","sources":["../../src/properties/mapProperty.js"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AACH,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACnD,MAAM,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAC3F,MAAM,EAAE,6BAA6B,EAAE,GAAG,OAAO,CAAC,iCAAiC,CAAC,CAAC;AACrF,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACxE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACvF,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC,SAAS,CAAC;AACzE,MAAM,EAAE,oBAAoB,EAA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;;;;;OAMG;IACH,MAAM;QACF,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC9C,CAAC;IAAA,CAAC;IAEF;;;;;;OAMG;IACH,SAAS;QACL,IAAI,KAAK,GAAG,6BAA6B,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEzE,IAAI,KAAK,KAAK,SAAS,EAAE;YACrB,OAAO,KAAK,CAAC;SAChB;aAAM;YACH,OAAO,IAAI,CAAC,MAAM,CAAC;SACtB;IACL,CAAC;IAAA,CAAC;IAEF;;OAEG;IACH,KAAK;QACD,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE;YAC9B,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC;IAAA,CAAC;CAEL;AA9XD,kCA8XC;AAED,WAAW,CAAC,SAAS,CAAC,OAAO,GAAG,cAAc,CAAC;AAC/C,WAAW,CAAC,SAAS,CAAC,QAAQ,GAAG,KAAK,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * @fileoverview Definition of the map property class\n */\nconst _ = require('lodash');\nconst { BaseProperty } = require('./baseProperty');\nconst { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty');\nconst { IndexedCollectionBaseProperty } = require('./indexedCollectionBaseProperty');\nconst { ConsoleUtils } = require('@fluid-experimental/property-common');\nconst { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\nconst { LazyLoadedProperties: Property } = require('./lazyLoadedProperties');\n\nconst PATH_TOKENS = BaseProperty.PATH_TOKENS;\n\n/**\n * typedef {property-properties.BaseProperty|string|number|boolean} property-properties.MapProperty~MapValueType\n *\n * The type of the values that are set/inserted into the map. Depending on the type of the map, these can either\n * be property objects or primitive values\n */\n\n/**\n * A MapProperty is a collection class that can contain an dictionary that maps from strings to properties.\n */\nexport class MapProperty extends IndexedCollectionBaseProperty {\n\n /**\n * @param {Object} in_params - Input parameters for property creation\n * @param {string|undefined} in_scope - The scope in which the map typeid is defined\n * @constructor\n * @protected\n * @extends property-properties.IndexedCollectionBaseProperty\n * @alias property-properties.MapProperty\n * @category Maps\n */\n constructor(in_params, in_scope) {\n super(in_params);\n\n this._scope = in_scope;\n this._contextKeyType = in_params.contextKeyType || 'string';\n\n /** Contains the actual entries of the map */\n this._dynamicChildren = {};\n };\n\n /**\n * Returns the full property type identifier for the ChangeSet including the enum type id\n * @param {boolean} [in_hideCollection=false] - if true the collection type (if applicable) will be omitted\n * @return {string} The typeid\n */\n getFullTypeid(in_hideCollection = false) {\n if (in_hideCollection) {\n return this._typeid;\n } else {\n return TypeIdHelper.createSerializationTypeId(this._typeid, 'map');\n }\n };\n\n /**\n * Is this property a leaf node with regard to flattening?\n *\n * TODO: Which semantics should flattening have? It stops at primitive types and collections?\n *\n * @return {boolean} Is it a leaf with regard to flattening?\n */\n _isFlattenLeaf() {\n return true;\n };\n\n /**\n * Sets multiple values in a map.\n *\n * @param {object} in_values to assign to the collection\n * @param {Boolean} in_typed - If the map's items have a typeid and a value then create the\n * properties with that typeid, else use the set's typeid (support polymorphic items).\n * @see {setValues}\n * @private\n */\n _setValuesInternal(in_values, in_typed) {\n if (this._containsPrimitiveTypes) {\n var that = this;\n _.each(in_values, function (value, key) {\n if (that.has(key)) {\n that.remove(key);\n }\n\n that.insert(key, value);\n });\n } else {\n var that = this;\n _.each(in_values, function (value, key) {\n var property = that.get(String(key), { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER });\n // if key exists in set replace its value else insert a new key/value\n if (property) {\n if (property instanceof Property.ValueProperty || property instanceof Property.StringProperty) {\n property.setValue(value);\n } else if (property instanceof BaseProperty && _.isObject(value)) {\n property._setValues(value, false, false);\n } else {\n throw new Error(MSG.SET_VALUES_PATH_INVALID + key);\n }\n } else {\n if (value instanceof BaseProperty) {\n that.insert(key, value);\n } else {\n if (in_typed) {\n that.insert(key, Property.PropertyFactory._createProperty(\n value.typeid || that._typeid, null, value.value, that._getScope()));\n } else {\n that.insert(key, Property.PropertyFactory._createProperty(\n that._typeid, null, value, that._getScope()));\n }\n }\n }\n });\n }\n };\n\n /**\n * Sets multiple values in a map.\n *\n * @param {object} in_values to assign to the collection\n * @param {Bool} in_typed - Whether the values are typed/polymorphic.\n * @param {Bool} in_initial - Whether we are setting default/initial values\n * or if the function is called directly with the values to set.\n * @see {setValues}\n * @override\n */\n _setValues(in_values, in_typed, in_initial) {\n if (in_initial) {\n this.clear();\n }\n\n this._setValuesInternal(in_values, in_typed);\n };\n\n /**\n * Sets multiple values in a map.\n *\n * @param {object} in_values to assign to the collection\n * @throws if one of the path in in_values does not exist in this property\n * @throws if trying to set a value to a path that leads to a Property other than ValueProperty or StringProperty\n * @override\n */\n setValues(in_values) {\n var checkoutView = this._getCheckoutView();\n if (checkoutView !== undefined) {\n checkoutView.pushNotificationDelayScope();\n this._setValues(in_values, false, false);\n checkoutView.popNotificationDelayScope();\n } else {\n this._setValues(in_values, false, false);\n }\n };\n\n /**\n * Returns an object with all the nested values contained in this property\n * @return {object} an object representing the values of your property\n * for example: {\n 'firstString': {\n 'stringValue': 'test1'\n },\n 'secondString': {\n 'stringValue': 'test2'\n }\n }\n */\n getValues() {\n var ids = this.getIds();\n var result = {};\n for (var i = 0; i < ids.length; i++) {\n var child = this.get(ids[i]);\n if (child.isPrimitiveType()) {\n result[ids[i]] = this.get(ids[i]).getValue();\n } else {\n result[ids[i]] = child.getValues();\n }\n }\n return result;\n };\n\n /**\n * Returns the path segment for a child\n *\n * @param {property-properties.BaseProperty} in_childNode - The child for which the path is returned\n *\n * @return {string} The path segment to resolve the child property under this property\n * @protected\n */\n _getPathSegmentForChildNode(in_childNode) {\n return '[' + PathHelper.quotePathSegmentIfNeeded(in_childNode._id) + ']';\n };\n\n /**\n * Resolves a direct child node based on the given path segment\n *\n * @param {String} in_segment - The path segment to resolve\n * @param {property-properties.PathHelper.TOKEN_TYPES} in_segmentType - The type of segment in the tokenized path\n *\n * @return {property-properties.BaseProperty|undefined} The child property that has been resolved\n * @protected\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n // Base Properties only support paths separated via dots\n if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN) {\n return this._dynamicChildren[in_segment];\n } else {\n return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType);\n }\n };\n\n /**\n * Inserts a property or value into the map\n *\n * Note: This will trigger an exception when this key already exists in the map. If you want to overwrite\n * existing entries you can use the set function.\n *\n * @param {string} in_key - The key under which the entry is added\n * @param {property-properties.Property} in_property - The property to insert\n * @throws if the property already exists\n * @throws if the property already has a parent\n * @throws if in_key is not a string\n * @throws if the property is a root property\n */\n insert(in_key, in_property) {\n ConsoleUtils.assert(_.isString(in_key), MSG.KEY_NOT_STRING + in_key);\n if (this._dynamicChildren[in_key] !== undefined) {\n throw new Error(MSG.PROPERTY_ALREADY_EXISTS + in_key);\n }\n if (in_property instanceof BaseProperty) {\n in_property._validateInsertIn(this);\n // Set the ID of the entry, to make sure it corresponds to the used key\n in_property._setId(in_key);\n\n // Insert the entry into the collection\n this._insert(in_key, in_property, true);\n\n } else {\n throw new Error(MSG.NONVALUE_MAP_INSERT_PROP);\n }\n };\n\n /**\n * Removes the entry with the given key from the map\n *\n * @param {string} in_key - The key of the entry to remove from the map\n * @throws if trying to remove an entry that does not exist\n * @return {*} the item removed\n */\n remove(in_key) {\n var item = this.get(in_key);\n this._removeByKey(in_key, true);\n return item;\n };\n\n /**\n * Sets the entry with the given key to the property passed in\n *\n * Note: this will overwrite an already existing value\n *\n * @param {string} in_key - The key under which the entry is stored\n * @param {property-properties.MapProperty~MapValueType} in_property - The property to store in the map\n * @throws if in_property is not a property\n * @throws if trying to insert a property that has a parent\n * @throws if in_key is not a string or a number\n */\n set(in_key, in_property) {\n this._checkIsNotReadOnly(true);\n if (this._dynamicChildren[in_key] !== in_property) {\n if (this._containsPrimitiveTypes === false && in_property.getParent() !== undefined) {\n throw new Error(MSG.INSERTED_ENTRY_WITH_PARENT);\n }\n if (this._dynamicChildren[in_key] !== undefined) {\n this._removeByKey(in_key, false);\n }\n // Set the ID of the entry, to make sure it corresponds to the used key\n if (this._containsPrimitiveTypes === false) {\n in_property._setId(in_key);\n }\n this._insert(in_key, in_property, false);\n\n // Make one final report\n this._reportDirtinessToView();\n }\n };\n\n /**\n * Returns an Object with all the entries of the map.\n * Contrary ot .getValues, for Property Maps, this will return the Property, not an object with their nested values.\n * WARNING: This is a direct access to the internal data-structure and the collection MUST NOT be modified. It is\n * read only for fast access and iteration. Insertion and deletion MUST be done via the insert and remove functions\n * of this class.\n *\n * @return {Object} The map with all entries in the map.\n */\n getEntriesReadOnly() {\n return this._dynamicChildren;\n };\n\n /**\n * Returns the collection entry with the given key\n *\n * @param {string|array<string>} in_ids - key of the entry to return or an array of keys\n * if an array is passed, the .get function will be performed on each id in sequence\n * for example .get(['position','x']) is equivalent to .get('position').get('x').\n * If .get resolves to a ReferenceProperty, it will return the property that the ReferenceProperty\n * refers to.\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n *\n * @return {property-properties.Property|*|undefined} The entry in the collection or undefined\n * if none could be found\n */\n get(in_ids, in_options) {\n if (_.isArray(in_ids)) {\n // Forward handling of arrays to the BaseProperty function\n return AbstractStaticCollectionProperty.prototype.get.call(this, in_ids, in_options);\n } else {\n in_options = in_options || {};\n in_options.referenceResolutionMode =\n in_options.referenceResolutionMode === undefined ? BaseProperty.REFERENCE_RESOLUTION.ALWAYS :\n in_options.referenceResolutionMode;\n\n var prop = this;\n if (in_ids === PATH_TOKENS.ROOT) {\n prop = prop.getRoot();\n } else if (in_ids === PATH_TOKENS.UP) {\n prop = prop.getParent();\n } else if (in_ids === PATH_TOKENS.REF) {\n throw new Error(MSG.NO_GET_DEREFERENCE_ONLY);\n } else {\n prop = prop._dynamicChildren[in_ids];\n }\n\n // Handle automatic reference resolution\n if (in_options.referenceResolutionMode === BaseProperty.REFERENCE_RESOLUTION.ALWAYS) {\n if (prop instanceof Property.ReferenceProperty) {\n prop = prop.ref;\n }\n }\n\n return prop;\n }\n };\n\n /**\n * Checks whether an entry with the given name exists\n *\n * @param {string} in_id - Name of the property\n * @return {boolean} True if the property exists, otherwise false.\n */\n has(in_id) {\n return this._dynamicChildren[in_id] !== undefined;\n };\n\n /**\n * Returns all entries of the map as an array.\n *\n * NOTE: This function creates a copy and thus is less efficient as getEntriesReadOnly.\n *\n * @return {Array.<property-properties.BaseProperty | *>} Array with all entries of the map. This array\n * is a shallow copy which can be modified by the caller without effects on the map.\n */\n getAsArray() {\n return _.values(this._dynamicChildren);\n };\n\n /**\n * Returns all keys found in the map\n *\n * NOTE: This function creates a copy and thus is less efficient as getEntriesReadOnly.\n *\n * @return {Array.<string>} The keys\n */\n getIds() {\n return Object.keys(this._dynamicChildren);\n };\n\n /**\n * Get the scope to which this property belongs to.\n * @return {string|undefined} The guid representing the scope in which the\n * map belongs to. If there is a workspace scope return it, else return the scope of this map.\n * @override\n * @private\n */\n _getScope() {\n var scope = IndexedCollectionBaseProperty.prototype._getScope.call(this);\n\n if (scope !== undefined) {\n return scope;\n } else {\n return this._scope;\n }\n };\n\n /**\n * Deletes all values from the Map\n */\n clear() {\n var that = this;\n this.getIds().forEach(function (id) {\n that.remove(id);\n });\n };\n\n}\n\nMapProperty.prototype._typeid = 'BaseProperty';\nMapProperty.prototype._context = 'map';\n"]}
|
|
@@ -27,7 +27,7 @@ class NamedNodeProperty extends NodeProperty {
|
|
|
27
27
|
* @category Other Collections
|
|
28
28
|
*/
|
|
29
29
|
constructor(in_params) {
|
|
30
|
-
super(
|
|
30
|
+
super(in_params);
|
|
31
31
|
/**
|
|
32
32
|
* Returns a string identifying the property
|
|
33
33
|
*
|
|
@@ -52,4 +52,5 @@ class NamedNodeProperty extends NodeProperty {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
exports.NamedNodeProperty = NamedNodeProperty;
|
|
55
|
+
NamedNodeProperty.prototype._typeid = 'NamedNodeProperty';
|
|
55
56
|
//# sourceMappingURL=namedNodeProperty.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namedNodeProperty.js","sourceRoot":"","sources":["../../src/properties/namedNodeProperty.js"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AAEH,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACrD,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAa,iBAAkB,SAAQ,YAAY;IAE/C;;;;;;;;;;OAUG;IACH,YAAY,SAAS;QACjB,KAAK,
|
|
1
|
+
{"version":3,"file":"namedNodeProperty.js","sourceRoot":"","sources":["../../src/properties/namedNodeProperty.js"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AAEH,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACrD,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAa,iBAAkB,SAAQ,YAAY;IAE/C;;;;;;;;;;OAUG;IACH,YAAY,SAAS;QACjB,KAAK,CAAC,SAAS,CAAC,CAAC;QAGrB;;;;;;WAMG;QACH,UAAK,GAAG,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC;QAEtC;;;;;;WAMG;QACH,YAAO,GAAG,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC;QAE1C;;;WAGG;QACH,WAAM,GAAG,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC;IAxBxC,CAAC;CA0BJ;AAzCD,8CAyCC;AAED,iBAAiB,CAAC,SAAS,CAAC,OAAO,GAAG,mBAAmB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * @fileoverview Definition of the named node property class\n */\n\nconst { NamedProperty } = require('./namedProperty');\nconst { NodeProperty } = require('./nodeProperty');\n\n/**\n * A NamedNodeProperty is a NodeProperty that has a GUID which unique identifies the property object.\n * This makes it possible to store it in a set collection.\n */\nexport class NamedNodeProperty extends NodeProperty {\n\n /**\n * @param {object} in_params - List of parameters\n * @param {string} in_params.id - id of the property (null, if the GUID should be used for the ID)\n * @param {string} in_params.typeid - The type identifier\n *\n * @constructor\n * @protected\n * @extends property-properties.NodeProperty\n * @alias property-properties.NamedNodeProperty\n * @category Other Collections\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Returns a string identifying the property\n *\n * If an id has been explicitly set on this property we return that one, otherwise the GUID is used.\n *\n * @return {string} String identifying the property\n */\n getId = NamedProperty.prototype.getId;\n\n /**\n * Returns the GUID of this named property\n * A Guid is a unique identifier for a branch, commit or repository,\n * similar to a URN. Most functions in the API will us a URN but the\n * Guid is used to traverse the commit graph.\n * @return {string} The GUID\n */\n getGuid = NamedProperty.prototype.getGuid;\n\n /**\n * Return the URN for this named property\n * @return {string} The URN\n */\n getUrn = NamedProperty.prototype.getUrn;\n\n}\n\nNamedNodeProperty.prototype._typeid = 'NamedNodeProperty';\n"]}
|
|
@@ -27,7 +27,7 @@ class NamedProperty extends ContainerProperty {
|
|
|
27
27
|
* @category Properties
|
|
28
28
|
*/
|
|
29
29
|
constructor(in_params) {
|
|
30
|
-
super(
|
|
30
|
+
super(in_params);
|
|
31
31
|
}
|
|
32
32
|
;
|
|
33
33
|
/**
|
|
@@ -60,4 +60,5 @@ class NamedProperty extends ContainerProperty {
|
|
|
60
60
|
;
|
|
61
61
|
}
|
|
62
62
|
exports.NamedProperty = NamedProperty;
|
|
63
|
+
NamedProperty.prototype._typeid = 'NamedProperty';
|
|
63
64
|
//# sourceMappingURL=namedProperty.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namedProperty.js","sourceRoot":"","sources":["../../src/properties/namedProperty.js"],"names":[],"mappings":";AAAA;;;GAGG;AACH;;GAEG;;;AAEH,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAC7D,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAa,aAAc,SAAQ,iBAAiB;IAEhD;;;;;;;;;;OAUG;IACH,YAAY,SAAS;QACjB,KAAK,
|
|
1
|
+
{"version":3,"file":"namedProperty.js","sourceRoot":"","sources":["../../src/properties/namedProperty.js"],"names":[],"mappings":";AAAA;;;GAGG;AACH;;GAEG;;;AAEH,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAC7D,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAa,aAAc,SAAQ,iBAAiB;IAEhD;;;;;;;;;;OAUG;IACH,YAAY,SAAS;QACjB,KAAK,CAAC,SAAS,CAAC,CAAC;IACrB,CAAC;IAAA,CAAC;IAEF;;;;;;OAMG;IACH,KAAK;QACD,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI,EAAE;YACnB,OAAO,IAAI,CAAC,GAAG,CAAC;SACnB;aAAM;YACH,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;SACzB;IACL,CAAC;IAAA,CAAC;IAEF;;;;;;OAMG;IACH,OAAO;QACH,IAAI,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,uBAAuB,EAAE,YAAY,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC,CAAC;QAClG,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACvC,CAAC;IAAA,CAAC;CAYL;AAtDD,sCAsDC;AACD,aAAa,CAAC,SAAS,CAAC,OAAO,GAAG,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Definition of the named property class\n */\n\nconst { ContainerProperty } = require('./containerProperty');\nconst { BaseProperty } = require('./baseProperty');\n\n/**\n * A NamedProperty has a URN which uniquely identifies the property object. This makes it possible to store it in a\n * set collection.\n */\nexport class NamedProperty extends ContainerProperty {\n\n /**\n * @param {object} in_params - List of parameters\n * @param {string} in_params.id - id of the property (null, if the GUID should be used for the ID)\n * @param {string} in_params.typeid - The type identifier\n *\n * @constructor\n * @protected\n * @extends property-properties.ContainerProperty\n * @alias property-properties.NamedProperty\n * @category Properties\n */\n constructor(in_params) {\n super(in_params);\n };\n\n /**\n * Returns a string identifying the property\n *\n * If an id has been explicitly set on this property we return that one, otherwise the GUID is used.\n *\n * @return {string} String identifying the property\n */\n getId() {\n if (this._id !== null) {\n return this._id;\n } else {\n return this.getGuid();\n }\n };\n\n /**\n * Returns the GUID of this named property\n * A Guid is a unique identifier for a branch, commit or repository,\n * similar to a URN. Most functions in the API will us a URN but the\n * Guid is used to traverse the commit graph.\n * @return {string} The GUID\n */\n getGuid() {\n var guid = this.get('guid', { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER });\n return guid ? guid.getValue() : '';\n };\n\n\n // THIS IS DISABLED FOR THE MOMENT, UNTIL WE BETTER UNDERSTAND HOW REFERENCES WORK IN FLUID\n /**\n * Return the URN for this named property\n * @return {string} The URN\n */\n /*NamedProperty.prototype.getUrn = function() {\n\n };*/\n\n}\nNamedProperty.prototype._typeid = 'NamedProperty';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeProperty.d.ts","sourceRoot":"","sources":["../../src/properties/nodeProperty.js"],"names":[],"mappings":"AAUA;;GAEG;AACH;IAEI;;;;;;;;OAQG;IACH,
|
|
1
|
+
{"version":3,"file":"nodeProperty.d.ts","sourceRoot":"","sources":["../../src/properties/nodeProperty.js"],"names":[],"mappings":"AAUA;;GAEG;AACH;IAEI;;;;;;;;OAQG;IACH,wBAGC;CAYJ"}
|
|
@@ -23,7 +23,8 @@ class NodeProperty extends ContainerProperty {
|
|
|
23
23
|
* @category Other Collections
|
|
24
24
|
*/
|
|
25
25
|
constructor(in_params) {
|
|
26
|
-
super(
|
|
26
|
+
super(in_params);
|
|
27
|
+
this._dynamicChildren = {};
|
|
27
28
|
}
|
|
28
29
|
;
|
|
29
30
|
/**
|
|
@@ -38,4 +39,5 @@ class NodeProperty extends ContainerProperty {
|
|
|
38
39
|
;
|
|
39
40
|
}
|
|
40
41
|
exports.NodeProperty = NodeProperty;
|
|
42
|
+
NodeProperty.prototype._typeid = 'NodeProperty';
|
|
41
43
|
//# sourceMappingURL=nodeProperty.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeProperty.js","sourceRoot":"","sources":["../../src/properties/nodeProperty.js"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AACH,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAE7D;;GAEG;AACH,MAAa,YAAa,SAAQ,iBAAiB;IAE/C;;;;;;;;OAQG;IACH,YAAY,SAAS;QACjB,KAAK,
|
|
1
|
+
{"version":3,"file":"nodeProperty.js","sourceRoot":"","sources":["../../src/properties/nodeProperty.js"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AACH,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAE7D;;GAEG;AACH,MAAa,YAAa,SAAQ,iBAAiB;IAE/C;;;;;;;;OAQG;IACH,YAAY,SAAS;QACjB,KAAK,CAAE,SAAS,CAAE,CAAC;QACnB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAC/B,CAAC;IAAA,CAAC;IAEF;;OAEG;IACH,SAAS,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IAAA,CAAC;IAE7B;;OAEG;IACH,eAAe,CAAC,KAAK,EAAE,WAAW,IAAI,CAAC;IAAA,CAAC;CAE3C;AA1BD,oCA0BC;AACD,YAAY,CAAC,SAAS,CAAC,OAAO,GAAG,cAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * @fileoverview This file contains the implementation of the NodeProperty class\n */\nconst { ContainerProperty } = require('./containerProperty');\n\n/**\n * A property object that allows to add child properties dynamically.\n */\nexport class NodeProperty extends ContainerProperty {\n\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ContainerProperty\n * @alias property-properties.NodeProperty\n * @category Other Collections\n */\n constructor(in_params) {\n super( in_params );\n this._dynamicChildren = {};\n };\n\n /**\n * @inheritdoc\n */\n isDynamic() { return true; };\n\n /**\n * @inheritdoc\n */\n _validateInsert(in_id, in_property) { };\n\n}\nNodeProperty.prototype._typeid = 'NodeProperty';\n"]}
|
|
@@ -30,7 +30,7 @@ class ReferenceArrayProperty extends ValueArrayProperty {
|
|
|
30
30
|
* @category Arrays
|
|
31
31
|
*/
|
|
32
32
|
constructor(in_params) {
|
|
33
|
-
super(
|
|
33
|
+
super(in_params);
|
|
34
34
|
}
|
|
35
35
|
;
|
|
36
36
|
/**
|
|
@@ -250,4 +250,5 @@ ReferenceArrayProperty._convertInputToPaths = function (in_array, in_callerName)
|
|
|
250
250
|
}
|
|
251
251
|
return arr;
|
|
252
252
|
};
|
|
253
|
+
ReferenceArrayProperty.prototype._typeid = 'Reference';
|
|
253
254
|
//# sourceMappingURL=referenceArrayProperty.js.map
|
|
@@ -1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AA,CAAC;IAEF;;;OAGG;IACH,gBAAgB,CAAC,SAAS;QACtB,IAAI,CAAC,aAAa,GAAG,IAAI,kBAAkB,CAAC,SAAS,CAAC,CAAC;QACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE;YAChC,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;SAClC;IACL,CAAC;IAAA,CAAC;;AAhNN,wDA0OC;AAxBG;;;;;;;;;;;GAWG;AACI,2CAAoB,GAAG,UAAU,QAAQ,EAAE,aAAa;IAC3D,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,kBAAkB,GAAG,yBAAyB,GAAG,aAAa,CAAC,CAAC;KACvF;IACD,IAAI,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC1B,IAAI,GAAG,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QAC1B,GAAG,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/D;IACD,OAAO,GAAG,CAAC;AACf,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Definition of the reference array property class\n */\nconst _ = require('lodash');\nconst { ValueArrayProperty } = require('./valueArrayProperty');\nconst { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset');\nconst { BaseProperty } = require('./baseProperty');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\nconst { UniversalDataArray, ConsoleUtils } = require('@fluid-experimental/property-common');\nconst { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty');\nconst { ReferenceProperty } = require('./referenceProperty');\n\n/**\n * An ArrayProperty which stores reference values\n */\nexport class ReferenceArrayProperty extends ValueArrayProperty {\n\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ArrayProperty\n * @alias property-properties.ReferenceArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super({ typeid: 'Reference', ...in_params, });\n };\n\n /**\n * Returns the typeid for the target of this reference\n *\n * Note: This is the type that is specified in the typeid of this reference and not the actual type\n * of the referenced object, which might inherit from that typeid.\n *\n * @return {string} The typeid of the nodes this reference may point to\n */\n getReferenceTargetTypeId() {\n return TypeIdHelper.extractReferenceTargetTypeIdFromReference(this.getTypeid());\n };\n\n /**\n * Resolves the referenced property for the given key\n *\n * @param {number|array<string|number>} in_ids the ID of the property or an array of IDs\n * if an array is passed, the .get function will be performed on each id in sequence\n * for example .get([0, 'position','x']) is equivalent to .get(0).get('position').get('x').\n * If .get resolves to a ReferenceProperty, it will, by default, return the property that the ReferenceProperty\n * refers to.\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n *\n * @return {property-properties.BaseProperty|undefined} The property object the reference points to or undefined if it\n * could not be resolved\n */\n get(in_ids, in_options) {\n in_options = in_options || {};\n in_options.referenceResolutionMode =\n in_options.referenceResolutionMode === undefined ? BaseProperty.REFERENCE_RESOLUTION.ALWAYS :\n in_options.referenceResolutionMode;\n\n if (_.isArray(in_ids)) {\n // Forward handling of arrays to the AbstractStaticCollectionProperty function\n return AbstractStaticCollectionProperty.prototype.get.call(this, in_ids, in_options);\n } else {\n var value = this._dataArrayRef.getValue(in_ids);\n if (value === undefined ||\n value === '') {\n return undefined;\n }\n\n return this.getParent().resolvePath(value, in_options);\n }\n };\n\n /**\n * Checks whether the reference is valid. This is either the case when it is empty or when the referenced\n * property exists.\n *\n * @param {number} in_position the target index\n * @return {boolean} True if the reference is valid, otherwise false.\n */\n isReferenceValid(in_position) {\n return ValueArrayProperty.prototype.get.call(this, in_position) === '' ||\n this.get(in_position) !== undefined;\n };\n\n /**\n * Sets the range in the array to point to the given property objects or to be equal to the given paths\n *\n * @param {number} in_offset - target start index\n * @param {Array<property-properties.BaseProperty|undefined|String>} in_array - contains the properties to be set or\n * the paths to those properties. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if in_offset is smaller than zero, larger than the length of the array or not a number\n * @throws if in_array is not an array\n * @throws if one of the items in in_array is defined, but is not a property or a string.\n */\n setRange(in_offset, in_array) {\n var arr = ReferenceArrayProperty._convertInputToPaths(in_array, 'setRange');\n ValueArrayProperty.prototype.setRange.call(this, in_offset, arr);\n };\n\n /**\n * Insert a range which points to the given property objects into the array\n *\n * @param {number} in_offset - target start index\n * @param {Array<property-properties.BaseProperty|undefined|String>} in_array - contains the properties to be set or\n * the paths to those properties. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if in_offset is smaller than zero, larger than the length of the array or not a number\n * @throws if in_array is not an array\n * @throws if one of the items in in_array is defined, but is not a property or a string.\n */\n insertRange(in_offset, in_array) {\n var arr = ReferenceArrayProperty._convertInputToPaths(in_array, 'insertRange');\n ValueArrayProperty.prototype.insertRange.call(this, in_offset, arr);\n };\n\n /**\n * returns the path value of a reference.\n * @param {number} in_id the index of the property\n * @return {string} the path string\n */\n getValue(in_id) {\n return this._dataArrayRef.getValue(in_id);\n };\n\n /**\n * Returns an object with all the nested values contained in this property\n * @return {array<String>} an array of strings representing the paths listed in this array\n * for example: ['/path1', '/path2']\n */\n getValues() {\n var result = [];\n var ids = this.getIds();\n for (var i = 0; i < ids.length; i++) {\n result.push(this.getValue(ids[i]));\n }\n return result;\n };\n\n /**\n * Removes the last element of the array\n * @throws if trying to modify a referenced property\n * @return {String} deleted element (string path)\n */\n pop() {\n if (this._dataArrayRef.length > 0) {\n var item = this.getValue(this._dataArrayRef.length - 1);\n this.remove(this._dataArrayRef.length - 1);\n return item;\n } else {\n return undefined;\n }\n };\n\n /**\n * Removes an element of the array and shift remaining elements to the left\n * @param {number} in_position the index that will be removed\n * @throws if in_position is not a number\n * @throws if trying to remove an item with a parent\n * @throws if trying to remove something that does not exist\n * @return {String} the value that was removed (string path).\n */\n remove(in_position) {\n var value = this.getValue(in_position);\n this.removeRange(in_position, 1);\n return value;\n };\n\n /**\n * Removes a given number of elements from the array and shifts remaining values to the left.\n * @param {number} in_offset target start index\n * @param {number} in_deleteCount number of elements to be deleted\n * @throws if in_offset is not a number\n * @throws if in_deleteCount is not a number\n * @throws if trying to remove an item with a parent\n * @throws if in_offset is smaller than zero or if in_offset + in_delete count is larger than the length of the array\n * @return {Array<String>} an array containing the values removed (string paths)\n */\n removeRange(in_offset, in_deleteCount) {\n ConsoleUtils.assert(_.isNumber(in_offset),\n MSG.NOT_NUMBER + 'in_offset, method: ArrayProperty.removeRange or .remove');\n ConsoleUtils.assert(_.isNumber(in_deleteCount),\n MSG.NOT_NUMBER + 'in_deleteCount, method: ArrayProperty.removeRange or .remove');\n ConsoleUtils.assert(in_offset + in_deleteCount < this.length + 1 && in_offset >= 0 && in_deleteCount > 0,\n MSG.REMOVE_OUT_OF_BOUNDS + 'Cannot remove ' + in_deleteCount + ' items starting at index ' + in_offset);\n var result = [];\n for (var i = in_offset; i < in_offset + in_deleteCount; i++) {\n result.push(this.getValue(i));\n }\n this._checkIsNotReadOnly(true);\n this._removeRangeWithoutDirtying(in_offset, in_deleteCount);\n this._setDirty();\n return result;\n };\n\n /**\n * @inheritdoc\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n\n // Array tokens are automatically resolved\n if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN) {\n return this.get(in_segment, { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER });\n } else {\n // Everything else is handled by the implementation in the base property\n return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType);\n }\n };\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new UniversalDataArray(in_length);\n for (var i = 0; i < in_length; i++) {\n this._dataArraySetValue(i, '');\n }\n };\n\n /**\n * Validates the array and returns a sanitized version of it containing only strings.\n *\n * @param {Array<property-properties.BaseProperty|undefined|String>} in_array - contains the properties to be set or\n * the paths to those properties. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @param {String} in_callerName - the name of the function that called, to make it appear in\n * the error message if any\n * @return {Array<string>} the array of paths\n * @throws if in_array is not an array\n * @throws if one of the items in in_array is defined, but is not a property or a string.\n */\n static _convertInputToPaths = function (in_array, in_callerName) {\n if (!_.isArray(in_array)) {\n throw new Error(MSG.IN_ARRAY_NOT_ARRAY + 'ReferenceArrayProperty.' + in_callerName);\n }\n var len = in_array.length;\n var arr = new Array(len);\n for (var i = 0; i < len; i++) {\n arr[i] = ReferenceProperty._convertInputToPath(in_array[i]);\n }\n return arr;\n };\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"referenceArrayProperty.js","sourceRoot":"","sources":["../../src/properties/referenceArrayProperty.js"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH;;GAEG;AACH,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAC/D,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACvF,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACnD,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC,SAAS,CAAC;AACzE,MAAM,EAAE,kBAAkB,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AAC5F,MAAM,EAAE,g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KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QAC1B,GAAG,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/D;IACD,OAAO,GAAG,CAAC;AACf,CAAC,CAAC;AAGN,sBAAsB,CAAC,SAAS,CAAC,OAAO,GAAG,WAAW,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Definition of the reference array property class\n */\nconst _ = require('lodash');\nconst { ValueArrayProperty } = require('./valueArrayProperty');\nconst { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset');\nconst { BaseProperty } = require('./baseProperty');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\nconst { UniversalDataArray, ConsoleUtils } = require('@fluid-experimental/property-common');\nconst { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty');\nconst { ReferenceProperty } = require('./referenceProperty');\n\n/**\n * An ArrayProperty which stores reference values\n */\nexport class ReferenceArrayProperty extends ValueArrayProperty {\n\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ArrayProperty\n * @alias property-properties.ReferenceArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n };\n\n /**\n * Returns the typeid for the target of this reference\n *\n * Note: This is the type that is specified in the typeid of this reference and not the actual type\n * of the referenced object, which might inherit from that typeid.\n *\n * @return {string} The typeid of the nodes this reference may point to\n */\n getReferenceTargetTypeId() {\n return TypeIdHelper.extractReferenceTargetTypeIdFromReference(this.getTypeid());\n };\n\n /**\n * Resolves the referenced property for the given key\n *\n * @param {number|array<string|number>} in_ids the ID of the property or an array of IDs\n * if an array is passed, the .get function will be performed on each id in sequence\n * for example .get([0, 'position','x']) is equivalent to .get(0).get('position').get('x').\n * If .get resolves to a ReferenceProperty, it will, by default, return the property that the ReferenceProperty\n * refers to.\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n *\n * @return {property-properties.BaseProperty|undefined} The property object the reference points to or undefined if it\n * could not be resolved\n */\n get(in_ids, in_options) {\n in_options = in_options || {};\n in_options.referenceResolutionMode =\n in_options.referenceResolutionMode === undefined ? BaseProperty.REFERENCE_RESOLUTION.ALWAYS :\n in_options.referenceResolutionMode;\n\n if (_.isArray(in_ids)) {\n // Forward handling of arrays to the AbstractStaticCollectionProperty function\n return AbstractStaticCollectionProperty.prototype.get.call(this, in_ids, in_options);\n } else {\n var value = this._dataArrayRef.getValue(in_ids);\n if (value === undefined ||\n value === '') {\n return undefined;\n }\n\n return this.getParent().resolvePath(value, in_options);\n }\n };\n\n /**\n * Checks whether the reference is valid. This is either the case when it is empty or when the referenced\n * property exists.\n *\n * @param {number} in_position the target index\n * @return {boolean} True if the reference is valid, otherwise false.\n */\n isReferenceValid(in_position) {\n return ValueArrayProperty.prototype.get.call(this, in_position) === '' ||\n this.get(in_position) !== undefined;\n };\n\n /**\n * Sets the range in the array to point to the given property objects or to be equal to the given paths\n *\n * @param {number} in_offset - target start index\n * @param {Array<property-properties.BaseProperty|undefined|String>} in_array - contains the properties to be set or\n * the paths to those properties. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if in_offset is smaller than zero, larger than the length of the array or not a number\n * @throws if in_array is not an array\n * @throws if one of the items in in_array is defined, but is not a property or a string.\n */\n setRange(in_offset, in_array) {\n var arr = ReferenceArrayProperty._convertInputToPaths(in_array, 'setRange');\n ValueArrayProperty.prototype.setRange.call(this, in_offset, arr);\n };\n\n /**\n * Insert a range which points to the given property objects into the array\n *\n * @param {number} in_offset - target start index\n * @param {Array<property-properties.BaseProperty|undefined|String>} in_array - contains the properties to be set or\n * the paths to those properties. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if in_offset is smaller than zero, larger than the length of the array or not a number\n * @throws if in_array is not an array\n * @throws if one of the items in in_array is defined, but is not a property or a string.\n */\n insertRange(in_offset, in_array) {\n var arr = ReferenceArrayProperty._convertInputToPaths(in_array, 'insertRange');\n ValueArrayProperty.prototype.insertRange.call(this, in_offset, arr);\n };\n\n /**\n * returns the path value of a reference.\n * @param {number} in_id the index of the property\n * @return {string} the path string\n */\n getValue(in_id) {\n return this._dataArrayRef.getValue(in_id);\n };\n\n /**\n * Returns an object with all the nested values contained in this property\n * @return {array<String>} an array of strings representing the paths listed in this array\n * for example: ['/path1', '/path2']\n */\n getValues() {\n var result = [];\n var ids = this.getIds();\n for (var i = 0; i < ids.length; i++) {\n result.push(this.getValue(ids[i]));\n }\n return result;\n };\n\n /**\n * Removes the last element of the array\n * @throws if trying to modify a referenced property\n * @return {String} deleted element (string path)\n */\n pop() {\n if (this._dataArrayRef.length > 0) {\n var item = this.getValue(this._dataArrayRef.length - 1);\n this.remove(this._dataArrayRef.length - 1);\n return item;\n } else {\n return undefined;\n }\n };\n\n /**\n * Removes an element of the array and shift remaining elements to the left\n * @param {number} in_position the index that will be removed\n * @throws if in_position is not a number\n * @throws if trying to remove an item with a parent\n * @throws if trying to remove something that does not exist\n * @return {String} the value that was removed (string path).\n */\n remove(in_position) {\n var value = this.getValue(in_position);\n this.removeRange(in_position, 1);\n return value;\n };\n\n /**\n * Removes a given number of elements from the array and shifts remaining values to the left.\n * @param {number} in_offset target start index\n * @param {number} in_deleteCount number of elements to be deleted\n * @throws if in_offset is not a number\n * @throws if in_deleteCount is not a number\n * @throws if trying to remove an item with a parent\n * @throws if in_offset is smaller than zero or if in_offset + in_delete count is larger than the length of the array\n * @return {Array<String>} an array containing the values removed (string paths)\n */\n removeRange(in_offset, in_deleteCount) {\n ConsoleUtils.assert(_.isNumber(in_offset),\n MSG.NOT_NUMBER + 'in_offset, method: ArrayProperty.removeRange or .remove');\n ConsoleUtils.assert(_.isNumber(in_deleteCount),\n MSG.NOT_NUMBER + 'in_deleteCount, method: ArrayProperty.removeRange or .remove');\n ConsoleUtils.assert(in_offset + in_deleteCount < this.length + 1 && in_offset >= 0 && in_deleteCount > 0,\n MSG.REMOVE_OUT_OF_BOUNDS + 'Cannot remove ' + in_deleteCount + ' items starting at index ' + in_offset);\n var result = [];\n for (var i = in_offset; i < in_offset + in_deleteCount; i++) {\n result.push(this.getValue(i));\n }\n this._checkIsNotReadOnly(true);\n this._removeRangeWithoutDirtying(in_offset, in_deleteCount);\n this._setDirty();\n return result;\n };\n\n /**\n * @inheritdoc\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n\n // Array tokens are automatically resolved\n if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN) {\n return this.get(in_segment, { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER });\n } else {\n // Everything else is handled by the implementation in the base property\n return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType);\n }\n };\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new UniversalDataArray(in_length);\n for (var i = 0; i < in_length; i++) {\n this._dataArraySetValue(i, '');\n }\n };\n\n /**\n * Validates the array and returns a sanitized version of it containing only strings.\n *\n * @param {Array<property-properties.BaseProperty|undefined|String>} in_array - contains the properties to be set or\n * the paths to those properties. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @param {String} in_callerName - the name of the function that called, to make it appear in\n * the error message if any\n * @return {Array<string>} the array of paths\n * @throws if in_array is not an array\n * @throws if one of the items in in_array is defined, but is not a property or a string.\n */\n static _convertInputToPaths = function (in_array, in_callerName) {\n if (!_.isArray(in_array)) {\n throw new Error(MSG.IN_ARRAY_NOT_ARRAY + 'ReferenceArrayProperty.' + in_callerName);\n }\n var len = in_array.length;\n var arr = new Array(len);\n for (var i = 0; i < len; i++) {\n arr[i] = ReferenceProperty._convertInputToPath(in_array[i]);\n }\n return arr;\n };\n\n}\nReferenceArrayProperty.prototype._typeid = 'Reference';\n"]}
|
|
@@ -29,7 +29,7 @@ class ReferenceMapProperty extends StringMapProperty {
|
|
|
29
29
|
* @category Maps
|
|
30
30
|
*/
|
|
31
31
|
constructor(in_params) {
|
|
32
|
-
super(
|
|
32
|
+
super(in_params);
|
|
33
33
|
}
|
|
34
34
|
;
|
|
35
35
|
/**
|
|
@@ -194,4 +194,5 @@ class ReferenceMapProperty extends StringMapProperty {
|
|
|
194
194
|
;
|
|
195
195
|
}
|
|
196
196
|
exports.ReferenceMapProperty = ReferenceMapProperty;
|
|
197
|
+
ReferenceMapProperty.prototype._typeid = 'Reference';
|
|
197
198
|
//# sourceMappingURL=referenceMapProperty.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"referenceMapProperty.js","sourceRoot":"","sources":["../../src/properties/referenceMapProperty.js"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH;;GAEG;AACH,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC5D,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACvF,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACnD,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC,SAAS,CAAC;AACzE,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAC7D,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAG7D;;GAEG;AACH,MAAa,oBAAqB,SAAQ,iBAAiB;IAEvD;;;;;;;;OAQG;IACH,YAAY,S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CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC;IAC5C,CAAC;IAAA,CAAC;IAEF;;;;OAIG;IACH,QAAQ,CAAC,MAAM;QACX,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACH,mBAAmB,CAAC,UAAU,EAAE,cAAc;QAE1C,0CAA0C;QAC1C,IAAI,cAAc,KAAK,UAAU,CAAC,WAAW,CAAC,WAAW,EAAE;YACvD,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,uBAAuB,EAAE,YAAY,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC,CAAC;SACrG;aAAM;YACH,wEAAwE;YACxE,OAAO,gCAAgC,CAAC,SAAS,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;SAChH;IACL,CAAC;IAAA,CAAC;CAEL;AAjLD,oDAiLC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Definition of the reference map property class\n */\nconst _ = require('lodash');\nconst { StringMapProperty } = require('./valueMapProperty');\nconst { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset');\nconst { BaseProperty } = require('./baseProperty');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\nconst { ContainerProperty } = require('./containerProperty');\nconst { ReferenceProperty } = require('./referenceProperty');\n\n\n/**\n * A StringMapProperty which stores reference values\n */\nexport class ReferenceMapProperty extends StringMapProperty {\n\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.StringMapProperty\n * @alias property-properties.ReferenceMapProperty\n * @category Maps\n */\n constructor(in_params) {\n super({ typeid: 'Reference', ...in_params });\n };\n\n /**\n * Returns the typeid for the target of this reference\n *\n * Note: This is the type that is specified in the typeid of this reference and not the actual type\n * of the referenced object, which might inherit from that typeid.\n *\n * @return {string} The typeid of the nodes this reference may point to\n */\n getReferenceTargetTypeId() {\n return TypeIdHelper.extractReferenceTargetTypeIdFromReference(this.getTypeid());\n };\n\n /**\n * Resolves the referenced property for the given key\n *\n * @param {string|array<string|number>} in_ids the ID of the property or an array of IDs\n * if an array is passed, the .get function will be performed on each id in sequence\n * for example .get(['position','x']) is equivalent to .get('position').get('x').\n * If .get resolves to a ReferenceProperty, it will return the property that the ReferenceProperty\n * refers to.\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n *\n * @return {property-properties.BaseProperty|undefined} The property object the reference points to or undefined if it\n * could not be resolved\n */\n get(in_ids, in_options) {\n in_options = in_options || {};\n in_options.referenceResolutionMode =\n in_options.referenceResolutionMode === undefined ? BaseProperty.REFERENCE_RESOLUTION.ALWAYS :\n in_options.referenceResolutionMode;\n\n if (_.isArray(in_ids)) {\n // Forward handling of arrays to the BaseProperty function\n return AbstractStaticCollectionProperty.prototype.get.call(this, in_ids, in_options);\n } else {\n\n var value = this._dynamicChildren[in_ids];\n if (value === undefined ||\n value === '') {\n return undefined;\n }\n return this.getParent().resolvePath(value, in_options);\n }\n };\n\n /**\n * Removes the entry with the given key from the map\n *\n * @param {string} in_key - The key of the entry to remove from the map\n * @throws if trying to remove an entry that does not exist\n * @return {String} the item removed (a string path)\n */\n remove(in_key) {\n var item = this.getValue(in_key);\n this._removeByKey(in_key, true);\n return item;\n };\n\n /**\n * Returns an object with all the nested path values\n * @return {object} an object representing the values of your property\n * for example: {\n 'firstPath': '/path',\n 'secondPath': '/path2'\n }\n */\n getValues() {\n var ids = this.getIds();\n var result = {};\n for (var i = 0; i < ids.length; i++) {\n result[ids[i]] = this.getValue(ids[i]);\n }\n return result;\n };\n\n /**\n * Sets or inserts the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {string} in_key - The key under which the entry is stored\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if in_key is not a string\n * @throws if in_value is defined, but is not a property or a string.\n * @throws if map is read only\n */\n set(in_key, in_value) {\n if (!_.isString(in_key)) {\n throw new Error(MSG.KEY_NOT_STRING + in_key);\n }\n var value = ReferenceProperty._convertInputToPath(in_value);\n StringMapProperty.prototype.set.call(this, in_key, value);\n };\n\n /**\n * Sets or inserts the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {string} in_key - The key under which the entry is stored\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if in_key is not a string\n * @throws if in_value is defined, but is not a property or a string.\n * @deprecated\n */\n setValue(...args) {\n return this.set(...args);\n }\n\n /**\n * Inserts the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {string} in_key - The key under which the entry is stored\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if there is already an entry under in_key\n * @throws if in_value is defined, but is not a property or a string.\n */\n insert(in_key, in_value) {\n var value = ReferenceProperty._convertInputToPath(in_value);\n this._insert(in_key, value, true);\n };\n\n /**\n * Checks whether the reference is valid. This is either the case when it is empty or when the referenced\n * property exists.\n *\n * @param {string} in_key - key of the entry to check\n * @return {boolean} True if the reference is valid, otherwise false.\n */\n isReferenceValid(in_key) {\n return this.has(in_key) &&\n (this.getValue(in_key) === '' ||\n this.get(in_key) !== undefined);\n };\n\n /**\n * Returns the string value stored in the map\n * @param {string} in_key the key of the reference\n * @return {string} the path string\n */\n getValue(in_key) {\n return this._getValue(in_key);\n };\n\n /**\n * @inheritdoc\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n\n // Array tokens are automatically resolved\n if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN) {\n return this.get(in_segment, { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER });\n } else {\n // Everything else is handled by the implementation in the base property\n return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType);\n }\n };\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"referenceMapProperty.js","sourceRoot":"","sources":["../../src/properties/referenceMapProperty.js"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH;;GAEG;AACH,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC5D,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACvF,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACnD,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC,SAAS,CAAC;AACzE,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAC7D,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAG7D;;GAEG;AACH,MAAa,oBAAqB,SAAQ,iBAAiB;IAEvD;;;;;;;;OAQG;IACH,YAAY,SAAS;QACjB,KAAK,CAAC,SAAS,CAAC,CAAC;IACrB,CAAC;IAAA,CAAC;IAEF;;;;;;;OAOG;IACH,wBAAwB;QACpB,OAAO,YAAY,CAAC,yCAAyC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IACpF,CAAC;IAAA,CAAC;IAEF;;;;;;;;;;;;;;OAcG;IACH,GAAG,CAAC,MAAM,EAAE,UAAU;QAClB,UAAU,GAAG,UAAU,IAAI,EAAE,CAAC;QAC9B,UAAU,CAAC,uBAAuB;YAC9B,UAAU,CAAC,uBAAuB,KA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B,EAAE,YAAY,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC,CAAC;SACrG;aAAM;YACH,wEAAwE;YACxE,OAAO,gCAAgC,CAAC,SAAS,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;SAChH;IACL,CAAC;IAAA,CAAC;CAEL;AAjLD,oDAiLC;AAED,oBAAoB,CAAC,SAAS,CAAC,OAAO,GAAG,WAAW,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Definition of the reference map property class\n */\nconst _ = require('lodash');\nconst { StringMapProperty } = require('./valueMapProperty');\nconst { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset');\nconst { BaseProperty } = require('./baseProperty');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\nconst { ContainerProperty } = require('./containerProperty');\nconst { ReferenceProperty } = require('./referenceProperty');\n\n\n/**\n * A StringMapProperty which stores reference values\n */\nexport class ReferenceMapProperty extends StringMapProperty {\n\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.StringMapProperty\n * @alias property-properties.ReferenceMapProperty\n * @category Maps\n */\n constructor(in_params) {\n super(in_params);\n };\n\n /**\n * Returns the typeid for the target of this reference\n *\n * Note: This is the type that is specified in the typeid of this reference and not the actual type\n * of the referenced object, which might inherit from that typeid.\n *\n * @return {string} The typeid of the nodes this reference may point to\n */\n getReferenceTargetTypeId() {\n return TypeIdHelper.extractReferenceTargetTypeIdFromReference(this.getTypeid());\n };\n\n /**\n * Resolves the referenced property for the given key\n *\n * @param {string|array<string|number>} in_ids the ID of the property or an array of IDs\n * if an array is passed, the .get function will be performed on each id in sequence\n * for example .get(['position','x']) is equivalent to .get('position').get('x').\n * If .get resolves to a ReferenceProperty, it will return the property that the ReferenceProperty\n * refers to.\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n *\n * @return {property-properties.BaseProperty|undefined} The property object the reference points to or undefined if it\n * could not be resolved\n */\n get(in_ids, in_options) {\n in_options = in_options || {};\n in_options.referenceResolutionMode =\n in_options.referenceResolutionMode === undefined ? BaseProperty.REFERENCE_RESOLUTION.ALWAYS :\n in_options.referenceResolutionMode;\n\n if (_.isArray(in_ids)) {\n // Forward handling of arrays to the BaseProperty function\n return AbstractStaticCollectionProperty.prototype.get.call(this, in_ids, in_options);\n } else {\n\n var value = this._dynamicChildren[in_ids];\n if (value === undefined ||\n value === '') {\n return undefined;\n }\n return this.getParent().resolvePath(value, in_options);\n }\n };\n\n /**\n * Removes the entry with the given key from the map\n *\n * @param {string} in_key - The key of the entry to remove from the map\n * @throws if trying to remove an entry that does not exist\n * @return {String} the item removed (a string path)\n */\n remove(in_key) {\n var item = this.getValue(in_key);\n this._removeByKey(in_key, true);\n return item;\n };\n\n /**\n * Returns an object with all the nested path values\n * @return {object} an object representing the values of your property\n * for example: {\n 'firstPath': '/path',\n 'secondPath': '/path2'\n }\n */\n getValues() {\n var ids = this.getIds();\n var result = {};\n for (var i = 0; i < ids.length; i++) {\n result[ids[i]] = this.getValue(ids[i]);\n }\n return result;\n };\n\n /**\n * Sets or inserts the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {string} in_key - The key under which the entry is stored\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if in_key is not a string\n * @throws if in_value is defined, but is not a property or a string.\n * @throws if map is read only\n */\n set(in_key, in_value) {\n if (!_.isString(in_key)) {\n throw new Error(MSG.KEY_NOT_STRING + in_key);\n }\n var value = ReferenceProperty._convertInputToPath(in_value);\n StringMapProperty.prototype.set.call(this, in_key, value);\n };\n\n /**\n * Sets or inserts the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {string} in_key - The key under which the entry is stored\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if in_key is not a string\n * @throws if in_value is defined, but is not a property or a string.\n * @deprecated\n */\n setValue(...args) {\n return this.set(...args);\n }\n\n /**\n * Inserts the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {string} in_key - The key under which the entry is stored\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if there is already an entry under in_key\n * @throws if in_value is defined, but is not a property or a string.\n */\n insert(in_key, in_value) {\n var value = ReferenceProperty._convertInputToPath(in_value);\n this._insert(in_key, value, true);\n };\n\n /**\n * Checks whether the reference is valid. This is either the case when it is empty or when the referenced\n * property exists.\n *\n * @param {string} in_key - key of the entry to check\n * @return {boolean} True if the reference is valid, otherwise false.\n */\n isReferenceValid(in_key) {\n return this.has(in_key) &&\n (this.getValue(in_key) === '' ||\n this.get(in_key) !== undefined);\n };\n\n /**\n * Returns the string value stored in the map\n * @param {string} in_key the key of the reference\n * @return {string} the path string\n */\n getValue(in_key) {\n return this._getValue(in_key);\n };\n\n /**\n * @inheritdoc\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n\n // Array tokens are automatically resolved\n if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN) {\n return this.get(in_segment, { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER });\n } else {\n // Everything else is handled by the implementation in the base property\n return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType);\n }\n };\n\n}\n\nReferenceMapProperty.prototype._typeid = 'Reference';\n"]}
|
|
@@ -25,7 +25,6 @@ export class ReferenceProperty extends ValueProperty {
|
|
|
25
25
|
* @category Properties
|
|
26
26
|
*/
|
|
27
27
|
protected constructor();
|
|
28
|
-
_castFunctor: (in_value: number) => number;
|
|
29
28
|
/**
|
|
30
29
|
* Returns the typeid for the target of this reference
|
|
31
30
|
*
|
|
@@ -54,6 +53,7 @@ export class ReferenceProperty extends ValueProperty {
|
|
|
54
53
|
set(...args: any[]): void;
|
|
55
54
|
set ref(arg: any);
|
|
56
55
|
get ref(): any;
|
|
56
|
+
_castFunctor: (in_value: number) => number;
|
|
57
57
|
}
|
|
58
58
|
import { ValueProperty } from "./valueProperty";
|
|
59
59
|
//# sourceMappingURL=referenceProperty.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"referenceProperty.d.ts","sourceRoot":"","sources":["../../src/properties/referenceProperty.js"],"names":[],"mappings":"AAiBA;;;;;GAKG;AACH;
|
|
1
|
+
{"version":3,"file":"referenceProperty.d.ts","sourceRoot":"","sources":["../../src/properties/referenceProperty.js"],"names":[],"mappings":"AAiBA;;;;;GAKG;AACH;IAoKI;;;;;;;;OAQG;IACH,2CAHY,MAAM,CAkBjB;IA3LD;;;;;;;;MAQE;IACF,wBAIC;IAUD;;;;;;;OAOG;IACH,4BAFY,MAAM,CAIjB;IAoED;;;;;OAKG;IACH,oBAFY,OAAO,CAIlB;IAkBD;;;;;;;;OAQG;IACH,0BAEC;IAqBD,kBAEC;IAND,eAEC;IAiCL,2CAAwC;CADvC"}
|
|
@@ -32,8 +32,7 @@ class ReferenceProperty extends ValueProperty {
|
|
|
32
32
|
* @category Properties
|
|
33
33
|
*/
|
|
34
34
|
constructor(in_params) {
|
|
35
|
-
super(
|
|
36
|
-
this._castFunctor = _castFunctors.String;
|
|
35
|
+
super(in_params);
|
|
37
36
|
// default for this property type is an empty string
|
|
38
37
|
this._data = '';
|
|
39
38
|
}
|
|
@@ -209,4 +208,6 @@ class ReferenceProperty extends ValueProperty {
|
|
|
209
208
|
}
|
|
210
209
|
}
|
|
211
210
|
exports.ReferenceProperty = ReferenceProperty;
|
|
211
|
+
ReferenceProperty.prototype._castFunctor = _castFunctors.String;
|
|
212
|
+
ReferenceProperty.prototype._typeid = "Reference";
|
|
212
213
|
//# sourceMappingURL=referenceProperty.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"referenceProperty.js","sourceRoot":"","sources":["../../src/properties/referenceProperty.js"],"names":[],"mappings":";AAAA;;;GAGG;AACH;;GAEG;;;AAEH,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACrD,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACvF,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACnD,MAAM,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAC3F,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAC1D,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC,SAAS,CAAC;AAGzE;;;;;GAKG;AACH,MAAa,iBAAkB,SAAQ,aAAa;IAChD;;;;;;;;MAQE;IACF,YAAY,SAAS;QACjB,KAAK,iBAAG,MAAM,EAAE,WAAW,IAAK,SAAS,EAAG,CAAC;QAKjD,iBAAY,GAAG,aAAa,CAAC,MAAM,CAAC;QAJhC,oDAAoD;QACpD,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IACpB,CAAC;IAAA,CAAC;IAIF;;;OAGG;IACH,eAAe;QACX,OAAO,IAAI,CAAC;IAChB,CAAC;IAAA,CAAC;IAEF;;;;;;;OAOG;IACH,wBAAwB;QACpB,OAAO,YAAY,CAAC,yCAAyC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IACpF,CAAC;IAAA,CAAC;IAEF;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAC,MAAM,EAAE,UAAU;QA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AC7B,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,mBAAmB,CAAC,QAAQ;QAC/B,IAAI,IAAI,CAAC;QACT,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAC9B,IAAI,GAAG,QAAQ,CAAC;SACnB;aAAM,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC/B,IAAI,GAAG,EAAE,CAAC;SACb;aAAM,IAAI,QAAQ,YAAY,YAAY,EAAE;YACzC,oGAAoG;YACpG,IAAI,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAC;SACrC;aAAM,IAAI,QAAQ,YAAY,MAAM,EAAE;YACnC,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;SAC3B;aAAM;YACH,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,qBAAqB,GAAG,GAAG,GAAG,OAAO,QAAQ,GAAG,IAAI,GAAG,QAAQ,CAAC,CAAC;SACxF;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CAEJ;AAhMD,8CAgMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Definition of the ReferenceProperty class\n */\n\nconst _ = require('lodash');\nconst { ValueProperty } = require('./valueProperty');\nconst { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset');\nconst { BaseProperty } = require('./baseProperty');\nconst { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty');\nconst { _castFunctors } = require('./primitiveTypeCasts');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\n\n\n/**\n * This class serves as a view to read, write and listen to changes in an\n * object's value field. To do this we simply keep a pointer to the object and\n * it's associated data field that we are interested in. If no data field is\n * present this property will have an undefined value.\n */\nexport class ReferenceProperty extends ValueProperty {\n /**\n * @param {Object=} in_params - the parameters\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueProperty\n * @alias property-properties.ReferenceProperty\n * @category Properties\n */\n constructor(in_params) {\n super({ typeid: 'Reference', ...in_params });\n // default for this property type is an empty string\n this._data = '';\n };\n\n _castFunctor = _castFunctors.String;\n\n /**\n * Evaluates Reference properties as primitives.\n * @return {boolean} true since Reference properties are primitives.\n */\n isPrimitiveType() {\n return true;\n };\n\n /**\n * Returns the typeid for the target of this reference\n *\n * Note: This is the type that is specified in the typeid of this reference and not the actual type\n * of the referenced object, which might inherit from that typeid.\n *\n * @return {string} The typeid of the nodes this reference may point to\n */\n getReferenceTargetTypeId() {\n return TypeIdHelper.extractReferenceTargetTypeIdFromReference(this.getTypeid());\n };\n\n /**\n * Resolves the referenced property\n *\n * @param {string|number|array<string|number>} in_ids the ID of the property or an array of IDs\n * if an array is passed, the .get function will be performed on each id in sequence\n * for example .get(['position','x']) is equivalent to .get('position').get('x').\n * If .get resolves to a ReferenceProperty, it will return the property that the ReferenceProperty\n * refers to.\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n * @return {property-properties.BaseProperty|undefined} The property object the reference points to or undefined if it\n * could not be resolved\n */\n get(in_ids, in_options) {\n in_options = in_options || {};\n in_options.referenceResolutionMode =\n in_options.referenceResolutionMode === undefined ? BaseProperty.REFERENCE_RESOLUTION.ALWAYS :\n in_options.referenceResolutionMode;\n\n if (_.isArray(in_ids) && in_ids.length === 0) {\n return this;\n }\n\n // Since this is a reference property, we return undefined, if reference resolution is disabled\n if (in_options.referenceResolutionMode !== BaseProperty.REFERENCE_RESOLUTION.ALWAYS) {\n return undefined;\n }\n\n if (this.value === '') {\n return undefined;\n }\n\n if (this.getParent() === undefined) {\n return undefined;\n }\n var resolvedProperty = this.getParent().resolvePath(this.value,\n { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.ALWAYS });\n\n if (resolvedProperty !== undefined && _.isArray(in_ids)) {\n // Forward handling of arrays to the BaseProperty function\n return resolvedProperty.get(in_ids, in_options);\n } else {\n return resolvedProperty;\n }\n };\n\n /**\n * Expand a path returning the value or property at the end.\n *\n * @param {string} in_path the path\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n * @return {property-properties.BaseProperty|undefined} resolved path\n * @throws if the path resolves to a primitive value\n * @throws if in_path is not a valid path\n */\n resolvePath(in_path, in_options) {\n if (in_options && in_options.referenceResolutionMode &&\n in_options.referenceResolutionMode === BaseProperty.REFERENCE_RESOLUTION.NEVER) {\n return undefined;\n }\n return AbstractStaticCollectionProperty.prototype.resolvePath.call(this, in_path, in_options);\n };\n\n /**\n * Checks whether the reference is valid. This is either the case when it is empty or when the referenced\n * property exists.\n *\n * @return {boolean} True if the reference is valid, otherwise false.\n */\n isReferenceValid() {\n return this.value === '' || this.ref !== undefined;\n };\n\n /**\n * Sets the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if property is read only\n * @throws if in_value is defined, but is not a property or a string.\n */\n setValue(in_value) {\n this._checkIsNotReadOnly(true);\n var value = ReferenceProperty._convertInputToPath(in_value);\n // Forward the call to setValue\n ValueProperty.prototype.setValue.call(this, value);\n };\n\n /**\n * Sets the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if property is read only\n * @throws if in_value is defined but is not a property or a string.\n */\n set(...args) {\n return this.setValue(...args);\n }\n\n /**\n * @inheritdoc\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n\n // path segments and array tokens are no longer automatically forwarded to the referenced node\n if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN ||\n in_segmentType === PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN) {\n return undefined;\n } else {\n return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType);\n }\n };\n\n // Define a property to simplify accessing the referenced path\n get ref() {\n return this.get.apply(this, arguments);\n }\n\n set ref(val) {\n this.set.call(this, val);\n }\n\n /**\n * Validates the input and does as much as possible to return a string representing a path.\n *\n * @param {property-properties.BaseProperty|undefined|String} in_value - contains the property to be set or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @return {string} the path\n * @throws if in_value is defined, but is not a property or a string.\n */\n static _convertInputToPath(in_value) {\n var path;\n if (typeof in_value === 'string') {\n path = in_value;\n } else if (in_value === undefined) {\n path = '';\n } else if (in_value instanceof BaseProperty) {\n // TODO: Check whether this is still the correct path once we start to support repository references\n path = in_value.getAbsolutePath();\n } else if (in_value instanceof String) {\n path = String(in_value);\n } else {\n throw new Error(MSG.PROPERTY_OR_UNDEFINED + '(' + typeof in_value + ') ' + in_value);\n }\n return path;\n }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"referenceProperty.js","sourceRoot":"","sources":["../../src/properties/referenceProperty.js"],"names":[],"mappings":";AAAA;;;GAGG;AACH;;GAEG;;;AAEH,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACrD,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACvF,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACnD,MAAM,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAC3F,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAC1D,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC,SAAS,CAAC;A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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Definition of the ReferenceProperty class\n */\n\nconst _ = require('lodash');\nconst { ValueProperty } = require('./valueProperty');\nconst { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset');\nconst { BaseProperty } = require('./baseProperty');\nconst { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty');\nconst { _castFunctors } = require('./primitiveTypeCasts');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\n\n\n/**\n * This class serves as a view to read, write and listen to changes in an\n * object's value field. To do this we simply keep a pointer to the object and\n * it's associated data field that we are interested in. If no data field is\n * present this property will have an undefined value.\n */\nexport class ReferenceProperty extends ValueProperty {\n /**\n * @param {Object=} in_params - the parameters\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueProperty\n * @alias property-properties.ReferenceProperty\n * @category Properties\n */\n constructor(in_params) {\n super(in_params);\n // default for this property type is an empty string\n this._data = '';\n };\n\n /**\n * Evaluates Reference properties as primitives.\n * @return {boolean} true since Reference properties are primitives.\n */\n isPrimitiveType() {\n return true;\n };\n\n /**\n * Returns the typeid for the target of this reference\n *\n * Note: This is the type that is specified in the typeid of this reference and not the actual type\n * of the referenced object, which might inherit from that typeid.\n *\n * @return {string} The typeid of the nodes this reference may point to\n */\n getReferenceTargetTypeId() {\n return TypeIdHelper.extractReferenceTargetTypeIdFromReference(this.getTypeid());\n };\n\n /**\n * Resolves the referenced property\n *\n * @param {string|number|array<string|number>} in_ids the ID of the property or an array of IDs\n * if an array is passed, the .get function will be performed on each id in sequence\n * for example .get(['position','x']) is equivalent to .get('position').get('x').\n * If .get resolves to a ReferenceProperty, it will return the property that the ReferenceProperty\n * refers to.\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n * @return {property-properties.BaseProperty|undefined} The property object the reference points to or undefined if it\n * could not be resolved\n */\n get(in_ids, in_options) {\n in_options = in_options || {};\n in_options.referenceResolutionMode =\n in_options.referenceResolutionMode === undefined ? BaseProperty.REFERENCE_RESOLUTION.ALWAYS :\n in_options.referenceResolutionMode;\n\n if (_.isArray(in_ids) && in_ids.length === 0) {\n return this;\n }\n\n // Since this is a reference property, we return undefined, if reference resolution is disabled\n if (in_options.referenceResolutionMode !== BaseProperty.REFERENCE_RESOLUTION.ALWAYS) {\n return undefined;\n }\n\n if (this.value === '') {\n return undefined;\n }\n\n if (this.getParent() === undefined) {\n return undefined;\n }\n var resolvedProperty = this.getParent().resolvePath(this.value,\n { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.ALWAYS });\n\n if (resolvedProperty !== undefined && _.isArray(in_ids)) {\n // Forward handling of arrays to the BaseProperty function\n return resolvedProperty.get(in_ids, in_options);\n } else {\n return resolvedProperty;\n }\n };\n\n /**\n * Expand a path returning the value or property at the end.\n *\n * @param {string} in_path the path\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n * @return {property-properties.BaseProperty|undefined} resolved path\n * @throws if the path resolves to a primitive value\n * @throws if in_path is not a valid path\n */\n resolvePath(in_path, in_options) {\n if (in_options && in_options.referenceResolutionMode &&\n in_options.referenceResolutionMode === BaseProperty.REFERENCE_RESOLUTION.NEVER) {\n return undefined;\n }\n return AbstractStaticCollectionProperty.prototype.resolvePath.call(this, in_path, in_options);\n };\n\n /**\n * Checks whether the reference is valid. This is either the case when it is empty or when the referenced\n * property exists.\n *\n * @return {boolean} True if the reference is valid, otherwise false.\n */\n isReferenceValid() {\n return this.value === '' || this.ref !== undefined;\n };\n\n /**\n * Sets the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if property is read only\n * @throws if in_value is defined, but is not a property or a string.\n */\n setValue(in_value) {\n this._checkIsNotReadOnly(true);\n var value = ReferenceProperty._convertInputToPath(in_value);\n // Forward the call to setValue\n ValueProperty.prototype.setValue.call(this, value);\n };\n\n /**\n * Sets the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if property is read only\n * @throws if in_value is defined but is not a property or a string.\n */\n set(...args) {\n return this.setValue(...args);\n }\n\n /**\n * @inheritdoc\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n\n // path segments and array tokens are no longer automatically forwarded to the referenced node\n if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN ||\n in_segmentType === PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN) {\n return undefined;\n } else {\n return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType);\n }\n };\n\n // Define a property to simplify accessing the referenced path\n get ref() {\n return this.get.apply(this, arguments);\n }\n\n set ref(val) {\n this.set.call(this, val);\n }\n\n /**\n * Validates the input and does as much as possible to return a string representing a path.\n *\n * @param {property-properties.BaseProperty|undefined|String} in_value - contains the property to be set or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @return {string} the path\n * @throws if in_value is defined, but is not a property or a string.\n */\n static _convertInputToPath(in_value) {\n var path;\n if (typeof in_value === 'string') {\n path = in_value;\n } else if (in_value === undefined) {\n path = '';\n } else if (in_value instanceof BaseProperty) {\n // TODO: Check whether this is still the correct path once we start to support repository references\n path = in_value.getAbsolutePath();\n } else if (in_value instanceof String) {\n path = String(in_value);\n } else {\n throw new Error(MSG.PROPERTY_OR_UNDEFINED + '(' + typeof in_value + ') ' + in_value);\n }\n return path;\n }\n\n}\nReferenceProperty.prototype._castFunctor = _castFunctors.String;\nReferenceProperty.prototype._typeid = \"Reference\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setProperty.d.ts","sourceRoot":"","sources":["../../src/properties/setProperty.js"],"names":[],"mappings":"AAiBA;;;GAGG;AACH;IAEI;;;;;;;;;OASG;IACH,wBAOC;IAJG,eAAsB;IAEtB,oEAAoE;IACpE,qBAA0B;
|
|
1
|
+
{"version":3,"file":"setProperty.d.ts","sourceRoot":"","sources":["../../src/properties/setProperty.js"],"names":[],"mappings":"AAiBA;;;GAGG;AACH;IAEI;;;;;;;;;OASG;IACH,wBAOC;IAJG,eAAsB;IAEtB,oEAAoE;IACpE,qBAA0B;IAmF9B;;;;;;;OAOG;IACH,+BAOC;IAED;;;;;;OAMG;IACH,iBAFW,eAAsC,QAehD;IAED;;;;;;OAMG;IACH,2BASC;IAwED;;;;;;;OAOG;IACH,2BAkBC;IAsCD;;;;;;;OAOG;IACH,cAHY,UAAe,CAK1B;IAmBD;;OAEG;IACH,cAKC;CAEJ"}
|