use new transpiler in vite-vanilla-repl

This commit is contained in:
Felix Roos 2022-11-08 19:50:27 +01:00
parent 9b2899c8fb
commit 4ed3ca4128
9 changed files with 74 additions and 62 deletions

View File

@ -1 +1 @@
import{g as s,b as d,e as t,j as u,l as o,f as r,p as f,i as p,d as g,h as i,w as l,a as m}from"./index.f88145a1.js";export{s as getAudioContext,d as getCachedBuffer,t as getLoadedBuffer,u as getLoadedSamples,o as loadBuffer,r as loadGithubSamples,f as panic,p as resetLoadedSamples,g as reverseBuffer,i as samples,l as webaudioOutput,m as webaudioOutputTrigger}; import{g as s,b as d,e as t,j as u,l as o,f as r,p as f,i as p,d as g,h as i,w as l,a as m}from"./index.f17ed672.js";export{s as getAudioContext,d as getCachedBuffer,t as getLoadedBuffer,u as getLoadedSamples,o as loadBuffer,r as loadGithubSamples,f as panic,p as resetLoadedSamples,g as reverseBuffer,i as samples,l as webaudioOutput,m as webaudioOutputTrigger};

View File

@ -1,4 +1,4 @@
import{c as ut,r as Se,s as pt}from"./index.f88145a1.js";function gt(a,c){function r(){this.constructor=a}r.prototype=c.prototype,a.prototype=new r}function D(a,c,r,_){var p=Error.call(this,a);return Object.setPrototypeOf&&Object.setPrototypeOf(p,D.prototype),p.expected=c,p.found=r,p.location=_,p.name="SyntaxError",p}gt(D,Error);function U(a,c,r){return r=r||" ",a.length>c?a:(c-=a.length,r+=r.repeat(c),a+r.slice(0,c))}D.prototype.format=function(a){var c="Error: "+this.message;if(this.location){var r=null,_;for(_=0;_<a.length;_++)if(a[_].source===this.location.source){r=a[_].text.split(/\r\n|\n|\r/g);break}var p=this.location.start,$=this.location.source+":"+p.line+":"+p.column;if(r){var w=this.location.end,A=U("",p.line.toString().length," "),E=r[p.line-1],m=p.line===w.line?w.column:E.length+1,h=m-p.column||1;c+=` import{c as ut,r as Se,s as pt}from"./index.f17ed672.js";function gt(a,c){function r(){this.constructor=a}r.prototype=c.prototype,a.prototype=new r}function D(a,c,r,_){var p=Error.call(this,a);return Object.setPrototypeOf&&Object.setPrototypeOf(p,D.prototype),p.expected=c,p.found=r,p.location=_,p.name="SyntaxError",p}gt(D,Error);function U(a,c,r){return r=r||" ",a.length>c?a:(c-=a.length,r+=r.repeat(c),a+r.slice(0,c))}D.prototype.format=function(a){var c="Error: "+this.message;if(this.location){var r=null,_;for(_=0;_<a.length;_++)if(a[_].source===this.location.source){r=a[_].text.split(/\r\n|\n|\r/g);break}var p=this.location.start,$=this.location.source+":"+p.line+":"+p.column;if(r){var w=this.location.end,A=U("",p.line.toString().length," "),E=r[p.line-1],m=p.line===w.line?w.column:E.length+1,h=m-p.column||1;c+=`
--> `+$+` --> `+$+`
`+A+` | `+A+` |
`+p.line+" | "+E+` `+p.line+" | "+E+`

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite Vanilla Strudel REPL</title> <title>Vite Vanilla Strudel REPL</title>
<script type="module" crossorigin src="/tidalcycles/strudel/general-purpose-scheduler/packages/core/examples/vite-vanilla-repl/dist/assets/index.f88145a1.js"></script> <script type="module" crossorigin src="/tidalcycles/strudel/general-purpose-scheduler/packages/core/examples/vite-vanilla-repl/dist/assets/index.f17ed672.js"></script>
</head> </head>
<body style="margin: 0; background: #222"> <body style="margin: 0; background: #222">
<div style="display: grid; height: 100vh"> <div style="display: grid; height: 100vh">

View File

@ -1,6 +1,7 @@
import { controls, repl, evalScope } from '@strudel.cycles/core'; import { controls, repl, evalScope } from '@strudel.cycles/core';
import { getAudioContext, webaudioOutput } from '@strudel.cycles/webaudio'; import { getAudioContext, webaudioOutput } from '@strudel.cycles/webaudio';
import { transpiler } from '@strudel.cycles/transpiler'; import { transpiler } from '@strudel.cycles/transpiler';
// import shapeshifter from '@strudel.cycles/eval/shapeshifter.mjs';
import tune from './tune.mjs'; import tune from './tune.mjs';
const ctx = getAudioContext(); const ctx = getAudioContext();
@ -19,6 +20,7 @@ const { evaluate } = repl({
defaultOutput: webaudioOutput, defaultOutput: webaudioOutput,
getTime: () => ctx.currentTime, getTime: () => ctx.currentTime,
transpiler, transpiler,
// transpiler: shapeshifter,
}); });
document.getElementById('start').addEventListener('click', () => { document.getElementById('start').addEventListener('click', () => {
ctx.resume(); ctx.resume();

View File

@ -5,10 +5,11 @@
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build --base /tidalcycles/strudel/general-purpose-scheduler/packages/core/examples/vite-vanilla-repl/dist/", "build-githack": "vite build --base /tidalcycles/strudel/general-purpose-scheduler/packages/core/examples/vite-vanilla-repl/dist/",
"build": "vite build",
"preview": "vite preview" "preview": "vite preview"
}, },
"devDependencies": { "devDependencies": {
"vite": "^3.2.0" "vite": "^3.2.0"
} }
} }

View File

@ -9,6 +9,7 @@ export function transpiler(input, options = {}) {
let ast = parse(input, { let ast = parse(input, {
ecmaVersion: 2022, ecmaVersion: 2022,
allowAwaitOutsideFunction: true, allowAwaitOutsideFunction: true,
// locations: true,
}); });
walk(ast, { walk(ast, {