From 16ed2bb7b1130878a9d91254d07167fa196da6de Mon Sep 17 00:00:00 2001 From: Wolfger Schramm Date: Thu, 29 Aug 2024 14:31:59 +0200 Subject: [PATCH] add astro-rainbow-line package --- README.md | 5 +- packages/astro-rainbow-line/.eslintignore | 1 + packages/astro-rainbow-line/.npmignore | 3 + packages/astro-rainbow-line/README.md | 5 ++ packages/astro-rainbow-line/RainbowLine.astro | 40 +++++++++ packages/astro-rainbow-line/package.json | 16 ++++ packages/astro-rainbow-line/project.json | 8 ++ .../astro-rainbow-line/rainbow-line-v0.2.1.js | 90 +++++++++++++++++++ pnpm-lock.yaml | 2 + scripts/publishNpmPkg.mjs | 3 +- 10 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 packages/astro-rainbow-line/.eslintignore create mode 100644 packages/astro-rainbow-line/.npmignore create mode 100644 packages/astro-rainbow-line/README.md create mode 100644 packages/astro-rainbow-line/RainbowLine.astro create mode 100644 packages/astro-rainbow-line/package.json create mode 100644 packages/astro-rainbow-line/project.json create mode 100644 packages/astro-rainbow-line/rainbow-line-v0.2.1.js diff --git a/README.md b/README.md index bffdbe3..33e3d53 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,9 @@ $ pnpm cbt # => clean build test | package | description | |-|-| -| [`offscreen-display`](packages/offscreen-display/) | Helpers for creating custom offscreen canvas elements | -| [`rainbow-line`](packages/rainbow-line/) | A custom element that displays a cut line animated with rainbow colors | +| [`offscreen-display`](packages/offscreen-display/) | helpers for creating custom offscreen canvas elements | +| [`rainbow-line`](packages/rainbow-line/) | a web component that displays a cut line animated with rainbow colors | +| [`@spearwolf/astro-rainbow-line`](packages/astro-rainbow-line/) | astro wrapper for the rainbow-line web component | ‼️ [for those interested in the shadow-ents-* packages, we are happy to announce that they have now been relocated to their own dedicated monorepo, "shadow-objects"](https://github.com/spearwolf/shadow-objects) diff --git a/packages/astro-rainbow-line/.eslintignore b/packages/astro-rainbow-line/.eslintignore new file mode 100644 index 0000000..d5557c4 --- /dev/null +++ b/packages/astro-rainbow-line/.eslintignore @@ -0,0 +1 @@ +rainbow-line-v0.2.1.js diff --git a/packages/astro-rainbow-line/.npmignore b/packages/astro-rainbow-line/.npmignore new file mode 100644 index 0000000..7ad8e67 --- /dev/null +++ b/packages/astro-rainbow-line/.npmignore @@ -0,0 +1,3 @@ +node_modules +.eslintignore +project.json diff --git a/packages/astro-rainbow-line/README.md b/packages/astro-rainbow-line/README.md new file mode 100644 index 0000000..87f8d9f --- /dev/null +++ b/packages/astro-rainbow-line/README.md @@ -0,0 +1,5 @@ +# @spearwolf/astro-rainbow-line + +An astro wrapper for the [rainbow-line web component](https://github.com/spearwolf/visual-fx-web-components/tree/main/packages/rainbow-line). + +> It is currently assumed that the [rainbow-line.js](./rainbow-line-v0.2.1.js) is located under `${import.meta.env.BASE_URL}/js/rainbow-line-v0.2.1.js`. diff --git a/packages/astro-rainbow-line/RainbowLine.astro b/packages/astro-rainbow-line/RainbowLine.astro new file mode 100644 index 0000000..0af8256 --- /dev/null +++ b/packages/astro-rainbow-line/RainbowLine.astro @@ -0,0 +1,40 @@ +--- +interface Props { + shadow?: boolean; + colorSliceWidth?: number; + sliceCycleTime?: number; + cycleDirection?: 'left' | 'right'; +} + +const {shadow = false, colorSliceWidth = 10, sliceCycleTime = 7, cycleDirection = 'right'} = Astro.props; +--- + + +{ + shadow && ( + + ) +} + + + + diff --git a/packages/astro-rainbow-line/package.json b/packages/astro-rainbow-line/package.json new file mode 100644 index 0000000..a0c4c6b --- /dev/null +++ b/packages/astro-rainbow-line/package.json @@ -0,0 +1,16 @@ +{ + "name": "@spearwolf/astro-rainbow-line", + "description": "astro wrapper for the rainbow-line web component", + "version": "1.0.0", + "main": "RainbowLine.astro", + "author": { + "name": "Wolfger Schramm", + "email": "wolfger@spearwolf.de", + "url": "https://www.spearwolf.de" + }, + "license": "Apache-2.0", + "homepage": "https://github.com/spearwolf/visual-fx-web-components", + "scripts": { + "publishNpmPkg": "pnpm node ../../scripts/publishNpmPkg.mjs ." + } +} diff --git a/packages/astro-rainbow-line/project.json b/packages/astro-rainbow-line/project.json new file mode 100644 index 0000000..357105f --- /dev/null +++ b/packages/astro-rainbow-line/project.json @@ -0,0 +1,8 @@ +{ + "name": "astro-rainbow-line", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "root": "packages/astro-rainbow-line", + "sourceRoot": "{projectRoot}", + "projectType": "library", + "tags": [] +} diff --git a/packages/astro-rainbow-line/rainbow-line-v0.2.1.js b/packages/astro-rainbow-line/rainbow-line-v0.2.1.js new file mode 100644 index 0000000..a285600 --- /dev/null +++ b/packages/astro-rainbow-line/rainbow-line-v0.2.1.js @@ -0,0 +1,90 @@ +/*! +@file rainbow-line - A custom element that displays a cut line animated with rainbow colors +@author Wolfger Schramm +@version 0.2.0+vanilla.20240510 + +Copyright 2024 Wolfger Schramm + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*/ +var o=class c extends HTMLElement{static InitialHTML=` + +
+ +
+ `;#e=0;#t=0;#i=0;constructor(e=c.InitialHTML){super(),this.shadow=this.attachShadow({mode:"open"}),this.shadow.innerHTML=e,this.worker=void 0}queryCanvasElement(){return this.shadow.querySelector("canvas")}createWorker(){throw new Error("createWorker() must be implemented by subclass")}getContextAttributes(){return this.hasAttribute("no-alpha")?{alpha:!1}:{alpha:!0}}#r(){let e=this.canvas.getBoundingClientRect();return this.#e=e.width,this.#t=e.height,{width:e.width,height:e.height}}#n(e){let t=this.canvas.getBoundingClientRect();(this.#e!==t.width||this.#t!==t.height)&&(this.#e=t.width,this.#t=t.height,e(t.width,t.height))}#a=()=>{this.#n((e,t)=>{this.worker.postMessage({resize:{width:e,height:t}})}),this.#s()};#s(){this.#i=requestAnimationFrame(this.#a)}#l(){cancelAnimationFrame(this.#i)}#h(){this.canvas=this.queryCanvasElement();let e=this.canvas.transferControlToOffscreen();this.worker=this.createWorker(),this.worker.postMessage({canvas:e,contextAttributes:this.getContextAttributes(),...this.getInitialWorkerAttributes()},[e])}getInitialWorkerAttributes(){return{}}asNumberValue(e,t){if(this.hasAttribute(e)){let i=parseFloat(this.getAttribute(e));return isNaN(i)?t:i}return t}connectedCallback(){this.worker||this.#h(),this.worker.postMessage({isConnected:!0,resize:this.#r()}),this.#s()}disconnectedCallback(){this.worker.postMessage({isConnected:!1}),this.#l()}};var u=s=>s==="left"?1:-1,r=class extends o{static observedAttributes=["color-slice-width","slice-cycle-time","cycle-direction"];constructor(){super(` + +
+ +
`)}createWorker(){return new Worker(new URL("rainbow-line.worker.js",import.meta.url),{type:"module"})}getContextAttributes(){return{alpha:!1}}getInitialWorkerAttributes(){return{"color-slice-width":this.asNumberValue("color-slice-width",10),"slice-cycle-time":this.asNumberValue("slice-cycle-time",7),"cycle-direction":u(this.getAttribute("cycle-direction")||"right")}}attributeChangedCallback(e,t,i){if(!this.worker)return;let n=e==="cycle-direction"?u(i):parseFloat(i);typeof n=="number"&&(isNaN(n)||this.worker.postMessage({[e]:n}))}};function a(s){let e=new Blob([s],{type:"text/javascript"}),t=URL.createObjectURL(e),i=new Worker(t);return URL.revokeObjectURL(t),i}function l(){return a(`var Ne=Object.defineProperty;var $e=(e,t,i)=>t in e?Ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var f=(e,t,i)=>($e(e,typeof t!="symbol"?t+"":t,i),i),J=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};var a=(e,t,i)=>(J(e,t,"read from private field"),i?i.call(e):t.get(e)),u=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},d=(e,t,i,r)=>(J(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);var ye=(e,t,i,r)=>({set _(n){d(e,t,n,i)},get _(){return a(e,t,r)}}),D=(e,t,i)=>(J(e,t,"access private method"),i);var qe=Object.defineProperty,Be=(e,t,i)=>t in e?qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,m=(e,t,i)=>(Be(e,typeof t!="symbol"?t+"":t,i),i),He=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},Ge=(e,t,i)=>(He(e,t,"read from private field"),i?i.call(e):t.get(e)),je=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},Z={Max:Number.POSITIVE_INFINITY,AAA:1e9,BB:1e6,C:1e3,Default:0,Low:-1e4,Min:Number.NEGATIVE_INFINITY},g="*",ge=1,ie=2,re=4,be=(Symbol.eventize||(Symbol.eventize=Symbol("eventize")),Symbol.eventize),Ue="[eventize]",q=e=>e===g,Ce=e=>{switch(typeof e){case"string":case"symbol":return!0;default:return!1}},Se=typeof console!="undefined",Ke=Se?console[console.warn?"warn":"log"].bind(console,Ue):()=>{},Ye=(e,t,i)=>(Object.defineProperty(e,t,{value:i,configurable:!0}),e),Je=0,xe=class{constructor(){m(this,"events",new Map),m(this,"eventNames",new Set)}static publish(e){e.sort((t,i)=>t.order-i.order).forEach(t=>t.emit())}add(e){Array.isArray(e)?e.forEach(t=>this.eventNames.add(t)):this.eventNames.add(e)}remove(e){Array.isArray(e)?e.forEach(t=>this.eventNames.delete(t)):this.eventNames.delete(e),this.clear(e)}clear(e){Array.isArray(e)?e.forEach(t=>this.events.delete(t)):this.events.delete(e)}retain(e,t){this.eventNames.has(e)&&this.events.set(e,{args:t,order:Je++})}isKnown(e){return this.eventNames.has(e)}emit(e,t,i=[]){if(q(e))this.eventNames.forEach(r=>this.emit(r,t,i));else if(this.events.has(e)){let{order:r,args:n}=this.events.get(e);i.push({order:r,emit:()=>t.apply(e,n)})}return i}},V=(e,t,i,r)=>{if(typeof t=="function"){let n=t.apply(e,i);n!=null&&(r==null||r(n))}},Xe=(e,t,i,r)=>V(t,t.emit,[e].concat(i),r),Ze=e=>{switch(typeof e){case"function":return ge;case"string":case"symbol":return ie;case"object":return re}},Ve=0,et=()=>++Ve,Le=class{constructor(e,t,i,r=null){m(this,"id"),m(this,"eventName"),m(this,"isCatchEmAll"),m(this,"priority"),m(this,"listener"),m(this,"listenerObject"),m(this,"listenerType"),m(this,"callAfterApply"),m(this,"isRemoved"),m(this,"refCount"),this.id=et(),this.eventName=e,this.isCatchEmAll=q(e),this.listener=i,this.listenerObject=r,this.priority=t,this.listenerType=Ze(i),this.callAfterApply=void 0,this.isRemoved=!1,this.refCount=1}isEqual(e,t=null){if(e===this)return!0;let i=typeof e;return i==="number"&&e===this.id?!0:t===null&&(i==="string"||i==="symbol")?e===g||e===this.eventName:this.listener===e&&this.listenerObject===t}apply(e,t,i){if(this.isRemoved)return;let{listener:r,listenerObject:n}=this;switch(this.listenerType){case ge:V(n,r,t,i),this.callAfterApply&&this.callAfterApply();break;case ie:V(n,n[r],t,i),this.callAfterApply&&this.callAfterApply();break;case re:{let h=r[e];if(this.isCatchEmAll||this.eventName===e){if(typeof h=="function"){let s=h.apply(r,t);s!=null&&(i==null||i(s))}else Xe(e,r,t,i);this.callAfterApply&&this.callAfterApply()}break}}}},tt=(e,t)=>e.priority!==t.priority?t.priority-e.priority:e.id-t.id,me=e=>e==null?void 0:e.slice(0),pe=(e,t)=>{let i=e.indexOf(t);i>-1&&e.splice(i,1)},it=e=>e===re||e===ie,ee=(e,t,i)=>{let r=e.findIndex(n=>n.isEqual(t,i));r>-1&&(e[r].isRemoved=!0,e.splice(r,1))},N=(e,t,i)=>{let r=[];for(let n of e)(t==null&&n.listenerObject===i||n.eventName===t&&n.listener===i)&&r.push(n);for(let n of r)ee(e,n,void 0)},X=e=>{e&&(e.forEach(t=>{t.isRemoved=!0}),e.length=0)},rt=(e,t)=>e.listenerType===t.listenerType?e.priority===t.priority&&e.eventName===t.eventName&&e.listenerObject===t.listenerObject&&e.listener===t.listener:!1,st=(e,t)=>{if(it(e.listenerType))return t.find(i=>rt(e,i))},nt=(e,t)=>{let i=st(e,t);return i?(i.refCount+=1,i):(t.push(e),t.sort(tt),e)},te,ot=class{constructor(){m(this,"namedListeners"),m(this,"catchEmAllListeners"),je(this,te,e=>{let t=this.namedListeners.get(e);return t||(t=[],this.namedListeners.set(e,t)),t}),this.namedListeners=new Map,this.catchEmAllListeners=[]}add(e){return nt(e,e.isCatchEmAll?this.catchEmAllListeners:Ge(this,te).call(this,e.eventName))}remove(e,t,i=!1){t==null&&Array.isArray(e)?e.forEach(r=>this.remove(r,null,i)):e==null||t==null&&q(e)?this.removeAllListeners():t==null&&Ce(e)?X(this.namedListeners.get(e)):e instanceof Le?e.isRemoved||(e.refCount-=1,e.refCount<1&&(e.isRemoved=!0,this.namedListeners.forEach(r=>pe(r,e)),pe(this.catchEmAllListeners,e))):i?q(e)?N(this.catchEmAllListeners,g,e):this.namedListeners.forEach(r=>N(r,e,t)):(this.namedListeners.forEach(r=>{ee(r,e,t),N(r,void 0,e)}),ee(this.catchEmAllListeners,e,t),N(this.catchEmAllListeners,void 0,e))}removeAllListeners(){this.namedListeners.forEach(e=>X(e)),this.namedListeners.clear(),X(this.catchEmAllListeners)}forEach(e,t){let i=me(this.catchEmAllListeners),r=me(this.namedListeners.get(e));if(e===g||!r||r.length===0)i.forEach(t);else if(i.length===0)r.forEach(t);else{let n=r.length,h=i.length,s=0,o=0;for(;s=h||l.priority>=i[o].priority){t(l),++s;continue}}o!!(e&&e[be]),ct=(e,t,i,r,n,h,s)=>{let o=e.add(new Le(i,r,n,h));return t.emit(i,o,s),o},at=(e,t,i,r)=>{let n=i.length,h=typeof i[0],s,o,l,c;if(n>=2&&n<=3&&h==="number"?(s=g,[o,l,c]=i):n>=3&&n<=4&&typeof i[1]=="number"?[s,o,l,c]=i:(o=Z.Default,h==="string"||h==="symbol"||Array.isArray(i[0])?[s,l,c]=i:(s=g,[l,c]=i)),!l&&Se)throw Ke("called with insufficient arguments!",i),"subscribeTo() called with insufficient arguments!";let p=A=>We=>ct(e,t,We,A,l,c,r);return Array.isArray(s)?s.map(A=>Array.isArray(A)?p(A[1])(A[0]):p(o)(A)):p(o)(s)},ve=(e,t,i)=>{let r=[],n=at(e,t,i,r);return xe.publish(r),n},Ee=e=>t=>{t.callAfterApply=()=>{e==null||e()}},Ae=(e,t)=>Object.assign(()=>e.off(t),Array.isArray(t)?{listeners:t}:{listener:t});function $(e){if(we(e))return e;let t=new ot,i=new xe;Ye(e,be,{keeper:i,store:t});let r=s=>{let o=ve(t,i,s),l=Ae(h,o),c=!1,p=()=>{c||(l(),c=!0)};return Array.isArray(o)?o.forEach(Ee(p)):Ee(p)(o),p},n=(s,o,l)=>{Array.isArray(s)?s.forEach(c=>{t.forEach(c,p=>p.apply(c,o,l)),i.retain(c,o)}):s!==g&&(t.forEach(s,c=>{c.apply(s,o,l)}),i.retain(s,o))},h=Object.assign(e,{on(...s){return Ae(h,ve(t,i,s))},once(...s){return r(s)},onceAsync(s){return new Promise(o=>{r([s,o])})},off(s,o){let l=typeof s,c=o!=null&&(l==="string"||l==="symbol");t.remove(s,o,c),Array.isArray(s)?i.remove(s.filter(p=>typeof p=="string")):Ce(s)&&i.remove(s)},emit(s,...o){n(s,o)},emitAsync(s,...o){let l=[];return n(s,o,c=>{l.push(c)}),l=l.map(c=>Array.isArray(c)?Promise.all(c):Promise.resolve(c)),l.length>0?Promise.all(l):Promise.resolve()},retain(s){i.add(s)},retainClear(s){i.clear(s)}});return h}var F=(()=>{let e=(t={})=>$(t);return e.inject=$,e.extend=t=>$(Object.create(t)),e.create=t=>{let i=$({});return i.on(g,Z.Default,t),i},e.is=we,e.Priority=Z,e})();var O,P,z=class{constructor(t="id",i=1){u(this,O,void 0);u(this,P,void 0);d(this,O,t),d(this,P,i)}make(){return Symbol(\`\${a(this,O)}\${ye(this,P)._++}\`)}};O=new WeakMap,P=new WeakMap;var lt=0;function Fe(){return lt>0}var B=Symbol("signal"),se=Symbol("destroySignal"),ne=Symbol("createEffect"),ze=Symbol("destroyEffect");var R=F({}),H=F({}),b=F({});var M,C=class{constructor(){u(this,M,new Set)}batch(t){a(this,M).add(t)}run(){b.emit(Array.from(a(this,M)))}};M=new WeakMap,f(C,"current");var Re=()=>C.current;function oe(e){let t=C.current;t?t=void 0:t=C.current=new C;try{e()}finally{t&&(C.current=void 0,t.run())}}var ce=[],G=()=>ce.at(-1),Ie=(e,t)=>{ce.push(e);try{return t()}finally{ce.pop()}};var ft=e=>e!=null&&typeof e.then=="function",S,x,L,w,I,E=class E{constructor(t,i){f(this,"id");f(this,"callback");u(this,S,void 0);u(this,x,new Set);u(this,L,new Set);f(this,"parentEffect");f(this,"childEffects",[]);f(this,"curChildEffectSlot",0);f(this,"autorun",!0);f(this,"shouldRun",!0);u(this,w,void 0);u(this,I,!1);var r;this.callback=t,this.autorun=(r=i==null?void 0:i.autorun)!=null?r:!0,d(this,w,i==null?void 0:i.dependencies),this.id=E.idGen.make(),b.on(this.id,"recall",this),++E.count}hasStaticDeps(){return a(this,w)!=null&&a(this,w).length>0}saveSignalsFromDeps(){for(let t of a(this,w))this.whenSignalIsRead(ae(t).id)}static createEffect(t,i,r){let n=Array.isArray(i)?i:void 0,h=n?r!=null?r:{dependencies:n}:i;h&&n&&(h.dependencies=n);let s,o=G();return o!=null?(s=o.getCurrentChildEffect(),s==null&&(s=new E(t,h),o.attachChildEffect(s),b.emit(ne,s)),o.curChildEffectSlot++):(s=new E(t,h),b.emit(ne,s)),s.hasStaticDeps()?s.saveSignalsFromDeps():s.autorun&&s.run(),[s.run.bind(s),s.destroy.bind(s)]}getCurrentChildEffect(){return this.childEffects[this.curChildEffectSlot]}attachChildEffect(t){this.childEffects.push(t),this.parentEffect=this}run(){if(a(this,I)||!this.shouldRun)return;let t=Re();t?t.batch(this.id):(this.runCleanupCallback(),this.curChildEffectSlot=0,this.shouldRun=!1,this.hasStaticDeps()?d(this,S,this.callback()):d(this,S,Ie(this,this.callback)))}recall(){this.shouldRun=!0,this.autorun&&this.run()}whenSignalIsRead(t){a(this,x).has(t)||(a(this,x).add(t),R.on(t,"recall",this),H.once(t,se,this))}[se](t){!a(this,L).has(t)&&a(this,x).has(t)&&(a(this,L).add(t),R.off(t,this),a(this,L).size===a(this,x).size&&this.destroy())}runCleanupCallback(){if(a(this,S)!=null){let t=a(this,S);d(this,S,void 0),ft(t)?Promise.resolve(t).then(i=>{typeof i=="function"&&i()}):t()}}destroy(){a(this,I)||(b.emit(ze,this),this.runCleanupCallback(),R.off(this),b.off(this),H.off(this),d(this,I,!0),a(this,x).clear(),a(this,L).clear(),this.childEffects.forEach(t=>{t.destroy()}),this.childEffects.length=0,--E.count)}};S=new WeakMap,x=new WeakMap,L=new WeakMap,w=new WeakMap,I=new WeakMap,f(E,"idGen",new z("ef")),f(E,"count",0);var j=E;var T=(...e)=>j.createEffect(...e);var ht=new z("si");function Te(e){var t;Fe()||(t=G())==null||t.whenSignalIsRead(e)}function De(e,t,i){R.emit(e,t,i)}var ut=e=>typeof e=="function"&&B in e,dt=e=>{let t=i=>{var r;return i?T(()=>(e.destroyed||Te(e.id),i(e.value)),[t]):e.destroyed||((r=e.beforeReadFn)==null||r.call(e),Te(e.id)),e.value};return Object.defineProperty(t,B,{value:e}),t},v,U=class U{constructor(t,i){f(this,"id");f(this,"lazy");f(this,"compareFn");f(this,"beforeReadFn");f(this,"muted",!1);f(this,"destroyed",!1);u(this,v,void 0);f(this,"valueFn");f(this,"reader");f(this,"writer",(t,i)=>{var o,l,c;let r=(o=i==null?void 0:i.lazy)!=null?o:!1,n=(l=i==null?void 0:i.compareFn)!=null?l:this.compareFn,h=n!=null?n:(p,A)=>p===A;if((r!==this.lazy||r&&t!==this.valueFn||!r&&!h(t,a(this,v)))&&(r?(d(this,v,void 0),this.valueFn=t,this.lazy=!0):(d(this,v,t),this.valueFn=void 0,this.lazy=!1),!this.muted&&!this.destroyed)){De(this.id,a(this,v));return}((c=i==null?void 0:i.touch)!=null?c:!1)&&De(this.id,a(this,v),{touch:!0})});this.id=ht.make(),++U.instanceCount,this.lazy=t,this.lazy?(this.value=void 0,this.valueFn=i):(this.value=i,this.valueFn=void 0),this.reader=dt(this)}get value(){return this.lazy&&(d(this,v,this.valueFn()),this.valueFn=void 0,this.lazy=!1),a(this,v)}set value(t){d(this,v,t)}};v=new WeakMap,f(U,"instanceCount",0);var le=U,ae=e=>e==null?void 0:e[B];function _(e=void 0,t){var r;let i;if(ut(e))i=ae(e);else{let n=(r=t==null?void 0:t.lazy)!=null?r:!1;i=new le(n,e),i.beforeReadFn=t==null?void 0:t.beforeReadFn,i.compareFn=t==null?void 0:t.compareFn}return[i.reader,i.writer]}var y,k,Q,W,fe,K,Pe,Y,Me,Oe=(y=class{constructor(){u(this,W);u(this,K);u(this,Y);u(this,k,0);u(this,Q,void 0);F(this);let[t,i]=_(null),[r,n]=_(!1),[h,s]=_(0),[o,l]=_(0);Object.defineProperties(this,{canvas:{get:()=>t(),set:c=>{i(c)},enumerable:!0},isConnected:{get:()=>r(),set:c=>{n(c)},enumerable:!0},canvasWidth:{get:()=>h(),set:c=>{s(c)},enumerable:!0},canvasHeight:{get:()=>o(),set:c=>{l(c)},enumerable:!0}}),this.now=0,this.retain([y.Canvas,y.Init,y.Resize]),T(()=>{this.canvas&&this.emit(y.Canvas,this,a(this,Q))},[t]),T(()=>{this.ready&&this.emit(y.Init,this)},[t,r]),T(()=>{this.emit(y.Resize,this)},[h,o])}get ready(){return this.canvas&&this.isConnected}parseMessageData(t){t&&(t.canvas&&(d(this,Q,t.contextAttributes||void 0),this.canvas=t.canvas),t.isConnected&&this.isConnected!==t.isConnected&&(this.isConnected=t.isConnected,this.isConnected?D(this,W,fe).call(this):D(this,K,Pe).call(this)),t.resize&&this.canvas&&(this.canvas.width=Math.floor(t.resize.width),this.canvas.height=Math.floor(t.resize.height)))}},k=new WeakMap,Q=new WeakMap,W=new WeakSet,fe=function(){d(this,k,requestAnimationFrame(t=>D(this,Y,Me).call(this,t)))},K=new WeakSet,Pe=function(){cancelAnimationFrame(a(this,k))},Y=new WeakSet,Me=function(t){this.ready&&(oe(()=>{this.canvasWidth=this.canvas.width,this.canvasHeight=this.canvas.height}),this.now=t/1e3,this.canvasWidth>0&&this.canvasHeight>0&&this.emit(y.Frame,this)),D(this,W,fe).call(this)},f(y,"Canvas","onCanvas"),f(y,"Init","onInit"),f(y,"Resize","onResize"),f(y,"Frame","onFrame"),y);var _e=new Oe,ue=10,de=7,ke=-1,he=null;_e.on({onCanvas({canvas:e},t){he=e.getContext("2d",t)},onFrame({now:e,canvasWidth:t,canvasHeight:i}){let r=0;for(;r{Qe(e.data)}); +/*! Bundled license information: + +@spearwolf/eventize/lib/index.mjs: + (*! + ============================================================================= + @spearwolf/eventize 3.4.1+build.20231031 + \u2014 https://github.com/spearwolf/eventize.git + ============================================================================= + + Copyright 2015-2023 Wolfger Schramm + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + *) +*/ +`)}var h=class extends r{createWorker(){return l()}};customElements.define("rainbow-line",h); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9ccd108..fd9d319 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -102,6 +102,8 @@ importers: specifier: ^1.6.0 version: 1.6.0(@types/node@20.14.8)(happy-dom@14.12.3) + packages/astro-rainbow-line: {} + packages/offscreen-display: dependencies: '@spearwolf/eventize': diff --git a/scripts/publishNpmPkg.mjs b/scripts/publishNpmPkg.mjs index 03578c6..605e779 100644 --- a/scripts/publishNpmPkg.mjs +++ b/scripts/publishNpmPkg.mjs @@ -37,7 +37,8 @@ exec(`npm show ${pkgJson.name} versions --json`, (error, stdout, stderr) => { } else { publishPackage(); } - } else if (stderr && stderr.toString().includes('npm ERR! code E404')) { + } else if (stderr && stderr.toString().includes('E404')) { + // => npm ERR! code E404 console.log('oh it looks like this is the first time to publish the package'); publishPackage(); } else {