@mokup/playground 0.1.1 → 0.2.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/dist/index.html
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
<title>Mokup Playground</title>
|
|
7
7
|
<script type="module" crossorigin src="./assets/playground.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="./assets/index.css">
|
|
9
|
-
<script type="module" src="assets/mokup-sw-lifecycle.js"></script>
|
|
10
9
|
</head>
|
|
11
10
|
<body>
|
|
12
11
|
<div id="app"></div>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mokup/playground",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.2",
|
|
5
5
|
"description": "Static playground UI for mokup mock APIs.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://mokup.icebreaker.top",
|
|
@@ -17,21 +17,25 @@
|
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@
|
|
20
|
+
"@codemirror/lang-json": "^6.0.2",
|
|
21
|
+
"@codemirror/language": "^6.11.3",
|
|
22
|
+
"@codemirror/state": "^6.5.2",
|
|
23
|
+
"@codemirror/view": "^6.39.13",
|
|
24
|
+
"@mokup/runtime": "1.0.9"
|
|
21
25
|
},
|
|
22
26
|
"devDependencies": {
|
|
23
|
-
"@iconify/
|
|
27
|
+
"@iconify-json/carbon": "^1.2.11",
|
|
24
28
|
"@iconify/tailwind": "^1.2.0",
|
|
25
29
|
"@tailwindcss/vite": "^4.1.13",
|
|
26
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
30
|
+
"@vitejs/plugin-vue": "^6.0.4",
|
|
27
31
|
"tailwind-merge": "^3.4.0",
|
|
28
32
|
"tailwind-variants": "^3.2.2",
|
|
29
33
|
"tailwindcss": "^4.1.13",
|
|
30
34
|
"typescript": "^5.9.3",
|
|
31
35
|
"vite": "^7.3.1",
|
|
32
|
-
"vue": "^3.5.
|
|
36
|
+
"vue": "^3.5.28",
|
|
33
37
|
"vue-i18n": "^11.1.12",
|
|
34
|
-
"@mokup/core": "1.1.
|
|
38
|
+
"@mokup/core": "1.1.3"
|
|
35
39
|
},
|
|
36
40
|
"scripts": {
|
|
37
41
|
"build": "vite build",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const c={fatal:0,error:0,warn:1,log:2,info:3,success:3,fail:3,debug:4,trace:5,verbose:Number.POSITIVE_INFINITY},_={silent:{level:-1},fatal:{level:c.fatal},error:{level:c.error},warn:{level:c.warn},log:{level:c.log},info:{level:c.info},success:{level:c.success},fail:{level:c.fail},ready:{level:c.info},start:{level:c.info},box:{level:c.info},debug:{level:c.debug},trace:{level:c.trace},verbose:{level:c.verbose}};function h(o){if(o===null||typeof o!="object")return!1;const t=Object.getPrototypeOf(o);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in o?!1:Symbol.toStringTag in o?Object.prototype.toString.call(o)==="[object Module]":!0}function y(o,t,e=".",s){if(!h(t))return y(o,{},e);const r=Object.assign({},t);for(const i in o){if(i==="__proto__"||i==="constructor")continue;const n=o[i];n!=null&&(Array.isArray(n)&&Array.isArray(r[i])?r[i]=[...n,...r[i]]:h(n)&&h(r[i])?r[i]=y(n,r[i],(e?`${e}.`:"")+i.toString()):r[i]=n)}return r}function v(o){return(...t)=>t.reduce((e,s)=>y(e,s,""),{})}const L=v();function S(o){return Object.prototype.toString.call(o)==="[object Object]"}function b(o){return!(!S(o)||!o.message&&!o.args||o.stack)}let g=!1;const m=[];class a{options;_lastLog;_mockFn;constructor(t={}){const e=t.types||_;this.options=L({...t,defaults:{...t.defaults},level:d(t.level,e),reporters:[...t.reporters||[]]},{types:_,throttle:1e3,throttleMin:5,formatOptions:{date:!0,colors:!1,compact:!0}});for(const s in e){const r={type:s,...this.options.defaults,...e[s]};this[s]=this._wrapLogFn(r),this[s].raw=this._wrapLogFn(r,!0)}this.options.mockFn&&this.mockTypes(),this._lastLog={}}get level(){return this.options.level}set level(t){this.options.level=d(t,this.options.types,this.options.level)}prompt(t,e){if(!this.options.prompt)throw new Error("prompt is not supported!");return this.options.prompt(t,e)}create(t){const e=new a({...this.options,...t});return this._mockFn&&e.mockTypes(this._mockFn),e}withDefaults(t){return this.create({...this.options,defaults:{...this.options.defaults,...t}})}withTag(t){return this.withDefaults({tag:this.options.defaults.tag?this.options.defaults.tag+":"+t:t})}addReporter(t){return this.options.reporters.push(t),this}removeReporter(t){if(t){const e=this.options.reporters.indexOf(t);if(e!==-1)return this.options.reporters.splice(e,1)}else this.options.reporters.splice(0);return this}setReporters(t){return this.options.reporters=Array.isArray(t)?t:[t],this}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}wrapConsole(){for(const t in this.options.types)console["__"+t]||(console["__"+t]=console[t]),console[t]=this[t].raw}restoreConsole(){for(const t in this.options.types)console["__"+t]&&(console[t]=console["__"+t],delete console["__"+t])}wrapStd(){this._wrapStream(this.options.stdout,"log"),this._wrapStream(this.options.stderr,"log")}_wrapStream(t,e){t&&(t.__write||(t.__write=t.write),t.write=s=>{this[e].raw(String(s).trim())})}restoreStd(){this._restoreStream(this.options.stdout),this._restoreStream(this.options.stderr)}_restoreStream(t){t&&t.__write&&(t.write=t.__write,delete t.__write)}pauseLogs(){g=!0}resumeLogs(){g=!1;const t=m.splice(0);for(const e of t)e[0]._logFn(e[1],e[2])}mockTypes(t){const e=t||this.options.mockFn;if(this._mockFn=e,typeof e=="function")for(const s in this.options.types)this[s]=e(s,this.options.types[s])||this[s],this[s].raw=this[s]}_wrapLogFn(t,e){return(...s)=>{if(g){m.push([this,t,s,e]);return}return this._logFn(t,s,e)}}_logFn(t,e,s){if((t.level||0)>this.level)return!1;const r={date:new Date,args:[],...t,level:d(t.level,this.options.types)};!s&&e.length===1&&b(e[0])?Object.assign(r,e[0]):r.args=[...e],r.message&&(r.args.unshift(r.message),delete r.message),r.additional&&(Array.isArray(r.additional)||(r.additional=r.additional.split(`
|
|
2
|
-
`)),r.args.push(`
|
|
3
|
-
`+r.additional.join(`
|
|
4
|
-
`)),delete r.additional),r.type=typeof r.type=="string"?r.type.toLowerCase():"log",r.tag=typeof r.tag=="string"?r.tag:"";const i=(l=!1)=>{const f=(this._lastLog.count||0)-this.options.throttleMin;if(this._lastLog.object&&f>0){const p=[...this._lastLog.object.args];f>1&&p.push(`(repeated ${f} times)`),this._log({...this._lastLog.object,args:p}),this._lastLog.count=1}l&&(this._lastLog.object=r,this._log(r))};clearTimeout(this._lastLog.timeout);const n=this._lastLog.time&&r.date?r.date.getTime()-this._lastLog.time.getTime():0;if(this._lastLog.time=r.date,n<this.options.throttle)try{const l=JSON.stringify([r.type,r.tag,r.args]),f=this._lastLog.serialized===l;if(this._lastLog.serialized=l,f&&(this._lastLog.count=(this._lastLog.count||0)+1,this._lastLog.count>this.options.throttleMin)){this._lastLog.timeout=setTimeout(i,this.options.throttle);return}}catch{}i(!0)}_log(t){for(const e of this.options.reporters)e.log(t,{options:this.options})}}function d(o,t={},e=3){return o===void 0?e:typeof o=="number"?o:t[o]&&t[o].level!==void 0?t[o].level:e}a.prototype.add=a.prototype.addReporter;a.prototype.remove=a.prototype.removeReporter;a.prototype.clear=a.prototype.removeReporter;a.prototype.withScope=a.prototype.withTag;a.prototype.mock=a.prototype.mockTypes;a.prototype.pause=a.prototype.pauseLogs;a.prototype.resume=a.prototype.resumeLogs;function k(o={}){return new a(o)}class F{options;defaultColor;levelColorMap;typeColorMap;constructor(t){this.options={...t},this.defaultColor="#7f8c8d",this.levelColorMap={0:"#c0392b",1:"#f39c12",3:"#00BCD4"},this.typeColorMap={success:"#2ecc71"}}_getLogFn(t){return t<1?console.__error||console.error:t===1?console.__warn||console.warn:console.__log||console.log}log(t){const e=this._getLogFn(t.level),s=t.type==="log"?"":t.type,r=t.tag||"",n=`
|
|
5
|
-
background: ${this.typeColorMap[t.type]||this.levelColorMap[t.level]||this.defaultColor};
|
|
6
|
-
border-radius: 0.5em;
|
|
7
|
-
color: white;
|
|
8
|
-
font-weight: bold;
|
|
9
|
-
padding: 2px 0.5em;
|
|
10
|
-
`,l=`%c${[r,s].filter(Boolean).join(":")}`;typeof t.args[0]=="string"?e(`${l}%c ${t.args[0]}`,n,"",...t.args.slice(1)):e(l,n,...t.args)}}function C(o={}){return k({reporters:o.reporters||[new F({})],prompt(e,s={}){return s.type==="confirm"?Promise.resolve(confirm(e)):Promise.resolve(prompt(e))},...o})}const T=C(),j={info:()=>{},warn:()=>{},error:()=>{},log:()=>{}};function R(o=!0){const t=typeof o=="boolean"?{enabled:o}:o;if(!(t?.enabled??!0))return j;const s=t?.tag??"mokup",r=T.withTag(s);return{info:(...i)=>{if(i.length===0)return;const[n,...l]=i;r.info(n,...l)},warn:(...i)=>{if(i.length===0)return;const[n,...l]=i;r.warn(n,...l)},error:(...i)=>{if(i.length===0)return;const[n,...l]=i;r.error(n,...l)},log:(...i)=>{if(i.length===0)return;const[n,...l]=i;r.log(n,...l)}}}const M="/mokup-sw.js",U="/",$=R();function A(o){return o?o.startsWith("/")?o:`/${o}`:M}function P(o){return o?o.startsWith("/")?o:`/${o}`:U}function O(o,t){const e=new URL(o,t);return e.pathname.endsWith("/")||(e.pathname=`${e.pathname}/`),e.href}function z(o,t,e){try{const s=new URL(o);return s.origin===t&&s.pathname===e}catch{return!1}}async function W(o={}){if(typeof window>"u"||!("serviceWorker"in navigator))return[];const t=window.location.origin,e=A(o.path),s=P(o.scope),r=new URL(e,t),i=O(s,t);try{const l=(await navigator.serviceWorker.getRegistrations()).filter(p=>p.scope!==i?!1:[p.active?.scriptURL,p.waiting?.scriptURL,p.installing?.scriptURL].filter(u=>typeof u=="string").some(u=>z(u,t,r.pathname))),f=[];for(const p of l)await p.unregister()&&f.push(p);return f}catch(n){return $.warn("Failed to unregister service worker:",n),[]}}(async()=>await W({path:"/mokup-sw.js",scope:"/"}))();
|