UNPKG

@stories-js/core

Version:

Stories web components to build stories

5 lines 2.32 kB
/*! * (C) StoriesJS https://storiesjs.org - GPL-2.0 License */ import{e,f as t}from"./p-dea5a230.js";const n=(e,t,n)=>{const o=e.get(t);if(!o){e.set(t,[n])}else if(!o.includes(n)){o.push(n)}};const o=(e,t)=>{let n;return(...o)=>{if(n){clearTimeout(n)}n=setTimeout((()=>{n=0;e(...o)}),t)}};const s=e=>!("isConnected"in e)||e.isConnected;const r=o((e=>{for(let t of e.keys()){e.set(t,e.get(t).filter(s))}}),2e3);const c=()=>{if(typeof e!=="function"){return{}}const o=new Map;return{dispose:()=>o.clear(),get:t=>{const s=e();if(s){n(o,t,s)}},set:e=>{const n=o.get(e);if(n){o.set(e,n.filter(t))}r(o)},reset:()=>{o.forEach((e=>e.forEach(t)));r(o)}}};const i=(e,t=((e,t)=>e!==t))=>{let n=new Map(Object.entries(e!==null&&e!==void 0?e:{}));const o={dispose:[],get:[],set:[],reset:[]};const s=()=>{n=new Map(Object.entries(e!==null&&e!==void 0?e:{}));o.reset.forEach((e=>e()))};const r=()=>{o.dispose.forEach((e=>e()));s()};const c=e=>{o.get.forEach((t=>t(e)));return n.get(e)};const i=(e,s)=>{const r=n.get(e);if(t(s,r,e)){n.set(e,s);o.set.forEach((t=>t(e,s,r)))}};const f=typeof Proxy==="undefined"?{}:new Proxy(e,{get(e,t){return c(t)},ownKeys(e){return Array.from(n.keys())},getOwnPropertyDescriptor(){return{enumerable:true,configurable:true}},has(e,t){return n.has(t)},set(e,t,n){i(t,n);return true}});const a=(e,t)=>{o[e].push(t);return()=>{u(o[e],t)}};const l=(t,n)=>{const o=a("set",((e,o)=>{if(e===t){n(o)}}));const s=a("reset",(()=>n(e[t])));return()=>{o();s()}};const d=(...e)=>{const t=e.reduce(((e,t)=>{if(t.set){e.push(a("set",t.set))}if(t.get){e.push(a("get",t.get))}if(t.reset){e.push(a("reset",t.reset))}if(t.dispose){e.push(a("dispose",t.dispose))}return e}),[]);return()=>t.forEach((e=>e()))};const p=e=>{const t=n.get(e);o.set.forEach((n=>n(e,t,t)))};return{state:f,get:c,set:i,on:a,onChange:l,use:d,dispose:r,reset:s,forceUpdate:p}};const u=(e,t)=>{const n=e.indexOf(t);if(n>=0){e[n]=e[e.length-1];e.length--}};const f=(e,t)=>{const n=i(e,t);n.use(c());return n};function a(e){return f(e)}const l=a({stories:{},story:undefined,context:undefined,notifications:[],zoom:1,showNav:true,showToolbar:true,showPanel:true,fullScreen:false,panelPosition:"bottom",singleStory:true,enableShortcuts:true,theme:"",selectedPanel:undefined,addons:{}});const d=l.state;export{d as s}; //# sourceMappingURL=p-1e8c2016.js.map