From a2cccec86132593c4f92b5e7e23c6d37ccde15de Mon Sep 17 00:00:00 2001 From: Luiz Bills Date: Tue, 7 May 2024 22:54:26 -0300 Subject: [PATCH] update engine --- package-lock.json | 15 +- public/about.html | 21 +- public/app.js | 13 +- public/litecanvas.js | 944 ++++++++++++++++++++++++++++++++++++++++++- public/sw.js | 2 +- src/completions.js | 8 +- src/demo.js | 5 +- src/template.js | 6 +- 8 files changed, 976 insertions(+), 38 deletions(-) diff --git a/package-lock.json b/package-lock.json index d491cea..a3acd6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -523,14 +523,17 @@ } }, "node_modules/@litecanvas/litecanvas": { - "version": "0.27.0", - "resolved": "https://registry.npmjs.org/@litecanvas/litecanvas/-/litecanvas-0.27.0.tgz", - "integrity": "sha512-Nlf4UhX3yOu1+ZRa1Jj5OXHWx2LQk91dbA8QOh0DE9N9jalY4wb3AMojTW3O1wgYhvrVcC4x3HivZAgj9zSVRg==" + "version": "0.28.0", + "resolved": "https://registry.npmjs.org/@litecanvas/litecanvas/-/litecanvas-0.28.0.tgz", + "integrity": "sha512-t8ZeOlRcUp29sjgsCk1PXK1WGwBY0G8fHebov4OscSPZQWEakm8N9gJCj48sdZzioF5M/iijoY13XjgJu9o2Rw==" }, "node_modules/@litecanvas/plugin-asset-loader": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@litecanvas/plugin-asset-loader/-/plugin-asset-loader-0.4.0.tgz", - "integrity": "sha512-ebqPKSQG3MUzMd+62vlVZmaxQodg6v8nW6L/Gfa/4B6bJgDRv/AQntwULi1NIka3xb639HKRco2OHSBevZ+8SQ==" + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@litecanvas/plugin-asset-loader/-/plugin-asset-loader-0.4.2.tgz", + "integrity": "sha512-sDDgEwIeIR1aYD8JMzLAfW3A45zQhho9zWQCPyvqPO+hwWDoxIbV8bOMMn1J06z/8XANpOFNCFCx9fvZphgVoQ==", + "peerDependencies": { + "@litecanvas/litecanvas": "*" + } }, "node_modules/codemirror": { "version": "6.0.1", diff --git a/public/about.html b/public/about.html index 6cd7d61..5f657de 100644 --- a/public/about.html +++ b/public/about.html @@ -497,7 +497,11 @@

Variables

Plugin API

-
// create or update variables
+      
// loads a plugin
+// see: https://github.com/litecanvas/game-engine/blob/main/samples/plugin-basics/plugin-basics.js
+use(callback): object|void
+
+// create or update variables
 setvar(name: string, value: any): void
 
 // get the color value
@@ -514,20 +518,7 @@ 

Advanced Features

// the plugin "Asset Loader" is automatically loaded into the playground
 // see: https://github.com/litecanvas/plugin-asset-loader
-
-// Asynchronously load an image
-loadImage(url: string, callback: function): void
-
-// Asynchronously load an external JavaScript file
-loadScript(url: string, callback: function): void
-
-// Asynchronously load a font
-loadFont(fontName:string, url: string, callback: function): void
-
-// a special variable that indicates if are loading or not
-// if equal to 0 then are not loading any asset
-// note: put `if (LOADING > 0) return` in your `update()` and `draw()`
-LOADING: number
+
diff --git a/public/app.js b/public/app.js index ac15221..be0647c 100644 --- a/public/app.js +++ b/public/app.js @@ -149,7 +149,10 @@ Rule: "${re.ruleId}"`),re}return f({directives:Ie.disableDirectives,disableFixes `,loc:We.loc}))}})}let Te=z.allowInlineConfig&&!z.warnInlineConfig?pe(we,Fe=>O(Fe,ce)):{problems:[],disableDirectives:[]},Be=Object.assign({},ce.rules,L.rules),$e;we.finalize();try{$e=wt(we,Be,Fe=>O(Fe,ce),void 0,ie,de,z.filename,z.disableFixes,oe.cwd,ee.physicalFilename,z.ruleFilter,z.stats,oe)}catch(Fe){if(Fe.message+=` Occurred while linting ${z.filename}`,B("An error occurred while traversing"),B("Filename:",z.filename),Fe.currentNode){let{line:Oe}=Fe.currentNode.loc.start;B("Line:",Oe),Fe.message+=`:${Oe}`}throw B("Parser Options:",ie.parserOptions),B("Settings:",de),Fe.ruleId&&(Fe.message+=` Rule: "${Fe.ruleId}"`),Fe}return f({directives:Te.disableDirectives,disableFixes:z.disableFixes,problems:$e.concat(Te.problems).concat(ue).sort((Fe,Oe)=>Fe.line-Oe.line||Fe.column-Oe.column),reportUnusedDisableDirectives:z.reportUnusedDisableDirectives,ruleFilter:z.ruleFilter,configuredRules:Be})}_verifyWithConfigArray(X,ne,ee){B("With ConfigArray: %s",ee.filename),xt.get(this).lastConfigArray=ne;let oe=ne.extractConfig(ee.filename),ce=oe.processor&&ne.pluginProcessors.get(oe.processor);if(ce){B("Apply the processor: %o",oe.processor);let{preprocess:z,postprocess:J,supportsAutofix:ie}=ce,de=ee.disableFixes||!ie;return this._verifyWithProcessor(X,oe,{...ee,disableFixes:de,postprocess:J,preprocess:z},ne)}return this._verifyWithoutProcessors(X,oe,ee)}_verifyWithFlatConfigArray(X,ne,ee,oe=!1){B("With flat config: %s",ee.filename);let ce=ee.filename||"__placeholder__.js";xt.get(this).lastConfigArray=ne;let z=ne.getConfig(ce);if(!z)return[{ruleId:null,severity:1,message:`No matching configuration found for ${ce}.`,line:0,column:0,nodeType:null}];if(z.processor){B("Apply the processor: %o",z.processor);let{preprocess:J,postprocess:ie,supportsAutofix:de}=z.processor,we=ee.disableFixes||!de;return this._verifyWithFlatConfigArrayAndProcessor(X,z,{...ee,filename:ce,disableFixes:we,postprocess:ie,preprocess:J},ne)}return oe&&(ee.preprocess||ee.postprocess)?this._verifyWithFlatConfigArrayAndProcessor(X,z,ee):this._verifyWithFlatConfigArrayAndWithoutProcessors(X,z,ee)}_verifyWithProcessor(X,ne,ee,oe){let ce=ee.filename||"",z=qe(ce),J=ee.physicalFilename||z,ie=vt(X),de=ee.preprocess||($e=>[$e]),we=ee.postprocess||($e=>$e.flat()),L=ee.filterCodeBlock||($e=>$e.endsWith(".js")),ue=r.extname(ce),Te;try{Te=de(ie,z)}catch($e){let Fe=`Preprocessing error: ${$e.message.replace(/^line \d+:/iu,"").trim()}`;return B(`%s -%s`,Fe,$e.stack),[{ruleId:null,fatal:!0,severity:2,message:Fe,line:$e.lineNumber,column:$e.column,nodeType:null}]}let Be=Te.map(($e,Fe)=>{if(B("A code block was found: %o",$e.filename||"(unnamed)"),typeof $e=="string")return this._verifyWithoutProcessors($e,ne,ee);let Oe=$e.text,Ie=r.join(ce,`${Fe}_${$e.filename}`);return L(Ie,Oe)?oe&&(ie!==Oe||r.extname(Ie)!==ue)?(B("Resolving configuration again because the file content or extension was changed."),this._verifyWithConfigArray(Oe,oe,{...ee,filename:Ie,physicalFilename:J})):this._verifyWithoutProcessors(Oe,ne,{...ee,filename:Ie,physicalFilename:J}):(B("This code block was skipped."),[])});return we(Be,z)}_distinguishSuppressedMessages(X){let ne=[],ee=[],oe=xt.get(this);for(let ce of X)ce.suppressions?ee.push(ce):ne.push(ce);return oe.lastSuppressedMessages=ee,ne}getSourceCode(){return xt.get(this).lastSourceCode}getTimes(){return xt.get(this).times??{passes:[]}}getFixPassCount(){return xt.get(this).fixPasses??0}getSuppressedMessages(){return xt.get(this).lastSuppressedMessages}defineRule(X,ne){Ye(this),xt.get(this).ruleMap.define(X,ne)}defineRules(X){Ye(this),Object.getOwnPropertyNames(X).forEach(ne=>{this.defineRule(ne,X[ne])})}getRules(){Ye(this);let{lastConfigArray:X,ruleMap:ne}=xt.get(this);return new Map(function*(){yield*ne,X&&(yield*X.pluginRules)}())}defineParser(X,ne){Ye(this),xt.get(this).parserMap.set(X,ne)}verifyAndFix(X,ne,ee){let oe,ce,z=!1,J=0,ie=X,de=ee&&ee.filename||`${X.slice(0,10)}...`,we=ee&&typeof ee.fix<"u"?ee.fix:!0,L=ee?.stats,ue=xt.get(this);L&&(delete ue.times,ue.fixPasses=0);do{J++;let Te;L&&(Te=E()),B(`Linting code for ${de} (pass ${J})`),oe=this.verify(ie,ne,ee),B(`Generating fixed text for ${de} (pass ${J})`);let Be;if(L&&(Be=E()),ce=x.applyFixes(ie,oe,we),L)if(ce.fixed){let $e=k(Be);Ce($e,{type:"fix"},ue),ue.fixPasses++}else Ce(0,{type:"fix"},ue);if(oe.length===1&&oe[0].fatal)break;if(z=z||ce.fixed,ie=ce.output,L){Te=k(Te);let $e=ue.times.passes.length-1;ue.times.passes[$e].total=Te}}while(ce.fixed&&J[Iw(),Rw(),Cw(),bC(),Ow(),ww(),Ut.allowMultipleSelections.of(!0),Jw(),fu(nC,{fallback:!0}),oC(),Ek(),Ck(),Aw(),Pw(),kw(),rk(),As.of([...ZC,...ok,...OC])];function xa(r){r.removeAttribute("hidden")}function Oa(r){r.setAttribute("hidden","")}function Xn(r,e=document){return e.querySelector(r)}var dN=()=>`litecanvas() +%s`,Fe,$e.stack),[{ruleId:null,fatal:!0,severity:2,message:Fe,line:$e.lineNumber,column:$e.column,nodeType:null}]}let Be=Te.map(($e,Fe)=>{if(B("A code block was found: %o",$e.filename||"(unnamed)"),typeof $e=="string")return this._verifyWithoutProcessors($e,ne,ee);let Oe=$e.text,Ie=r.join(ce,`${Fe}_${$e.filename}`);return L(Ie,Oe)?oe&&(ie!==Oe||r.extname(Ie)!==ue)?(B("Resolving configuration again because the file content or extension was changed."),this._verifyWithConfigArray(Oe,oe,{...ee,filename:Ie,physicalFilename:J})):this._verifyWithoutProcessors(Oe,ne,{...ee,filename:Ie,physicalFilename:J}):(B("This code block was skipped."),[])});return we(Be,z)}_distinguishSuppressedMessages(X){let ne=[],ee=[],oe=xt.get(this);for(let ce of X)ce.suppressions?ee.push(ce):ne.push(ce);return oe.lastSuppressedMessages=ee,ne}getSourceCode(){return xt.get(this).lastSourceCode}getTimes(){return xt.get(this).times??{passes:[]}}getFixPassCount(){return xt.get(this).fixPasses??0}getSuppressedMessages(){return xt.get(this).lastSuppressedMessages}defineRule(X,ne){Ye(this),xt.get(this).ruleMap.define(X,ne)}defineRules(X){Ye(this),Object.getOwnPropertyNames(X).forEach(ne=>{this.defineRule(ne,X[ne])})}getRules(){Ye(this);let{lastConfigArray:X,ruleMap:ne}=xt.get(this);return new Map(function*(){yield*ne,X&&(yield*X.pluginRules)}())}defineParser(X,ne){Ye(this),xt.get(this).parserMap.set(X,ne)}verifyAndFix(X,ne,ee){let oe,ce,z=!1,J=0,ie=X,de=ee&&ee.filename||`${X.slice(0,10)}...`,we=ee&&typeof ee.fix<"u"?ee.fix:!0,L=ee?.stats,ue=xt.get(this);L&&(delete ue.times,ue.fixPasses=0);do{J++;let Te;L&&(Te=E()),B(`Linting code for ${de} (pass ${J})`),oe=this.verify(ie,ne,ee),B(`Generating fixed text for ${de} (pass ${J})`);let Be;if(L&&(Be=E()),ce=x.applyFixes(ie,oe,we),L)if(ce.fixed){let $e=k(Be);Ce($e,{type:"fix"},ue),ue.fixPasses++}else Ce(0,{type:"fix"},ue);if(oe.length===1&&oe[0].fatal)break;if(z=z||ce.fixed,ie=ce.output,L){Te=k(Te);let $e=ue.times.passes.length-1;ue.times.passes[$e].total=Te}}while(ce.fixed&&J[Iw(),Rw(),Cw(),bC(),Ow(),ww(),Ut.allowMultipleSelections.of(!0),Jw(),fu(nC,{fallback:!0}),oC(),Ek(),Ck(),Aw(),Pw(),kw(),rk(),As.of([...ZC,...ok,...OC])];function xa(r){r.removeAttribute("hidden")}function Oa(r){r.setAttribute("hidden","")}function Xn(r,e=document){return e.querySelector(r)}var dN=()=>`// Welcome to litecanvas playground! +// Learn more tapping on the question mark above +// or join our discord community: https://discord.com/invite/r2c3rGsvH3 +litecanvas() function init () { color = 0 @@ -230,15 +233,15 @@ function draw () {