-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1582 from quadratichq/test-make-cells-async
Test make cells async
- Loading branch information
Showing
24 changed files
with
511 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...p/web-workers/javascriptWebWorker/worker/javascript/runner/generateJavascriptForRunner.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Generated file from ./compileJavascriptRunner.mjs | ||
export const javascriptLibrary = `const javascriptSendMessageAwaitingResponse=async message=>new Promise(resolve=>{self.onmessage=event=>resolve(event.data),self.postMessage(message)}),getCells=async(x0,y0,x1,y1,sheetName)=>{if(isNaN(x0)||isNaN(y0)||isNaN(x1))throw new Error("getCells requires at least 3 arguments, received getCells("+x0+", "+y0+", "+x1+", "+y1+")"+(___line_number___!==void 0?" at line "+___line_number___:""));return await javascriptSendMessageAwaitingResponse({type:"getCells",x0,y0,x1,y1,sheetName})},cells=getCells,getCellsWithHeadings=async(x0,y0,x1,y1,sheetName)=>{if(isNaN(x0)||isNaN(y0)||isNaN(x1))throw new Error("getCellsWithHeadings requires at least 3 arguments, received getCellsWithHeadings("+x0+", "+y0+", "+x1+", "+y1+")"+(___line_number___!==void 0?" at line "+___line_number___:""));const cells2=await getCells(x0,y0,x1,y1,sheetName),headers=cells2[0];return cells2.slice(1).map(row=>{const obj={};return headers.forEach((header,i)=>{obj[header]=row[i]}),obj})},getCell=async(x,y,sheetName)=>{if(isNaN(x)||isNaN(y))throw new Error("getCell requires at least 2 arguments, received getCell("+x+", "+y+")"+(___line_number___!==void 0?" at line "+___line_number___:""));return(await getCells(x,y,x,y,sheetName))?.[0]?.[0]},c=getCell,cell=getCell,pos=()=>({x:0,y:0}),relCell=async(deltaX,deltaY)=>{const p=pos();if(isNaN(deltaX)||isNaN(deltaY))throw new Error("relCell requires at least 2 arguments, received relCell("+deltaX+", "+deltaY+")"+(___line_number___!==void 0?" at line "+___line_number___:""));return await getCell(deltaX+p.x,deltaY+p.y)},relCells=async(deltaX0,deltaY0,deltaX1,deltaY1)=>{const p=pos();if(isNaN(deltaX0)||isNaN(deltaY0)||isNaN(deltaX1)||isNaN(deltaY1))throw new Error("relCells requires at least 4 arguments, received relCells("+deltaX0+", "+deltaY0+", "+deltaX1+", "+deltaY1+")"+(___line_number___!==void 0?" at line "+___line_number___:""));return await getCells(deltaX0+p.x,deltaY0+p.y,deltaX1+p.x,deltaY1+p.y)},rc=relCell,TAB=" ";class JavascriptConsole{oldConsoleLog;logs=[];constructor(){this.oldConsoleLog=console.log,console.log=this.consoleMap,console.warn=this.consoleMap}log(...args){this.oldConsoleLog(args)}consoleMap=(...args)=>{args=args.map(a=>this.mapArgument(a)),this.logs.push(...args)};reset(){this.logs=[]}push(s){Array.isArray(s)?this.logs.push(...s):this.logs.push(s)}output(){return this.logs.length?this.logs.join(""):null}tab=n=>Array(n).fill(TAB).join("");mapArgument(a,level=0){if(Array.isArray(a)){if(a.length===0)return"Array: []\\n";let s="Array: [\\n";for(let i=0;i<a.length;i++)s+=this.tab(level+1)+i+": "+this.mapArgument(a[i],level+2);return s+this.tab(level)+"]\\n"}else{if(a===null)return"null\\n";if(typeof a=="bigint")return a.toString()+"n\\n";if(a instanceof Date)return a.toString()+"\\n";if(typeof a=="object"){let s="Object: { \\n";for(const key in a)s+=this.tab(level+1)+key+": "+this.mapArgument(a[key],level+1);return s+this.tab(level)+"}\\n"}else return typeof a=="string"?a+"\\n":a===void 0?"undefined\\n":a+"\\n"}}}const javascriptConsole=new JavascriptConsole;export{c,cell,cells,getCell,getCells,getCellsWithHeadings,javascriptConsole,pos,rc,relCell,relCells}; | ||
export const javascriptLibrary = `const getCellsDB=(x0,y0,x1,y1,sheetName)=>{try{let sharedBuffer=new SharedArrayBuffer(12),int32View=new Int32Array(sharedBuffer,0,3);Atomics.store(int32View,0,0),self.postMessage({type:"getCellsLength",sharedBuffer,x0,y0,x1,y1,sheetName});let result=Atomics.wait(int32View,0,0);const length=int32View[1];if(result!=="ok"||length===0)return[];const id=int32View[2];if(sharedBuffer=new SharedArrayBuffer(4+length),int32View=new Int32Array(sharedBuffer,0,1),Atomics.store(int32View,0,0),self.postMessage({type:"getCellsData",id,sharedBuffer}),result=Atomics.wait(int32View,0,0),result!=="ok")return[];let uint8View=new Uint8Array(sharedBuffer,4,length);const nonSharedBuffer=new ArrayBuffer(uint8View.byteLength),nonSharedView=new Uint8Array(nonSharedBuffer);nonSharedView.set(uint8View),sharedBuffer=void 0,int32View=void 0,uint8View=void 0;const cellsStringified=new TextDecoder().decode(nonSharedView);return convertNullToUndefined(JSON.parse(cellsStringified))}catch(e){console.warn("[javascriptLibrary] getCells error",e)}return[]};function convertNullToUndefined(arr){return arr.map(subArr=>subArr.map(element=>element===null?void 0:element))}const getCells=(x0,y0,x1,y1,sheetName)=>{if(isNaN(x0)||isNaN(y0)||isNaN(x1))throw new Error("getCells requires at least 3 arguments, received getCells("+x0+", "+y0+", "+x1+", "+y1+")"+(___line_number___!==void 0?" at line "+___line_number___:""));return getCellsDB(x0,y0,x1,y1,sheetName)},cells=getCells,getCellsWithHeadings=(x0,y0,x1,y1,sheetName)=>{if(isNaN(x0)||isNaN(y0)||isNaN(x1))throw new Error("getCellsWithHeadings requires at least 3 arguments, received getCellsWithHeadings("+x0+", "+y0+", "+x1+", "+y1+")"+(___line_number___!==void 0?" at line "+___line_number___:""));const cells2=getCells(x0,y0,x1,y1,sheetName),headers=cells2[0];return cells2.slice(1).map(row=>{const obj={};return headers.forEach((header,i)=>{obj[header]=row[i]}),obj})},getCell=(x,y,sheetName)=>{if(isNaN(x)||isNaN(y))throw new Error("getCell requires at least 2 arguments, received getCell("+x+", "+y+")"+(___line_number___!==void 0?" at line "+___line_number___:""));return getCells(x,y,x,y,sheetName)?.[0]?.[0]},c=getCell,cell=getCell,pos=()=>({x:0,y:0}),relCell=(deltaX,deltaY)=>{const p=pos();if(isNaN(deltaX)||isNaN(deltaY))throw new Error("relCell requires at least 2 arguments, received relCell("+deltaX+", "+deltaY+")"+(___line_number___!==void 0?" at line "+___line_number___:""));return getCell(deltaX+p.x,deltaY+p.y)},relCells=(deltaX0,deltaY0,deltaX1,deltaY1)=>{const p=pos();if(isNaN(deltaX0)||isNaN(deltaY0)||isNaN(deltaX1)||isNaN(deltaY1))throw new Error("relCells requires at least 4 arguments, received relCells("+deltaX0+", "+deltaY0+", "+deltaX1+", "+deltaY1+")"+(___line_number___!==void 0?" at line "+___line_number___:""));return getCells(deltaX0+p.x,deltaY0+p.y,deltaX1+p.x,deltaY1+p.y)},rc=relCell,TAB=" ";class JavascriptConsole{oldConsoleLog;logs=[];constructor(){this.oldConsoleLog=console.log,console.log=this.consoleMap,console.warn=this.consoleMap}log(...args){this.oldConsoleLog(args)}consoleMap=(...args)=>{args=args.map(a=>this.mapArgument(a)),this.logs.push(...args)};reset(){this.logs=[]}push(s){Array.isArray(s)?this.logs.push(...s):this.logs.push(s)}output(){return this.logs.length?this.logs.join(""):null}tab=n=>Array(n).fill(TAB).join("");mapArgument(a,level=0){if(Array.isArray(a)){if(a.length===0)return"Array: []\\n";let s="Array: [\\n";for(let i=0;i<a.length;i++)s+=this.tab(level+1)+i+": "+this.mapArgument(a[i],level+2);return s+this.tab(level)+"]\\n"}else{if(a===null)return"null\\n";if(typeof a=="bigint")return a.toString()+"n\\n";if(a instanceof Date)return a.toString()+"\\n";if(typeof a=="object"){let s="Object: { \\n";for(const key in a)s+=this.tab(level+1)+key+": "+this.mapArgument(a[key],level+1);return s+this.tab(level)+"}\\n"}else return typeof a=="string"?a+"\\n":a===void 0?"undefined\\n":a+"\\n"}}}const javascriptConsole=new JavascriptConsole;export{c,cell,cells,getCell,getCells,getCellsWithHeadings,javascriptConsole,pos,rc,relCell,relCells}; | ||
`; | ||
export const javascriptLibraryLines = javascriptLibrary.split("\n").length; |
Oops, something went wrong.