-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ayush/2075' of github.com:quadratichq/quadratic into ay…
…ush/2075
- Loading branch information
Showing
6 changed files
with
24 additions
and
6 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
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 = `function convertNullToUndefined(arr){return arr.map(subArr=>subArr.map(element=>element===null?void 0:element))}function lineNumber(){try{throw new Error}catch(e){const match=e.stack.split("\\n")[3].match(/:(\\d+):(\\d+)/);if(match)return match[1]}}const createConversionError=(funcName,a1Params,oldFuncParams,sheetName)=>{const oldFunc=funcName+"("+oldFuncParams+")";let params=a1Params;sheetName&&(params=sheetName+":"+params);const newFunc="q.cells('"+params+"')";q.conversionError(oldFunc,newFunc)},getCellsConversionError=(funcName,x0,y0,x1,y1,sheetName)=>{const a1_0=q.toA1(x0,y0),a1_1=q.toA1(x1,y1);let oldFuncParams=x0+", "+y0+", "+x1;y1&&(oldFuncParams+=", "+y1),sheetName&&(oldFuncParams+=", "+sheetName),createConversionError(funcName,a1_0+":"+a1_1,oldFuncParams,sheetName)},getCellConversionError=(funcName,x,y,sheetName)=>{const a1=q.toA1(x,y);let oldFuncParams=x+", "+y;sheetName&&(oldFuncParams+=", "+sheetName),createConversionError(funcName,a1,oldFuncParams,sheetName)},getCells=(x0,y0,x1,y1,sheetName)=>{getCellsConversionError("getCells",x0,y0,x1,y1,sheetName)},cells=(x0,y0,x1,y1,sheetName)=>{getCellsConversionError("cells",x0,y0,x1,y1,sheetName)},getCellsWithHeadings=(x0,y0,x1,y1,sheetName)=>{getCellsConversionError("getCellsWithHeadings",x0,y0,x1,y1,sheetName)},getCell=(x,y,sheetName)=>{getCellConversionError("getCell",x,y,sheetName)},cell=(x,y,sheetName)=>{getCellConversionError("cell",x,y,sheetName)},c=(x,y,sheetName)=>{getCellConversionError("c",x,y,sheetName)},pos=()=>({x:0,y:0}),relCell=(deltaX,deltaY)=>{const a1=q.toA1(deltaX,deltaY,!1);let oldFuncParams=deltaX+", "+deltaY;createConversionError("relCell",a1,oldFuncParams)},relCells=(deltaX0,deltaY0,deltaX1,deltaY1)=>{const a1_0=q.toA1(deltaX0,deltaY0,!1),a1_1=q.toA1(deltaX1,deltaY1,!1),oldFuncParams=deltaX0+", "+deltaY0+", "+deltaX1+", "+deltaY1;createConversionError("relCells",a1_0+":"+a1_1,oldFuncParams)},rc=relCell;class q{static cells(a1){if(typeof a1!="string"){const line=lineNumber();throw new Error("q.cell requires at least 1 argument, received q.cell("+a1+")"+(line!==void 0?" at line "+(line-1):""))}try{let sharedBuffer=new SharedArrayBuffer(12),int32View=new Int32Array(sharedBuffer,0,3);Atomics.store(int32View,0,0),self.postMessage({type:"getCellsA1Length",sharedBuffer,a1});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 resultsStringified=new TextDecoder().decode(nonSharedView),results=JSON.parse(resultsStringified),cells2=convertNullToUndefined(results.cells);if(cells2.forEach(row=>{row.forEach((cell2,i)=>{typeof cell2=="string"&&cell2.startsWith("___date___")&&(row[i]=new Date(parseInt(cell2.substring(10))))})}),!results.two_dimensional){if(cells2.length===1&&cells2[0].length===1)return cells2[0][0];if(cells2.every(row=>row.length===1))return cells2.map(row=>row[0]);if(cells2.length===1)return cells2[0]}return cells2}catch(e){console.warn("[javascriptLibrary] q error",e)}return[]}static toA1(x,y,absolute=!0){let column="";if(!absolute){const p=pos();x=x+p.x,y!==void 0&&(y=y+p.y)}for(;x>0;)x--,column=String.fromCharCode(x%26+65)+column,x=Math.floor(x/26);return column+y}static pos(){return pos()}static conversionError(oldFunc,newFunc){const message=oldFunc+" functionality is no longer supported. Use "+newFunc+" instead.";throw new Error(message)}}const 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,q,rc,relCell,relCells}; | ||
export const javascriptLibrary = `function convertNullToUndefined(arr){return arr.map(subArr=>subArr.map(element=>element===null?void 0:element))}function lineNumber(){try{throw new Error}catch(e){const match=e.stack.split("\\n")[3].match(/:(\\d+):(\\d+)/);if(match)return match[1]}}const createConversionError=(funcName,a1Params,oldFuncParams,sheetName)=>{const oldFunc=funcName+"("+oldFuncParams+")";let params=a1Params;sheetName&&(params=sheetName+":"+params);const newFunc="q.cells('"+params+"')";q.conversionError(oldFunc,newFunc)},getCellsConversionError=(funcName,x0,y0,x1,y1,sheetName)=>{const a1_0=q.toA1(x0,y0),a1_1=q.toA1(x1,y1);let oldFuncParams=x0+", "+y0+", "+x1;y1&&(oldFuncParams+=", "+y1),sheetName&&(oldFuncParams+=", "+sheetName),createConversionError(funcName,a1_0+":"+a1_1,oldFuncParams,sheetName)},getCellConversionError=(funcName,x,y,sheetName)=>{const a1=q.toA1(x,y);let oldFuncParams=x+", "+y;sheetName&&(oldFuncParams+=", "+sheetName),createConversionError(funcName,a1,oldFuncParams,sheetName)},getCells=(x0,y0,x1,y1,sheetName)=>{getCellsConversionError("getCells",x0,y0,x1,y1,sheetName)},cells=(x0,y0,x1,y1,sheetName)=>{getCellsConversionError("cells",x0,y0,x1,y1,sheetName)},getCellsWithHeadings=(x0,y0,x1,y1,sheetName)=>{getCellsConversionError("getCellsWithHeadings",x0,y0,x1,y1,sheetName)},getCell=(x,y,sheetName)=>{getCellConversionError("getCell",x,y,sheetName)},cell=(x,y,sheetName)=>{getCellConversionError("cell",x,y,sheetName)},c=(x,y,sheetName)=>{getCellConversionError("c",x,y,sheetName)},pos=()=>({x:0,y:0}),relCell=(deltaX,deltaY)=>{const a1=q.toA1(deltaX,deltaY,!1);let oldFuncParams=deltaX+", "+deltaY;createConversionError("relCell",a1,oldFuncParams)},relCells=(deltaX0,deltaY0,deltaX1,deltaY1)=>{const a1_0=q.toA1(deltaX0,deltaY0,!1),a1_1=q.toA1(deltaX1,deltaY1,!1),oldFuncParams=deltaX0+", "+deltaY0+", "+deltaX1+", "+deltaY1;createConversionError("relCells",a1_0+":"+a1_1,oldFuncParams)},rc=relCell;class q{static cells(a1){if(typeof a1!="string"){const line=lineNumber();throw new Error("q.cell requires at least 1 argument, received q.cell("+a1+")"+(line!==void 0?" at line "+(line-1):""))}try{let sharedBuffer=new SharedArrayBuffer(12),int32View=new Int32Array(sharedBuffer,0,3);Atomics.store(int32View,0,0),self.postMessage({type:"getCellsA1Length",sharedBuffer,a1});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 resultsStringified=new TextDecoder().decode(nonSharedView),results=JSON.parse(resultsStringified),cells2=convertNullToUndefined(results.cells);if(cells2.forEach(row=>{row.forEach((cell2,i)=>{typeof cell2=="string"&&cell2.startsWith("___date___")&&(row[i]=new Date(parseInt(cell2.substring(10))))})}),!results.two_dimensional){if(cells2.length===1&&cells2[0].length===1)return cells2[0][0];if(cells2.every(row=>row.length===1))return cells2.map(row=>row[0]);if(cells2.length===1)return cells2[0]}return cells2}catch(e){console.warn("[javascriptLibrary] q error",e)}return[]}static toA1(x,y,absolute=!0){let column="";if(!absolute){const p=pos();x=x+p.x,y!==void 0&&(y=y+p.y)}for(;x>0;)x--,column=String.fromCharCode(x%26+65)+column,x=Math.floor(x/26);return column+y}static pos(){return pos()}static conversionError(oldFunc,newFunc){const message=oldFunc+" functionality is no longer supported. Use "+newFunc+" instead. Refer to the documentation at {COMMUNITY_A1_FILE_UPDATE_URL} for more details.";throw new Error(message)}}const 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,q,rc,relCell,relCells}; | ||
`; | ||
export const javascriptLibraryLines = javascriptLibrary.split("\n").length; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,6 @@ class PythonClient { | |
break; | ||
|
||
case 'clientPythonInit': | ||
this.env = e.data.env; | ||
return; | ||
|
||
default: | ||
|
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