omi - v6.9.0

* Add extend, get and set methods
This commit is contained in:
dntzhang 2019-08-03 22:22:43 +08:00
parent 5912990142
commit eed04e8591
15 changed files with 153 additions and 37 deletions

View File

@ -198,6 +198,10 @@ declare namespace Omi {
function extractClass(...args: any[]): object;
function o(obj: any): string;
function extend(name: string, handler: (el: HTMLElement, path: string, scope: WeElement) => void): void;
function get(obj: any, path: string): any;
function set(obj: any, path: string, value: any): void;
var options: {
vnode?: (vnode: VNode<any>) => void;
event?: (event: Event) => Event;

View File

@ -1,5 +1,5 @@
/**
* omi v6.8.2 http://omijs.org
* omi v6.9.0 http://omijs.org
* Omi === Preact + Scoped CSS + Store System + Native Support in 3kb javascript.
* By dntzhang https://github.com/dntzhang
* Github: https://github.com/Tencent/omi
@ -1292,6 +1292,34 @@
});
}
var extention = {};
function extend$1(name, handler) {
extention[name] = handler;
}
function set(origin, path, value) {
var arr = path.replace(/]/g, '').replace(/\[/g, '.').split('.');
var current = origin;
for (var i = 0, len = arr.length; i < len; i++) {
if (i === len - 1) {
current[arr[i]] = value;
} else {
current = current[arr[i]];
}
}
}
function get(origin, path) {
var arr = path.replace(/]/g, '').replace(/\[/g, '.').split('.');
var current = origin;
for (var i = 0, len = arr.length; i < len; i++) {
current = current[arr[i]];
}
return current;
}
function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn$1(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
@ -1315,6 +1343,8 @@
}
WeElement.prototype.connectedCallback = function connectedCallback() {
var _this2 = this;
var p = this.parentNode;
while (p && !this.store) {
this.store = p.store;
@ -1383,6 +1413,16 @@
}
this.installed();
this._isInstalled = true;
var _loop = function _loop(key) {
_this2.shadowRoot.querySelectorAll('[o-' + key + ']').forEach(function (node) {
extention[key](node, node.getAttribute('o-' + key), _this2);
});
};
for (var key in extention) {
_loop(key);
}
};
WeElement.prototype.disconnectedCallback = function disconnectedCallback() {
@ -1780,7 +1820,7 @@
return JSON.stringify(obj);
}
var n=function(t,r,u,e){for(var p=1;p<r.length;p++){var s=r[p],h="number"==typeof s?u[s]:s,a=r[++p];1===a?e[0]=h:3===a?e[1]=Object.assign(e[1]||{},h):5===a?(e[1]=e[1]||{})[r[++p]]=h:6===a?e[1][r[++p]]+=h+"":e.push(a?t.apply(null,n(t,h,u,["",null])):h);}return e},t=function(n){for(var t,r,u=1,e="",p="",s=[0],h=function(n){1===u&&(n||(e=e.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?s.push(n||e,0):3===u&&(n||e)?(s.push(n||e,1), u=2):2===u&&"..."===e&&n?s.push(n,3):2===u&&e&&!n?s.push(!0,5,e):u>=5&&((e||!n&&5===u)&&(s.push(e,u,r), u=6), n&&(s.push(n,u,r), u=6)), e="";},a=0;a<n.length;a++){a&&(1===u&&h(), h(a));for(var f=0;f<n[a].length;f++)t=n[a][f], 1===u?"<"===t?(h(), s=[s], u=3):e+=t:4===u?"--"===e&&">"===t?(u=1, e=""):e=t+e[0]:p?t===p?p="":e+=t:'"'===t||"'"===t?p=t:">"===t?(h(), u=1):u&&("="===t?(u=5, r=e, e=""):"/"===t&&(u<5||">"===n[a][f+1])?(h(), 3===u&&(s=s[0]), u=s, (s=s[0]).push(u,2), u=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(h(), u=2):e+=t), 3===u&&"!--"===e&&(u=4, s=s[0]);}return h(), s},r="function"==typeof Map,u=r?new Map:{},e=r?function(n){var r=u.get(n);return r||u.set(n,r=t(n)), r}:function(n){for(var r="",e=0;e<n.length;e++)r+=n[e].length+"-"+n[e];return u[r]||(u[r]=t(n))};function htm(t){var r=n(this,e(t),arguments,[]);return r.length>1?r:r[0]}
var n=function(t,r,u,e){for(var p=1;p<r.length;p++){var s=r[p++],a="number"==typeof s?u[s]:s;1===r[p]?e[0]=a:2===r[p]?(e[1]=e[1]||{})[r[++p]]=a:3===r[p]?e[1]=Object.assign(e[1]||{},a):e.push(r[p]?t.apply(null,n(t,a,u,["",null])):a);}return e},t=function(n){for(var t,r,u=1,e="",p="",s=[0],a=function(n){1===u&&(n||(e=e.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?s.push(n||e,0):3===u&&(n||e)?(s.push(n||e,1), u=2):2===u&&"..."===e&&n?s.push(n,3):2===u&&e&&!n?s.push(!0,2,e):4===u&&r&&(s.push(n||e,2,r), r=""), e="";},f=0;f<n.length;f++){f&&(1===u&&a(), a(f));for(var h=0;h<n[f].length;h++)t=n[f][h], 1===u?"<"===t?(a(), s=[s], u=3):e+=t:p?t===p?p="":e+=t:'"'===t||"'"===t?p=t:">"===t?(a(), u=1):u&&("="===t?(u=4, r=e, e=""):"/"===t?(a(), 3===u&&(s=s[0]), u=s, (s=s[0]).push(u,4), u=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(a(), u=2):e+=t);}return a(), s},r="function"==typeof Map,u=r?new Map:{},e=r?function(n){var r=u.get(n);return r||u.set(n,r=t(n)), r}:function(n){for(var r="",e=0;e<n.length;e++)r+=n[e].length+"-"+n[e];return u[r]||(u[r]=t(n))};function htm(t){var r=n(this,e(t),arguments,[]);return r.length>1?r:r[0]}
var html = htm.bind(h);
@ -1817,12 +1857,15 @@
htm: htm,
o: o,
elements: elements,
$: $
$: $,
extend: extend$1,
get: get,
set: set
};
options.root.Omi = omi;
options.root.omi = omi;
options.root.Omi.version = '6.8.2';
options.root.Omi.version = '6.9.0';
if (typeof module != 'undefined') module.exports = omi;else self.Omi = omi;
}());

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/**
* omi v6.8.2 http://omijs.org
* omi v6.9.0 http://omijs.org
* Omi === Preact + Scoped CSS + Store System + Native Support in 3kb javascript.
* By dntzhang https://github.com/dntzhang
* Github: https://github.com/Tencent/omi
@ -1289,6 +1289,34 @@ function _arrayToPath(data, path, result) {
});
}
var extention = {};
function extend$1(name, handler) {
extention[name] = handler;
}
function set(origin, path, value) {
var arr = path.replace(/]/g, '').replace(/\[/g, '.').split('.');
var current = origin;
for (var i = 0, len = arr.length; i < len; i++) {
if (i === len - 1) {
current[arr[i]] = value;
} else {
current = current[arr[i]];
}
}
}
function get(origin, path) {
var arr = path.replace(/]/g, '').replace(/\[/g, '.').split('.');
var current = origin;
for (var i = 0, len = arr.length; i < len; i++) {
current = current[arr[i]];
}
return current;
}
function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn$1(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
@ -1312,6 +1340,8 @@ var WeElement = function (_HTMLElement) {
}
WeElement.prototype.connectedCallback = function connectedCallback() {
var _this2 = this;
var p = this.parentNode;
while (p && !this.store) {
this.store = p.store;
@ -1380,6 +1410,16 @@ var WeElement = function (_HTMLElement) {
}
this.installed();
this._isInstalled = true;
var _loop = function _loop(key) {
_this2.shadowRoot.querySelectorAll('[o-' + key + ']').forEach(function (node) {
extention[key](node, node.getAttribute('o-' + key), _this2);
});
};
for (var key in extention) {
_loop(key);
}
};
WeElement.prototype.disconnectedCallback = function disconnectedCallback() {
@ -1777,7 +1817,7 @@ function o(obj) {
return JSON.stringify(obj);
}
var n=function(t,r,u,e){for(var p=1;p<r.length;p++){var s=r[p],h="number"==typeof s?u[s]:s,a=r[++p];1===a?e[0]=h:3===a?e[1]=Object.assign(e[1]||{},h):5===a?(e[1]=e[1]||{})[r[++p]]=h:6===a?e[1][r[++p]]+=h+"":e.push(a?t.apply(null,n(t,h,u,["",null])):h);}return e},t=function(n){for(var t,r,u=1,e="",p="",s=[0],h=function(n){1===u&&(n||(e=e.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?s.push(n||e,0):3===u&&(n||e)?(s.push(n||e,1), u=2):2===u&&"..."===e&&n?s.push(n,3):2===u&&e&&!n?s.push(!0,5,e):u>=5&&((e||!n&&5===u)&&(s.push(e,u,r), u=6), n&&(s.push(n,u,r), u=6)), e="";},a=0;a<n.length;a++){a&&(1===u&&h(), h(a));for(var f=0;f<n[a].length;f++)t=n[a][f], 1===u?"<"===t?(h(), s=[s], u=3):e+=t:4===u?"--"===e&&">"===t?(u=1, e=""):e=t+e[0]:p?t===p?p="":e+=t:'"'===t||"'"===t?p=t:">"===t?(h(), u=1):u&&("="===t?(u=5, r=e, e=""):"/"===t&&(u<5||">"===n[a][f+1])?(h(), 3===u&&(s=s[0]), u=s, (s=s[0]).push(u,2), u=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(h(), u=2):e+=t), 3===u&&"!--"===e&&(u=4, s=s[0]);}return h(), s},r="function"==typeof Map,u=r?new Map:{},e=r?function(n){var r=u.get(n);return r||u.set(n,r=t(n)), r}:function(n){for(var r="",e=0;e<n.length;e++)r+=n[e].length+"-"+n[e];return u[r]||(u[r]=t(n))};function htm(t){var r=n(this,e(t),arguments,[]);return r.length>1?r:r[0]}
var n=function(t,r,u,e){for(var p=1;p<r.length;p++){var s=r[p++],a="number"==typeof s?u[s]:s;1===r[p]?e[0]=a:2===r[p]?(e[1]=e[1]||{})[r[++p]]=a:3===r[p]?e[1]=Object.assign(e[1]||{},a):e.push(r[p]?t.apply(null,n(t,a,u,["",null])):a);}return e},t=function(n){for(var t,r,u=1,e="",p="",s=[0],a=function(n){1===u&&(n||(e=e.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?s.push(n||e,0):3===u&&(n||e)?(s.push(n||e,1), u=2):2===u&&"..."===e&&n?s.push(n,3):2===u&&e&&!n?s.push(!0,2,e):4===u&&r&&(s.push(n||e,2,r), r=""), e="";},f=0;f<n.length;f++){f&&(1===u&&a(), a(f));for(var h=0;h<n[f].length;h++)t=n[f][h], 1===u?"<"===t?(a(), s=[s], u=3):e+=t:p?t===p?p="":e+=t:'"'===t||"'"===t?p=t:">"===t?(a(), u=1):u&&("="===t?(u=4, r=e, e=""):"/"===t?(a(), 3===u&&(s=s[0]), u=s, (s=s[0]).push(u,4), u=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(a(), u=2):e+=t);}return a(), s},r="function"==typeof Map,u=r?new Map:{},e=r?function(n){var r=u.get(n);return r||u.set(n,r=t(n)), r}:function(n){for(var r="",e=0;e<n.length;e++)r+=n[e].length+"-"+n[e];return u[r]||(u[r]=t(n))};function htm(t){var r=n(this,e(t),arguments,[]);return r.length>1?r:r[0]}
var html = htm.bind(h);
@ -1814,13 +1854,16 @@ var omi = {
htm: htm,
o: o,
elements: elements,
$: $
$: $,
extend: extend$1,
get: get,
set: set
};
options.root.Omi = omi;
options.root.omi = omi;
options.root.Omi.version = '6.8.2';
options.root.Omi.version = '6.9.0';
export default omi;
export { tag, WeElement, Component, render, h, h as createElement, options, define, observe, cloneElement, getHost, rpx, tick, nextTick, ModelView, defineElement, classNames, extractClass, createRef, html, htm, o, elements, $ };
export { tag, WeElement, Component, render, h, h as createElement, options, define, observe, cloneElement, getHost, rpx, tick, nextTick, ModelView, defineElement, classNames, extractClass, createRef, html, htm, o, elements, $, extend$1 as extend, get, set };
//# sourceMappingURL=omi.esm.js.map

File diff suppressed because one or more lines are too long

View File

@ -470,6 +470,20 @@
if ('[object Object]' === type) _objToPath(item, path + '[' + index + ']', result); else if ('[object Array]' === type) _arrayToPath(item, path + '[' + index + ']', result);
});
}
function extend$1(name, handler) {
extention[name] = handler;
}
function set(origin, path, value) {
var arr = path.replace(/]/g, '').replace(/\[/g, '.').split('.');
var current = origin;
for (var i = 0, len = arr.length; i < len; i++) if (i === len - 1) current[arr[i]] = value; else current = current[arr[i]];
}
function get(origin, path) {
var arr = path.replace(/]/g, '').replace(/\[/g, '.').split('.');
var current = origin;
for (var i = 0, len = arr.length; i < len; i++) current = current[arr[i]];
return current;
}
function _classCallCheck$1(instance, Constructor) {
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
}
@ -875,6 +889,7 @@
}();
var callbacks = [];
var nextTickCallback = [];
var extention = {};
var id = 0;
var WeElement = function(_HTMLElement) {
function WeElement() {
@ -887,6 +902,7 @@
}
_inherits$1(WeElement, _HTMLElement);
WeElement.prototype.connectedCallback = function() {
var _this2 = this;
var p = this.parentNode;
while (p && !this.store) {
this.store = p.store;
@ -932,6 +948,11 @@
}); else shadowRoot.appendChild(this.rootNode);
this.installed();
this.B = !0;
for (var key in extention) !function(key) {
_this2.shadowRoot.querySelectorAll('[o-' + key + ']').forEach(function(node) {
extention[key](node, node.getAttribute('o-' + key), _this2);
});
}(key);
};
WeElement.prototype.disconnectedCallback = function() {
this.uninstall();
@ -1037,24 +1058,22 @@
var hasOwn = {}.hasOwnProperty;
var n = function(t, r, u, e) {
for (var p = 1; p < r.length; p++) {
var s = r[p], h = "number" == typeof s ? u[s] : s, a = r[++p];
1 === a ? e[0] = h : 3 === a ? e[1] = Object.assign(e[1] || {}, h) : 5 === a ? (e[1] = e[1] || {})[r[++p]] = h : 6 === a ? e[1][r[++p]] += h + "" : e.push(a ? t.apply(null, n(t, h, u, [ "", null ])) : h);
var s = r[p++], a = "number" == typeof s ? u[s] : s;
1 === r[p] ? e[0] = a : 2 === r[p] ? (e[1] = e[1] || {})[r[++p]] = a : 3 === r[p] ? e[1] = Object.assign(e[1] || {}, a) : e.push(r[p] ? t.apply(null, n(t, a, u, [ "", null ])) : a);
}
return e;
}, t = function(n) {
for (var t, r, u = 1, e = "", p = "", s = [ 0 ], h = function(n) {
for (var t, r, u = 1, e = "", p = "", s = [ 0 ], a = function(n) {
1 === u && (n || (e = e.replace(/^\s*\n\s*|\s*\n\s*$/g, ""))) ? s.push(n || e, 0) : 3 === u && (n || e) ? (s.push(n || e, 1),
u = 2) : 2 === u && "..." === e && n ? s.push(n, 3) : 2 === u && e && !n ? s.push(!0, 5, e) : u >= 5 && ((e || !n && 5 === u) && (s.push(e, u, r),
u = 6), n && (s.push(n, u, r), u = 6)), e = "";
}, a = 0; a < n.length; a++) {
a && (1 === u && h(), h(a));
for (var f = 0; f < n[a].length; f++) t = n[a][f], 1 === u ? "<" === t ? (h(), s = [ s ], u = 3) : e += t : 4 === u ? "--" === e && ">" === t ? (u = 1,
e = "") : e = t + e[0] : p ? t === p ? p = "" : e += t : '"' === t || "'" === t ? p = t : ">" === t ? (h(), u = 1) : u && ("=" === t ? (u = 5,
r = e, e = "") : "/" === t && (u < 5 || ">" === n[a][f + 1]) ? (h(), 3 === u && (s = s[0]), u = s, (s = s[0]).push(u, 2),
u = 0) : " " === t || "\t" === t || "\n" === t || "\r" === t ? (h(), u = 2) : e += t), 3 === u && "!--" === e && (u = 4,
s = s[0]);
u = 2) : 2 === u && "..." === e && n ? s.push(n, 3) : 2 === u && e && !n ? s.push(!0, 2, e) : 4 === u && r && (s.push(n || e, 2, r),
r = ""), e = "";
}, f = 0; f < n.length; f++) {
f && (1 === u && a(), a(f));
for (var h = 0; h < n[f].length; h++) t = n[f][h], 1 === u ? "<" === t ? (a(), s = [ s ], u = 3) : e += t : p ? t === p ? p = "" : e += t : '"' === t || "'" === t ? p = t : ">" === t ? (a(),
u = 1) : u && ("=" === t ? (u = 4, r = e, e = "") : "/" === t ? (a(), 3 === u && (s = s[0]), u = s, (s = s[0]).push(u, 4),
u = 0) : " " === t || "\t" === t || "\n" === t || "\r" === t ? (a(), u = 2) : e += t);
}
return h(), s;
return a(), s;
}, r = "function" == typeof Map, u = r ? new Map() : {}, e = r ? function(n) {
var r = u.get(n);
return r || u.set(n, r = t(n)), r;
@ -1091,11 +1110,14 @@
htm: htm,
o: o,
elements: elements,
$: $
$: $,
extend: extend$1,
get: get,
set: set
};
options.root.Omi = omi;
options.root.omi = omi;
options.root.Omi.version = '6.8.2';
options.root.Omi.version = '6.9.0';
if ('undefined' != typeof module) module.exports = omi; else self.Omi = omi;
}();
//# sourceMappingURL=omi.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1293,8 +1293,8 @@
var extention = {};
function extend$1(name, options) {
extention[name] = options;
function extend$1(name, handler) {
extention[name] = handler;
}
function set(origin, path, value) {
@ -1863,7 +1863,7 @@
options.root.Omi = omi;
options.root.omi = omi;
options.root.Omi.version = '6.8.2';
options.root.Omi.version = '6.9.0';
function _classCallCheck$3(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "omi",
"version": "6.8.2",
"version": "6.9.0",
"description": "Front End Cross-Frameworks Framework.",
"main": "dist/omi.js",
"jsnext:main": "dist/omi.esm.js",

View File

@ -1,7 +1,7 @@
export const extention = {}
export function extend(name, options) {
extention[name] = options
export function extend(name, handler) {
extention[name] = handler
}
export function set(origin, path, value) {

View File

@ -198,6 +198,10 @@ declare namespace Omi {
function extractClass(...args: any[]): object;
function o(obj: any): string;
function extend(name: string, handler: (el: HTMLElement, path: string, scope: WeElement) => void): void;
function get(obj: any, path: string): any;
function set(obj: any, path: string, value: any): void;
var options: {
vnode?: (vnode: VNode<any>) => void;
event?: (event: Event) => Event;

View File

@ -58,7 +58,7 @@ const omi = {
options.root.Omi = omi
options.root.omi = omi
options.root.Omi.version = '6.8.2'
options.root.Omi.version = '6.9.0'
export default omi