nanosplash 3.1.1 → 4.0.0

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.
@@ -25,7 +25,7 @@ jobs:
25
25
  uses: actions/setup-node@v3
26
26
  with:
27
27
  node-version: 20
28
-
28
+ registry-url: 'https://registry.npmjs.org'
29
29
  - name: Set up Git and update production branch
30
30
  run: |
31
31
  git config --global user.name "GitHub Actions"
@@ -38,7 +38,7 @@ jobs:
38
38
  uses: actions/configure-pages@v3
39
39
 
40
40
  - name: Install dependencies
41
- run: pnpm install
41
+ run: pnpm install --no-frozen-lockfile
42
42
 
43
43
  - name: Build (Vite)
44
44
  run: pnpm build
@@ -54,3 +54,8 @@ jobs:
54
54
  git add .
55
55
  git commit --allow-empty -m "Build, test, and coverage report"
56
56
  git push
57
+
58
+ - name: Publish to NPM
59
+ run: npm publish
60
+ env:
61
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
@@ -44,7 +44,7 @@ jobs:
44
44
  - name: Setup Pages
45
45
  uses: actions/configure-pages@v3
46
46
  - name: Install dependencies
47
- run: pnpm install
47
+ run: pnpm install --no-frozen-lockfile
48
48
  - name: Build with VitePress
49
49
  run: |
50
50
  pnpm docs:build
package/dist/cjs/ns.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b='@keyframes nsRotate{to{transform:rotate(360deg)}}@keyframes nsDash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}@keyframes nsFade{0%{opacity:0}to{opacity:1}}@keyframes nsAscend{0%{opacity:0;transform:translateY(13px)}to{opacity:1;transform:translateY(0)}}:root{--ns-top: 0px}.ns,body.nsh,body.nsh:before,.nsh:before{width:100%;height:100%}.ns,.nsh:before{bottom:0;right:0}.ns{display:flex;justify-content:center;align-items:center}.nsh{--color: DarkSlateGray;--size: 20px;--relSize: calc(var(--size) * .9);--font: "Helvetica", "Arial", sans-serif;--weight: 400;--bg: rgba(255, 255, 255, .9);--zIdx: 999999999;--blur: blur(5px)}.nsh{position:relative;z-index:var(--zIdx)}.nsh:before{position:absolute;background-color:var(--bg);content:"";backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur);z-index:calc(var(--zIdx) + 1);border-radius:inherit}body.nsh,body.nsh:before{position:fixed;top:var(--ns-top);left:0}.ns{position:absolute;z-index:calc(var(--zIdx) + 2);animation:nsFade 2s;gap:var(--relSize)}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);max-width:80dvw;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-shadow:0 0 .06rem rgba(47,79,79,.25);filter:drop-shadow(0 0 .07rem rgba(0,0,0,.25));animation:nsAscend .5s}.nss{display:block;width:var(--relSize);height:var(--relSize);animation:nsAscend .5s}.nss>svg{animation:nsRotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:nsDash 1.5s ease-in-out infinite}',m="3.1.1",l="ns",i=document,r=i.body,a=e=>(s=>({all:s,first:t=>s(t)[0]??null}))(s=>Array.from(e.querySelectorAll(s))),f=e=>a(i).all(e),h=e=>a(i).first(e),p=()=>f(".ns"),u=e=>e instanceof Element?e:h(e),n=(e,...s)=>{const t=i.createElement("div");return e&&t.classList.add(e),t.append(...s),t},v=e=>{const s=n();return s.innerHTML=e,s.firstChild},g=()=>{const s=v('<svg viewBox="0 0 50 50"><circle class=path cx=25 cy=25 r=20 fill=none /></svg>'),t=n("ns",n("nst"),n("nss",s));return t.nsId=Date.now(),t},w=()=>p().sort((e,s)=>e.nsId-s.nsId)[0]??null,k=(e,s)=>{const t=a(e).first(".nst");if(!s)return t==null?void 0:t.remove();const o=n("nst",s);t?t.replaceWith(o):e.insertBefore(o,e.firstChild)},x=(e,s)=>{const t=s.firstElementChild;t&&s.insertBefore(e,t),s.append(e),s.classList.add("nsh")},z=(e,s)=>{const t=s?u(s):r;let o;const c=a(t??r).first("& > .ns");c?o=c:(o=g(),x(o,t)),k(o,e??"");const y=scrollY+"px";return r.style.setProperty("--ns-top",y),o.nsId},d=e=>{var s;(s=e==null?void 0:e.parentElement)==null||s.classList.remove("nsh"),e==null||e.remove()},I=e=>p().find(s=>s.nsId===e)??null,N=e=>{e==="*"?f(".ns").forEach(d):d(typeof e=="number"?I(e):w())},A=()=>{var e;(e=h("#"+l))==null||e.remove(),r.append(v(`<style id=${l}>${b}</style>`))},S=()=>(A(),window.ns={show:z,hide:N,version:m});exports.useNs=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b='@keyframes nsRotate{to{transform:rotate(360deg)}}@keyframes nsDash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}@keyframes nsFade{0%{opacity:0}to{opacity:1}}@keyframes nsAscend{0%{opacity:0;transform:translateY(13px)}to{opacity:1;transform:translateY(0)}}:root{--ns-top: 0px}.ns,body.nsh,body.nsh:before,.nsh:before{width:100%;height:100%}.ns,.nsh:before{bottom:0;right:0}.ns{display:flex;justify-content:center;align-items:center}.nsh{--color: DarkSlateGray;--size: 20px;--relSize: calc(var(--size) * .9);--font: "Helvetica", "Arial", sans-serif;--weight: 400;--bg: rgba(255, 255, 255, .9);--zIdx: 999999999;--blur: blur(5px)}.nsh{position:relative;z-index:var(--zIdx)}.nsh:before{position:absolute;background-color:var(--bg);content:"";backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur);z-index:calc(var(--zIdx) + 1);border-radius:inherit}body.nsh,body.nsh:before{position:fixed;top:var(--ns-top);left:0}.ns{position:absolute;z-index:calc(var(--zIdx) + 2);animation:nsFade 2s;gap:var(--relSize)}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);max-width:80dvw;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-shadow:0 0 .06rem rgba(47,79,79,.25);filter:drop-shadow(0 0 .07rem rgba(0,0,0,.25));animation:nsAscend .5s}.nss{display:block;width:var(--relSize);height:var(--relSize);animation:nsAscend .5s}.nss>svg{animation:nsRotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:nsDash 1.5s ease-in-out infinite}',m="4.0.0",l="ns",i=document,r=i.body,a=e=>(s=>({all:s,first:t=>s(t)[0]??null}))(s=>Array.from(e.querySelectorAll(s))),f=e=>a(i).all(e),h=e=>a(i).first(e),p=()=>f(".ns"),u=e=>e instanceof Element?e:h(e),n=(e,...s)=>{const t=i.createElement("div");return e&&t.classList.add(e),t.append(...s),t},v=e=>{const s=n();return s.innerHTML=e,s.firstChild},g=()=>{const s=v('<svg viewBox="0 0 50 50"><circle class=path cx=25 cy=25 r=20 fill=none /></svg>'),t=n("ns",n("nst"),n("nss",s));return t.nsId=Date.now(),t},k=()=>p().sort((e,s)=>e.nsId-s.nsId)[0]??null,w=(e,s)=>{const t=a(e).first(".nst");if(!s)return t==null?void 0:t.remove();const o=n("nst",s);t?t.replaceWith(o):e.insertBefore(o,e.firstChild)},x=(e,s)=>{const t=s.firstElementChild;t&&s.insertBefore(e,t),s.append(e),s.classList.add("nsh")},z=(e,s)=>{const t=s?u(s):r;let o;const c=a(t??r).first("& > .ns");c?o=c:(o=g(),x(o,t)),w(o,e??"");const y=scrollY+"px";return r.style.setProperty("--ns-top",y),o.nsId},d=e=>{var s;(s=e==null?void 0:e.parentElement)==null||s.classList.remove("nsh"),e==null||e.remove()},I=e=>p().find(s=>s.nsId===e)??null,N=e=>{e==="*"?f(".ns").forEach(d):d(typeof e=="number"?I(e):k())},A=()=>{var e;(e=h("#"+l))==null||e.remove(),r.append(v(`<style id=${l}>${b}</style>`))},S=()=>(A(),{show:z,hide:N,version:m});exports.useNs=S;
package/dist/es/ns.js CHANGED
@@ -1,4 +1,4 @@
1
- const b = '@keyframes nsRotate{to{transform:rotate(360deg)}}@keyframes nsDash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}@keyframes nsFade{0%{opacity:0}to{opacity:1}}@keyframes nsAscend{0%{opacity:0;transform:translateY(13px)}to{opacity:1;transform:translateY(0)}}:root{--ns-top: 0px}.ns,body.nsh,body.nsh:before,.nsh:before{width:100%;height:100%}.ns,.nsh:before{bottom:0;right:0}.ns{display:flex;justify-content:center;align-items:center}.nsh{--color: DarkSlateGray;--size: 20px;--relSize: calc(var(--size) * .9);--font: "Helvetica", "Arial", sans-serif;--weight: 400;--bg: rgba(255, 255, 255, .9);--zIdx: 999999999;--blur: blur(5px)}.nsh{position:relative;z-index:var(--zIdx)}.nsh:before{position:absolute;background-color:var(--bg);content:"";backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur);z-index:calc(var(--zIdx) + 1);border-radius:inherit}body.nsh,body.nsh:before{position:fixed;top:var(--ns-top);left:0}.ns{position:absolute;z-index:calc(var(--zIdx) + 2);animation:nsFade 2s;gap:var(--relSize)}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);max-width:80dvw;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-shadow:0 0 .06rem rgba(47,79,79,.25);filter:drop-shadow(0 0 .07rem rgba(0,0,0,.25));animation:nsAscend .5s}.nss{display:block;width:var(--relSize);height:var(--relSize);animation:nsAscend .5s}.nss>svg{animation:nsRotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:nsDash 1.5s ease-in-out infinite}', m = "3.1.1", l = "ns", i = document, r = i.body, a = (e) => /* @__PURE__ */ ((s) => ({
1
+ const b = '@keyframes nsRotate{to{transform:rotate(360deg)}}@keyframes nsDash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}@keyframes nsFade{0%{opacity:0}to{opacity:1}}@keyframes nsAscend{0%{opacity:0;transform:translateY(13px)}to{opacity:1;transform:translateY(0)}}:root{--ns-top: 0px}.ns,body.nsh,body.nsh:before,.nsh:before{width:100%;height:100%}.ns,.nsh:before{bottom:0;right:0}.ns{display:flex;justify-content:center;align-items:center}.nsh{--color: DarkSlateGray;--size: 20px;--relSize: calc(var(--size) * .9);--font: "Helvetica", "Arial", sans-serif;--weight: 400;--bg: rgba(255, 255, 255, .9);--zIdx: 999999999;--blur: blur(5px)}.nsh{position:relative;z-index:var(--zIdx)}.nsh:before{position:absolute;background-color:var(--bg);content:"";backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur);z-index:calc(var(--zIdx) + 1);border-radius:inherit}body.nsh,body.nsh:before{position:fixed;top:var(--ns-top);left:0}.ns{position:absolute;z-index:calc(var(--zIdx) + 2);animation:nsFade 2s;gap:var(--relSize)}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);max-width:80dvw;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-shadow:0 0 .06rem rgba(47,79,79,.25);filter:drop-shadow(0 0 .07rem rgba(0,0,0,.25));animation:nsAscend .5s}.nss{display:block;width:var(--relSize);height:var(--relSize);animation:nsAscend .5s}.nss>svg{animation:nsRotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:nsDash 1.5s ease-in-out infinite}', m = "4.0.0", l = "ns", i = document, r = i.body, a = (e) => /* @__PURE__ */ ((s) => ({
2
2
  all: s,
3
3
  first: (t) => s(t)[0] ?? null
4
4
  }))((s) => Array.from(e.querySelectorAll(s))), f = (e) => a(i).all(e), h = (e) => a(i).first(e), p = () => f(".ns"), u = (e) => e instanceof Element ? e : h(e), n = (e, ...s) => {
@@ -10,7 +10,7 @@ const b = '@keyframes nsRotate{to{transform:rotate(360deg)}}@keyframes nsDash{0%
10
10
  }, g = () => {
11
11
  const s = v('<svg viewBox="0 0 50 50"><circle class=path cx=25 cy=25 r=20 fill=none /></svg>'), t = n("ns", n("nst"), n("nss", s));
12
12
  return t.nsId = Date.now(), t;
13
- }, w = () => p().sort((e, s) => e.nsId - s.nsId)[0] ?? null, k = (e, s) => {
13
+ }, k = () => p().sort((e, s) => e.nsId - s.nsId)[0] ?? null, w = (e, s) => {
14
14
  const t = a(e).first(".nst");
15
15
  if (!s)
16
16
  return t == null ? void 0 : t.remove();
@@ -23,18 +23,18 @@ const b = '@keyframes nsRotate{to{transform:rotate(360deg)}}@keyframes nsDash{0%
23
23
  const t = s ? u(s) : r;
24
24
  let o;
25
25
  const c = a(t ?? r).first("& > .ns");
26
- c ? o = c : (o = g(), x(o, t)), k(o, e ?? "");
26
+ c ? o = c : (o = g(), x(o, t)), w(o, e ?? "");
27
27
  const y = scrollY + "px";
28
28
  return r.style.setProperty("--ns-top", y), o.nsId;
29
29
  }, d = (e) => {
30
30
  var s;
31
31
  (s = e == null ? void 0 : e.parentElement) == null || s.classList.remove("nsh"), e == null || e.remove();
32
32
  }, I = (e) => p().find((s) => s.nsId === e) ?? null, A = (e) => {
33
- e === "*" ? f(".ns").forEach(d) : d(typeof e == "number" ? I(e) : w());
33
+ e === "*" ? f(".ns").forEach(d) : d(typeof e == "number" ? I(e) : k());
34
34
  }, N = () => {
35
35
  var e;
36
36
  (e = h("#" + l)) == null || e.remove(), r.append(v(`<style id=${l}>${b}</style>`));
37
- }, S = () => (N(), window.ns = {
37
+ }, S = () => (N(), {
38
38
  show: z,
39
39
  hide: A,
40
40
  version: m
@@ -1 +1 @@
1
- (function(){"use strict";const y='@keyframes nsRotate{to{transform:rotate(360deg)}}@keyframes nsDash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}@keyframes nsFade{0%{opacity:0}to{opacity:1}}@keyframes nsAscend{0%{opacity:0;transform:translateY(13px)}to{opacity:1;transform:translateY(0)}}:root{--ns-top: 0px}.ns,body.nsh,body.nsh:before,.nsh:before{width:100%;height:100%}.ns,.nsh:before{bottom:0;right:0}.ns{display:flex;justify-content:center;align-items:center}.nsh{--color: DarkSlateGray;--size: 20px;--relSize: calc(var(--size) * .9);--font: "Helvetica", "Arial", sans-serif;--weight: 400;--bg: rgba(255, 255, 255, .9);--zIdx: 999999999;--blur: blur(5px)}.nsh{position:relative;z-index:var(--zIdx)}.nsh:before{position:absolute;background-color:var(--bg);content:"";backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur);z-index:calc(var(--zIdx) + 1);border-radius:inherit}body.nsh,body.nsh:before{position:fixed;top:var(--ns-top);left:0}.ns{position:absolute;z-index:calc(var(--zIdx) + 2);animation:nsFade 2s;gap:var(--relSize)}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);max-width:80dvw;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-shadow:0 0 .06rem rgba(47,79,79,.25);filter:drop-shadow(0 0 .07rem rgba(0,0,0,.25));animation:nsAscend .5s}.nss{display:block;width:var(--relSize);height:var(--relSize);animation:nsAscend .5s}.nss>svg{animation:nsRotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:nsDash 1.5s ease-in-out infinite}',b="3.1.1",c="ns",r=document,i=r.body,a=e=>(s=>({all:s,first:t=>s(t)[0]??null}))(s=>Array.from(e.querySelectorAll(s))),l=e=>a(r).all(e),d=e=>a(r).first(e),f=()=>l(".ns"),m=e=>e instanceof Element?e:d(e),o=(e,...s)=>{const t=r.createElement("div");return e&&t.classList.add(e),t.append(...s),t},h=e=>{const s=o();return s.innerHTML=e,s.firstChild},u=()=>{const s=h('<svg viewBox="0 0 50 50"><circle class=path cx=25 cy=25 r=20 fill=none /></svg>'),t=o("ns",o("nst"),o("nss",s));return t.nsId=Date.now(),t},g=()=>f().sort((e,s)=>e.nsId-s.nsId)[0]??null,w=(e,s)=>{const t=a(e).first(".nst");if(!s)return t==null?void 0:t.remove();const n=o("nst",s);t?t.replaceWith(n):e.insertBefore(n,e.firstChild)},k=(e,s)=>{const t=s.firstElementChild;t&&s.insertBefore(e,t),s.append(e),s.classList.add("nsh")},x=(e,s)=>{const t=s?m(s):i;let n;const v=a(t??i).first("& > .ns");v?n=v:(n=u(),k(n,t)),w(n,e??"");const A=scrollY+"px";return i.style.setProperty("--ns-top",A),n.nsId},p=e=>{var s;(s=e==null?void 0:e.parentElement)==null||s.classList.remove("nsh"),e==null||e.remove()},z=e=>f().find(s=>s.nsId===e)??null,I=e=>{e==="*"?l(".ns").forEach(p):p(typeof e=="number"?z(e):g())},N=()=>{var e;(e=d("#"+c))==null||e.remove(),i.append(h(`<style id=${c}>${y}</style>`))};N(),window.ns={show:x,hide:I,version:b}})();
1
+ (function(){"use strict";const y='@keyframes nsRotate{to{transform:rotate(360deg)}}@keyframes nsDash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}@keyframes nsFade{0%{opacity:0}to{opacity:1}}@keyframes nsAscend{0%{opacity:0;transform:translateY(13px)}to{opacity:1;transform:translateY(0)}}:root{--ns-top: 0px}.ns,body.nsh,body.nsh:before,.nsh:before{width:100%;height:100%}.ns,.nsh:before{bottom:0;right:0}.ns{display:flex;justify-content:center;align-items:center}.nsh{--color: DarkSlateGray;--size: 20px;--relSize: calc(var(--size) * .9);--font: "Helvetica", "Arial", sans-serif;--weight: 400;--bg: rgba(255, 255, 255, .9);--zIdx: 999999999;--blur: blur(5px)}.nsh{position:relative;z-index:var(--zIdx)}.nsh:before{position:absolute;background-color:var(--bg);content:"";backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur);z-index:calc(var(--zIdx) + 1);border-radius:inherit}body.nsh,body.nsh:before{position:fixed;top:var(--ns-top);left:0}.ns{position:absolute;z-index:calc(var(--zIdx) + 2);animation:nsFade 2s;gap:var(--relSize)}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);max-width:80dvw;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-shadow:0 0 .06rem rgba(47,79,79,.25);filter:drop-shadow(0 0 .07rem rgba(0,0,0,.25));animation:nsAscend .5s}.nss{display:block;width:var(--relSize);height:var(--relSize);animation:nsAscend .5s}.nss>svg{animation:nsRotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:nsDash 1.5s ease-in-out infinite}',b="4.0.0",c="ns",r=document,i=r.body,a=e=>(s=>({all:s,first:t=>s(t)[0]??null}))(s=>Array.from(e.querySelectorAll(s))),l=e=>a(r).all(e),d=e=>a(r).first(e),f=()=>l(".ns"),m=e=>e instanceof Element?e:d(e),o=(e,...s)=>{const t=r.createElement("div");return e&&t.classList.add(e),t.append(...s),t},h=e=>{const s=o();return s.innerHTML=e,s.firstChild},u=()=>{const s=h('<svg viewBox="0 0 50 50"><circle class=path cx=25 cy=25 r=20 fill=none /></svg>'),t=o("ns",o("nst"),o("nss",s));return t.nsId=Date.now(),t},g=()=>f().sort((e,s)=>e.nsId-s.nsId)[0]??null,w=(e,s)=>{const t=a(e).first(".nst");if(!s)return t==null?void 0:t.remove();const n=o("nst",s);t?t.replaceWith(n):e.insertBefore(n,e.firstChild)},k=(e,s)=>{const t=s.firstElementChild;t&&s.insertBefore(e,t),s.append(e),s.classList.add("nsh")},x=(e,s)=>{const t=s?m(s):i;let n;const v=a(t??i).first("& > .ns");v?n=v:(n=u(),k(n,t)),w(n,e??"");const S=scrollY+"px";return i.style.setProperty("--ns-top",S),n.nsId},p=e=>{var s;(s=e==null?void 0:e.parentElement)==null||s.classList.remove("nsh"),e==null||e.remove()},z=e=>f().find(s=>s.nsId===e)??null,I=e=>{e==="*"?l(".ns").forEach(p):p(typeof e=="number"?z(e):g())},A=()=>{var e;(e=d("#"+c))==null||e.remove(),i.append(h(`<style id=${c}>${y}</style>`))},N=()=>(A(),{show:x,hide:I,version:b});window.ns=N()})();
@@ -6,6 +6,9 @@ export default defineConfig({
6
6
  description: 'The tiny loading screen for web artisans',
7
7
  base: '/nanosplash/',
8
8
  appearance: 'dark',
9
+ head: [
10
+ ['script', { src: 'https://unpkg.com/nanosplash/dist/iife/ns.iife.js' }],
11
+ ],
9
12
  themeConfig: {
10
13
  nav: [
11
14
  { text: 'Home', link: '/' },
@@ -1,7 +1,6 @@
1
1
  <script setup>
2
2
  import CardGrid from './CardGrid.vue'
3
3
  import Card from './Card.vue'
4
- import Exe from './Exe.vue'
5
4
  </script>
6
5
 
7
6
  <template>
@@ -20,7 +19,6 @@ import Exe from './Exe.vue'
20
19
  Lorem ipsum dolor sit amet consectetur adipiscing elit ut aliquam
21
20
  </Card>
22
21
  </CardGrid>
23
- <Exe />
24
22
  </div>
25
23
  </template>
26
24
 
@@ -18,15 +18,15 @@ Add the following script tag inside of the `<body>` tag:
18
18
  <script src="https://unpkg.com/nanosplash/dist/iife/ns.iife.js"></script>
19
19
  ```
20
20
 
21
- ```html{7}
21
+ ### Example
22
+
23
+ ```html{6}
22
24
  <html>
23
25
  <head>
24
- <meta charset="UTF-8" />
25
26
  <title>My awesome application 🚀</title>
26
27
  </head>
27
28
  <body>
28
29
  <script src="https://unpkg.com/nanosplash/dist/iife/ns.iife.js"></script>
29
- ...
30
30
  </body>
31
31
  </html>
32
32
  ```
@@ -53,5 +53,9 @@ const ns = useNs()
53
53
  ns.show('It works!')
54
54
  ```
55
55
 
56
- The hook will inject the Nanosplash API inside the global `window` object.
57
- You can now start using Nanosplash by simply calling `ns.show`.
56
+ For ease of use, add it to the window object for global access.
57
+
58
+ ```js{2}
59
+ import { useNs } from 'nanosplash'
60
+ window.ns = useNs()
61
+ ```
@@ -8,4 +8,9 @@ Here you can play around with Nanosplash and see how it works.
8
8
 
9
9
  <PlayGround />
10
10
 
11
- Select a method from the dropdown menu above and click "Run" to see it in action.
11
+ Open your browser console (developer tools).
12
+
13
+ - macOS: `⌘` `⌥` `i`
14
+ - Windows: `Ctrl` `⇧` `i`
15
+
16
+ Try to target different elements in the DOM. Nanosplash is available in the window scope as `ns`. Give it a shot!
package/package.json CHANGED
@@ -1,91 +1,91 @@
1
1
  {
2
- "name": "nanosplash",
3
- "version": "3.1.1",
4
- "author": {
5
- "name": "Isak K. Hauge",
6
- "email": "isakhauge@icloud.com",
7
- "url": "https://no.linkedin.com/in/isakhauge"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/isakhauge/nanosplash.git"
12
- },
13
- "main": "./dist/es/ns.js",
14
- "module": "./dist/es/ns.js",
15
- "devDependencies": {
16
- "@types/jsdom": "^21.1.6",
17
- "@types/node": "^20.11.29",
18
- "@types/rollup": "^0.54.0",
19
- "@vitest/coverage-v8": "^1.4.0",
20
- "@vitest/ui": "^1.4.0",
21
- "cross-env": "^7.0.3",
22
- "eslint": "^8.57.0",
23
- "eslint-config-prettier": "^9.1.0",
24
- "eslint-plugin-prettier": "^5.1.3",
25
- "jsdom": "^24.0.0",
26
- "sass": "^1.72.0",
27
- "stylelint-prettier": "^5.0.0",
28
- "typescript": "5.4.2",
29
- "typescript-eslint": "^7.2.0",
30
- "vite": "^5.1.6",
31
- "vitepress": "",
32
- "vitest": "^1.4.0"
33
- },
34
- "exports": {
35
- ".": {
36
- "types": {
37
- "require": "./src/ts/types/global.d.ts",
38
- "default": "./src/ts/types/global.d.ts"
39
- },
40
- "browser": {
41
- "require": "./dist/cjs/ns.cjs",
42
- "default": "./dist/es/ns.js"
43
- },
44
- "default": {
45
- "require": "./dist/cjs/ns.cjs",
46
- "default": "./dist/es/ns.js"
47
- }
48
- }
49
- },
50
- "description": "The tiny loading screen for web artisans",
51
- "homepage": "https://isakhauge.github.io/nanosplash",
52
- "keywords": [
53
- "loading",
54
- "loader",
55
- "screen",
56
- "splash",
57
- "nano",
58
- "nanosplash",
59
- "small",
60
- "tiny",
61
- "es",
62
- "esm",
63
- "ts",
64
- "typescript",
65
- "iife",
66
- "cdn",
67
- "vite"
68
- ],
69
- "license": "MIT",
70
- "private": false,
71
- "source": "./src/main.ts",
72
- "type": "module",
73
- "types": "./src/ts/types/global.d.ts",
74
- "unpkg": "./dist/iife/ns.iife.js",
75
- "scripts": {
76
- "build": "pnpm build:all && pnpm build:docs",
77
- "build:es": "tsc && cross-env entry=./src/ts/Nanosplash.ts format=es vite build -m production --c vite.config.ts",
78
- "build:cjs": "tsc && cross-env entry=./src/ts/Nanosplash.ts format=cjs vite build -m production --c vite.config.ts",
79
- "build:iife": "tsc && cross-env entry=./src/ts/main.ts format=iife vite build -m production --c vite.config.ts",
80
- "build:all": "pnpm build:es && pnpm build:cjs && pnpm build:iife",
81
- "build:docs": "pnpm docs:build",
82
- "preview": "vite preview",
83
- "test": "vitest",
84
- "test:ui": "vitest --ui",
85
- "lint": "eslint src/ts/**/*.ts --fix",
86
- "coverage": "vitest --coverage",
87
- "docs:dev": "pnpm exec vitepress dev docs",
88
- "docs:build": "pnpm exec vitepress build docs",
89
- "docs:preview": "pnpm exec vitepress preview docs"
90
- }
91
- }
2
+ "name": "nanosplash",
3
+ "version": "4.0.0",
4
+ "author": {
5
+ "name": "Isak K. Hauge",
6
+ "email": "isakhauge@icloud.com",
7
+ "url": "https://no.linkedin.com/in/isakhauge"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/isakhauge/nanosplash.git"
12
+ },
13
+ "main": "./dist/es/ns.js",
14
+ "module": "./dist/es/ns.js",
15
+ "devDependencies": {
16
+ "@types/jsdom": "^21.1.6",
17
+ "@types/node": "^20.11.30",
18
+ "@types/rollup": "^0.54.0",
19
+ "@vitest/coverage-v8": "^1.4.0",
20
+ "@vitest/ui": "^1.4.0",
21
+ "cross-env": "^7.0.3",
22
+ "eslint": "^8.57.0",
23
+ "eslint-config-prettier": "^9.1.0",
24
+ "eslint-plugin-prettier": "^5.1.3",
25
+ "jsdom": "^24.0.0",
26
+ "sass": "^1.72.0",
27
+ "stylelint-prettier": "^5.0.0",
28
+ "typescript": "5.4.2",
29
+ "typescript-eslint": "^7.2.0",
30
+ "vite": "^5.1.6",
31
+ "vitepress": "1.0.0-rc.45",
32
+ "vitest": "^1.4.0"
33
+ },
34
+ "exports": {
35
+ ".": {
36
+ "types": {
37
+ "require": "./src/ts/types/global.d.ts",
38
+ "default": "./src/ts/types/global.d.ts"
39
+ },
40
+ "browser": {
41
+ "require": "./dist/cjs/ns.cjs",
42
+ "default": "./dist/es/ns.js"
43
+ },
44
+ "default": {
45
+ "require": "./dist/cjs/ns.cjs",
46
+ "default": "./dist/es/ns.js"
47
+ }
48
+ }
49
+ },
50
+ "description": "The tiny loading screen for web artisans",
51
+ "homepage": "https://isakhauge.github.io/nanosplash",
52
+ "keywords": [
53
+ "loading",
54
+ "loader",
55
+ "screen",
56
+ "splash",
57
+ "nano",
58
+ "nanosplash",
59
+ "small",
60
+ "tiny",
61
+ "es",
62
+ "esm",
63
+ "ts",
64
+ "typescript",
65
+ "iife",
66
+ "cdn",
67
+ "vite"
68
+ ],
69
+ "license": "MIT",
70
+ "private": false,
71
+ "scripts": {
72
+ "build": "pnpm build:all && pnpm build:docs",
73
+ "build:es": "tsc && cross-env entry=./src/ts/Nanosplash.ts format=es vite build -m production --c vite.config.ts",
74
+ "build:cjs": "tsc && cross-env entry=./src/ts/Nanosplash.ts format=cjs vite build -m production --c vite.config.ts",
75
+ "build:iife": "tsc && cross-env entry=./src/ts/main.ts format=iife vite build -m production --c vite.config.ts",
76
+ "build:all": "pnpm build:es && pnpm build:cjs && pnpm build:iife",
77
+ "build:docs": "pnpm docs:build",
78
+ "preview": "vite preview",
79
+ "test": "vitest",
80
+ "test:ui": "vitest --ui",
81
+ "lint": "eslint src/ts/**/*.ts --fix",
82
+ "coverage": "vitest --coverage",
83
+ "docs:dev": "pnpm exec vitepress dev docs",
84
+ "docs:build": "pnpm exec vitepress build docs",
85
+ "docs:preview": "pnpm exec vitepress preview docs"
86
+ },
87
+ "source": "./src/main.ts",
88
+ "type": "module",
89
+ "types": "./src/ts/types/global.d.ts",
90
+ "unpkg": "./dist/iife/ns.iife.js"
91
+ }
@@ -201,9 +201,9 @@ const addCssToBody = (): void => {
201
201
  */
202
202
  export const useNs = (): NanosplashInterface => {
203
203
  addCssToBody()
204
- return (window.ns = {
204
+ return {
205
205
  show,
206
206
  hide,
207
207
  version,
208
- })
208
+ }
209
209
  }
package/src/ts/main.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // @ts-strict
2
2
  import { useNs } from './Nanosplash'
3
- useNs() // Attach API to global scope (Window)
3
+ window.ns = useNs() // Attach API to global scope (Window)
@@ -1,121 +0,0 @@
1
- <script setup>
2
- import { ref, onMounted } from 'vue'
3
-
4
- onMounted(async () => {
5
- if (!window) return
6
- const nsLib = await import('../../../../dist/es/ns.js')
7
- const ns = nsLib.useNs()
8
-
9
- const Commands = {
10
- ShowInsideA: 'ns.show("Loading A", "#a")',
11
- ShowInsideB: 'ns.show("Loading B", "#b")',
12
- ShowInsideC: 'ns.show("Loading C", "#c")',
13
- ShowInsideD: 'ns.show("Loading D", "#d")',
14
- ShowInsideWrapper: 'ns.show("Loading Wrapper", "#wrapper")',
15
- ShowFullScreen: 'ns.show("Loading window")',
16
- Progress: 'Progressive Demo',
17
- Hide: 'ns.hide()',
18
- HideAll: 'ns.hide("*")',
19
- }
20
-
21
- const rCommandString = ref('')
22
-
23
- const wait = ms => new Promise(r => setTimeout(r, ms))
24
-
25
- async function onClickExe() {
26
- const value = rCommandString.value
27
- const phrases = [
28
- 'Generating witty dialog',
29
- 'Swapping time and space',
30
- 'sudo rm -rf /**/*',
31
- 'Tokenizing real life',
32
- 'Pushing pixels',
33
- "Don't think of purple hippos",
34
- 'One mississippi, two mississippi...',
35
- ]
36
- switch (value) {
37
- case Commands.ShowInsideA:
38
- ns.show('Loading A', '#a')
39
- break
40
- case Commands.ShowInsideB:
41
- ns.show('Loading B', '#b')
42
- break
43
- case Commands.ShowInsideC:
44
- ns.show('Loading C', '#c')
45
- break
46
- case Commands.ShowInsideD:
47
- ns.show('Loading D', '#d')
48
- break
49
- case Commands.ShowInsideWrapper:
50
- ns.show('Loading Wrapper', '#wrapper')
51
- break
52
- case Commands.ShowFullScreen:
53
- const id = ns.show('Loading window')
54
- await wait(4000)
55
- ns.hide(id)
56
- break
57
- case Commands.Hide:
58
- ns.hide()
59
- break
60
- case Commands.HideAll:
61
- ns.hide('*')
62
- break
63
- case Commands.Progress:
64
- for (const phrase of phrases) {
65
- ns.show(phrase)
66
- await wait(1500)
67
- }
68
- ns.hide('*')
69
- }
70
- }
71
- })
72
- </script>
73
-
74
- <template>
75
- <div class="container">
76
- <select class="select" v-model="rCommandString">
77
- <option value="" selected disabled>Click and select</option>
78
- <option v-for="(command, i) in Commands" :key="i" :value="command">
79
- {{ command }}
80
- </option>
81
- </select>
82
- <div class="exe" @click="onClickExe">Run</div>
83
- </div>
84
- </template>
85
-
86
- <style lang="sass" scoped>
87
- @use "sass:color"
88
-
89
- $border-radius: 5px
90
- .container
91
- position: relative
92
- display: flex
93
- border-radius: $border-radius
94
- z-index: 1
95
- & > *
96
- padding: 10px 20px
97
-
98
- .select
99
- position: relative
100
- display: flex
101
- flex-grow: 1
102
- font-family: monospace
103
- font-size: 14px
104
- background-color: var(--vp-c-bg-alt)
105
- border-radius: $border-radius 0 0 $border-radius
106
- border: 1px solid rgba(Black, 0.1)
107
- cursor: pointer
108
- width: 100%
109
-
110
- $btn-bg: RoyalBlue
111
- .exe
112
- position: relative
113
- display: inline-flex
114
- color: White
115
- background-color: $btn-bg
116
- cursor: pointer
117
- border-radius: 0 $border-radius $border-radius 0
118
- border: 1px solid rgba(Black, 0.1)
119
- &:hover
120
- background-color: darken($btn-bg, 10%)
121
- </style>