Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

directive-splitter

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

directive-splitter - npm Package Compare versions

Comparing version
0.1.1
to
0.1.2
+1
-1
./dist/cjs/production/index.cjs

@@ -1,1 +0,1 @@

"use strict";var ee=Object.create;var v=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var ie=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var oe=(t,n)=>{for(var i in n)v(t,i,{get:n[i],enumerable:!0})},L=(t,n,i,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of ne(n))!re.call(t,o)&&o!==i&&v(t,o,{get:()=>n[o],enumerable:!(r=te(n,o))||r.enumerable});return t};var P=(t,n,i)=>(i=t!=null?ee(ie(t)):{},L(n||!t||!t.__esModule?v(i,"default",{value:t,enumerable:!0}):i,t)),ae=t=>L(v({},"__esModule",{value:!0}),t);var Re={};oe(Re,{compile:()=>Be});module.exports=ae(Re);var X=P(require("@babel/core"),1),B=P(require("path"),1);function k(t,n){if(!t)throw new Error(n)}var e=P(require("@babel/types"),1);var I=P(require("@babel/types"),1);function U(t,n,i,r){if(n.scope.hasGlobal(i))return!1;if(t===n)return!0;if(n.scope.hasOwnBinding(i)){if(r==="block"){let o=n.scope.getBinding(i);return!!o&&o.kind==="param"}return!1}return n.parentPath?U(t,n.parentPath,i,r):!0}function se(t){let n=t.parentPath;for(;n;){if(I.isTypeScript(n.node)&&!I.isExpression(n.node))return!0;n=n.parentPath}return!1}function y(t,n){let i=new Set;return t.traverse({ReferencedIdentifier(r){!se(r)&&(n==="expression"?!t.scope.hasGlobal(r.node.name):U(t,r,r.node.name,n))&&i.add(r.node.name)}}),i}function A(t,n){let i=t;for(;i;){switch(i.node.type){case"FunctionDeclaration":case"FunctionExpression":{if(i.node.id)return i.node.id.name;break}case"VariableDeclarator":{if(i.node.id.type==="Identifier")return i.node.id.name;break}case"ClassPrivateMethod":case"ClassMethod":case"ObjectMethod":{switch(i.node.key.type){case"Identifier":return i.node.key.name;case"PrivateName":return i.node.key.id.name;default:break}break}default:break}i=i.parentPath}return n}var N=P(require("@babel/generator"),1),le=typeof N.default!="function"?N.default.default:N.default,M=le;var O=P(require("@babel/types"),1);function C(t){let n=t.parentPath;for(;n;){let i=n.parentPath;if(i&&O.isProgram(i.node))return n;n=i}return t}var D=P(require("@babel/types"),1);function K(t){switch(t.imported.type){case"Identifier":return t.imported.name;case"StringLiteral":return t.imported.value}}function x(t,n){return n(t.node)}function fe(t){switch(t.type){case"ParenthesizedExpression":case"TypeCastExpression":case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":case"TSInstantiationExpression":return!0;default:return!1}}function w(t,n){if(x(t,n))return t;if(x(t,fe))return w(t.get("expression"),n)}function j(t){k(x(t,D.isImportSpecifier)||x(t,D.isImportDefaultSpecifier)||x(t,D.isImportNamespaceSpecifier),"invariant");let i=t.getStatementParent().node.source.value;switch(t.node.type){case"ImportDefaultSpecifier":return{source:i,kind:"default",local:t.node.local.name};case"ImportNamespaceSpecifier":return{source:i,kind:"namespace",local:t.node.local.name};case"ImportSpecifier":{let r=K(t.node);return r==="default"?{source:i,kind:"default",local:t.node.local.name,imported:""}:{source:i,kind:"named",local:t.node.local.name,imported:r}}}}var Y=P(require("@babel/types"),1);function ce(t){let n=[];for(let i=0,r=t.elements.length;i<r;i++){let o=t.elements[i];o&&n.push(...h(o))}return n}function ue(t){let n=[];for(let i=0,r=t.properties.length;i<r;i++){let o=t.properties[i];o&&(o.type==="RestElement"?n.push(...h(o)):Y.isLVal(o.value)&&n.push(...h(o.value)))}return n}function h(t){switch(t.type){case"Identifier":return[t.name];case"ArrayPattern":return ce(t);case"AssignmentPattern":return h(t.left);case"ObjectPattern":return ue(t);case"RestElement":return h(t.argument);default:return[]}}function pe(t){switch(t.kind){case"default":return e.importDefaultSpecifier(e.identifier(t.local));case"named":return e.importSpecifier(e.identifier(t.local),t.imported?e.identifier(t.imported):e.identifier(t.local));case"namespace":return e.importNamespaceSpecifier(e.identifier(t.local))}}function _(t){return e.importDeclaration([pe(t)],e.stringLiteral(t.source))}function F(t){let n=[];for(let i=0,r=t.length;i<r;i++)n[i]=_(t[i]);return n}function me(t){switch(t){case"let":case"var":case"param":return!0;case"const":case"hoisted":case"local":case"module":case"unknown":return!1}}function de(t,n,i,r){let o=t.bindings.get(i);if(o)n.push(o);else if(x(r.path,e.isVariableDeclarator)){let a=xe(t,r.path);for(let s=0,f=a.length;s<f;s++)n.push(a[s]),t.bindings.set(a[s].local,a[s])}else if(x(r.path,e.isFunctionDeclaration)){let a=ge(t,r.path);n.push(a),t.bindings.set(a.local,a)}}function be(t,n,i,r,o,a){if(a.kind==="module")n.push(j(a.path));else if(a.kind==="param")i.push(a.identifier);else{let s=a.path.scope.getBlockParent(),f=a.path.scope.getProgramParent();s===f?de(t,n,o,a):(i.push(a.identifier),me(a.kind)&&r.push(a.identifier))}}function T(t,n,i){let r=[],o=[],a=[];for(let s of i){let f=n.scope.getBinding(s);f&&be(t,r,o,a,s,f)}return{modules:r,locals:o,mutations:a}}function ge(t,n){let i=y(n,"function"),{modules:r}=T(t,n,i),o=t.options.getVirtualFileName(t.path,t.virtual.count++),a=M(e.program([...F(r),e.exportDefaultDeclaration(n.node)]));t.onVirtualFile(o,a.code);let s=C(n),u={kind:"default",local:(n.node.id||n.scope.generateUidIdentifier("func")).name,source:o};return s.insertBefore(_(u)),n.remove(),u}function xe(t,n){let i=w(n.get("init"),e.isExpression),r=i?T(t,n,y(n,x(i,e.isArrowFunctionExpression)||x(i,e.isFunctionExpression)?"function":"expression")).modules:[],o=t.options.getVirtualFileName(t.path,t.virtual.count++),a=n.parentPath.node,s=M(e.program([...F(r),e.exportNamedDeclaration(e.variableDeclaration(a.kind,[n.node]))]));t.onVirtualFile(o,s.code);let f=h(n.node.id).map(c=>({kind:"named",local:c,source:o})),u=C(n);return u&&u.insertBefore(F(f)),n.remove(),f}var G=e.numericLiteral(0),H=e.numericLiteral(1),W=e.numericLiteral(2),Se=e.numericLiteral(3),$=e.numericLiteral(4);function Pe(t,n){let i=t.scope.getFunctionParent()||t.scope.getProgramParent(),r=[],o=0,a=[],s=0,f=!1,u=!1,c=n.length?t.scope.generateUidIdentifier("mutate"):void 0;t.traverse({BreakStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){let p=[G];if(o++,l.node.label){let E=l.node.label.name;r.push(E),p.push(e.stringLiteral(E))}else p.push(e.nullLiteral());c&&p.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(p))),l.skip()}},ContinueStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){let p=[H];if(s++,l.node.label){let E=l.node.label.name;a.push(E),p.push(e.stringLiteral(E))}else p.push(e.nullLiteral());c&&p.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(p))),l.skip()}},ReturnStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){f=!0;let p=[W];l.node.argument?p.push(l.node.argument):p.push(e.nullLiteral()),c&&p.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(p))),l.skip()}},YieldExpression(l){(l.scope.getFunctionParent()||l.scope.getProgramParent())===i&&(u=!0)}});let m=t.scope.generateUidIdentifier("error"),g=[$,m],S=[Se];c&&(g.push(e.callExpression(c,[])),S.push(e.nullLiteral()),S.push(e.callExpression(c,[])));let d=[e.tryStatement(e.blockStatement(t.node.body),e.catchClause(m,e.blockStatement([e.returnStatement(e.arrayExpression(g))]))),e.returnStatement(e.arrayExpression(S))];return c&&d.unshift(e.variableDeclaration("const",[e.variableDeclarator(c,e.arrowFunctionExpression([],e.objectExpression(n.map(l=>e.objectProperty(l,l,!1,!0)))))])),t.node.body=d,{breaks:r,continues:a,hasReturn:f,hasYield:u,breakCount:o,continueCount:s}}function Ee(t,n,i,r,o){let a;i!==r.length&&(a=e.blockStatement([e.breakStatement()]));for(let s=0,f=r.length;s<f;s++){let u=r[s];a=e.blockStatement([e.ifStatement(e.binaryExpression("===",n,e.stringLiteral(u)),e.blockStatement([e.breakStatement(e.identifier(u))]),a)])}return a?e.ifStatement(e.binaryExpression("===",t,G),a,o):o}function he(t,n,i,r,o){let a;i!==r.length&&(a=e.blockStatement([e.continueStatement()]));for(let s=0,f=r.length;s<f;s++){let u=r[s];a=e.blockStatement([e.ifStatement(e.binaryExpression("===",n,e.stringLiteral(u)),e.blockStatement([e.continueStatement(e.identifier(u))]),a)])}return a?e.ifStatement(e.binaryExpression("===",t,H),a,o):o}function De(t,n,i){let r=t.scope.generateUidIdentifier("iterator"),o=t.scope.generateUidIdentifier("step");return[[e.variableDeclaration("let",[e.variableDeclarator(o),e.variableDeclarator(r,e.awaitExpression(e.callExpression(n,i)))]),e.whileStatement(e.booleanLiteral(!0),e.blockStatement([e.expressionStatement(e.assignmentExpression("=",o,e.callExpression(e.memberExpression(r,e.identifier("next")),[]))),e.ifStatement(e.memberExpression(o,e.identifier("done")),e.blockStatement([e.breakStatement()]),e.blockStatement([e.expressionStatement(e.yieldExpression(e.memberExpression(o,e.identifier("value"))))]))]))],o]}function ke(t,n,i,r){let o=Pe(n,r.mutations),a=`${t.blocks.hash}-${t.blocks.count++}`;t.options.env!=="production"&&(a+=`-${A(n,"anonymous")}`);let s=[e.stringLiteral(a)];t.options.mode==="server"&&s.push(e.functionExpression(void 0,r.locals,e.blockStatement(n.node.body),o.hasYield,!0));let f=t.options.getVirtualFileName(t.path,t.virtual.count++),u=n.scope.generateUidIdentifier("register"),c=M(e.program([...t.options.mode==="server"?F(r.modules):[],_({kind:i.import.kind,source:i.import.source,local:u.name,imported:i.import.kind==="named"?i.import.name:void 0}),e.exportDefaultDeclaration(e.callExpression(u,s))]));t.onEntryFile(f),t.onVirtualFile(f,c.code);let m=n.scope.generateUidIdentifier("type"),g=n.scope.generateUidIdentifier("result"),S=n.scope.generateUidIdentifier("mutations"),d=e.ifStatement(e.binaryExpression("===",m,$),e.blockStatement([e.throwStatement(g)]));o.hasReturn&&(d=e.ifStatement(e.binaryExpression("===",m,W),e.blockStatement([e.returnStatement(g)]),d)),o.breakCount>0&&(d=Ee(m,g,o.breakCount,o.breaks,d)),o.continueCount>0&&(d=he(m,g,o.continueCount,o.continues,d));let l=n.scope.generateUidIdentifier("block"),b=[e.variableDeclaration("const",[e.variableDeclarator(l,e.memberExpression(e.awaitExpression(e.importExpression(e.stringLiteral(f))),e.identifier("default")))])];if(o.hasYield){let[p,E]=De(n,l,r.locals);for(let R=0,Z=p.length;R<Z;R++)b.push(p[R]);b.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([m,g,S]),e.memberExpression(E,e.identifier("value")))]))}else b.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([m,g,S]),e.awaitExpression(e.callExpression(l,r.locals)))]));r.mutations.length&&b.push(e.expressionStatement(e.assignmentExpression("=",e.objectPattern(r.mutations.map(p=>e.objectProperty(p,p,!1,!0))),S))),d&&b.push(d),n.replaceWith(e.blockStatement(b))}function z(t,n,i){ke(t,n,i,T(t,n,y(n,"block")))}function q(t,n){for(let i=0,r=t.options.directives.length;i<r;i++){let o=t.options.directives[i];if(o.value===n)return o}}function ye(t,n){for(let i=0,r=n.node.directives.length;i<r;i++){let o=n.node.directives[i].value.value,a=q(t,o);if(a)return a}}function ve(t,n){for(let i=0,r=n.node.body.length;i<r;i++){let o=n.node.body[i];if(o.type==="ExpressionStatement"&&o.expression.type==="StringLiteral"){let a=q(t,o.expression.value);if(a)return a}else break}}function Ie(t,n){let i=n.getFunctionParent();if(!(i&&!i.node.async))return ye(t,n)||ve(t,n)}function Ne(t,n){let i=[];for(let r=0,o=t.node.directives.length;r<o;r++){let a=t.node.directives[r];a.value.value!==n.value&&i.push(a)}t.node.directives=i}function Me(t,n){let i=t.get("body");for(let r=0,o=i.length;r<o;r++){let a=i[r];if(a.node.type==="ExpressionStatement"&&a.node.expression.type==="StringLiteral"&&a.node.expression.value===n.value){a.remove();return}}}function J(t,n){let i=Ie(t,n);i&&(Ne(n,i),Me(n,i),z(t,n,i))}function Q(){return{name:"directive-splitter",visitor:{BlockStatement(t,n){J(n.opts,t)}}}}function Fe(t){let n=[];for(let i=0,r=t.length;i<r;++i){let o=t.charCodeAt(i);if(o<128)n.push(o);else if(o<2048)n.push(192|o>>6,128|o&63);else if(o<55296||o>=57344)n.push(224|o>>12,128|o>>6&63,128|o&63);else{let a=65536+((o&1023)<<10|t.charCodeAt(++i)&1023);n.push(240|a>>18&7,128|a>>12&63,128|a>>6&63,128|a&63)}}return new Uint8Array(n)}function V(t,n=0){t=typeof t=="string"?Fe(t):t;let i=t,r=n+374761393&4294967295,o=0;if(i.length>=16){let s=[n+2654435761+2246822519&4294967295,n+2246822519&4294967295,n+0&4294967295,n-2654435761&4294967295],f=t,u=f.length-16,c=0;for(o=0;(o&4294967280)<=u;o+=4){let m=o,g=f[m+0]+(f[m+1]<<8),S=f[m+2]+(f[m+3]<<8),d=g*2246822519+(S*2246822519<<16),l=s[c]+d&4294967295;l=l<<13|l>>>19;let b=l&65535,p=l>>>16;s[c]=b*2654435761+(p*2654435761<<16)&4294967295,c=c+1&3}r=(s[0]<<1|s[0]>>>31)+(s[1]<<7|s[1]>>>25)+(s[2]<<12|s[2]>>>20)+(s[3]<<18|s[3]>>>14)&4294967295}r=r+t.length&4294967295;let a=t.length-4;for(;o<=a;o+=4){let s=o,f=i[s+0]+(i[s+1]<<8),u=i[s+2]+(i[s+3]<<8),c=f*3266489917+(u*3266489917<<16);r=r+c&4294967295,r=r<<17|r>>>15,r=(r&65535)*668265263+((r>>>16)*668265263<<16)&4294967295}for(;o<i.length;++o){let s=i[o];r+=s*374761393,r=r<<11|r>>>21,r=(r&65535)*2654435761+((r>>>16)*2654435761<<16)&4294967295}return r^=r>>>15,r=((r&65535)*2246822519&4294967295)+((r>>>16)*2246822519<<16),r^=r>>>13,r=((r&65535)*3266489917&4294967295)+((r>>>16)*3266489917<<16),r^=r>>>16,r<0?r+4294967296:r}async function Be(t,n,i){let r=B.default.parse(n),o=[],a=new Map,s={path:r,imports:new Map,virtual:{count:0},options:i,bindings:new Map,blocks:{hash:V(n).toString(16),count:0},onVirtualFile(c,m){a.set(B.default.join(r.dir,c),m)},onEntryFile(c){o.push(B.default.join(r.dir,c))}},f=["jsx"];/\.[mc]?tsx?$/i.test(n)&&f.push("typescript");let u=await X.transformAsync(t,{plugins:[[Q,s]],parserOpts:{plugins:f},filename:r.base,ast:!1,sourceFileName:n,sourceMaps:!0,configFile:!1,babelrc:!1});return k(u,"invariant"),{code:u.code,map:u.map,files:a,entries:o}}
"use strict";var re=Object.create;var F=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var se=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var fe=(t,n)=>{for(var i in n)F(t,i,{get:n[i],enumerable:!0})},A=(t,n,i,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of ae(n))!le.call(t,o)&&o!==i&&F(t,o,{get:()=>n[o],enumerable:!(r=oe(n,o))||r.enumerable});return t};var h=(t,n,i)=>(i=t!=null?re(se(t)):{},A(n||!t||!t.__esModule?F(i,"default",{value:t,enumerable:!0}):i,t)),ce=t=>A(F({},"__esModule",{value:!0}),t);var Te={};fe(Te,{compile:()=>_e});module.exports=ce(Te);var te=h(require("@babel/core"),1),w=h(require("path"),1);function I(t,n){if(!t)throw new Error(n)}var e=h(require("@babel/types"),1);var B=h(require("@babel/types"),1);function O(t,n,i,r){if(n.scope.hasGlobal(i))return!1;if(t===n)return!0;if(n.scope.hasOwnBinding(i)){if(r==="block"){let o=n.scope.getBinding(i);return!!o&&o.kind==="param"}return!1}return n.parentPath?O(t,n.parentPath,i,r):!0}function ue(t){let n=t.parentPath;for(;n;){if(B.isTypeScript(n.node)&&!B.isExpression(n.node))return!0;n=n.parentPath}return!1}function v(t,n){let i=new Set;return t.traverse({ReferencedIdentifier(r){!ue(r)&&(n==="expression"?!t.scope.hasGlobal(r.node.name):O(t,r,r.node.name,n))&&i.add(r.node.name)}}),i}function K(t,n){let i=t;for(;i;){switch(i.node.type){case"FunctionDeclaration":case"FunctionExpression":{if(i.node.id)return i.node.id.name;break}case"VariableDeclarator":{if(i.node.id.type==="Identifier")return i.node.id.name;break}case"ClassPrivateMethod":case"ClassMethod":case"ObjectMethod":{switch(i.node.key.type){case"Identifier":return i.node.key.name;case"PrivateName":return i.node.key.id.name;default:break}break}default:break}i=i.parentPath}return n}var C=h(require("@babel/generator"),1),pe=typeof C.default!="function"?C.default.default:C.default,N=pe;var j=h(require("@babel/types"),1);function T(t){let n=t.parentPath;for(;n;){let i=n.parentPath;if(i&&j.isProgram(i.node))return n;n=i}return t}var y=h(require("@babel/types"),1);function Y(t){switch(t.imported.type){case"Identifier":return t.imported.name;case"StringLiteral":return t.imported.value}}function b(t,n){return n(t.node)}function me(t){switch(t.type){case"ParenthesizedExpression":case"TypeCastExpression":case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":case"TSInstantiationExpression":return!0;default:return!1}}function V(t,n){if(b(t,n))return t;if(b(t,me))return V(t.get("expression"),n)}function $(t){I(b(t,y.isImportSpecifier)||b(t,y.isImportDefaultSpecifier)||b(t,y.isImportNamespaceSpecifier),"invariant");let i=t.getStatementParent().node.source.value;switch(t.node.type){case"ImportDefaultSpecifier":return{source:i,kind:"default",local:t.node.local.name};case"ImportNamespaceSpecifier":return{source:i,kind:"namespace",local:t.node.local.name};case"ImportSpecifier":{let r=Y(t.node);return r==="default"?{source:i,kind:"default",local:t.node.local.name,imported:""}:{source:i,kind:"named",local:t.node.local.name,imported:r}}}}var G=h(require("@babel/types"),1);function de(t){let n=[];for(let i=0,r=t.elements.length;i<r;i++){let o=t.elements[i];o&&n.push(...D(o))}return n}function be(t){let n=[];for(let i=0,r=t.properties.length;i<r;i++){let o=t.properties[i];o&&(o.type==="RestElement"?n.push(...D(o)):G.isLVal(o.value)&&n.push(...D(o.value)))}return n}function D(t){switch(t.type){case"Identifier":return[t.name];case"ArrayPattern":return de(t);case"AssignmentPattern":return D(t.left);case"ObjectPattern":return be(t);case"RestElement":return D(t.argument);default:return[]}}function ge(t){switch(t.kind){case"default":return e.importDefaultSpecifier(e.identifier(t.local));case"named":return e.importSpecifier(e.identifier(t.local),t.imported?e.identifier(t.imported):e.identifier(t.local));case"namespace":return e.importNamespaceSpecifier(e.identifier(t.local))}}function H(t){return e.importDeclaration([ge(t)],e.stringLiteral(t.source))}function M(t){let n=[];for(let i=0,r=t.length;i<r;i++)n[i]=H(t[i]);return n}function xe(t){switch(t){case"let":case"var":case"param":return!0;case"const":case"hoisted":case"local":case"module":case"unknown":return!1}}function Se(t,n,i,r){let o=t.bindings.get(i);if(o)n.push(o);else if(b(r.path,e.isVariableDeclarator)){let a=he(t,r.path);for(let s=0,f=a.length;s<f;s++)n.push(a[s]),t.bindings.set(a[s].local,a[s])}else if(b(r.path,e.isFunctionDeclaration)){let a=Ee(t,r.path);n.push(a),t.bindings.set(a.local,a)}}function Pe(t,n,i,r,o,a){if(a.kind==="module")n.push($(a.path));else if(a.kind==="param")i.push(a.identifier);else{let s=a.path.scope.getBlockParent(),f=a.path.scope.getProgramParent();s===f?Se(t,n,o,a):(i.push(a.identifier),xe(a.kind)&&r.push(a.identifier))}}function L(t,n,i){let r=[],o=[],a=[];for(let s of i){let f=n.scope.getBinding(s);f&&Pe(t,r,o,a,s,f)}return{modules:r,locals:o,mutations:a}}function R(t){return`./${t.path.base}?directive=${t.virtual.count++}${t.path.ext}`}function Ee(t,n){let i=v(n,"function"),{modules:r}=L(t,n,i),o=R(t),a=N(e.program([...M(r),e.exportDefaultDeclaration(n.node)]));t.onVirtualFile(o,a.code,"none");let s=T(n),p={kind:"default",local:(n.node.id||n.scope.generateUidIdentifier("func")).name,source:o};return s.insertBefore(H(p)),n.remove(),p}function he(t,n){let i=V(n.get("init"),e.isExpression),r=i?L(t,n,v(n,b(i,e.isArrowFunctionExpression)||b(i,e.isFunctionExpression)?"function":"expression")).modules:[],o=R(t),a=n.parentPath.node,s=N(e.program([...M(r),e.exportNamedDeclaration(e.variableDeclaration(a.kind,[n.node]))]));t.onVirtualFile(o,s.code,"none");let f=D(n.node.id).map(c=>({kind:"named",local:c,source:o})),p=T(n);return p&&p.insertBefore(M(f)),n.remove(),f}var W=e.numericLiteral(0),z=e.numericLiteral(1),q=e.numericLiteral(2),De=e.numericLiteral(3),J=e.numericLiteral(4);function ke(t,n){let i=t.scope.getFunctionParent()||t.scope.getProgramParent(),r=[],o=0,a=[],s=0,f=!1,p=!1,c=n.length?t.scope.generateUidIdentifier("mutate"):void 0;t.traverse({BreakStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){let u=[W];if(o++,l.node.label){let P=l.node.label.name;r.push(P),u.push(e.stringLiteral(P))}else u.push(e.nullLiteral());c&&u.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(u))),l.skip()}},ContinueStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){let u=[z];if(s++,l.node.label){let P=l.node.label.name;a.push(P),u.push(e.stringLiteral(P))}else u.push(e.nullLiteral());c&&u.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(u))),l.skip()}},ReturnStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){f=!0;let u=[q];l.node.argument?u.push(l.node.argument):u.push(e.nullLiteral()),c&&u.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(u))),l.skip()}},YieldExpression(l){(l.scope.getFunctionParent()||l.scope.getProgramParent())===i&&(p=!0)}});let d=t.scope.generateUidIdentifier("error"),x=[J,d],g=[De];c&&(x.push(e.callExpression(c,[])),g.push(e.nullLiteral()),g.push(e.callExpression(c,[])));let m=[e.tryStatement(e.blockStatement(t.node.body),e.catchClause(d,e.blockStatement([e.returnStatement(e.arrayExpression(x))]))),e.returnStatement(e.arrayExpression(g))];return c&&m.unshift(e.variableDeclaration("const",[e.variableDeclarator(c,e.arrowFunctionExpression([],e.objectExpression(n.map(l=>e.objectProperty(l,l,!1,!0)))))])),t.node.body=m,{breaks:r,continues:a,hasReturn:f,hasYield:p,breakCount:o,continueCount:s}}function ye(t,n,i,r,o){let a;i!==r.length&&(a=e.blockStatement([e.breakStatement()]));for(let s=0,f=r.length;s<f;s++){let p=r[s];a=e.blockStatement([e.ifStatement(e.binaryExpression("===",n,e.stringLiteral(p)),e.blockStatement([e.breakStatement(e.identifier(p))]),a)])}return a?e.ifStatement(e.binaryExpression("===",t,W),a,o):o}function Ie(t,n,i,r,o){let a;i!==r.length&&(a=e.blockStatement([e.continueStatement()]));for(let s=0,f=r.length;s<f;s++){let p=r[s];a=e.blockStatement([e.ifStatement(e.binaryExpression("===",n,e.stringLiteral(p)),e.blockStatement([e.continueStatement(e.identifier(p))]),a)])}return a?e.ifStatement(e.binaryExpression("===",t,z),a,o):o}function ve(t,n,i){let r=t.scope.generateUidIdentifier("iterator"),o=t.scope.generateUidIdentifier("step");return[[e.variableDeclaration("let",[e.variableDeclarator(o),e.variableDeclarator(r,e.awaitExpression(e.callExpression(n,i)))]),e.whileStatement(e.booleanLiteral(!0),e.blockStatement([e.expressionStatement(e.assignmentExpression("=",o,e.callExpression(e.memberExpression(r,e.identifier("next")),[]))),e.ifStatement(e.memberExpression(o,e.identifier("done")),e.blockStatement([e.breakStatement()]),e.blockStatement([e.expressionStatement(e.yieldExpression(e.memberExpression(o,e.identifier("value"))))]))]))],o]}function Ne(t,n,i,r){let o=ke(n,r.mutations),a=R(t),s=N(e.program([...t.options.mode==="server"?M(r.modules):[],e.exportDefaultDeclaration(e.functionExpression(void 0,r.locals,e.blockStatement(n.node.body),o.hasYield,!0))]));t.onVirtualFile(a,s.code,"root");let f=`${t.blocks.hash}-${t.blocks.count++}`;t.options.env!=="production"&&(f+=`-${K(n,"anonymous")}`);let p=n.scope.generateUidIdentifier("entry"),c=[{kind:i.import.kind,source:i.import.source,local:p.name,imported:i.import.kind==="named"?i.import.name:void 0}],d=[e.stringLiteral(f)];if(t.options.mode==="server"){let E=n.scope.generateUidIdentifier("root");c.push({kind:"default",source:a,local:E.name}),d.push(E)}let x=R(t),g=N(e.program([...M(c),e.exportDefaultDeclaration(e.callExpression(p,d))]));t.onVirtualFile(x,g.code,"entry");let m=n.scope.generateUidIdentifier("type"),l=n.scope.generateUidIdentifier("result"),S=n.scope.generateUidIdentifier("mutations"),u=e.ifStatement(e.binaryExpression("===",m,J),e.blockStatement([e.throwStatement(l)]));o.hasReturn&&(u=e.ifStatement(e.binaryExpression("===",m,q),e.blockStatement([e.returnStatement(l)]),u)),o.breakCount>0&&(u=ye(m,l,o.breakCount,o.breaks,u)),o.continueCount>0&&(u=Ie(m,l,o.continueCount,o.continues,u));let P=n.scope.generateUidIdentifier("block"),k=[e.variableDeclaration("const",[e.variableDeclarator(P,e.memberExpression(e.awaitExpression(e.importExpression(e.stringLiteral(x))),e.identifier("default")))])];if(o.hasYield){let[E,ne]=ve(n,P,r.locals);for(let _=0,ie=E.length;_<ie;_++)k.push(E[_]);k.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([m,l,S]),e.memberExpression(ne,e.identifier("value")))]))}else k.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([m,l,S]),e.awaitExpression(e.callExpression(P,r.locals)))]));r.mutations.length&&k.push(e.expressionStatement(e.assignmentExpression("=",e.objectPattern(r.mutations.map(E=>e.objectProperty(E,E,!1,!0))),S))),u&&k.push(u),n.replaceWith(e.blockStatement(k))}function Q(t,n,i){Ne(t,n,i,L(t,n,v(n,"block")))}function X(t,n){for(let i=0,r=t.options.directives.length;i<r;i++){let o=t.options.directives[i];if(o.value===n)return o}}function Me(t,n){for(let i=0,r=n.node.directives.length;i<r;i++){let o=n.node.directives[i].value.value,a=X(t,o);if(a)return a}}function Fe(t,n){for(let i=0,r=n.node.body.length;i<r;i++){let o=n.node.body[i];if(o.type==="ExpressionStatement"&&o.expression.type==="StringLiteral"){let a=X(t,o.expression.value);if(a)return a}else break}}function Be(t,n){let i=n.getFunctionParent();if(!(i&&!i.node.async))return Me(t,n)||Fe(t,n)}function Ce(t,n){let i=[];for(let r=0,o=t.node.directives.length;r<o;r++){let a=t.node.directives[r];a.value.value!==n.value&&i.push(a)}t.node.directives=i}function Re(t,n){let i=t.get("body");for(let r=0,o=i.length;r<o;r++){let a=i[r];if(a.node.type==="ExpressionStatement"&&a.node.expression.type==="StringLiteral"&&a.node.expression.value===n.value){a.remove();return}}}function Z(t,n){let i=Be(t,n);i&&(Ce(n,i),Re(n,i),Q(t,n,i))}function ee(){return{name:"directive-splitter",visitor:{BlockStatement(t,n){Z(n.opts,t)}}}}function we(t){let n=[];for(let i=0,r=t.length;i<r;++i){let o=t.charCodeAt(i);if(o<128)n.push(o);else if(o<2048)n.push(192|o>>6,128|o&63);else if(o<55296||o>=57344)n.push(224|o>>12,128|o>>6&63,128|o&63);else{let a=65536+((o&1023)<<10|t.charCodeAt(++i)&1023);n.push(240|a>>18&7,128|a>>12&63,128|a>>6&63,128|a&63)}}return new Uint8Array(n)}function U(t,n=0){t=typeof t=="string"?we(t):t;let i=t,r=n+374761393&4294967295,o=0;if(i.length>=16){let s=[n+2654435761+2246822519&4294967295,n+2246822519&4294967295,n+0&4294967295,n-2654435761&4294967295],f=t,p=f.length-16,c=0;for(o=0;(o&4294967280)<=p;o+=4){let d=o,x=f[d+0]+(f[d+1]<<8),g=f[d+2]+(f[d+3]<<8),m=x*2246822519+(g*2246822519<<16),l=s[c]+m&4294967295;l=l<<13|l>>>19;let S=l&65535,u=l>>>16;s[c]=S*2654435761+(u*2654435761<<16)&4294967295,c=c+1&3}r=(s[0]<<1|s[0]>>>31)+(s[1]<<7|s[1]>>>25)+(s[2]<<12|s[2]>>>20)+(s[3]<<18|s[3]>>>14)&4294967295}r=r+t.length&4294967295;let a=t.length-4;for(;o<=a;o+=4){let s=o,f=i[s+0]+(i[s+1]<<8),p=i[s+2]+(i[s+3]<<8),c=f*3266489917+(p*3266489917<<16);r=r+c&4294967295,r=r<<17|r>>>15,r=(r&65535)*668265263+((r>>>16)*668265263<<16)&4294967295}for(;o<i.length;++o){let s=i[o];r+=s*374761393,r=r<<11|r>>>21,r=(r&65535)*2654435761+((r>>>16)*2654435761<<16)&4294967295}return r^=r>>>15,r=((r&65535)*2246822519&4294967295)+((r>>>16)*2246822519<<16),r^=r>>>13,r=((r&65535)*3266489917&4294967295)+((r>>>16)*3266489917<<16),r^=r>>>16,r<0?r+4294967296:r}async function _e(t,n,i){let r=w.default.parse(n),o=[],a=[],s=new Map,f={path:r,imports:new Map,virtual:{count:0},options:i,bindings:new Map,blocks:{hash:U(n).toString(16),count:0},onVirtualFile(d,x,g){let m=w.default.join(r.dir,d);s.set(w.default.join(r.dir,d),x),g==="entry"?o.push(m):g==="root"&&a.push(m)}},p=["jsx"];/\.[mc]?tsx?$/i.test(n)&&p.push("typescript");let c=await te.transformAsync(t,{plugins:[[ee,f]],parserOpts:{plugins:p},filename:r.base,ast:!1,sourceFileName:n,sourceMaps:!0,configFile:!1,babelrc:!1});return I(c,"invariant"),{code:c.code,map:c.map,files:s,entries:o,roots:a}}

@@ -366,6 +366,9 @@ "use strict";

}
function createVirtualFileName(ctx) {
return `./${ctx.path.base}?directive=${ctx.virtual.count++}${ctx.path.ext}`;
}
function splitFunctionDeclaration(ctx, path2) {
const bindings = getForeignBindings(path2, "function");
const { modules } = extractBindings(ctx, path2, bindings);
const file = ctx.options.getVirtualFileName(ctx.path, ctx.virtual.count++);
const file = createVirtualFileName(ctx);
const compiled = generator_shim_default(

@@ -377,3 +380,3 @@ t5.program([

);
ctx.onVirtualFile(file, compiled.code);
ctx.onVirtualFile(file, compiled.code, "none");
const statement = getRootStatementPath(path2);

@@ -400,3 +403,3 @@ const identifier2 = path2.node.id || path2.scope.generateUidIdentifier("func");

).modules : [];
const file = ctx.options.getVirtualFileName(ctx.path, ctx.virtual.count++);
const file = createVirtualFileName(ctx);
const parent = path2.parentPath.node;

@@ -409,3 +412,3 @@ const compiled = generator_shim_default(

);
ctx.onVirtualFile(file, compiled.code);
ctx.onVirtualFile(file, compiled.code, "none");
const definitions = getIdentifiersFromLVal(

@@ -637,2 +640,18 @@ path2.node.id

const halting = transformHalting(path2, bindings.mutations);
const rootFile = createVirtualFileName(ctx);
const rootContent = generator_shim_default(
t5.program([
...ctx.options.mode === "server" ? moduleDefinitionsToImportDeclarations(bindings.modules) : [],
t5.exportDefaultDeclaration(
t5.functionExpression(
void 0,
bindings.locals,
t5.blockStatement(path2.node.body),
halting.hasYield,
true
)
)
])
);
ctx.onVirtualFile(rootFile, rootContent.code, "root");
let id = `${ctx.blocks.hash}-${ctx.blocks.count++}`;

@@ -642,33 +661,29 @@ if (ctx.options.env !== "production") {

}
const entryID = path2.scope.generateUidIdentifier("entry");
const entryImports = [
{
kind: directive.import.kind,
source: directive.import.source,
local: entryID.name,
imported: directive.import.kind === "named" ? directive.import.name : void 0
}
];
const args = [t5.stringLiteral(id)];
if (ctx.options.mode === "server") {
args.push(
t5.functionExpression(
void 0,
bindings.locals,
t5.blockStatement(path2.node.body),
halting.hasYield,
true
)
);
const rootID = path2.scope.generateUidIdentifier("root");
entryImports.push({
kind: "default",
source: rootFile,
local: rootID.name
});
args.push(rootID);
}
const registrationFile = ctx.options.getVirtualFileName(
ctx.path,
ctx.virtual.count++
);
const registerID = path2.scope.generateUidIdentifier("register");
const registrationContent = generator_shim_default(
const entryFile = createVirtualFileName(ctx);
const entryContent = generator_shim_default(
t5.program([
...ctx.options.mode === "server" ? moduleDefinitionsToImportDeclarations(bindings.modules) : [],
moduleDefinitionToImportDeclaration({
kind: directive.import.kind,
source: directive.import.source,
local: registerID.name,
imported: directive.import.kind === "named" ? directive.import.name : void 0
}),
t5.exportDefaultDeclaration(t5.callExpression(registerID, args))
...moduleDefinitionsToImportDeclarations(entryImports),
t5.exportDefaultDeclaration(t5.callExpression(entryID, args))
])
);
ctx.onEntryFile(registrationFile);
ctx.onVirtualFile(registrationFile, registrationContent.code);
ctx.onVirtualFile(entryFile, entryContent.code, "entry");
const returnType = path2.scope.generateUidIdentifier("type");

@@ -712,5 +727,3 @@ const returnResult = path2.scope.generateUidIdentifier("result");

t5.memberExpression(
t5.awaitExpression(
t5.importExpression(t5.stringLiteral(registrationFile))
),
t5.awaitExpression(t5.importExpression(t5.stringLiteral(entryFile))),
t5.identifier("default")

@@ -951,2 +964,3 @@ )

const entries = [];
const roots = [];
const files = /* @__PURE__ */ new Map();

@@ -965,7 +979,10 @@ const ctx = {

},
onVirtualFile(current, content) {
onVirtualFile(current, content, mode) {
const filePath = import_path.default.join(parsedPath.dir, current);
files.set(import_path.default.join(parsedPath.dir, current), content);
},
onEntryFile(current) {
entries.push(import_path.default.join(parsedPath.dir, current));
if (mode === "entry") {
entries.push(filePath);
} else if (mode === "root") {
roots.push(filePath);
}
}

@@ -994,5 +1011,6 @@ };

files,
entries
entries,
roots
};
}
//# sourceMappingURL=index.cjs.map
{
"version": 3,
"sources": ["../../../src/index.ts", "../../../src/utils/assert.ts", "../../../src/split.ts", "../../../src/utils/get-foreign-bindings.ts", "../../../src/utils/get-descriptive-name.ts", "../../../src/utils/generator-shim.ts", "../../../src/utils/get-root-statement-path.ts", "../../../src/utils/get-module-definition.ts", "../../../src/utils/get-import-specifier-name.ts", "../../../src/utils/unwrap.ts", "../../../src/utils/get-identifiers-from-lval.ts", "../../../src/transform-block.ts", "../../../src/plugin.ts", "../../../src/utils/xxhash32.ts"],
"sourcesContent": ["import * as babel from '@babel/core';\nimport path from 'path';\nimport type { Options, StateContext } from './types';\nimport assert from './utils/assert';\nimport { plugin } from './plugin';\nimport xxHash32 from './utils/xxhash32';\n\nexport interface Output {\n code: babel.BabelFileResult['code'];\n map: babel.BabelFileResult['map'];\n files: Map<string, string>;\n entries: string[];\n}\n\nexport {\n NamedImportDefinition,\n DefaultImportDefinition,\n DirectiveDefinition,\n ImportDefinition,\n Options,\n} from './types';\n\nexport async function compile(\n code: string,\n id: string,\n options: Options,\n): Promise<Output> {\n const parsedPath = path.parse(id);\n\n const entries: string[] = [];\n const files = new Map<string, string>();\n\n const ctx: StateContext = {\n path: parsedPath,\n imports: new Map(),\n virtual: {\n count: 0,\n },\n options,\n bindings: new Map(),\n blocks: {\n hash: xxHash32(id).toString(16),\n count: 0,\n },\n onVirtualFile(current, content) {\n files.set(path.join(parsedPath.dir, current), content);\n },\n onEntryFile(current) {\n entries.push(path.join(parsedPath.dir, current));\n },\n };\n\n const plugins: babel.ParserOptions['plugins'] = ['jsx'];\n\n if (/\\.[mc]?tsx?$/i.test(id)) {\n plugins.push('typescript');\n }\n\n const result = await babel.transformAsync(code, {\n plugins: [[plugin, ctx]],\n parserOpts: {\n plugins,\n },\n filename: parsedPath.base,\n ast: false,\n sourceFileName: id,\n sourceMaps: true,\n configFile: false,\n babelrc: false,\n });\n\n assert(result, 'invariant');\n\n return {\n code: result.code,\n map: result.map,\n files,\n entries,\n };\n}\n", "export default function assert(cond: unknown, error: string): asserts cond {\n if (!cond) {\n throw new Error(error);\n }\n}\n", "import * as t from '@babel/types';\nimport * as babel from '@babel/core';\nimport { DirectiveDefinition, ModuleDefinition, StateContext } from './types';\nimport getForeignBindings from './utils/get-foreign-bindings';\nimport { Binding, BindingKind } from '@babel/traverse';\nimport { getDescriptiveName } from './utils/get-descriptive-name';\nimport generator from './utils/generator-shim';\nimport { getRootStatementPath } from './utils/get-root-statement-path';\nimport { getModuleDefinition } from './utils/get-module-definition';\nimport { isPathValid, unwrapPath } from './utils/unwrap';\nimport { getIdentifiersFromLVal } from './utils/get-identifiers-from-lval';\n\nfunction moduleDefinitionToImportSpecifier(definition: ModuleDefinition) {\n switch (definition.kind) {\n case 'default':\n return t.importDefaultSpecifier(t.identifier(definition.local));\n case 'named':\n return t.importSpecifier(\n t.identifier(definition.local),\n definition.imported\n ? t.identifier(definition.imported)\n : t.identifier(definition.local),\n );\n case 'namespace':\n return t.importNamespaceSpecifier(t.identifier(definition.local));\n }\n}\n\nfunction moduleDefinitionToImportDeclaration(definition: ModuleDefinition) {\n return t.importDeclaration(\n [moduleDefinitionToImportSpecifier(definition)],\n t.stringLiteral(definition.source),\n );\n}\n\nfunction moduleDefinitionsToImportDeclarations(\n definitions: ModuleDefinition[],\n) {\n const declarations: t.ImportDeclaration[] = [];\n for (let i = 0, len = definitions.length; i < len; i++) {\n declarations[i] = moduleDefinitionToImportDeclaration(definitions[i]);\n }\n return declarations;\n}\n\nfunction isMutation(kind: BindingKind): boolean {\n switch (kind) {\n case 'let':\n case 'var':\n case 'param':\n return true;\n case 'const':\n case 'hoisted':\n case 'local':\n case 'module':\n case 'unknown':\n return false;\n }\n}\n\nfunction registerModuleLevelBinding(\n ctx: StateContext,\n modules: ModuleDefinition[],\n binding: string,\n target: Binding,\n): void {\n const current = ctx.bindings.get(binding);\n if (current) {\n modules.push(current);\n } else if (isPathValid(target.path, t.isVariableDeclarator)) {\n const definitions = splitVariableDeclarator(ctx, target.path);\n for (let k = 0, klen = definitions.length; k < klen; k++) {\n modules.push(definitions[k]);\n ctx.bindings.set(definitions[k].local, definitions[k]);\n }\n } else if (isPathValid(target.path, t.isFunctionDeclaration)) {\n const definition = splitFunctionDeclaration(ctx, target.path);\n modules.push(definition);\n ctx.bindings.set(definition.local, definition);\n }\n}\n\nfunction registerBinding(\n ctx: StateContext,\n modules: ModuleDefinition[],\n locals: t.Identifier[],\n mutations: t.Identifier[],\n binding: string,\n target: Binding,\n): void {\n if (target.kind === 'module') {\n modules.push(getModuleDefinition(target.path));\n } else if (target.kind === 'param') {\n locals.push(target.identifier);\n } else {\n const blockParent = target.path.scope.getBlockParent();\n const programParent = target.path.scope.getProgramParent();\n if (blockParent === programParent) {\n registerModuleLevelBinding(ctx, modules, binding, target);\n } else {\n locals.push(target.identifier);\n if (isMutation(target.kind)) {\n mutations.push(target.identifier);\n }\n }\n }\n}\n\ninterface ExtractedBindings {\n modules: ModuleDefinition[];\n locals: t.Identifier[];\n mutations: t.Identifier[];\n}\n\nfunction extractBindings(\n ctx: StateContext,\n path: babel.NodePath,\n bindings: Set<string>,\n): ExtractedBindings {\n const modules: ModuleDefinition[] = [];\n const locals: t.Identifier[] = [];\n const mutations: t.Identifier[] = [];\n for (const binding of bindings) {\n const target = path.scope.getBinding(binding);\n if (target) {\n registerBinding(ctx, modules, locals, mutations, binding, target);\n }\n }\n\n return {\n modules,\n locals,\n mutations,\n };\n}\n\nfunction splitFunctionDeclaration(\n ctx: StateContext,\n path: babel.NodePath<t.FunctionDeclaration>,\n): ModuleDefinition {\n const bindings = getForeignBindings(path, 'function');\n const { modules } = extractBindings(ctx, path, bindings);\n const file = ctx.options.getVirtualFileName(ctx.path, ctx.virtual.count++);\n const compiled = generator(\n t.program([\n ...moduleDefinitionsToImportDeclarations(modules),\n t.exportDefaultDeclaration(path.node),\n ]),\n );\n ctx.onVirtualFile(file, compiled.code);\n\n const statement = getRootStatementPath(path);\n\n const identifier = path.node.id || path.scope.generateUidIdentifier('func');\n const definition: ModuleDefinition = {\n kind: 'default',\n local: identifier.name,\n source: file,\n };\n\n statement.insertBefore(moduleDefinitionToImportDeclaration(definition));\n path.remove();\n return definition;\n}\n\nfunction splitVariableDeclarator(\n ctx: StateContext,\n path: babel.NodePath<t.VariableDeclarator>,\n): ModuleDefinition[] {\n const init = unwrapPath(path.get('init'), t.isExpression);\n const modules = init\n ? extractBindings(\n ctx,\n path,\n getForeignBindings(\n path,\n isPathValid(init, t.isArrowFunctionExpression) ||\n isPathValid(init, t.isFunctionExpression)\n ? 'function'\n : 'expression',\n ),\n ).modules\n : [];\n const file = ctx.options.getVirtualFileName(ctx.path, ctx.virtual.count++);\n const parent = path.parentPath.node as t.VariableDeclaration;\n const compiled = generator(\n t.program([\n ...moduleDefinitionsToImportDeclarations(modules),\n t.exportNamedDeclaration(t.variableDeclaration(parent.kind, [path.node])),\n ]),\n );\n ctx.onVirtualFile(file, compiled.code);\n const definitions: ModuleDefinition[] = getIdentifiersFromLVal(\n path.node.id,\n ).map(name => ({\n kind: 'named',\n local: name,\n source: file,\n }));\n // Replace declaration with definition\n const statement = getRootStatementPath(path);\n if (statement) {\n statement.insertBefore(moduleDefinitionsToImportDeclarations(definitions));\n }\n path.remove();\n return definitions;\n}\n\n// These are internal code for the control flow of the server block\n// The goal is to transform these into return statements, and the\n// the return value with the associated control flow code.\n// This allows the replacement statement for the server block to\n// know what to do if it encounters the said statement on the server.\nconst BREAK_KEY = t.numericLiteral(0);\nconst CONTINUE_KEY = t.numericLiteral(1);\nconst RETURN_KEY = t.numericLiteral(2);\n// If the function has no explicit return\nconst NO_HALT_KEY = t.numericLiteral(3);\nconst THROW_KEY = t.numericLiteral(4);\n\nfunction transformHalting(\n path: babel.NodePath<t.BlockStatement>,\n mutations: t.Identifier[],\n): {\n breaks: string[];\n breakCount: number;\n continues: string[];\n continueCount: number;\n hasReturn: boolean;\n hasYield: boolean;\n} {\n const target =\n path.scope.getFunctionParent() || path.scope.getProgramParent();\n\n const breaks: string[] = [];\n let breakCount = 0;\n const continues: string[] = [];\n let continueCount = 0;\n let hasReturn = false;\n let hasYield = false;\n\n const applyMutations = mutations.length\n ? path.scope.generateUidIdentifier('mutate')\n : undefined;\n\n // Transform the control flow statements\n path.traverse({\n BreakStatement(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n const replacement: t.Expression[] = [BREAK_KEY];\n breakCount++;\n if (child.node.label) {\n const targetName = child.node.label.name;\n breaks.push(targetName);\n replacement.push(t.stringLiteral(targetName));\n } else {\n replacement.push(t.nullLiteral());\n }\n if (applyMutations) {\n replacement.push(t.callExpression(applyMutations, []));\n }\n child.replaceWith(t.returnStatement(t.arrayExpression(replacement)));\n child.skip();\n }\n },\n ContinueStatement(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n const replacement: t.Expression[] = [CONTINUE_KEY];\n continueCount++;\n if (child.node.label) {\n const targetName = child.node.label.name;\n continues.push(targetName);\n replacement.push(t.stringLiteral(targetName));\n } else {\n replacement.push(t.nullLiteral());\n }\n if (applyMutations) {\n replacement.push(t.callExpression(applyMutations, []));\n }\n child.replaceWith(t.returnStatement(t.arrayExpression(replacement)));\n child.skip();\n }\n },\n ReturnStatement(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n hasReturn = true;\n const replacement: t.Expression[] = [RETURN_KEY];\n if (child.node.argument) {\n replacement.push(child.node.argument);\n } else {\n replacement.push(t.nullLiteral());\n }\n if (applyMutations) {\n replacement.push(t.callExpression(applyMutations, []));\n }\n child.replaceWith(t.returnStatement(t.arrayExpression(replacement)));\n child.skip();\n }\n },\n YieldExpression(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n hasYield = true;\n }\n },\n });\n\n const error = path.scope.generateUidIdentifier('error');\n\n const throwResult: t.Expression[] = [THROW_KEY, error];\n const haltResult: t.Expression[] = [NO_HALT_KEY];\n\n if (applyMutations) {\n throwResult.push(t.callExpression(applyMutations, []));\n haltResult.push(t.nullLiteral());\n haltResult.push(t.callExpression(applyMutations, []));\n }\n\n const statements: t.Statement[] = [\n t.tryStatement(\n t.blockStatement(path.node.body),\n t.catchClause(\n error,\n t.blockStatement([t.returnStatement(t.arrayExpression(throwResult))]),\n ),\n ),\n t.returnStatement(t.arrayExpression(haltResult)),\n ];\n\n if (applyMutations) {\n statements.unshift(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n applyMutations,\n t.arrowFunctionExpression(\n [],\n t.objectExpression(\n mutations.map(item => t.objectProperty(item, item, false, true)),\n ),\n ),\n ),\n ]),\n );\n }\n\n path.node.body = statements;\n return { breaks, continues, hasReturn, hasYield, breakCount, continueCount };\n}\n\n// This generates a chain of if-statements that checks the\n// received server return (which is transformed from the original block's\n// server statement)\n// Each if-statement matches an specific label, assuming that the original\n// break statement is a labeled break statement.\n// Otherwise, the output code is either a normal break statement or none.\nfunction getBreakCheck(\n returnType: t.Identifier,\n returnResult: t.Identifier,\n breakCount: number,\n breaks: string[],\n check: t.Statement,\n): t.Statement {\n let current: t.Statement | undefined;\n if (breakCount !== breaks.length) {\n current = t.blockStatement([t.breakStatement()]);\n }\n for (let i = 0, len = breaks.length; i < len; i++) {\n const target = breaks[i];\n current = t.blockStatement([\n t.ifStatement(\n t.binaryExpression('===', returnResult, t.stringLiteral(target)),\n t.blockStatement([t.breakStatement(t.identifier(target))]),\n current,\n ),\n ]);\n }\n if (current) {\n return t.ifStatement(\n t.binaryExpression('===', returnType, BREAK_KEY),\n current,\n check,\n );\n }\n return check;\n}\n\n// This generates a chain of if-statements that checks the\n// received server return (which is transformed from the original block's\n// server statement)\n// Each if-statement matches an specific label, assuming that the original\n// continue statement is a labeled continue statement.\n// Otherwise, the output code is either a normal continue statement or none.\nfunction getContinueCheck(\n returnType: t.Identifier,\n returnResult: t.Identifier,\n continueCount: number,\n continues: string[],\n check: t.Statement,\n): t.Statement {\n let current: t.Statement | undefined;\n if (continueCount !== continues.length) {\n current = t.blockStatement([t.continueStatement()]);\n }\n for (let i = 0, len = continues.length; i < len; i++) {\n const target = continues[i];\n current = t.blockStatement([\n t.ifStatement(\n t.binaryExpression('===', returnResult, t.stringLiteral(target)),\n t.blockStatement([t.continueStatement(t.identifier(target))]),\n current,\n ),\n ]);\n }\n if (current) {\n return t.ifStatement(\n t.binaryExpression('===', returnType, CONTINUE_KEY),\n current,\n check,\n );\n }\n return check;\n}\n\nfunction getGeneratorReplacementForServerBlock(\n path: babel.NodePath<t.BlockStatement>,\n registerID: t.Identifier,\n cloneArgs: t.Identifier[],\n): [replacements: t.Statement[], step: t.Identifier] {\n const iterator = path.scope.generateUidIdentifier('iterator');\n const step = path.scope.generateUidIdentifier('step');\n const replacement: t.Statement[] = [\n t.variableDeclaration('let', [\n t.variableDeclarator(step),\n // First, get the iterator by calling the generator\n t.variableDeclarator(\n iterator,\n t.awaitExpression(t.callExpression(registerID, cloneArgs)),\n ),\n ]),\n // Create a while statement, the intent is to\n // repeatedly iterate the generator\n t.whileStatement(\n t.booleanLiteral(true),\n t.blockStatement([\n // Get the next value\n t.expressionStatement(\n t.assignmentExpression(\n '=',\n step,\n t.callExpression(\n t.memberExpression(iterator, t.identifier('next')),\n [],\n ),\n ),\n ),\n // Check if the step is done\n t.ifStatement(\n t.memberExpression(step, t.identifier('done')),\n t.blockStatement([\n // exit the loop\n t.breakStatement(),\n ]),\n // Otherwise, yield the value\n t.blockStatement([\n t.expressionStatement(\n t.yieldExpression(\n t.memberExpression(step, t.identifier('value')),\n ),\n ),\n ]),\n ),\n ]),\n ),\n ];\n return [replacement, step];\n}\n\nfunction replaceBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n directive: DirectiveDefinition,\n bindings: ExtractedBindings,\n): void {\n // Transform all control statements\n const halting = transformHalting(path, bindings.mutations);\n // Create an ID\n let id = `${ctx.blocks.hash}-${ctx.blocks.count++}`;\n if (ctx.options.env !== 'production') {\n id += `-${getDescriptiveName(path, 'anonymous')}`;\n }\n const args: t.Expression[] = [t.stringLiteral(id)];\n if (ctx.options.mode === 'server') {\n args.push(\n t.functionExpression(\n undefined,\n bindings.locals,\n t.blockStatement(path.node.body),\n halting.hasYield,\n true,\n ),\n );\n }\n // Create the registration call\n const registrationFile = ctx.options.getVirtualFileName(\n ctx.path,\n ctx.virtual.count++,\n );\n const registerID = path.scope.generateUidIdentifier('register');\n const registrationContent = generator(\n t.program([\n ...(ctx.options.mode === 'server'\n ? moduleDefinitionsToImportDeclarations(bindings.modules)\n : []),\n moduleDefinitionToImportDeclaration({\n kind: directive.import.kind,\n source: directive.import.source,\n local: registerID.name,\n imported:\n directive.import.kind === 'named' ? directive.import.name : undefined,\n }),\n t.exportDefaultDeclaration(t.callExpression(registerID, args)),\n ]),\n );\n ctx.onEntryFile(registrationFile);\n ctx.onVirtualFile(registrationFile, registrationContent.code);\n\n // Move to the replacement for the server block,\n // declare the type and result based from transformHalting\n const returnType = path.scope.generateUidIdentifier('type');\n const returnResult = path.scope.generateUidIdentifier('result');\n const returnMutations = path.scope.generateUidIdentifier('mutations');\n let check: t.Statement = t.ifStatement(\n t.binaryExpression('===', returnType, THROW_KEY),\n t.blockStatement([t.throwStatement(returnResult)]),\n );\n // If the block has a return, we need to make sure that the\n // replacement does too.\n if (halting.hasReturn) {\n check = t.ifStatement(\n t.binaryExpression('===', returnType, RETURN_KEY),\n t.blockStatement([t.returnStatement(returnResult)]),\n check,\n );\n }\n // If the block has a break, we also do it.\n if (halting.breakCount > 0) {\n check = getBreakCheck(\n returnType,\n returnResult,\n halting.breakCount,\n halting.breaks,\n check,\n );\n }\n // If the block has a continue, we also do it.\n if (halting.continueCount > 0) {\n check = getContinueCheck(\n returnType,\n returnResult,\n halting.continueCount,\n halting.continues,\n check,\n );\n }\n\n const blockID = path.scope.generateUidIdentifier('block');\n // If the server block happens to be declared in a generator\n const replacement: t.Statement[] = [\n t.variableDeclaration('const', [\n t.variableDeclarator(\n blockID,\n t.memberExpression(\n t.awaitExpression(\n t.importExpression(t.stringLiteral(registrationFile)),\n ),\n t.identifier('default'),\n ),\n ),\n ]),\n ];\n if (halting.hasYield) {\n const [reps, step] = getGeneratorReplacementForServerBlock(\n path,\n blockID,\n bindings.locals,\n );\n for (let i = 0, len = reps.length; i < len; i++) {\n replacement.push(reps[i]);\n }\n replacement.push(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.arrayPattern([returnType, returnResult, returnMutations]),\n t.memberExpression(step, t.identifier('value')),\n ),\n ]),\n );\n } else {\n replacement.push(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.arrayPattern([returnType, returnResult, returnMutations]),\n t.awaitExpression(t.callExpression(blockID, bindings.locals)),\n ),\n ]),\n );\n }\n if (bindings.mutations.length) {\n replacement.push(\n t.expressionStatement(\n t.assignmentExpression(\n '=',\n t.objectPattern(\n bindings.mutations.map(item =>\n t.objectProperty(item, item, false, true),\n ),\n ),\n returnMutations,\n ),\n ),\n );\n }\n if (check) {\n replacement.push(check);\n }\n path.replaceWith(t.blockStatement(replacement));\n}\n\nexport function splitBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n directive: DirectiveDefinition,\n): void {\n replaceBlock(\n ctx,\n path,\n directive,\n extractBindings(ctx, path, getForeignBindings(path, 'block')),\n );\n}\n", "import type * as babel from '@babel/core';\nimport * as t from '@babel/types';\n\nfunction isForeignBinding(\n source: babel.NodePath,\n current: babel.NodePath,\n name: string,\n mode: 'block' | 'function',\n): boolean {\n if (current.scope.hasGlobal(name)) {\n return false;\n }\n if (source === current) {\n return true;\n }\n if (current.scope.hasOwnBinding(name)) {\n if (mode === 'block') {\n const binding = current.scope.getBinding(name);\n return !!binding && binding.kind === 'param';\n }\n return false;\n }\n if (current.parentPath) {\n return isForeignBinding(source, current.parentPath, name, mode);\n }\n return true;\n}\n\nfunction isInTypescript(path: babel.NodePath): boolean {\n let parent = path.parentPath;\n while (parent) {\n if (t.isTypeScript(parent.node) && !t.isExpression(parent.node)) {\n return true;\n }\n parent = parent.parentPath;\n }\n return false;\n}\n\nexport default function getForeignBindings(\n path: babel.NodePath,\n mode: 'block' | 'function' | 'expression',\n): Set<string> {\n const identifiers = new Set<string>();\n path.traverse({\n ReferencedIdentifier(p) {\n // Check identifiers that aren't in a TS expression\n if (\n !isInTypescript(p) &&\n (mode === 'expression'\n ? !path.scope.hasGlobal(p.node.name)\n : isForeignBinding(path, p, p.node.name, mode))\n ) {\n identifiers.add(p.node.name);\n }\n },\n });\n\n return identifiers;\n}\n", "import type { NodePath } from '@babel/core';\n\nexport function getDescriptiveName(\n path: NodePath,\n defaultName: string,\n): string {\n let current: NodePath | null = path;\n while (current) {\n switch (current.node.type) {\n case 'FunctionDeclaration':\n case 'FunctionExpression': {\n if (current.node.id) {\n return current.node.id.name;\n }\n break;\n }\n case 'VariableDeclarator': {\n if (current.node.id.type === 'Identifier') {\n return current.node.id.name;\n }\n break;\n }\n case 'ClassPrivateMethod':\n case 'ClassMethod':\n case 'ObjectMethod': {\n switch (current.node.key.type) {\n case 'Identifier':\n return current.node.key.name;\n case 'PrivateName':\n return current.node.key.id.name;\n default:\n break;\n }\n break;\n }\n default:\n break;\n }\n current = current.parentPath;\n }\n return defaultName;\n}\n", "import _generator from '@babel/generator';\n\ntype GeneratorShim = typeof _generator;\n\n// https://github.com/babel/babel/issues/15269\nconst generator: GeneratorShim =\n typeof _generator !== 'function'\n ? (_generator as unknown as { default: GeneratorShim }).default\n : _generator;\n\nexport default generator;\n", "import type * as babel from '@babel/core';\nimport * as t from '@babel/types';\n\nexport function getRootStatementPath(path: babel.NodePath): babel.NodePath {\n let current = path.parentPath;\n while (current) {\n const next = current.parentPath;\n if (next && t.isProgram(next.node)) {\n return current;\n }\n current = next;\n }\n return path;\n}\n", "import * as t from '@babel/types';\nimport * as babel from '@babel/core';\nimport assert from './assert';\nimport { getImportSpecifierName } from './get-import-specifier-name';\nimport { ModuleDefinition } from '../types';\nimport { isPathValid } from './unwrap';\n\nexport function getModuleDefinition(path: babel.NodePath): ModuleDefinition {\n assert(\n isPathValid(path, t.isImportSpecifier) ||\n isPathValid(path, t.isImportDefaultSpecifier) ||\n isPathValid(path, t.isImportNamespaceSpecifier),\n 'invariant',\n );\n const parent =\n path.getStatementParent() as babel.NodePath<t.ImportDeclaration>;\n const source = parent.node.source.value;\n switch (path.node.type) {\n case 'ImportDefaultSpecifier':\n return {\n source,\n kind: 'default',\n local: path.node.local.name,\n };\n case 'ImportNamespaceSpecifier':\n return {\n source,\n kind: 'namespace',\n local: path.node.local.name,\n };\n case 'ImportSpecifier': {\n const imported = getImportSpecifierName(path.node);\n if (imported === 'default') {\n return {\n source,\n kind: 'default',\n local: path.node.local.name,\n imported: '',\n };\n }\n return {\n source,\n kind: 'named',\n local: path.node.local.name,\n imported,\n };\n }\n }\n}\n", "import type * as t from '@babel/types';\n\nexport function getImportSpecifierName(node: t.ImportSpecifier) {\n switch (node.imported.type) {\n case 'Identifier':\n return node.imported.name;\n case 'StringLiteral':\n return node.imported.value;\n }\n}\n", "import type * as babel from '@babel/core';\nimport type * as t from '@babel/types';\n\ntype TypeFilter<V extends t.Node> = (node: t.Node) => node is V;\n\nexport function isPathValid<V extends t.Node>(\n path: unknown,\n key: TypeFilter<V>,\n): path is babel.NodePath<V> {\n return key((path as babel.NodePath).node);\n}\n\nexport type NestedExpression =\n | t.ParenthesizedExpression\n | t.TypeCastExpression\n | t.TSAsExpression\n | t.TSSatisfiesExpression\n | t.TSNonNullExpression\n | t.TSInstantiationExpression\n | t.TSTypeAssertion;\n\nexport function isNestedExpression(node: t.Node): node is NestedExpression {\n switch (node.type) {\n case 'ParenthesizedExpression':\n case 'TypeCastExpression':\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n case 'TSTypeAssertion':\n case 'TSInstantiationExpression':\n return true;\n default:\n return false;\n }\n}\n\ntype TypeCheck<K> = K extends TypeFilter<infer U> ? U : never;\n\nexport function unwrapNode<K extends (value: t.Node) => boolean>(\n node: t.Node,\n key: K,\n): TypeCheck<K> | undefined {\n if (key(node)) {\n return node as TypeCheck<K>;\n }\n if (isNestedExpression(node)) {\n return unwrapNode(node.expression, key);\n }\n return undefined;\n}\n\nexport function unwrapPath<V extends t.Node>(\n path: unknown,\n key: TypeFilter<V>,\n): babel.NodePath<V> | undefined {\n if (isPathValid(path, key)) {\n return path;\n }\n if (isPathValid(path, isNestedExpression)) {\n return unwrapPath(path.get('expression'), key);\n }\n return undefined;\n}\n", "import * as t from '@babel/types';\n\nfunction getIdentifiersFromArrayPattern(node: t.ArrayPattern): string[] {\n const ids: string[] = [];\n for (let i = 0, len = node.elements.length; i < len; i++) {\n const el = node.elements[i];\n if (el) {\n ids.push(...getIdentifiersFromLVal(el));\n }\n }\n return ids;\n}\n\nfunction getIdentifiersFromObjectPattern(node: t.ObjectPattern): string[] {\n const ids: string[] = [];\n for (let i = 0, len = node.properties.length; i < len; i++) {\n const el = node.properties[i];\n if (el) {\n if (el.type === 'RestElement') {\n ids.push(...getIdentifiersFromLVal(el));\n } else if (t.isLVal(el.value)) {\n ids.push(...getIdentifiersFromLVal(el.value));\n }\n }\n }\n return ids;\n}\n\nexport function getIdentifiersFromLVal(node: t.LVal): string[] {\n switch (node.type) {\n case 'Identifier':\n return [node.name];\n case 'ArrayPattern':\n return getIdentifiersFromArrayPattern(node);\n case 'AssignmentPattern':\n return getIdentifiersFromLVal(node.left);\n case 'ObjectPattern':\n return getIdentifiersFromObjectPattern(node);\n case 'RestElement':\n return getIdentifiersFromLVal(node.argument);\n default:\n return [];\n }\n}\n", "import * as t from '@babel/types';\nimport * as babel from '@babel/core';\nimport { DirectiveDefinition, StateContext } from './types';\nimport { splitBlock } from './split';\n\nfunction getValidDirectiveFromString(\n ctx: StateContext,\n string: string,\n): DirectiveDefinition | undefined {\n for (let i = 0, len = ctx.options.directives.length; i < len; i++) {\n const current = ctx.options.directives[i];\n if (current.value === string) {\n return current;\n }\n }\n return undefined;\n}\n\nfunction getDefinitionFromDirectives(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): DirectiveDefinition | undefined {\n for (let i = 0, len = path.node.directives.length; i < len; i++) {\n const statement = path.node.directives[i].value.value;\n const directive = getValidDirectiveFromString(ctx, statement);\n if (directive) {\n return directive;\n }\n }\n return undefined;\n}\n\nfunction getDefinitionFromFauxDirectives(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): DirectiveDefinition | undefined {\n for (let i = 0, len = path.node.body.length; i < len; i++) {\n const statement = path.node.body[i];\n if (\n statement.type === 'ExpressionStatement' &&\n statement.expression.type === 'StringLiteral'\n ) {\n const directive = getValidDirectiveFromString(\n ctx,\n statement.expression.value,\n );\n if (directive) {\n return directive;\n }\n } else {\n break;\n }\n }\n return undefined;\n}\n\nfunction getDirectiveDefinitionFromBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): DirectiveDefinition | undefined {\n const parent = path.getFunctionParent();\n if (parent && !parent.node.async) {\n return undefined;\n }\n return (\n getDefinitionFromDirectives(ctx, path) ||\n getDefinitionFromFauxDirectives(ctx, path)\n );\n}\n\nfunction cleanBlockForDirectives(\n path: babel.NodePath<t.BlockStatement>,\n definition: DirectiveDefinition,\n): void {\n const newDirectives: t.Directive[] = [];\n for (let i = 0, len = path.node.directives.length; i < len; i++) {\n const current = path.node.directives[i];\n if (current.value.value !== definition.value) {\n newDirectives.push(current);\n }\n }\n path.node.directives = newDirectives;\n}\n\nfunction cleanBlockForFauxDirectives(\n path: babel.NodePath<t.BlockStatement>,\n definition: DirectiveDefinition,\n): void {\n const body = path.get('body');\n for (let i = 0, len = body.length; i < len; i++) {\n const statement = body[i];\n if (\n statement.node.type === 'ExpressionStatement' &&\n statement.node.expression.type === 'StringLiteral'\n ) {\n if (statement.node.expression.value === definition.value) {\n statement.remove();\n return;\n }\n }\n }\n}\n\nexport function transformBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): void {\n const definition = getDirectiveDefinitionFromBlock(ctx, path);\n if (!definition) {\n return;\n }\n cleanBlockForDirectives(path, definition);\n cleanBlockForFauxDirectives(path, definition);\n splitBlock(ctx, path, definition);\n}\n", "import type * as babel from '@babel/core';\nimport { StateContext } from './types';\nimport { transformBlock } from './transform-block';\n\ninterface State extends babel.PluginPass {\n opts: StateContext;\n}\n\nexport function plugin(): babel.PluginObj<State> {\n return {\n name: 'directive-splitter',\n visitor: {\n BlockStatement(path, ctx) {\n transformBlock(ctx.opts, path);\n },\n },\n };\n}\n", "/* eslint-disable @typescript-eslint/no-shadow */\n/**\n * Copyright (c) 2019 Jason Dent\n * https://github.com/Jason3S/xxhash\n */\nconst PRIME32_1 = 2654435761;\nconst PRIME32_2 = 2246822519;\nconst PRIME32_3 = 3266489917;\nconst PRIME32_4 = 668265263;\nconst PRIME32_5 = 374761393;\n\nfunction toUtf8(text: string): Uint8Array {\n const bytes: number[] = [];\n for (let i = 0, n = text.length; i < n; ++i) {\n const c = text.charCodeAt(i);\n if (c < 0x80) {\n bytes.push(c);\n } else if (c < 0x800) {\n bytes.push(0xc0 | (c >> 6), 0x80 | (c & 0x3f));\n } else if (c < 0xd800 || c >= 0xe000) {\n bytes.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 0x3f), 0x80 | (c & 0x3f));\n } else {\n const cp =\n 0x10000 + (((c & 0x3ff) << 10) | (text.charCodeAt(++i) & 0x3ff));\n bytes.push(\n 0xf0 | ((cp >> 18) & 0x7),\n 0x80 | ((cp >> 12) & 0x3f),\n 0x80 | ((cp >> 6) & 0x3f),\n 0x80 | (cp & 0x3f),\n );\n }\n }\n return new Uint8Array(bytes);\n}\n/**\n *\n * @param buffer - byte array or string\n * @param seed - optional seed (32-bit unsigned);\n */\nexport default function xxHash32(\n buffer: Uint8Array | string,\n seed = 0,\n): number {\n buffer = typeof buffer === 'string' ? toUtf8(buffer) : buffer;\n const b = buffer;\n\n /*\n Step 1. Initialize internal accumulators\n Each accumulator gets an initial value based on optional seed input.\n Since the seed is optional, it can be 0.\n ```\n u32 acc1 = seed + PRIME32_1 + PRIME32_2;\n u32 acc2 = seed + PRIME32_2;\n u32 acc3 = seed + 0;\n u32 acc4 = seed - PRIME32_1;\n ```\n Special case : input is less than 16 bytes\n When input is too small (< 16 bytes), the algorithm will not process any stripe.\n Consequently, it will not make use of parallel accumulators.\n In which case, a simplified initialization is performed, using a single accumulator :\n u32 acc = seed + PRIME32_5;\n The algorithm then proceeds directly to step 4.\n */\n\n let acc = (seed + PRIME32_5) & 0xffffffff;\n let offset = 0;\n\n if (b.length >= 16) {\n const accN = [\n (seed + PRIME32_1 + PRIME32_2) & 0xffffffff,\n (seed + PRIME32_2) & 0xffffffff,\n (seed + 0) & 0xffffffff,\n (seed - PRIME32_1) & 0xffffffff,\n ];\n\n /*\n Step 2. Process stripes\n A stripe is a contiguous segment of 16 bytes. It is evenly divided into 4 lanes,\n of 4 bytes each. The first lane is used to update accumulator 1, the second lane\n is used to update accumulator 2, and so on. Each lane read its associated 32-bit\n value using little-endian convention. For each {lane, accumulator}, the update\n process is called a round, and applies the following formula :\n ```\n accN = accN + (laneN * PRIME32_2);\n accN = accN <<< 13;\n accN = accN * PRIME32_1;\n ```\n This shuffles the bits so that any bit from input lane impacts several bits in\n output accumulator. All operations are performed modulo 2^32.\n Input is consumed one full stripe at a time. Step 2 is looped as many times as\n necessary to consume the whole input, except the last remaining bytes which cannot\n form a stripe (< 16 bytes). When that happens, move to step 3.\n */\n\n const b = buffer;\n const limit = b.length - 16;\n let lane = 0;\n for (offset = 0; (offset & 0xfffffff0) <= limit; offset += 4) {\n const i = offset;\n const laneN0 = b[i + 0] + (b[i + 1] << 8);\n const laneN1 = b[i + 2] + (b[i + 3] << 8);\n const laneNP = laneN0 * PRIME32_2 + ((laneN1 * PRIME32_2) << 16);\n let acc = (accN[lane] + laneNP) & 0xffffffff;\n acc = (acc << 13) | (acc >>> 19);\n const acc0 = acc & 0xffff;\n const acc1 = acc >>> 16;\n accN[lane] = (acc0 * PRIME32_1 + ((acc1 * PRIME32_1) << 16)) & 0xffffffff;\n lane = (lane + 1) & 0x3;\n }\n\n /*\n Step 3. Accumulator convergence\n All 4 lane accumulators from previous steps are merged to produce a\n single remaining accumulator\n of same width (32-bit). The associated formula is as follows :\n ```\n acc = (acc1 <<< 1) + (acc2 <<< 7) + (acc3 <<< 12) + (acc4 <<< 18);\n ```\n */\n acc =\n (((accN[0] << 1) | (accN[0] >>> 31)) +\n ((accN[1] << 7) | (accN[1] >>> 25)) +\n ((accN[2] << 12) | (accN[2] >>> 20)) +\n ((accN[3] << 18) | (accN[3] >>> 14))) &\n 0xffffffff;\n }\n\n /*\n Step 4. Add input length\n The input total length is presumed known at this stage.\n This step is just about adding the length to\n accumulator, so that it participates to final mixing.\n ```\n acc = acc + (u32)inputLength;\n ```\n */\n acc = (acc + buffer.length) & 0xffffffff;\n\n /*\n Step 5. Consume remaining input\n There may be up to 15 bytes remaining to consume from the input.\n The final stage will digest them according\n to following pseudo-code :\n ```\n while (remainingLength >= 4) {\n lane = read_32bit_little_endian(input_ptr);\n acc = acc + lane * PRIME32_3;\n acc = (acc <<< 17) * PRIME32_4;\n input_ptr += 4; remainingLength -= 4;\n }\n ```\n This process ensures that all input bytes are present in the final mix.\n */\n\n const limit = buffer.length - 4;\n for (; offset <= limit; offset += 4) {\n const i = offset;\n const laneN0 = b[i + 0] + (b[i + 1] << 8);\n const laneN1 = b[i + 2] + (b[i + 3] << 8);\n const laneP = laneN0 * PRIME32_3 + ((laneN1 * PRIME32_3) << 16);\n acc = (acc + laneP) & 0xffffffff;\n acc = (acc << 17) | (acc >>> 15);\n acc =\n ((acc & 0xffff) * PRIME32_4 + (((acc >>> 16) * PRIME32_4) << 16)) &\n 0xffffffff;\n }\n\n /*\n ```\n while (remainingLength >= 1) {\n lane = read_byte(input_ptr);\n acc = acc + lane * PRIME32_5;\n acc = (acc <<< 11) * PRIME32_1;\n input_ptr += 1; remainingLength -= 1;\n }\n ```\n */\n\n for (; offset < b.length; ++offset) {\n const lane = b[offset];\n acc += lane * PRIME32_5;\n acc = (acc << 11) | (acc >>> 21);\n acc =\n ((acc & 0xffff) * PRIME32_1 + (((acc >>> 16) * PRIME32_1) << 16)) &\n 0xffffffff;\n }\n\n /*\n Step 6. Final mix (avalanche)\n The final mix ensures that all input bits have a chance to impact any bit in\n the output digest, resulting in an unbiased distribution. This is also called\n avalanche effect.\n ```\n acc = acc xor (acc >> 15);\n acc = acc * PRIME32_2;\n acc = acc xor (acc >> 13);\n acc = acc * PRIME32_3;\n acc = acc xor (acc >> 16);\n ```\n */\n\n acc ^= acc >>> 15;\n acc =\n (((acc & 0xffff) * PRIME32_2) & 0xffffffff) +\n (((acc >>> 16) * PRIME32_2) << 16);\n acc ^= acc >>> 13;\n acc =\n (((acc & 0xffff) * PRIME32_3) & 0xffffffff) +\n (((acc >>> 16) * PRIME32_3) << 16);\n acc ^= acc >>> 16;\n\n // turn any negatives back into a positive number;\n return acc < 0 ? acc + 4294967296 : acc;\n}\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,kBAAiB;;;ACDF,SAAR,OAAwB,MAAe,OAA6B;AACzE,MAAI,CAAC,MAAM;AACT,UAAM,IAAI,MAAM,KAAK;AAAA,EACvB;AACF;;;ACJA,IAAAA,KAAmB;;;ACCnB,QAAmB;AAEnB,SAAS,iBACP,QACA,SACA,MACA,MACS;AACT,MAAI,QAAQ,MAAM,UAAU,IAAI,GAAG;AACjC,WAAO;AAAA,EACT;AACA,MAAI,WAAW,SAAS;AACtB,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,MAAM,cAAc,IAAI,GAAG;AACrC,QAAI,SAAS,SAAS;AACpB,YAAM,UAAU,QAAQ,MAAM,WAAW,IAAI;AAC7C,aAAO,CAAC,CAAC,WAAW,QAAQ,SAAS;AAAA,IACvC;AACA,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,YAAY;AACtB,WAAO,iBAAiB,QAAQ,QAAQ,YAAY,MAAM,IAAI;AAAA,EAChE;AACA,SAAO;AACT;AAEA,SAAS,eAAeC,OAA+B;AACrD,MAAI,SAASA,MAAK;AAClB,SAAO,QAAQ;AACb,QAAM,eAAa,OAAO,IAAI,KAAK,CAAG,eAAa,OAAO,IAAI,GAAG;AAC/D,aAAO;AAAA,IACT;AACA,aAAS,OAAO;AAAA,EAClB;AACA,SAAO;AACT;AAEe,SAAR,mBACLA,OACA,MACa;AACb,QAAM,cAAc,oBAAI,IAAY;AACpC,EAAAA,MAAK,SAAS;AAAA,IACZ,qBAAqB,GAAG;AAEtB,UACE,CAAC,eAAe,CAAC,MAChB,SAAS,eACN,CAACA,MAAK,MAAM,UAAU,EAAE,KAAK,IAAI,IACjC,iBAAiBA,OAAM,GAA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AAO,CAAC;AAAA,IACjD;AAAA,EACF;AAEA,QAAM,UAA0C,CAAC,KAAK;AAEtD,MAAI,gBAAgB,KAAK,EAAE,GAAG;AAC5B,YAAQ,KAAK,YAAY;AAAA,EAC3B;AAEA,QAAM,SAAS,MAAY,qBAAe,MAAM;AAAA,IAC9C,SAAS,CAAC,CAAC,QAAQ,GAAG,CAAC;AAAA,IACvB,YAAY;AAAA,MACV;AAAA,IACF;AAAA,IACA,UAAU,WAAW;AAAA,IACrB,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,SAAS;AAAA,EACX,CAAC;AAED,SAAO,QAAQ,WAAW;AAE1B,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,KAAK,OAAO;AAAA,IACZ;AAAA,IACA;AAAA,EACF;AACF;",
"sourcesContent": ["import * as babel from '@babel/core';\nimport path from 'path';\nimport type { Options, StateContext } from './types';\nimport assert from './utils/assert';\nimport { plugin } from './plugin';\nimport xxHash32 from './utils/xxhash32';\n\nexport interface Output {\n code: babel.BabelFileResult['code'];\n map: babel.BabelFileResult['map'];\n files: Map<string, string>;\n entries: string[];\n roots: string[];\n}\n\nexport {\n NamedImportDefinition,\n DefaultImportDefinition,\n DirectiveDefinition,\n ImportDefinition,\n Options,\n} from './types';\n\nexport async function compile(\n code: string,\n id: string,\n options: Options,\n): Promise<Output> {\n const parsedPath = path.parse(id);\n\n const entries: string[] = [];\n const roots: string[] = [];\n const files = new Map<string, string>();\n\n const ctx: StateContext = {\n path: parsedPath,\n imports: new Map(),\n virtual: {\n count: 0,\n },\n options,\n bindings: new Map(),\n blocks: {\n hash: xxHash32(id).toString(16),\n count: 0,\n },\n onVirtualFile(current, content, mode) {\n const filePath = path.join(parsedPath.dir, current);\n files.set(path.join(parsedPath.dir, current), content);\n if (mode === 'entry') {\n entries.push(filePath);\n } else if (mode === 'root') {\n roots.push(filePath);\n }\n },\n };\n\n const plugins: babel.ParserOptions['plugins'] = ['jsx'];\n\n if (/\\.[mc]?tsx?$/i.test(id)) {\n plugins.push('typescript');\n }\n\n const result = await babel.transformAsync(code, {\n plugins: [[plugin, ctx]],\n parserOpts: {\n plugins,\n },\n filename: parsedPath.base,\n ast: false,\n sourceFileName: id,\n sourceMaps: true,\n configFile: false,\n babelrc: false,\n });\n\n assert(result, 'invariant');\n\n return {\n code: result.code,\n map: result.map,\n files,\n entries,\n roots,\n };\n}\n", "export default function assert(cond: unknown, error: string): asserts cond {\n if (!cond) {\n throw new Error(error);\n }\n}\n", "import * as t from '@babel/types';\nimport * as babel from '@babel/core';\nimport { DirectiveDefinition, ModuleDefinition, StateContext } from './types';\nimport getForeignBindings from './utils/get-foreign-bindings';\nimport { Binding, BindingKind } from '@babel/traverse';\nimport { getDescriptiveName } from './utils/get-descriptive-name';\nimport generator from './utils/generator-shim';\nimport { getRootStatementPath } from './utils/get-root-statement-path';\nimport { getModuleDefinition } from './utils/get-module-definition';\nimport { isPathValid, unwrapPath } from './utils/unwrap';\nimport { getIdentifiersFromLVal } from './utils/get-identifiers-from-lval';\n\nfunction moduleDefinitionToImportSpecifier(definition: ModuleDefinition) {\n switch (definition.kind) {\n case 'default':\n return t.importDefaultSpecifier(t.identifier(definition.local));\n case 'named':\n return t.importSpecifier(\n t.identifier(definition.local),\n definition.imported\n ? t.identifier(definition.imported)\n : t.identifier(definition.local),\n );\n case 'namespace':\n return t.importNamespaceSpecifier(t.identifier(definition.local));\n }\n}\n\nfunction moduleDefinitionToImportDeclaration(definition: ModuleDefinition) {\n return t.importDeclaration(\n [moduleDefinitionToImportSpecifier(definition)],\n t.stringLiteral(definition.source),\n );\n}\n\nfunction moduleDefinitionsToImportDeclarations(\n definitions: ModuleDefinition[],\n) {\n const declarations: t.ImportDeclaration[] = [];\n for (let i = 0, len = definitions.length; i < len; i++) {\n declarations[i] = moduleDefinitionToImportDeclaration(definitions[i]);\n }\n return declarations;\n}\n\nfunction isMutation(kind: BindingKind): boolean {\n switch (kind) {\n case 'let':\n case 'var':\n case 'param':\n return true;\n case 'const':\n case 'hoisted':\n case 'local':\n case 'module':\n case 'unknown':\n return false;\n }\n}\n\nfunction registerModuleLevelBinding(\n ctx: StateContext,\n modules: ModuleDefinition[],\n binding: string,\n target: Binding,\n): void {\n const current = ctx.bindings.get(binding);\n if (current) {\n modules.push(current);\n } else if (isPathValid(target.path, t.isVariableDeclarator)) {\n const definitions = splitVariableDeclarator(ctx, target.path);\n for (let k = 0, klen = definitions.length; k < klen; k++) {\n modules.push(definitions[k]);\n ctx.bindings.set(definitions[k].local, definitions[k]);\n }\n } else if (isPathValid(target.path, t.isFunctionDeclaration)) {\n const definition = splitFunctionDeclaration(ctx, target.path);\n modules.push(definition);\n ctx.bindings.set(definition.local, definition);\n }\n}\n\nfunction registerBinding(\n ctx: StateContext,\n modules: ModuleDefinition[],\n locals: t.Identifier[],\n mutations: t.Identifier[],\n binding: string,\n target: Binding,\n): void {\n if (target.kind === 'module') {\n modules.push(getModuleDefinition(target.path));\n } else if (target.kind === 'param') {\n locals.push(target.identifier);\n } else {\n const blockParent = target.path.scope.getBlockParent();\n const programParent = target.path.scope.getProgramParent();\n if (blockParent === programParent) {\n registerModuleLevelBinding(ctx, modules, binding, target);\n } else {\n locals.push(target.identifier);\n if (isMutation(target.kind)) {\n mutations.push(target.identifier);\n }\n }\n }\n}\n\ninterface ExtractedBindings {\n modules: ModuleDefinition[];\n locals: t.Identifier[];\n mutations: t.Identifier[];\n}\n\nfunction extractBindings(\n ctx: StateContext,\n path: babel.NodePath,\n bindings: Set<string>,\n): ExtractedBindings {\n const modules: ModuleDefinition[] = [];\n const locals: t.Identifier[] = [];\n const mutations: t.Identifier[] = [];\n for (const binding of bindings) {\n const target = path.scope.getBinding(binding);\n if (target) {\n registerBinding(ctx, modules, locals, mutations, binding, target);\n }\n }\n\n return {\n modules,\n locals,\n mutations,\n };\n}\n\nfunction createVirtualFileName(ctx: StateContext) {\n return `./${ctx.path.base}?directive=${ctx.virtual.count++}${ctx.path.ext}`;\n}\n\nfunction splitFunctionDeclaration(\n ctx: StateContext,\n path: babel.NodePath<t.FunctionDeclaration>,\n): ModuleDefinition {\n const bindings = getForeignBindings(path, 'function');\n const { modules } = extractBindings(ctx, path, bindings);\n const file = createVirtualFileName(ctx);\n const compiled = generator(\n t.program([\n ...moduleDefinitionsToImportDeclarations(modules),\n t.exportDefaultDeclaration(path.node),\n ]),\n );\n ctx.onVirtualFile(file, compiled.code, 'none');\n\n const statement = getRootStatementPath(path);\n\n const identifier = path.node.id || path.scope.generateUidIdentifier('func');\n const definition: ModuleDefinition = {\n kind: 'default',\n local: identifier.name,\n source: file,\n };\n\n statement.insertBefore(moduleDefinitionToImportDeclaration(definition));\n path.remove();\n return definition;\n}\n\nfunction splitVariableDeclarator(\n ctx: StateContext,\n path: babel.NodePath<t.VariableDeclarator>,\n): ModuleDefinition[] {\n const init = unwrapPath(path.get('init'), t.isExpression);\n const modules = init\n ? extractBindings(\n ctx,\n path,\n getForeignBindings(\n path,\n isPathValid(init, t.isArrowFunctionExpression) ||\n isPathValid(init, t.isFunctionExpression)\n ? 'function'\n : 'expression',\n ),\n ).modules\n : [];\n const file = createVirtualFileName(ctx);\n const parent = path.parentPath.node as t.VariableDeclaration;\n const compiled = generator(\n t.program([\n ...moduleDefinitionsToImportDeclarations(modules),\n t.exportNamedDeclaration(t.variableDeclaration(parent.kind, [path.node])),\n ]),\n );\n ctx.onVirtualFile(file, compiled.code, 'none');\n const definitions: ModuleDefinition[] = getIdentifiersFromLVal(\n path.node.id,\n ).map(name => ({\n kind: 'named',\n local: name,\n source: file,\n }));\n // Replace declaration with definition\n const statement = getRootStatementPath(path);\n if (statement) {\n statement.insertBefore(moduleDefinitionsToImportDeclarations(definitions));\n }\n path.remove();\n return definitions;\n}\n\n// These are internal code for the control flow of the server block\n// The goal is to transform these into return statements, and the\n// the return value with the associated control flow code.\n// This allows the replacement statement for the server block to\n// know what to do if it encounters the said statement on the server.\nconst BREAK_KEY = t.numericLiteral(0);\nconst CONTINUE_KEY = t.numericLiteral(1);\nconst RETURN_KEY = t.numericLiteral(2);\n// If the function has no explicit return\nconst NO_HALT_KEY = t.numericLiteral(3);\nconst THROW_KEY = t.numericLiteral(4);\n\nfunction transformHalting(\n path: babel.NodePath<t.BlockStatement>,\n mutations: t.Identifier[],\n): {\n breaks: string[];\n breakCount: number;\n continues: string[];\n continueCount: number;\n hasReturn: boolean;\n hasYield: boolean;\n} {\n const target =\n path.scope.getFunctionParent() || path.scope.getProgramParent();\n\n const breaks: string[] = [];\n let breakCount = 0;\n const continues: string[] = [];\n let continueCount = 0;\n let hasReturn = false;\n let hasYield = false;\n\n const applyMutations = mutations.length\n ? path.scope.generateUidIdentifier('mutate')\n : undefined;\n\n // Transform the control flow statements\n path.traverse({\n BreakStatement(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n const replacement: t.Expression[] = [BREAK_KEY];\n breakCount++;\n if (child.node.label) {\n const targetName = child.node.label.name;\n breaks.push(targetName);\n replacement.push(t.stringLiteral(targetName));\n } else {\n replacement.push(t.nullLiteral());\n }\n if (applyMutations) {\n replacement.push(t.callExpression(applyMutations, []));\n }\n child.replaceWith(t.returnStatement(t.arrayExpression(replacement)));\n child.skip();\n }\n },\n ContinueStatement(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n const replacement: t.Expression[] = [CONTINUE_KEY];\n continueCount++;\n if (child.node.label) {\n const targetName = child.node.label.name;\n continues.push(targetName);\n replacement.push(t.stringLiteral(targetName));\n } else {\n replacement.push(t.nullLiteral());\n }\n if (applyMutations) {\n replacement.push(t.callExpression(applyMutations, []));\n }\n child.replaceWith(t.returnStatement(t.arrayExpression(replacement)));\n child.skip();\n }\n },\n ReturnStatement(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n hasReturn = true;\n const replacement: t.Expression[] = [RETURN_KEY];\n if (child.node.argument) {\n replacement.push(child.node.argument);\n } else {\n replacement.push(t.nullLiteral());\n }\n if (applyMutations) {\n replacement.push(t.callExpression(applyMutations, []));\n }\n child.replaceWith(t.returnStatement(t.arrayExpression(replacement)));\n child.skip();\n }\n },\n YieldExpression(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n hasYield = true;\n }\n },\n });\n\n const error = path.scope.generateUidIdentifier('error');\n\n const throwResult: t.Expression[] = [THROW_KEY, error];\n const haltResult: t.Expression[] = [NO_HALT_KEY];\n\n if (applyMutations) {\n throwResult.push(t.callExpression(applyMutations, []));\n haltResult.push(t.nullLiteral());\n haltResult.push(t.callExpression(applyMutations, []));\n }\n\n const statements: t.Statement[] = [\n t.tryStatement(\n t.blockStatement(path.node.body),\n t.catchClause(\n error,\n t.blockStatement([t.returnStatement(t.arrayExpression(throwResult))]),\n ),\n ),\n t.returnStatement(t.arrayExpression(haltResult)),\n ];\n\n if (applyMutations) {\n statements.unshift(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n applyMutations,\n t.arrowFunctionExpression(\n [],\n t.objectExpression(\n mutations.map(item => t.objectProperty(item, item, false, true)),\n ),\n ),\n ),\n ]),\n );\n }\n\n path.node.body = statements;\n return { breaks, continues, hasReturn, hasYield, breakCount, continueCount };\n}\n\n// This generates a chain of if-statements that checks the\n// received server return (which is transformed from the original block's\n// server statement)\n// Each if-statement matches an specific label, assuming that the original\n// break statement is a labeled break statement.\n// Otherwise, the output code is either a normal break statement or none.\nfunction getBreakCheck(\n returnType: t.Identifier,\n returnResult: t.Identifier,\n breakCount: number,\n breaks: string[],\n check: t.Statement,\n): t.Statement {\n let current: t.Statement | undefined;\n if (breakCount !== breaks.length) {\n current = t.blockStatement([t.breakStatement()]);\n }\n for (let i = 0, len = breaks.length; i < len; i++) {\n const target = breaks[i];\n current = t.blockStatement([\n t.ifStatement(\n t.binaryExpression('===', returnResult, t.stringLiteral(target)),\n t.blockStatement([t.breakStatement(t.identifier(target))]),\n current,\n ),\n ]);\n }\n if (current) {\n return t.ifStatement(\n t.binaryExpression('===', returnType, BREAK_KEY),\n current,\n check,\n );\n }\n return check;\n}\n\n// This generates a chain of if-statements that checks the\n// received server return (which is transformed from the original block's\n// server statement)\n// Each if-statement matches an specific label, assuming that the original\n// continue statement is a labeled continue statement.\n// Otherwise, the output code is either a normal continue statement or none.\nfunction getContinueCheck(\n returnType: t.Identifier,\n returnResult: t.Identifier,\n continueCount: number,\n continues: string[],\n check: t.Statement,\n): t.Statement {\n let current: t.Statement | undefined;\n if (continueCount !== continues.length) {\n current = t.blockStatement([t.continueStatement()]);\n }\n for (let i = 0, len = continues.length; i < len; i++) {\n const target = continues[i];\n current = t.blockStatement([\n t.ifStatement(\n t.binaryExpression('===', returnResult, t.stringLiteral(target)),\n t.blockStatement([t.continueStatement(t.identifier(target))]),\n current,\n ),\n ]);\n }\n if (current) {\n return t.ifStatement(\n t.binaryExpression('===', returnType, CONTINUE_KEY),\n current,\n check,\n );\n }\n return check;\n}\n\nfunction getGeneratorReplacementForServerBlock(\n path: babel.NodePath<t.BlockStatement>,\n registerID: t.Identifier,\n cloneArgs: t.Identifier[],\n): [replacements: t.Statement[], step: t.Identifier] {\n const iterator = path.scope.generateUidIdentifier('iterator');\n const step = path.scope.generateUidIdentifier('step');\n const replacement: t.Statement[] = [\n t.variableDeclaration('let', [\n t.variableDeclarator(step),\n // First, get the iterator by calling the generator\n t.variableDeclarator(\n iterator,\n t.awaitExpression(t.callExpression(registerID, cloneArgs)),\n ),\n ]),\n // Create a while statement, the intent is to\n // repeatedly iterate the generator\n t.whileStatement(\n t.booleanLiteral(true),\n t.blockStatement([\n // Get the next value\n t.expressionStatement(\n t.assignmentExpression(\n '=',\n step,\n t.callExpression(\n t.memberExpression(iterator, t.identifier('next')),\n [],\n ),\n ),\n ),\n // Check if the step is done\n t.ifStatement(\n t.memberExpression(step, t.identifier('done')),\n t.blockStatement([\n // exit the loop\n t.breakStatement(),\n ]),\n // Otherwise, yield the value\n t.blockStatement([\n t.expressionStatement(\n t.yieldExpression(\n t.memberExpression(step, t.identifier('value')),\n ),\n ),\n ]),\n ),\n ]),\n ),\n ];\n return [replacement, step];\n}\n\nfunction replaceBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n directive: DirectiveDefinition,\n bindings: ExtractedBindings,\n): void {\n // Transform all control statements\n const halting = transformHalting(path, bindings.mutations);\n const rootFile = createVirtualFileName(ctx);\n const rootContent = generator(\n t.program([\n ...(ctx.options.mode === 'server'\n ? moduleDefinitionsToImportDeclarations(bindings.modules)\n : []),\n t.exportDefaultDeclaration(\n t.functionExpression(\n undefined,\n bindings.locals,\n t.blockStatement(path.node.body),\n halting.hasYield,\n true,\n ),\n ),\n ]),\n );\n ctx.onVirtualFile(rootFile, rootContent.code, 'root');\n // Create an ID\n let id = `${ctx.blocks.hash}-${ctx.blocks.count++}`;\n if (ctx.options.env !== 'production') {\n id += `-${getDescriptiveName(path, 'anonymous')}`;\n }\n const entryID = path.scope.generateUidIdentifier('entry');\n const entryImports: ModuleDefinition[] = [\n {\n kind: directive.import.kind,\n source: directive.import.source,\n local: entryID.name,\n imported:\n directive.import.kind === 'named' ? directive.import.name : undefined,\n },\n ];\n const args: t.Expression[] = [t.stringLiteral(id)];\n if (ctx.options.mode === 'server') {\n const rootID = path.scope.generateUidIdentifier('root');\n entryImports.push({\n kind: 'default',\n source: rootFile,\n local: rootID.name,\n });\n args.push(rootID);\n }\n // Create the registration call\n const entryFile = createVirtualFileName(ctx);\n const entryContent = generator(\n t.program([\n ...moduleDefinitionsToImportDeclarations(entryImports),\n t.exportDefaultDeclaration(t.callExpression(entryID, args)),\n ]),\n );\n ctx.onVirtualFile(entryFile, entryContent.code, 'entry');\n\n // Move to the replacement for the server block,\n // declare the type and result based from transformHalting\n const returnType = path.scope.generateUidIdentifier('type');\n const returnResult = path.scope.generateUidIdentifier('result');\n const returnMutations = path.scope.generateUidIdentifier('mutations');\n let check: t.Statement = t.ifStatement(\n t.binaryExpression('===', returnType, THROW_KEY),\n t.blockStatement([t.throwStatement(returnResult)]),\n );\n // If the block has a return, we need to make sure that the\n // replacement does too.\n if (halting.hasReturn) {\n check = t.ifStatement(\n t.binaryExpression('===', returnType, RETURN_KEY),\n t.blockStatement([t.returnStatement(returnResult)]),\n check,\n );\n }\n // If the block has a break, we also do it.\n if (halting.breakCount > 0) {\n check = getBreakCheck(\n returnType,\n returnResult,\n halting.breakCount,\n halting.breaks,\n check,\n );\n }\n // If the block has a continue, we also do it.\n if (halting.continueCount > 0) {\n check = getContinueCheck(\n returnType,\n returnResult,\n halting.continueCount,\n halting.continues,\n check,\n );\n }\n\n const blockID = path.scope.generateUidIdentifier('block');\n // If the server block happens to be declared in a generator\n const replacement: t.Statement[] = [\n t.variableDeclaration('const', [\n t.variableDeclarator(\n blockID,\n t.memberExpression(\n t.awaitExpression(t.importExpression(t.stringLiteral(entryFile))),\n t.identifier('default'),\n ),\n ),\n ]),\n ];\n if (halting.hasYield) {\n const [reps, step] = getGeneratorReplacementForServerBlock(\n path,\n blockID,\n bindings.locals,\n );\n for (let i = 0, len = reps.length; i < len; i++) {\n replacement.push(reps[i]);\n }\n replacement.push(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.arrayPattern([returnType, returnResult, returnMutations]),\n t.memberExpression(step, t.identifier('value')),\n ),\n ]),\n );\n } else {\n replacement.push(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.arrayPattern([returnType, returnResult, returnMutations]),\n t.awaitExpression(t.callExpression(blockID, bindings.locals)),\n ),\n ]),\n );\n }\n if (bindings.mutations.length) {\n replacement.push(\n t.expressionStatement(\n t.assignmentExpression(\n '=',\n t.objectPattern(\n bindings.mutations.map(item =>\n t.objectProperty(item, item, false, true),\n ),\n ),\n returnMutations,\n ),\n ),\n );\n }\n if (check) {\n replacement.push(check);\n }\n path.replaceWith(t.blockStatement(replacement));\n}\n\nexport function splitBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n directive: DirectiveDefinition,\n): void {\n replaceBlock(\n ctx,\n path,\n directive,\n extractBindings(ctx, path, getForeignBindings(path, 'block')),\n );\n}\n", "import type * as babel from '@babel/core';\nimport * as t from '@babel/types';\n\nfunction isForeignBinding(\n source: babel.NodePath,\n current: babel.NodePath,\n name: string,\n mode: 'block' | 'function',\n): boolean {\n if (current.scope.hasGlobal(name)) {\n return false;\n }\n if (source === current) {\n return true;\n }\n if (current.scope.hasOwnBinding(name)) {\n if (mode === 'block') {\n const binding = current.scope.getBinding(name);\n return !!binding && binding.kind === 'param';\n }\n return false;\n }\n if (current.parentPath) {\n return isForeignBinding(source, current.parentPath, name, mode);\n }\n return true;\n}\n\nfunction isInTypescript(path: babel.NodePath): boolean {\n let parent = path.parentPath;\n while (parent) {\n if (t.isTypeScript(parent.node) && !t.isExpression(parent.node)) {\n return true;\n }\n parent = parent.parentPath;\n }\n return false;\n}\n\nexport default function getForeignBindings(\n path: babel.NodePath,\n mode: 'block' | 'function' | 'expression',\n): Set<string> {\n const identifiers = new Set<string>();\n path.traverse({\n ReferencedIdentifier(p) {\n // Check identifiers that aren't in a TS expression\n if (\n !isInTypescript(p) &&\n (mode === 'expression'\n ? !path.scope.hasGlobal(p.node.name)\n : isForeignBinding(path, p, p.node.name, mode))\n ) {\n identifiers.add(p.node.name);\n }\n },\n });\n\n return identifiers;\n}\n", "import type { NodePath } from '@babel/core';\n\nexport function getDescriptiveName(\n path: NodePath,\n defaultName: string,\n): string {\n let current: NodePath | null = path;\n while (current) {\n switch (current.node.type) {\n case 'FunctionDeclaration':\n case 'FunctionExpression': {\n if (current.node.id) {\n return current.node.id.name;\n }\n break;\n }\n case 'VariableDeclarator': {\n if (current.node.id.type === 'Identifier') {\n return current.node.id.name;\n }\n break;\n }\n case 'ClassPrivateMethod':\n case 'ClassMethod':\n case 'ObjectMethod': {\n switch (current.node.key.type) {\n case 'Identifier':\n return current.node.key.name;\n case 'PrivateName':\n return current.node.key.id.name;\n default:\n break;\n }\n break;\n }\n default:\n break;\n }\n current = current.parentPath;\n }\n return defaultName;\n}\n", "import _generator from '@babel/generator';\n\ntype GeneratorShim = typeof _generator;\n\n// https://github.com/babel/babel/issues/15269\nconst generator: GeneratorShim =\n typeof _generator !== 'function'\n ? (_generator as unknown as { default: GeneratorShim }).default\n : _generator;\n\nexport default generator;\n", "import type * as babel from '@babel/core';\nimport * as t from '@babel/types';\n\nexport function getRootStatementPath(path: babel.NodePath): babel.NodePath {\n let current = path.parentPath;\n while (current) {\n const next = current.parentPath;\n if (next && t.isProgram(next.node)) {\n return current;\n }\n current = next;\n }\n return path;\n}\n", "import * as t from '@babel/types';\nimport * as babel from '@babel/core';\nimport assert from './assert';\nimport { getImportSpecifierName } from './get-import-specifier-name';\nimport { ModuleDefinition } from '../types';\nimport { isPathValid } from './unwrap';\n\nexport function getModuleDefinition(path: babel.NodePath): ModuleDefinition {\n assert(\n isPathValid(path, t.isImportSpecifier) ||\n isPathValid(path, t.isImportDefaultSpecifier) ||\n isPathValid(path, t.isImportNamespaceSpecifier),\n 'invariant',\n );\n const parent =\n path.getStatementParent() as babel.NodePath<t.ImportDeclaration>;\n const source = parent.node.source.value;\n switch (path.node.type) {\n case 'ImportDefaultSpecifier':\n return {\n source,\n kind: 'default',\n local: path.node.local.name,\n };\n case 'ImportNamespaceSpecifier':\n return {\n source,\n kind: 'namespace',\n local: path.node.local.name,\n };\n case 'ImportSpecifier': {\n const imported = getImportSpecifierName(path.node);\n if (imported === 'default') {\n return {\n source,\n kind: 'default',\n local: path.node.local.name,\n imported: '',\n };\n }\n return {\n source,\n kind: 'named',\n local: path.node.local.name,\n imported,\n };\n }\n }\n}\n", "import type * as t from '@babel/types';\n\nexport function getImportSpecifierName(node: t.ImportSpecifier) {\n switch (node.imported.type) {\n case 'Identifier':\n return node.imported.name;\n case 'StringLiteral':\n return node.imported.value;\n }\n}\n", "import type * as babel from '@babel/core';\nimport type * as t from '@babel/types';\n\ntype TypeFilter<V extends t.Node> = (node: t.Node) => node is V;\n\nexport function isPathValid<V extends t.Node>(\n path: unknown,\n key: TypeFilter<V>,\n): path is babel.NodePath<V> {\n return key((path as babel.NodePath).node);\n}\n\nexport type NestedExpression =\n | t.ParenthesizedExpression\n | t.TypeCastExpression\n | t.TSAsExpression\n | t.TSSatisfiesExpression\n | t.TSNonNullExpression\n | t.TSInstantiationExpression\n | t.TSTypeAssertion;\n\nexport function isNestedExpression(node: t.Node): node is NestedExpression {\n switch (node.type) {\n case 'ParenthesizedExpression':\n case 'TypeCastExpression':\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n case 'TSTypeAssertion':\n case 'TSInstantiationExpression':\n return true;\n default:\n return false;\n }\n}\n\ntype TypeCheck<K> = K extends TypeFilter<infer U> ? U : never;\n\nexport function unwrapNode<K extends (value: t.Node) => boolean>(\n node: t.Node,\n key: K,\n): TypeCheck<K> | undefined {\n if (key(node)) {\n return node as TypeCheck<K>;\n }\n if (isNestedExpression(node)) {\n return unwrapNode(node.expression, key);\n }\n return undefined;\n}\n\nexport function unwrapPath<V extends t.Node>(\n path: unknown,\n key: TypeFilter<V>,\n): babel.NodePath<V> | undefined {\n if (isPathValid(path, key)) {\n return path;\n }\n if (isPathValid(path, isNestedExpression)) {\n return unwrapPath(path.get('expression'), key);\n }\n return undefined;\n}\n", "import * as t from '@babel/types';\n\nfunction getIdentifiersFromArrayPattern(node: t.ArrayPattern): string[] {\n const ids: string[] = [];\n for (let i = 0, len = node.elements.length; i < len; i++) {\n const el = node.elements[i];\n if (el) {\n ids.push(...getIdentifiersFromLVal(el));\n }\n }\n return ids;\n}\n\nfunction getIdentifiersFromObjectPattern(node: t.ObjectPattern): string[] {\n const ids: string[] = [];\n for (let i = 0, len = node.properties.length; i < len; i++) {\n const el = node.properties[i];\n if (el) {\n if (el.type === 'RestElement') {\n ids.push(...getIdentifiersFromLVal(el));\n } else if (t.isLVal(el.value)) {\n ids.push(...getIdentifiersFromLVal(el.value));\n }\n }\n }\n return ids;\n}\n\nexport function getIdentifiersFromLVal(node: t.LVal): string[] {\n switch (node.type) {\n case 'Identifier':\n return [node.name];\n case 'ArrayPattern':\n return getIdentifiersFromArrayPattern(node);\n case 'AssignmentPattern':\n return getIdentifiersFromLVal(node.left);\n case 'ObjectPattern':\n return getIdentifiersFromObjectPattern(node);\n case 'RestElement':\n return getIdentifiersFromLVal(node.argument);\n default:\n return [];\n }\n}\n", "import * as t from '@babel/types';\nimport * as babel from '@babel/core';\nimport { DirectiveDefinition, StateContext } from './types';\nimport { splitBlock } from './split';\n\nfunction getValidDirectiveFromString(\n ctx: StateContext,\n string: string,\n): DirectiveDefinition | undefined {\n for (let i = 0, len = ctx.options.directives.length; i < len; i++) {\n const current = ctx.options.directives[i];\n if (current.value === string) {\n return current;\n }\n }\n return undefined;\n}\n\nfunction getDefinitionFromDirectives(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): DirectiveDefinition | undefined {\n for (let i = 0, len = path.node.directives.length; i < len; i++) {\n const statement = path.node.directives[i].value.value;\n const directive = getValidDirectiveFromString(ctx, statement);\n if (directive) {\n return directive;\n }\n }\n return undefined;\n}\n\nfunction getDefinitionFromFauxDirectives(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): DirectiveDefinition | undefined {\n for (let i = 0, len = path.node.body.length; i < len; i++) {\n const statement = path.node.body[i];\n if (\n statement.type === 'ExpressionStatement' &&\n statement.expression.type === 'StringLiteral'\n ) {\n const directive = getValidDirectiveFromString(\n ctx,\n statement.expression.value,\n );\n if (directive) {\n return directive;\n }\n } else {\n break;\n }\n }\n return undefined;\n}\n\nfunction getDirectiveDefinitionFromBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): DirectiveDefinition | undefined {\n const parent = path.getFunctionParent();\n if (parent && !parent.node.async) {\n return undefined;\n }\n return (\n getDefinitionFromDirectives(ctx, path) ||\n getDefinitionFromFauxDirectives(ctx, path)\n );\n}\n\nfunction cleanBlockForDirectives(\n path: babel.NodePath<t.BlockStatement>,\n definition: DirectiveDefinition,\n): void {\n const newDirectives: t.Directive[] = [];\n for (let i = 0, len = path.node.directives.length; i < len; i++) {\n const current = path.node.directives[i];\n if (current.value.value !== definition.value) {\n newDirectives.push(current);\n }\n }\n path.node.directives = newDirectives;\n}\n\nfunction cleanBlockForFauxDirectives(\n path: babel.NodePath<t.BlockStatement>,\n definition: DirectiveDefinition,\n): void {\n const body = path.get('body');\n for (let i = 0, len = body.length; i < len; i++) {\n const statement = body[i];\n if (\n statement.node.type === 'ExpressionStatement' &&\n statement.node.expression.type === 'StringLiteral'\n ) {\n if (statement.node.expression.value === definition.value) {\n statement.remove();\n return;\n }\n }\n }\n}\n\nexport function transformBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): void {\n const definition = getDirectiveDefinitionFromBlock(ctx, path);\n if (!definition) {\n return;\n }\n cleanBlockForDirectives(path, definition);\n cleanBlockForFauxDirectives(path, definition);\n splitBlock(ctx, path, definition);\n}\n", "import type * as babel from '@babel/core';\nimport { StateContext } from './types';\nimport { transformBlock } from './transform-block';\n\ninterface State extends babel.PluginPass {\n opts: StateContext;\n}\n\nexport function plugin(): babel.PluginObj<State> {\n return {\n name: 'directive-splitter',\n visitor: {\n BlockStatement(path, ctx) {\n transformBlock(ctx.opts, path);\n },\n },\n };\n}\n", "/* eslint-disable @typescript-eslint/no-shadow */\n/**\n * Copyright (c) 2019 Jason Dent\n * https://github.com/Jason3S/xxhash\n */\nconst PRIME32_1 = 2654435761;\nconst PRIME32_2 = 2246822519;\nconst PRIME32_3 = 3266489917;\nconst PRIME32_4 = 668265263;\nconst PRIME32_5 = 374761393;\n\nfunction toUtf8(text: string): Uint8Array {\n const bytes: number[] = [];\n for (let i = 0, n = text.length; i < n; ++i) {\n const c = text.charCodeAt(i);\n if (c < 0x80) {\n bytes.push(c);\n } else if (c < 0x800) {\n bytes.push(0xc0 | (c >> 6), 0x80 | (c & 0x3f));\n } else if (c < 0xd800 || c >= 0xe000) {\n bytes.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 0x3f), 0x80 | (c & 0x3f));\n } else {\n const cp =\n 0x10000 + (((c & 0x3ff) << 10) | (text.charCodeAt(++i) & 0x3ff));\n bytes.push(\n 0xf0 | ((cp >> 18) & 0x7),\n 0x80 | ((cp >> 12) & 0x3f),\n 0x80 | ((cp >> 6) & 0x3f),\n 0x80 | (cp & 0x3f),\n );\n }\n }\n return new Uint8Array(bytes);\n}\n/**\n *\n * @param buffer - byte array or string\n * @param seed - optional seed (32-bit unsigned);\n */\nexport default function xxHash32(\n buffer: Uint8Array | string,\n seed = 0,\n): number {\n buffer = typeof buffer === 'string' ? toUtf8(buffer) : buffer;\n const b = buffer;\n\n /*\n Step 1. Initialize internal accumulators\n Each accumulator gets an initial value based on optional seed input.\n Since the seed is optional, it can be 0.\n ```\n u32 acc1 = seed + PRIME32_1 + PRIME32_2;\n u32 acc2 = seed + PRIME32_2;\n u32 acc3 = seed + 0;\n u32 acc4 = seed - PRIME32_1;\n ```\n Special case : input is less than 16 bytes\n When input is too small (< 16 bytes), the algorithm will not process any stripe.\n Consequently, it will not make use of parallel accumulators.\n In which case, a simplified initialization is performed, using a single accumulator :\n u32 acc = seed + PRIME32_5;\n The algorithm then proceeds directly to step 4.\n */\n\n let acc = (seed + PRIME32_5) & 0xffffffff;\n let offset = 0;\n\n if (b.length >= 16) {\n const accN = [\n (seed + PRIME32_1 + PRIME32_2) & 0xffffffff,\n (seed + PRIME32_2) & 0xffffffff,\n (seed + 0) & 0xffffffff,\n (seed - PRIME32_1) & 0xffffffff,\n ];\n\n /*\n Step 2. Process stripes\n A stripe is a contiguous segment of 16 bytes. It is evenly divided into 4 lanes,\n of 4 bytes each. The first lane is used to update accumulator 1, the second lane\n is used to update accumulator 2, and so on. Each lane read its associated 32-bit\n value using little-endian convention. For each {lane, accumulator}, the update\n process is called a round, and applies the following formula :\n ```\n accN = accN + (laneN * PRIME32_2);\n accN = accN <<< 13;\n accN = accN * PRIME32_1;\n ```\n This shuffles the bits so that any bit from input lane impacts several bits in\n output accumulator. All operations are performed modulo 2^32.\n Input is consumed one full stripe at a time. Step 2 is looped as many times as\n necessary to consume the whole input, except the last remaining bytes which cannot\n form a stripe (< 16 bytes). When that happens, move to step 3.\n */\n\n const b = buffer;\n const limit = b.length - 16;\n let lane = 0;\n for (offset = 0; (offset & 0xfffffff0) <= limit; offset += 4) {\n const i = offset;\n const laneN0 = b[i + 0] + (b[i + 1] << 8);\n const laneN1 = b[i + 2] + (b[i + 3] << 8);\n const laneNP = laneN0 * PRIME32_2 + ((laneN1 * PRIME32_2) << 16);\n let acc = (accN[lane] + laneNP) & 0xffffffff;\n acc = (acc << 13) | (acc >>> 19);\n const acc0 = acc & 0xffff;\n const acc1 = acc >>> 16;\n accN[lane] = (acc0 * PRIME32_1 + ((acc1 * PRIME32_1) << 16)) & 0xffffffff;\n lane = (lane + 1) & 0x3;\n }\n\n /*\n Step 3. Accumulator convergence\n All 4 lane accumulators from previous steps are merged to produce a\n single remaining accumulator\n of same width (32-bit). The associated formula is as follows :\n ```\n acc = (acc1 <<< 1) + (acc2 <<< 7) + (acc3 <<< 12) + (acc4 <<< 18);\n ```\n */\n acc =\n (((accN[0] << 1) | (accN[0] >>> 31)) +\n ((accN[1] << 7) | (accN[1] >>> 25)) +\n ((accN[2] << 12) | (accN[2] >>> 20)) +\n ((accN[3] << 18) | (accN[3] >>> 14))) &\n 0xffffffff;\n }\n\n /*\n Step 4. Add input length\n The input total length is presumed known at this stage.\n This step is just about adding the length to\n accumulator, so that it participates to final mixing.\n ```\n acc = acc + (u32)inputLength;\n ```\n */\n acc = (acc + buffer.length) & 0xffffffff;\n\n /*\n Step 5. Consume remaining input\n There may be up to 15 bytes remaining to consume from the input.\n The final stage will digest them according\n to following pseudo-code :\n ```\n while (remainingLength >= 4) {\n lane = read_32bit_little_endian(input_ptr);\n acc = acc + lane * PRIME32_3;\n acc = (acc <<< 17) * PRIME32_4;\n input_ptr += 4; remainingLength -= 4;\n }\n ```\n This process ensures that all input bytes are present in the final mix.\n */\n\n const limit = buffer.length - 4;\n for (; offset <= limit; offset += 4) {\n const i = offset;\n const laneN0 = b[i + 0] + (b[i + 1] << 8);\n const laneN1 = b[i + 2] + (b[i + 3] << 8);\n const laneP = laneN0 * PRIME32_3 + ((laneN1 * PRIME32_3) << 16);\n acc = (acc + laneP) & 0xffffffff;\n acc = (acc << 17) | (acc >>> 15);\n acc =\n ((acc & 0xffff) * PRIME32_4 + (((acc >>> 16) * PRIME32_4) << 16)) &\n 0xffffffff;\n }\n\n /*\n ```\n while (remainingLength >= 1) {\n lane = read_byte(input_ptr);\n acc = acc + lane * PRIME32_5;\n acc = (acc <<< 11) * PRIME32_1;\n input_ptr += 1; remainingLength -= 1;\n }\n ```\n */\n\n for (; offset < b.length; ++offset) {\n const lane = b[offset];\n acc += lane * PRIME32_5;\n acc = (acc << 11) | (acc >>> 21);\n acc =\n ((acc & 0xffff) * PRIME32_1 + (((acc >>> 16) * PRIME32_1) << 16)) &\n 0xffffffff;\n }\n\n /*\n Step 6. Final mix (avalanche)\n The final mix ensures that all input bits have a chance to impact any bit in\n the output digest, resulting in an unbiased distribution. This is also called\n avalanche effect.\n ```\n acc = acc xor (acc >> 15);\n acc = acc * PRIME32_2;\n acc = acc xor (acc >> 13);\n acc = acc * PRIME32_3;\n acc = acc xor (acc >> 16);\n ```\n */\n\n acc ^= acc >>> 15;\n acc =\n (((acc & 0xffff) * PRIME32_2) & 0xffffffff) +\n (((acc >>> 16) * PRIME32_2) << 16);\n acc ^= acc >>> 13;\n acc =\n (((acc & 0xffff) * PRIME32_3) & 0xffffffff) +\n (((acc >>> 16) * PRIME32_3) << 16);\n acc ^= acc >>> 16;\n\n // turn any negatives back into a positive number;\n return acc < 0 ? acc + 4294967296 : acc;\n}\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,kBAAiB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A,QAAK,KAAK,WAAW,KAAK,OAAO;AAClD,YAAM,IAAI,YAAAA,QAAK,KAAK,WAAW,KAAK,OAAO,GAAG,OAAO;AACrD,UAAI,SAAS,SAAS;AACpB,gBAAQ,KAAK,QAAQ;AAAA,MACvB,WAAW,SAAS,QAAQ;AAC1B,cAAM,KAAK,QAAQ;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AAEA,QAAM,UAA0C,CAAC,KAAK;AAEtD,MAAI,gBAAgB,KAAK,EAAE,GAAG;AAC5B,YAAQ,KAAK,YAAY;AAAA,EAC3B;AAEA,QAAM,SAAS,MAAY,qBAAe,MAAM;AAAA,IAC9C,SAAS,CAAC,CAAC,QAAQ,GAAG,CAAC;AAAA,IACvB,YAAY;AAAA,MACV;AAAA,IACF;AAAA,IACA,UAAU,WAAW;AAAA,IACrB,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,SAAS;AAAA,EACX,CAAC;AAED,SAAO,QAAQ,WAAW;AAE1B,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,KAAK,OAAO;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
"names": ["t", "path", "path", "_generator", "t", "path", "t", "path", "path", "path", "t", "path", "identifier", "path", "path", "b", "limit", "acc", "path"]
}

@@ -1,1 +0,1 @@

"use strict";var ee=Object.create;var v=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var ie=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var oe=(t,n)=>{for(var i in n)v(t,i,{get:n[i],enumerable:!0})},L=(t,n,i,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of ne(n))!re.call(t,o)&&o!==i&&v(t,o,{get:()=>n[o],enumerable:!(r=te(n,o))||r.enumerable});return t};var P=(t,n,i)=>(i=t!=null?ee(ie(t)):{},L(n||!t||!t.__esModule?v(i,"default",{value:t,enumerable:!0}):i,t)),ae=t=>L(v({},"__esModule",{value:!0}),t);var Re={};oe(Re,{compile:()=>Be});module.exports=ae(Re);var X=P(require("@babel/core"),1),B=P(require("path"),1);function k(t,n){if(!t)throw new Error(n)}var e=P(require("@babel/types"),1);var I=P(require("@babel/types"),1);function U(t,n,i,r){if(n.scope.hasGlobal(i))return!1;if(t===n)return!0;if(n.scope.hasOwnBinding(i)){if(r==="block"){let o=n.scope.getBinding(i);return!!o&&o.kind==="param"}return!1}return n.parentPath?U(t,n.parentPath,i,r):!0}function se(t){let n=t.parentPath;for(;n;){if(I.isTypeScript(n.node)&&!I.isExpression(n.node))return!0;n=n.parentPath}return!1}function y(t,n){let i=new Set;return t.traverse({ReferencedIdentifier(r){!se(r)&&(n==="expression"?!t.scope.hasGlobal(r.node.name):U(t,r,r.node.name,n))&&i.add(r.node.name)}}),i}function A(t,n){let i=t;for(;i;){switch(i.node.type){case"FunctionDeclaration":case"FunctionExpression":{if(i.node.id)return i.node.id.name;break}case"VariableDeclarator":{if(i.node.id.type==="Identifier")return i.node.id.name;break}case"ClassPrivateMethod":case"ClassMethod":case"ObjectMethod":{switch(i.node.key.type){case"Identifier":return i.node.key.name;case"PrivateName":return i.node.key.id.name;default:break}break}default:break}i=i.parentPath}return n}var N=P(require("@babel/generator"),1),le=typeof N.default!="function"?N.default.default:N.default,M=le;var O=P(require("@babel/types"),1);function C(t){let n=t.parentPath;for(;n;){let i=n.parentPath;if(i&&O.isProgram(i.node))return n;n=i}return t}var D=P(require("@babel/types"),1);function K(t){switch(t.imported.type){case"Identifier":return t.imported.name;case"StringLiteral":return t.imported.value}}function x(t,n){return n(t.node)}function fe(t){switch(t.type){case"ParenthesizedExpression":case"TypeCastExpression":case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":case"TSInstantiationExpression":return!0;default:return!1}}function w(t,n){if(x(t,n))return t;if(x(t,fe))return w(t.get("expression"),n)}function j(t){k(x(t,D.isImportSpecifier)||x(t,D.isImportDefaultSpecifier)||x(t,D.isImportNamespaceSpecifier),"invariant");let i=t.getStatementParent().node.source.value;switch(t.node.type){case"ImportDefaultSpecifier":return{source:i,kind:"default",local:t.node.local.name};case"ImportNamespaceSpecifier":return{source:i,kind:"namespace",local:t.node.local.name};case"ImportSpecifier":{let r=K(t.node);return r==="default"?{source:i,kind:"default",local:t.node.local.name,imported:""}:{source:i,kind:"named",local:t.node.local.name,imported:r}}}}var Y=P(require("@babel/types"),1);function ce(t){let n=[];for(let i=0,r=t.elements.length;i<r;i++){let o=t.elements[i];o&&n.push(...h(o))}return n}function ue(t){let n=[];for(let i=0,r=t.properties.length;i<r;i++){let o=t.properties[i];o&&(o.type==="RestElement"?n.push(...h(o)):Y.isLVal(o.value)&&n.push(...h(o.value)))}return n}function h(t){switch(t.type){case"Identifier":return[t.name];case"ArrayPattern":return ce(t);case"AssignmentPattern":return h(t.left);case"ObjectPattern":return ue(t);case"RestElement":return h(t.argument);default:return[]}}function pe(t){switch(t.kind){case"default":return e.importDefaultSpecifier(e.identifier(t.local));case"named":return e.importSpecifier(e.identifier(t.local),t.imported?e.identifier(t.imported):e.identifier(t.local));case"namespace":return e.importNamespaceSpecifier(e.identifier(t.local))}}function _(t){return e.importDeclaration([pe(t)],e.stringLiteral(t.source))}function F(t){let n=[];for(let i=0,r=t.length;i<r;i++)n[i]=_(t[i]);return n}function me(t){switch(t){case"let":case"var":case"param":return!0;case"const":case"hoisted":case"local":case"module":case"unknown":return!1}}function de(t,n,i,r){let o=t.bindings.get(i);if(o)n.push(o);else if(x(r.path,e.isVariableDeclarator)){let a=xe(t,r.path);for(let s=0,f=a.length;s<f;s++)n.push(a[s]),t.bindings.set(a[s].local,a[s])}else if(x(r.path,e.isFunctionDeclaration)){let a=ge(t,r.path);n.push(a),t.bindings.set(a.local,a)}}function be(t,n,i,r,o,a){if(a.kind==="module")n.push(j(a.path));else if(a.kind==="param")i.push(a.identifier);else{let s=a.path.scope.getBlockParent(),f=a.path.scope.getProgramParent();s===f?de(t,n,o,a):(i.push(a.identifier),me(a.kind)&&r.push(a.identifier))}}function T(t,n,i){let r=[],o=[],a=[];for(let s of i){let f=n.scope.getBinding(s);f&&be(t,r,o,a,s,f)}return{modules:r,locals:o,mutations:a}}function ge(t,n){let i=y(n,"function"),{modules:r}=T(t,n,i),o=t.options.getVirtualFileName(t.path,t.virtual.count++),a=M(e.program([...F(r),e.exportDefaultDeclaration(n.node)]));t.onVirtualFile(o,a.code);let s=C(n),u={kind:"default",local:(n.node.id||n.scope.generateUidIdentifier("func")).name,source:o};return s.insertBefore(_(u)),n.remove(),u}function xe(t,n){let i=w(n.get("init"),e.isExpression),r=i?T(t,n,y(n,x(i,e.isArrowFunctionExpression)||x(i,e.isFunctionExpression)?"function":"expression")).modules:[],o=t.options.getVirtualFileName(t.path,t.virtual.count++),a=n.parentPath.node,s=M(e.program([...F(r),e.exportNamedDeclaration(e.variableDeclaration(a.kind,[n.node]))]));t.onVirtualFile(o,s.code);let f=h(n.node.id).map(c=>({kind:"named",local:c,source:o})),u=C(n);return u&&u.insertBefore(F(f)),n.remove(),f}var G=e.numericLiteral(0),H=e.numericLiteral(1),W=e.numericLiteral(2),Se=e.numericLiteral(3),$=e.numericLiteral(4);function Pe(t,n){let i=t.scope.getFunctionParent()||t.scope.getProgramParent(),r=[],o=0,a=[],s=0,f=!1,u=!1,c=n.length?t.scope.generateUidIdentifier("mutate"):void 0;t.traverse({BreakStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){let p=[G];if(o++,l.node.label){let E=l.node.label.name;r.push(E),p.push(e.stringLiteral(E))}else p.push(e.nullLiteral());c&&p.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(p))),l.skip()}},ContinueStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){let p=[H];if(s++,l.node.label){let E=l.node.label.name;a.push(E),p.push(e.stringLiteral(E))}else p.push(e.nullLiteral());c&&p.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(p))),l.skip()}},ReturnStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){f=!0;let p=[W];l.node.argument?p.push(l.node.argument):p.push(e.nullLiteral()),c&&p.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(p))),l.skip()}},YieldExpression(l){(l.scope.getFunctionParent()||l.scope.getProgramParent())===i&&(u=!0)}});let m=t.scope.generateUidIdentifier("error"),g=[$,m],S=[Se];c&&(g.push(e.callExpression(c,[])),S.push(e.nullLiteral()),S.push(e.callExpression(c,[])));let d=[e.tryStatement(e.blockStatement(t.node.body),e.catchClause(m,e.blockStatement([e.returnStatement(e.arrayExpression(g))]))),e.returnStatement(e.arrayExpression(S))];return c&&d.unshift(e.variableDeclaration("const",[e.variableDeclarator(c,e.arrowFunctionExpression([],e.objectExpression(n.map(l=>e.objectProperty(l,l,!1,!0)))))])),t.node.body=d,{breaks:r,continues:a,hasReturn:f,hasYield:u,breakCount:o,continueCount:s}}function Ee(t,n,i,r,o){let a;i!==r.length&&(a=e.blockStatement([e.breakStatement()]));for(let s=0,f=r.length;s<f;s++){let u=r[s];a=e.blockStatement([e.ifStatement(e.binaryExpression("===",n,e.stringLiteral(u)),e.blockStatement([e.breakStatement(e.identifier(u))]),a)])}return a?e.ifStatement(e.binaryExpression("===",t,G),a,o):o}function he(t,n,i,r,o){let a;i!==r.length&&(a=e.blockStatement([e.continueStatement()]));for(let s=0,f=r.length;s<f;s++){let u=r[s];a=e.blockStatement([e.ifStatement(e.binaryExpression("===",n,e.stringLiteral(u)),e.blockStatement([e.continueStatement(e.identifier(u))]),a)])}return a?e.ifStatement(e.binaryExpression("===",t,H),a,o):o}function De(t,n,i){let r=t.scope.generateUidIdentifier("iterator"),o=t.scope.generateUidIdentifier("step");return[[e.variableDeclaration("let",[e.variableDeclarator(o),e.variableDeclarator(r,e.awaitExpression(e.callExpression(n,i)))]),e.whileStatement(e.booleanLiteral(!0),e.blockStatement([e.expressionStatement(e.assignmentExpression("=",o,e.callExpression(e.memberExpression(r,e.identifier("next")),[]))),e.ifStatement(e.memberExpression(o,e.identifier("done")),e.blockStatement([e.breakStatement()]),e.blockStatement([e.expressionStatement(e.yieldExpression(e.memberExpression(o,e.identifier("value"))))]))]))],o]}function ke(t,n,i,r){let o=Pe(n,r.mutations),a=`${t.blocks.hash}-${t.blocks.count++}`;t.options.env!=="production"&&(a+=`-${A(n,"anonymous")}`);let s=[e.stringLiteral(a)];t.options.mode==="server"&&s.push(e.functionExpression(void 0,r.locals,e.blockStatement(n.node.body),o.hasYield,!0));let f=t.options.getVirtualFileName(t.path,t.virtual.count++),u=n.scope.generateUidIdentifier("register"),c=M(e.program([...t.options.mode==="server"?F(r.modules):[],_({kind:i.import.kind,source:i.import.source,local:u.name,imported:i.import.kind==="named"?i.import.name:void 0}),e.exportDefaultDeclaration(e.callExpression(u,s))]));t.onEntryFile(f),t.onVirtualFile(f,c.code);let m=n.scope.generateUidIdentifier("type"),g=n.scope.generateUidIdentifier("result"),S=n.scope.generateUidIdentifier("mutations"),d=e.ifStatement(e.binaryExpression("===",m,$),e.blockStatement([e.throwStatement(g)]));o.hasReturn&&(d=e.ifStatement(e.binaryExpression("===",m,W),e.blockStatement([e.returnStatement(g)]),d)),o.breakCount>0&&(d=Ee(m,g,o.breakCount,o.breaks,d)),o.continueCount>0&&(d=he(m,g,o.continueCount,o.continues,d));let l=n.scope.generateUidIdentifier("block"),b=[e.variableDeclaration("const",[e.variableDeclarator(l,e.memberExpression(e.awaitExpression(e.importExpression(e.stringLiteral(f))),e.identifier("default")))])];if(o.hasYield){let[p,E]=De(n,l,r.locals);for(let R=0,Z=p.length;R<Z;R++)b.push(p[R]);b.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([m,g,S]),e.memberExpression(E,e.identifier("value")))]))}else b.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([m,g,S]),e.awaitExpression(e.callExpression(l,r.locals)))]));r.mutations.length&&b.push(e.expressionStatement(e.assignmentExpression("=",e.objectPattern(r.mutations.map(p=>e.objectProperty(p,p,!1,!0))),S))),d&&b.push(d),n.replaceWith(e.blockStatement(b))}function z(t,n,i){ke(t,n,i,T(t,n,y(n,"block")))}function q(t,n){for(let i=0,r=t.options.directives.length;i<r;i++){let o=t.options.directives[i];if(o.value===n)return o}}function ye(t,n){for(let i=0,r=n.node.directives.length;i<r;i++){let o=n.node.directives[i].value.value,a=q(t,o);if(a)return a}}function ve(t,n){for(let i=0,r=n.node.body.length;i<r;i++){let o=n.node.body[i];if(o.type==="ExpressionStatement"&&o.expression.type==="StringLiteral"){let a=q(t,o.expression.value);if(a)return a}else break}}function Ie(t,n){let i=n.getFunctionParent();if(!(i&&!i.node.async))return ye(t,n)||ve(t,n)}function Ne(t,n){let i=[];for(let r=0,o=t.node.directives.length;r<o;r++){let a=t.node.directives[r];a.value.value!==n.value&&i.push(a)}t.node.directives=i}function Me(t,n){let i=t.get("body");for(let r=0,o=i.length;r<o;r++){let a=i[r];if(a.node.type==="ExpressionStatement"&&a.node.expression.type==="StringLiteral"&&a.node.expression.value===n.value){a.remove();return}}}function J(t,n){let i=Ie(t,n);i&&(Ne(n,i),Me(n,i),z(t,n,i))}function Q(){return{name:"directive-splitter",visitor:{BlockStatement(t,n){J(n.opts,t)}}}}function Fe(t){let n=[];for(let i=0,r=t.length;i<r;++i){let o=t.charCodeAt(i);if(o<128)n.push(o);else if(o<2048)n.push(192|o>>6,128|o&63);else if(o<55296||o>=57344)n.push(224|o>>12,128|o>>6&63,128|o&63);else{let a=65536+((o&1023)<<10|t.charCodeAt(++i)&1023);n.push(240|a>>18&7,128|a>>12&63,128|a>>6&63,128|a&63)}}return new Uint8Array(n)}function V(t,n=0){t=typeof t=="string"?Fe(t):t;let i=t,r=n+374761393&4294967295,o=0;if(i.length>=16){let s=[n+2654435761+2246822519&4294967295,n+2246822519&4294967295,n+0&4294967295,n-2654435761&4294967295],f=t,u=f.length-16,c=0;for(o=0;(o&4294967280)<=u;o+=4){let m=o,g=f[m+0]+(f[m+1]<<8),S=f[m+2]+(f[m+3]<<8),d=g*2246822519+(S*2246822519<<16),l=s[c]+d&4294967295;l=l<<13|l>>>19;let b=l&65535,p=l>>>16;s[c]=b*2654435761+(p*2654435761<<16)&4294967295,c=c+1&3}r=(s[0]<<1|s[0]>>>31)+(s[1]<<7|s[1]>>>25)+(s[2]<<12|s[2]>>>20)+(s[3]<<18|s[3]>>>14)&4294967295}r=r+t.length&4294967295;let a=t.length-4;for(;o<=a;o+=4){let s=o,f=i[s+0]+(i[s+1]<<8),u=i[s+2]+(i[s+3]<<8),c=f*3266489917+(u*3266489917<<16);r=r+c&4294967295,r=r<<17|r>>>15,r=(r&65535)*668265263+((r>>>16)*668265263<<16)&4294967295}for(;o<i.length;++o){let s=i[o];r+=s*374761393,r=r<<11|r>>>21,r=(r&65535)*2654435761+((r>>>16)*2654435761<<16)&4294967295}return r^=r>>>15,r=((r&65535)*2246822519&4294967295)+((r>>>16)*2246822519<<16),r^=r>>>13,r=((r&65535)*3266489917&4294967295)+((r>>>16)*3266489917<<16),r^=r>>>16,r<0?r+4294967296:r}async function Be(t,n,i){let r=B.default.parse(n),o=[],a=new Map,s={path:r,imports:new Map,virtual:{count:0},options:i,bindings:new Map,blocks:{hash:V(n).toString(16),count:0},onVirtualFile(c,m){a.set(B.default.join(r.dir,c),m)},onEntryFile(c){o.push(B.default.join(r.dir,c))}},f=["jsx"];/\.[mc]?tsx?$/i.test(n)&&f.push("typescript");let u=await X.transformAsync(t,{plugins:[[Q,s]],parserOpts:{plugins:f},filename:r.base,ast:!1,sourceFileName:n,sourceMaps:!0,configFile:!1,babelrc:!1});return k(u,"invariant"),{code:u.code,map:u.map,files:a,entries:o}}
"use strict";var re=Object.create;var F=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var se=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var fe=(t,n)=>{for(var i in n)F(t,i,{get:n[i],enumerable:!0})},A=(t,n,i,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of ae(n))!le.call(t,o)&&o!==i&&F(t,o,{get:()=>n[o],enumerable:!(r=oe(n,o))||r.enumerable});return t};var h=(t,n,i)=>(i=t!=null?re(se(t)):{},A(n||!t||!t.__esModule?F(i,"default",{value:t,enumerable:!0}):i,t)),ce=t=>A(F({},"__esModule",{value:!0}),t);var Te={};fe(Te,{compile:()=>_e});module.exports=ce(Te);var te=h(require("@babel/core"),1),w=h(require("path"),1);function I(t,n){if(!t)throw new Error(n)}var e=h(require("@babel/types"),1);var B=h(require("@babel/types"),1);function O(t,n,i,r){if(n.scope.hasGlobal(i))return!1;if(t===n)return!0;if(n.scope.hasOwnBinding(i)){if(r==="block"){let o=n.scope.getBinding(i);return!!o&&o.kind==="param"}return!1}return n.parentPath?O(t,n.parentPath,i,r):!0}function ue(t){let n=t.parentPath;for(;n;){if(B.isTypeScript(n.node)&&!B.isExpression(n.node))return!0;n=n.parentPath}return!1}function v(t,n){let i=new Set;return t.traverse({ReferencedIdentifier(r){!ue(r)&&(n==="expression"?!t.scope.hasGlobal(r.node.name):O(t,r,r.node.name,n))&&i.add(r.node.name)}}),i}function K(t,n){let i=t;for(;i;){switch(i.node.type){case"FunctionDeclaration":case"FunctionExpression":{if(i.node.id)return i.node.id.name;break}case"VariableDeclarator":{if(i.node.id.type==="Identifier")return i.node.id.name;break}case"ClassPrivateMethod":case"ClassMethod":case"ObjectMethod":{switch(i.node.key.type){case"Identifier":return i.node.key.name;case"PrivateName":return i.node.key.id.name;default:break}break}default:break}i=i.parentPath}return n}var C=h(require("@babel/generator"),1),pe=typeof C.default!="function"?C.default.default:C.default,N=pe;var j=h(require("@babel/types"),1);function T(t){let n=t.parentPath;for(;n;){let i=n.parentPath;if(i&&j.isProgram(i.node))return n;n=i}return t}var y=h(require("@babel/types"),1);function Y(t){switch(t.imported.type){case"Identifier":return t.imported.name;case"StringLiteral":return t.imported.value}}function b(t,n){return n(t.node)}function me(t){switch(t.type){case"ParenthesizedExpression":case"TypeCastExpression":case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":case"TSInstantiationExpression":return!0;default:return!1}}function V(t,n){if(b(t,n))return t;if(b(t,me))return V(t.get("expression"),n)}function $(t){I(b(t,y.isImportSpecifier)||b(t,y.isImportDefaultSpecifier)||b(t,y.isImportNamespaceSpecifier),"invariant");let i=t.getStatementParent().node.source.value;switch(t.node.type){case"ImportDefaultSpecifier":return{source:i,kind:"default",local:t.node.local.name};case"ImportNamespaceSpecifier":return{source:i,kind:"namespace",local:t.node.local.name};case"ImportSpecifier":{let r=Y(t.node);return r==="default"?{source:i,kind:"default",local:t.node.local.name,imported:""}:{source:i,kind:"named",local:t.node.local.name,imported:r}}}}var G=h(require("@babel/types"),1);function de(t){let n=[];for(let i=0,r=t.elements.length;i<r;i++){let o=t.elements[i];o&&n.push(...D(o))}return n}function be(t){let n=[];for(let i=0,r=t.properties.length;i<r;i++){let o=t.properties[i];o&&(o.type==="RestElement"?n.push(...D(o)):G.isLVal(o.value)&&n.push(...D(o.value)))}return n}function D(t){switch(t.type){case"Identifier":return[t.name];case"ArrayPattern":return de(t);case"AssignmentPattern":return D(t.left);case"ObjectPattern":return be(t);case"RestElement":return D(t.argument);default:return[]}}function ge(t){switch(t.kind){case"default":return e.importDefaultSpecifier(e.identifier(t.local));case"named":return e.importSpecifier(e.identifier(t.local),t.imported?e.identifier(t.imported):e.identifier(t.local));case"namespace":return e.importNamespaceSpecifier(e.identifier(t.local))}}function H(t){return e.importDeclaration([ge(t)],e.stringLiteral(t.source))}function M(t){let n=[];for(let i=0,r=t.length;i<r;i++)n[i]=H(t[i]);return n}function xe(t){switch(t){case"let":case"var":case"param":return!0;case"const":case"hoisted":case"local":case"module":case"unknown":return!1}}function Se(t,n,i,r){let o=t.bindings.get(i);if(o)n.push(o);else if(b(r.path,e.isVariableDeclarator)){let a=he(t,r.path);for(let s=0,f=a.length;s<f;s++)n.push(a[s]),t.bindings.set(a[s].local,a[s])}else if(b(r.path,e.isFunctionDeclaration)){let a=Ee(t,r.path);n.push(a),t.bindings.set(a.local,a)}}function Pe(t,n,i,r,o,a){if(a.kind==="module")n.push($(a.path));else if(a.kind==="param")i.push(a.identifier);else{let s=a.path.scope.getBlockParent(),f=a.path.scope.getProgramParent();s===f?Se(t,n,o,a):(i.push(a.identifier),xe(a.kind)&&r.push(a.identifier))}}function L(t,n,i){let r=[],o=[],a=[];for(let s of i){let f=n.scope.getBinding(s);f&&Pe(t,r,o,a,s,f)}return{modules:r,locals:o,mutations:a}}function R(t){return`./${t.path.base}?directive=${t.virtual.count++}${t.path.ext}`}function Ee(t,n){let i=v(n,"function"),{modules:r}=L(t,n,i),o=R(t),a=N(e.program([...M(r),e.exportDefaultDeclaration(n.node)]));t.onVirtualFile(o,a.code,"none");let s=T(n),p={kind:"default",local:(n.node.id||n.scope.generateUidIdentifier("func")).name,source:o};return s.insertBefore(H(p)),n.remove(),p}function he(t,n){let i=V(n.get("init"),e.isExpression),r=i?L(t,n,v(n,b(i,e.isArrowFunctionExpression)||b(i,e.isFunctionExpression)?"function":"expression")).modules:[],o=R(t),a=n.parentPath.node,s=N(e.program([...M(r),e.exportNamedDeclaration(e.variableDeclaration(a.kind,[n.node]))]));t.onVirtualFile(o,s.code,"none");let f=D(n.node.id).map(c=>({kind:"named",local:c,source:o})),p=T(n);return p&&p.insertBefore(M(f)),n.remove(),f}var W=e.numericLiteral(0),z=e.numericLiteral(1),q=e.numericLiteral(2),De=e.numericLiteral(3),J=e.numericLiteral(4);function ke(t,n){let i=t.scope.getFunctionParent()||t.scope.getProgramParent(),r=[],o=0,a=[],s=0,f=!1,p=!1,c=n.length?t.scope.generateUidIdentifier("mutate"):void 0;t.traverse({BreakStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){let u=[W];if(o++,l.node.label){let P=l.node.label.name;r.push(P),u.push(e.stringLiteral(P))}else u.push(e.nullLiteral());c&&u.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(u))),l.skip()}},ContinueStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){let u=[z];if(s++,l.node.label){let P=l.node.label.name;a.push(P),u.push(e.stringLiteral(P))}else u.push(e.nullLiteral());c&&u.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(u))),l.skip()}},ReturnStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){f=!0;let u=[q];l.node.argument?u.push(l.node.argument):u.push(e.nullLiteral()),c&&u.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(u))),l.skip()}},YieldExpression(l){(l.scope.getFunctionParent()||l.scope.getProgramParent())===i&&(p=!0)}});let d=t.scope.generateUidIdentifier("error"),x=[J,d],g=[De];c&&(x.push(e.callExpression(c,[])),g.push(e.nullLiteral()),g.push(e.callExpression(c,[])));let m=[e.tryStatement(e.blockStatement(t.node.body),e.catchClause(d,e.blockStatement([e.returnStatement(e.arrayExpression(x))]))),e.returnStatement(e.arrayExpression(g))];return c&&m.unshift(e.variableDeclaration("const",[e.variableDeclarator(c,e.arrowFunctionExpression([],e.objectExpression(n.map(l=>e.objectProperty(l,l,!1,!0)))))])),t.node.body=m,{breaks:r,continues:a,hasReturn:f,hasYield:p,breakCount:o,continueCount:s}}function ye(t,n,i,r,o){let a;i!==r.length&&(a=e.blockStatement([e.breakStatement()]));for(let s=0,f=r.length;s<f;s++){let p=r[s];a=e.blockStatement([e.ifStatement(e.binaryExpression("===",n,e.stringLiteral(p)),e.blockStatement([e.breakStatement(e.identifier(p))]),a)])}return a?e.ifStatement(e.binaryExpression("===",t,W),a,o):o}function Ie(t,n,i,r,o){let a;i!==r.length&&(a=e.blockStatement([e.continueStatement()]));for(let s=0,f=r.length;s<f;s++){let p=r[s];a=e.blockStatement([e.ifStatement(e.binaryExpression("===",n,e.stringLiteral(p)),e.blockStatement([e.continueStatement(e.identifier(p))]),a)])}return a?e.ifStatement(e.binaryExpression("===",t,z),a,o):o}function ve(t,n,i){let r=t.scope.generateUidIdentifier("iterator"),o=t.scope.generateUidIdentifier("step");return[[e.variableDeclaration("let",[e.variableDeclarator(o),e.variableDeclarator(r,e.awaitExpression(e.callExpression(n,i)))]),e.whileStatement(e.booleanLiteral(!0),e.blockStatement([e.expressionStatement(e.assignmentExpression("=",o,e.callExpression(e.memberExpression(r,e.identifier("next")),[]))),e.ifStatement(e.memberExpression(o,e.identifier("done")),e.blockStatement([e.breakStatement()]),e.blockStatement([e.expressionStatement(e.yieldExpression(e.memberExpression(o,e.identifier("value"))))]))]))],o]}function Ne(t,n,i,r){let o=ke(n,r.mutations),a=R(t),s=N(e.program([...t.options.mode==="server"?M(r.modules):[],e.exportDefaultDeclaration(e.functionExpression(void 0,r.locals,e.blockStatement(n.node.body),o.hasYield,!0))]));t.onVirtualFile(a,s.code,"root");let f=`${t.blocks.hash}-${t.blocks.count++}`;t.options.env!=="production"&&(f+=`-${K(n,"anonymous")}`);let p=n.scope.generateUidIdentifier("entry"),c=[{kind:i.import.kind,source:i.import.source,local:p.name,imported:i.import.kind==="named"?i.import.name:void 0}],d=[e.stringLiteral(f)];if(t.options.mode==="server"){let E=n.scope.generateUidIdentifier("root");c.push({kind:"default",source:a,local:E.name}),d.push(E)}let x=R(t),g=N(e.program([...M(c),e.exportDefaultDeclaration(e.callExpression(p,d))]));t.onVirtualFile(x,g.code,"entry");let m=n.scope.generateUidIdentifier("type"),l=n.scope.generateUidIdentifier("result"),S=n.scope.generateUidIdentifier("mutations"),u=e.ifStatement(e.binaryExpression("===",m,J),e.blockStatement([e.throwStatement(l)]));o.hasReturn&&(u=e.ifStatement(e.binaryExpression("===",m,q),e.blockStatement([e.returnStatement(l)]),u)),o.breakCount>0&&(u=ye(m,l,o.breakCount,o.breaks,u)),o.continueCount>0&&(u=Ie(m,l,o.continueCount,o.continues,u));let P=n.scope.generateUidIdentifier("block"),k=[e.variableDeclaration("const",[e.variableDeclarator(P,e.memberExpression(e.awaitExpression(e.importExpression(e.stringLiteral(x))),e.identifier("default")))])];if(o.hasYield){let[E,ne]=ve(n,P,r.locals);for(let _=0,ie=E.length;_<ie;_++)k.push(E[_]);k.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([m,l,S]),e.memberExpression(ne,e.identifier("value")))]))}else k.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([m,l,S]),e.awaitExpression(e.callExpression(P,r.locals)))]));r.mutations.length&&k.push(e.expressionStatement(e.assignmentExpression("=",e.objectPattern(r.mutations.map(E=>e.objectProperty(E,E,!1,!0))),S))),u&&k.push(u),n.replaceWith(e.blockStatement(k))}function Q(t,n,i){Ne(t,n,i,L(t,n,v(n,"block")))}function X(t,n){for(let i=0,r=t.options.directives.length;i<r;i++){let o=t.options.directives[i];if(o.value===n)return o}}function Me(t,n){for(let i=0,r=n.node.directives.length;i<r;i++){let o=n.node.directives[i].value.value,a=X(t,o);if(a)return a}}function Fe(t,n){for(let i=0,r=n.node.body.length;i<r;i++){let o=n.node.body[i];if(o.type==="ExpressionStatement"&&o.expression.type==="StringLiteral"){let a=X(t,o.expression.value);if(a)return a}else break}}function Be(t,n){let i=n.getFunctionParent();if(!(i&&!i.node.async))return Me(t,n)||Fe(t,n)}function Ce(t,n){let i=[];for(let r=0,o=t.node.directives.length;r<o;r++){let a=t.node.directives[r];a.value.value!==n.value&&i.push(a)}t.node.directives=i}function Re(t,n){let i=t.get("body");for(let r=0,o=i.length;r<o;r++){let a=i[r];if(a.node.type==="ExpressionStatement"&&a.node.expression.type==="StringLiteral"&&a.node.expression.value===n.value){a.remove();return}}}function Z(t,n){let i=Be(t,n);i&&(Ce(n,i),Re(n,i),Q(t,n,i))}function ee(){return{name:"directive-splitter",visitor:{BlockStatement(t,n){Z(n.opts,t)}}}}function we(t){let n=[];for(let i=0,r=t.length;i<r;++i){let o=t.charCodeAt(i);if(o<128)n.push(o);else if(o<2048)n.push(192|o>>6,128|o&63);else if(o<55296||o>=57344)n.push(224|o>>12,128|o>>6&63,128|o&63);else{let a=65536+((o&1023)<<10|t.charCodeAt(++i)&1023);n.push(240|a>>18&7,128|a>>12&63,128|a>>6&63,128|a&63)}}return new Uint8Array(n)}function U(t,n=0){t=typeof t=="string"?we(t):t;let i=t,r=n+374761393&4294967295,o=0;if(i.length>=16){let s=[n+2654435761+2246822519&4294967295,n+2246822519&4294967295,n+0&4294967295,n-2654435761&4294967295],f=t,p=f.length-16,c=0;for(o=0;(o&4294967280)<=p;o+=4){let d=o,x=f[d+0]+(f[d+1]<<8),g=f[d+2]+(f[d+3]<<8),m=x*2246822519+(g*2246822519<<16),l=s[c]+m&4294967295;l=l<<13|l>>>19;let S=l&65535,u=l>>>16;s[c]=S*2654435761+(u*2654435761<<16)&4294967295,c=c+1&3}r=(s[0]<<1|s[0]>>>31)+(s[1]<<7|s[1]>>>25)+(s[2]<<12|s[2]>>>20)+(s[3]<<18|s[3]>>>14)&4294967295}r=r+t.length&4294967295;let a=t.length-4;for(;o<=a;o+=4){let s=o,f=i[s+0]+(i[s+1]<<8),p=i[s+2]+(i[s+3]<<8),c=f*3266489917+(p*3266489917<<16);r=r+c&4294967295,r=r<<17|r>>>15,r=(r&65535)*668265263+((r>>>16)*668265263<<16)&4294967295}for(;o<i.length;++o){let s=i[o];r+=s*374761393,r=r<<11|r>>>21,r=(r&65535)*2654435761+((r>>>16)*2654435761<<16)&4294967295}return r^=r>>>15,r=((r&65535)*2246822519&4294967295)+((r>>>16)*2246822519<<16),r^=r>>>13,r=((r&65535)*3266489917&4294967295)+((r>>>16)*3266489917<<16),r^=r>>>16,r<0?r+4294967296:r}async function _e(t,n,i){let r=w.default.parse(n),o=[],a=[],s=new Map,f={path:r,imports:new Map,virtual:{count:0},options:i,bindings:new Map,blocks:{hash:U(n).toString(16),count:0},onVirtualFile(d,x,g){let m=w.default.join(r.dir,d);s.set(w.default.join(r.dir,d),x),g==="entry"?o.push(m):g==="root"&&a.push(m)}},p=["jsx"];/\.[mc]?tsx?$/i.test(n)&&p.push("typescript");let c=await te.transformAsync(t,{plugins:[[ee,f]],parserOpts:{plugins:p},filename:r.base,ast:!1,sourceFileName:n,sourceMaps:!0,configFile:!1,babelrc:!1});return I(c,"invariant"),{code:c.code,map:c.map,files:s,entries:o,roots:a}}

@@ -332,6 +332,9 @@ // src/index.ts

}
function createVirtualFileName(ctx) {
return `./${ctx.path.base}?directive=${ctx.virtual.count++}${ctx.path.ext}`;
}
function splitFunctionDeclaration(ctx, path2) {
const bindings = getForeignBindings(path2, "function");
const { modules } = extractBindings(ctx, path2, bindings);
const file = ctx.options.getVirtualFileName(ctx.path, ctx.virtual.count++);
const file = createVirtualFileName(ctx);
const compiled = generator_shim_default(

@@ -343,3 +346,3 @@ t5.program([

);
ctx.onVirtualFile(file, compiled.code);
ctx.onVirtualFile(file, compiled.code, "none");
const statement = getRootStatementPath(path2);

@@ -366,3 +369,3 @@ const identifier2 = path2.node.id || path2.scope.generateUidIdentifier("func");

).modules : [];
const file = ctx.options.getVirtualFileName(ctx.path, ctx.virtual.count++);
const file = createVirtualFileName(ctx);
const parent = path2.parentPath.node;

@@ -375,3 +378,3 @@ const compiled = generator_shim_default(

);
ctx.onVirtualFile(file, compiled.code);
ctx.onVirtualFile(file, compiled.code, "none");
const definitions = getIdentifiersFromLVal(

@@ -603,2 +606,18 @@ path2.node.id

const halting = transformHalting(path2, bindings.mutations);
const rootFile = createVirtualFileName(ctx);
const rootContent = generator_shim_default(
t5.program([
...ctx.options.mode === "server" ? moduleDefinitionsToImportDeclarations(bindings.modules) : [],
t5.exportDefaultDeclaration(
t5.functionExpression(
void 0,
bindings.locals,
t5.blockStatement(path2.node.body),
halting.hasYield,
true
)
)
])
);
ctx.onVirtualFile(rootFile, rootContent.code, "root");
let id = `${ctx.blocks.hash}-${ctx.blocks.count++}`;

@@ -608,33 +627,29 @@ if (ctx.options.env !== "production") {

}
const entryID = path2.scope.generateUidIdentifier("entry");
const entryImports = [
{
kind: directive.import.kind,
source: directive.import.source,
local: entryID.name,
imported: directive.import.kind === "named" ? directive.import.name : void 0
}
];
const args = [t5.stringLiteral(id)];
if (ctx.options.mode === "server") {
args.push(
t5.functionExpression(
void 0,
bindings.locals,
t5.blockStatement(path2.node.body),
halting.hasYield,
true
)
);
const rootID = path2.scope.generateUidIdentifier("root");
entryImports.push({
kind: "default",
source: rootFile,
local: rootID.name
});
args.push(rootID);
}
const registrationFile = ctx.options.getVirtualFileName(
ctx.path,
ctx.virtual.count++
);
const registerID = path2.scope.generateUidIdentifier("register");
const registrationContent = generator_shim_default(
const entryFile = createVirtualFileName(ctx);
const entryContent = generator_shim_default(
t5.program([
...ctx.options.mode === "server" ? moduleDefinitionsToImportDeclarations(bindings.modules) : [],
moduleDefinitionToImportDeclaration({
kind: directive.import.kind,
source: directive.import.source,
local: registerID.name,
imported: directive.import.kind === "named" ? directive.import.name : void 0
}),
t5.exportDefaultDeclaration(t5.callExpression(registerID, args))
...moduleDefinitionsToImportDeclarations(entryImports),
t5.exportDefaultDeclaration(t5.callExpression(entryID, args))
])
);
ctx.onEntryFile(registrationFile);
ctx.onVirtualFile(registrationFile, registrationContent.code);
ctx.onVirtualFile(entryFile, entryContent.code, "entry");
const returnType = path2.scope.generateUidIdentifier("type");

@@ -678,5 +693,3 @@ const returnResult = path2.scope.generateUidIdentifier("result");

t5.memberExpression(
t5.awaitExpression(
t5.importExpression(t5.stringLiteral(registrationFile))
),
t5.awaitExpression(t5.importExpression(t5.stringLiteral(entryFile))),
t5.identifier("default")

@@ -917,2 +930,3 @@ )

const entries = [];
const roots = [];
const files = /* @__PURE__ */ new Map();

@@ -931,7 +945,10 @@ const ctx = {

},
onVirtualFile(current, content) {
onVirtualFile(current, content, mode) {
const filePath = path.join(parsedPath.dir, current);
files.set(path.join(parsedPath.dir, current), content);
},
onEntryFile(current) {
entries.push(path.join(parsedPath.dir, current));
if (mode === "entry") {
entries.push(filePath);
} else if (mode === "root") {
roots.push(filePath);
}
}

@@ -960,3 +977,4 @@ };

files,
entries
entries,
roots
};

@@ -963,0 +981,0 @@ }

{
"version": 3,
"sources": ["../../../src/index.ts", "../../../src/utils/assert.ts", "../../../src/split.ts", "../../../src/utils/get-foreign-bindings.ts", "../../../src/utils/get-descriptive-name.ts", "../../../src/utils/generator-shim.ts", "../../../src/utils/get-root-statement-path.ts", "../../../src/utils/get-module-definition.ts", "../../../src/utils/get-import-specifier-name.ts", "../../../src/utils/unwrap.ts", "../../../src/utils/get-identifiers-from-lval.ts", "../../../src/transform-block.ts", "../../../src/plugin.ts", "../../../src/utils/xxhash32.ts"],
"sourcesContent": ["import * as babel from '@babel/core';\nimport path from 'path';\nimport type { Options, StateContext } from './types';\nimport assert from './utils/assert';\nimport { plugin } from './plugin';\nimport xxHash32 from './utils/xxhash32';\n\nexport interface Output {\n code: babel.BabelFileResult['code'];\n map: babel.BabelFileResult['map'];\n files: Map<string, string>;\n entries: string[];\n}\n\nexport {\n NamedImportDefinition,\n DefaultImportDefinition,\n DirectiveDefinition,\n ImportDefinition,\n Options,\n} from './types';\n\nexport async function compile(\n code: string,\n id: string,\n options: Options,\n): Promise<Output> {\n const parsedPath = path.parse(id);\n\n const entries: string[] = [];\n const files = new Map<string, string>();\n\n const ctx: StateContext = {\n path: parsedPath,\n imports: new Map(),\n virtual: {\n count: 0,\n },\n options,\n bindings: new Map(),\n blocks: {\n hash: xxHash32(id).toString(16),\n count: 0,\n },\n onVirtualFile(current, content) {\n files.set(path.join(parsedPath.dir, current), content);\n },\n onEntryFile(current) {\n entries.push(path.join(parsedPath.dir, current));\n },\n };\n\n const plugins: babel.ParserOptions['plugins'] = ['jsx'];\n\n if (/\\.[mc]?tsx?$/i.test(id)) {\n plugins.push('typescript');\n }\n\n const result = await babel.transformAsync(code, {\n plugins: [[plugin, ctx]],\n parserOpts: {\n plugins,\n },\n filename: parsedPath.base,\n ast: false,\n sourceFileName: id,\n sourceMaps: true,\n configFile: false,\n babelrc: false,\n });\n\n assert(result, 'invariant');\n\n return {\n code: result.code,\n map: result.map,\n files,\n entries,\n };\n}\n", "export default function assert(cond: unknown, error: string): asserts cond {\n if (!cond) {\n throw new Error(error);\n }\n}\n", "import * as t from '@babel/types';\nimport * as babel from '@babel/core';\nimport { DirectiveDefinition, ModuleDefinition, StateContext } from './types';\nimport getForeignBindings from './utils/get-foreign-bindings';\nimport { Binding, BindingKind } from '@babel/traverse';\nimport { getDescriptiveName } from './utils/get-descriptive-name';\nimport generator from './utils/generator-shim';\nimport { getRootStatementPath } from './utils/get-root-statement-path';\nimport { getModuleDefinition } from './utils/get-module-definition';\nimport { isPathValid, unwrapPath } from './utils/unwrap';\nimport { getIdentifiersFromLVal } from './utils/get-identifiers-from-lval';\n\nfunction moduleDefinitionToImportSpecifier(definition: ModuleDefinition) {\n switch (definition.kind) {\n case 'default':\n return t.importDefaultSpecifier(t.identifier(definition.local));\n case 'named':\n return t.importSpecifier(\n t.identifier(definition.local),\n definition.imported\n ? t.identifier(definition.imported)\n : t.identifier(definition.local),\n );\n case 'namespace':\n return t.importNamespaceSpecifier(t.identifier(definition.local));\n }\n}\n\nfunction moduleDefinitionToImportDeclaration(definition: ModuleDefinition) {\n return t.importDeclaration(\n [moduleDefinitionToImportSpecifier(definition)],\n t.stringLiteral(definition.source),\n );\n}\n\nfunction moduleDefinitionsToImportDeclarations(\n definitions: ModuleDefinition[],\n) {\n const declarations: t.ImportDeclaration[] = [];\n for (let i = 0, len = definitions.length; i < len; i++) {\n declarations[i] = moduleDefinitionToImportDeclaration(definitions[i]);\n }\n return declarations;\n}\n\nfunction isMutation(kind: BindingKind): boolean {\n switch (kind) {\n case 'let':\n case 'var':\n case 'param':\n return true;\n case 'const':\n case 'hoisted':\n case 'local':\n case 'module':\n case 'unknown':\n return false;\n }\n}\n\nfunction registerModuleLevelBinding(\n ctx: StateContext,\n modules: ModuleDefinition[],\n binding: string,\n target: Binding,\n): void {\n const current = ctx.bindings.get(binding);\n if (current) {\n modules.push(current);\n } else if (isPathValid(target.path, t.isVariableDeclarator)) {\n const definitions = splitVariableDeclarator(ctx, target.path);\n for (let k = 0, klen = definitions.length; k < klen; k++) {\n modules.push(definitions[k]);\n ctx.bindings.set(definitions[k].local, definitions[k]);\n }\n } else if (isPathValid(target.path, t.isFunctionDeclaration)) {\n const definition = splitFunctionDeclaration(ctx, target.path);\n modules.push(definition);\n ctx.bindings.set(definition.local, definition);\n }\n}\n\nfunction registerBinding(\n ctx: StateContext,\n modules: ModuleDefinition[],\n locals: t.Identifier[],\n mutations: t.Identifier[],\n binding: string,\n target: Binding,\n): void {\n if (target.kind === 'module') {\n modules.push(getModuleDefinition(target.path));\n } else if (target.kind === 'param') {\n locals.push(target.identifier);\n } else {\n const blockParent = target.path.scope.getBlockParent();\n const programParent = target.path.scope.getProgramParent();\n if (blockParent === programParent) {\n registerModuleLevelBinding(ctx, modules, binding, target);\n } else {\n locals.push(target.identifier);\n if (isMutation(target.kind)) {\n mutations.push(target.identifier);\n }\n }\n }\n}\n\ninterface ExtractedBindings {\n modules: ModuleDefinition[];\n locals: t.Identifier[];\n mutations: t.Identifier[];\n}\n\nfunction extractBindings(\n ctx: StateContext,\n path: babel.NodePath,\n bindings: Set<string>,\n): ExtractedBindings {\n const modules: ModuleDefinition[] = [];\n const locals: t.Identifier[] = [];\n const mutations: t.Identifier[] = [];\n for (const binding of bindings) {\n const target = path.scope.getBinding(binding);\n if (target) {\n registerBinding(ctx, modules, locals, mutations, binding, target);\n }\n }\n\n return {\n modules,\n locals,\n mutations,\n };\n}\n\nfunction splitFunctionDeclaration(\n ctx: StateContext,\n path: babel.NodePath<t.FunctionDeclaration>,\n): ModuleDefinition {\n const bindings = getForeignBindings(path, 'function');\n const { modules } = extractBindings(ctx, path, bindings);\n const file = ctx.options.getVirtualFileName(ctx.path, ctx.virtual.count++);\n const compiled = generator(\n t.program([\n ...moduleDefinitionsToImportDeclarations(modules),\n t.exportDefaultDeclaration(path.node),\n ]),\n );\n ctx.onVirtualFile(file, compiled.code);\n\n const statement = getRootStatementPath(path);\n\n const identifier = path.node.id || path.scope.generateUidIdentifier('func');\n const definition: ModuleDefinition = {\n kind: 'default',\n local: identifier.name,\n source: file,\n };\n\n statement.insertBefore(moduleDefinitionToImportDeclaration(definition));\n path.remove();\n return definition;\n}\n\nfunction splitVariableDeclarator(\n ctx: StateContext,\n path: babel.NodePath<t.VariableDeclarator>,\n): ModuleDefinition[] {\n const init = unwrapPath(path.get('init'), t.isExpression);\n const modules = init\n ? extractBindings(\n ctx,\n path,\n getForeignBindings(\n path,\n isPathValid(init, t.isArrowFunctionExpression) ||\n isPathValid(init, t.isFunctionExpression)\n ? 'function'\n : 'expression',\n ),\n ).modules\n : [];\n const file = ctx.options.getVirtualFileName(ctx.path, ctx.virtual.count++);\n const parent = path.parentPath.node as t.VariableDeclaration;\n const compiled = generator(\n t.program([\n ...moduleDefinitionsToImportDeclarations(modules),\n t.exportNamedDeclaration(t.variableDeclaration(parent.kind, [path.node])),\n ]),\n );\n ctx.onVirtualFile(file, compiled.code);\n const definitions: ModuleDefinition[] = getIdentifiersFromLVal(\n path.node.id,\n ).map(name => ({\n kind: 'named',\n local: name,\n source: file,\n }));\n // Replace declaration with definition\n const statement = getRootStatementPath(path);\n if (statement) {\n statement.insertBefore(moduleDefinitionsToImportDeclarations(definitions));\n }\n path.remove();\n return definitions;\n}\n\n// These are internal code for the control flow of the server block\n// The goal is to transform these into return statements, and the\n// the return value with the associated control flow code.\n// This allows the replacement statement for the server block to\n// know what to do if it encounters the said statement on the server.\nconst BREAK_KEY = t.numericLiteral(0);\nconst CONTINUE_KEY = t.numericLiteral(1);\nconst RETURN_KEY = t.numericLiteral(2);\n// If the function has no explicit return\nconst NO_HALT_KEY = t.numericLiteral(3);\nconst THROW_KEY = t.numericLiteral(4);\n\nfunction transformHalting(\n path: babel.NodePath<t.BlockStatement>,\n mutations: t.Identifier[],\n): {\n breaks: string[];\n breakCount: number;\n continues: string[];\n continueCount: number;\n hasReturn: boolean;\n hasYield: boolean;\n} {\n const target =\n path.scope.getFunctionParent() || path.scope.getProgramParent();\n\n const breaks: string[] = [];\n let breakCount = 0;\n const continues: string[] = [];\n let continueCount = 0;\n let hasReturn = false;\n let hasYield = false;\n\n const applyMutations = mutations.length\n ? path.scope.generateUidIdentifier('mutate')\n : undefined;\n\n // Transform the control flow statements\n path.traverse({\n BreakStatement(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n const replacement: t.Expression[] = [BREAK_KEY];\n breakCount++;\n if (child.node.label) {\n const targetName = child.node.label.name;\n breaks.push(targetName);\n replacement.push(t.stringLiteral(targetName));\n } else {\n replacement.push(t.nullLiteral());\n }\n if (applyMutations) {\n replacement.push(t.callExpression(applyMutations, []));\n }\n child.replaceWith(t.returnStatement(t.arrayExpression(replacement)));\n child.skip();\n }\n },\n ContinueStatement(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n const replacement: t.Expression[] = [CONTINUE_KEY];\n continueCount++;\n if (child.node.label) {\n const targetName = child.node.label.name;\n continues.push(targetName);\n replacement.push(t.stringLiteral(targetName));\n } else {\n replacement.push(t.nullLiteral());\n }\n if (applyMutations) {\n replacement.push(t.callExpression(applyMutations, []));\n }\n child.replaceWith(t.returnStatement(t.arrayExpression(replacement)));\n child.skip();\n }\n },\n ReturnStatement(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n hasReturn = true;\n const replacement: t.Expression[] = [RETURN_KEY];\n if (child.node.argument) {\n replacement.push(child.node.argument);\n } else {\n replacement.push(t.nullLiteral());\n }\n if (applyMutations) {\n replacement.push(t.callExpression(applyMutations, []));\n }\n child.replaceWith(t.returnStatement(t.arrayExpression(replacement)));\n child.skip();\n }\n },\n YieldExpression(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n hasYield = true;\n }\n },\n });\n\n const error = path.scope.generateUidIdentifier('error');\n\n const throwResult: t.Expression[] = [THROW_KEY, error];\n const haltResult: t.Expression[] = [NO_HALT_KEY];\n\n if (applyMutations) {\n throwResult.push(t.callExpression(applyMutations, []));\n haltResult.push(t.nullLiteral());\n haltResult.push(t.callExpression(applyMutations, []));\n }\n\n const statements: t.Statement[] = [\n t.tryStatement(\n t.blockStatement(path.node.body),\n t.catchClause(\n error,\n t.blockStatement([t.returnStatement(t.arrayExpression(throwResult))]),\n ),\n ),\n t.returnStatement(t.arrayExpression(haltResult)),\n ];\n\n if (applyMutations) {\n statements.unshift(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n applyMutations,\n t.arrowFunctionExpression(\n [],\n t.objectExpression(\n mutations.map(item => t.objectProperty(item, item, false, true)),\n ),\n ),\n ),\n ]),\n );\n }\n\n path.node.body = statements;\n return { breaks, continues, hasReturn, hasYield, breakCount, continueCount };\n}\n\n// This generates a chain of if-statements that checks the\n// received server return (which is transformed from the original block's\n// server statement)\n// Each if-statement matches an specific label, assuming that the original\n// break statement is a labeled break statement.\n// Otherwise, the output code is either a normal break statement or none.\nfunction getBreakCheck(\n returnType: t.Identifier,\n returnResult: t.Identifier,\n breakCount: number,\n breaks: string[],\n check: t.Statement,\n): t.Statement {\n let current: t.Statement | undefined;\n if (breakCount !== breaks.length) {\n current = t.blockStatement([t.breakStatement()]);\n }\n for (let i = 0, len = breaks.length; i < len; i++) {\n const target = breaks[i];\n current = t.blockStatement([\n t.ifStatement(\n t.binaryExpression('===', returnResult, t.stringLiteral(target)),\n t.blockStatement([t.breakStatement(t.identifier(target))]),\n current,\n ),\n ]);\n }\n if (current) {\n return t.ifStatement(\n t.binaryExpression('===', returnType, BREAK_KEY),\n current,\n check,\n );\n }\n return check;\n}\n\n// This generates a chain of if-statements that checks the\n// received server return (which is transformed from the original block's\n// server statement)\n// Each if-statement matches an specific label, assuming that the original\n// continue statement is a labeled continue statement.\n// Otherwise, the output code is either a normal continue statement or none.\nfunction getContinueCheck(\n returnType: t.Identifier,\n returnResult: t.Identifier,\n continueCount: number,\n continues: string[],\n check: t.Statement,\n): t.Statement {\n let current: t.Statement | undefined;\n if (continueCount !== continues.length) {\n current = t.blockStatement([t.continueStatement()]);\n }\n for (let i = 0, len = continues.length; i < len; i++) {\n const target = continues[i];\n current = t.blockStatement([\n t.ifStatement(\n t.binaryExpression('===', returnResult, t.stringLiteral(target)),\n t.blockStatement([t.continueStatement(t.identifier(target))]),\n current,\n ),\n ]);\n }\n if (current) {\n return t.ifStatement(\n t.binaryExpression('===', returnType, CONTINUE_KEY),\n current,\n check,\n );\n }\n return check;\n}\n\nfunction getGeneratorReplacementForServerBlock(\n path: babel.NodePath<t.BlockStatement>,\n registerID: t.Identifier,\n cloneArgs: t.Identifier[],\n): [replacements: t.Statement[], step: t.Identifier] {\n const iterator = path.scope.generateUidIdentifier('iterator');\n const step = path.scope.generateUidIdentifier('step');\n const replacement: t.Statement[] = [\n t.variableDeclaration('let', [\n t.variableDeclarator(step),\n // First, get the iterator by calling the generator\n t.variableDeclarator(\n iterator,\n t.awaitExpression(t.callExpression(registerID, cloneArgs)),\n ),\n ]),\n // Create a while statement, the intent is to\n // repeatedly iterate the generator\n t.whileStatement(\n t.booleanLiteral(true),\n t.blockStatement([\n // Get the next value\n t.expressionStatement(\n t.assignmentExpression(\n '=',\n step,\n t.callExpression(\n t.memberExpression(iterator, t.identifier('next')),\n [],\n ),\n ),\n ),\n // Check if the step is done\n t.ifStatement(\n t.memberExpression(step, t.identifier('done')),\n t.blockStatement([\n // exit the loop\n t.breakStatement(),\n ]),\n // Otherwise, yield the value\n t.blockStatement([\n t.expressionStatement(\n t.yieldExpression(\n t.memberExpression(step, t.identifier('value')),\n ),\n ),\n ]),\n ),\n ]),\n ),\n ];\n return [replacement, step];\n}\n\nfunction replaceBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n directive: DirectiveDefinition,\n bindings: ExtractedBindings,\n): void {\n // Transform all control statements\n const halting = transformHalting(path, bindings.mutations);\n // Create an ID\n let id = `${ctx.blocks.hash}-${ctx.blocks.count++}`;\n if (ctx.options.env !== 'production') {\n id += `-${getDescriptiveName(path, 'anonymous')}`;\n }\n const args: t.Expression[] = [t.stringLiteral(id)];\n if (ctx.options.mode === 'server') {\n args.push(\n t.functionExpression(\n undefined,\n bindings.locals,\n t.blockStatement(path.node.body),\n halting.hasYield,\n true,\n ),\n );\n }\n // Create the registration call\n const registrationFile = ctx.options.getVirtualFileName(\n ctx.path,\n ctx.virtual.count++,\n );\n const registerID = path.scope.generateUidIdentifier('register');\n const registrationContent = generator(\n t.program([\n ...(ctx.options.mode === 'server'\n ? moduleDefinitionsToImportDeclarations(bindings.modules)\n : []),\n moduleDefinitionToImportDeclaration({\n kind: directive.import.kind,\n source: directive.import.source,\n local: registerID.name,\n imported:\n directive.import.kind === 'named' ? directive.import.name : undefined,\n }),\n t.exportDefaultDeclaration(t.callExpression(registerID, args)),\n ]),\n );\n ctx.onEntryFile(registrationFile);\n ctx.onVirtualFile(registrationFile, registrationContent.code);\n\n // Move to the replacement for the server block,\n // declare the type and result based from transformHalting\n const returnType = path.scope.generateUidIdentifier('type');\n const returnResult = path.scope.generateUidIdentifier('result');\n const returnMutations = path.scope.generateUidIdentifier('mutations');\n let check: t.Statement = t.ifStatement(\n t.binaryExpression('===', returnType, THROW_KEY),\n t.blockStatement([t.throwStatement(returnResult)]),\n );\n // If the block has a return, we need to make sure that the\n // replacement does too.\n if (halting.hasReturn) {\n check = t.ifStatement(\n t.binaryExpression('===', returnType, RETURN_KEY),\n t.blockStatement([t.returnStatement(returnResult)]),\n check,\n );\n }\n // If the block has a break, we also do it.\n if (halting.breakCount > 0) {\n check = getBreakCheck(\n returnType,\n returnResult,\n halting.breakCount,\n halting.breaks,\n check,\n );\n }\n // If the block has a continue, we also do it.\n if (halting.continueCount > 0) {\n check = getContinueCheck(\n returnType,\n returnResult,\n halting.continueCount,\n halting.continues,\n check,\n );\n }\n\n const blockID = path.scope.generateUidIdentifier('block');\n // If the server block happens to be declared in a generator\n const replacement: t.Statement[] = [\n t.variableDeclaration('const', [\n t.variableDeclarator(\n blockID,\n t.memberExpression(\n t.awaitExpression(\n t.importExpression(t.stringLiteral(registrationFile)),\n ),\n t.identifier('default'),\n ),\n ),\n ]),\n ];\n if (halting.hasYield) {\n const [reps, step] = getGeneratorReplacementForServerBlock(\n path,\n blockID,\n bindings.locals,\n );\n for (let i = 0, len = reps.length; i < len; i++) {\n replacement.push(reps[i]);\n }\n replacement.push(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.arrayPattern([returnType, returnResult, returnMutations]),\n t.memberExpression(step, t.identifier('value')),\n ),\n ]),\n );\n } else {\n replacement.push(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.arrayPattern([returnType, returnResult, returnMutations]),\n t.awaitExpression(t.callExpression(blockID, bindings.locals)),\n ),\n ]),\n );\n }\n if (bindings.mutations.length) {\n replacement.push(\n t.expressionStatement(\n t.assignmentExpression(\n '=',\n t.objectPattern(\n bindings.mutations.map(item =>\n t.objectProperty(item, item, false, true),\n ),\n ),\n returnMutations,\n ),\n ),\n );\n }\n if (check) {\n replacement.push(check);\n }\n path.replaceWith(t.blockStatement(replacement));\n}\n\nexport function splitBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n directive: DirectiveDefinition,\n): void {\n replaceBlock(\n ctx,\n path,\n directive,\n extractBindings(ctx, path, getForeignBindings(path, 'block')),\n );\n}\n", "import type * as babel from '@babel/core';\nimport * as t from '@babel/types';\n\nfunction isForeignBinding(\n source: babel.NodePath,\n current: babel.NodePath,\n name: string,\n mode: 'block' | 'function',\n): boolean {\n if (current.scope.hasGlobal(name)) {\n return false;\n }\n if (source === current) {\n return true;\n }\n if (current.scope.hasOwnBinding(name)) {\n if (mode === 'block') {\n const binding = current.scope.getBinding(name);\n return !!binding && binding.kind === 'param';\n }\n return false;\n }\n if (current.parentPath) {\n return isForeignBinding(source, current.parentPath, name, mode);\n }\n return true;\n}\n\nfunction isInTypescript(path: babel.NodePath): boolean {\n let parent = path.parentPath;\n while (parent) {\n if (t.isTypeScript(parent.node) && !t.isExpression(parent.node)) {\n return true;\n }\n parent = parent.parentPath;\n }\n return false;\n}\n\nexport default function getForeignBindings(\n path: babel.NodePath,\n mode: 'block' | 'function' | 'expression',\n): Set<string> {\n const identifiers = new Set<string>();\n path.traverse({\n ReferencedIdentifier(p) {\n // Check identifiers that aren't in a TS expression\n if (\n !isInTypescript(p) &&\n (mode === 'expression'\n ? !path.scope.hasGlobal(p.node.name)\n : isForeignBinding(path, p, p.node.name, mode))\n ) {\n identifiers.add(p.node.name);\n }\n },\n });\n\n return identifiers;\n}\n", "import type { NodePath } from '@babel/core';\n\nexport function getDescriptiveName(\n path: NodePath,\n defaultName: string,\n): string {\n let current: NodePath | null = path;\n while (current) {\n switch (current.node.type) {\n case 'FunctionDeclaration':\n case 'FunctionExpression': {\n if (current.node.id) {\n return current.node.id.name;\n }\n break;\n }\n case 'VariableDeclarator': {\n if (current.node.id.type === 'Identifier') {\n return current.node.id.name;\n }\n break;\n }\n case 'ClassPrivateMethod':\n case 'ClassMethod':\n case 'ObjectMethod': {\n switch (current.node.key.type) {\n case 'Identifier':\n return current.node.key.name;\n case 'PrivateName':\n return current.node.key.id.name;\n default:\n break;\n }\n break;\n }\n default:\n break;\n }\n current = current.parentPath;\n }\n return defaultName;\n}\n", "import _generator from '@babel/generator';\n\ntype GeneratorShim = typeof _generator;\n\n// https://github.com/babel/babel/issues/15269\nconst generator: GeneratorShim =\n typeof _generator !== 'function'\n ? (_generator as unknown as { default: GeneratorShim }).default\n : _generator;\n\nexport default generator;\n", "import type * as babel from '@babel/core';\nimport * as t from '@babel/types';\n\nexport function getRootStatementPath(path: babel.NodePath): babel.NodePath {\n let current = path.parentPath;\n while (current) {\n const next = current.parentPath;\n if (next && t.isProgram(next.node)) {\n return current;\n }\n current = next;\n }\n return path;\n}\n", "import * as t from '@babel/types';\nimport * as babel from '@babel/core';\nimport assert from './assert';\nimport { getImportSpecifierName } from './get-import-specifier-name';\nimport { ModuleDefinition } from '../types';\nimport { isPathValid } from './unwrap';\n\nexport function getModuleDefinition(path: babel.NodePath): ModuleDefinition {\n assert(\n isPathValid(path, t.isImportSpecifier) ||\n isPathValid(path, t.isImportDefaultSpecifier) ||\n isPathValid(path, t.isImportNamespaceSpecifier),\n 'invariant',\n );\n const parent =\n path.getStatementParent() as babel.NodePath<t.ImportDeclaration>;\n const source = parent.node.source.value;\n switch (path.node.type) {\n case 'ImportDefaultSpecifier':\n return {\n source,\n kind: 'default',\n local: path.node.local.name,\n };\n case 'ImportNamespaceSpecifier':\n return {\n source,\n kind: 'namespace',\n local: path.node.local.name,\n };\n case 'ImportSpecifier': {\n const imported = getImportSpecifierName(path.node);\n if (imported === 'default') {\n return {\n source,\n kind: 'default',\n local: path.node.local.name,\n imported: '',\n };\n }\n return {\n source,\n kind: 'named',\n local: path.node.local.name,\n imported,\n };\n }\n }\n}\n", "import type * as t from '@babel/types';\n\nexport function getImportSpecifierName(node: t.ImportSpecifier) {\n switch (node.imported.type) {\n case 'Identifier':\n return node.imported.name;\n case 'StringLiteral':\n return node.imported.value;\n }\n}\n", "import type * as babel from '@babel/core';\nimport type * as t from '@babel/types';\n\ntype TypeFilter<V extends t.Node> = (node: t.Node) => node is V;\n\nexport function isPathValid<V extends t.Node>(\n path: unknown,\n key: TypeFilter<V>,\n): path is babel.NodePath<V> {\n return key((path as babel.NodePath).node);\n}\n\nexport type NestedExpression =\n | t.ParenthesizedExpression\n | t.TypeCastExpression\n | t.TSAsExpression\n | t.TSSatisfiesExpression\n | t.TSNonNullExpression\n | t.TSInstantiationExpression\n | t.TSTypeAssertion;\n\nexport function isNestedExpression(node: t.Node): node is NestedExpression {\n switch (node.type) {\n case 'ParenthesizedExpression':\n case 'TypeCastExpression':\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n case 'TSTypeAssertion':\n case 'TSInstantiationExpression':\n return true;\n default:\n return false;\n }\n}\n\ntype TypeCheck<K> = K extends TypeFilter<infer U> ? U : never;\n\nexport function unwrapNode<K extends (value: t.Node) => boolean>(\n node: t.Node,\n key: K,\n): TypeCheck<K> | undefined {\n if (key(node)) {\n return node as TypeCheck<K>;\n }\n if (isNestedExpression(node)) {\n return unwrapNode(node.expression, key);\n }\n return undefined;\n}\n\nexport function unwrapPath<V extends t.Node>(\n path: unknown,\n key: TypeFilter<V>,\n): babel.NodePath<V> | undefined {\n if (isPathValid(path, key)) {\n return path;\n }\n if (isPathValid(path, isNestedExpression)) {\n return unwrapPath(path.get('expression'), key);\n }\n return undefined;\n}\n", "import * as t from '@babel/types';\n\nfunction getIdentifiersFromArrayPattern(node: t.ArrayPattern): string[] {\n const ids: string[] = [];\n for (let i = 0, len = node.elements.length; i < len; i++) {\n const el = node.elements[i];\n if (el) {\n ids.push(...getIdentifiersFromLVal(el));\n }\n }\n return ids;\n}\n\nfunction getIdentifiersFromObjectPattern(node: t.ObjectPattern): string[] {\n const ids: string[] = [];\n for (let i = 0, len = node.properties.length; i < len; i++) {\n const el = node.properties[i];\n if (el) {\n if (el.type === 'RestElement') {\n ids.push(...getIdentifiersFromLVal(el));\n } else if (t.isLVal(el.value)) {\n ids.push(...getIdentifiersFromLVal(el.value));\n }\n }\n }\n return ids;\n}\n\nexport function getIdentifiersFromLVal(node: t.LVal): string[] {\n switch (node.type) {\n case 'Identifier':\n return [node.name];\n case 'ArrayPattern':\n return getIdentifiersFromArrayPattern(node);\n case 'AssignmentPattern':\n return getIdentifiersFromLVal(node.left);\n case 'ObjectPattern':\n return getIdentifiersFromObjectPattern(node);\n case 'RestElement':\n return getIdentifiersFromLVal(node.argument);\n default:\n return [];\n }\n}\n", "import * as t from '@babel/types';\nimport * as babel from '@babel/core';\nimport { DirectiveDefinition, StateContext } from './types';\nimport { splitBlock } from './split';\n\nfunction getValidDirectiveFromString(\n ctx: StateContext,\n string: string,\n): DirectiveDefinition | undefined {\n for (let i = 0, len = ctx.options.directives.length; i < len; i++) {\n const current = ctx.options.directives[i];\n if (current.value === string) {\n return current;\n }\n }\n return undefined;\n}\n\nfunction getDefinitionFromDirectives(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): DirectiveDefinition | undefined {\n for (let i = 0, len = path.node.directives.length; i < len; i++) {\n const statement = path.node.directives[i].value.value;\n const directive = getValidDirectiveFromString(ctx, statement);\n if (directive) {\n return directive;\n }\n }\n return undefined;\n}\n\nfunction getDefinitionFromFauxDirectives(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): DirectiveDefinition | undefined {\n for (let i = 0, len = path.node.body.length; i < len; i++) {\n const statement = path.node.body[i];\n if (\n statement.type === 'ExpressionStatement' &&\n statement.expression.type === 'StringLiteral'\n ) {\n const directive = getValidDirectiveFromString(\n ctx,\n statement.expression.value,\n );\n if (directive) {\n return directive;\n }\n } else {\n break;\n }\n }\n return undefined;\n}\n\nfunction getDirectiveDefinitionFromBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): DirectiveDefinition | undefined {\n const parent = path.getFunctionParent();\n if (parent && !parent.node.async) {\n return undefined;\n }\n return (\n getDefinitionFromDirectives(ctx, path) ||\n getDefinitionFromFauxDirectives(ctx, path)\n );\n}\n\nfunction cleanBlockForDirectives(\n path: babel.NodePath<t.BlockStatement>,\n definition: DirectiveDefinition,\n): void {\n const newDirectives: t.Directive[] = [];\n for (let i = 0, len = path.node.directives.length; i < len; i++) {\n const current = path.node.directives[i];\n if (current.value.value !== definition.value) {\n newDirectives.push(current);\n }\n }\n path.node.directives = newDirectives;\n}\n\nfunction cleanBlockForFauxDirectives(\n path: babel.NodePath<t.BlockStatement>,\n definition: DirectiveDefinition,\n): void {\n const body = path.get('body');\n for (let i = 0, len = body.length; i < len; i++) {\n const statement = body[i];\n if (\n statement.node.type === 'ExpressionStatement' &&\n statement.node.expression.type === 'StringLiteral'\n ) {\n if (statement.node.expression.value === definition.value) {\n statement.remove();\n return;\n }\n }\n }\n}\n\nexport function transformBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): void {\n const definition = getDirectiveDefinitionFromBlock(ctx, path);\n if (!definition) {\n return;\n }\n cleanBlockForDirectives(path, definition);\n cleanBlockForFauxDirectives(path, definition);\n splitBlock(ctx, path, definition);\n}\n", "import type * as babel from '@babel/core';\nimport { StateContext } from './types';\nimport { transformBlock } from './transform-block';\n\ninterface State extends babel.PluginPass {\n opts: StateContext;\n}\n\nexport function plugin(): babel.PluginObj<State> {\n return {\n name: 'directive-splitter',\n visitor: {\n BlockStatement(path, ctx) {\n transformBlock(ctx.opts, path);\n },\n },\n };\n}\n", "/* eslint-disable @typescript-eslint/no-shadow */\n/**\n * Copyright (c) 2019 Jason Dent\n * https://github.com/Jason3S/xxhash\n */\nconst PRIME32_1 = 2654435761;\nconst PRIME32_2 = 2246822519;\nconst PRIME32_3 = 3266489917;\nconst PRIME32_4 = 668265263;\nconst PRIME32_5 = 374761393;\n\nfunction toUtf8(text: string): Uint8Array {\n const bytes: number[] = [];\n for (let i = 0, n = text.length; i < n; ++i) {\n const c = text.charCodeAt(i);\n if (c < 0x80) {\n bytes.push(c);\n } else if (c < 0x800) {\n bytes.push(0xc0 | (c >> 6), 0x80 | (c & 0x3f));\n } else if (c < 0xd800 || c >= 0xe000) {\n bytes.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 0x3f), 0x80 | (c & 0x3f));\n } else {\n const cp =\n 0x10000 + (((c & 0x3ff) << 10) | (text.charCodeAt(++i) & 0x3ff));\n bytes.push(\n 0xf0 | ((cp >> 18) & 0x7),\n 0x80 | ((cp >> 12) & 0x3f),\n 0x80 | ((cp >> 6) & 0x3f),\n 0x80 | (cp & 0x3f),\n );\n }\n }\n return new Uint8Array(bytes);\n}\n/**\n *\n * @param buffer - byte array or string\n * @param seed - optional seed (32-bit unsigned);\n */\nexport default function xxHash32(\n buffer: Uint8Array | string,\n seed = 0,\n): number {\n buffer = typeof buffer === 'string' ? toUtf8(buffer) : buffer;\n const b = buffer;\n\n /*\n Step 1. Initialize internal accumulators\n Each accumulator gets an initial value based on optional seed input.\n Since the seed is optional, it can be 0.\n ```\n u32 acc1 = seed + PRIME32_1 + PRIME32_2;\n u32 acc2 = seed + PRIME32_2;\n u32 acc3 = seed + 0;\n u32 acc4 = seed - PRIME32_1;\n ```\n Special case : input is less than 16 bytes\n When input is too small (< 16 bytes), the algorithm will not process any stripe.\n Consequently, it will not make use of parallel accumulators.\n In which case, a simplified initialization is performed, using a single accumulator :\n u32 acc = seed + PRIME32_5;\n The algorithm then proceeds directly to step 4.\n */\n\n let acc = (seed + PRIME32_5) & 0xffffffff;\n let offset = 0;\n\n if (b.length >= 16) {\n const accN = [\n (seed + PRIME32_1 + PRIME32_2) & 0xffffffff,\n (seed + PRIME32_2) & 0xffffffff,\n (seed + 0) & 0xffffffff,\n (seed - PRIME32_1) & 0xffffffff,\n ];\n\n /*\n Step 2. Process stripes\n A stripe is a contiguous segment of 16 bytes. It is evenly divided into 4 lanes,\n of 4 bytes each. The first lane is used to update accumulator 1, the second lane\n is used to update accumulator 2, and so on. Each lane read its associated 32-bit\n value using little-endian convention. For each {lane, accumulator}, the update\n process is called a round, and applies the following formula :\n ```\n accN = accN + (laneN * PRIME32_2);\n accN = accN <<< 13;\n accN = accN * PRIME32_1;\n ```\n This shuffles the bits so that any bit from input lane impacts several bits in\n output accumulator. All operations are performed modulo 2^32.\n Input is consumed one full stripe at a time. Step 2 is looped as many times as\n necessary to consume the whole input, except the last remaining bytes which cannot\n form a stripe (< 16 bytes). When that happens, move to step 3.\n */\n\n const b = buffer;\n const limit = b.length - 16;\n let lane = 0;\n for (offset = 0; (offset & 0xfffffff0) <= limit; offset += 4) {\n const i = offset;\n const laneN0 = b[i + 0] + (b[i + 1] << 8);\n const laneN1 = b[i + 2] + (b[i + 3] << 8);\n const laneNP = laneN0 * PRIME32_2 + ((laneN1 * PRIME32_2) << 16);\n let acc = (accN[lane] + laneNP) & 0xffffffff;\n acc = (acc << 13) | (acc >>> 19);\n const acc0 = acc & 0xffff;\n const acc1 = acc >>> 16;\n accN[lane] = (acc0 * PRIME32_1 + ((acc1 * PRIME32_1) << 16)) & 0xffffffff;\n lane = (lane + 1) & 0x3;\n }\n\n /*\n Step 3. Accumulator convergence\n All 4 lane accumulators from previous steps are merged to produce a\n single remaining accumulator\n of same width (32-bit). The associated formula is as follows :\n ```\n acc = (acc1 <<< 1) + (acc2 <<< 7) + (acc3 <<< 12) + (acc4 <<< 18);\n ```\n */\n acc =\n (((accN[0] << 1) | (accN[0] >>> 31)) +\n ((accN[1] << 7) | (accN[1] >>> 25)) +\n ((accN[2] << 12) | (accN[2] >>> 20)) +\n ((accN[3] << 18) | (accN[3] >>> 14))) &\n 0xffffffff;\n }\n\n /*\n Step 4. Add input length\n The input total length is presumed known at this stage.\n This step is just about adding the length to\n accumulator, so that it participates to final mixing.\n ```\n acc = acc + (u32)inputLength;\n ```\n */\n acc = (acc + buffer.length) & 0xffffffff;\n\n /*\n Step 5. Consume remaining input\n There may be up to 15 bytes remaining to consume from the input.\n The final stage will digest them according\n to following pseudo-code :\n ```\n while (remainingLength >= 4) {\n lane = read_32bit_little_endian(input_ptr);\n acc = acc + lane * PRIME32_3;\n acc = (acc <<< 17) * PRIME32_4;\n input_ptr += 4; remainingLength -= 4;\n }\n ```\n This process ensures that all input bytes are present in the final mix.\n */\n\n const limit = buffer.length - 4;\n for (; offset <= limit; offset += 4) {\n const i = offset;\n const laneN0 = b[i + 0] + (b[i + 1] << 8);\n const laneN1 = b[i + 2] + (b[i + 3] << 8);\n const laneP = laneN0 * PRIME32_3 + ((laneN1 * PRIME32_3) << 16);\n acc = (acc + laneP) & 0xffffffff;\n acc = (acc << 17) | (acc >>> 15);\n acc =\n ((acc & 0xffff) * PRIME32_4 + (((acc >>> 16) * PRIME32_4) << 16)) &\n 0xffffffff;\n }\n\n /*\n ```\n while (remainingLength >= 1) {\n lane = read_byte(input_ptr);\n acc = acc + lane * PRIME32_5;\n acc = (acc <<< 11) * PRIME32_1;\n input_ptr += 1; remainingLength -= 1;\n }\n ```\n */\n\n for (; offset < b.length; ++offset) {\n const lane = b[offset];\n acc += lane * PRIME32_5;\n acc = (acc << 11) | (acc >>> 21);\n acc =\n ((acc & 0xffff) * PRIME32_1 + (((acc >>> 16) * PRIME32_1) << 16)) &\n 0xffffffff;\n }\n\n /*\n Step 6. Final mix (avalanche)\n The final mix ensures that all input bits have a chance to impact any bit in\n the output digest, resulting in an unbiased distribution. This is also called\n avalanche effect.\n ```\n acc = acc xor (acc >> 15);\n acc = acc * PRIME32_2;\n acc = acc xor (acc >> 13);\n acc = acc * PRIME32_3;\n acc = acc xor (acc >> 16);\n ```\n */\n\n acc ^= acc >>> 15;\n acc =\n (((acc & 0xffff) * PRIME32_2) & 0xffffffff) +\n (((acc >>> 16) * PRIME32_2) << 16);\n acc ^= acc >>> 13;\n acc =\n (((acc & 0xffff) * PRIME32_3) & 0xffffffff) +\n (((acc >>> 16) * PRIME32_3) << 16);\n acc ^= acc >>> 16;\n\n // turn any negatives back into a positive number;\n return acc < 0 ? acc + 4294967296 : acc;\n}\n"],
"mappings": ";AAAA,YAAY,WAAW;AACvB,OAAO,UAAU;;;ACDF,SAAR,OAAwB,MAAe,OAA6B;AACzE,MAAI,CAAC,MAAM;AACT,UAAM,IAAI,MAAM,KAAK;AAAA,EACvB;AACF;;;ACJA,YAAYA,QAAO;;;ACCnB,YAAY,OAAO;AAEnB,SAAS,iBACP,QACA,SACA,MACA,MACS;AACT,MAAI,QAAQ,MAAM,UAAU,IAAI,GAAG;AACjC,WAAO;AAAA,EACT;AACA,MAAI,WAAW,SAAS;AACtB,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,MAAM,cAAc,IAAI,GAAG;AACrC,QAAI,SAAS,SAAS;AACpB,YAAM,UAAU,QAAQ,MAAM,WAAW,IAAI;AAC7C,aAAO,CAAC,CAAC,WAAW,QAAQ,SAAS;AAAA,IACvC;AACA,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,YAAY;AACtB,WAAO,iBAAiB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M,QAAQ,oBAAI,IAAoB;AAEtC,QAAM,MAAoB;AAAA,IACxB,MAAM;AAAA,IACN,SAAS,oBAAI,IAAI;AAAA,IACjB,SAAS;AAAA,MACP,OAAO;AAAA,IACT;AAAA,IACA;AAAA,IACA,UAAU,oBAAI,IAAI;AAAA,IAClB,QAAQ;AAAA,MACN,MAAM,SAAS,EAAE,EAAE,SAAS,EAAE;AAAA,MAC9B,OAAO;AAAA,IACT;AAAA,IACA,cAAc,SAAS,SAAS;AAC9B,YAAM,IAAI,KAAK,KAAK,WAAW,KAAK,OAAO,GAAG,OAAO;AAAA,IACvD;AAAA,IACA,YAAY,SAAS;AACnB,cAAQ,KAAK,KAAK,KAAK,WAAW,KAAK,OAAO,CAAC;AAAA,IACjD;AAAA,EACF;AAEA,QAAM,UAA0C,CAAC,KAAK;AAEtD,MAAI,gBAAgB,KAAK,EAAE,GAAG;AAC5B,YAAQ,KAAK,YAAY;AAAA,EAC3B;AAEA,QAAM,SAAS,MAAY,qBAAe,MAAM;AAAA,IAC9C,SAAS,CAAC,CAAC,QAAQ,GAAG,CAAC;AAAA,IACvB,YAAY;AAAA,MACV;AAAA,IACF;AAAA,IACA,UAAU,WAAW;AAAA,IACrB,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,SAAS;AAAA,EACX,CAAC;AAED,SAAO,QAAQ,WAAW;AAE1B,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,KAAK,OAAO;AAAA,IACZ;AAAA,IACA;AAAA,EACF;AACF;",
"sourcesContent": ["import * as babel from '@babel/core';\nimport path from 'path';\nimport type { Options, StateContext } from './types';\nimport assert from './utils/assert';\nimport { plugin } from './plugin';\nimport xxHash32 from './utils/xxhash32';\n\nexport interface Output {\n code: babel.BabelFileResult['code'];\n map: babel.BabelFileResult['map'];\n files: Map<string, string>;\n entries: string[];\n roots: string[];\n}\n\nexport {\n NamedImportDefinition,\n DefaultImportDefinition,\n DirectiveDefinition,\n ImportDefinition,\n Options,\n} from './types';\n\nexport async function compile(\n code: string,\n id: string,\n options: Options,\n): Promise<Output> {\n const parsedPath = path.parse(id);\n\n const entries: string[] = [];\n const roots: string[] = [];\n const files = new Map<string, string>();\n\n const ctx: StateContext = {\n path: parsedPath,\n imports: new Map(),\n virtual: {\n count: 0,\n },\n options,\n bindings: new Map(),\n blocks: {\n hash: xxHash32(id).toString(16),\n count: 0,\n },\n onVirtualFile(current, content, mode) {\n const filePath = path.join(parsedPath.dir, current);\n files.set(path.join(parsedPath.dir, current), content);\n if (mode === 'entry') {\n entries.push(filePath);\n } else if (mode === 'root') {\n roots.push(filePath);\n }\n },\n };\n\n const plugins: babel.ParserOptions['plugins'] = ['jsx'];\n\n if (/\\.[mc]?tsx?$/i.test(id)) {\n plugins.push('typescript');\n }\n\n const result = await babel.transformAsync(code, {\n plugins: [[plugin, ctx]],\n parserOpts: {\n plugins,\n },\n filename: parsedPath.base,\n ast: false,\n sourceFileName: id,\n sourceMaps: true,\n configFile: false,\n babelrc: false,\n });\n\n assert(result, 'invariant');\n\n return {\n code: result.code,\n map: result.map,\n files,\n entries,\n roots,\n };\n}\n", "export default function assert(cond: unknown, error: string): asserts cond {\n if (!cond) {\n throw new Error(error);\n }\n}\n", "import * as t from '@babel/types';\nimport * as babel from '@babel/core';\nimport { DirectiveDefinition, ModuleDefinition, StateContext } from './types';\nimport getForeignBindings from './utils/get-foreign-bindings';\nimport { Binding, BindingKind } from '@babel/traverse';\nimport { getDescriptiveName } from './utils/get-descriptive-name';\nimport generator from './utils/generator-shim';\nimport { getRootStatementPath } from './utils/get-root-statement-path';\nimport { getModuleDefinition } from './utils/get-module-definition';\nimport { isPathValid, unwrapPath } from './utils/unwrap';\nimport { getIdentifiersFromLVal } from './utils/get-identifiers-from-lval';\n\nfunction moduleDefinitionToImportSpecifier(definition: ModuleDefinition) {\n switch (definition.kind) {\n case 'default':\n return t.importDefaultSpecifier(t.identifier(definition.local));\n case 'named':\n return t.importSpecifier(\n t.identifier(definition.local),\n definition.imported\n ? t.identifier(definition.imported)\n : t.identifier(definition.local),\n );\n case 'namespace':\n return t.importNamespaceSpecifier(t.identifier(definition.local));\n }\n}\n\nfunction moduleDefinitionToImportDeclaration(definition: ModuleDefinition) {\n return t.importDeclaration(\n [moduleDefinitionToImportSpecifier(definition)],\n t.stringLiteral(definition.source),\n );\n}\n\nfunction moduleDefinitionsToImportDeclarations(\n definitions: ModuleDefinition[],\n) {\n const declarations: t.ImportDeclaration[] = [];\n for (let i = 0, len = definitions.length; i < len; i++) {\n declarations[i] = moduleDefinitionToImportDeclaration(definitions[i]);\n }\n return declarations;\n}\n\nfunction isMutation(kind: BindingKind): boolean {\n switch (kind) {\n case 'let':\n case 'var':\n case 'param':\n return true;\n case 'const':\n case 'hoisted':\n case 'local':\n case 'module':\n case 'unknown':\n return false;\n }\n}\n\nfunction registerModuleLevelBinding(\n ctx: StateContext,\n modules: ModuleDefinition[],\n binding: string,\n target: Binding,\n): void {\n const current = ctx.bindings.get(binding);\n if (current) {\n modules.push(current);\n } else if (isPathValid(target.path, t.isVariableDeclarator)) {\n const definitions = splitVariableDeclarator(ctx, target.path);\n for (let k = 0, klen = definitions.length; k < klen; k++) {\n modules.push(definitions[k]);\n ctx.bindings.set(definitions[k].local, definitions[k]);\n }\n } else if (isPathValid(target.path, t.isFunctionDeclaration)) {\n const definition = splitFunctionDeclaration(ctx, target.path);\n modules.push(definition);\n ctx.bindings.set(definition.local, definition);\n }\n}\n\nfunction registerBinding(\n ctx: StateContext,\n modules: ModuleDefinition[],\n locals: t.Identifier[],\n mutations: t.Identifier[],\n binding: string,\n target: Binding,\n): void {\n if (target.kind === 'module') {\n modules.push(getModuleDefinition(target.path));\n } else if (target.kind === 'param') {\n locals.push(target.identifier);\n } else {\n const blockParent = target.path.scope.getBlockParent();\n const programParent = target.path.scope.getProgramParent();\n if (blockParent === programParent) {\n registerModuleLevelBinding(ctx, modules, binding, target);\n } else {\n locals.push(target.identifier);\n if (isMutation(target.kind)) {\n mutations.push(target.identifier);\n }\n }\n }\n}\n\ninterface ExtractedBindings {\n modules: ModuleDefinition[];\n locals: t.Identifier[];\n mutations: t.Identifier[];\n}\n\nfunction extractBindings(\n ctx: StateContext,\n path: babel.NodePath,\n bindings: Set<string>,\n): ExtractedBindings {\n const modules: ModuleDefinition[] = [];\n const locals: t.Identifier[] = [];\n const mutations: t.Identifier[] = [];\n for (const binding of bindings) {\n const target = path.scope.getBinding(binding);\n if (target) {\n registerBinding(ctx, modules, locals, mutations, binding, target);\n }\n }\n\n return {\n modules,\n locals,\n mutations,\n };\n}\n\nfunction createVirtualFileName(ctx: StateContext) {\n return `./${ctx.path.base}?directive=${ctx.virtual.count++}${ctx.path.ext}`;\n}\n\nfunction splitFunctionDeclaration(\n ctx: StateContext,\n path: babel.NodePath<t.FunctionDeclaration>,\n): ModuleDefinition {\n const bindings = getForeignBindings(path, 'function');\n const { modules } = extractBindings(ctx, path, bindings);\n const file = createVirtualFileName(ctx);\n const compiled = generator(\n t.program([\n ...moduleDefinitionsToImportDeclarations(modules),\n t.exportDefaultDeclaration(path.node),\n ]),\n );\n ctx.onVirtualFile(file, compiled.code, 'none');\n\n const statement = getRootStatementPath(path);\n\n const identifier = path.node.id || path.scope.generateUidIdentifier('func');\n const definition: ModuleDefinition = {\n kind: 'default',\n local: identifier.name,\n source: file,\n };\n\n statement.insertBefore(moduleDefinitionToImportDeclaration(definition));\n path.remove();\n return definition;\n}\n\nfunction splitVariableDeclarator(\n ctx: StateContext,\n path: babel.NodePath<t.VariableDeclarator>,\n): ModuleDefinition[] {\n const init = unwrapPath(path.get('init'), t.isExpression);\n const modules = init\n ? extractBindings(\n ctx,\n path,\n getForeignBindings(\n path,\n isPathValid(init, t.isArrowFunctionExpression) ||\n isPathValid(init, t.isFunctionExpression)\n ? 'function'\n : 'expression',\n ),\n ).modules\n : [];\n const file = createVirtualFileName(ctx);\n const parent = path.parentPath.node as t.VariableDeclaration;\n const compiled = generator(\n t.program([\n ...moduleDefinitionsToImportDeclarations(modules),\n t.exportNamedDeclaration(t.variableDeclaration(parent.kind, [path.node])),\n ]),\n );\n ctx.onVirtualFile(file, compiled.code, 'none');\n const definitions: ModuleDefinition[] = getIdentifiersFromLVal(\n path.node.id,\n ).map(name => ({\n kind: 'named',\n local: name,\n source: file,\n }));\n // Replace declaration with definition\n const statement = getRootStatementPath(path);\n if (statement) {\n statement.insertBefore(moduleDefinitionsToImportDeclarations(definitions));\n }\n path.remove();\n return definitions;\n}\n\n// These are internal code for the control flow of the server block\n// The goal is to transform these into return statements, and the\n// the return value with the associated control flow code.\n// This allows the replacement statement for the server block to\n// know what to do if it encounters the said statement on the server.\nconst BREAK_KEY = t.numericLiteral(0);\nconst CONTINUE_KEY = t.numericLiteral(1);\nconst RETURN_KEY = t.numericLiteral(2);\n// If the function has no explicit return\nconst NO_HALT_KEY = t.numericLiteral(3);\nconst THROW_KEY = t.numericLiteral(4);\n\nfunction transformHalting(\n path: babel.NodePath<t.BlockStatement>,\n mutations: t.Identifier[],\n): {\n breaks: string[];\n breakCount: number;\n continues: string[];\n continueCount: number;\n hasReturn: boolean;\n hasYield: boolean;\n} {\n const target =\n path.scope.getFunctionParent() || path.scope.getProgramParent();\n\n const breaks: string[] = [];\n let breakCount = 0;\n const continues: string[] = [];\n let continueCount = 0;\n let hasReturn = false;\n let hasYield = false;\n\n const applyMutations = mutations.length\n ? path.scope.generateUidIdentifier('mutate')\n : undefined;\n\n // Transform the control flow statements\n path.traverse({\n BreakStatement(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n const replacement: t.Expression[] = [BREAK_KEY];\n breakCount++;\n if (child.node.label) {\n const targetName = child.node.label.name;\n breaks.push(targetName);\n replacement.push(t.stringLiteral(targetName));\n } else {\n replacement.push(t.nullLiteral());\n }\n if (applyMutations) {\n replacement.push(t.callExpression(applyMutations, []));\n }\n child.replaceWith(t.returnStatement(t.arrayExpression(replacement)));\n child.skip();\n }\n },\n ContinueStatement(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n const replacement: t.Expression[] = [CONTINUE_KEY];\n continueCount++;\n if (child.node.label) {\n const targetName = child.node.label.name;\n continues.push(targetName);\n replacement.push(t.stringLiteral(targetName));\n } else {\n replacement.push(t.nullLiteral());\n }\n if (applyMutations) {\n replacement.push(t.callExpression(applyMutations, []));\n }\n child.replaceWith(t.returnStatement(t.arrayExpression(replacement)));\n child.skip();\n }\n },\n ReturnStatement(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n hasReturn = true;\n const replacement: t.Expression[] = [RETURN_KEY];\n if (child.node.argument) {\n replacement.push(child.node.argument);\n } else {\n replacement.push(t.nullLiteral());\n }\n if (applyMutations) {\n replacement.push(t.callExpression(applyMutations, []));\n }\n child.replaceWith(t.returnStatement(t.arrayExpression(replacement)));\n child.skip();\n }\n },\n YieldExpression(child) {\n const parent =\n child.scope.getFunctionParent() || child.scope.getProgramParent();\n if (parent === target) {\n hasYield = true;\n }\n },\n });\n\n const error = path.scope.generateUidIdentifier('error');\n\n const throwResult: t.Expression[] = [THROW_KEY, error];\n const haltResult: t.Expression[] = [NO_HALT_KEY];\n\n if (applyMutations) {\n throwResult.push(t.callExpression(applyMutations, []));\n haltResult.push(t.nullLiteral());\n haltResult.push(t.callExpression(applyMutations, []));\n }\n\n const statements: t.Statement[] = [\n t.tryStatement(\n t.blockStatement(path.node.body),\n t.catchClause(\n error,\n t.blockStatement([t.returnStatement(t.arrayExpression(throwResult))]),\n ),\n ),\n t.returnStatement(t.arrayExpression(haltResult)),\n ];\n\n if (applyMutations) {\n statements.unshift(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n applyMutations,\n t.arrowFunctionExpression(\n [],\n t.objectExpression(\n mutations.map(item => t.objectProperty(item, item, false, true)),\n ),\n ),\n ),\n ]),\n );\n }\n\n path.node.body = statements;\n return { breaks, continues, hasReturn, hasYield, breakCount, continueCount };\n}\n\n// This generates a chain of if-statements that checks the\n// received server return (which is transformed from the original block's\n// server statement)\n// Each if-statement matches an specific label, assuming that the original\n// break statement is a labeled break statement.\n// Otherwise, the output code is either a normal break statement or none.\nfunction getBreakCheck(\n returnType: t.Identifier,\n returnResult: t.Identifier,\n breakCount: number,\n breaks: string[],\n check: t.Statement,\n): t.Statement {\n let current: t.Statement | undefined;\n if (breakCount !== breaks.length) {\n current = t.blockStatement([t.breakStatement()]);\n }\n for (let i = 0, len = breaks.length; i < len; i++) {\n const target = breaks[i];\n current = t.blockStatement([\n t.ifStatement(\n t.binaryExpression('===', returnResult, t.stringLiteral(target)),\n t.blockStatement([t.breakStatement(t.identifier(target))]),\n current,\n ),\n ]);\n }\n if (current) {\n return t.ifStatement(\n t.binaryExpression('===', returnType, BREAK_KEY),\n current,\n check,\n );\n }\n return check;\n}\n\n// This generates a chain of if-statements that checks the\n// received server return (which is transformed from the original block's\n// server statement)\n// Each if-statement matches an specific label, assuming that the original\n// continue statement is a labeled continue statement.\n// Otherwise, the output code is either a normal continue statement or none.\nfunction getContinueCheck(\n returnType: t.Identifier,\n returnResult: t.Identifier,\n continueCount: number,\n continues: string[],\n check: t.Statement,\n): t.Statement {\n let current: t.Statement | undefined;\n if (continueCount !== continues.length) {\n current = t.blockStatement([t.continueStatement()]);\n }\n for (let i = 0, len = continues.length; i < len; i++) {\n const target = continues[i];\n current = t.blockStatement([\n t.ifStatement(\n t.binaryExpression('===', returnResult, t.stringLiteral(target)),\n t.blockStatement([t.continueStatement(t.identifier(target))]),\n current,\n ),\n ]);\n }\n if (current) {\n return t.ifStatement(\n t.binaryExpression('===', returnType, CONTINUE_KEY),\n current,\n check,\n );\n }\n return check;\n}\n\nfunction getGeneratorReplacementForServerBlock(\n path: babel.NodePath<t.BlockStatement>,\n registerID: t.Identifier,\n cloneArgs: t.Identifier[],\n): [replacements: t.Statement[], step: t.Identifier] {\n const iterator = path.scope.generateUidIdentifier('iterator');\n const step = path.scope.generateUidIdentifier('step');\n const replacement: t.Statement[] = [\n t.variableDeclaration('let', [\n t.variableDeclarator(step),\n // First, get the iterator by calling the generator\n t.variableDeclarator(\n iterator,\n t.awaitExpression(t.callExpression(registerID, cloneArgs)),\n ),\n ]),\n // Create a while statement, the intent is to\n // repeatedly iterate the generator\n t.whileStatement(\n t.booleanLiteral(true),\n t.blockStatement([\n // Get the next value\n t.expressionStatement(\n t.assignmentExpression(\n '=',\n step,\n t.callExpression(\n t.memberExpression(iterator, t.identifier('next')),\n [],\n ),\n ),\n ),\n // Check if the step is done\n t.ifStatement(\n t.memberExpression(step, t.identifier('done')),\n t.blockStatement([\n // exit the loop\n t.breakStatement(),\n ]),\n // Otherwise, yield the value\n t.blockStatement([\n t.expressionStatement(\n t.yieldExpression(\n t.memberExpression(step, t.identifier('value')),\n ),\n ),\n ]),\n ),\n ]),\n ),\n ];\n return [replacement, step];\n}\n\nfunction replaceBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n directive: DirectiveDefinition,\n bindings: ExtractedBindings,\n): void {\n // Transform all control statements\n const halting = transformHalting(path, bindings.mutations);\n const rootFile = createVirtualFileName(ctx);\n const rootContent = generator(\n t.program([\n ...(ctx.options.mode === 'server'\n ? moduleDefinitionsToImportDeclarations(bindings.modules)\n : []),\n t.exportDefaultDeclaration(\n t.functionExpression(\n undefined,\n bindings.locals,\n t.blockStatement(path.node.body),\n halting.hasYield,\n true,\n ),\n ),\n ]),\n );\n ctx.onVirtualFile(rootFile, rootContent.code, 'root');\n // Create an ID\n let id = `${ctx.blocks.hash}-${ctx.blocks.count++}`;\n if (ctx.options.env !== 'production') {\n id += `-${getDescriptiveName(path, 'anonymous')}`;\n }\n const entryID = path.scope.generateUidIdentifier('entry');\n const entryImports: ModuleDefinition[] = [\n {\n kind: directive.import.kind,\n source: directive.import.source,\n local: entryID.name,\n imported:\n directive.import.kind === 'named' ? directive.import.name : undefined,\n },\n ];\n const args: t.Expression[] = [t.stringLiteral(id)];\n if (ctx.options.mode === 'server') {\n const rootID = path.scope.generateUidIdentifier('root');\n entryImports.push({\n kind: 'default',\n source: rootFile,\n local: rootID.name,\n });\n args.push(rootID);\n }\n // Create the registration call\n const entryFile = createVirtualFileName(ctx);\n const entryContent = generator(\n t.program([\n ...moduleDefinitionsToImportDeclarations(entryImports),\n t.exportDefaultDeclaration(t.callExpression(entryID, args)),\n ]),\n );\n ctx.onVirtualFile(entryFile, entryContent.code, 'entry');\n\n // Move to the replacement for the server block,\n // declare the type and result based from transformHalting\n const returnType = path.scope.generateUidIdentifier('type');\n const returnResult = path.scope.generateUidIdentifier('result');\n const returnMutations = path.scope.generateUidIdentifier('mutations');\n let check: t.Statement = t.ifStatement(\n t.binaryExpression('===', returnType, THROW_KEY),\n t.blockStatement([t.throwStatement(returnResult)]),\n );\n // If the block has a return, we need to make sure that the\n // replacement does too.\n if (halting.hasReturn) {\n check = t.ifStatement(\n t.binaryExpression('===', returnType, RETURN_KEY),\n t.blockStatement([t.returnStatement(returnResult)]),\n check,\n );\n }\n // If the block has a break, we also do it.\n if (halting.breakCount > 0) {\n check = getBreakCheck(\n returnType,\n returnResult,\n halting.breakCount,\n halting.breaks,\n check,\n );\n }\n // If the block has a continue, we also do it.\n if (halting.continueCount > 0) {\n check = getContinueCheck(\n returnType,\n returnResult,\n halting.continueCount,\n halting.continues,\n check,\n );\n }\n\n const blockID = path.scope.generateUidIdentifier('block');\n // If the server block happens to be declared in a generator\n const replacement: t.Statement[] = [\n t.variableDeclaration('const', [\n t.variableDeclarator(\n blockID,\n t.memberExpression(\n t.awaitExpression(t.importExpression(t.stringLiteral(entryFile))),\n t.identifier('default'),\n ),\n ),\n ]),\n ];\n if (halting.hasYield) {\n const [reps, step] = getGeneratorReplacementForServerBlock(\n path,\n blockID,\n bindings.locals,\n );\n for (let i = 0, len = reps.length; i < len; i++) {\n replacement.push(reps[i]);\n }\n replacement.push(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.arrayPattern([returnType, returnResult, returnMutations]),\n t.memberExpression(step, t.identifier('value')),\n ),\n ]),\n );\n } else {\n replacement.push(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.arrayPattern([returnType, returnResult, returnMutations]),\n t.awaitExpression(t.callExpression(blockID, bindings.locals)),\n ),\n ]),\n );\n }\n if (bindings.mutations.length) {\n replacement.push(\n t.expressionStatement(\n t.assignmentExpression(\n '=',\n t.objectPattern(\n bindings.mutations.map(item =>\n t.objectProperty(item, item, false, true),\n ),\n ),\n returnMutations,\n ),\n ),\n );\n }\n if (check) {\n replacement.push(check);\n }\n path.replaceWith(t.blockStatement(replacement));\n}\n\nexport function splitBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n directive: DirectiveDefinition,\n): void {\n replaceBlock(\n ctx,\n path,\n directive,\n extractBindings(ctx, path, getForeignBindings(path, 'block')),\n );\n}\n", "import type * as babel from '@babel/core';\nimport * as t from '@babel/types';\n\nfunction isForeignBinding(\n source: babel.NodePath,\n current: babel.NodePath,\n name: string,\n mode: 'block' | 'function',\n): boolean {\n if (current.scope.hasGlobal(name)) {\n return false;\n }\n if (source === current) {\n return true;\n }\n if (current.scope.hasOwnBinding(name)) {\n if (mode === 'block') {\n const binding = current.scope.getBinding(name);\n return !!binding && binding.kind === 'param';\n }\n return false;\n }\n if (current.parentPath) {\n return isForeignBinding(source, current.parentPath, name, mode);\n }\n return true;\n}\n\nfunction isInTypescript(path: babel.NodePath): boolean {\n let parent = path.parentPath;\n while (parent) {\n if (t.isTypeScript(parent.node) && !t.isExpression(parent.node)) {\n return true;\n }\n parent = parent.parentPath;\n }\n return false;\n}\n\nexport default function getForeignBindings(\n path: babel.NodePath,\n mode: 'block' | 'function' | 'expression',\n): Set<string> {\n const identifiers = new Set<string>();\n path.traverse({\n ReferencedIdentifier(p) {\n // Check identifiers that aren't in a TS expression\n if (\n !isInTypescript(p) &&\n (mode === 'expression'\n ? !path.scope.hasGlobal(p.node.name)\n : isForeignBinding(path, p, p.node.name, mode))\n ) {\n identifiers.add(p.node.name);\n }\n },\n });\n\n return identifiers;\n}\n", "import type { NodePath } from '@babel/core';\n\nexport function getDescriptiveName(\n path: NodePath,\n defaultName: string,\n): string {\n let current: NodePath | null = path;\n while (current) {\n switch (current.node.type) {\n case 'FunctionDeclaration':\n case 'FunctionExpression': {\n if (current.node.id) {\n return current.node.id.name;\n }\n break;\n }\n case 'VariableDeclarator': {\n if (current.node.id.type === 'Identifier') {\n return current.node.id.name;\n }\n break;\n }\n case 'ClassPrivateMethod':\n case 'ClassMethod':\n case 'ObjectMethod': {\n switch (current.node.key.type) {\n case 'Identifier':\n return current.node.key.name;\n case 'PrivateName':\n return current.node.key.id.name;\n default:\n break;\n }\n break;\n }\n default:\n break;\n }\n current = current.parentPath;\n }\n return defaultName;\n}\n", "import _generator from '@babel/generator';\n\ntype GeneratorShim = typeof _generator;\n\n// https://github.com/babel/babel/issues/15269\nconst generator: GeneratorShim =\n typeof _generator !== 'function'\n ? (_generator as unknown as { default: GeneratorShim }).default\n : _generator;\n\nexport default generator;\n", "import type * as babel from '@babel/core';\nimport * as t from '@babel/types';\n\nexport function getRootStatementPath(path: babel.NodePath): babel.NodePath {\n let current = path.parentPath;\n while (current) {\n const next = current.parentPath;\n if (next && t.isProgram(next.node)) {\n return current;\n }\n current = next;\n }\n return path;\n}\n", "import * as t from '@babel/types';\nimport * as babel from '@babel/core';\nimport assert from './assert';\nimport { getImportSpecifierName } from './get-import-specifier-name';\nimport { ModuleDefinition } from '../types';\nimport { isPathValid } from './unwrap';\n\nexport function getModuleDefinition(path: babel.NodePath): ModuleDefinition {\n assert(\n isPathValid(path, t.isImportSpecifier) ||\n isPathValid(path, t.isImportDefaultSpecifier) ||\n isPathValid(path, t.isImportNamespaceSpecifier),\n 'invariant',\n );\n const parent =\n path.getStatementParent() as babel.NodePath<t.ImportDeclaration>;\n const source = parent.node.source.value;\n switch (path.node.type) {\n case 'ImportDefaultSpecifier':\n return {\n source,\n kind: 'default',\n local: path.node.local.name,\n };\n case 'ImportNamespaceSpecifier':\n return {\n source,\n kind: 'namespace',\n local: path.node.local.name,\n };\n case 'ImportSpecifier': {\n const imported = getImportSpecifierName(path.node);\n if (imported === 'default') {\n return {\n source,\n kind: 'default',\n local: path.node.local.name,\n imported: '',\n };\n }\n return {\n source,\n kind: 'named',\n local: path.node.local.name,\n imported,\n };\n }\n }\n}\n", "import type * as t from '@babel/types';\n\nexport function getImportSpecifierName(node: t.ImportSpecifier) {\n switch (node.imported.type) {\n case 'Identifier':\n return node.imported.name;\n case 'StringLiteral':\n return node.imported.value;\n }\n}\n", "import type * as babel from '@babel/core';\nimport type * as t from '@babel/types';\n\ntype TypeFilter<V extends t.Node> = (node: t.Node) => node is V;\n\nexport function isPathValid<V extends t.Node>(\n path: unknown,\n key: TypeFilter<V>,\n): path is babel.NodePath<V> {\n return key((path as babel.NodePath).node);\n}\n\nexport type NestedExpression =\n | t.ParenthesizedExpression\n | t.TypeCastExpression\n | t.TSAsExpression\n | t.TSSatisfiesExpression\n | t.TSNonNullExpression\n | t.TSInstantiationExpression\n | t.TSTypeAssertion;\n\nexport function isNestedExpression(node: t.Node): node is NestedExpression {\n switch (node.type) {\n case 'ParenthesizedExpression':\n case 'TypeCastExpression':\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n case 'TSTypeAssertion':\n case 'TSInstantiationExpression':\n return true;\n default:\n return false;\n }\n}\n\ntype TypeCheck<K> = K extends TypeFilter<infer U> ? U : never;\n\nexport function unwrapNode<K extends (value: t.Node) => boolean>(\n node: t.Node,\n key: K,\n): TypeCheck<K> | undefined {\n if (key(node)) {\n return node as TypeCheck<K>;\n }\n if (isNestedExpression(node)) {\n return unwrapNode(node.expression, key);\n }\n return undefined;\n}\n\nexport function unwrapPath<V extends t.Node>(\n path: unknown,\n key: TypeFilter<V>,\n): babel.NodePath<V> | undefined {\n if (isPathValid(path, key)) {\n return path;\n }\n if (isPathValid(path, isNestedExpression)) {\n return unwrapPath(path.get('expression'), key);\n }\n return undefined;\n}\n", "import * as t from '@babel/types';\n\nfunction getIdentifiersFromArrayPattern(node: t.ArrayPattern): string[] {\n const ids: string[] = [];\n for (let i = 0, len = node.elements.length; i < len; i++) {\n const el = node.elements[i];\n if (el) {\n ids.push(...getIdentifiersFromLVal(el));\n }\n }\n return ids;\n}\n\nfunction getIdentifiersFromObjectPattern(node: t.ObjectPattern): string[] {\n const ids: string[] = [];\n for (let i = 0, len = node.properties.length; i < len; i++) {\n const el = node.properties[i];\n if (el) {\n if (el.type === 'RestElement') {\n ids.push(...getIdentifiersFromLVal(el));\n } else if (t.isLVal(el.value)) {\n ids.push(...getIdentifiersFromLVal(el.value));\n }\n }\n }\n return ids;\n}\n\nexport function getIdentifiersFromLVal(node: t.LVal): string[] {\n switch (node.type) {\n case 'Identifier':\n return [node.name];\n case 'ArrayPattern':\n return getIdentifiersFromArrayPattern(node);\n case 'AssignmentPattern':\n return getIdentifiersFromLVal(node.left);\n case 'ObjectPattern':\n return getIdentifiersFromObjectPattern(node);\n case 'RestElement':\n return getIdentifiersFromLVal(node.argument);\n default:\n return [];\n }\n}\n", "import * as t from '@babel/types';\nimport * as babel from '@babel/core';\nimport { DirectiveDefinition, StateContext } from './types';\nimport { splitBlock } from './split';\n\nfunction getValidDirectiveFromString(\n ctx: StateContext,\n string: string,\n): DirectiveDefinition | undefined {\n for (let i = 0, len = ctx.options.directives.length; i < len; i++) {\n const current = ctx.options.directives[i];\n if (current.value === string) {\n return current;\n }\n }\n return undefined;\n}\n\nfunction getDefinitionFromDirectives(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): DirectiveDefinition | undefined {\n for (let i = 0, len = path.node.directives.length; i < len; i++) {\n const statement = path.node.directives[i].value.value;\n const directive = getValidDirectiveFromString(ctx, statement);\n if (directive) {\n return directive;\n }\n }\n return undefined;\n}\n\nfunction getDefinitionFromFauxDirectives(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): DirectiveDefinition | undefined {\n for (let i = 0, len = path.node.body.length; i < len; i++) {\n const statement = path.node.body[i];\n if (\n statement.type === 'ExpressionStatement' &&\n statement.expression.type === 'StringLiteral'\n ) {\n const directive = getValidDirectiveFromString(\n ctx,\n statement.expression.value,\n );\n if (directive) {\n return directive;\n }\n } else {\n break;\n }\n }\n return undefined;\n}\n\nfunction getDirectiveDefinitionFromBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): DirectiveDefinition | undefined {\n const parent = path.getFunctionParent();\n if (parent && !parent.node.async) {\n return undefined;\n }\n return (\n getDefinitionFromDirectives(ctx, path) ||\n getDefinitionFromFauxDirectives(ctx, path)\n );\n}\n\nfunction cleanBlockForDirectives(\n path: babel.NodePath<t.BlockStatement>,\n definition: DirectiveDefinition,\n): void {\n const newDirectives: t.Directive[] = [];\n for (let i = 0, len = path.node.directives.length; i < len; i++) {\n const current = path.node.directives[i];\n if (current.value.value !== definition.value) {\n newDirectives.push(current);\n }\n }\n path.node.directives = newDirectives;\n}\n\nfunction cleanBlockForFauxDirectives(\n path: babel.NodePath<t.BlockStatement>,\n definition: DirectiveDefinition,\n): void {\n const body = path.get('body');\n for (let i = 0, len = body.length; i < len; i++) {\n const statement = body[i];\n if (\n statement.node.type === 'ExpressionStatement' &&\n statement.node.expression.type === 'StringLiteral'\n ) {\n if (statement.node.expression.value === definition.value) {\n statement.remove();\n return;\n }\n }\n }\n}\n\nexport function transformBlock(\n ctx: StateContext,\n path: babel.NodePath<t.BlockStatement>,\n): void {\n const definition = getDirectiveDefinitionFromBlock(ctx, path);\n if (!definition) {\n return;\n }\n cleanBlockForDirectives(path, definition);\n cleanBlockForFauxDirectives(path, definition);\n splitBlock(ctx, path, definition);\n}\n", "import type * as babel from '@babel/core';\nimport { StateContext } from './types';\nimport { transformBlock } from './transform-block';\n\ninterface State extends babel.PluginPass {\n opts: StateContext;\n}\n\nexport function plugin(): babel.PluginObj<State> {\n return {\n name: 'directive-splitter',\n visitor: {\n BlockStatement(path, ctx) {\n transformBlock(ctx.opts, path);\n },\n },\n };\n}\n", "/* eslint-disable @typescript-eslint/no-shadow */\n/**\n * Copyright (c) 2019 Jason Dent\n * https://github.com/Jason3S/xxhash\n */\nconst PRIME32_1 = 2654435761;\nconst PRIME32_2 = 2246822519;\nconst PRIME32_3 = 3266489917;\nconst PRIME32_4 = 668265263;\nconst PRIME32_5 = 374761393;\n\nfunction toUtf8(text: string): Uint8Array {\n const bytes: number[] = [];\n for (let i = 0, n = text.length; i < n; ++i) {\n const c = text.charCodeAt(i);\n if (c < 0x80) {\n bytes.push(c);\n } else if (c < 0x800) {\n bytes.push(0xc0 | (c >> 6), 0x80 | (c & 0x3f));\n } else if (c < 0xd800 || c >= 0xe000) {\n bytes.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 0x3f), 0x80 | (c & 0x3f));\n } else {\n const cp =\n 0x10000 + (((c & 0x3ff) << 10) | (text.charCodeAt(++i) & 0x3ff));\n bytes.push(\n 0xf0 | ((cp >> 18) & 0x7),\n 0x80 | ((cp >> 12) & 0x3f),\n 0x80 | ((cp >> 6) & 0x3f),\n 0x80 | (cp & 0x3f),\n );\n }\n }\n return new Uint8Array(bytes);\n}\n/**\n *\n * @param buffer - byte array or string\n * @param seed - optional seed (32-bit unsigned);\n */\nexport default function xxHash32(\n buffer: Uint8Array | string,\n seed = 0,\n): number {\n buffer = typeof buffer === 'string' ? toUtf8(buffer) : buffer;\n const b = buffer;\n\n /*\n Step 1. Initialize internal accumulators\n Each accumulator gets an initial value based on optional seed input.\n Since the seed is optional, it can be 0.\n ```\n u32 acc1 = seed + PRIME32_1 + PRIME32_2;\n u32 acc2 = seed + PRIME32_2;\n u32 acc3 = seed + 0;\n u32 acc4 = seed - PRIME32_1;\n ```\n Special case : input is less than 16 bytes\n When input is too small (< 16 bytes), the algorithm will not process any stripe.\n Consequently, it will not make use of parallel accumulators.\n In which case, a simplified initialization is performed, using a single accumulator :\n u32 acc = seed + PRIME32_5;\n The algorithm then proceeds directly to step 4.\n */\n\n let acc = (seed + PRIME32_5) & 0xffffffff;\n let offset = 0;\n\n if (b.length >= 16) {\n const accN = [\n (seed + PRIME32_1 + PRIME32_2) & 0xffffffff,\n (seed + PRIME32_2) & 0xffffffff,\n (seed + 0) & 0xffffffff,\n (seed - PRIME32_1) & 0xffffffff,\n ];\n\n /*\n Step 2. Process stripes\n A stripe is a contiguous segment of 16 bytes. It is evenly divided into 4 lanes,\n of 4 bytes each. The first lane is used to update accumulator 1, the second lane\n is used to update accumulator 2, and so on. Each lane read its associated 32-bit\n value using little-endian convention. For each {lane, accumulator}, the update\n process is called a round, and applies the following formula :\n ```\n accN = accN + (laneN * PRIME32_2);\n accN = accN <<< 13;\n accN = accN * PRIME32_1;\n ```\n This shuffles the bits so that any bit from input lane impacts several bits in\n output accumulator. All operations are performed modulo 2^32.\n Input is consumed one full stripe at a time. Step 2 is looped as many times as\n necessary to consume the whole input, except the last remaining bytes which cannot\n form a stripe (< 16 bytes). When that happens, move to step 3.\n */\n\n const b = buffer;\n const limit = b.length - 16;\n let lane = 0;\n for (offset = 0; (offset & 0xfffffff0) <= limit; offset += 4) {\n const i = offset;\n const laneN0 = b[i + 0] + (b[i + 1] << 8);\n const laneN1 = b[i + 2] + (b[i + 3] << 8);\n const laneNP = laneN0 * PRIME32_2 + ((laneN1 * PRIME32_2) << 16);\n let acc = (accN[lane] + laneNP) & 0xffffffff;\n acc = (acc << 13) | (acc >>> 19);\n const acc0 = acc & 0xffff;\n const acc1 = acc >>> 16;\n accN[lane] = (acc0 * PRIME32_1 + ((acc1 * PRIME32_1) << 16)) & 0xffffffff;\n lane = (lane + 1) & 0x3;\n }\n\n /*\n Step 3. Accumulator convergence\n All 4 lane accumulators from previous steps are merged to produce a\n single remaining accumulator\n of same width (32-bit). The associated formula is as follows :\n ```\n acc = (acc1 <<< 1) + (acc2 <<< 7) + (acc3 <<< 12) + (acc4 <<< 18);\n ```\n */\n acc =\n (((accN[0] << 1) | (accN[0] >>> 31)) +\n ((accN[1] << 7) | (accN[1] >>> 25)) +\n ((accN[2] << 12) | (accN[2] >>> 20)) +\n ((accN[3] << 18) | (accN[3] >>> 14))) &\n 0xffffffff;\n }\n\n /*\n Step 4. Add input length\n The input total length is presumed known at this stage.\n This step is just about adding the length to\n accumulator, so that it participates to final mixing.\n ```\n acc = acc + (u32)inputLength;\n ```\n */\n acc = (acc + buffer.length) & 0xffffffff;\n\n /*\n Step 5. Consume remaining input\n There may be up to 15 bytes remaining to consume from the input.\n The final stage will digest them according\n to following pseudo-code :\n ```\n while (remainingLength >= 4) {\n lane = read_32bit_little_endian(input_ptr);\n acc = acc + lane * PRIME32_3;\n acc = (acc <<< 17) * PRIME32_4;\n input_ptr += 4; remainingLength -= 4;\n }\n ```\n This process ensures that all input bytes are present in the final mix.\n */\n\n const limit = buffer.length - 4;\n for (; offset <= limit; offset += 4) {\n const i = offset;\n const laneN0 = b[i + 0] + (b[i + 1] << 8);\n const laneN1 = b[i + 2] + (b[i + 3] << 8);\n const laneP = laneN0 * PRIME32_3 + ((laneN1 * PRIME32_3) << 16);\n acc = (acc + laneP) & 0xffffffff;\n acc = (acc << 17) | (acc >>> 15);\n acc =\n ((acc & 0xffff) * PRIME32_4 + (((acc >>> 16) * PRIME32_4) << 16)) &\n 0xffffffff;\n }\n\n /*\n ```\n while (remainingLength >= 1) {\n lane = read_byte(input_ptr);\n acc = acc + lane * PRIME32_5;\n acc = (acc <<< 11) * PRIME32_1;\n input_ptr += 1; remainingLength -= 1;\n }\n ```\n */\n\n for (; offset < b.length; ++offset) {\n const lane = b[offset];\n acc += lane * PRIME32_5;\n acc = (acc << 11) | (acc >>> 21);\n acc =\n ((acc & 0xffff) * PRIME32_1 + (((acc >>> 16) * PRIME32_1) << 16)) &\n 0xffffffff;\n }\n\n /*\n Step 6. Final mix (avalanche)\n The final mix ensures that all input bits have a chance to impact any bit in\n the output digest, resulting in an unbiased distribution. This is also called\n avalanche effect.\n ```\n acc = acc xor (acc >> 15);\n acc = acc * PRIME32_2;\n acc = acc xor (acc >> 13);\n acc = acc * PRIME32_3;\n acc = acc xor (acc >> 16);\n ```\n */\n\n acc ^= acc >>> 15;\n acc =\n (((acc & 0xffff) * PRIME32_2) & 0xffffffff) +\n (((acc >>> 16) * PRIME32_2) << 16);\n acc ^= acc >>> 13;\n acc =\n (((acc & 0xffff) * PRIME32_3) & 0xffffffff) +\n (((acc >>> 16) * PRIME32_3) << 16);\n acc ^= acc >>> 16;\n\n // turn any negatives back into a positive number;\n return acc < 0 ? acc + 4294967296 : acc;\n}\n"],
"mappings": ";AAAA,YAAY,WAAW;AACvB,OAAO,UAAU;;;ACDF,SAAR,OAAwB,MAAe,OAA6B;AACzE,MAAI,CAAC,MAAM;AACT,UAAM,IAAI,MAAM,KAAK;AAAA,EACvB;AACF;;;ACJA,YAAYA,QAAO;;;ACCnB,YAAY,OAAO;AAEnB,SAAS,iBACP,QACA,SACA,MACA,MACS;AACT,MAAI,QAAQ,MAAM,UAAU,IAAI,GAAG;AACjC,WAAO;AAAA,EACT;AACA,MAAI,WAAW,SAAS;AACtB,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,MAAM,cAAc,IAAI,GAAG;AACrC,QAAI,SAAS,SAAS;AACpB,YAAM,UAAU,QAAQ,MAAM,WAAW,IAAI;AAC7C,aAAO,CAAC,CAAC,WAAW,QAAQ,SAAS;AAAA,IACvC;AACA,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,YAAY;AACtB,WAAO,iBAAiB,QAAQ,QAAQ,YAAY,MAAM,IAAI;AAAA,EAChE;AACA,SAAO;AACT;AAEA,SAAS,eAAeC,OAA+B;AACrD,MAAI,SAASA,MAAK;AAClB,SAAO,QAAQ;AACb,QAAM,eAAa,OAAO,IAAI,KAAK,CAAG,eAAa,OAAO,IAAI,GAAG;AAC/D,aAAO;AAAA,IACT;AACA,aAAS,OAAO;AAAA,EAClB;AACA,SAAO;AACT;AAEe,SAAR,mBACLA,OACA,MACa;AACb,QAAM,cAAc,oBA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QAAM,QAAkB,CAAC;AACzB,QAAM,QAAQ,oBAAI,IAAoB;AAEtC,QAAM,MAAoB;AAAA,IACxB,MAAM;AAAA,IACN,SAAS,oBAAI,IAAI;AAAA,IACjB,SAAS;AAAA,MACP,OAAO;AAAA,IACT;AAAA,IACA;AAAA,IACA,UAAU,oBAAI,IAAI;AAAA,IAClB,QAAQ;AAAA,MACN,MAAM,SAAS,EAAE,EAAE,SAAS,EAAE;AAAA,MAC9B,OAAO;AAAA,IACT;AAAA,IACA,cAAc,SAAS,SAAS,MAAM;AACpC,YAAM,WAAW,KAAK,KAAK,WAAW,KAAK,OAAO;AAClD,YAAM,IAAI,KAAK,KAAK,WAAW,KAAK,OAAO,GAAG,OAAO;AACrD,UAAI,SAAS,SAAS;AACpB,gBAAQ,KAAK,QAAQ;AAAA,MACvB,WAAW,SAAS,QAAQ;AAC1B,cAAM,KAAK,QAAQ;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AAEA,QAAM,UAA0C,CAAC,KAAK;AAEtD,MAAI,gBAAgB,KAAK,EAAE,GAAG;AAC5B,YAAQ,KAAK,YAAY;AAAA,EAC3B;AAEA,QAAM,SAAS,MAAY,qBAAe,MAAM;AAAA,IAC9C,SAAS,CAAC,CAAC,QAAQ,GAAG,CAAC;AAAA,IACvB,YAAY;AAAA,MACV;AAAA,IACF;AAAA,IACA,UAAU,WAAW;AAAA,IACrB,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,SAAS;AAAA,EACX,CAAC;AAED,SAAO,QAAQ,WAAW;AAE1B,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,KAAK,OAAO;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
"names": ["t", "path", "path", "t", "path", "t", "path", "path", "path", "t", "path", "identifier", "path", "path", "b", "limit", "acc"]
}

@@ -1,1 +0,1 @@

import*as q from"@babel/core";import _ from"path";function D(t,n){if(!t)throw new Error(n)}import*as e from"@babel/types";import*as y from"@babel/types";function T(t,n,i,r){if(n.scope.hasGlobal(i))return!1;if(t===n)return!0;if(n.scope.hasOwnBinding(i)){if(r==="block"){let o=n.scope.getBinding(i);return!!o&&o.kind==="param"}return!1}return n.parentPath?T(t,n.parentPath,i,r):!0}function Q(t){let n=t.parentPath;for(;n;){if(y.isTypeScript(n.node)&&!y.isExpression(n.node))return!0;n=n.parentPath}return!1}function k(t,n){let i=new Set;return t.traverse({ReferencedIdentifier(r){!Q(r)&&(n==="expression"?!t.scope.hasGlobal(r.node.name):T(t,r,r.node.name,n))&&i.add(r.node.name)}}),i}function V(t,n){let i=t;for(;i;){switch(i.node.type){case"FunctionDeclaration":case"FunctionExpression":{if(i.node.id)return i.node.id.name;break}case"VariableDeclarator":{if(i.node.id.type==="Identifier")return i.node.id.name;break}case"ClassPrivateMethod":case"ClassMethod":case"ObjectMethod":{switch(i.node.key.type){case"Identifier":return i.node.key.name;case"PrivateName":return i.node.key.id.name;default:break}break}default:break}i=i.parentPath}return n}import M from"@babel/generator";var X=typeof M!="function"?M.default:M,v=X;import*as L from"@babel/types";function F(t){let n=t.parentPath;for(;n;){let i=n.parentPath;if(i&&L.isProgram(i.node))return n;n=i}return t}import*as h from"@babel/types";function U(t){switch(t.imported.type){case"Identifier":return t.imported.name;case"StringLiteral":return t.imported.value}}function x(t,n){return n(t.node)}function Z(t){switch(t.type){case"ParenthesizedExpression":case"TypeCastExpression":case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":case"TSInstantiationExpression":return!0;default:return!1}}function B(t,n){if(x(t,n))return t;if(x(t,Z))return B(t.get("expression"),n)}function A(t){D(x(t,h.isImportSpecifier)||x(t,h.isImportDefaultSpecifier)||x(t,h.isImportNamespaceSpecifier),"invariant");let i=t.getStatementParent().node.source.value;switch(t.node.type){case"ImportDefaultSpecifier":return{source:i,kind:"default",local:t.node.local.name};case"ImportNamespaceSpecifier":return{source:i,kind:"namespace",local:t.node.local.name};case"ImportSpecifier":{let r=U(t.node);return r==="default"?{source:i,kind:"default",local:t.node.local.name,imported:""}:{source:i,kind:"named",local:t.node.local.name,imported:r}}}}import*as O from"@babel/types";function ee(t){let n=[];for(let i=0,r=t.elements.length;i<r;i++){let o=t.elements[i];o&&n.push(...E(o))}return n}function te(t){let n=[];for(let i=0,r=t.properties.length;i<r;i++){let o=t.properties[i];o&&(o.type==="RestElement"?n.push(...E(o)):O.isLVal(o.value)&&n.push(...E(o.value)))}return n}function E(t){switch(t.type){case"Identifier":return[t.name];case"ArrayPattern":return ee(t);case"AssignmentPattern":return E(t.left);case"ObjectPattern":return te(t);case"RestElement":return E(t.argument);default:return[]}}function ne(t){switch(t.kind){case"default":return e.importDefaultSpecifier(e.identifier(t.local));case"named":return e.importSpecifier(e.identifier(t.local),t.imported?e.identifier(t.imported):e.identifier(t.local));case"namespace":return e.importNamespaceSpecifier(e.identifier(t.local))}}function R(t){return e.importDeclaration([ne(t)],e.stringLiteral(t.source))}function I(t){let n=[];for(let i=0,r=t.length;i<r;i++)n[i]=R(t[i]);return n}function ie(t){switch(t){case"let":case"var":case"param":return!0;case"const":case"hoisted":case"local":case"module":case"unknown":return!1}}function re(t,n,i,r){let o=t.bindings.get(i);if(o)n.push(o);else if(x(r.path,e.isVariableDeclarator)){let a=se(t,r.path);for(let s=0,f=a.length;s<f;s++)n.push(a[s]),t.bindings.set(a[s].local,a[s])}else if(x(r.path,e.isFunctionDeclaration)){let a=ae(t,r.path);n.push(a),t.bindings.set(a.local,a)}}function oe(t,n,i,r,o,a){if(a.kind==="module")n.push(A(a.path));else if(a.kind==="param")i.push(a.identifier);else{let s=a.path.scope.getBlockParent(),f=a.path.scope.getProgramParent();s===f?re(t,n,o,a):(i.push(a.identifier),ie(a.kind)&&r.push(a.identifier))}}function C(t,n,i){let r=[],o=[],a=[];for(let s of i){let f=n.scope.getBinding(s);f&&oe(t,r,o,a,s,f)}return{modules:r,locals:o,mutations:a}}function ae(t,n){let i=k(n,"function"),{modules:r}=C(t,n,i),o=t.options.getVirtualFileName(t.path,t.virtual.count++),a=v(e.program([...I(r),e.exportDefaultDeclaration(n.node)]));t.onVirtualFile(o,a.code);let s=F(n),u={kind:"default",local:(n.node.id||n.scope.generateUidIdentifier("func")).name,source:o};return s.insertBefore(R(u)),n.remove(),u}function se(t,n){let i=B(n.get("init"),e.isExpression),r=i?C(t,n,k(n,x(i,e.isArrowFunctionExpression)||x(i,e.isFunctionExpression)?"function":"expression")).modules:[],o=t.options.getVirtualFileName(t.path,t.virtual.count++),a=n.parentPath.node,s=v(e.program([...I(r),e.exportNamedDeclaration(e.variableDeclaration(a.kind,[n.node]))]));t.onVirtualFile(o,s.code);let f=E(n.node.id).map(c=>({kind:"named",local:c,source:o})),u=F(n);return u&&u.insertBefore(I(f)),n.remove(),f}var K=e.numericLiteral(0),j=e.numericLiteral(1),Y=e.numericLiteral(2),le=e.numericLiteral(3),G=e.numericLiteral(4);function fe(t,n){let i=t.scope.getFunctionParent()||t.scope.getProgramParent(),r=[],o=0,a=[],s=0,f=!1,u=!1,c=n.length?t.scope.generateUidIdentifier("mutate"):void 0;t.traverse({BreakStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){let p=[K];if(o++,l.node.label){let P=l.node.label.name;r.push(P),p.push(e.stringLiteral(P))}else p.push(e.nullLiteral());c&&p.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(p))),l.skip()}},ContinueStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){let p=[j];if(s++,l.node.label){let P=l.node.label.name;a.push(P),p.push(e.stringLiteral(P))}else p.push(e.nullLiteral());c&&p.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(p))),l.skip()}},ReturnStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){f=!0;let p=[Y];l.node.argument?p.push(l.node.argument):p.push(e.nullLiteral()),c&&p.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(p))),l.skip()}},YieldExpression(l){(l.scope.getFunctionParent()||l.scope.getProgramParent())===i&&(u=!0)}});let m=t.scope.generateUidIdentifier("error"),g=[G,m],S=[le];c&&(g.push(e.callExpression(c,[])),S.push(e.nullLiteral()),S.push(e.callExpression(c,[])));let d=[e.tryStatement(e.blockStatement(t.node.body),e.catchClause(m,e.blockStatement([e.returnStatement(e.arrayExpression(g))]))),e.returnStatement(e.arrayExpression(S))];return c&&d.unshift(e.variableDeclaration("const",[e.variableDeclarator(c,e.arrowFunctionExpression([],e.objectExpression(n.map(l=>e.objectProperty(l,l,!1,!0)))))])),t.node.body=d,{breaks:r,continues:a,hasReturn:f,hasYield:u,breakCount:o,continueCount:s}}function ce(t,n,i,r,o){let a;i!==r.length&&(a=e.blockStatement([e.breakStatement()]));for(let s=0,f=r.length;s<f;s++){let u=r[s];a=e.blockStatement([e.ifStatement(e.binaryExpression("===",n,e.stringLiteral(u)),e.blockStatement([e.breakStatement(e.identifier(u))]),a)])}return a?e.ifStatement(e.binaryExpression("===",t,K),a,o):o}function ue(t,n,i,r,o){let a;i!==r.length&&(a=e.blockStatement([e.continueStatement()]));for(let s=0,f=r.length;s<f;s++){let u=r[s];a=e.blockStatement([e.ifStatement(e.binaryExpression("===",n,e.stringLiteral(u)),e.blockStatement([e.continueStatement(e.identifier(u))]),a)])}return a?e.ifStatement(e.binaryExpression("===",t,j),a,o):o}function pe(t,n,i){let r=t.scope.generateUidIdentifier("iterator"),o=t.scope.generateUidIdentifier("step");return[[e.variableDeclaration("let",[e.variableDeclarator(o),e.variableDeclarator(r,e.awaitExpression(e.callExpression(n,i)))]),e.whileStatement(e.booleanLiteral(!0),e.blockStatement([e.expressionStatement(e.assignmentExpression("=",o,e.callExpression(e.memberExpression(r,e.identifier("next")),[]))),e.ifStatement(e.memberExpression(o,e.identifier("done")),e.blockStatement([e.breakStatement()]),e.blockStatement([e.expressionStatement(e.yieldExpression(e.memberExpression(o,e.identifier("value"))))]))]))],o]}function me(t,n,i,r){let o=fe(n,r.mutations),a=`${t.blocks.hash}-${t.blocks.count++}`;t.options.env!=="production"&&(a+=`-${V(n,"anonymous")}`);let s=[e.stringLiteral(a)];t.options.mode==="server"&&s.push(e.functionExpression(void 0,r.locals,e.blockStatement(n.node.body),o.hasYield,!0));let f=t.options.getVirtualFileName(t.path,t.virtual.count++),u=n.scope.generateUidIdentifier("register"),c=v(e.program([...t.options.mode==="server"?I(r.modules):[],R({kind:i.import.kind,source:i.import.source,local:u.name,imported:i.import.kind==="named"?i.import.name:void 0}),e.exportDefaultDeclaration(e.callExpression(u,s))]));t.onEntryFile(f),t.onVirtualFile(f,c.code);let m=n.scope.generateUidIdentifier("type"),g=n.scope.generateUidIdentifier("result"),S=n.scope.generateUidIdentifier("mutations"),d=e.ifStatement(e.binaryExpression("===",m,G),e.blockStatement([e.throwStatement(g)]));o.hasReturn&&(d=e.ifStatement(e.binaryExpression("===",m,Y),e.blockStatement([e.returnStatement(g)]),d)),o.breakCount>0&&(d=ce(m,g,o.breakCount,o.breaks,d)),o.continueCount>0&&(d=ue(m,g,o.continueCount,o.continues,d));let l=n.scope.generateUidIdentifier("block"),b=[e.variableDeclaration("const",[e.variableDeclarator(l,e.memberExpression(e.awaitExpression(e.importExpression(e.stringLiteral(f))),e.identifier("default")))])];if(o.hasYield){let[p,P]=pe(n,l,r.locals);for(let N=0,J=p.length;N<J;N++)b.push(p[N]);b.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([m,g,S]),e.memberExpression(P,e.identifier("value")))]))}else b.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([m,g,S]),e.awaitExpression(e.callExpression(l,r.locals)))]));r.mutations.length&&b.push(e.expressionStatement(e.assignmentExpression("=",e.objectPattern(r.mutations.map(p=>e.objectProperty(p,p,!1,!0))),S))),d&&b.push(d),n.replaceWith(e.blockStatement(b))}function H(t,n,i){me(t,n,i,C(t,n,k(n,"block")))}function W(t,n){for(let i=0,r=t.options.directives.length;i<r;i++){let o=t.options.directives[i];if(o.value===n)return o}}function de(t,n){for(let i=0,r=n.node.directives.length;i<r;i++){let o=n.node.directives[i].value.value,a=W(t,o);if(a)return a}}function be(t,n){for(let i=0,r=n.node.body.length;i<r;i++){let o=n.node.body[i];if(o.type==="ExpressionStatement"&&o.expression.type==="StringLiteral"){let a=W(t,o.expression.value);if(a)return a}else break}}function ge(t,n){let i=n.getFunctionParent();if(!(i&&!i.node.async))return de(t,n)||be(t,n)}function xe(t,n){let i=[];for(let r=0,o=t.node.directives.length;r<o;r++){let a=t.node.directives[r];a.value.value!==n.value&&i.push(a)}t.node.directives=i}function Se(t,n){let i=t.get("body");for(let r=0,o=i.length;r<o;r++){let a=i[r];if(a.node.type==="ExpressionStatement"&&a.node.expression.type==="StringLiteral"&&a.node.expression.value===n.value){a.remove();return}}}function $(t,n){let i=ge(t,n);i&&(xe(n,i),Se(n,i),H(t,n,i))}function z(){return{name:"directive-splitter",visitor:{BlockStatement(t,n){$(n.opts,t)}}}}function Pe(t){let n=[];for(let i=0,r=t.length;i<r;++i){let o=t.charCodeAt(i);if(o<128)n.push(o);else if(o<2048)n.push(192|o>>6,128|o&63);else if(o<55296||o>=57344)n.push(224|o>>12,128|o>>6&63,128|o&63);else{let a=65536+((o&1023)<<10|t.charCodeAt(++i)&1023);n.push(240|a>>18&7,128|a>>12&63,128|a>>6&63,128|a&63)}}return new Uint8Array(n)}function w(t,n=0){t=typeof t=="string"?Pe(t):t;let i=t,r=n+374761393&4294967295,o=0;if(i.length>=16){let s=[n+2654435761+2246822519&4294967295,n+2246822519&4294967295,n+0&4294967295,n-2654435761&4294967295],f=t,u=f.length-16,c=0;for(o=0;(o&4294967280)<=u;o+=4){let m=o,g=f[m+0]+(f[m+1]<<8),S=f[m+2]+(f[m+3]<<8),d=g*2246822519+(S*2246822519<<16),l=s[c]+d&4294967295;l=l<<13|l>>>19;let b=l&65535,p=l>>>16;s[c]=b*2654435761+(p*2654435761<<16)&4294967295,c=c+1&3}r=(s[0]<<1|s[0]>>>31)+(s[1]<<7|s[1]>>>25)+(s[2]<<12|s[2]>>>20)+(s[3]<<18|s[3]>>>14)&4294967295}r=r+t.length&4294967295;let a=t.length-4;for(;o<=a;o+=4){let s=o,f=i[s+0]+(i[s+1]<<8),u=i[s+2]+(i[s+3]<<8),c=f*3266489917+(u*3266489917<<16);r=r+c&4294967295,r=r<<17|r>>>15,r=(r&65535)*668265263+((r>>>16)*668265263<<16)&4294967295}for(;o<i.length;++o){let s=i[o];r+=s*374761393,r=r<<11|r>>>21,r=(r&65535)*2654435761+((r>>>16)*2654435761<<16)&4294967295}return r^=r>>>15,r=((r&65535)*2246822519&4294967295)+((r>>>16)*2246822519<<16),r^=r>>>13,r=((r&65535)*3266489917&4294967295)+((r>>>16)*3266489917<<16),r^=r>>>16,r<0?r+4294967296:r}async function Je(t,n,i){let r=_.parse(n),o=[],a=new Map,s={path:r,imports:new Map,virtual:{count:0},options:i,bindings:new Map,blocks:{hash:w(n).toString(16),count:0},onVirtualFile(c,m){a.set(_.join(r.dir,c),m)},onEntryFile(c){o.push(_.join(r.dir,c))}},f=["jsx"];/\.[mc]?tsx?$/i.test(n)&&f.push("typescript");let u=await q.transformAsync(t,{plugins:[[z,s]],parserOpts:{plugins:f},filename:r.base,ast:!1,sourceFileName:n,sourceMaps:!0,configFile:!1,babelrc:!1});return D(u,"invariant"),{code:u.code,map:u.map,files:a,entries:o}}export{Je as compile};
import*as X from"@babel/core";import V from"path";function y(t,n){if(!t)throw new Error(n)}import*as e from"@babel/types";import*as M from"@babel/types";function L(t,n,i,r){if(n.scope.hasGlobal(i))return!1;if(t===n)return!0;if(n.scope.hasOwnBinding(i)){if(r==="block"){let o=n.scope.getBinding(i);return!!o&&o.kind==="param"}return!1}return n.parentPath?L(t,n.parentPath,i,r):!0}function te(t){let n=t.parentPath;for(;n;){if(M.isTypeScript(n.node)&&!M.isExpression(n.node))return!0;n=n.parentPath}return!1}function I(t,n){let i=new Set;return t.traverse({ReferencedIdentifier(r){!te(r)&&(n==="expression"?!t.scope.hasGlobal(r.node.name):L(t,r,r.node.name,n))&&i.add(r.node.name)}}),i}function U(t,n){let i=t;for(;i;){switch(i.node.type){case"FunctionDeclaration":case"FunctionExpression":{if(i.node.id)return i.node.id.name;break}case"VariableDeclarator":{if(i.node.id.type==="Identifier")return i.node.id.name;break}case"ClassPrivateMethod":case"ClassMethod":case"ObjectMethod":{switch(i.node.key.type){case"Identifier":return i.node.key.name;case"PrivateName":return i.node.key.id.name;default:break}break}default:break}i=i.parentPath}return n}import C from"@babel/generator";var ne=typeof C!="function"?C.default:C,v=ne;import*as A from"@babel/types";function R(t){let n=t.parentPath;for(;n;){let i=n.parentPath;if(i&&A.isProgram(i.node))return n;n=i}return t}import*as k from"@babel/types";function O(t){switch(t.imported.type){case"Identifier":return t.imported.name;case"StringLiteral":return t.imported.value}}function b(t,n){return n(t.node)}function ie(t){switch(t.type){case"ParenthesizedExpression":case"TypeCastExpression":case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":case"TSInstantiationExpression":return!0;default:return!1}}function w(t,n){if(b(t,n))return t;if(b(t,ie))return w(t.get("expression"),n)}function K(t){y(b(t,k.isImportSpecifier)||b(t,k.isImportDefaultSpecifier)||b(t,k.isImportNamespaceSpecifier),"invariant");let i=t.getStatementParent().node.source.value;switch(t.node.type){case"ImportDefaultSpecifier":return{source:i,kind:"default",local:t.node.local.name};case"ImportNamespaceSpecifier":return{source:i,kind:"namespace",local:t.node.local.name};case"ImportSpecifier":{let r=O(t.node);return r==="default"?{source:i,kind:"default",local:t.node.local.name,imported:""}:{source:i,kind:"named",local:t.node.local.name,imported:r}}}}import*as j from"@babel/types";function re(t){let n=[];for(let i=0,r=t.elements.length;i<r;i++){let o=t.elements[i];o&&n.push(...h(o))}return n}function oe(t){let n=[];for(let i=0,r=t.properties.length;i<r;i++){let o=t.properties[i];o&&(o.type==="RestElement"?n.push(...h(o)):j.isLVal(o.value)&&n.push(...h(o.value)))}return n}function h(t){switch(t.type){case"Identifier":return[t.name];case"ArrayPattern":return re(t);case"AssignmentPattern":return h(t.left);case"ObjectPattern":return oe(t);case"RestElement":return h(t.argument);default:return[]}}function ae(t){switch(t.kind){case"default":return e.importDefaultSpecifier(e.identifier(t.local));case"named":return e.importSpecifier(e.identifier(t.local),t.imported?e.identifier(t.imported):e.identifier(t.local));case"namespace":return e.importNamespaceSpecifier(e.identifier(t.local))}}function Y(t){return e.importDeclaration([ae(t)],e.stringLiteral(t.source))}function N(t){let n=[];for(let i=0,r=t.length;i<r;i++)n[i]=Y(t[i]);return n}function se(t){switch(t){case"let":case"var":case"param":return!0;case"const":case"hoisted":case"local":case"module":case"unknown":return!1}}function le(t,n,i,r){let o=t.bindings.get(i);if(o)n.push(o);else if(b(r.path,e.isVariableDeclarator)){let a=ue(t,r.path);for(let s=0,f=a.length;s<f;s++)n.push(a[s]),t.bindings.set(a[s].local,a[s])}else if(b(r.path,e.isFunctionDeclaration)){let a=ce(t,r.path);n.push(a),t.bindings.set(a.local,a)}}function fe(t,n,i,r,o,a){if(a.kind==="module")n.push(K(a.path));else if(a.kind==="param")i.push(a.identifier);else{let s=a.path.scope.getBlockParent(),f=a.path.scope.getProgramParent();s===f?le(t,n,o,a):(i.push(a.identifier),se(a.kind)&&r.push(a.identifier))}}function _(t,n,i){let r=[],o=[],a=[];for(let s of i){let f=n.scope.getBinding(s);f&&fe(t,r,o,a,s,f)}return{modules:r,locals:o,mutations:a}}function F(t){return`./${t.path.base}?directive=${t.virtual.count++}${t.path.ext}`}function ce(t,n){let i=I(n,"function"),{modules:r}=_(t,n,i),o=F(t),a=v(e.program([...N(r),e.exportDefaultDeclaration(n.node)]));t.onVirtualFile(o,a.code,"none");let s=R(n),p={kind:"default",local:(n.node.id||n.scope.generateUidIdentifier("func")).name,source:o};return s.insertBefore(Y(p)),n.remove(),p}function ue(t,n){let i=w(n.get("init"),e.isExpression),r=i?_(t,n,I(n,b(i,e.isArrowFunctionExpression)||b(i,e.isFunctionExpression)?"function":"expression")).modules:[],o=F(t),a=n.parentPath.node,s=v(e.program([...N(r),e.exportNamedDeclaration(e.variableDeclaration(a.kind,[n.node]))]));t.onVirtualFile(o,s.code,"none");let f=h(n.node.id).map(c=>({kind:"named",local:c,source:o})),p=R(n);return p&&p.insertBefore(N(f)),n.remove(),f}var $=e.numericLiteral(0),G=e.numericLiteral(1),H=e.numericLiteral(2),pe=e.numericLiteral(3),W=e.numericLiteral(4);function me(t,n){let i=t.scope.getFunctionParent()||t.scope.getProgramParent(),r=[],o=0,a=[],s=0,f=!1,p=!1,c=n.length?t.scope.generateUidIdentifier("mutate"):void 0;t.traverse({BreakStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){let u=[$];if(o++,l.node.label){let P=l.node.label.name;r.push(P),u.push(e.stringLiteral(P))}else u.push(e.nullLiteral());c&&u.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(u))),l.skip()}},ContinueStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){let u=[G];if(s++,l.node.label){let P=l.node.label.name;a.push(P),u.push(e.stringLiteral(P))}else u.push(e.nullLiteral());c&&u.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(u))),l.skip()}},ReturnStatement(l){if((l.scope.getFunctionParent()||l.scope.getProgramParent())===i){f=!0;let u=[H];l.node.argument?u.push(l.node.argument):u.push(e.nullLiteral()),c&&u.push(e.callExpression(c,[])),l.replaceWith(e.returnStatement(e.arrayExpression(u))),l.skip()}},YieldExpression(l){(l.scope.getFunctionParent()||l.scope.getProgramParent())===i&&(p=!0)}});let d=t.scope.generateUidIdentifier("error"),x=[W,d],g=[pe];c&&(x.push(e.callExpression(c,[])),g.push(e.nullLiteral()),g.push(e.callExpression(c,[])));let m=[e.tryStatement(e.blockStatement(t.node.body),e.catchClause(d,e.blockStatement([e.returnStatement(e.arrayExpression(x))]))),e.returnStatement(e.arrayExpression(g))];return c&&m.unshift(e.variableDeclaration("const",[e.variableDeclarator(c,e.arrowFunctionExpression([],e.objectExpression(n.map(l=>e.objectProperty(l,l,!1,!0)))))])),t.node.body=m,{breaks:r,continues:a,hasReturn:f,hasYield:p,breakCount:o,continueCount:s}}function de(t,n,i,r,o){let a;i!==r.length&&(a=e.blockStatement([e.breakStatement()]));for(let s=0,f=r.length;s<f;s++){let p=r[s];a=e.blockStatement([e.ifStatement(e.binaryExpression("===",n,e.stringLiteral(p)),e.blockStatement([e.breakStatement(e.identifier(p))]),a)])}return a?e.ifStatement(e.binaryExpression("===",t,$),a,o):o}function be(t,n,i,r,o){let a;i!==r.length&&(a=e.blockStatement([e.continueStatement()]));for(let s=0,f=r.length;s<f;s++){let p=r[s];a=e.blockStatement([e.ifStatement(e.binaryExpression("===",n,e.stringLiteral(p)),e.blockStatement([e.continueStatement(e.identifier(p))]),a)])}return a?e.ifStatement(e.binaryExpression("===",t,G),a,o):o}function ge(t,n,i){let r=t.scope.generateUidIdentifier("iterator"),o=t.scope.generateUidIdentifier("step");return[[e.variableDeclaration("let",[e.variableDeclarator(o),e.variableDeclarator(r,e.awaitExpression(e.callExpression(n,i)))]),e.whileStatement(e.booleanLiteral(!0),e.blockStatement([e.expressionStatement(e.assignmentExpression("=",o,e.callExpression(e.memberExpression(r,e.identifier("next")),[]))),e.ifStatement(e.memberExpression(o,e.identifier("done")),e.blockStatement([e.breakStatement()]),e.blockStatement([e.expressionStatement(e.yieldExpression(e.memberExpression(o,e.identifier("value"))))]))]))],o]}function xe(t,n,i,r){let o=me(n,r.mutations),a=F(t),s=v(e.program([...t.options.mode==="server"?N(r.modules):[],e.exportDefaultDeclaration(e.functionExpression(void 0,r.locals,e.blockStatement(n.node.body),o.hasYield,!0))]));t.onVirtualFile(a,s.code,"root");let f=`${t.blocks.hash}-${t.blocks.count++}`;t.options.env!=="production"&&(f+=`-${U(n,"anonymous")}`);let p=n.scope.generateUidIdentifier("entry"),c=[{kind:i.import.kind,source:i.import.source,local:p.name,imported:i.import.kind==="named"?i.import.name:void 0}],d=[e.stringLiteral(f)];if(t.options.mode==="server"){let E=n.scope.generateUidIdentifier("root");c.push({kind:"default",source:a,local:E.name}),d.push(E)}let x=F(t),g=v(e.program([...N(c),e.exportDefaultDeclaration(e.callExpression(p,d))]));t.onVirtualFile(x,g.code,"entry");let m=n.scope.generateUidIdentifier("type"),l=n.scope.generateUidIdentifier("result"),S=n.scope.generateUidIdentifier("mutations"),u=e.ifStatement(e.binaryExpression("===",m,W),e.blockStatement([e.throwStatement(l)]));o.hasReturn&&(u=e.ifStatement(e.binaryExpression("===",m,H),e.blockStatement([e.returnStatement(l)]),u)),o.breakCount>0&&(u=de(m,l,o.breakCount,o.breaks,u)),o.continueCount>0&&(u=be(m,l,o.continueCount,o.continues,u));let P=n.scope.generateUidIdentifier("block"),D=[e.variableDeclaration("const",[e.variableDeclarator(P,e.memberExpression(e.awaitExpression(e.importExpression(e.stringLiteral(x))),e.identifier("default")))])];if(o.hasYield){let[E,Z]=ge(n,P,r.locals);for(let B=0,ee=E.length;B<ee;B++)D.push(E[B]);D.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([m,l,S]),e.memberExpression(Z,e.identifier("value")))]))}else D.push(e.variableDeclaration("const",[e.variableDeclarator(e.arrayPattern([m,l,S]),e.awaitExpression(e.callExpression(P,r.locals)))]));r.mutations.length&&D.push(e.expressionStatement(e.assignmentExpression("=",e.objectPattern(r.mutations.map(E=>e.objectProperty(E,E,!1,!0))),S))),u&&D.push(u),n.replaceWith(e.blockStatement(D))}function z(t,n,i){xe(t,n,i,_(t,n,I(n,"block")))}function q(t,n){for(let i=0,r=t.options.directives.length;i<r;i++){let o=t.options.directives[i];if(o.value===n)return o}}function Se(t,n){for(let i=0,r=n.node.directives.length;i<r;i++){let o=n.node.directives[i].value.value,a=q(t,o);if(a)return a}}function Pe(t,n){for(let i=0,r=n.node.body.length;i<r;i++){let o=n.node.body[i];if(o.type==="ExpressionStatement"&&o.expression.type==="StringLiteral"){let a=q(t,o.expression.value);if(a)return a}else break}}function Ee(t,n){let i=n.getFunctionParent();if(!(i&&!i.node.async))return Se(t,n)||Pe(t,n)}function he(t,n){let i=[];for(let r=0,o=t.node.directives.length;r<o;r++){let a=t.node.directives[r];a.value.value!==n.value&&i.push(a)}t.node.directives=i}function De(t,n){let i=t.get("body");for(let r=0,o=i.length;r<o;r++){let a=i[r];if(a.node.type==="ExpressionStatement"&&a.node.expression.type==="StringLiteral"&&a.node.expression.value===n.value){a.remove();return}}}function J(t,n){let i=Ee(t,n);i&&(he(n,i),De(n,i),z(t,n,i))}function Q(){return{name:"directive-splitter",visitor:{BlockStatement(t,n){J(n.opts,t)}}}}function ke(t){let n=[];for(let i=0,r=t.length;i<r;++i){let o=t.charCodeAt(i);if(o<128)n.push(o);else if(o<2048)n.push(192|o>>6,128|o&63);else if(o<55296||o>=57344)n.push(224|o>>12,128|o>>6&63,128|o&63);else{let a=65536+((o&1023)<<10|t.charCodeAt(++i)&1023);n.push(240|a>>18&7,128|a>>12&63,128|a>>6&63,128|a&63)}}return new Uint8Array(n)}function T(t,n=0){t=typeof t=="string"?ke(t):t;let i=t,r=n+374761393&4294967295,o=0;if(i.length>=16){let s=[n+2654435761+2246822519&4294967295,n+2246822519&4294967295,n+0&4294967295,n-2654435761&4294967295],f=t,p=f.length-16,c=0;for(o=0;(o&4294967280)<=p;o+=4){let d=o,x=f[d+0]+(f[d+1]<<8),g=f[d+2]+(f[d+3]<<8),m=x*2246822519+(g*2246822519<<16),l=s[c]+m&4294967295;l=l<<13|l>>>19;let S=l&65535,u=l>>>16;s[c]=S*2654435761+(u*2654435761<<16)&4294967295,c=c+1&3}r=(s[0]<<1|s[0]>>>31)+(s[1]<<7|s[1]>>>25)+(s[2]<<12|s[2]>>>20)+(s[3]<<18|s[3]>>>14)&4294967295}r=r+t.length&4294967295;let a=t.length-4;for(;o<=a;o+=4){let s=o,f=i[s+0]+(i[s+1]<<8),p=i[s+2]+(i[s+3]<<8),c=f*3266489917+(p*3266489917<<16);r=r+c&4294967295,r=r<<17|r>>>15,r=(r&65535)*668265263+((r>>>16)*668265263<<16)&4294967295}for(;o<i.length;++o){let s=i[o];r+=s*374761393,r=r<<11|r>>>21,r=(r&65535)*2654435761+((r>>>16)*2654435761<<16)&4294967295}return r^=r>>>15,r=((r&65535)*2246822519&4294967295)+((r>>>16)*2246822519<<16),r^=r>>>13,r=((r&65535)*3266489917&4294967295)+((r>>>16)*3266489917<<16),r^=r>>>16,r<0?r+4294967296:r}async function et(t,n,i){let r=V.parse(n),o=[],a=[],s=new Map,f={path:r,imports:new Map,virtual:{count:0},options:i,bindings:new Map,blocks:{hash:T(n).toString(16),count:0},onVirtualFile(d,x,g){let m=V.join(r.dir,d);s.set(V.join(r.dir,d),x),g==="entry"?o.push(m):g==="root"&&a.push(m)}},p=["jsx"];/\.[mc]?tsx?$/i.test(n)&&p.push("typescript");let c=await X.transformAsync(t,{plugins:[[Q,f]],parserOpts:{plugins:p},filename:r.base,ast:!1,sourceFileName:n,sourceMaps:!0,configFile:!1,babelrc:!1});return y(c,"invariant"),{code:c.code,map:c.map,files:s,entries:o,roots:a}}export{et as compile};

@@ -8,2 +8,3 @@ import * as babel from '@babel/core';

entries: string[];
roots: string[];
}

@@ -10,0 +11,0 @@ export { NamedImportDefinition, DefaultImportDefinition, DirectiveDefinition, ImportDefinition, Options, } from './types';

@@ -1,1 +0,1 @@

{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AAErC,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,SAAS,CAAC;AAKrD,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IACpC,GAAG,EAAE,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAClC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,OAAO,GACR,MAAM,SAAS,CAAC;AAEjB,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,CAAC,CAqDjB"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AAErC,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,SAAS,CAAC;AAKrD,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IACpC,GAAG,EAAE,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAClC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,OAAO,GACR,MAAM,SAAS,CAAC;AAEjB,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,CAAC,CA0DjB"}

@@ -1,1 +0,1 @@

{"version":3,"file":"split.d.ts","sourceRoot":"","sources":["../../src/split.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAoB,YAAY,EAAE,MAAM,SAAS,CAAC;AAynB9E,wBAAgB,UAAU,CACxB,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,EACtC,SAAS,EAAE,mBAAmB,GAC7B,IAAI,CAON"}
{"version":3,"file":"split.d.ts","sourceRoot":"","sources":["../../src/split.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAoB,YAAY,EAAE,MAAM,SAAS,CAAC;AAuoB9E,wBAAgB,UAAU,CACxB,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,EACtC,SAAS,EAAE,mBAAmB,GAC7B,IAAI,CAON"}

@@ -22,3 +22,2 @@ /// <reference types="node" />

directives: DirectiveDefinition[];
getVirtualFileName: (path: path.ParsedPath, count: number) => string;
}

@@ -43,5 +42,4 @@ export interface ModuleDefinition {

options: Options;
onVirtualFile: (path: string, content: string) => void;
onEntryFile: (path: string) => void;
onVirtualFile: (path: string, content: string, mode: 'entry' | 'root' | 'none') => void;
}
//# sourceMappingURL=types.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,CAAC,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAC;AAElC,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,gBAAgB,GAAG,uBAAuB,GAAG,qBAAqB,CAAC;AAE/E,MAAM,WAAW,mBAAmB;IAClC,K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3 @@ "files": [

"module": "./dist/esm/production/index.mjs",
"gitHead": "6c5f7249b39b21723d8c87bbed2cc2c23ac7e838"
"gitHead": "8e369842613820a39d1a27dbb4f2c98ad42bdbfe"
}

@@ -13,2 +13,3 @@ import * as babel from '@babel/core';

entries: string[];
roots: string[];
}

@@ -32,2 +33,3 @@

const entries: string[] = [];
const roots: string[] = [];
const files = new Map<string, string>();

@@ -47,8 +49,11 @@

},
onVirtualFile(current, content) {
onVirtualFile(current, content, mode) {
const filePath = path.join(parsedPath.dir, current);
files.set(path.join(parsedPath.dir, current), content);
if (mode === 'entry') {
entries.push(filePath);
} else if (mode === 'root') {
roots.push(filePath);
}
},
onEntryFile(current) {
entries.push(path.join(parsedPath.dir, current));
},
};

@@ -82,3 +87,4 @@

entries,
roots,
};
}

@@ -137,2 +137,6 @@ import * as t from '@babel/types';

function createVirtualFileName(ctx: StateContext) {
return `./${ctx.path.base}?directive=${ctx.virtual.count++}${ctx.path.ext}`;
}
function splitFunctionDeclaration(

@@ -144,3 +148,3 @@ ctx: StateContext,

const { modules } = extractBindings(ctx, path, bindings);
const file = ctx.options.getVirtualFileName(ctx.path, ctx.virtual.count++);
const file = createVirtualFileName(ctx);
const compiled = generator(

@@ -152,3 +156,3 @@ t.program([

);
ctx.onVirtualFile(file, compiled.code);
ctx.onVirtualFile(file, compiled.code, 'none');

@@ -187,3 +191,3 @@ const statement = getRootStatementPath(path);

: [];
const file = ctx.options.getVirtualFileName(ctx.path, ctx.virtual.count++);
const file = createVirtualFileName(ctx);
const parent = path.parentPath.node as t.VariableDeclaration;

@@ -196,3 +200,3 @@ const compiled = generator(

);
ctx.onVirtualFile(file, compiled.code);
ctx.onVirtualFile(file, compiled.code, 'none');
const definitions: ModuleDefinition[] = getIdentifiersFromLVal(

@@ -498,2 +502,20 @@ path.node.id,

const halting = transformHalting(path, bindings.mutations);
const rootFile = createVirtualFileName(ctx);
const rootContent = generator(
t.program([
...(ctx.options.mode === 'server'
? moduleDefinitionsToImportDeclarations(bindings.modules)
: []),
t.exportDefaultDeclaration(
t.functionExpression(
undefined,
bindings.locals,
t.blockStatement(path.node.body),
halting.hasYield,
true,
),
),
]),
);
ctx.onVirtualFile(rootFile, rootContent.code, 'root');
// Create an ID

@@ -504,37 +526,31 @@ let id = `${ctx.blocks.hash}-${ctx.blocks.count++}`;

}
const entryID = path.scope.generateUidIdentifier('entry');
const entryImports: ModuleDefinition[] = [
{
kind: directive.import.kind,
source: directive.import.source,
local: entryID.name,
imported:
directive.import.kind === 'named' ? directive.import.name : undefined,
},
];
const args: t.Expression[] = [t.stringLiteral(id)];
if (ctx.options.mode === 'server') {
args.push(
t.functionExpression(
undefined,
bindings.locals,
t.blockStatement(path.node.body),
halting.hasYield,
true,
),
);
const rootID = path.scope.generateUidIdentifier('root');
entryImports.push({
kind: 'default',
source: rootFile,
local: rootID.name,
});
args.push(rootID);
}
// Create the registration call
const registrationFile = ctx.options.getVirtualFileName(
ctx.path,
ctx.virtual.count++,
);
const registerID = path.scope.generateUidIdentifier('register');
const registrationContent = generator(
const entryFile = createVirtualFileName(ctx);
const entryContent = generator(
t.program([
...(ctx.options.mode === 'server'
? moduleDefinitionsToImportDeclarations(bindings.modules)
: []),
moduleDefinitionToImportDeclaration({
kind: directive.import.kind,
source: directive.import.source,
local: registerID.name,
imported:
directive.import.kind === 'named' ? directive.import.name : undefined,
}),
t.exportDefaultDeclaration(t.callExpression(registerID, args)),
...moduleDefinitionsToImportDeclarations(entryImports),
t.exportDefaultDeclaration(t.callExpression(entryID, args)),
]),
);
ctx.onEntryFile(registrationFile);
ctx.onVirtualFile(registrationFile, registrationContent.code);
ctx.onVirtualFile(entryFile, entryContent.code, 'entry');

@@ -587,5 +603,3 @@ // Move to the replacement for the server block,

t.memberExpression(
t.awaitExpression(
t.importExpression(t.stringLiteral(registrationFile)),
),
t.awaitExpression(t.importExpression(t.stringLiteral(entryFile))),
t.identifier('default'),

@@ -592,0 +606,0 @@ ),

@@ -26,3 +26,2 @@ import type * as t from '@babel/types';

directives: DirectiveDefinition[];
getVirtualFileName: (path: path.ParsedPath, count: number) => string;
}

@@ -49,4 +48,7 @@

options: Options;
onVirtualFile: (path: string, content: string) => void;
onEntryFile: (path: string) => void;
onVirtualFile: (
path: string,
content: string,
mode: 'entry' | 'root' | 'none',
) => void;
}