diff --git a/packages/westore/.eslintrc.json b/packages/westore/.eslintrc.json new file mode 100644 index 0000000..26325c0 --- /dev/null +++ b/packages/westore/.eslintrc.json @@ -0,0 +1,14 @@ +{ + "env": { + "browser": true, + "es2021": true + }, + "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 12, + "sourceType": "module" + }, + "plugins": ["@typescript-eslint"], + "rules": {} +} diff --git a/packages/westore/.gitignore b/packages/westore/.gitignore index a56a7ef..ee89780 100644 --- a/packages/westore/.gitignore +++ b/packages/westore/.gitignore @@ -1,2 +1,2 @@ node_modules - +pnpm-lock.yaml diff --git a/packages/westore/.prettierrc b/packages/westore/.prettierrc new file mode 100644 index 0000000..6a1775b --- /dev/null +++ b/packages/westore/.prettierrc @@ -0,0 +1,9 @@ +{ + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "singleQuote": true, + "semi": false, + "trailingComma": "none", + "bracketSpacing": true +} diff --git a/packages/westore/LICENSE b/packages/westore/LICENSE new file mode 100644 index 0000000..60f7f15 --- /dev/null +++ b/packages/westore/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright © 2010-2018 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/westore/dist/index.cmd.js b/packages/westore/dist/index.cmd.js new file mode 100644 index 0000000..b07d70f --- /dev/null +++ b/packages/westore/dist/index.cmd.js @@ -0,0 +1,365 @@ +'use strict'; + +var rfdc_1 = rfdc; + +function copyBuffer (cur) { + if (cur instanceof Buffer) { + return Buffer.from(cur) + } + + return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length) +} + +function rfdc (opts) { + opts = opts || {}; + + if (opts.circles) return rfdcCircles(opts) + return opts.proto ? cloneProto : clone + + function cloneArray (a, fn) { + var keys = Object.keys(a); + var a2 = new Array(keys.length); + for (var i = 0; i < keys.length; i++) { + var k = keys[i]; + var cur = a[k]; + if (typeof cur !== 'object' || cur === null) { + a2[k] = cur; + } else if (cur instanceof Date) { + a2[k] = new Date(cur); + } else if (ArrayBuffer.isView(cur)) { + a2[k] = copyBuffer(cur); + } else { + a2[k] = fn(cur); + } + } + return a2 + } + + function clone (o) { + if (typeof o !== 'object' || o === null) return o + if (o instanceof Date) return new Date(o) + if (Array.isArray(o)) return cloneArray(o, clone) + if (o instanceof Map) return new Map(cloneArray(Array.from(o), clone)) + if (o instanceof Set) return new Set(cloneArray(Array.from(o), clone)) + var o2 = {}; + for (var k in o) { + if (Object.hasOwnProperty.call(o, k) === false) continue + var cur = o[k]; + if (typeof cur !== 'object' || cur === null) { + o2[k] = cur; + } else if (cur instanceof Date) { + o2[k] = new Date(cur); + } else if (cur instanceof Map) { + o2[k] = new Map(cloneArray(Array.from(cur), clone)); + } else if (cur instanceof Set) { + o2[k] = new Set(cloneArray(Array.from(cur), clone)); + } else if (ArrayBuffer.isView(cur)) { + o2[k] = copyBuffer(cur); + } else { + o2[k] = clone(cur); + } + } + return o2 + } + + function cloneProto (o) { + if (typeof o !== 'object' || o === null) return o + if (o instanceof Date) return new Date(o) + if (Array.isArray(o)) return cloneArray(o, cloneProto) + if (o instanceof Map) return new Map(cloneArray(Array.from(o), cloneProto)) + if (o instanceof Set) return new Set(cloneArray(Array.from(o), cloneProto)) + var o2 = {}; + for (var k in o) { + var cur = o[k]; + if (typeof cur !== 'object' || cur === null) { + o2[k] = cur; + } else if (cur instanceof Date) { + o2[k] = new Date(cur); + } else if (cur instanceof Map) { + o2[k] = new Map(cloneArray(Array.from(cur), cloneProto)); + } else if (cur instanceof Set) { + o2[k] = new Set(cloneArray(Array.from(cur), cloneProto)); + } else if (ArrayBuffer.isView(cur)) { + o2[k] = copyBuffer(cur); + } else { + o2[k] = cloneProto(cur); + } + } + return o2 + } +} + +function rfdcCircles (opts) { + var refs = []; + var refsNew = []; + + return opts.proto ? cloneProto : clone + + function cloneArray (a, fn) { + var keys = Object.keys(a); + var a2 = new Array(keys.length); + for (var i = 0; i < keys.length; i++) { + var k = keys[i]; + var cur = a[k]; + if (typeof cur !== 'object' || cur === null) { + a2[k] = cur; + } else if (cur instanceof Date) { + a2[k] = new Date(cur); + } else if (ArrayBuffer.isView(cur)) { + a2[k] = copyBuffer(cur); + } else { + var index = refs.indexOf(cur); + if (index !== -1) { + a2[k] = refsNew[index]; + } else { + a2[k] = fn(cur); + } + } + } + return a2 + } + + function clone (o) { + if (typeof o !== 'object' || o === null) return o + if (o instanceof Date) return new Date(o) + if (Array.isArray(o)) return cloneArray(o, clone) + if (o instanceof Map) return new Map(cloneArray(Array.from(o), clone)) + if (o instanceof Set) return new Set(cloneArray(Array.from(o), clone)) + var o2 = {}; + refs.push(o); + refsNew.push(o2); + for (var k in o) { + if (Object.hasOwnProperty.call(o, k) === false) continue + var cur = o[k]; + if (typeof cur !== 'object' || cur === null) { + o2[k] = cur; + } else if (cur instanceof Date) { + o2[k] = new Date(cur); + } else if (cur instanceof Map) { + o2[k] = new Map(cloneArray(Array.from(cur), clone)); + } else if (cur instanceof Set) { + o2[k] = new Set(cloneArray(Array.from(cur), clone)); + } else if (ArrayBuffer.isView(cur)) { + o2[k] = copyBuffer(cur); + } else { + var i = refs.indexOf(cur); + if (i !== -1) { + o2[k] = refsNew[i]; + } else { + o2[k] = clone(cur); + } + } + } + refs.pop(); + refsNew.pop(); + return o2 + } + + function cloneProto (o) { + if (typeof o !== 'object' || o === null) return o + if (o instanceof Date) return new Date(o) + if (Array.isArray(o)) return cloneArray(o, cloneProto) + if (o instanceof Map) return new Map(cloneArray(Array.from(o), cloneProto)) + if (o instanceof Set) return new Set(cloneArray(Array.from(o), cloneProto)) + var o2 = {}; + refs.push(o); + refsNew.push(o2); + for (var k in o) { + var cur = o[k]; + if (typeof cur !== 'object' || cur === null) { + o2[k] = cur; + } else if (cur instanceof Date) { + o2[k] = new Date(cur); + } else if (cur instanceof Map) { + o2[k] = new Map(cloneArray(Array.from(cur), cloneProto)); + } else if (cur instanceof Set) { + o2[k] = new Set(cloneArray(Array.from(cur), cloneProto)); + } else if (ArrayBuffer.isView(cur)) { + o2[k] = copyBuffer(cur); + } else { + var i = refs.indexOf(cur); + if (i !== -1) { + o2[k] = refsNew[i]; + } else { + o2[k] = cloneProto(cur); + } + } + } + refs.pop(); + refsNew.pop(); + return o2 + } +} + +const clone = rfdc_1(); +var DataTypes; +(function (DataTypes) { + DataTypes["ARRAYTYPE"] = "[object Array]"; + DataTypes["OBJECTTYPE"] = "[object Object]"; + DataTypes["FUNCTIONTYPE"] = "[object Function]"; +})(DataTypes || (DataTypes = {})); +const ARRAYTYPE = DataTypes.ARRAYTYPE; +const OBJECTTYPE = DataTypes.OBJECTTYPE; +const FUNCTIONTYPE = DataTypes.FUNCTIONTYPE; +function diffData(current, previous) { + const result = {}; + if (!previous) + return current; + syncKeys(current, previous); + _diff(current, previous, '', result); + return result; +} +function syncKeys(current, previous) { + if (current === previous) + return; + const rootCurrentType = getType(current); + const rootPreType = getType(previous); + if (rootCurrentType == OBJECTTYPE && rootPreType == OBJECTTYPE) { + for (let key in previous) { + const currentValue = current[key]; + if (currentValue === undefined) { + current[key] = null; + } + else { + syncKeys(currentValue, previous[key]); + } + } + } + else if (rootCurrentType == ARRAYTYPE && rootPreType == ARRAYTYPE) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + if (current.length >= previous.length) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + previous.forEach((item, index) => { + syncKeys(current[index], item); + }); + } + } +} +function setResult(result, k, v) { + if (getType(v) != FUNCTIONTYPE) { + result[k] = v; + } +} +function _diff(current, previous, path, result) { + if (current === previous) + return; + const rootCurrentType = getType(current); + const rootPreType = getType(previous); + if (rootCurrentType == OBJECTTYPE) { + if (rootPreType != OBJECTTYPE || + (Object.keys(current).length < Object.keys(previous).length && + path !== '')) { + setResult(result, path, current); + } + else { + for (const key in current) { + const currentValue = current[key]; + const preValue = previous[key]; + const currentType = getType(currentValue); + const preType = getType(preValue); + if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) { + if (currentValue !== previous[key]) { + setResult(result, concatPathAndKey(path, key), currentValue); + } + } + else if (currentType == ARRAYTYPE) { + if (preType != ARRAYTYPE) { + setResult(result, concatPathAndKey(path, key), currentValue); + } + else { + if (currentValue.length < preValue.length) { + setResult(result, concatPathAndKey(path, key), currentValue); + } + else { + currentValue.forEach((item, index) => { + _diff(item, preValue[index], concatPathAndKey(path, key) + '[' + index + ']', result); + }); + } + } + } + else if (currentType == OBJECTTYPE) { + if (preType != OBJECTTYPE || + Object.keys(currentValue).length < Object.keys(preValue).length) { + setResult(result, concatPathAndKey(path, key), currentValue); + } + else { + for (let subKey in currentValue) { + const realPath = concatPathAndKey(path, key) + + (subKey.includes('.') ? `["${subKey}"]` : `.${subKey}`); + _diff(currentValue[subKey], preValue[subKey], realPath, result); + } + } + } + } + } + } + else if (rootCurrentType == ARRAYTYPE) { + if (rootPreType != ARRAYTYPE) { + setResult(result, path, current); + } + else { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + if (current.length < previous.length) { + setResult(result, path, current); + } + else { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + current.forEach((item, index) => { + _diff(item, previous[index], path + '[' + index + ']', result); + }); + } + } + } + else { + setResult(result, path, current); + } +} +function concatPathAndKey(path, key) { + return key.includes('.') + ? path + `["${key}"]` + : (path == '' ? '' : path + '.') + key; +} +function getType(obj) { + return Object.prototype.toString.call(obj); +} +function update(view, callback) { + const patch = diffData(view.data, view._westorePrevData); + view.setData(patch, callback); + view._westorePrevData = clone(view.data); +} +class Store { + constructor() { + this.views = {}; + this._westoreViewId = 0; + } + bind(keyOrView, view) { + if (arguments.length === 1) { + this.data = keyOrView.data; + this.views[this._westoreViewId++] = keyOrView; + } + else { + //设置回 view 的 data,不然引用地址 错误 + this.data = view.data; + this.views[keyOrView] = view; + } + } + update(viewKey) { + if (arguments.length === 1) { + update(this.views[viewKey]); + } + else { + for (const key in this.views) { + update(this.views[key]); + } + } + } +} + +var index = { diffData, update, Store }; + +module.exports = index; +//# sourceMappingURL=index.cmd.js.map diff --git a/packages/westore/dist/index.cmd.js.map b/packages/westore/dist/index.cmd.js.map new file mode 100644 index 0000000..830bedd --- /dev/null +++ b/packages/westore/dist/index.cmd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.cmd.js","sources":["../node_modules/.pnpm/rfdc@1.3.0/node_modules/rfdc/index.js","../src/westore.ts","../src/index.ts"],"sourcesContent":["'use strict'\nmodule.exports = rfdc\n\nfunction copyBuffer (cur) {\n if (cur instanceof Buffer) {\n return Buffer.from(cur)\n }\n\n return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length)\n}\n\nfunction rfdc (opts) {\n opts = opts || {}\n\n if (opts.circles) return rfdcCircles(opts)\n return opts.proto ? cloneProto : clone\n\n function cloneArray (a, fn) {\n var keys = Object.keys(a)\n var a2 = new Array(keys.length)\n for (var i = 0; i < keys.length; i++) {\n var k = keys[i]\n var cur = a[k]\n if (typeof cur !== 'object' || cur === null) {\n a2[k] = cur\n } else if (cur instanceof Date) {\n a2[k] = new Date(cur)\n } else if (ArrayBuffer.isView(cur)) {\n a2[k] = copyBuffer(cur)\n } else {\n a2[k] = fn(cur)\n }\n }\n return a2\n }\n\n function clone (o) {\n if (typeof o !== 'object' || o === null) return o\n if (o instanceof Date) return new Date(o)\n if (Array.isArray(o)) return cloneArray(o, clone)\n if (o instanceof Map) return new Map(cloneArray(Array.from(o), clone))\n if (o instanceof Set) return new Set(cloneArray(Array.from(o), clone))\n var o2 = {}\n for (var k in o) {\n if (Object.hasOwnProperty.call(o, k) === false) continue\n var cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof Date) {\n o2[k] = new Date(cur)\n } else if (cur instanceof Map) {\n o2[k] = new Map(cloneArray(Array.from(cur), clone))\n } else if (cur instanceof Set) {\n o2[k] = new Set(cloneArray(Array.from(cur), clone))\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n o2[k] = clone(cur)\n }\n }\n return o2\n }\n\n function cloneProto (o) {\n if (typeof o !== 'object' || o === null) return o\n if (o instanceof Date) return new Date(o)\n if (Array.isArray(o)) return cloneArray(o, cloneProto)\n if (o instanceof Map) return new Map(cloneArray(Array.from(o), cloneProto))\n if (o instanceof Set) return new Set(cloneArray(Array.from(o), cloneProto))\n var o2 = {}\n for (var k in o) {\n var cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof Date) {\n o2[k] = new Date(cur)\n } else if (cur instanceof Map) {\n o2[k] = new Map(cloneArray(Array.from(cur), cloneProto))\n } else if (cur instanceof Set) {\n o2[k] = new Set(cloneArray(Array.from(cur), cloneProto))\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n o2[k] = cloneProto(cur)\n }\n }\n return o2\n }\n}\n\nfunction rfdcCircles (opts) {\n var refs = []\n var refsNew = []\n\n return opts.proto ? cloneProto : clone\n\n function cloneArray (a, fn) {\n var keys = Object.keys(a)\n var a2 = new Array(keys.length)\n for (var i = 0; i < keys.length; i++) {\n var k = keys[i]\n var cur = a[k]\n if (typeof cur !== 'object' || cur === null) {\n a2[k] = cur\n } else if (cur instanceof Date) {\n a2[k] = new Date(cur)\n } else if (ArrayBuffer.isView(cur)) {\n a2[k] = copyBuffer(cur)\n } else {\n var index = refs.indexOf(cur)\n if (index !== -1) {\n a2[k] = refsNew[index]\n } else {\n a2[k] = fn(cur)\n }\n }\n }\n return a2\n }\n\n function clone (o) {\n if (typeof o !== 'object' || o === null) return o\n if (o instanceof Date) return new Date(o)\n if (Array.isArray(o)) return cloneArray(o, clone)\n if (o instanceof Map) return new Map(cloneArray(Array.from(o), clone))\n if (o instanceof Set) return new Set(cloneArray(Array.from(o), clone))\n var o2 = {}\n refs.push(o)\n refsNew.push(o2)\n for (var k in o) {\n if (Object.hasOwnProperty.call(o, k) === false) continue\n var cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof Date) {\n o2[k] = new Date(cur)\n } else if (cur instanceof Map) {\n o2[k] = new Map(cloneArray(Array.from(cur), clone))\n } else if (cur instanceof Set) {\n o2[k] = new Set(cloneArray(Array.from(cur), clone))\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n var i = refs.indexOf(cur)\n if (i !== -1) {\n o2[k] = refsNew[i]\n } else {\n o2[k] = clone(cur)\n }\n }\n }\n refs.pop()\n refsNew.pop()\n return o2\n }\n\n function cloneProto (o) {\n if (typeof o !== 'object' || o === null) return o\n if (o instanceof Date) return new Date(o)\n if (Array.isArray(o)) return cloneArray(o, cloneProto)\n if (o instanceof Map) return new Map(cloneArray(Array.from(o), cloneProto))\n if (o instanceof Set) return new Set(cloneArray(Array.from(o), cloneProto))\n var o2 = {}\n refs.push(o)\n refsNew.push(o2)\n for (var k in o) {\n var cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof Date) {\n o2[k] = new Date(cur)\n } else if (cur instanceof Map) {\n o2[k] = new Map(cloneArray(Array.from(cur), cloneProto))\n } else if (cur instanceof Set) {\n o2[k] = new Set(cloneArray(Array.from(cur), cloneProto))\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n var i = refs.indexOf(cur)\n if (i !== -1) {\n o2[k] = refsNew[i]\n } else {\n o2[k] = cloneProto(cur)\n }\n }\n }\n refs.pop()\n refsNew.pop()\n return o2\n }\n}\n",null,null],"names":["rfdc"],"mappings":";;IACA,MAAc,GAAG,KAAI;AACrB;AACA,SAAS,UAAU,EAAE,GAAG,EAAE;AAC1B,EAAE,IAAI,GAAG,YAAY,MAAM,EAAE;AAC7B,IAAI,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AAC3B,GAAG;AACH;AACA,EAAE,OAAO,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC;AAC5E,CAAC;AACD;AACA,SAAS,IAAI,EAAE,IAAI,EAAE;AACrB,EAAE,IAAI,GAAG,IAAI,IAAI,GAAE;AACnB;AACA,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE,OAAO,WAAW,CAAC,IAAI,CAAC;AAC5C,EAAE,OAAO,IAAI,CAAC,KAAK,GAAG,UAAU,GAAG,KAAK;AACxC;AACA,EAAE,SAAS,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE;AAC9B,IAAI,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,EAAC;AAC7B,IAAI,IAAI,EAAE,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,EAAC;AACnC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC1C,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,EAA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,CAAA;SAC9C;aAAM;;YAEL,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;YACrB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAA;SAC7B;KACF;IACD,MAAM,CAAC,OAAwB;QAC7B,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;YAC1B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;SAC5B;aAAM;YACL,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE;gBAC5B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;aACxB;SACF;KACF;;;AC5MH,YAAe,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE;;;;"} \ No newline at end of file diff --git a/packages/westore/dist/index.cmd.min.js b/packages/westore/dist/index.cmd.min.js new file mode 100644 index 0000000..1640d38 --- /dev/null +++ b/packages/westore/dist/index.cmd.min.js @@ -0,0 +1,2 @@ +"use strict";var e=function(e){return(e=e||{}).circles?function(e){var r=[],n=[];return e.proto?function e(a){if("object"!=typeof a||null===a)return a;if(a instanceof Date)return new Date(a);if(Array.isArray(a))return f(a,e);if(a instanceof Map)return new Map(f(Array.from(a),e));if(a instanceof Set)return new Set(f(Array.from(a),e));var i={};for(var o in r.push(a),n.push(i),a){var s=a[o];if("object"!=typeof s||null===s)i[o]=s;else if(s instanceof Date)i[o]=new Date(s);else if(s instanceof Map)i[o]=new Map(f(Array.from(s),e));else if(s instanceof Set)i[o]=new Set(f(Array.from(s),e));else if(ArrayBuffer.isView(s))i[o]=t(s);else{var c=r.indexOf(s);i[o]=-1!==c?n[c]:e(s)}}return r.pop(),n.pop(),i}:function e(a){if("object"!=typeof a||null===a)return a;if(a instanceof Date)return new Date(a);if(Array.isArray(a))return f(a,e);if(a instanceof Map)return new Map(f(Array.from(a),e));if(a instanceof Set)return new Set(f(Array.from(a),e));var i={};for(var o in r.push(a),n.push(i),a)if(!1!==Object.hasOwnProperty.call(a,o)){var s=a[o];if("object"!=typeof s||null===s)i[o]=s;else if(s instanceof Date)i[o]=new Date(s);else if(s instanceof Map)i[o]=new Map(f(Array.from(s),e));else if(s instanceof Set)i[o]=new Set(f(Array.from(s),e));else if(ArrayBuffer.isView(s))i[o]=t(s);else{var c=r.indexOf(s);i[o]=-1!==c?n[c]:e(s)}}return r.pop(),n.pop(),i};function f(e,f){for(var a=Object.keys(e),i=new Array(a.length),o=0;o=t.length&&t.forEach(((t,r)=>{s(e[r],t)}))}function c(e,t,r){y(r)!=i&&(e[t]=r)}function u(e,t,r,n){if(e===t)return;const i=y(e),o=y(t);if(i==a)if(o!=a||Object.keys(e).length{u(e,s[t],l(r,i)+"["+t+"]",n)}));else if(w==a)if(p!=a||Object.keys(o).length{u(e,t[f],r+"["+f+"]",n)})):c(n,r,e)}function l(e,t){return t.includes(".")?e+`["${t}"]`:(""==e?"":e+".")+t}function y(e){return Object.prototype.toString.call(e)}function w(e,t){const n=o(e.data,e._westorePrevData);e.setData(n,t),e._westorePrevData=r(e.data)}var p={diffData:o,update:w,Store:class{constructor(){this.views={},this._westoreViewId=0}bind(e,t){1===arguments.length?(this.data=e.data,this.views[this._westoreViewId++]=e):(this.data=t.data,this.views[e]=t)}update(e){if(1===arguments.length)w(this.views[e]);else for(const e in this.views)w(this.views[e])}}};module.exports=p; +//# sourceMappingURL=index.cmd.min.js.map diff --git a/packages/westore/dist/index.cmd.min.js.map b/packages/westore/dist/index.cmd.min.js.map new file mode 100644 index 0000000..585f66b --- /dev/null +++ b/packages/westore/dist/index.cmd.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.cmd.min.js","sources":["../node_modules/.pnpm/rfdc@1.3.0/node_modules/rfdc/index.js","../src/westore.ts","../src/index.ts"],"sourcesContent":["'use strict'\nmodule.exports = rfdc\n\nfunction copyBuffer (cur) {\n if (cur instanceof Buffer) {\n return Buffer.from(cur)\n }\n\n return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length)\n}\n\nfunction rfdc (opts) {\n opts = opts || {}\n\n if (opts.circles) return rfdcCircles(opts)\n return opts.proto ? cloneProto : clone\n\n function cloneArray (a, fn) {\n var keys = Object.keys(a)\n var a2 = new Array(keys.length)\n for (var i = 0; i < keys.length; i++) {\n var k = keys[i]\n var cur = a[k]\n if (typeof cur !== 'object' || cur === null) {\n a2[k] = cur\n } else if (cur instanceof Date) {\n a2[k] = new Date(cur)\n } else if (ArrayBuffer.isView(cur)) {\n a2[k] = copyBuffer(cur)\n } else {\n a2[k] = fn(cur)\n }\n }\n return a2\n }\n\n function clone (o) {\n if (typeof o !== 'object' || o === null) return o\n if (o instanceof Date) return new Date(o)\n if (Array.isArray(o)) return cloneArray(o, clone)\n if (o instanceof Map) return new Map(cloneArray(Array.from(o), clone))\n if (o instanceof Set) return new Set(cloneArray(Array.from(o), clone))\n var o2 = {}\n for (var k in o) {\n if (Object.hasOwnProperty.call(o, k) === false) continue\n var cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof Date) {\n o2[k] = new Date(cur)\n } else if (cur instanceof Map) {\n o2[k] = new Map(cloneArray(Array.from(cur), clone))\n } else if (cur instanceof Set) {\n o2[k] = new Set(cloneArray(Array.from(cur), clone))\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n o2[k] = clone(cur)\n }\n }\n return o2\n }\n\n function cloneProto (o) {\n if (typeof o !== 'object' || o === null) return o\n if (o instanceof Date) return new Date(o)\n if (Array.isArray(o)) return cloneArray(o, cloneProto)\n if (o instanceof Map) return new Map(cloneArray(Array.from(o), cloneProto))\n if (o instanceof Set) return new Set(cloneArray(Array.from(o), cloneProto))\n var o2 = {}\n for (var k in o) {\n var cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof Date) {\n o2[k] = new Date(cur)\n } else if (cur instanceof Map) {\n o2[k] = new Map(cloneArray(Array.from(cur), cloneProto))\n } else if (cur instanceof Set) {\n o2[k] = new Set(cloneArray(Array.from(cur), cloneProto))\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n o2[k] = cloneProto(cur)\n }\n }\n return o2\n }\n}\n\nfunction rfdcCircles (opts) {\n var refs = []\n var refsNew = []\n\n return opts.proto ? cloneProto : clone\n\n function cloneArray (a, fn) {\n var keys = Object.keys(a)\n var a2 = new Array(keys.length)\n for (var i = 0; i < keys.length; i++) {\n var k = keys[i]\n var cur = a[k]\n if (typeof cur !== 'object' || cur === null) {\n a2[k] = cur\n } else if (cur instanceof Date) {\n a2[k] = new Date(cur)\n } else if (ArrayBuffer.isView(cur)) {\n a2[k] = copyBuffer(cur)\n } else {\n var index = refs.indexOf(cur)\n if (index !== -1) {\n a2[k] = refsNew[index]\n } else {\n a2[k] = fn(cur)\n }\n }\n }\n return a2\n }\n\n function clone (o) {\n if (typeof o !== 'object' || o === null) return o\n if (o instanceof Date) return new Date(o)\n if (Array.isArray(o)) return cloneArray(o, clone)\n if (o instanceof Map) return new Map(cloneArray(Array.from(o), clone))\n if (o instanceof Set) return new Set(cloneArray(Array.from(o), clone))\n var o2 = {}\n refs.push(o)\n refsNew.push(o2)\n for (var k in o) {\n if (Object.hasOwnProperty.call(o, k) === false) continue\n var cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof Date) {\n o2[k] = new Date(cur)\n } else if (cur instanceof Map) {\n o2[k] = new Map(cloneArray(Array.from(cur), clone))\n } else if (cur instanceof Set) {\n o2[k] = new Set(cloneArray(Array.from(cur), clone))\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n var i = refs.indexOf(cur)\n if (i !== -1) {\n o2[k] = refsNew[i]\n } else {\n o2[k] = clone(cur)\n }\n }\n }\n refs.pop()\n refsNew.pop()\n return o2\n }\n\n function cloneProto (o) {\n if (typeof o !== 'object' || o === null) return o\n if (o instanceof Date) return new Date(o)\n if (Array.isArray(o)) return cloneArray(o, cloneProto)\n if (o instanceof Map) return new Map(cloneArray(Array.from(o), cloneProto))\n if (o instanceof Set) return new Set(cloneArray(Array.from(o), cloneProto))\n var o2 = {}\n refs.push(o)\n refsNew.push(o2)\n for (var k in o) {\n var cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof Date) {\n o2[k] = new Date(cur)\n } else if (cur instanceof Map) {\n o2[k] = new Map(cloneArray(Array.from(cur), cloneProto))\n } else if (cur instanceof Set) {\n o2[k] = new Set(cloneArray(Array.from(cur), cloneProto))\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n var i = refs.indexOf(cur)\n if (i !== -1) {\n o2[k] = refsNew[i]\n } else {\n o2[k] = cloneProto(cur)\n }\n }\n }\n refs.pop()\n refsNew.pop()\n return o2\n }\n}\n",null,null],"names":["rfdc_1","opts","circles","refs","refsNew","proto","cloneProto","o","Date","Array","isArray","cloneArray","Map","from","Set","o2","k","push","cur","ArrayBuffer","isView","copyBuffer","i","indexOf","pop","clone","Object","hasOwnProperty","call","a","fn","keys","a2","length","index","rfdcCircles","Buffer","constructor","buffer","slice","byteOffset","rfdc","DataTypes","ARRAYTYPE","OBJECTTYPE","FUNCTIONTYPE","diffData","current","previous","result","syncKeys","_diff","rootCurrentType","getType","rootPreType","key","currentValue","undefined","forEach","item","setResult","v","path","preValue","currentType","preType","concatPathAndKey","subKey","realPath","includes","obj","prototype","toString","update","view","callback","patch","data","_westorePrevData","setData","Store","this","views","_westoreViewId","bind","keyOrView","arguments","viewKey"],"mappings":"iBACAA,EAUA,SAAeC,GAGb,OAFAA,EAAOA,GAAQ,IAENC,QA4EX,SAAsBD,GACpB,IAAIE,EAAO,GACPC,EAAU,GAEd,OAAOH,EAAKI,MA8DZ,SAASC,EAAYC,GACnB,GAAiB,iBAANA,GAAwB,OAANA,EAAY,OAAOA,EAChD,GA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CAC/B,MAAMY,EACJF,EAAiBJ,EAAMP,IACtBY,EAAOE,SAAS,KAAO,KAAKF,MAAa,IAAIA,KAChDhB,EAAMK,EAAaW,GAASJ,EAASI,GAASC,EAAUnB,SAMzDG,GAAmBT,EACxBW,GAAeX,GAKbI,EAAQd,OAASe,EAASf,OAJ9B2B,EAAUX,EAAQa,EAAMf,GAStBA,EAAQW,SAAQ,CAACC,EAAWzB,KAC1BiB,EAAMQ,EAAMX,EAASd,GAAQ4B,EAAO,IAAM5B,EAAQ,IAAKe,MAK7DW,EAAUX,EAAQa,EAAMf,GAI5B,SAASmB,EAAiBJ,EAAcP,GACtC,OAAOA,EAAIc,SAAS,KAChBP,EAAO,KAAKP,OACH,IAARO,EAAa,GAAKA,EAAO,KAAOP,EAGvC,SAASF,EAAQiB,GACf,OAAO5C,OAAO6C,UAAUC,SAAS5C,KAAK0C,YAGxBG,EACdC,EACAC,GAEA,MAAMC,EAAQ9B,EAAS4B,EAAKG,KAAMH,EAAKI,kBACvCJ,EAAKK,QAAQH,EAAOD,GACpBD,EAAKI,iBAAmBrD,EAAMiD,EAAKG,MC1KrC,MAAe,CAAE/B,SAAAA,EAAU2B,OAAAA,EAAQO,YDkLjC3C,cACE4C,KAAKC,MAAQ,GACbD,KAAKE,eAAiB,EAGxBC,KACEC,EACAX,GAEyB,IAArBY,UAAUrD,QACZgD,KAAKJ,KAAOQ,EAAUR,KACtBI,KAAKC,MAAMD,KAAKE,kBAAoBE,IAGpCJ,KAAKJ,KAAOH,EAAKG,KACjBI,KAAKC,MAAMG,GAAaX,GAG5BD,OAAOc,GACL,GAAyB,IAArBD,UAAUrD,OACZwC,EAAOQ,KAAKC,MAAMK,SAElB,IAAK,MAAMhC,KAAO0B,KAAKC,MACrBT,EAAOQ,KAAKC,MAAM3B"} \ No newline at end of file diff --git a/packages/westore/dist/index.d.ts b/packages/westore/dist/index.d.ts new file mode 100644 index 0000000..2545b5e --- /dev/null +++ b/packages/westore/dist/index.d.ts @@ -0,0 +1,31 @@ +declare type WechatMiniprogramPageOrComponent = any; +interface Views { + key?: WechatMiniprogramPageOrComponent; +} +interface Current { + key?: any; +} +interface Previous { + key?: any; +} +interface diffResult { + key?: any; +} +declare function diffData(current: Current, previous: Previous): diffResult; +declare function update(view: WechatMiniprogramPageOrComponent, callback?: () => void): void; +declare class Store { + views: Views; + data: any; + private _westoreViewId; + constructor(); + bind(keyOrView: string | number | WechatMiniprogramPageOrComponent, view?: WechatMiniprogramPageOrComponent): void; + update(viewKey: string | number): void; +} + +declare const _default: { + diffData: typeof diffData; + update: typeof update; + Store: typeof Store; +}; + +export { _default as default }; diff --git a/packages/westore/dist/index.esm.js b/packages/westore/dist/index.esm.js new file mode 100644 index 0000000..df86689 --- /dev/null +++ b/packages/westore/dist/index.esm.js @@ -0,0 +1,363 @@ +var rfdc_1 = rfdc; + +function copyBuffer (cur) { + if (cur instanceof Buffer) { + return Buffer.from(cur) + } + + return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length) +} + +function rfdc (opts) { + opts = opts || {}; + + if (opts.circles) return rfdcCircles(opts) + return opts.proto ? cloneProto : clone + + function cloneArray (a, fn) { + var keys = Object.keys(a); + var a2 = new Array(keys.length); + for (var i = 0; i < keys.length; i++) { + var k = keys[i]; + var cur = a[k]; + if (typeof cur !== 'object' || cur === null) { + a2[k] = cur; + } else if (cur instanceof Date) { + a2[k] = new Date(cur); + } else if (ArrayBuffer.isView(cur)) { + a2[k] = copyBuffer(cur); + } else { + a2[k] = fn(cur); + } + } + return a2 + } + + function clone (o) { + if (typeof o !== 'object' || o === null) return o + if (o instanceof Date) return new Date(o) + if (Array.isArray(o)) return cloneArray(o, clone) + if (o instanceof Map) return new Map(cloneArray(Array.from(o), clone)) + if (o instanceof Set) return new Set(cloneArray(Array.from(o), clone)) + var o2 = {}; + for (var k in o) { + if (Object.hasOwnProperty.call(o, k) === false) continue + var cur = o[k]; + if (typeof cur !== 'object' || cur === null) { + o2[k] = cur; + } else if (cur instanceof Date) { + o2[k] = new Date(cur); + } else if (cur instanceof Map) { + o2[k] = new Map(cloneArray(Array.from(cur), clone)); + } else if (cur instanceof Set) { + o2[k] = new Set(cloneArray(Array.from(cur), clone)); + } else if (ArrayBuffer.isView(cur)) { + o2[k] = copyBuffer(cur); + } else { + o2[k] = clone(cur); + } + } + return o2 + } + + function cloneProto (o) { + if (typeof o !== 'object' || o === null) return o + if (o instanceof Date) return new Date(o) + if (Array.isArray(o)) return cloneArray(o, cloneProto) + if (o instanceof Map) return new Map(cloneArray(Array.from(o), cloneProto)) + if (o instanceof Set) return new Set(cloneArray(Array.from(o), cloneProto)) + var o2 = {}; + for (var k in o) { + var cur = o[k]; + if (typeof cur !== 'object' || cur === null) { + o2[k] = cur; + } else if (cur instanceof Date) { + o2[k] = new Date(cur); + } else if (cur instanceof Map) { + o2[k] = new Map(cloneArray(Array.from(cur), cloneProto)); + } else if (cur instanceof Set) { + o2[k] = new Set(cloneArray(Array.from(cur), cloneProto)); + } else if (ArrayBuffer.isView(cur)) { + o2[k] = copyBuffer(cur); + } else { + o2[k] = cloneProto(cur); + } + } + return o2 + } +} + +function rfdcCircles (opts) { + var refs = []; + var refsNew = []; + + return opts.proto ? cloneProto : clone + + function cloneArray (a, fn) { + var keys = Object.keys(a); + var a2 = new Array(keys.length); + for (var i = 0; i < keys.length; i++) { + var k = keys[i]; + var cur = a[k]; + if (typeof cur !== 'object' || cur === null) { + a2[k] = cur; + } else if (cur instanceof Date) { + a2[k] = new Date(cur); + } else if (ArrayBuffer.isView(cur)) { + a2[k] = copyBuffer(cur); + } else { + var index = refs.indexOf(cur); + if (index !== -1) { + a2[k] = refsNew[index]; + } else { + a2[k] = fn(cur); + } + } + } + return a2 + } + + function clone (o) { + if (typeof o !== 'object' || o === null) return o + if (o instanceof Date) return new Date(o) + if (Array.isArray(o)) return cloneArray(o, clone) + if (o instanceof Map) return new Map(cloneArray(Array.from(o), clone)) + if (o instanceof Set) return new Set(cloneArray(Array.from(o), clone)) + var o2 = {}; + refs.push(o); + refsNew.push(o2); + for (var k in o) { + if (Object.hasOwnProperty.call(o, k) === false) continue + var cur = o[k]; + if (typeof cur !== 'object' || cur === null) { + o2[k] = cur; + } else if (cur instanceof Date) { + o2[k] = new Date(cur); + } else if (cur instanceof Map) { + o2[k] = new Map(cloneArray(Array.from(cur), clone)); + } else if (cur instanceof Set) { + o2[k] = new Set(cloneArray(Array.from(cur), clone)); + } else if (ArrayBuffer.isView(cur)) { + o2[k] = copyBuffer(cur); + } else { + var i = refs.indexOf(cur); + if (i !== -1) { + o2[k] = refsNew[i]; + } else { + o2[k] = clone(cur); + } + } + } + refs.pop(); + refsNew.pop(); + return o2 + } + + function cloneProto (o) { + if (typeof o !== 'object' || o === null) return o + if (o instanceof Date) return new Date(o) + if (Array.isArray(o)) return cloneArray(o, cloneProto) + if (o instanceof Map) return new Map(cloneArray(Array.from(o), cloneProto)) + if (o instanceof Set) return new Set(cloneArray(Array.from(o), cloneProto)) + var o2 = {}; + refs.push(o); + refsNew.push(o2); + for (var k in o) { + var cur = o[k]; + if (typeof cur !== 'object' || cur === null) { + o2[k] = cur; + } else if (cur instanceof Date) { + o2[k] = new Date(cur); + } else if (cur instanceof Map) { + o2[k] = new Map(cloneArray(Array.from(cur), cloneProto)); + } else if (cur instanceof Set) { + o2[k] = new Set(cloneArray(Array.from(cur), cloneProto)); + } else if (ArrayBuffer.isView(cur)) { + o2[k] = copyBuffer(cur); + } else { + var i = refs.indexOf(cur); + if (i !== -1) { + o2[k] = refsNew[i]; + } else { + o2[k] = cloneProto(cur); + } + } + } + refs.pop(); + refsNew.pop(); + return o2 + } +} + +const clone = rfdc_1(); +var DataTypes; +(function (DataTypes) { + DataTypes["ARRAYTYPE"] = "[object Array]"; + DataTypes["OBJECTTYPE"] = "[object Object]"; + DataTypes["FUNCTIONTYPE"] = "[object Function]"; +})(DataTypes || (DataTypes = {})); +const ARRAYTYPE = DataTypes.ARRAYTYPE; +const OBJECTTYPE = DataTypes.OBJECTTYPE; +const FUNCTIONTYPE = DataTypes.FUNCTIONTYPE; +function diffData(current, previous) { + const result = {}; + if (!previous) + return current; + syncKeys(current, previous); + _diff(current, previous, '', result); + return result; +} +function syncKeys(current, previous) { + if (current === previous) + return; + const rootCurrentType = getType(current); + const rootPreType = getType(previous); + if (rootCurrentType == OBJECTTYPE && rootPreType == OBJECTTYPE) { + for (let key in previous) { + const currentValue = current[key]; + if (currentValue === undefined) { + current[key] = null; + } + else { + syncKeys(currentValue, previous[key]); + } + } + } + else if (rootCurrentType == ARRAYTYPE && rootPreType == ARRAYTYPE) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + if (current.length >= previous.length) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + previous.forEach((item, index) => { + syncKeys(current[index], item); + }); + } + } +} +function setResult(result, k, v) { + if (getType(v) != FUNCTIONTYPE) { + result[k] = v; + } +} +function _diff(current, previous, path, result) { + if (current === previous) + return; + const rootCurrentType = getType(current); + const rootPreType = getType(previous); + if (rootCurrentType == OBJECTTYPE) { + if (rootPreType != OBJECTTYPE || + (Object.keys(current).length < Object.keys(previous).length && + path !== '')) { + setResult(result, path, current); + } + else { + for (const key in current) { + const currentValue = current[key]; + const preValue = previous[key]; + const currentType = getType(currentValue); + const preType = getType(preValue); + if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) { + if (currentValue !== previous[key]) { + setResult(result, concatPathAndKey(path, key), currentValue); + } + } + else if (currentType == ARRAYTYPE) { + if (preType != ARRAYTYPE) { + setResult(result, concatPathAndKey(path, key), currentValue); + } + else { + if (currentValue.length < preValue.length) { + setResult(result, concatPathAndKey(path, key), currentValue); + } + else { + currentValue.forEach((item, index) => { + _diff(item, preValue[index], concatPathAndKey(path, key) + '[' + index + ']', result); + }); + } + } + } + else if (currentType == OBJECTTYPE) { + if (preType != OBJECTTYPE || + Object.keys(currentValue).length < Object.keys(preValue).length) { + setResult(result, concatPathAndKey(path, key), currentValue); + } + else { + for (let subKey in currentValue) { + const realPath = concatPathAndKey(path, key) + + (subKey.includes('.') ? `["${subKey}"]` : `.${subKey}`); + _diff(currentValue[subKey], preValue[subKey], realPath, result); + } + } + } + } + } + } + else if (rootCurrentType == ARRAYTYPE) { + if (rootPreType != ARRAYTYPE) { + setResult(result, path, current); + } + else { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + if (current.length < previous.length) { + setResult(result, path, current); + } + else { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + current.forEach((item, index) => { + _diff(item, previous[index], path + '[' + index + ']', result); + }); + } + } + } + else { + setResult(result, path, current); + } +} +function concatPathAndKey(path, key) { + return key.includes('.') + ? path + `["${key}"]` + : (path == '' ? '' : path + '.') + key; +} +function getType(obj) { + return Object.prototype.toString.call(obj); +} +function update(view, callback) { + const patch = diffData(view.data, view._westorePrevData); + view.setData(patch, callback); + view._westorePrevData = clone(view.data); +} +class Store { + constructor() { + this.views = {}; + this._westoreViewId = 0; + } + bind(keyOrView, view) { + if (arguments.length === 1) { + this.data = keyOrView.data; + this.views[this._westoreViewId++] = keyOrView; + } + else { + //设置回 view 的 data,不然引用地址 错误 + this.data = view.data; + this.views[keyOrView] = view; + } + } + update(viewKey) { + if (arguments.length === 1) { + update(this.views[viewKey]); + } + else { + for (const key in this.views) { + update(this.views[key]); + } + } + } +} + +var index = { diffData, update, Store }; + +export { index as default }; +//# sourceMappingURL=index.esm.js.map diff --git a/packages/westore/dist/index.esm.js.map b/packages/westore/dist/index.esm.js.map new file mode 100644 index 0000000..2d0e563 --- /dev/null +++ b/packages/westore/dist/index.esm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.esm.js","sources":["../node_modules/.pnpm/rfdc@1.3.0/node_modules/rfdc/index.js","../src/westore.ts","../src/index.ts"],"sourcesContent":["'use strict'\nmodule.exports = rfdc\n\nfunction copyBuffer (cur) {\n if (cur instanceof Buffer) {\n return Buffer.from(cur)\n }\n\n return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length)\n}\n\nfunction rfdc (opts) {\n opts = opts || {}\n\n if (opts.circles) return rfdcCircles(opts)\n return opts.proto ? cloneProto : clone\n\n function cloneArray (a, fn) {\n var keys = Object.keys(a)\n var a2 = new Array(keys.length)\n for (var i = 0; i < keys.length; i++) {\n var k = keys[i]\n var cur = a[k]\n if (typeof cur !== 'object' || cur === null) {\n a2[k] = cur\n } else if (cur instanceof Date) {\n a2[k] = new Date(cur)\n } else if (ArrayBuffer.isView(cur)) {\n a2[k] = copyBuffer(cur)\n } else {\n a2[k] = fn(cur)\n }\n }\n return a2\n }\n\n function clone (o) {\n if (typeof o !== 'object' || o === null) return o\n if (o instanceof Date) return new Date(o)\n if (Array.isArray(o)) return cloneArray(o, clone)\n if (o instanceof Map) return new Map(cloneArray(Array.from(o), clone))\n if (o instanceof Set) return new Set(cloneArray(Array.from(o), clone))\n var o2 = {}\n for (var k in o) {\n if (Object.hasOwnProperty.call(o, k) === false) continue\n var cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof Date) {\n o2[k] = new Date(cur)\n } else if (cur instanceof Map) {\n o2[k] = new Map(cloneArray(Array.from(cur), clone))\n } else if (cur instanceof Set) {\n o2[k] = new Set(cloneArray(Array.from(cur), clone))\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n o2[k] = clone(cur)\n }\n }\n return o2\n }\n\n function cloneProto (o) {\n if (typeof o !== 'object' || o === null) return o\n if (o instanceof Date) return new Date(o)\n if (Array.isArray(o)) return cloneArray(o, cloneProto)\n if (o instanceof Map) return new Map(cloneArray(Array.from(o), cloneProto))\n if (o instanceof Set) return new Set(cloneArray(Array.from(o), cloneProto))\n var o2 = {}\n for (var k in o) {\n var cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof Date) {\n o2[k] = new Date(cur)\n } else if (cur instanceof Map) {\n o2[k] = new Map(cloneArray(Array.from(cur), cloneProto))\n } else if (cur instanceof Set) {\n o2[k] = new Set(cloneArray(Array.from(cur), cloneProto))\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n o2[k] = cloneProto(cur)\n }\n }\n return o2\n }\n}\n\nfunction rfdcCircles (opts) {\n var refs = []\n var refsNew = []\n\n return opts.proto ? cloneProto : clone\n\n function cloneArray (a, fn) {\n var keys = Object.keys(a)\n var a2 = new Array(keys.length)\n for (var i = 0; i < keys.length; i++) {\n var k = keys[i]\n var cur = a[k]\n if (typeof cur !== 'object' || cur === null) {\n a2[k] = cur\n } else if (cur instanceof Date) {\n a2[k] = new Date(cur)\n } else if (ArrayBuffer.isView(cur)) {\n a2[k] = copyBuffer(cur)\n } else {\n var index = refs.indexOf(cur)\n if (index !== -1) {\n a2[k] = refsNew[index]\n } else {\n a2[k] = fn(cur)\n }\n }\n }\n return a2\n }\n\n function clone (o) {\n if (typeof o !== 'object' || o === null) return o\n if (o instanceof Date) return new Date(o)\n if (Array.isArray(o)) return cloneArray(o, clone)\n if (o instanceof Map) return new Map(cloneArray(Array.from(o), clone))\n if (o instanceof Set) return new Set(cloneArray(Array.from(o), clone))\n var o2 = {}\n refs.push(o)\n refsNew.push(o2)\n for (var k in o) {\n if (Object.hasOwnProperty.call(o, k) === false) continue\n var cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof Date) {\n o2[k] = new Date(cur)\n } else if (cur instanceof Map) {\n o2[k] = new Map(cloneArray(Array.from(cur), clone))\n } else if (cur instanceof Set) {\n o2[k] = new Set(cloneArray(Array.from(cur), clone))\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n var i = refs.indexOf(cur)\n if (i !== -1) {\n o2[k] = refsNew[i]\n } else {\n o2[k] = clone(cur)\n }\n }\n }\n refs.pop()\n refsNew.pop()\n return o2\n }\n\n function cloneProto (o) {\n if (typeof o !== 'object' || o === null) return o\n if (o instanceof Date) return new Date(o)\n if (Array.isArray(o)) return cloneArray(o, cloneProto)\n if (o instanceof Map) return new Map(cloneArray(Array.from(o), cloneProto))\n if (o instanceof Set) return new Set(cloneArray(Array.from(o), cloneProto))\n var o2 = {}\n refs.push(o)\n refsNew.push(o2)\n for (var k in o) {\n var cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof Date) {\n o2[k] = new Date(cur)\n } else if (cur instanceof Map) {\n o2[k] = new Map(cloneArray(Array.from(cur), cloneProto))\n } else if (cur instanceof Set) {\n o2[k] = new Set(cloneArray(Array.from(cur), cloneProto))\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n var i = refs.indexOf(cur)\n if (i !== -1) {\n o2[k] = refsNew[i]\n } else {\n o2[k] = cloneProto(cur)\n }\n }\n }\n refs.pop()\n refsNew.pop()\n return o2\n }\n}\n",null,null],"names":["rfdc"],"mappings":"IACA,MAAc,GAAG,KAAI;AACrB;AACA,SAAS,UAAU,EAAE,GAAG,EAAE;AAC1B,EAAE,IAAI,GAAG,YAAY,MAAM,EAAE;AAC7B,IAAI,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AAC3B,GAAG;AACH;AACA,EAAE,OAAO,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC;AAC5E,CAAC;AACD;AACA,SAAS,IAAI,EAAE,IAAI,EAAE;AACrB,EAAE,IAAI,GAAG,IAAI,IAAI,GAAE;AACnB;AACA,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE,OAAO,WAAW,CAAC,IAAI,CAAC;AAC5C,EAAE,OAAO,IAAI,CAAC,KAAK,GAAG,UAAU,GAAG,KAAK;AACxC;AACA,EAAE,SAAS,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE;AAC9B,IAAI,IAAI,IAAI,GAA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CAAA;QACf,IAAI,CAAC,cAAc,GAAG,CAAC,CAAA;KACxB;IAED,IAAI,CACF,SAA6D,EAC7D,IAAuC;QAEvC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;YAC1B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAA;YAC1B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,GAAG,SAAS,CAAA;SAC9C;aAAM;;YAEL,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;YACrB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAA;SAC7B;KACF;IACD,MAAM,CAAC,OAAwB;QAC7B,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;YAC1B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;SAC5B;aAAM;YACL,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE;gBAC5B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;aACxB;SACF;KACF;;;AC5MH,YAAe,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE;;;;"} \ No newline at end of file diff --git a/packages/westore/dist/index.esm.min.js b/packages/westore/dist/index.esm.min.js new file mode 100644 index 0000000..e01b607 --- /dev/null +++ b/packages/westore/dist/index.esm.min.js @@ -0,0 +1,2 @@ +var e=function(e){return(e=e||{}).circles?function(e){var r=[],n=[];return e.proto?function e(a){if("object"!=typeof a||null===a)return a;if(a instanceof Date)return new Date(a);if(Array.isArray(a))return f(a,e);if(a instanceof Map)return new Map(f(Array.from(a),e));if(a instanceof Set)return new Set(f(Array.from(a),e));var i={};for(var o in r.push(a),n.push(i),a){var s=a[o];if("object"!=typeof s||null===s)i[o]=s;else if(s instanceof Date)i[o]=new Date(s);else if(s instanceof Map)i[o]=new Map(f(Array.from(s),e));else if(s instanceof Set)i[o]=new Set(f(Array.from(s),e));else if(ArrayBuffer.isView(s))i[o]=t(s);else{var c=r.indexOf(s);i[o]=-1!==c?n[c]:e(s)}}return r.pop(),n.pop(),i}:function e(a){if("object"!=typeof a||null===a)return a;if(a instanceof Date)return new Date(a);if(Array.isArray(a))return f(a,e);if(a instanceof Map)return new Map(f(Array.from(a),e));if(a instanceof Set)return new Set(f(Array.from(a),e));var i={};for(var o in r.push(a),n.push(i),a)if(!1!==Object.hasOwnProperty.call(a,o)){var s=a[o];if("object"!=typeof s||null===s)i[o]=s;else if(s instanceof Date)i[o]=new Date(s);else if(s instanceof Map)i[o]=new Map(f(Array.from(s),e));else if(s instanceof Set)i[o]=new Set(f(Array.from(s),e));else if(ArrayBuffer.isView(s))i[o]=t(s);else{var c=r.indexOf(s);i[o]=-1!==c?n[c]:e(s)}}return r.pop(),n.pop(),i};function f(e,f){for(var a=Object.keys(e),i=new Array(a.length),o=0;o=t.length&&t.forEach(((t,r)=>{s(e[r],t)}))}function c(e,t,r){y(r)!=i&&(e[t]=r)}function u(e,t,r,n){if(e===t)return;const i=y(e),o=y(t);if(i==a)if(o!=a||Object.keys(e).length{u(e,s[t],l(r,i)+"["+t+"]",n)}));else if(w==a)if(p!=a||Object.keys(o).length{u(e,t[f],r+"["+f+"]",n)})):c(n,r,e)}function l(e,t){return t.includes(".")?e+`["${t}"]`:(""==e?"":e+".")+t}function y(e){return Object.prototype.toString.call(e)}function w(e,t){const n=o(e.data,e._westorePrevData);e.setData(n,t),e._westorePrevData=r(e.data)}var p={diffData:o,update:w,Store:class{constructor(){this.views={},this._westoreViewId=0}bind(e,t){1===arguments.length?(this.data=e.data,this.views[this._westoreViewId++]=e):(this.data=t.data,this.views[e]=t)}update(e){if(1===arguments.length)w(this.views[e]);else for(const e in this.views)w(this.views[e])}}};export{p as default}; +//# sourceMappingURL=index.esm.min.js.map diff --git a/packages/westore/dist/index.esm.min.js.map b/packages/westore/dist/index.esm.min.js.map new file mode 100644 index 0000000..fdbd101 --- /dev/null +++ b/packages/westore/dist/index.esm.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.esm.min.js","sources":["../node_modules/.pnpm/rfdc@1.3.0/node_modules/rfdc/index.js","../src/westore.ts","../src/index.ts"],"sourcesContent":["'use strict'\nmodule.exports = rfdc\n\nfunction copyBuffer (cur) {\n if (cur instanceof Buffer) {\n return Buffer.from(cur)\n }\n\n return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length)\n}\n\nfunction rfdc (opts) {\n opts = opts || {}\n\n if (opts.circles) return rfdcCircles(opts)\n return opts.proto ? cloneProto : clone\n\n function cloneArray (a, fn) {\n var keys = Object.keys(a)\n var a2 = new Array(keys.length)\n for (var i = 0; i < keys.length; i++) {\n var k = keys[i]\n var cur = a[k]\n if (typeof cur !== 'object' || cur === null) {\n a2[k] = cur\n } else if (cur instanceof Date) {\n a2[k] = new Date(cur)\n } else if (ArrayBuffer.isView(cur)) {\n a2[k] = copyBuffer(cur)\n } else {\n a2[k] = fn(cur)\n }\n }\n return a2\n }\n\n function clone (o) {\n if (typeof o !== 'object' || o === null) return o\n if (o instanceof Date) return new Date(o)\n if (Array.isArray(o)) return cloneArray(o, clone)\n if (o instanceof Map) return new Map(cloneArray(Array.from(o), clone))\n if (o instanceof Set) return new Set(cloneArray(Array.from(o), clone))\n var o2 = {}\n for (var k in o) {\n if (Object.hasOwnProperty.call(o, k) === false) continue\n var cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof Date) {\n o2[k] = new Date(cur)\n } else if (cur instanceof Map) {\n o2[k] = new Map(cloneArray(Array.from(cur), clone))\n } else if (cur instanceof Set) {\n o2[k] = new Set(cloneArray(Array.from(cur), clone))\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n o2[k] = clone(cur)\n }\n }\n return o2\n }\n\n function cloneProto (o) {\n if (typeof o !== 'object' || o === null) return o\n if (o instanceof Date) return new Date(o)\n if (Array.isArray(o)) return cloneArray(o, cloneProto)\n if (o instanceof Map) return new Map(cloneArray(Array.from(o), cloneProto))\n if (o instanceof Set) return new Set(cloneArray(Array.from(o), cloneProto))\n var o2 = {}\n for (var k in o) {\n var cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof Date) {\n o2[k] = new Date(cur)\n } else if (cur instanceof Map) {\n o2[k] = new Map(cloneArray(Array.from(cur), cloneProto))\n } else if (cur instanceof Set) {\n o2[k] = new Set(cloneArray(Array.from(cur), cloneProto))\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n o2[k] = cloneProto(cur)\n }\n }\n return o2\n }\n}\n\nfunction rfdcCircles (opts) {\n var refs = []\n var refsNew = []\n\n return opts.proto ? cloneProto : clone\n\n function cloneArray (a, fn) {\n var keys = Object.keys(a)\n var a2 = new Array(keys.length)\n for (var i = 0; i < keys.length; i++) {\n var k = keys[i]\n var cur = a[k]\n if (typeof cur !== 'object' || cur === null) {\n a2[k] = cur\n } else if (cur instanceof Date) {\n a2[k] = new Date(cur)\n } else if (ArrayBuffer.isView(cur)) {\n a2[k] = copyBuffer(cur)\n } else {\n var index = refs.indexOf(cur)\n if (index !== -1) {\n a2[k] = refsNew[index]\n } else {\n a2[k] = fn(cur)\n }\n }\n }\n return a2\n }\n\n function clone (o) {\n if (typeof o !== 'object' || o === null) return o\n if (o instanceof Date) return new Date(o)\n if (Array.isArray(o)) return cloneArray(o, clone)\n if (o instanceof Map) return new Map(cloneArray(Array.from(o), clone))\n if (o instanceof Set) return new Set(cloneArray(Array.from(o), clone))\n var o2 = {}\n refs.push(o)\n refsNew.push(o2)\n for (var k in o) {\n if (Object.hasOwnProperty.call(o, k) === false) continue\n var cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof Date) {\n o2[k] = new Date(cur)\n } else if (cur instanceof Map) {\n o2[k] = new Map(cloneArray(Array.from(cur), clone))\n } else if (cur instanceof Set) {\n o2[k] = new Set(cloneArray(Array.from(cur), clone))\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n var i = refs.indexOf(cur)\n if (i !== -1) {\n o2[k] = refsNew[i]\n } else {\n o2[k] = clone(cur)\n }\n }\n }\n refs.pop()\n refsNew.pop()\n return o2\n }\n\n function cloneProto (o) {\n if (typeof o !== 'object' || o === null) return o\n if (o instanceof Date) return new Date(o)\n if (Array.isArray(o)) return cloneArray(o, cloneProto)\n if (o instanceof Map) return new Map(cloneArray(Array.from(o), cloneProto))\n if (o instanceof Set) return new Set(cloneArray(Array.from(o), cloneProto))\n var o2 = {}\n refs.push(o)\n refsNew.push(o2)\n for (var k in o) {\n var cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k] = cur\n } else if (cur instanceof Date) {\n o2[k] = new Date(cur)\n } else if (cur instanceof Map) {\n o2[k] = new Map(cloneArray(Array.from(cur), cloneProto))\n } else if (cur instanceof Set) {\n o2[k] = new Set(cloneArray(Array.from(cur), cloneProto))\n } else if (ArrayBuffer.isView(cur)) {\n o2[k] = copyBuffer(cur)\n } else {\n var i = refs.indexOf(cur)\n if (i !== -1) {\n o2[k] = refsNew[i]\n } else {\n o2[k] = cloneProto(cur)\n }\n }\n }\n refs.pop()\n refsNew.pop()\n return o2\n }\n}\n",null,null],"names":["rfdc_1","opts","circles","refs","refsNew","proto","cloneProto","o","Date","Array","isArray","cloneArray","Map","from","Set","o2","k","push","cur","ArrayBuffer","isView","copyBuffer","i","indexOf","pop","clone","Object","hasOwnProperty","call","a","fn","keys","a2","length","index","rfdcCircles","Buffer","constructor","buffer","slice","byteOffset","rfdc","DataTypes","ARRAYTYPE","OBJECTTYPE","FUNCTIONTYPE","diffData","current","previous","result","syncKeys","_diff","rootCurrentType","getType","rootPreType","key","currentValue","undefined","forEach","item","setResult","v","path","preValue","currentType","preType","concatPathAndKey","subKey","realPath","includes","obj","prototype","toString","update","view","callback","patch","data","_westorePr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AAOc,GACL,GAAyB,IAArBD,UAAUrD,OACZwC,EAAOQ,KAAKC,MAAMK,SAElB,IAAK,MAAMhC,KAAO0B,KAAKC,MACrBT,EAAOQ,KAAKC,MAAM3B"} \ No newline at end of file diff --git a/packages/westore/index.common.js b/packages/westore/index.common.js deleted file mode 100644 index 1c6bd66..0000000 --- a/packages/westore/index.common.js +++ /dev/null @@ -1,145 +0,0 @@ -const ARRAYTYPE = '[object Array]' -const OBJECTTYPE = '[object Object]' -const FUNCTIONTYPE = '[object Function]' -const clone = require('rfdc')() - -function diffData(current, previous) { - const result = {} - if (!previous) return current - syncKeys(current, previous) - _diff(current, previous, '', result) - return result -} - -function syncKeys(current, previous) { - if (current === previous) return - const rootCurrentType = getType(current) - const rootPreType = getType(previous) - if (rootCurrentType == OBJECTTYPE && rootPreType == OBJECTTYPE) { - for (let key in previous) { - const currentValue = current[key] - if (currentValue === undefined) { - current[key] = null - } else { - syncKeys(currentValue, previous[key]) - } - } - } else if (rootCurrentType == ARRAYTYPE && rootPreType == ARRAYTYPE) { - if (current.length >= previous.length) { - previous.forEach((item, index) => { - syncKeys(current[index], item) - }) - } - } -} - -function _diff(current, previous, path, result) { - if (current === previous) return - const rootCurrentType = getType(current) - const rootPreType = getType(previous) - if (rootCurrentType == OBJECTTYPE) { - if (rootPreType != OBJECTTYPE || Object.keys(current).length < Object.keys(previous).length && path !== '') { - setResult(result, path, current) - } else { - for (let key in current) { - const currentValue = current[key] - const preValue = previous[key] - const currentType = getType(currentValue) - const preType = getType(preValue) - if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) { - if (currentValue !== previous[key]) { - setResult(result, concatPathAndKey(path, key), currentValue) - } - } else if (currentType == ARRAYTYPE) { - if (preType != ARRAYTYPE) { - setResult(result, concatPathAndKey(path, key), currentValue) - } else { - if (currentValue.length < preValue.length) { - setResult(result, concatPathAndKey(path, key), currentValue) - } else { - currentValue.forEach((item, index) => { - _diff(item, preValue[index], concatPathAndKey(path, key) + '[' + index + ']', result) - }) - } - } - } else if (currentType == OBJECTTYPE) { - if (preType != OBJECTTYPE || Object.keys(currentValue).length < Object.keys(preValue).length) { - setResult(result, concatPathAndKey(path, key), currentValue) - } else { - for (let subKey in currentValue) { - const realPath = concatPathAndKey(path, key) + (subKey.includes('.') ? `["${subKey}"]` : `.${subKey}`) - _diff(currentValue[subKey], preValue[subKey], realPath, result) - } - } - } - } - } - } else if (rootCurrentType == ARRAYTYPE) { - if (rootPreType != ARRAYTYPE) { - setResult(result, path, current) - } else { - if (current.length < previous.length) { - setResult(result, path, current) - } else { - current.forEach((item, index) => { - _diff(item, previous[index], path + '[' + index + ']', result) - }) - } - } - } else { - setResult(result, path, current) - } -} - -function concatPathAndKey(path, key) { - return key.includes('.') - ? path + `["${key}"]` - : (path == '' ? '' : path + ".") + key -} - -function setResult(result, k, v) { - if (getType(v) != FUNCTIONTYPE) { - result[k] = v - } -} - -function getType(obj) { - return Object.prototype.toString.call(obj) -} - -function update(view, callback) { - const patch = diffData(view.data, view._westorePrevData) - view.setData(patch, callback) - view._westorePrevData = clone(view.data) -} - - -class Store { - constructor() { - this.views = {} - } - - bind(key, view) { - //设置回view的data,会有其他store的属性污染data - this.data = view.data - this.views[key] = view - - - } - - update(viewKey) { - if (viewKey) { - update(this.views[viewKey]) - } else { - for (const key in this.views) { - update(this.views[key]) - } - } - } -} - -module.exports = { - update, - diffData, - Store -} \ No newline at end of file diff --git a/packages/westore/index.d.ts b/packages/westore/index.d.ts deleted file mode 100644 index ced798c..0000000 --- a/packages/westore/index.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -interface Current { - key?: any; -} - -interface Previous { - key?: any; -} - -interface diffResult { - key?: any; -} - -type WechatMiniprogramPageOrComponent = any; - -export declare function diffData( - current: Current, - previous: Previous -): diffResult; - -export declare function update( - view: WechatMiniprogramPageOrComponent, - callback?: () => void -): void; diff --git a/packages/westore/index.esm.js b/packages/westore/index.esm.js deleted file mode 100644 index 7d58e3c..0000000 --- a/packages/westore/index.esm.js +++ /dev/null @@ -1,137 +0,0 @@ -const ARRAYTYPE = '[object Array]' -const OBJECTTYPE = '[object Object]' -const FUNCTIONTYPE = '[object Function]' -const clone = require('rfdc')() - -export function diffData(current, previous) { - const result = {} - if (!previous) return current - syncKeys(current, previous) - _diff(current, previous, '', result) - return result -} - -function syncKeys(current, previous) { - if (current === previous) return - const rootCurrentType = getType(current) - const rootPreType = getType(previous) - if (rootCurrentType == OBJECTTYPE && rootPreType == OBJECTTYPE) { - for (let key in previous) { - const currentValue = current[key] - if (currentValue === undefined) { - current[key] = null - } else { - syncKeys(currentValue, previous[key]) - } - } - } else if (rootCurrentType == ARRAYTYPE && rootPreType == ARRAYTYPE) { - if (current.length >= previous.length) { - previous.forEach((item, index) => { - syncKeys(current[index], item) - }) - } - } -} - -function _diff(current, previous, path, result) { - if (current === previous) return - const rootCurrentType = getType(current) - const rootPreType = getType(previous) - if (rootCurrentType == OBJECTTYPE) { - if (rootPreType != OBJECTTYPE || Object.keys(current).length < Object.keys(previous).length && path !== '') { - setResult(result, path, current) - } else { - for (let key in current) { - const currentValue = current[key] - const preValue = previous[key] - const currentType = getType(currentValue) - const preType = getType(preValue) - if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) { - if (currentValue !== previous[key]) { - setResult(result, concatPathAndKey(path, key), currentValue) - } - } else if (currentType == ARRAYTYPE) { - if (preType != ARRAYTYPE) { - setResult(result, concatPathAndKey(path, key), currentValue) - } else { - if (currentValue.length < preValue.length) { - setResult(result, concatPathAndKey(path, key), currentValue) - } else { - currentValue.forEach((item, index) => { - _diff(item, preValue[index], concatPathAndKey(path, key) + '[' + index + ']', result) - }) - } - } - } else if (currentType == OBJECTTYPE) { - if (preType != OBJECTTYPE || Object.keys(currentValue).length < Object.keys(preValue).length) { - setResult(result, concatPathAndKey(path, key), currentValue) - } else { - for (let subKey in currentValue) { - const realPath = concatPathAndKey(path, key) + (subKey.includes('.') ? `["${subKey}"]` : `.${subKey}`) - _diff(currentValue[subKey], preValue[subKey], realPath, result) - } - } - } - } - } - } else if (rootCurrentType == ARRAYTYPE) { - if (rootPreType != ARRAYTYPE) { - setResult(result, path, current) - } else { - if (current.length < previous.length) { - setResult(result, path, current) - } else { - current.forEach((item, index) => { - _diff(item, previous[index], path + '[' + index + ']', result) - }) - } - } - } else { - setResult(result, path, current) - } -} - -function concatPathAndKey(path, key) { - return key.includes('.') - ? path + `["${key}"]` - : (path == '' ? '' : path + ".") + key -} - -function setResult(result, k, v) { - if (getType(v) != FUNCTIONTYPE) { - result[k] = v - } -} - -function getType(obj) { - return Object.prototype.toString.call(obj) -} - -export function update(view, callback) { - const patch = diffData(view.data, view._westorePrevData) - view.setData(patch, callback) - view._westorePrevData = clone(view.data) -} - - -export class Store { - constructor() { - this.views = {} - } - - bind(key, view) { - //设置回 view 的 data,不然引用地址 错误 - this.data = view.data - this.views[key] = view - } - - update(viewKey) { - if (viewKey) { - update(this.views[viewKey]) - } else { - for (const key in this.views) { - update(this.views[key]) - } - } - } -} \ No newline at end of file diff --git a/packages/westore/package.json b/packages/westore/package.json index db53e7c..88aa52e 100644 --- a/packages/westore/package.json +++ b/packages/westore/package.json @@ -1,17 +1,42 @@ { "name": "westore", - "version": "0.1.6", + "version": "0.1.8", "description": "Better mini program architecture.", - "main": "index.esm.js", - "module": "index.esm.js", - "types": "index.d.ts", + "main": "dist/index.esm.js", + "module": "dist/index.esm.js", + "commonjs": "dist/index.cmd.js", + "module:minified": "dist/index.esm.min.js", + "commonjs:minified": "dist/index.cmd.min.js", + "types": "dist/index.d.ts", "scripts": { - "test": "jest" + "clean": "rimraf dist", + "build": "npm-run-all clean build:dev build:prod", + "build:dev": "rollup -c ./rollup.config.dev.js", + "build:prod": "rollup -c ./rollup.config.prod.js", + "test": "jest", + "lint:fix": "eslint --fix src --ext .ts --max-warnings=0", + "format": "npx prettier --write ." }, "author": "dntzhang", "license": "MIT", "devDependencies": { - "jest": "^27.2.0" + "@rollup/plugin-commonjs": "^20.0.0", + "@rollup/plugin-node-resolve": "^13.0.5", + "@rollup/plugin-typescript": "^8.2.5", + "@types/jest": "^27.0.2", + "@typescript-eslint/eslint-plugin": "^4.31.2", + "@typescript-eslint/parser": "^4.31.2", + "eslint": ">=5.16.0", + "eslint-config-google": "^0.14.0", + "jest": "^27.2.1", + "npm-run-all": "^4.1.5", + "rimraf": "^3.0.2", + "rollup": "^2.57.0", + "rollup-plugin-dts": "^4.0.0", + "rollup-plugin-sourcemaps": "^0.6.3", + "rollup-plugin-terser": "^7.0.2", + "tslib": "^2.3.1", + "typescript": "^4.4.3" }, "dependencies": { "rfdc": "^1.3.0" diff --git a/packages/westore/rollup.config.dev.js b/packages/westore/rollup.config.dev.js new file mode 100644 index 0000000..24b6902 --- /dev/null +++ b/packages/westore/rollup.config.dev.js @@ -0,0 +1,35 @@ +import resolve from '@rollup/plugin-node-resolve' +import commonjs from '@rollup/plugin-commonjs' +import typescript from '@rollup/plugin-typescript' +import sourceMaps from 'rollup-plugin-sourcemaps' +import dts from 'rollup-plugin-dts' + +const pkg = require('./package.json') + +export default [ + { + input: 'src/index.ts', + output: [ + { + file: pkg.module, + format: 'module', + sourcemap: true + }, + { + file: pkg.commonjs, + format: 'cjs', + exports: 'auto', + sourcemap: true + } + ], + plugins: [resolve(), commonjs(), typescript(), sourceMaps()] + }, + { + input: 'src/index.ts', + output: { + file: pkg.types, + format: 'module' + }, + plugins: [dts()] + } +] diff --git a/packages/westore/rollup.config.prod.js b/packages/westore/rollup.config.prod.js new file mode 100644 index 0000000..320175a --- /dev/null +++ b/packages/westore/rollup.config.prod.js @@ -0,0 +1,25 @@ +import resolve from '@rollup/plugin-node-resolve' +import commonjs from '@rollup/plugin-commonjs' +import typescript from '@rollup/plugin-typescript' +import sourceMaps from 'rollup-plugin-sourcemaps' +import { terser } from 'rollup-plugin-terser' + +const pkg = require('./package.json') + +export default { + input: 'src/index.ts', + output: [ + { + file: pkg['module:minified'], + format: 'module', + sourcemap: true + }, + { + file: pkg['commonjs:minified'], + format: 'cjs', + exports: 'auto', + sourcemap: true + } + ], + plugins: [resolve(), commonjs(), typescript(), sourceMaps(), terser()] +} diff --git a/packages/westore/src/index.ts b/packages/westore/src/index.ts new file mode 100644 index 0000000..75c39dc --- /dev/null +++ b/packages/westore/src/index.ts @@ -0,0 +1,3 @@ +import { diffData, update, Store } from './westore' + +export default { diffData, update, Store } diff --git a/packages/westore/src/westore.ts b/packages/westore/src/westore.ts new file mode 100644 index 0000000..14fb1cc --- /dev/null +++ b/packages/westore/src/westore.ts @@ -0,0 +1,208 @@ +import rfdc from 'rfdc' +const clone = rfdc() + +enum DataTypes { + ARRAYTYPE = '[object Array]', + OBJECTTYPE = '[object Object]', + FUNCTIONTYPE = '[object Function]' +} + +type WechatMiniprogramPageOrComponent = any + +interface Views { + key?: WechatMiniprogramPageOrComponent +} + +interface Current { + key?: any +} + +interface Previous { + key?: any +} + +interface diffResult { + key?: any +} + +const ARRAYTYPE = DataTypes.ARRAYTYPE +const OBJECTTYPE = DataTypes.OBJECTTYPE +const FUNCTIONTYPE = DataTypes.FUNCTIONTYPE + +export function diffData(current: Current, previous: Previous): diffResult { + const result = {} + if (!previous) return current + syncKeys(current, previous) + _diff(current, previous, '', result) + return result +} + +function syncKeys(current: Current, previous: Previous) { + if (current === previous) return + + const rootCurrentType: DataTypes = getType(current) + const rootPreType: DataTypes = getType(previous) + + if (rootCurrentType == OBJECTTYPE && rootPreType == OBJECTTYPE) { + for (let key in previous) { + const currentValue = current[key] + if (currentValue === undefined) { + current[key] = null + } else { + syncKeys(currentValue, previous[key]) + } + } + } else if (rootCurrentType == ARRAYTYPE && rootPreType == ARRAYTYPE) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + if (current.length >= previous.length) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + previous.forEach((item: any, index: string | number) => { + syncKeys(current[index], item) + }) + } + } +} + +function setResult(result: { [x: string]: any }, k: string, v: any) { + if (getType(v) != FUNCTIONTYPE) { + result[k] = v + } +} + +function _diff( + current: Current, + previous: Previous, + path: string, + result: diffResult +) { + if (current === previous) return + + const rootCurrentType = getType(current) + const rootPreType = getType(previous) + + if (rootCurrentType == OBJECTTYPE) { + if ( + rootPreType != OBJECTTYPE || + (Object.keys(current).length < Object.keys(previous).length && + path !== '') + ) { + setResult(result, path, current) + } else { + for (const key in current) { + const currentValue = current[key] + const preValue = previous[key] + const currentType = getType(currentValue) + const preType = getType(preValue) + if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) { + if (currentValue !== previous[key]) { + setResult(result, concatPathAndKey(path, key), currentValue) + } + } else if (currentType == ARRAYTYPE) { + if (preType != ARRAYTYPE) { + setResult(result, concatPathAndKey(path, key), currentValue) + } else { + if (currentValue.length < preValue.length) { + setResult(result, concatPathAndKey(path, key), currentValue) + } else { + currentValue.forEach((item: any, index: string) => { + _diff( + item, + preValue[index], + concatPathAndKey(path, key) + '[' + index + ']', + result + ) + }) + } + } + } else if (currentType == OBJECTTYPE) { + if ( + preType != OBJECTTYPE || + Object.keys(currentValue).length < Object.keys(preValue).length + ) { + setResult(result, concatPathAndKey(path, key), currentValue) + } else { + for (let subKey in currentValue) { + const realPath = + concatPathAndKey(path, key) + + (subKey.includes('.') ? `["${subKey}"]` : `.${subKey}`) + _diff(currentValue[subKey], preValue[subKey], realPath, result) + } + } + } + } + } + } else if (rootCurrentType == ARRAYTYPE) { + if (rootPreType != ARRAYTYPE) { + setResult(result, path, current) + } else { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + if (current.length < previous.length) { + setResult(result, path, current) + } else { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + current.forEach((item: any, index: any) => { + _diff(item, previous[index], path + '[' + index + ']', result) + }) + } + } + } else { + setResult(result, path, current) + } +} + +function concatPathAndKey(path: string, key: string | string[]) { + return key.includes('.') + ? path + `["${key}"]` + : (path == '' ? '' : path + '.') + key +} + +function getType(obj: any) { + return Object.prototype.toString.call(obj) +} + +export function update( + view: WechatMiniprogramPageOrComponent, + callback?: () => void +): void { + const patch = diffData(view.data, view._westorePrevData) + view.setData(patch, callback) + view._westorePrevData = clone(view.data) +} + +export class Store { + views: Views + data: any + private _westoreViewId: any + + constructor() { + this.views = {} + this._westoreViewId = 0 + } + + bind( + keyOrView: string | number | WechatMiniprogramPageOrComponent, + view?: WechatMiniprogramPageOrComponent + ): void { + if (arguments.length === 1) { + this.data = keyOrView.data + this.views[this._westoreViewId++] = keyOrView + } else { + //设置回 view 的 data,不然引用地址 错误 + this.data = view.data + this.views[keyOrView] = view + } + } + update(viewKey: string | number): void { + if (arguments.length === 1) { + update(this.views[viewKey]) + } else { + for (const key in this.views) { + update(this.views[key]) + } + } + } +} diff --git a/packages/westore/test/array.test.js b/packages/westore/test/array.test.js index 7fd6a97..b4686de 100644 --- a/packages/westore/test/array.test.js +++ b/packages/westore/test/array.test.js @@ -1,70 +1,83 @@ -const { diffData } = require('../index.common'); +const { diffData } = require('../dist/index.cmd') test('add item to array', () => { - expect(diffData( - { list: [{ a: 1 }, { a: 2 }] }, - { list: [{ a: 1 }] } - )).toStrictEqual({ + expect( + diffData({ list: [{ a: 1 }, { a: 2 }] }, { list: [{ a: 1 }] }) + ).toStrictEqual({ 'list[1]': { a: 2 } }) }) test('diff with null/undefined', () => { - expect(diffData( - { list: [{ a: 1 }, { a: 2 }] }, - null - )).toStrictEqual({ + expect(diffData({ list: [{ a: 1 }, { a: 2 }] }, null)).toStrictEqual({ list: [{ a: 1 }, { a: 2 }] }) }) - test('delete item from array', () => { - expect(diffData( - { list: [{ a: 1 }] }, - { list: [{ a: 1 }, { a: 2 }] } - )).toStrictEqual({ - 'list': [{ a: 1 }] + expect( + diffData({ list: [{ a: 1 }] }, { list: [{ a: 1 }, { a: 2 }] }) + ).toStrictEqual({ + list: [{ a: 1 }] }) }) - test('modify item of array', () => { - expect(diffData( - { list: [{ a: 1 }] }, - { list: [{ a: 2 }] } - )).toStrictEqual({ + expect(diffData({ list: [{ a: 1 }] }, { list: [{ a: 2 }] })).toStrictEqual({ 'list[0].a': 1 }) }) test('modify item of array', () => { - expect(diffData( - { list: [{ a: 1 }] }, - { list: [{ a: 2 }] } - )).toStrictEqual({ + expect(diffData({ list: [{ a: 1 }] }, { list: [{ a: 2 }] })).toStrictEqual({ 'list[0].a': 1 }) }) test('modify item of array & update props', () => { - expect(diffData( - { list: [{ a: 1 }], a: 1 }, - { list: [{ a: 2 }], a: 2 } - )).toStrictEqual({ + expect( + diffData({ list: [{ a: 1 }], a: 1 }, { list: [{ a: 2 }], a: 2 }) + ).toStrictEqual({ 'list[0].a': 1, a: 1 }) }) test('complex ', () => { - expect(diffData( - { a: 1, b: 2, c: "str", d: { e: [2, { a: 4 }, 5] }, f: true, h: [1], g: { a: [1, 2], j: 111 } }, - { - a: [], b: "aa", c: 3, d: { e: [3, { a: 3 }] }, f: false, h: [1, 2], g: { a: [1, 1, 1], i: "delete" }, k: 'del' - } - )).toStrictEqual({ "a": 1, "b": 2, "c": "str", "d.e[0]": 2, "d.e[1].a": 4, "d.e[2]": 5, "f": true, "h": [1], "g.a": [1, 2], "g.j": 111, "g.i": null, "k": null } - ) + expect( + diffData( + { + a: 1, + b: 2, + c: 'str', + d: { e: [2, { a: 4 }, 5] }, + f: true, + h: [1], + g: { a: [1, 2], j: 111 } + }, + { + a: [], + b: 'aa', + c: 3, + d: { e: [3, { a: 3 }] }, + f: false, + h: [1, 2], + g: { a: [1, 1, 1], i: 'delete' }, + k: 'del' + } + ) + ).toStrictEqual({ + a: 1, + b: 2, + c: 'str', + 'd.e[0]': 2, + 'd.e[1].a': 4, + 'd.e[2]': 5, + f: true, + h: [1], + 'g.a': [1, 2], + 'g.j': 111, + 'g.i': null, + k: null + }) }) - - diff --git a/packages/westore/test/base.test.js b/packages/westore/test/base.test.js index 01be6dc..c58656f 100644 --- a/packages/westore/test/base.test.js +++ b/packages/westore/test/base.test.js @@ -1,89 +1,78 @@ -const { diffData } = require('../index.common'); - +const { diffData } = require('../dist/index.cmd') test('same props', () => { - expect(diffData( - { a: 1 }, - { a: 1 } - )).toStrictEqual({ - - }) + expect(diffData({ a: 1 }, { a: 1 })).toStrictEqual({}) }) test('update props', () => { - expect(diffData( - { a: 1 }, - { a: 2 } - )).toStrictEqual({ + expect(diffData({ a: 1 }, { a: 2 })).toStrictEqual({ a: 1 }) }) test('delete props', () => { - expect(diffData( - { a: 1 }, - { a: 1, b: 2 } - )).toStrictEqual({ + expect(diffData({ a: 1 }, { a: 1, b: 2 })).toStrictEqual({ b: null }) }) test('add props', () => { - expect(diffData( - { a: 1, b: 2 }, - { a: 1 } - )).toStrictEqual({ + expect(diffData({ a: 1, b: 2 }, { a: 1 })).toStrictEqual({ b: 2 }) }) - test('update deep props', () => { - expect(diffData( - { user: { name: 'dnt', age: 18 } }, - { user: { name: 'dnt', age: 20 } }, - )).toStrictEqual({ + expect( + diffData( + { user: { name: 'dnt', age: 18 } }, + { user: { name: 'dnt', age: 20 } } + ) + ).toStrictEqual({ 'user.age': 18 }) }) test('update deep props', () => { - expect(diffData( - { user: { name: 'dnt2', age: 18 } }, - { user: { name: 'dnt', age: 20 } }, - )).toStrictEqual({ + expect( + diffData( + { user: { name: 'dnt2', age: 18 } }, + { user: { name: 'dnt', age: 20 } } + ) + ).toStrictEqual({ 'user.age': 18, 'user.name': 'dnt2' }) }) test('add deep props', () => { - expect(diffData( - { user: { name: 'dnt', age: 18 } }, - { user: { name: 'dnt', } }, - )).toStrictEqual({ + expect( + diffData({ user: { name: 'dnt', age: 18 } }, { user: { name: 'dnt' } }) + ).toStrictEqual({ 'user.age': 18 }) }) test('add deep props', () => { - expect(diffData( - { user: { name: 'dnt', age: 18, sex: 1 } }, - { user: { name: 'dnt', } }, - )).toStrictEqual({ + expect( + diffData( + { user: { name: 'dnt', age: 18, sex: 1 } }, + { user: { name: 'dnt' } } + ) + ).toStrictEqual({ 'user.age': 18, 'user.sex': 1 }) }) - test('delete deep props', () => { - expect(diffData( - { user: { name: 'dnt' } }, - { user: { name: 'dnt', age: 18, sex: 1 } }, - )).toStrictEqual({ + expect( + diffData( + { user: { name: 'dnt' } }, + { user: { name: 'dnt', age: 18, sex: 1 } } + ) + ).toStrictEqual({ 'user.age': null, 'user.sex': null }) }) - diff --git a/packages/westore/tsconfig.json b/packages/westore/tsconfig.json new file mode 100644 index 0000000..9cac7c0 --- /dev/null +++ b/packages/westore/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compileOnSave": true, + "compilerOptions": { + "target": "ES2018", + "module": "esnext", + "moduleResolution": "node", + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "allowSyntheticDefaultImports": true, + "inlineSourceMap": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "stripInternal": true, + "pretty": true, + "declaration": true, + "outDir": "dist", + "baseUrl": "./", + "paths": { + "*": ["src/*"] + } + }, + "exclude": ["lib", "node_modules"] +}