| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 102× 124× 124× 87× 37× 15× 1× 166× 166× 103× 103× 177× 177× 103× 61× 3× 61× 1× 60× 105× 105× 2× 103× 103× 103× 20× 83× 83× 81× 1× 1× 28× 1× 28× 9× 9× 9× 19× 19× 19× 19× 19× 19× 19× 19× 105× 61× 1× 1× | "use strict"; /* istanbul ignore next */ var __assign = (this && this.__assign) || Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; var core_1 = require("./core"); var array_1 = require("./array"); var nextSuffix = 1; function getPropertyDescriptor(obj, propertyName) { while (obj) { var desc = Object.getOwnPropertyDescriptor(obj, propertyName); if (desc) { return desc; } obj = Object.getPrototypeOf(obj); } return undefined; } function getJsonComputed(that, _a) { var computedKey = _a.computedKey, propertiesKey = _a.propertiesKey, superGet = _a.superGet, superSet = _a.superSet; return core_1.getOrCreateComputed(that, computedKey, function () { return ({ get: function () { // Note we "clone" the superclass's data if any, not merging into its data! var data = superGet ? __assign({}, superGet.call(that)) : {}; for (var _i = 0, _a = that[propertiesKey]; _i < _a.length; _i++) { var propertyName = _a[_i]; data[propertyName] = core_1.save(that[propertyName]); } return data; }, set: function (data) { if (superSet) { superSet.call(that, data); } if (!data || typeof data !== "object") { return; } for (var _i = 0, _a = that[propertiesKey]; _i < _a.length; _i++) { var propertyName = _a[_i]; if (!(propertyName in data)) { continue; } var source = data[propertyName]; var target = that[propertyName]; if (source !== null && source !== undefined && core_1.canLoadInto(target)) { core_1.load(target, source); } else { var prop = getPropertyDescriptor(that, propertyName); if (!prop || prop.set || !prop.get) { that[propertyName] = source; } } } } }); }); } var classSuffixKey = "<classId>"; function makePropertiesKey(suffix) { return "<properties:" + suffix + ">"; } function jsonImpl(prototype, propertyName) { if (Object.prototype.hasOwnProperty.call(prototype, classSuffixKey)) { var suffix_1 = prototype[classSuffixKey]; prototype[makePropertiesKey(suffix_1)].push(propertyName); return; } var suffix = nextSuffix++; prototype[classSuffixKey] = suffix; var propertiesKey = makePropertiesKey(suffix); prototype[propertiesKey] = [propertyName]; Eif (!Object.prototype.hasOwnProperty.call(prototype, "json")) { var superJsonProp = getPropertyDescriptor(prototype, "json"); var options_1 = { propertiesKey: propertiesKey, computedKey: "<json:" + suffix + ">", superGet: superJsonProp && superJsonProp.get, superSet: superJsonProp && superJsonProp.set }; Object.defineProperty(prototype, "json", { get: function () { return getJsonComputed(this, options_1).get(); }, set: function (data) { getJsonComputed(this, options_1).set(data); } }); } } exports.json = Object.assign(jsonImpl, { load: core_1.load, save: core_1.save, array: array_1.array, arrayOf: array_1.arrayOf, idOf: array_1.getArrayItemId }); 0; // Disposable is unused but must be imported //# sourceMappingURL=json.js.map |