@peter.naydenov/cuts 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Changelog.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # Release History
2
2
 
3
3
 
4
+
5
+ ### 1.0.2 (2024-12-12)
6
+ - [x] Create d.ts files in folder 'types';
7
+
8
+
9
+
10
+ ### 1.0.1 (2024-05-10)
11
+ - [x] Fix: Repository address in package.json;
12
+
13
+
14
+
4
15
  ### 1.0.0 (2024-05-08)
5
16
  - [x] Initial release;
6
17
 
package/dist/cuts.umd.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).cuts=t()}(this,(function(){"use strict";var e={_normalizeWithPlugins:function(e,t){return function(e){const n=t.shortcuts;Object.keys(n).forEach((t=>{Object.entries(n[t]).forEach((([r,o])=>{const s=e(r);s!==r&&(delete n[t][r],n[t][s]=o)}))}))}},_readShortcutWithPlugins:function(e,t){return function(n){const{inAPI:r}=e,o=n.split(":")[0],s=r._systemAction(o,"none");let c=n;return-1!==s&&(c=t.plugins[s].shortcutName(n)),c}},_systemAction:function(e,t){return function(e,n,r=null){return t.plugins.findIndex((t=>t.getPrefix()===e&&(t[n]&&t[n](r),!0)))}},changeContext:function(e,t){const{shortcuts:n,currentContext:r}=t,{ev:o}=e;return function(e=!1){const s=r.name;if(!e)return o.reset(),void(r.name=null);s!==e&&(n[e]?(n[s]&&o.reset(),r.name=e,t.plugins.forEach((t=>t.contextChange(e))),Object.entries(n[e]).forEach((([e,t])=>{t.forEach((t=>o.on(e,t)))})),o.on("*",((...e)=>{t.exposeShortcut&&t.exposeShortcut(...e)}))):o.emit("@shortcuts-error",`Context '${e}' does not exist`))}},listShortcuts:function(e,t){const n=t.shortcuts;return function(e=null){if(null!=e){let t=n[e];return null==t?null:Object.entries(t).map((([e,t])=>e))}return Object.keys(n).map((e=>{let t={};return t.context=e,t.shortcuts=Object.entries(n[e]).map((([e,t])=>e)),t}))}},load:function(e,t){const{shortcuts:n,plugins:r}=t,{API:{changeContext:o,getContext:s}}=e;return function(e){const t=s(),c=r.map((e=>e.getPrefix().toUpperCase()));let i=!1;Object.entries(e).forEach((([e,o])=>{e===t&&(i=!0),n[e]={},Object.entries(o).forEach((([t,o])=>{let s=t,i=t.toUpperCase().trim(),u=c.map(((e,t)=>i.startsWith(e)?t:null)).filter((e=>null!==e));if(u.length){let e=u[0];s=r[e].shortcutName(t)}o instanceof Function&&(o=[o]),n[e][s]=o}))})),i&&(o(),o(t))}},unload:function(e,t){const{currentContext:n,shortcuts:r}=t,{ev:o}=e;return function(e){n.name!==e?r[e]?delete r[e]:o.emit("shortcuts-error",`Context '${e}' does not exist`):o.emit("shortcuts-error",`Context '${e}' can't be removed during is current active context. Change the context first`)}}};function t(t={}){const n=new function(){let e={"*":[]},t={},n=[],r=!1,o="";return{on:function(t,n){e[t]||(e[t]=[]),e[t].push(n)},once:function(e,n){"*"!==e&&(t[e]||(t[e]=[]),t[e].push(n))},off:function(n,r){if(r)return e[n]&&(e[n]=e[n].filter((e=>e!==r))),t[n]&&(t[n]=t[n].filter((e=>e!==r))),e[n]&&0===e[n].length&&delete e[n],void(t[n]&&0===t[n].length&&delete e[n]);t[n]&&delete t[n],e[n]&&delete e[n]},reset:function(){e={"*":[]},t={},n=[]},emit:function(){const[s,...c]=arguments;function i(t){let r=!1;"*"!==t&&(n.includes(t)||(e[t].every((e=>{const t=e(...c);return"string"!=typeof t||"STOP"!==t.toUpperCase()||(r=!0,!1)})),r||e["*"].forEach((e=>e(s,...c)))))}if(r&&(console.log(`${o} Event "${s}" was triggered.`),c.length>0&&(console.log("Arguments:"),console.log(...c),console.log("^----"))),"*"!==s){if(t[s]){if(n.includes(s))return;t[s].forEach((e=>e(...c))),delete t[s]}e[s]&&i(s)}else Object.keys(e).forEach((e=>i(e)))},stop:function(r){if("*"!==r)n.push(r);else{const r=Object.keys(e),o=Object.keys(t);n=[...o,...r]}},start:function(e){n="*"!==e?n.filter((t=>e!=t)):[]},debug:function(e,t){r=!!e,t&&"string"==typeof t&&(o=t)}}},r={},o={},s={currentContext:{name:null,note:null},shortcuts:{},plugins:[],exposeShortcut:!(!t.onShortcut||"function"!=typeof t.onShortcut)&&t.onShortcut},c={ev:n,inAPI:r,API:o,extra:{}};return o.enablePlugin=(e,t={})=>{const n=e.name;if(-1===r._systemAction(n,"none")){let n;n=e(c,s,t),s.plugins.push(n)}},o.disablePlugin=e=>{const t=r._systemAction(e,"destroy");-1!==t&&(s.plugins=s.plugins.filter(((e,n)=>n!==t)))},o.mutePlugin=e=>r._systemAction(e,"mute"),o.unmutePlugin=e=>r._systemAction(e,"unmute"),o.getContext=()=>s.currentContext.name,o.getNote=()=>s.currentContext.note,o.setNote=(e=null)=>{"string"!=typeof e&&null!=e||(s.currentContext.note=e)},o.pause=(e="*")=>{let t=r._readShortcutWithPlugins(e);n.stop(t)},o.resume=(e="*")=>{const t=r._readShortcutWithPlugins(e);n.start(t)},o.emit=(e,...t)=>n.emit(r._readShortcutWithPlugins(e),...t),o.listContexts=()=>Object.keys(s.shortcuts),o.setDependencies=e=>c.extra={...c.extra,...e},o.getDependencies=()=>c.extra,Object.entries(e).forEach((([e,t])=>{e.startsWith("_")?r[e]=t(c,s):o[e]=t(c,s)})),o}function n(e){let t,n=!1;return e?(t=function(e){let t=e.map((e=>r())),n=t.map((e=>e.promise));return t.promises=n,t.onComplete=o(Promise.all(n)),t}(e),n=!0):t=r(),t.timeout=function(e,t){let n;return n=e?Promise.all(t.promises):t.promise,function(e,r){let s,c=new Promise(((t,o)=>{s=setTimeout((()=>{t(r),Promise.resolve(n)}),e)}));return n.then((()=>clearTimeout(s))),t.onComplete=o(Promise.race([n,c])),t}}(n,t),t}function r(){let e,t;const n=new Promise(((n,r)=>{e=n,t=r}));return{promise:n,done:e,cancel:t,onComplete:o(n)}}function o(e){return function(t){e.then((e=>t(e)))}}function s({message:e,level:t,type:n,logLevel:r}){if(0===r)return null;if(r<t)return null;const o=`[Debug]: ${e}`;switch(n){case"warn":console.warn(o);break;case"error":console.error(o);break;default:console.log(o)}return o}function c(e={},t=s){return function({message:n,type:r,level:o,...s}){const{level:c,type:i,defaultMessageLevel:u}=Object.assign({},{level:1e3,type:"log",defaultMessageLevel:1},e);return r||(r=i),o||(o=u),t({message:n,type:r,level:o,logLevel:c,...s})}}function*i(e,t,n,r){let o=null;if(null===e)return yield*r.map((e=>[e,"show"])),void(yield[n,"show"]);if(!r||0===r.length)return t?(yield[e,"hide"],t.reverse(),yield*t.map((e=>[e,"hide"])),void(yield[n,"show"])):(yield[e,"hide"],void(yield[n,"show"]));if(r.includes(e)){for(let t=r.indexOf(e)+1;t<r.length;t++)yield[r[t],"show"];yield[n,"show"]}else{if(!t)return yield[e,"hide"],void(yield*r.map((e=>[e,"show"])));if(r.every(((e,n)=>t[n]===r[n]&&(o=n,!0))),null==o)return yield[e,"hide"],t.reverse(),yield*t.map((e=>[e,"hide"])),yield*r.map((e=>[e,"show"])),void(yield[n,"show"]);yield[e,"hide"];for(let e=t.length;e>o+1;e--)yield[t[e-1],"hide"];for(let e=o+1;e<r.length;e++)yield[r[e],"show"];yield[n,"show"]}}function u(e){return function(t,...n){const{askForPromise:r,deps:o}=e;return function(){const e=r();return t({task:e,dependencies:o()},...n),e.promise}}}n.sequence=function(e,...t){const r=n(),o=[],s=function*(e){for(const t of e)yield t}(e);return function e(t,...n){t.done?r.done(o):t.value(...n).then((t=>{o.push(t),e(s.next(),...n,t)}))}(s.next(),...t),r},n.all=function(e,...t){const r=n(),o=[],s=e.map(((e,n)=>"function"==typeof e?e(...t).then((e=>o[n]=e)):e.then((e=>o[n]=e))));return Promise.all(s).then((()=>r.done(o))),r};var l={hide:function(e,t){return function(n=1){const{askForPromise:r,shortcutMngr:o,setInstruction:s}=e,{currentScene:c,currentParents:i,scenes:u}=t,l=r(),a=[],f=i.length>0;let h;return o.pause(),a.push(s(u[c].hide)),f||(t.currentScene=null),f&&"*"===n&&[...i].reverse().forEach((e=>{h=t.currentParents.pop(),t.currentScene=h,a.push(s(u[e].hide))})),f&&!["*",1].includes(n)&&i.slice("-"+(n-1)).reverse().map((e=>{h=t.currentParents.pop(),t.currentScene=h,a.push(s(u[e].hide))})),(n=r.sequence(a)).onComplete((()=>{o.changeContext(t.currentScene),l.done()})),l.promise}},listShortcuts:function(e,t){return function(e){const{scenes:n,sceneNames:r}=t;if(!r.has(e))return null;const{show:o,hide:s,parents:c,...i}=n[e];return Object.keys(i)}},setScenes:function(e,t){return function(n){const{shortcutMngr:r}=e;n.forEach((({name:e,scene:n})=>{n.parents||(n.parents=[]),t.scenes[e]=n,t.sceneNames.add(e);const{show:o,hide:s,parents:c,...i}=n,u={};u[e]=i,r.load(u)}))}},show:function(e,t){return function({scene:n,options:r={ssr:!1}},...o){const{shortcutMngr:s,askForPromise:c,log:i,findInstructions:u,setInstruction:l}=e,a=c(),{opened:f,scenes:h,sceneNames:d}=t;if(!d.has(n)&&i)return i({message:`Scene ${n} is not available.`,level:1,type:"error"}),a.done(),a.promise;if(!f&&r.ssr)return t.opened=!0,t.currentPage=n,s.changeContext(n),a.done(),a.promise;const{show:p,parents:m}=h[n];if("*"===m[0])return p().then((()=>a.done())),t.currentParents.push(t.currentPage),t.currentPage=n,a.promise;if(!(m.forEach((e=>d.has(e)))||!0))return i&&i({message:`Some of '${n}' parent scenes are not set.`,level:1,type:"error"}),a.done(),a.promise;function g([e,n]){if("show"===n)t.currentScene&&t.currentParents.push(t.currentScene),t.currentScene=e;else{let e=t.currentParents.pop();t.currentScene=e}return h[e][n]}t.currentParents||(t.currentParents=[]);const y=u(t.currentScene,t.currentParents,n,m),P=[];for(let e of y)[e].map(g).map((e=>P.push(l(e),...o)));return c.sequence(P).onComplete((()=>{t.opened=!0,s.changeContext(n),a.done()})),a.promise}}};return function(e={logLevel:0}){const r=t(),o=c({level:e.logLevel||0}),s={currentScene:null,currentParents:null,sceneNames:new Set,scenes:{},opened:!1},a={},f={},h={shortcutMngr:r,API:a,inAPI:f,findInstructions:i,askForPromise:n,setInstruction:u({askForPromise:n,deps:r.getDependencies}),log:o};return Object.entries(l).forEach((([e,t])=>{e.startsWith("_")?f[e]=t(h,s):a[e]=t(h,s)})),a.setDependencies=e=>r.setDependencies(e),a.getDependencies=()=>r.getDependencies(),a.setNote=e=>t.setNote(e),a.listScenes=()=>[...s.sceneNames],a.enablePlugin=(e,t)=>r.enablePlugin(e,t),a.disablePlugin=e=>r.disablePlugin(e),a.emit=(e,...t)=>r.emit(e,...t),a}}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).cuts=t()}(this,(function(){"use strict";var e={_normalizeWithPlugins:function(e,t){return function(e){const n=t.shortcuts;Object.keys(n).forEach((t=>{Object.entries(n[t]).forEach((([r,o])=>{const s=e(r);s!==r&&(delete n[t][r],n[t][s]=o)}))}))}},_readShortcutWithPlugins:function(e,t){return function(n){const{inAPI:r}=e,o=n.split(":")[0],s=r._systemAction(o,"none");let c=n;return-1!==s&&(c=t.plugins[s].shortcutName(n)),c}},_systemAction:function(e,t){return function(e,n,r=null){return t.plugins.findIndex((t=>t.getPrefix()===e&&(t[n]&&t[n](r),!0)))}},changeContext:function(e,t){const{shortcuts:n,currentContext:r}=t,{ev:o}=e;return function(e=!1){const s=r.name;if(!e)return o.reset(),void(r.name=null);s!==e&&(n[e]?(n[s]&&o.reset(),r.name=e,t.plugins.forEach((t=>t.contextChange(e))),Object.entries(n[e]).forEach((([e,t])=>{t.forEach((t=>o.on(e,t)))})),o.on("*",((...e)=>{t.exposeShortcut&&t.exposeShortcut(...e)}))):o.emit("@shortcuts-error",`Context '${e}' does not exist`))}},listShortcuts:function(e,t){const n=t.shortcuts;return function(e=null){if(null!=e){let t=n[e];return null==t?null:Object.entries(t).map((([e,t])=>e))}return Object.keys(n).map((e=>{let t={};return t.context=e,t.shortcuts=Object.entries(n[e]).map((([e,t])=>e)),t}))}},load:function(e,t){const{shortcuts:n,plugins:r}=t,{API:{changeContext:o,getContext:s}}=e;return function(e){const t=s(),c=r.map((e=>e.getPrefix().toUpperCase()));let i=!1;Object.entries(e).forEach((([e,o])=>{e===t&&(i=!0),n[e]={},Object.entries(o).forEach((([t,o])=>{let s=t,i=t.toUpperCase().trim(),u=c.map(((e,t)=>i.startsWith(e)?t:null)).filter((e=>null!==e));if(u.length){let e=u[0];s=r[e].shortcutName(t)}o instanceof Function&&(o=[o]),n[e][s]=o}))})),i&&(o(),o(t))}},unload:function(e,t){const{currentContext:n,shortcuts:r}=t,{ev:o}=e;return function(e){n.name!==e?r[e]?delete r[e]:o.emit("shortcuts-error",`Context '${e}' does not exist`):o.emit("shortcuts-error",`Context '${e}' can't be removed during is current active context. Change the context first`)}}};function t(t={}){const n=new function(){let e={"*":[]},t={},n=[],r=!1,o="";return{on:function(t,n){e[t]||(e[t]=[]),e[t].push(n)},once:function(e,n){"*"!==e&&(t[e]||(t[e]=[]),t[e].push(n))},off:function(n,r){if(r)return e[n]&&(e[n]=e[n].filter((e=>e!==r))),t[n]&&(t[n]=t[n].filter((e=>e!==r))),e[n]&&0===e[n].length&&delete e[n],void(t[n]&&0===t[n].length&&delete e[n]);t[n]&&delete t[n],e[n]&&delete e[n]},reset:function(){e={"*":[]},t={},n=[]},emit:function(){const[s,...c]=arguments;function i(t){let r=!1;"*"!==t&&(n.includes(t)||(e[t].every((e=>{const t=e(...c);return"string"!=typeof t||"STOP"!==t.toUpperCase()||(r=!0,!1)})),r||e["*"].forEach((e=>e(s,...c)))))}if(r&&(console.log(`${o} Event "${s}" was triggered.`),c.length>0&&(console.log("Arguments:"),console.log(...c),console.log("^----"))),"*"!==s){if(t[s]){if(n.includes(s))return;t[s].forEach((e=>e(...c))),delete t[s]}e[s]&&i(s)}else Object.keys(e).forEach((e=>i(e)))},stop:function(r){if("*"!==r)n.push(r);else{const r=Object.keys(e),o=Object.keys(t);n=[...o,...r]}},start:function(e){n="*"!==e?n.filter((t=>e!=t)):[]},debug:function(e,t){r=!!e,t&&"string"==typeof t&&(o=t)}}},r={},o={},s={currentContext:{name:null,note:null},shortcuts:{},plugins:[],exposeShortcut:!(!t.onShortcut||"function"!=typeof t.onShortcut)&&t.onShortcut},c={ev:n,inAPI:r,API:o,extra:{}};return o.enablePlugin=(e,t={})=>{const n=e.name;if(-1===r._systemAction(n,"none")){let n;n=e(c,s,t),s.plugins.push(n)}},o.disablePlugin=e=>{const t=r._systemAction(e,"destroy");-1!==t&&(s.plugins=s.plugins.filter(((e,n)=>n!==t)))},o.mutePlugin=e=>r._systemAction(e,"mute"),o.unmutePlugin=e=>r._systemAction(e,"unmute"),o.getContext=()=>s.currentContext.name,o.getNote=()=>s.currentContext.note,o.setNote=(e=null)=>{"string"!=typeof e&&null!=e||(s.currentContext.note=e)},o.pause=(e="*")=>{let t=r._readShortcutWithPlugins(e);n.stop(t)},o.resume=(e="*")=>{const t=r._readShortcutWithPlugins(e);n.start(t)},o.emit=(e,...t)=>n.emit(r._readShortcutWithPlugins(e),...t),o.listContexts=()=>Object.keys(s.shortcuts),o.setDependencies=e=>c.extra={...c.extra,...e},o.getDependencies=()=>c.extra,Object.entries(e).forEach((([e,t])=>{e.startsWith("_")?r[e]=t(c,s):o[e]=t(c,s)})),o}function n(e){let t,n=!1;return e?(t=function(e){let t=e.map((e=>r())),n=t.map((e=>e.promise));return t.promises=n,t.onComplete=o(Promise.all(n)),t}(e),n=!0):t=r(),t.timeout=function(e,t){let n;n=e?Promise.all(t.promises):t.promise;return function(e,r){let s,c=new Promise(((t,o)=>{s=setTimeout((()=>{t(r),Promise.resolve(n)}),e)}));return n.then((()=>clearTimeout(s))),t.onComplete=o(Promise.race([n,c])),t}}(n,t),t}function r(){let e,t;const n=new Promise(((n,r)=>{e=n,t=r}));return{promise:n,done:e,cancel:t,onComplete:o(n)}}function o(e){return function(t){e.then((e=>t(e)))}}function s({message:e,level:t,type:n,logLevel:r}){if(0===r)return null;if(r<t)return null;const o=`[Debug]: ${e}`;switch(n){case"warn":console.warn(o);break;case"error":console.error(o);break;default:console.log(o)}return o}function c(e={},t=s){return function({message:n,type:r,level:o,...s}){const{level:c,type:i,defaultMessageLevel:u}=Object.assign({},{level:1e3,type:"log",defaultMessageLevel:1},e);return r||(r=i),o||(o=u),t({message:n,type:r,level:o,logLevel:c,...s})}}function*i(e,t,n,r){let o=null;if(null===e)return yield*r.map((e=>[e,"show"])),void(yield[n,"show"]);if(!r||0===r.length)return t?(yield[e,"hide"],t.reverse(),yield*t.map((e=>[e,"hide"])),void(yield[n,"show"])):(yield[e,"hide"],void(yield[n,"show"]));if(r.includes(e)){for(let t=r.indexOf(e)+1;t<r.length;t++)yield[r[t],"show"];yield[n,"show"]}else{if(!t)return yield[e,"hide"],void(yield*r.map((e=>[e,"show"])));if(r.every(((e,n)=>t[n]===r[n]&&(o=n,!0))),null==o)return yield[e,"hide"],t.reverse(),yield*t.map((e=>[e,"hide"])),yield*r.map((e=>[e,"show"])),void(yield[n,"show"]);yield[e,"hide"];for(let e=t.length;e>o+1;e--)yield[t[e-1],"hide"];for(let e=o+1;e<r.length;e++)yield[r[e],"show"];yield[n,"show"]}}function u(e){return function(t,...n){const{askForPromise:r,deps:o}=e;return function(){const e=r();return t({task:e,dependencies:o()},...n),e.promise}}}n.sequence=function(e,...t){const r=n(),o=[];const s=function*(e){for(const t of e)yield t}(e);return function e(t,...n){t.done?r.done(o):t.value(...n).then((t=>{o.push(t),e(s.next(),...n,t)}))}(s.next(),...t),r},n.all=function(e,...t){const r=n(),o=[],s=e.map(((e,n)=>"function"==typeof e?e(...t).then((e=>o[n]=e)):e.then((e=>o[n]=e))));return Promise.all(s).then((()=>r.done(o))),r};var l={hide:function(e,t){return function(n=1){const{askForPromise:r,shortcutMngr:o,setInstruction:s}=e,{currentScene:c,currentParents:i,scenes:u}=t,l=r(),a=[],f=i.length>0;let h;return o.pause(),a.push(s(u[c].hide)),f||(t.currentScene=null),f&&"*"===n&&[...i].reverse().forEach((e=>{h=t.currentParents.pop(),t.currentScene=h,a.push(s(u[e].hide))})),f&&!["*",1].includes(n)&&i.slice("-"+(n-1)).reverse().map((e=>{h=t.currentParents.pop(),t.currentScene=h,a.push(s(u[e].hide))})),(n=r.sequence(a)).onComplete((()=>{o.changeContext(t.currentScene),l.done()})),l.promise}},listShortcuts:function(e,t){return function(e){const{scenes:n,sceneNames:r}=t;if(!r.has(e))return null;const{show:o,hide:s,parents:c,...i}=n[e];return Object.keys(i)}},setScenes:function(e,t){return function(n){const{shortcutMngr:r}=e;n.forEach((({name:e,scene:n})=>{n.parents||(n.parents=[]),t.scenes[e]=n,t.sceneNames.add(e);const{show:o,hide:s,parents:c,...i}=n,u={};u[e]=i,r.load(u)}))}},show:function(e,t){return function({scene:n,options:r={ssr:!1}},...o){const{shortcutMngr:s,askForPromise:c,log:i,findInstructions:u,setInstruction:l}=e,a=c(),{opened:f,scenes:h,sceneNames:d}=t;if(!d.has(n)&&i)return i({message:`Scene ${n} is not available.`,level:1,type:"error"}),a.done(),a.promise;if(!f&&r.ssr)return t.opened=!0,t.currentPage=n,s.changeContext(n),a.done(),a.promise;const{show:p,parents:m}=h[n];if("*"===m[0])return p().then((()=>a.done())),t.currentParents.push(t.currentPage),t.currentPage=n,a.promise;if(!(m.forEach((e=>d.has(e)))||!0))return i&&i({message:`Some of '${n}' parent scenes are not set.`,level:1,type:"error"}),a.done(),a.promise;function g([e,n]){if("show"===n)t.currentScene&&t.currentParents.push(t.currentScene),t.currentScene=e;else{let e=t.currentParents.pop();t.currentScene=e}return h[e][n]}t.currentParents||(t.currentParents=[]);const y=u(t.currentScene,t.currentParents,n,m),P=[];for(let e of y)[e].map(g).map((e=>P.push(l(e),...o)));return c.sequence(P).onComplete((()=>{t.opened=!0,s.changeContext(n),a.done()})),a.promise}}};return function(e={logLevel:0}){const r=t(),o=c({level:e.logLevel||0}),s={currentScene:null,currentParents:null,sceneNames:new Set,scenes:{},opened:!1},a={},f={},h={shortcutMngr:r,API:a,inAPI:f,findInstructions:i,askForPromise:n,setInstruction:u({askForPromise:n,deps:r.getDependencies}),log:o};return Object.entries(l).forEach((([e,t])=>{e.startsWith("_")?f[e]=t(h,s):a[e]=t(h,s)})),a.setDependencies=e=>r.setDependencies(e),a.getDependencies=()=>r.getDependencies(),a.setNote=e=>t.setNote(e),a.listScenes=()=>[...s.sceneNames],a.enablePlugin=(e,t)=>r.enablePlugin(e,t),a.disablePlugin=e=>r.disablePlugin(e),a.emit=(e,...t)=>r.emit(e,...t),a}}));
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@peter.naydenov/cuts",
3
3
  "description": "SPA scene manager",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "license": "MIT",
6
6
  "author": "Peter Naydenov",
7
- "main": "./dist/cuts.umd.js",
7
+ "main": "./src/main.js",
8
8
  "type": "module",
9
+ "types": "./types/main.d.ts",
9
10
  "exports": {
10
11
  ".": {
11
- "import": "./dist/cuts.esm.mjs",
12
+ "import": "./src/main.js",
12
13
  "require": "./dist/cuts.cjs",
13
- "default": "./dist/cuts.umd.js"
14
+ "default": "./src/main.js"
14
15
  },
15
16
  "./package.json": "./package.json",
16
17
  "./dist/*": "./dist/*",
@@ -19,6 +20,7 @@
19
20
  "scripts": {
20
21
  "dev": "vite",
21
22
  "build": "rollup -c",
23
+ "postbuild": "tsc -p tsconfig.json",
22
24
  "preview": "vite preview",
23
25
  "test": "mocha test-mocha/*.js",
24
26
  "cypress": "cypress open --component --browser chrome"
@@ -28,23 +30,25 @@
28
30
  "url": "git+https://github.com/PeterNaydenov/cuts.git"
29
31
  },
30
32
  "devDependencies": {
31
- "@peter.naydenov/visual-controller-for-vue3": "^2.1.0",
32
- "@rollup/plugin-commonjs": "^25.0.7",
33
- "@rollup/plugin-node-resolve": "^15.2.3",
33
+ "@peter.naydenov/visual-controller-for-vue3": "^2.1.3",
34
+ "@rollup/plugin-commonjs": "^28.0.1",
35
+ "@rollup/plugin-node-resolve": "^15.3.0",
34
36
  "@rollup/plugin-terser": "^0.4.4",
35
- "@vitejs/plugin-vue": "^5.0.4",
36
- "c8": "^9.1.0",
37
- "chai": "^5.1.1",
38
- "cypress": "^13.9.0",
39
- "mocha": "^10.4.0",
40
- "rollup": "^4.17.2",
41
- "vite": "^5.2.11",
42
- "vue": "^3.4.27"
37
+ "@types/node": "^22.10.2",
38
+ "@vitejs/plugin-vue": "^5.2.1",
39
+ "c8": "^10.1.3",
40
+ "chai": "^5.1.2",
41
+ "cypress": "^13.16.1",
42
+ "mocha": "^11.0.1",
43
+ "rollup": "^4.28.1",
44
+ "typescript": "^5.7.2",
45
+ "vite": "^6.0.3",
46
+ "vue": "^3.5.13"
43
47
  },
44
48
  "dependencies": {
45
49
  "@peter.naydenov/log": "^1.1.0",
46
50
  "@peter.naydenov/shortcuts": "^3.1.1",
47
- "ask-for-promise": "^2.0.3"
51
+ "ask-for-promise": "^2.0.4"
48
52
  },
49
53
  "keywords": [
50
54
  "script",
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "include": ["./src/**/*"],
3
+ "compilerOptions": {
4
+ "allowJs": true,
5
+ "declaration": true,
6
+ "emitDeclarationOnly": true,
7
+ "outDir": "types",
8
+ "declarationMap": true
9
+ }
10
+ }
@@ -0,0 +1,3 @@
1
+ export default findInstructions;
2
+ declare function findInstructions(currentName: any, currentParents: any, targetName: any, targetParents: any): Generator<any, void, any>;
3
+ //# sourceMappingURL=findInstructions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findInstructions.d.ts","sourceRoot":"","sources":["../src/findInstructions.js"],"names":[],"mappings":";AAGA,yIAiEC"}
@@ -0,0 +1,13 @@
1
+ export default main;
2
+ declare function main(cfg?: {
3
+ logLevel: number;
4
+ }): {
5
+ setDependencies(deps: any): any;
6
+ getDependencies(): any;
7
+ setNote(note: string): any;
8
+ listScenes(): Array<string>;
9
+ enablePlugin(plugin: Function, options: any): any;
10
+ disablePlugin(pluginName: string): any;
11
+ emit(event: string, ...args: any[]): any;
12
+ };
13
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.js"],"names":[],"mappings":";AA8BA;;;0BAiCmB,GAAC;uBAQC,GAAC;kBAMH,MAAM;kBAQJ,KAAK,CAAE,MAAM,CAAC;4CAQhB,GAAC;8BAQD,MAAM;gBASN,MAAM;EAOxB"}
@@ -0,0 +1,3 @@
1
+ export default hide;
2
+ declare function hide(dependencies: any, state: any): (endSteps?: number | string) => Promise<any>;
3
+ //# sourceMappingURL=hide.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hide.d.ts","sourceRoot":"","sources":["../../src/methods/hide.js"],"names":[],"mappings":";AAIA,kEAIW,MAAM,GAAC,MAAM,kBAsCtB"}
@@ -0,0 +1,12 @@
1
+ declare namespace _default {
2
+ export { hide };
3
+ export { listShortcuts };
4
+ export { setScenes };
5
+ export { show };
6
+ }
7
+ export default _default;
8
+ import hide from './hide.js';
9
+ import listShortcuts from './listShortcuts.js';
10
+ import setScenes from './setScenes.js';
11
+ import show from './show.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/methods/index.js"],"names":[],"mappings":";;;;;;;iBAC0B,WAAW;0BACX,oBAAoB;sBACpB,gBAAgB;iBAChB,WAAW"}
@@ -0,0 +1,3 @@
1
+ export default listShortcuts;
2
+ declare function listShortcuts(dependencies: any, state: any): (sceneName: string) => (Array<string> | null);
3
+ //# sourceMappingURL=listShortcuts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listShortcuts.d.ts","sourceRoot":"","sources":["../../src/methods/listShortcuts.js"],"names":[],"mappings":";AAEA,2EAIW,MAAM,KACJ,CAAC,KAAK,CAAE,MAAM,CAAC,GAAC,IAAI,CAAC,CAOhC"}
@@ -0,0 +1,8 @@
1
+ export default setScenes;
2
+ /**
3
+ * @type sceneDescription
4
+ * @param {string} name - name of the scene
5
+ * @param {object} scene - object should contain 'show' and 'hide' + shortcuts and action functions
6
+ */
7
+ declare function setScenes(dependencies: any, state: any): (list: any) => void;
8
+ //# sourceMappingURL=setScenes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setScenes.d.ts","sourceRoot":"","sources":["../../src/methods/setScenes.js"],"names":[],"mappings":";AAEA;;;;GAIG;AAEH,0EAIc,IAAI,CAiBhB"}
@@ -0,0 +1,8 @@
1
+ export default show;
2
+ declare function show(dependencies: any, state: any): ({ scene: requestedScene, options }: {
3
+ scene: string;
4
+ options: {
5
+ ssr: boolean;
6
+ };
7
+ }, ...args: any[]) => Promise<any>;
8
+ //# sourceMappingURL=show.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../src/methods/show.js"],"names":[],"mappings":";AAIA,2FAKG;IAAwB,KAAK,EAArB,MAAM;IACU,OAAO,EAC/B;QAAiC,GAAG,EAA5B,OAAO;KACf;CAAA,kCAsFD"}
@@ -0,0 +1,3 @@
1
+ export default setInstruction;
2
+ declare function setInstruction(dependencies: any): (fn: any, ...args: any[]) => () => any;
3
+ //# sourceMappingURL=setInstruction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setInstruction.d.ts","sourceRoot":"","sources":["../src/setInstruction.js"],"names":[],"mappings":";AAEA,2FAQE"}