diff --git a/packages/core/logger.mjs b/packages/core/logger.mjs index 8d37a4cb..caca9d2b 100644 --- a/packages/core/logger.mjs +++ b/packages/core/logger.mjs @@ -1,3 +1,18 @@ -export function logger(message) { - console.log(`%c${message}`, 'background-color: black;color:white;padding:4px;border-radius:15px'); +export const logKey = 'strudel.log'; + +export function logger(message, type, data = {}) { + console.log(`%c${message}`, 'background-color: black;color:white;border-radius:15px'); + if (typeof CustomEvent !== 'undefined') { + document.dispatchEvent( + new CustomEvent(logKey, { + detail: { + message, + type, + data, + }, + }), + ); + } } + +logger.key = logKey; diff --git a/packages/react/dist/index.cjs.js b/packages/react/dist/index.cjs.js index 62058770..0bff0414 100644 --- a/packages/react/dist/index.cjs.js +++ b/packages/react/dist/index.cjs.js @@ -1,23 +1,23 @@ -"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const ee=require("react"),xr=require("@uiw/react-codemirror"),Be=require("@codemirror/view"),dt=require("@codemirror/state"),yr=require("@codemirror/lang-javascript"),ue=require("@lezer/highlight"),br=require("@uiw/codemirror-themes"),Sr=require("react-hook-inview"),gi=require("@strudel.cycles/webaudio"),mi=require("@strudel.cycles/core"),Ci=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function Br(e){if(e&&e.__esModule)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const i in e)if(i!=="default"){const u=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,u.get?u:{enumerable:!0,get:()=>e[i]})}}return t.default=e,Object.freeze(t)}const fe=Ci(ee),_r=Ci(xr),wr=Br(mi),kr=br.createTheme({theme:"dark",settings:{background:"#222",foreground:"#75baff",caret:"#ffcc00",selection:"rgba(128, 203, 196, 0.5)",selectionMatch:"#036dd626",lineHighlight:"#00000050",gutterBackground:"transparent",gutterForeground:"#8a919966"},styles:[{tag:ue.tags.keyword,color:"#c792ea"},{tag:ue.tags.operator,color:"#89ddff"},{tag:ue.tags.special(ue.tags.variableName),color:"#eeffff"},{tag:ue.tags.typeName,color:"#c3e88d"},{tag:ue.tags.atom,color:"#f78c6c"},{tag:ue.tags.number,color:"#c3e88d"},{tag:ue.tags.definition(ue.tags.variableName),color:"#82aaff"},{tag:ue.tags.string,color:"#c3e88d"},{tag:ue.tags.special(ue.tags.string),color:"#c3e88d"},{tag:ue.tags.comment,color:"#7d8799"},{tag:ue.tags.variableName,color:"#c792ea"},{tag:ue.tags.tagName,color:"#c3e88d"},{tag:ue.tags.bracket,color:"#525154"},{tag:ue.tags.meta,color:"#ffcb6b"},{tag:ue.tags.attributeName,color:"#c792ea"},{tag:ue.tags.propertyName,color:"#c792ea"},{tag:ue.tags.className,color:"#decb6b"},{tag:ue.tags.invalid,color:"#ffffff"}]});const wt=dt.StateEffect.define(),Ir=dt.StateField.define({create(){return Be.Decoration.none},update(e,t){try{for(let i of t.effects)if(i.is(wt))if(i.value){const u=Be.Decoration.mark({attributes:{style:"background-color: #FFCA2880"}});e=Be.Decoration.set([u.range(0,t.newDoc.length)])}else e=Be.Decoration.set([]);return e}catch(i){return console.warn("flash error",i),e}},provide:e=>Be.EditorView.decorations.from(e)}),Ai=e=>{e.dispatch({effects:wt.of(!0)}),setTimeout(()=>{e.dispatch({effects:wt.of(!1)})},200)},lt=dt.StateEffect.define(),Pr=dt.StateField.define({create(){return Be.Decoration.none},update(e,t){try{for(let i of t.effects)if(i.is(lt)){const u=i.value.map(n=>(n.context.locations||[]).map(({start:c,end:a})=>{const f=n.context.color||"#FFCA28";let p=t.newDoc.line(c.line).from+c.column,g=t.newDoc.line(a.line).from+a.column;const D=t.newDoc.length;return p>D||g>D?void 0:Be.Decoration.mark({attributes:{style:`outline: 1.5px solid ${f};`}}).range(p,g)})).flat().filter(Boolean)||[];e=Be.Decoration.set(u,!0)}return e}catch{return Be.Decoration.set([])}},provide:e=>Be.EditorView.decorations.from(e)}),Lr=[yr.javascript(),kr,Pr,Ir];function Ei({value:e,onChange:t,onViewChanged:i,onSelectionChange:u,options:n,editorDidMount:c}){const a=ee.useCallback(g=>{t?.(g)},[t]),f=ee.useCallback(g=>{i?.(g)},[i]),p=ee.useCallback(g=>{g.selectionSet&&u&&u?.(g.state.selection)},[u]);return fe.default.createElement(fe.default.Fragment,null,fe.default.createElement(_r.default,{value:e,onChange:a,onCreateEditor:f,onUpdate:p,extensions:Lr}))}function kt(...e){return e.filter(Boolean).join(" ")}function Fi({view:e,pattern:t,active:i,getTime:u}){const n=ee.useRef([]),c=ee.useRef();ee.useEffect(()=>{if(e)if(t&&i){let f=function(){try{const p=u(),D=[Math.max(c.current||p,p-1/10,0),p+1/60];c.current=D[1],n.current=n.current.filter(m=>m.whole.end>p);const F=t.queryArc(...D).filter(m=>m.hasOnset());n.current=n.current.concat(F),e.dispatch({effects:lt.of(n.current)})}catch{e.dispatch({effects:lt.of([])})}a=requestAnimationFrame(f)},a=requestAnimationFrame(f);return()=>{cancelAnimationFrame(a)}}else n.current=[],e.dispatch({effects:lt.of([])})},[t,i,e])}const Nr="_container_3i85k_1",Tr="_header_3i85k_5",Rr="_buttons_3i85k_9",Mr="_button_3i85k_9",Or="_buttonDisabled_3i85k_17",Vr="_error_3i85k_21",qr="_body_3i85k_25",Le={container:Nr,header:Tr,buttons:Rr,button:Mr,buttonDisabled:Or,error:Vr,body:qr};function Jt({type:e}){return fe.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"sc-h-5 sc-w-5",viewBox:"0 0 20 20",fill:"currentColor"},{refresh:fe.default.createElement("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"}),play:fe.default.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z",clipRule:"evenodd"}),pause:fe.default.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zM7 8a1 1 0 012 0v4a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v4a1 1 0 102 0V8a1 1 0 00-1-1z",clipRule:"evenodd"})}[e])}function Ur(e,t,i=.05,u=.1,n=.1){let c=0,a=0,f=10**4,p=.01;const g=I=>i=I(i);n=n||u/2;const D=()=>{const I=e(),P=I+u+n;for(a===0&&(a=I+p);a
=I&&t(a,i,c),a{A(),D(),F=setInterval(D,u*1e3)},A=()=>F!==void 0&&clearInterval(F);return{setDuration:g,start:m,stop:()=>{c=0,a=0,A()},pause:()=>A(),duration:i,getPhase:()=>a}}class jr{worker;pattern;started=!1;cps=1;getTime;phase=0;constructor({interval:t,onTrigger:i,onToggle:u,onError:n,getTime:c,latency:a=.1,onLog:f}){this.getTime=c,this.onToggle=u,this.onLog=f,this.latency=a;const p=g=>Math.round(g*1e3)/1e3;this.clock=Ur(c,(g,D,F)=>{F===0&&(this.origin=g);const m=p(g-this.origin);this.phase=m-a;const A=p(m+D),x=c();try{this.pattern.queryArc(m,A).forEach(v=>{if(v.part.begin.equals(v.whole.begin)){const I=v.whole.begin+this.origin-x+a,P=v.duration*1;i?.(v,I,P)}})}catch(C){f(`error: ${C.message}`),n?.(C)}},t)}getPhase(t=!0){return this.phase-(t?this.latency:0)}setStarted(t){this.started=t,this.onToggle?.(t)}start(){if(!this.pattern)throw new Error("Scheduler: no pattern set! call .setPattern first.");this.onLog?.("start"),this.clock.start(),this.setStarted(!0)}pause(){this.onLog?.("pause"),this.clock.pause(),this.setStarted(!1)}stop(){this.onLog?.("stop"),this.clock.stop(),this.setStarted(!1)}setPattern(t,i=!1){this.pattern=t,i&&!this.started&&this.start()}setCps(t=1){this.cps=t}log(t,i,u){const n=u.filter(c=>c.hasOnset());console.log(`${t.toFixed(4)} - ${i.toFixed(4)} ${Array(n.length).fill("I").join("")}`)}}const{isPattern:Wr,Pattern:Gr}=wr;let It=!1;const zr=async(...e)=>{It&&console.warn("evalScope was called more than once."),It=!0;const t=await Promise.allSettled(e),i=t.filter(u=>u.status==="fulfilled").map(u=>u.value);t.forEach((u,n)=>{u.status==="rejected"&&console.warn(`evalScope: module with index ${n} could not be loaded:`,u.reason)}),Object.assign(globalThis,...i,Gr.prototype.bootstrap())};function Hr(e,t={}){const{wrapExpression:i=!0,wrapAsync:u=!0}=t;i&&(e=`{${e}}`),u&&(e=`(async ()=>${e})()`);const n=`"use strict";return (${e})`;return Function(n)()}const Kr=async(e,t)=>{It||await zr(),t&&(e=t(e));let u=await Hr(e,{wrapExpression:!!t});if(!Wr(u)){console.log("evaluated",u);const n=`got "${typeof u}" instead of pattern`;throw new Error(n+(typeof u=="function"?", did you forget to call a function?":"."))}return{mode:"javascript",pattern:u}};function Qr({interval:e,defaultOutput:t,onSchedulerError:i,onEvalError:u,beforeEval:n,afterEval:c,getTime:a,transpiler:f,onToggle:p,onLog:g}){const D=new jr({interval:e,onTrigger:async(C,v,I)=>{try{if(!C.context.onTrigger)return await t(C,v,I);const P=1;return await C.context.onTrigger(a()+v,C,a(),P)}catch(P){g?.(`[cyclist] error: ${P.message}`,"error")}},onError:i,getTime:a,onToggle:p,onLog:(C,v)=>g?.(`[cyclist] ${C}`,v)});return{scheduler:D,evaluate:async(C,v=!0)=>{if(!C)throw new Error("no code to evaluate");try{n({code:C});const{pattern:I}=await Kr(C,f);return g?.("[eval] code updated"),D.setPattern(I,v),c({code:C,pattern:I}),I}catch(I){g?.(`[eval] error: ${I.message}`,"error"),u?.(I)}},start:()=>D.start(),stop:()=>D.stop(),pause:()=>D.pause()}}var Yr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},vi={},xi={};(function(e){(function t(i){var u,n,c,a,f,p;function g(E){var B={},S,w;for(S in E)E.hasOwnProperty(S)&&(w=E[S],typeof w=="object"&&w!==null?B[S]=g(w):B[S]=w);return B}function D(E,B){var S,w,j,T;for(w=E.length,j=0;w;)S=w>>>1,T=j+S,B(E[T])?w=S:(j=T+1,w-=S+1);return j}u={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ChainExpression:"ChainExpression",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportExpression:"ImportExpression",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",PrivateIdentifier:"PrivateIdentifier",Program:"Program",Property:"Property",PropertyDefinition:"PropertyDefinition",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"},c={AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","body"],AwaitExpression:["argument"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ChainExpression:["expression"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ComprehensionBlock:["left","right"],ComprehensionExpression:["blocks","filter","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExportAllDeclaration:["source"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source"],ExportSpecifier:["exported","local"],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],GeneratorExpression:["blocks","filter","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportExpression:["source"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MetaProperty:["meta","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],PrivateIdentifier:[],Program:["body"],Property:["key","value"],PropertyDefinition:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],Super:[],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]},a={},f={},p={},n={Break:a,Skip:f,Remove:p};function F(E,B){this.parent=E,this.key=B}F.prototype.replace=function(B){this.parent[this.key]=B},F.prototype.remove=function(){return Array.isArray(this.parent)?(this.parent.splice(this.key,1),!0):(this.replace(null),!1)};function m(E,B,S,w){this.node=E,this.path=B,this.wrap=S,this.ref=w}function A(){}A.prototype.path=function(){var B,S,w,j,T,W;function V(R,H){if(Array.isArray(H))for(w=0,j=H.length;w =I&&t(a,i,c),a{A(),D(),F=setInterval(D,u*1e3)},A=()=>F!==void 0&&clearInterval(F);return{setDuration:g,start:m,stop:()=>{c=0,a=0,A()},pause:()=>A(),duration:i,getPhase:()=>a}}class jr{worker;pattern;started=!1;cps=1;getTime;phase=0;constructor({interval:t,onTrigger:i,onToggle:u,onError:n,getTime:c,latency:a=.1,onLog:f}){this.getTime=c,this.onToggle=u,this.onLog=f,this.latency=a;const p=g=>Math.round(g*1e3)/1e3;this.clock=Ur(c,(g,D,F)=>{F===0&&(this.origin=g);const m=p(g-this.origin);this.phase=m-a;const A=p(m+D),x=c();try{this.pattern.queryArc(m,A).forEach(v=>{if(v.part.begin.equals(v.whole.begin)){const I=v.whole.begin+this.origin-x+a,P=v.duration*1;i?.(v,I,P)}})}catch(C){f(`error: ${C.message}`),n?.(C)}},t)}getPhase(t=!0){return this.phase-(t?this.latency:0)}setStarted(t){this.started=t,this.onToggle?.(t)}start(){if(!this.pattern)throw new Error("Scheduler: no pattern set! call .setPattern first.");this.onLog?.("start"),this.clock.start(),this.setStarted(!0)}pause(){this.onLog?.("pause"),this.clock.pause(),this.setStarted(!1)}stop(){this.onLog?.("stop"),this.clock.stop(),this.setStarted(!1)}setPattern(t,i=!1){this.pattern=t,i&&!this.started&&this.start()}setCps(t=1){this.cps=t}log(t,i,u){const n=u.filter(c=>c.hasOnset());console.log(`${t.toFixed(4)} - ${i.toFixed(4)} ${Array(n.length).fill("I").join("")}`)}}const{isPattern:Wr,Pattern:Gr}=wr;let It=!1;const zr=async(...e)=>{It&&console.warn("evalScope was called more than once."),It=!0;const t=await Promise.allSettled(e),i=t.filter(u=>u.status==="fulfilled").map(u=>u.value);t.forEach((u,n)=>{u.status==="rejected"&&console.warn(`evalScope: module with index ${n} could not be loaded:`,u.reason)}),Object.assign(globalThis,...i,Gr.prototype.bootstrap())};function Hr(e,t={}){const{wrapExpression:i=!0,wrapAsync:u=!0}=t;i&&(e=`{${e}}`),u&&(e=`(async ()=>${e})()`);const n=`"use strict";return (${e})`;return Function(n)()}const Kr=async(e,t)=>{It||await zr(),t&&(e=t(e));let u=await Hr(e,{wrapExpression:!!t});if(!Wr(u)){console.log("evaluated",u);const n=`got "${typeof u}" instead of pattern`;throw new Error(n+(typeof u=="function"?", did you forget to call a function?":"."))}return{mode:"javascript",pattern:u}};function Qr({interval:e,defaultOutput:t,onSchedulerError:i,onEvalError:u,beforeEval:n,afterEval:c,getTime:a,transpiler:f,onToggle:p,onLog:g}){const D=new jr({interval:e,onTrigger:async(C,v,I)=>{try{if(!C.context.onTrigger)return await t(C,v,I);const P=1;return await C.context.onTrigger(a()+v,C,a(),P)}catch(P){g?.(`[cyclist] error: ${P.message}`,"error")}},onError:i,getTime:a,onToggle:p,onLog:(C,v)=>g?.(`[cyclist] ${C}`,v)});return{scheduler:D,evaluate:async(C,v=!0)=>{if(!C)throw new Error("no code to evaluate");try{n({code:C});const{pattern:I}=await Kr(C,f);return g?.("[eval] code updated"),D.setPattern(I,v),c({code:C,pattern:I}),I}catch(I){g?.(`[eval] error: ${I.message}`,"error"),u?.(I)}},start:()=>D.start(),stop:()=>D.stop(),pause:()=>D.pause()}}var Yr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},vi={},xi={};(function(e){(function t(i){var u,n,c,a,f,p;function g(E){var S={},B,w;for(B in E)E.hasOwnProperty(B)&&(w=E[B],typeof w=="object"&&w!==null?S[B]=g(w):S[B]=w);return S}function D(E,S){var B,w,j,T;for(w=E.length,j=0;w;)B=w>>>1,T=j+B,S(E[T])?w=B:(j=T+1,w-=B+1);return j}u={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ChainExpression:"ChainExpression",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportExpression:"ImportExpression",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",PrivateIdentifier:"PrivateIdentifier",Program:"Program",Property:"Property",PropertyDefinition:"PropertyDefinition",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"},c={AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","body"],AwaitExpression:["argument"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ChainExpression:["expression"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ComprehensionBlock:["left","right"],ComprehensionExpression:["blocks","filter","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExportAllDeclaration:["source"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source"],ExportSpecifier:["exported","local"],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],GeneratorExpression:["blocks","filter","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportExpression:["source"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MetaProperty:["meta","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],PrivateIdentifier:[],Program:["body"],Property:["key","value"],PropertyDefinition:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],Super:[],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]},a={},f={},p={},n={Break:a,Skip:f,Remove:p};function F(E,S){this.parent=E,this.key=S}F.prototype.replace=function(S){this.parent[this.key]=S},F.prototype.remove=function(){return Array.isArray(this.parent)?(this.parent.splice(this.key,1),!0):(this.replace(null),!1)};function m(E,S,B,w){this.node=E,this.path=S,this.wrap=B,this.ref=w}function A(){}A.prototype.path=function(){var S,B,w,j,T,W;function V(R,H){if(Array.isArray(H))for(w=0,j=H.length;w126))){o+=dr(d,r.charCodeAt(s+1));continue}o+=String.fromCharCode(d)}if(k=!(m==="double"||m==="auto"&&_=0&&!a.code.isLineTerminator(r.charCodeAt(o));--o);return r.length-1-o}function Ar(r,o){var s,l,d,b,_,k,L,K;for(s=r.split(/\r\n|[\r\n]/),k=Number.MAX_VALUE,l=1,d=s.length;l126))){o+=dr(d,r.charCodeAt(s+1));continue}o+=String.fromCharCode(d)}if(k=!(m==="double"||m==="auto"&&_=0&&!a.code.isLineTerminator(r.charCodeAt(o));--o);return r.length-1-o}function Ar(r,o){var s,l,d,b,_,k,L,K;for(s=r.split(/\r\n|[\r\n]/),k=Number.MAX_VALUE,l=1,d=s.length;l