-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
1 lines (1 loc) · 2.74 KB
/
index.js
1
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue-demi")):"function"==typeof define&&define.amd?define(["exports","vue-demi"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VueFort={},e.VueDemi)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(){}function f(e){return!(!e||!0!==e.$isEffect)}let i,o=new WeakMap;function c(e){return o.has(e)}function u(e){return!!(e&&e.$effectScope&&c(e.$effectScope))}function s(e){if(f(e)){let{stop:t}=e;return t()}if(c(e)){let{stop:t}=o.get(e);return t()}return function(e){return!!(e&&e.$effect&&f(e.$effect))}(e)?s(e.$effect):u(e)?s(e.$effectScope):void 0}function a(e){if(i){let{effects:t}=o.get(i);t.add(e)}else t.getCurrentInstance()&&t.onUnmounted((()=>{s(e)}))}function l(e){let t=[],n=e=>{t.push(e)},r={},f=new Set,c=e=>{if(e){let t=i;i=r;try{Object.assign(r,e(n))}finally{i=t}}return r};return o.set(r,{effects:f,extend:c,stop(){f.forEach((e=>{s(e)})),t.forEach((e=>{e()}))}}),a(r),c(e),r}function d(e,t){if(c(e)){let{extend:n}=o.get(e);return n(t)}if(u(e))return d(e.$effectScope,t)}function p(e){if(e){let t=typeof e;return"object"===t||"function"===t}return!1}function b(e){return e.startsWith("_")}function h(e,t,n){t.startsWith("$")||t in e||Object.defineProperty(e,t,{configurable:!1,enumerable:!b(t),...n})}function v(e,f){void 0!==f&&p(f)&&Object.entries(f).forEach((([f,i])=>{n(i)&&(i=function(e){let f,i;n(e)?(f=e,i=r):({get:f,set:i}=e);let o,c=!0;return a({$isEffect:!0,stop(){c=!1}}),t.computed({get:()=>(c&&(o=f()),o),set:i})}(i.bind(e)),h(e,f,{get:()=>i.value}))}))}function g(e,t){void 0!==t&&p(t)&&Object.keys(t).forEach((n=>{h(e,n,{get:()=>t[n],set(e){t[n]=e}})}))}var y=Array.isArray;function $(e){return"string"==typeof e}function j(e,r){void 0!==r&&p(r)&&Object.entries(r).forEach((([r,f])=>{let i=(t=>{let n=t.split(".");return 1===n.length?()=>e[t]:()=>function(e,t){return t.forEach((t=>{e=e[t]})),e}(e,n)})(r);var o;o=r=>{let f,o;$(r)?f=e[r]:n(r)?f=r.bind(e):p(r)&&(({handler:r,...o}=r),$(r)?f=e[r]:n(r)&&(f=r.bind(e))),function(...e){let n=t.watch(...e);a({$isEffect:!0,stop:n})}(i,f,o)},y(f)?f.forEach(o):o(f)}))}e.createInstance=function({state:e,getters:r,watch:f,methods:i,bind:o=!0}={}){let a=!1,b=((e,t)=>{if(!0===e)return l(t);if(c(e)||u(e)){let n;return d(e,(()=>{n=l(t)})),n}})(o,(e=>{e((()=>{a=!0}))})),y=Object.create(null);return Object.defineProperties(y,{$effectScope:{value:b},$destroy:{value(){s(b)}},$isDestroyed:{get:()=>a}}),d(b,(()=>{var o,c;v(y,r),o=y,void 0!==(c=i)&&p(c)&&Object.entries(c).forEach((([e,t])=>{n(t)&&h(o,e,{value:t.bind(o)})})),function(e,r){void 0!==r&&(n(r)?void 0!==(r=r.call(e))&&p(r)&&g(e,r=t.reactive(r)):p(r)&&g(e,r=t.reactive(r)))}(y,e),j(y,f)})),y},Object.defineProperty(e,"__esModule",{value:!0})}));