@i.un/libs
Advanced tools
Comparing version 0.0.20 to 0.0.21
@@ -25,1 +25,12 @@ /** | ||
export declare function delayExecution<T>(callback: () => T, delay?: number): Promise<T>; | ||
type Property<T> = T | symbol; | ||
type ProxyObject<T> = Record<string, Property<T>>; | ||
/** | ||
* 创建一个代理对象,当访问未初始化的属性时返回默认值。 | ||
* | ||
* @template T - 属性值的类型 | ||
* @param {Property<T>} defaultValue - 未初始化属性的默认值,可以是 T 类型或 symbol | ||
* @returns {ProxyObject<T>} - 具有默认值逻辑的代理对象 | ||
*/ | ||
export declare function createDefaultObject<T>(defaultValue: Property<T>): ProxyObject<T>; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
function t(t){return"function"==typeof(null==t?void 0:t.clone)}function e(t){const e=typeof t;return null===t||"string"===e||"number"===e||"boolean"===e||"undefined"===e}function n(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this}function r(t){return e(t)?String(t):JSON.stringify(t,function(t,e){return"object"!=typeof e||null===e||Array.isArray(e)?e:Object.keys(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})})}function o(e){if(null===e||"object"!=typeof e)return e;if(t(e))return e.clone();if(Array.isArray(e))return e.map(t=>o(t));const n={};for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=o(e[t]));return n}function i(t,e){let n=null;return function(...r){const o=this;null!==n&&clearTimeout(n),n=setTimeout(()=>{t.apply(o,r),n=null},e)}}function s(t,e){let n=0;return function(...r){const o=Date.now();o-n>=e&&(t.apply(this,r),n=o)}}function c(t,e=0){return new Promise(n=>{0===e?n(t()):setTimeout(()=>{n(t())},e)})}const u={};function l(t){return u[t]}const a={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function f(t,e=a){return function(...n){const i=r(n)+t.name+(e.identifier||"");if(u[i])return Promise.resolve(o(l(i)));const s=i+"_l_o_a_d_i_n_g_";if(u[s]){const t=Object.assign({},a,e);return new Promise(e=>{const n=Date.now(),r=setInterval(()=>{u[i]?(clearInterval(r),e(o(l(i)))):Date.now()-n>t.timeout&&(u[s]=!1,clearInterval(r),e(o(t.timeoutResult)))},100)})}return u[s]=!0,t(...n).then(t=>(u[i]=t,o(u[i]))).catch(t=>{throw t}).finally(()=>{u[s]=!1})}}function d(t,e=0){const n=function n(...r){if(n.isExecuting)return void console.log(`Function(${t.name}) is executing.`);n.isExecuting=!0;const o=performance.now();let i;function s(){const t=performance.now()-o;e&&e>t?setTimeout(()=>{n.isExecuting=!1},e-t):n.isExecuting=!1}try{i=t.apply(this,r),i instanceof Promise?i.finally(()=>{s()}):s()}catch(t){throw s(),t}return i};return n.isExecuting=!1,n}function p(t,e,n,r=!1){if(e in t.style)t.style[e]=n;else{const o=r?"important":"";t.style.setProperty(e,String(n),o)}}function y({tag:t="div",children:e=[],props:n={},attrs:r={},styles:o={}}={}){const i=document.createElement(t);Object.assign(i,n);for(const[t,e]of Object.entries(r))!1!==e&&i.setAttribute(t,e);for(const[t,e]of Object.entries(o))p(i,t,e);const s=Array.isArray(e)?e:[e];for(const t of s)t&&("object"==typeof t?t instanceof Element?i.appendChild(t):i.appendChild(y(t)):i.appendChild(document.createTextNode(t)));return i}function m(t){const e=document.createElementNS("http://www.w3.org/2000/svg",t.type);if(t.props)for(const[n,r]of Object.entries(t.props))e.setAttribute(n,r);if("string"==typeof t.children){const n=document.createTextNode(t.children);e.appendChild(n)}else Array.isArray(t.children)&&t.children.forEach(t=>{const n=m(t);e.appendChild(n)});return e}function g(t){const e=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!(e instanceof SVGElement))throw new Error("解析失败,结果不是有效的 SVG 元素");return e}function h(t){return"string"==typeof t?g(t):m(t)}async function w(t){try{const e=await fetch(t);if(!e.ok)throw new Error(`网络请求失败: ${e.status} ${e.statusText}`);return g(await e.text())}catch(t){const e=t instanceof Error?t.message:"未知错误";throw new Error(`无法创建 SVG 元素: ${e}`)}}function b(t){t&&setTimeout(()=>{t.scrollTop=t.scrollHeight},0)}function E(t){t&&("true"!==t.dataset.isListeningForUserScroll&&(function(t){t&&t.addEventListener("scroll",()=>{!function(t,e){t.dataset.userInteracted=e?"true":"false"}(t,t.scrollTop+t.clientHeight<t.scrollHeight-5)})}(t),t.dataset.isListeningForUserScroll="true"),"true"!==t.dataset.userInteracted&&b(t))}export{f as cacheWrapper,o as cloneDeep,y as createElement,h as createSvg,g as createSvgFromString,w as createSvgFromUrl,m as createSvgFromVNode,i as debounce,c as delayExecution,r as generateStableUniqueKey,n as getGlobal,t as isCloneable,e as isPrimitive,b as scrollToBottom,E as scrollToBottomIfNeeded,d as singleExecutionWrapper,s as throttle}; | ||
function t(t){return"function"==typeof(null==t?void 0:t.clone)}function e(t){const e=typeof t;return null===t||"string"===e||"number"===e||"boolean"===e||"undefined"===e}function n(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this}function r(t){return e(t)?String(t):JSON.stringify(t,function(t,e){return"object"!=typeof e||null===e||Array.isArray(e)?e:Object.keys(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})})}function o(e){if(null===e||"object"!=typeof e)return e;if(t(e))return e.clone();if(Array.isArray(e))return e.map(t=>o(t));const n={};for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=o(e[t]));return n}function i(t,e){let n=null;return function(...r){const o=this;null!==n&&clearTimeout(n),n=setTimeout(()=>{t.apply(o,r),n=null},e)}}function c(t,e){let n=0;return function(...r){const o=Date.now();o-n>=e&&(t.apply(this,r),n=o)}}function s(t,e=0){return new Promise(n=>{0===e?n(t()):setTimeout(()=>{n(t())},e)})}function u(t){return new Proxy({},{get:(e,n)=>n in e?e[n]:t})}const l=Symbol("cacheDefaultValue"),a=u(l);function f(t){return a[t]}function d(t){return a[t]!==l}const p={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function y(t,e=p){return function(...n){const i=r(n)+t.name+(e.identifier||"");if(d(i))return Promise.resolve(o(f(i)));const c=i+"_l_o_a_d_i_n_g_";if(a[c]){const t=Object.assign({},p,e);return new Promise(e=>{const n=Date.now(),r=setInterval(()=>{d(i)?(clearInterval(r),e(o(f(i)))):Date.now()-n>t.timeout&&(a[c]=!1,clearInterval(r),e(o(t.timeoutResult)))},100)})}return a[c]=!0,t(...n).then(t=>(a[i]=t,o(a[i]))).catch(t=>{throw t}).finally(()=>{a[c]=!1})}}function m(t,e=0){const n=function n(...r){if(n.isExecuting)return void console.log(`Function(${t.name}) is executing.`);n.isExecuting=!0;const o=performance.now();let i;function c(){const t=performance.now()-o;e&&e>t?setTimeout(()=>{n.isExecuting=!1},e-t):n.isExecuting=!1}try{i=t.apply(this,r),i instanceof Promise?i.finally(()=>{c()}):c()}catch(t){throw c(),t}return i};return n.isExecuting=!1,n}function g(t,e,n,r=!1){if(e in t.style)t.style[e]=n;else{const o=r?"important":"";t.style.setProperty(e,String(n),o)}}function h({tag:t="div",children:e=[],props:n={},attrs:r={},styles:o={}}={}){const i=document.createElement(t);Object.assign(i,n);for(const[t,e]of Object.entries(r))!1!==e&&i.setAttribute(t,e);for(const[t,e]of Object.entries(o))g(i,t,e);const c=Array.isArray(e)?e:[e];for(const t of c)t&&("object"==typeof t?t instanceof Element?i.appendChild(t):i.appendChild(h(t)):i.appendChild(document.createTextNode(t)));return i}function w(t){const e=document.createElementNS("http://www.w3.org/2000/svg",t.type);if(t.props)for(const[n,r]of Object.entries(t.props))e.setAttribute(n,r);if("string"==typeof t.children){const n=document.createTextNode(t.children);e.appendChild(n)}else Array.isArray(t.children)&&t.children.forEach(t=>{const n=w(t);e.appendChild(n)});return e}function b(t){const e=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!(e instanceof SVGElement))throw new Error("解析失败,结果不是有效的 SVG 元素");return e}function E(t){return"string"==typeof t?b(t):w(t)}async function x(t){try{const e=await fetch(t);if(!e.ok)throw new Error(`网络请求失败: ${e.status} ${e.statusText}`);return b(await e.text())}catch(t){const e=t instanceof Error?t.message:"未知错误";throw new Error(`无法创建 SVG 元素: ${e}`)}}function T(t){t&&setTimeout(()=>{t.scrollTop=t.scrollHeight},0)}function S(t){t&&("true"!==t.dataset.isListeningForUserScroll&&(function(t){t&&t.addEventListener("scroll",()=>{!function(t,e){t.dataset.userInteracted=e?"true":"false"}(t,t.scrollTop+t.clientHeight<t.scrollHeight-5)})}(t),t.dataset.isListeningForUserScroll="true"),"true"!==t.dataset.userInteracted&&T(t))}export{y as cacheWrapper,o as cloneDeep,u as createDefaultObject,h as createElement,E as createSvg,b as createSvgFromString,x as createSvgFromUrl,w as createSvgFromVNode,i as debounce,s as delayExecution,r as generateStableUniqueKey,n as getGlobal,t as isCloneable,e as isPrimitive,T as scrollToBottom,S as scrollToBottomIfNeeded,m as singleExecutionWrapper,c as throttle}; | ||
//# sourceMappingURL=index.modern.js.map |
@@ -1,2 +0,2 @@ | ||
function t(t){return"function"==typeof(null==t?void 0:t.clone)}function e(t){var e=typeof t;return null===t||"string"===e||"number"===e||"boolean"===e||"undefined"===e}function n(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this}function r(t){return e(t)?String(t):JSON.stringify(t,function(t,e){return"object"!=typeof e||null===e||Array.isArray(e)?e:Object.keys(e).sort().reduce(function(t,n){return t[n]=e[n],t},{})})}function i(e){if(null===e||"object"!=typeof e)return e;if(t(e))return e.clone();if(Array.isArray(e))return e.map(function(t){return i(t)});var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=i(e[r]));return n}function o(t,e){var n=null;return function(){var r=arguments,i=this;null!==n&&clearTimeout(n),n=setTimeout(function(){t.apply(i,[].slice.call(r)),n=null},e)}}function a(t,e){var n=0;return function(){var r=Date.now();r-n>=e&&(t.apply(this,[].slice.call(arguments)),n=r)}}function u(t,e){return void 0===e&&(e=0),new Promise(function(n){0===e?n(t()):setTimeout(function(){n(t())},e)})}var c={};function l(t){return c[t]}var s={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function f(t,e){return void 0===e&&(e=s),function(){var n=[].slice.call(arguments),o=r(n)+t.name+(e.identifier||"");if(c[o])return Promise.resolve(i(l(o)));var a=o+"_l_o_a_d_i_n_g_";if(c[a]){var u=Object.assign({},s,e);return new Promise(function(t){var e=Date.now(),n=setInterval(function(){c[o]?(clearInterval(n),t(i(l(o)))):Date.now()-e>u.timeout&&(c[a]=!1,clearInterval(n),t(i(u.timeoutResult)))},100)})}return c[a]=!0,t.apply(void 0,n).then(function(t){return c[o]=t,i(c[o])}).catch(function(t){throw t}).finally(function(){c[a]=!1})}}function d(t,e){void 0===e&&(e=0);var n=function(){if(!n.isExecuting){n.isExecuting=!0;var r,i=performance.now();try{(r=t.apply(this,[].slice.call(arguments)))instanceof Promise?r.finally(function(){o()}):o()}catch(t){throw o(),t}return r}function o(){var t=performance.now()-i;e&&e>t?setTimeout(function(){n.isExecuting=!1},e-t):n.isExecuting=!1}console.log("Function("+t.name+") is executing.")};return n.isExecuting=!1,n}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function p(t,e,n,r){if(void 0===r&&(r=!1),e in t.style)t.style[e]=n;else{var i=r?"important":"";t.style.setProperty(e,String(n),i)}}var y=function(t){try{return Promise.resolve(function(e,n){try{var r=Promise.resolve(fetch(t)).then(function(t){if(!t.ok)throw new Error("网络请求失败: "+t.status+" "+t.statusText);return Promise.resolve(t.text()).then(g)})}catch(t){return n(t)}return r&&r.then?r.then(void 0,n):r}(0,function(t){var e=t instanceof Error?t.message:"未知错误";throw new Error("无法创建 SVG 元素: "+e)}))}catch(t){return Promise.reject(t)}};function m(t){var e=void 0===t?{}:t,n=e.tag,r=e.children,i=void 0===r?[]:r,o=e.props,a=void 0===o?{}:o,u=e.attrs,c=void 0===u?{}:u,l=e.styles,s=void 0===l?{}:l,f=document.createElement(void 0===n?"div":n);Object.assign(f,a);for(var d=0,y=Object.entries(c);d<y.length;d++){var h=y[d],g=h[1];!1!==g&&f.setAttribute(h[0],g)}for(var b=0,w=Object.entries(s);b<w.length;b++){var E=w[b];p(f,E[0],E[1])}for(var A,S=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,e){if(t){if("string"==typeof t)return v(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(t,e):void 0}}(t))){e&&(t=e);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(i)?i:[i]);!(A=S()).done;){var j=A.value;j&&("object"==typeof j?j instanceof Element?f.appendChild(j):f.appendChild(m(j)):f.appendChild(document.createTextNode(j)))}return f}function h(t){var e=document.createElementNS("http://www.w3.org/2000/svg",t.type);if(t.props)for(var n=0,r=Object.entries(t.props);n<r.length;n++){var i=r[n];e.setAttribute(i[0],i[1])}if("string"==typeof t.children){var o=document.createTextNode(t.children);e.appendChild(o)}else Array.isArray(t.children)&&t.children.forEach(function(t){var n=h(t);e.appendChild(n)});return e}function g(t){var e=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!(e instanceof SVGElement))throw new Error("解析失败,结果不是有效的 SVG 元素");return e}function b(t){return"string"==typeof t?g(t):h(t)}function w(t){t&&setTimeout(function(){t.scrollTop=t.scrollHeight},0)}function E(t){t&&("true"!==t.dataset.isListeningForUserScroll&&(function(t){t&&t.addEventListener("scroll",function(){!function(t,e){t.dataset.userInteracted=e?"true":"false"}(t,t.scrollTop+t.clientHeight<t.scrollHeight-5)})}(t),t.dataset.isListeningForUserScroll="true"),"true"!==t.dataset.userInteracted&&w(t))}export{f as cacheWrapper,i as cloneDeep,m as createElement,b as createSvg,g as createSvgFromString,y as createSvgFromUrl,h as createSvgFromVNode,o as debounce,u as delayExecution,r as generateStableUniqueKey,n as getGlobal,t as isCloneable,e as isPrimitive,w as scrollToBottom,E as scrollToBottomIfNeeded,d as singleExecutionWrapper,a as throttle}; | ||
function t(t){return"function"==typeof(null==t?void 0:t.clone)}function e(t){var e=typeof t;return null===t||"string"===e||"number"===e||"boolean"===e||"undefined"===e}function n(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this}function r(t){return e(t)?String(t):JSON.stringify(t,function(t,e){return"object"!=typeof e||null===e||Array.isArray(e)?e:Object.keys(e).sort().reduce(function(t,n){return t[n]=e[n],t},{})})}function o(e){if(null===e||"object"!=typeof e)return e;if(t(e))return e.clone();if(Array.isArray(e))return e.map(function(t){return o(t)});var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=o(e[r]));return n}function i(t,e){var n=null;return function(){var r=arguments,o=this;null!==n&&clearTimeout(n),n=setTimeout(function(){t.apply(o,[].slice.call(r)),n=null},e)}}function u(t,e){var n=0;return function(){var r=Date.now();r-n>=e&&(t.apply(this,[].slice.call(arguments)),n=r)}}function a(t,e){return void 0===e&&(e=0),new Promise(function(n){0===e?n(t()):setTimeout(function(){n(t())},e)})}function c(t){return new Proxy({},{get:function(e,n){return n in e?e[n]:t}})}var l=Symbol("cacheDefaultValue"),s=c(l);function f(t){return s[t]}function d(t){return s[t]!==l}var v={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function p(t,e){return void 0===e&&(e=v),function(){var n=[].slice.call(arguments),i=r(n)+t.name+(e.identifier||"");if(d(i))return Promise.resolve(o(f(i)));var u=i+"_l_o_a_d_i_n_g_";if(s[u]){var a=Object.assign({},v,e);return new Promise(function(t){var e=Date.now(),n=setInterval(function(){d(i)?(clearInterval(n),t(o(f(i)))):Date.now()-e>a.timeout&&(s[u]=!1,clearInterval(n),t(o(a.timeoutResult)))},100)})}return s[u]=!0,t.apply(void 0,n).then(function(t){return s[i]=t,o(s[i])}).catch(function(t){throw t}).finally(function(){s[u]=!1})}}function y(t,e){void 0===e&&(e=0);var n=function(){if(!n.isExecuting){n.isExecuting=!0;var r,o=performance.now();try{(r=t.apply(this,[].slice.call(arguments)))instanceof Promise?r.finally(function(){i()}):i()}catch(t){throw i(),t}return r}function i(){var t=performance.now()-o;e&&e>t?setTimeout(function(){n.isExecuting=!1},e-t):n.isExecuting=!1}console.log("Function("+t.name+") is executing.")};return n.isExecuting=!1,n}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function h(t,e,n,r){if(void 0===r&&(r=!1),e in t.style)t.style[e]=n;else{var o=r?"important":"";t.style.setProperty(e,String(n),o)}}var g=function(t){try{return Promise.resolve(function(e,n){try{var r=Promise.resolve(fetch(t)).then(function(t){if(!t.ok)throw new Error("网络请求失败: "+t.status+" "+t.statusText);return Promise.resolve(t.text()).then(E)})}catch(t){return n(t)}return r&&r.then?r.then(void 0,n):r}(0,function(t){var e=t instanceof Error?t.message:"未知错误";throw new Error("无法创建 SVG 元素: "+e)}))}catch(t){return Promise.reject(t)}};function b(t){var e=void 0===t?{}:t,n=e.tag,r=e.children,o=void 0===r?[]:r,i=e.props,u=void 0===i?{}:i,a=e.attrs,c=void 0===a?{}:a,l=e.styles,s=void 0===l?{}:l,f=document.createElement(void 0===n?"div":n);Object.assign(f,u);for(var d=0,v=Object.entries(c);d<v.length;d++){var p=v[d],y=p[1];!1!==y&&f.setAttribute(p[0],y)}for(var g=0,w=Object.entries(s);g<w.length;g++){var E=w[g];h(f,E[0],E[1])}for(var A,S=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,e){if(t){if("string"==typeof t)return m(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m(t,e):void 0}}(t))){e&&(t=e);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(o)?o:[o]);!(A=S()).done;){var x=A.value;x&&("object"==typeof x?x instanceof Element?f.appendChild(x):f.appendChild(b(x)):f.appendChild(document.createTextNode(x)))}return f}function w(t){var e=document.createElementNS("http://www.w3.org/2000/svg",t.type);if(t.props)for(var n=0,r=Object.entries(t.props);n<r.length;n++){var o=r[n];e.setAttribute(o[0],o[1])}if("string"==typeof t.children){var i=document.createTextNode(t.children);e.appendChild(i)}else Array.isArray(t.children)&&t.children.forEach(function(t){var n=w(t);e.appendChild(n)});return e}function E(t){var e=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!(e instanceof SVGElement))throw new Error("解析失败,结果不是有效的 SVG 元素");return e}function A(t){return"string"==typeof t?E(t):w(t)}function S(t){t&&setTimeout(function(){t.scrollTop=t.scrollHeight},0)}function x(t){t&&("true"!==t.dataset.isListeningForUserScroll&&(function(t){t&&t.addEventListener("scroll",function(){!function(t,e){t.dataset.userInteracted=e?"true":"false"}(t,t.scrollTop+t.clientHeight<t.scrollHeight-5)})}(t),t.dataset.isListeningForUserScroll="true"),"true"!==t.dataset.userInteracted&&S(t))}export{p as cacheWrapper,o as cloneDeep,c as createDefaultObject,b as createElement,A as createSvg,E as createSvgFromString,g as createSvgFromUrl,w as createSvgFromVNode,i as debounce,a as delayExecution,r as generateStableUniqueKey,n as getGlobal,t as isCloneable,e as isPrimitive,S as scrollToBottom,x as scrollToBottomIfNeeded,y as singleExecutionWrapper,u as throttle}; | ||
//# sourceMappingURL=index.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).iunLibs={})}(this,function(e){function t(e){return"function"==typeof(null==e?void 0:e.clone)}function n(e){var t=typeof e;return null===e||"string"===t||"number"===t||"boolean"===t||"undefined"===t}function r(e){return n(e)?String(e):JSON.stringify(e,function(e,t){return"object"!=typeof t||null===t||Array.isArray(t)?t:Object.keys(t).sort().reduce(function(e,n){return e[n]=t[n],e},{})})}function o(e){if(null===e||"object"!=typeof e)return e;if(t(e))return e.clone();if(Array.isArray(e))return e.map(function(e){return o(e)});var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=o(e[r]));return n}var i={};function a(e){return i[e]}var u={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function l(e,t,n,r){if(void 0===r&&(r=!1),t in e.style)e.style[t]=n;else{var o=r?"important":"";e.style.setProperty(t,String(n),o)}}function s(e){var t=document.createElementNS("http://www.w3.org/2000/svg",e.type);if(e.props)for(var n=0,r=Object.entries(e.props);n<r.length;n++){var o=r[n];t.setAttribute(o[0],o[1])}if("string"==typeof e.children){var i=document.createTextNode(e.children);t.appendChild(i)}else Array.isArray(e.children)&&e.children.forEach(function(e){var n=s(e);t.appendChild(n)});return t}function f(e){var t=(new DOMParser).parseFromString(e,"image/svg+xml").documentElement;if(!(t instanceof SVGElement))throw new Error("解析失败,结果不是有效的 SVG 元素");return t}function d(e){e&&setTimeout(function(){e.scrollTop=e.scrollHeight},0)}e.cacheWrapper=function(e,t){return void 0===t&&(t=u),function(){var n=[].slice.call(arguments),c=r(n)+e.name+(t.identifier||"");if(i[c])return Promise.resolve(o(a(c)));var l=c+"_l_o_a_d_i_n_g_";if(i[l]){var s=Object.assign({},u,t);return new Promise(function(e){var t=Date.now(),n=setInterval(function(){i[c]?(clearInterval(n),e(o(a(c)))):Date.now()-t>s.timeout&&(i[l]=!1,clearInterval(n),e(o(s.timeoutResult)))},100)})}return i[l]=!0,e.apply(void 0,n).then(function(e){return i[c]=e,o(i[c])}).catch(function(e){throw e}).finally(function(){i[l]=!1})}},e.cloneDeep=o,e.createElement=function e(t){var n=void 0===t?{}:t,r=n.tag,o=n.children,i=void 0===o?[]:o,a=n.props,u=void 0===a?{}:a,s=n.attrs,f=void 0===s?{}:s,d=n.styles,v=void 0===d?{}:d,p=document.createElement(void 0===r?"div":r);Object.assign(p,u);for(var m=0,y=Object.entries(f);m<y.length;m++){var g=y[m],h=g[1];!1!==h&&p.setAttribute(g[0],h)}for(var b=0,w=Object.entries(v);b<w.length;b++){var S=w[b];l(p,S[0],S[1])}for(var E,x=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,t){if(e){if("string"==typeof e)return c(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(e,t):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(i)?i:[i]);!(E=x()).done;){var T=E.value;T&&("object"==typeof T?T instanceof Element?p.appendChild(T):p.appendChild(e(T)):p.appendChild(document.createTextNode(T)))}return p},e.createSvg=function(e){return"string"==typeof e?f(e):s(e)},e.createSvgFromString=f,e.createSvgFromUrl=function(e){try{return Promise.resolve(function(t,n){try{var r=Promise.resolve(fetch(e)).then(function(e){if(!e.ok)throw new Error("网络请求失败: "+e.status+" "+e.statusText);return Promise.resolve(e.text()).then(f)})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(e){var t=e instanceof Error?e.message:"未知错误";throw new Error("无法创建 SVG 元素: "+t)}))}catch(e){return Promise.reject(e)}},e.createSvgFromVNode=s,e.debounce=function(e,t){var n=null;return function(){var r=arguments,o=this;null!==n&&clearTimeout(n),n=setTimeout(function(){e.apply(o,[].slice.call(r)),n=null},t)}},e.delayExecution=function(e,t){return void 0===t&&(t=0),new Promise(function(n){0===t?n(e()):setTimeout(function(){n(e())},t)})},e.generateStableUniqueKey=r,e.getGlobal=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this},e.isCloneable=t,e.isPrimitive=n,e.scrollToBottom=d,e.scrollToBottomIfNeeded=function(e){e&&("true"!==e.dataset.isListeningForUserScroll&&(function(e){e&&e.addEventListener("scroll",function(){!function(e,t){e.dataset.userInteracted=t?"true":"false"}(e,e.scrollTop+e.clientHeight<e.scrollHeight-5)})}(e),e.dataset.isListeningForUserScroll="true"),"true"!==e.dataset.userInteracted&&d(e))},e.singleExecutionWrapper=function(e,t){void 0===t&&(t=0);var n=function(){if(!n.isExecuting){n.isExecuting=!0;var r,o=performance.now();try{(r=e.apply(this,[].slice.call(arguments)))instanceof Promise?r.finally(function(){i()}):i()}catch(e){throw i(),e}return r}function i(){var e=performance.now()-o;t&&t>e?setTimeout(function(){n.isExecuting=!1},t-e):n.isExecuting=!1}console.log("Function("+e.name+") is executing.")};return n.isExecuting=!1,n},e.throttle=function(e,t){var n=0;return function(){var r=Date.now();r-n>=t&&(e.apply(this,[].slice.call(arguments)),n=r)}}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).iunLibs={})}(this,function(e){function t(e){return"function"==typeof(null==e?void 0:e.clone)}function n(e){var t=typeof e;return null===e||"string"===t||"number"===t||"boolean"===t||"undefined"===t}function r(e){return n(e)?String(e):JSON.stringify(e,function(e,t){return"object"!=typeof t||null===t||Array.isArray(t)?t:Object.keys(t).sort().reduce(function(e,n){return e[n]=t[n],e},{})})}function o(e){if(null===e||"object"!=typeof e)return e;if(t(e))return e.clone();if(Array.isArray(e))return e.map(function(e){return o(e)});var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=o(e[r]));return n}function i(e){return new Proxy({},{get:function(t,n){return n in t?t[n]:e}})}var a=Symbol("cacheDefaultValue"),u=i(a);function c(e){return u[e]}function l(e){return u[e]!==a}var s={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function d(e,t,n,r){if(void 0===r&&(r=!1),t in e.style)e.style[t]=n;else{var o=r?"important":"";e.style.setProperty(t,String(n),o)}}function v(e){var t=document.createElementNS("http://www.w3.org/2000/svg",e.type);if(e.props)for(var n=0,r=Object.entries(e.props);n<r.length;n++){var o=r[n];t.setAttribute(o[0],o[1])}if("string"==typeof e.children){var i=document.createTextNode(e.children);t.appendChild(i)}else Array.isArray(e.children)&&e.children.forEach(function(e){var n=v(e);t.appendChild(n)});return t}function p(e){var t=(new DOMParser).parseFromString(e,"image/svg+xml").documentElement;if(!(t instanceof SVGElement))throw new Error("解析失败,结果不是有效的 SVG 元素");return t}function m(e){e&&setTimeout(function(){e.scrollTop=e.scrollHeight},0)}e.cacheWrapper=function(e,t){return void 0===t&&(t=s),function(){var n=[].slice.call(arguments),i=r(n)+e.name+(t.identifier||"");if(l(i))return Promise.resolve(o(c(i)));var a=i+"_l_o_a_d_i_n_g_";if(u[a]){var f=Object.assign({},s,t);return new Promise(function(e){var t=Date.now(),n=setInterval(function(){l(i)?(clearInterval(n),e(o(c(i)))):Date.now()-t>f.timeout&&(u[a]=!1,clearInterval(n),e(o(f.timeoutResult)))},100)})}return u[a]=!0,e.apply(void 0,n).then(function(e){return u[i]=e,o(u[i])}).catch(function(e){throw e}).finally(function(){u[a]=!1})}},e.cloneDeep=o,e.createDefaultObject=i,e.createElement=function e(t){var n=void 0===t?{}:t,r=n.tag,o=n.children,i=void 0===o?[]:o,a=n.props,u=void 0===a?{}:a,c=n.attrs,l=void 0===c?{}:c,s=n.styles,v=void 0===s?{}:s,p=document.createElement(void 0===r?"div":r);Object.assign(p,u);for(var m=0,y=Object.entries(l);m<y.length;m++){var g=y[m],h=g[1];!1!==h&&p.setAttribute(g[0],h)}for(var b=0,w=Object.entries(v);b<w.length;b++){var S=w[b];d(p,S[0],S[1])}for(var E,x=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,t){if(e){if("string"==typeof e)return f(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?f(e,t):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(i)?i:[i]);!(E=x()).done;){var T=E.value;T&&("object"==typeof T?T instanceof Element?p.appendChild(T):p.appendChild(e(T)):p.appendChild(document.createTextNode(T)))}return p},e.createSvg=function(e){return"string"==typeof e?p(e):v(e)},e.createSvgFromString=p,e.createSvgFromUrl=function(e){try{return Promise.resolve(function(t,n){try{var r=Promise.resolve(fetch(e)).then(function(e){if(!e.ok)throw new Error("网络请求失败: "+e.status+" "+e.statusText);return Promise.resolve(e.text()).then(p)})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(e){var t=e instanceof Error?e.message:"未知错误";throw new Error("无法创建 SVG 元素: "+t)}))}catch(e){return Promise.reject(e)}},e.createSvgFromVNode=v,e.debounce=function(e,t){var n=null;return function(){var r=arguments,o=this;null!==n&&clearTimeout(n),n=setTimeout(function(){e.apply(o,[].slice.call(r)),n=null},t)}},e.delayExecution=function(e,t){return void 0===t&&(t=0),new Promise(function(n){0===t?n(e()):setTimeout(function(){n(e())},t)})},e.generateStableUniqueKey=r,e.getGlobal=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this},e.isCloneable=t,e.isPrimitive=n,e.scrollToBottom=m,e.scrollToBottomIfNeeded=function(e){e&&("true"!==e.dataset.isListeningForUserScroll&&(function(e){e&&e.addEventListener("scroll",function(){!function(e,t){e.dataset.userInteracted=t?"true":"false"}(e,e.scrollTop+e.clientHeight<e.scrollHeight-5)})}(e),e.dataset.isListeningForUserScroll="true"),"true"!==e.dataset.userInteracted&&m(e))},e.singleExecutionWrapper=function(e,t){void 0===t&&(t=0);var n=function(){if(!n.isExecuting){n.isExecuting=!0;var r,o=performance.now();try{(r=e.apply(this,[].slice.call(arguments)))instanceof Promise?r.finally(function(){i()}):i()}catch(e){throw i(),e}return r}function i(){var e=performance.now()-o;t&&t>e?setTimeout(function(){n.isExecuting=!1},t-e):n.isExecuting=!1}console.log("Function("+e.name+") is executing.")};return n.isExecuting=!1,n},e.throttle=function(e,t){var n=0;return function(){var r=Date.now();r-n>=t&&(e.apply(this,[].slice.call(arguments)),n=r)}}}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "@i.un/libs", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"description": "一个实用的ts函数库", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
143272
346