unplugin-typegpu 0.1.0-alpha.2 → 0.1.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/babel.cjs +1 -1
  2. package/babel.cjs.map +1 -1
  3. package/babel.js +1 -1
  4. package/chunk-4LM3AL5S.cjs +2 -0
  5. package/chunk-4LM3AL5S.cjs.map +1 -0
  6. package/chunk-AS55AP7V.js +2 -0
  7. package/chunk-AS55AP7V.js.map +1 -0
  8. package/chunk-EDH7U5CG.cjs +2 -0
  9. package/chunk-EDH7U5CG.cjs.map +1 -0
  10. package/chunk-ULMT6YNR.js +2 -0
  11. package/chunk-ULMT6YNR.js.map +1 -0
  12. package/esbuild.cjs +2 -0
  13. package/esbuild.cjs.map +1 -0
  14. package/esbuild.d.cts +10 -0
  15. package/esbuild.d.ts +10 -0
  16. package/esbuild.js +2 -0
  17. package/esbuild.js.map +1 -0
  18. package/farm.cjs +2 -0
  19. package/farm.cjs.map +1 -0
  20. package/farm.d.cts +10 -0
  21. package/farm.d.ts +10 -0
  22. package/farm.js +2 -0
  23. package/farm.js.map +1 -0
  24. package/index.cjs +1 -1
  25. package/index.cjs.map +1 -1
  26. package/index.d.cts +17 -8
  27. package/index.d.ts +17 -8
  28. package/index.js +1 -1
  29. package/index.js.map +1 -1
  30. package/package.json +43 -6
  31. package/rolldown.cjs +2 -0
  32. package/rolldown.cjs.map +1 -0
  33. package/rolldown.d.cts +10 -0
  34. package/rolldown.d.ts +10 -0
  35. package/rolldown.js +2 -0
  36. package/rolldown.js.map +1 -0
  37. package/rollup.cjs +1 -1
  38. package/rollup.cjs.map +1 -1
  39. package/rollup.d.cts +9 -1
  40. package/rollup.d.ts +9 -1
  41. package/rollup.js +1 -1
  42. package/rollup.js.map +1 -1
  43. package/rspack.cjs +2 -0
  44. package/rspack.cjs.map +1 -0
  45. package/rspack.d.cts +10 -0
  46. package/rspack.d.ts +10 -0
  47. package/rspack.js +2 -0
  48. package/rspack.js.map +1 -0
  49. package/vite.cjs +2 -0
  50. package/vite.cjs.map +1 -0
  51. package/vite.d.cts +10 -0
  52. package/vite.d.ts +10 -0
  53. package/vite.js +2 -0
  54. package/vite.js.map +1 -0
  55. package/webpack.cjs +2 -0
  56. package/webpack.cjs.map +1 -0
  57. package/webpack.d.cts +10 -0
  58. package/webpack.d.ts +10 -0
  59. package/webpack.js +2 -0
  60. package/webpack.js.map +1 -0
  61. package/chunk-5MLKKHGO.js +0 -2
  62. package/chunk-5MLKKHGO.js.map +0 -1
  63. package/chunk-5YUXNY4J.cjs +0 -2
  64. package/chunk-5YUXNY4J.cjs.map +0 -1
  65. package/chunk-GN3AXEAX.cjs +0 -2
  66. package/chunk-GN3AXEAX.cjs.map +0 -1
  67. package/chunk-SPKQUOK3.cjs +0 -2
  68. package/chunk-SPKQUOK3.cjs.map +0 -1
  69. package/chunk-VSVKZFFD.js +0 -2
  70. package/chunk-VSVKZFFD.js.map +0 -1
  71. package/chunk-XWE2EDOE.js +0 -2
  72. package/chunk-XWE2EDOE.js.map +0 -1
  73. package/rollup-C-ISXvlZ.d.cts +0 -16
  74. package/rollup-C-ISXvlZ.d.ts +0 -16
package/babel.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkSPKQUOK3cjs = require('./chunk-SPKQUOK3.cjs');require('./chunk-5YUXNY4J.cjs');exports.default = _chunkSPKQUOK3cjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4LM3AL5Scjs = require('./chunk-4LM3AL5S.cjs');exports.default = _chunk4LM3AL5Scjs.e;
2
2
  //# sourceMappingURL=babel.cjs.map
package/babel.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/babel.cjs"],"names":[],"mappings":"AAAA,iIAAwC,sCAAqB","file":"/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/babel.cjs"}
package/babel.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-5MLKKHGO.js";import"./chunk-XWE2EDOE.js";export{a as default};
1
+ import{e as a}from"./chunk-ULMT6YNR.js";export{a as default};
2
2
  //# sourceMappingURL=babel.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }var _standalone = require('@babel/standalone'); var o = _interopRequireWildcard(_standalone);var _tinyestforwgsl = require('tinyest-for-wgsl');function u(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function y(e,r){let t="",p=r;for(;;)if(p.type==="MemberExpression"){if(p.property.type!=="Identifier")break;t=t?`${p.property.name}.${t}`:p.property.name,p=p.object}else if(p.type==="Identifier"){t=t?`${p.name}.${t}`:p.name;break}else break;return e.tgpuAliases.has(t)}var d=/import.*from\s*['"]typegpu.*['"]/g,b=/import\s*\(\s*['"]\s*typegpu.*['"]/g,x=/require\s*\(\s*['"]\s*typegpu.*['"]\s*\)/g;function c(e,r,t){if(t&&!(e!=null&&e.include)){if(!d.test(t)&&!x.test(t)&&!b.test(t))return!0}else if(e!=null&&e.include&&e.include!=="all"&&(!r||!e.include.some(p=>p.test(r))))return!0;return!1}function m(e,r){if(e.source.value==="typegpu")for(let t of e.specifiers)t.type==="ImportDefaultSpecifier"||t.type==="ImportSpecifier"&&t.imported.type==="Identifier"&&t.imported.name==="tgpu"?r.tgpuAliases.add(t.local.name):t.type==="ImportNamespaceSpecifier"&&r.tgpuAliases.add(`${t.local.name}.tgpu`)}function f(e,r){return e.callee.type==="MemberExpression"&&e.arguments.length===1&&e.callee.property.type==="Identifier"&&(e.callee.property.name==="procedure"&&y(r,e.callee.object)||e.callee.property.name==="does")}var g=o.packages.template,n=o.packages.types;function C(e){return{ImportDeclaration(r){m(r.node,e)},CallExpression(r){let t=r.node;if(f(t,e)){let p=t.arguments[0];if(p&&(p.type==="FunctionExpression"||p.type==="ArrowFunctionExpression")){let{argNames:s,body:a,externalNames:i}=_tinyestforwgsl.transpileFn.call(void 0, p);r.replaceWith(n.callExpression(t.callee,[n.callExpression(g.expression("tgpu.__assignAst")(),[p,g.expression`${u({argNames:s,body:a,externalNames:i})}`(),n.objectExpression(i.map(l=>n.objectProperty(n.identifier(l),n.identifier(l))))])])),r.skip()}}}}}function A(){return{visitor:{Program(e,r){var i;let t=(i=r.file)==null?void 0:i.code,p=r.opts,s=r.filename;if(c(p,s,t))return;let a={tgpuAliases:new Set(["tgpu"])};e.traverse(C(a))}}}}exports.a = u; exports.b = c; exports.c = m; exports.d = f; exports.e = A;
2
+ //# sourceMappingURL=chunk-4LM3AL5S.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/babel.ts","../src/common.ts"],"names":["embedJSON","jsValue","isTgpu","ctx","node","path","tail"],"mappings":"AAAA,wbAAuB,kDAIK,SCWZA,CAAAA,CAAUC,CAAAA,CAAkB,CAC1C,OAAO,IAAA,CAAK,SAAA,CAAUA,CAAO,CAAA,CAC1B,OAAA,CAAQ,SAAA,CAAW,SAAS,CAAA,CAC5B,OAAA,CAAQ,SAAA,CAAW,SAAS,CACjC,CAMA,SAASC,CAAAA,CAAOC,CAAAA,CAAcC,CAAAA,CAA2C,CACvE,IAAIC,CAAAA,CAAO,EAAA,CAEPC,CAAAA,CAAOF,CAAAA,CACX,GAAA,CAAA,CAAA,CAAA,CACE,EAAA,CAAIE,CAAAA,CAAK,IAAA,GAAS,kBAAA,CAAoB,CACpC,EAAA,CAAIA,CAAAA,CAAK,QAAA,CAAS,IAAA,GAAS,YAAA,CAEzB,KAAA,CAGFD,CAAAA,CAAOA,CAAAA,CAAO,CAAA,EAAA","file":"/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/chunk-4LM3AL5S.cjs","sourcesContent":["import * as Babel from '@babel/standalone';\nimport type TemplateGenerator from '@babel/template';\nimport type { TraverseOptions } from '@babel/traverse';\nimport type * as t from '@babel/types';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport {\n type Context,\n type TypegpuPluginOptions,\n embedJSON,\n gatherTgpuAliases,\n isDoesCall,\n shouldSkipFile,\n} from './common';\n\n// NOTE: @babel/standalone does expose internal packages, as specified in the docs, but the\n// typing for @babel/standalone does not expose them.\nconst template = (\n Babel as unknown as { packages: { template: typeof TemplateGenerator } }\n).packages.template;\nconst types = (Babel as unknown as { packages: { types: typeof t } }).packages\n .types;\n\nfunction functionVisitor(ctx: Context): TraverseOptions {\n return {\n ImportDeclaration(path) {\n gatherTgpuAliases(path.node, ctx);\n },\n\n CallExpression(path) {\n const node = path.node;\n\n if (isDoesCall(node, ctx)) {\n const implementation = node.arguments[0];\n\n if (\n implementation &&\n (implementation.type === 'FunctionExpression' ||\n implementation.type === 'ArrowFunctionExpression')\n ) {\n const { argNames, body, externalNames } = transpileFn(implementation);\n\n path.replaceWith(\n types.callExpression(node.callee, [\n types.callExpression(template.expression('tgpu.__assignAst')(), [\n implementation,\n template.expression`${embedJSON({ argNames, body, externalNames })}`(),\n types.objectExpression(\n externalNames.map((name) =>\n types.objectProperty(\n types.identifier(name),\n types.identifier(name),\n ),\n ),\n ),\n ]),\n ]),\n );\n\n path.skip();\n }\n }\n },\n };\n}\n\nexport default function () {\n return {\n visitor: {\n Program(path, state) {\n // @ts-ignore\n const code: string | undefined = state.file?.code;\n // @ts-ignore\n const options: TypegpuPluginOptions | undefined = state.opts;\n // @ts-ignore\n const id: string | undefined = state.filename;\n\n if (shouldSkipFile(options, id, code)) {\n return;\n }\n\n const ctx: Context = {\n tgpuAliases: new Set(['tgpu']),\n };\n\n path.traverse(functionVisitor(ctx));\n },\n } satisfies TraverseOptions,\n };\n}\n","import type * as babel from '@babel/types';\nimport type * as acorn from 'acorn';\n\nexport type Context = {\n /**\n * How the `tgpu` object is used in code. Since it can be aliased, we\n * need to catch that and act accordingly.\n */\n tgpuAliases: Set<string>;\n};\n\nexport interface TypegpuPluginOptions {\n include?: 'all' | RegExp[];\n}\n\nexport function embedJSON(jsValue: unknown) {\n return JSON.stringify(jsValue)\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n}\n\n/**\n * Checks if `node` is an alias for the 'tgpu' object, traditionally\n * available via `import tgpu from 'typegpu'`.\n */\nfunction isTgpu(ctx: Context, node: babel.Node | acorn.AnyNode): boolean {\n let path = '';\n\n let tail = node;\n while (true) {\n if (tail.type === 'MemberExpression') {\n if (tail.property.type !== 'Identifier') {\n // Not handling computed expressions.\n break;\n }\n\n path = path ? `${tail.property.name}.${path}` : tail.property.name;\n tail = tail.object;\n } else if (tail.type === 'Identifier') {\n path = path ? `${tail.name}.${path}` : tail.name;\n break;\n } else {\n break;\n }\n }\n\n return ctx.tgpuAliases.has(path);\n}\n\nconst typegpuImportRegex = /import.*from\\s*['\"]typegpu.*['\"]/g;\nconst typegpuDynamicImportRegex = /import\\s*\\(\\s*['\"]\\s*typegpu.*['\"]/g;\nconst typegpuRequireRegex = /require\\s*\\(\\s*['\"]\\s*typegpu.*['\"]\\s*\\)/g;\n\nexport function shouldSkipFile(\n options: TypegpuPluginOptions | undefined,\n id: string | undefined,\n code: string | undefined,\n) {\n if (code && !options?.include) {\n if (\n !typegpuImportRegex.test(code) &&\n !typegpuRequireRegex.test(code) &&\n !typegpuDynamicImportRegex.test(code)\n ) {\n // No imports to `typegpu` or its sub modules, exiting early.\n return true;\n }\n } else if (\n options?.include &&\n options.include !== 'all' &&\n (!id || !options.include.some((pattern) => pattern.test(id)))\n ) {\n return true;\n }\n\n return false;\n}\n\nexport function gatherTgpuAliases(\n node: acorn.ImportDeclaration | babel.ImportDeclaration,\n ctx: Context,\n) {\n if (node.source.value === 'typegpu') {\n for (const spec of node.specifiers) {\n if (\n // The default export of 'typegpu' is the `tgpu` object.\n spec.type === 'ImportDefaultSpecifier' ||\n // Aliasing 'tgpu' while importing, e.g. import { tgpu as t } from 'typegpu';\n (spec.type === 'ImportSpecifier' &&\n spec.imported.type === 'Identifier' &&\n spec.imported.name === 'tgpu')\n ) {\n ctx.tgpuAliases.add(spec.local.name);\n } else if (spec.type === 'ImportNamespaceSpecifier') {\n // Importing everything, e.g. import * as t from 'typegpu';\n ctx.tgpuAliases.add(`${spec.local.name}.tgpu`);\n }\n }\n }\n}\n\nexport function isDoesCall(\n node: acorn.CallExpression | babel.CallExpression,\n ctx: Context,\n) {\n return (\n node.callee.type === 'MemberExpression' &&\n node.arguments.length === 1 &&\n node.callee.property.type === 'Identifier' &&\n ((node.callee.property.name === 'procedure' &&\n isTgpu(ctx, node.callee.object)) ||\n // Assuming that every call to `.does` is related to TypeGPU\n // because shells can be created separately from calls to `tgpu`,\n // making it hard to detect.\n node.callee.property.name === 'does')\n );\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import{a as g,b as m,c,d as f,e as d}from"./chunk-ULMT6YNR.js";import{walk as b}from"estree-walker";import h from"magic-string";import{transpileFn as w}from"tinyest-for-wgsl";import{createUnplugin as F}from"unplugin";var N=y=>({name:"unplugin-typegpu",transform(r,x){if(m(y,x,r))return;let l={tgpuAliases:new Set(["tgpu"])},P=this.parse(r,{allowReturnOutsideFunction:!0}),s=[];b(P,{enter(e,a,u,p){let o=e;if(o.type==="ImportDeclaration"&&c(o,l),o.type==="CallExpression"&&f(o,l)){let i=o.arguments[0];i&&i.type!=="TemplateLiteral"&&i.type!=="Literal"&&s.push({varDecl:o,implementation:i})}}});let n=new h(r);for(let e of s){let{argNames:a,body:u,externalNames:p}=w(e.implementation);n.appendLeft(e.implementation.start,"tgpu.__assignAst("),n.appendRight(e.implementation.end,`, ${g({argNames:a,body:u,externalNames:p})}`),p.length>0?n.appendRight(e.implementation.end,`, {${p.join(", ")}})`):n.appendRight(e.implementation.end,", undefined)")}return{code:n.toString(),map:n.generateMap()}}}),t=F(N),S=t,v=t.vite,R=t.rollup,E=t.rolldown,L=t.webpack,U=t.rspack,_=t.esbuild,M=t.farm,$=d;export{S as a,v as b,R as c,E as d,L as e,U as f,_ as g,M as h,$ as i};
2
+ //# sourceMappingURL=chunk-AS55AP7V.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { AnyNode, CallExpression } from 'acorn';\nimport { type Node, walk } from 'estree-walker';\nimport MagicString from 'magic-string';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport { type UnpluginFactory, createUnplugin } from 'unplugin';\nimport babel from './babel';\nimport {\n type Context,\n type TypegpuPluginOptions,\n embedJSON,\n gatherTgpuAliases,\n isDoesCall,\n shouldSkipFile,\n} from './common';\n\ntype TgslFunctionDef = {\n varDecl: CallExpression;\n implementation: AnyNode;\n};\n\nconst typegpu: UnpluginFactory<TypegpuPluginOptions> = (\n options: TypegpuPluginOptions,\n) => ({\n name: 'unplugin-typegpu' as const,\n transform(code, id) {\n if (shouldSkipFile(options, id, code)) {\n return;\n }\n\n const ctx: Context = {\n tgpuAliases: new Set(['tgpu']),\n };\n\n const ast = this.parse(code, {\n allowReturnOutsideFunction: true,\n }) as Node;\n\n const tgslFunctionDefs: TgslFunctionDef[] = [];\n\n walk(ast, {\n enter(_node, _parent, prop, index) {\n const node = _node as AnyNode;\n\n if (node.type === 'ImportDeclaration') {\n gatherTgpuAliases(node, ctx);\n }\n\n if (node.type === 'CallExpression') {\n if (isDoesCall(node, ctx)) {\n const implementation = node.arguments[0];\n\n if (\n implementation &&\n !(implementation.type === 'TemplateLiteral') &&\n !(implementation.type === 'Literal')\n ) {\n tgslFunctionDefs.push({\n varDecl: node,\n implementation,\n });\n }\n }\n }\n },\n });\n\n const magicString = new MagicString(code);\n\n for (const expr of tgslFunctionDefs) {\n const { argNames, body, externalNames } = transpileFn(\n expr.implementation,\n );\n\n // Wrap the implementation in a call to `tgpu.__assignAst` to associate the AST with the implementation.\n magicString.appendLeft(expr.implementation.start, 'tgpu.__assignAst(');\n magicString.appendRight(\n expr.implementation.end,\n `, ${embedJSON({ argNames, body, externalNames })}`,\n );\n\n if (externalNames.length > 0) {\n magicString.appendRight(\n expr.implementation.end,\n `, {${externalNames.join(', ')}})`,\n );\n } else {\n magicString.appendRight(expr.implementation.end, ', undefined)');\n }\n }\n\n return {\n code: magicString.toString(),\n map: magicString.generateMap(),\n };\n },\n});\n\nconst unplugin = createUnplugin(typegpu);\n\nexport type { TypegpuPluginOptions } from './common';\n\nexport default unplugin;\n\nexport const vitePlugin = unplugin.vite;\nexport const rollupPlugin = unplugin.rollup;\nexport const rolldownPlugin = unplugin.rolldown;\nexport const webpackPlugin = unplugin.webpack;\nexport const rspackPlugin = unplugin.rspack;\nexport const esbuildPlugin = unplugin.esbuild;\nexport const farmPlugin = unplugin.farm;\nexport const babelPlugin = babel;\n"],"mappings":"+DACA,OAAoB,QAAAA,MAAY,gBAChC,OAAOC,MAAiB,eACxB,OAAS,eAAAC,MAAmB,mBAC5B,OAA+B,kBAAAC,MAAsB,WAgBrD,IAAMC,EACJC,IACI,CACJ,KAAM,mBACN,UAAUC,EAAMC,EAAI,CAClB,GAAIC,EAAeH,EAASE,EAAID,CAAI,EAClC,OAGF,IAAMG,EAAe,CACnB,YAAa,IAAI,IAAI,CAAC,MAAM,CAAC,CAC/B,EAEMC,EAAM,KAAK,MAAMJ,EAAM,CAC3B,2BAA4B,EAC9B,CAAC,EAEKK,EAAsC,CAAC,EAE7CC,EAAKF,EAAK,CACR,MAAMG,EAAOC,EAASC,EAAMC,EAAO,CACjC,IAAMC,EAAOJ,EAMb,GAJII,EAAK,OAAS,qBAChBC,EAAkBD,EAAMR,CAAG,EAGzBQ,EAAK,OAAS,kBACZE,EAAWF,EAAMR,CAAG,EAAG,CACzB,IAAMW,EAAiBH,EAAK,UAAU,CAAC,EAGrCG,GACEA,EAAe,OAAS,mBACxBA,EAAe,OAAS,WAE1BT,EAAiB,KAAK,CACpB,QAASM,EACT,eAAAG,CACF,CAAC,CAEL,CAEJ,CACF,CAAC,EAED,IAAMC,EAAc,IAAIC,EAAYhB,CAAI,EAExC,QAAWiB,KAAQZ,EAAkB,CACnC,GAAM,CAAE,SAAAa,EAAU,KAAAC,EAAM,cAAAC,CAAc,EAAIC,EACxCJ,EAAK,cACP,EAGAF,EAAY,WAAWE,EAAK,eAAe,MAAO,mBAAmB,EACrEF,EAAY,YACVE,EAAK,eAAe,IACpB,KAAKK,EAAU,CAAE,SAAAJ,EAAU,KAAAC,EAAM,cAAAC,CAAc,CAAC,CAAC,EACnD,EAEIA,EAAc,OAAS,EACzBL,EAAY,YACVE,EAAK,eAAe,IACpB,MAAMG,EAAc,KAAK,IAAI,CAAC,IAChC,EAEAL,EAAY,YAAYE,EAAK,eAAe,IAAK,cAAc,CAEnE,CAEA,MAAO,CACL,KAAMF,EAAY,SAAS,EAC3B,IAAKA,EAAY,YAAY,CAC/B,CACF,CACF,GAEMQ,EAAWC,EAAe1B,CAAO,EAIhC2B,EAAQF,EAEFG,EAAaH,EAAS,KACtBI,EAAeJ,EAAS,OACxBK,EAAiBL,EAAS,SAC1BM,EAAgBN,EAAS,QACzBO,EAAeP,EAAS,OACxBQ,EAAgBR,EAAS,QACzBS,EAAaT,EAAS,KACtBU,EAAcC","names":["walk","MagicString","transpileFn","createUnplugin","typegpu","options","code","id","shouldSkipFile","ctx","ast","tgslFunctionDefs","walk","_node","_parent","prop","index","node","gatherTgpuAliases","isDoesCall","implementation","magicString","MagicString","expr","argNames","body","externalNames","transpileFn","embedJSON","unplugin","createUnplugin","index_default","vitePlugin","rollupPlugin","rolldownPlugin","webpackPlugin","rspackPlugin","esbuildPlugin","farmPlugin","babelPlugin","babel_default"]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunk4LM3AL5Scjs = require('./chunk-4LM3AL5S.cjs');var _estreewalker = require('estree-walker');var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireDefault(_magicstring);var _tinyestforwgsl = require('tinyest-for-wgsl');var _unplugin = require('unplugin');var N=y=>({name:"unplugin-typegpu",transform(r,x){if(_chunk4LM3AL5Scjs.b.call(void 0, y,x,r))return;let l={tgpuAliases:new Set(["tgpu"])},P=this.parse(r,{allowReturnOutsideFunction:!0}),s=[];_estreewalker.walk.call(void 0, P,{enter(e,a,u,p){let o=e;if(o.type==="ImportDeclaration"&&_chunk4LM3AL5Scjs.c.call(void 0, o,l),o.type==="CallExpression"&&_chunk4LM3AL5Scjs.d.call(void 0, o,l)){let i=o.arguments[0];i&&i.type!=="TemplateLiteral"&&i.type!=="Literal"&&s.push({varDecl:o,implementation:i})}}});let n=new (0, _magicstring2.default)(r);for(let e of s){let{argNames:a,body:u,externalNames:p}=_tinyestforwgsl.transpileFn.call(void 0, e.implementation);n.appendLeft(e.implementation.start,"tgpu.__assignAst("),n.appendRight(e.implementation.end,`, ${_chunk4LM3AL5Scjs.a.call(void 0, {argNames:a,body:u,externalNames:p})}`),p.length>0?n.appendRight(e.implementation.end,`, {${p.join(", ")}})`):n.appendRight(e.implementation.end,", undefined)")}return{code:n.toString(),map:n.generateMap()}}}),t=_unplugin.createUnplugin.call(void 0, N),S= exports.a =t,v= exports.b =t.vite,R= exports.c =t.rollup,E= exports.d =t.rolldown,L= exports.e =t.webpack,U= exports.f =t.rspack,_= exports.g =t.esbuild,M= exports.h =t.farm,$= exports.i =_chunk4LM3AL5Scjs.e;exports.a = S; exports.b = v; exports.c = R; exports.d = E; exports.e = L; exports.f = U; exports.g = _; exports.h = M; exports.i = $;
2
+ //# sourceMappingURL=chunk-EDH7U5CG.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/chunk-EDH7U5CG.cjs","../src/index.ts"],"names":["typegpu","options","code","id","shouldSkipFile","ctx","ast","tgslFunctionDefs","walk","_node","_parent","prop","index","node","gatherTgpuAliases","isDoesCall","implementation","magicString","MagicString","expr","argNames","body","externalNames","transpileFn","embedJSON"],"mappings":"AAAA,iOAA+D,6CCC/B,qGACR,kDACI,oCACyB,IAgB/CA,CAAAA,CACJC,CAAAA,EAAAA,CACI,CACJ,IAAA,CAAM,kBAAA,CACN,SAAA,CAAUC,CAAAA,CAAMC,CAAAA,CAAI,CAClB,EAAA,CAAIC,iCAAAA,CAAeH,CAASE,CAAAA,CAAID,CAAI,CAAA,CAClC,MAAA,CAGF,IAAMG,CAAAA,CAAe,CACnB,WAAA,CAAa,IAAI,GAAA,CAAI,CAAC,MAAM,CAAC,CAC/B,CAAA,CAEMC,CAAAA,CAAM,IAAA,CAAK,KAAA,CAAMJ,CAAAA,CAAM,CAC3B,0BAAA,CAA4B,CAAA,CAC9B,CAAC,CAAA,CAEKK,CAAAA,CAAsC,CAAC,CAAA,CAE7CC,gCAAAA,CAAKF,CAAK,CACR,KAAA,CAAMG,CAAAA,CAAOC,CAAAA,CAASC,CAAAA,CAAMC,CAAAA,CAAO,CACjC,IAAMC,CAAAA,CAAOJ,CAAAA,CAMb,EAAA,CAJII,CAAAA,CAAK,IAAA,GAAS,mBAAA,EAChBC,iCAAAA,CAAkBD,CAAMR,CAAG,CAAA,CAGzBQ,CAAAA,CAAK,IAAA,GAAS,gBAAA,EACZE,iCAAAA,CAAWF,CAAMR,CAAG,CAAA,CAAG,CACzB,IAAMW,CAAAA,CAAiBH,CAAAA,CAAK,SAAA,CAAU,CAAC,CAAA,CAGrCG,CAAAA,EACEA,CAAAA,CAAe,IAAA,GAAS,iBAAA,EACxBA,CAAAA,CAAe,IAAA,GAAS,SAAA,EAE1BT,CAAAA,CAAiB,IAAA,CAAK,CACpB,OAAA,CAASM,CAAAA,CACT,cAAA,CAAAG,CACF,CAAC,CAEL,CAEJ,CACF,CAAC,CAAA,CAED,IAAMC,CAAAA,CAAc,IAAIC,0BAAAA,CAAYhB,CAAI,CAAA,CAExC,GAAA,CAAA,IAAWiB,EAAAA,GAAQZ,CAAAA,CAAkB,CACnC,GAAM,CAAE,QAAA,CAAAa,CAAAA,CAAU,IAAA,CAAAC,CAAAA,CAAM,aAAA,CAAAC,CAAc,CAAA,CAAIC,yCAAAA,CACxCJ,CAAK,cACP,CAAA,CAGAF,CAAAA,CAAY,UAAA,CAAWE,CAAAA,CAAK,cAAA,CAAe,KAAA,CAAO,mBAAmB,CAAA,CACrEF,CAAAA,CAAY,WAAA,CACVE,CAAAA,CAAK,cAAA,CAAe,GAAA,CACpB,CAAA,EAAA,EAAKK,iCAAAA,CAAY,QAAA,CAAAJ,CAAAA,CAAU,IAAA,CAAAC,CAAAA,CAAM,aAAA,CAAAC,CAAc,CAAC,CAAC,CAAA,CAAA","file":"/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/chunk-EDH7U5CG.cjs","sourcesContent":[null,"import type { AnyNode, CallExpression } from 'acorn';\nimport { type Node, walk } from 'estree-walker';\nimport MagicString from 'magic-string';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport { type UnpluginFactory, createUnplugin } from 'unplugin';\nimport babel from './babel';\nimport {\n type Context,\n type TypegpuPluginOptions,\n embedJSON,\n gatherTgpuAliases,\n isDoesCall,\n shouldSkipFile,\n} from './common';\n\ntype TgslFunctionDef = {\n varDecl: CallExpression;\n implementation: AnyNode;\n};\n\nconst typegpu: UnpluginFactory<TypegpuPluginOptions> = (\n options: TypegpuPluginOptions,\n) => ({\n name: 'unplugin-typegpu' as const,\n transform(code, id) {\n if (shouldSkipFile(options, id, code)) {\n return;\n }\n\n const ctx: Context = {\n tgpuAliases: new Set(['tgpu']),\n };\n\n const ast = this.parse(code, {\n allowReturnOutsideFunction: true,\n }) as Node;\n\n const tgslFunctionDefs: TgslFunctionDef[] = [];\n\n walk(ast, {\n enter(_node, _parent, prop, index) {\n const node = _node as AnyNode;\n\n if (node.type === 'ImportDeclaration') {\n gatherTgpuAliases(node, ctx);\n }\n\n if (node.type === 'CallExpression') {\n if (isDoesCall(node, ctx)) {\n const implementation = node.arguments[0];\n\n if (\n implementation &&\n !(implementation.type === 'TemplateLiteral') &&\n !(implementation.type === 'Literal')\n ) {\n tgslFunctionDefs.push({\n varDecl: node,\n implementation,\n });\n }\n }\n }\n },\n });\n\n const magicString = new MagicString(code);\n\n for (const expr of tgslFunctionDefs) {\n const { argNames, body, externalNames } = transpileFn(\n expr.implementation,\n );\n\n // Wrap the implementation in a call to `tgpu.__assignAst` to associate the AST with the implementation.\n magicString.appendLeft(expr.implementation.start, 'tgpu.__assignAst(');\n magicString.appendRight(\n expr.implementation.end,\n `, ${embedJSON({ argNames, body, externalNames })}`,\n );\n\n if (externalNames.length > 0) {\n magicString.appendRight(\n expr.implementation.end,\n `, {${externalNames.join(', ')}})`,\n );\n } else {\n magicString.appendRight(expr.implementation.end, ', undefined)');\n }\n }\n\n return {\n code: magicString.toString(),\n map: magicString.generateMap(),\n };\n },\n});\n\nconst unplugin = createUnplugin(typegpu);\n\nexport type { TypegpuPluginOptions } from './common';\n\nexport default unplugin;\n\nexport const vitePlugin = unplugin.vite;\nexport const rollupPlugin = unplugin.rollup;\nexport const rolldownPlugin = unplugin.rolldown;\nexport const webpackPlugin = unplugin.webpack;\nexport const rspackPlugin = unplugin.rspack;\nexport const esbuildPlugin = unplugin.esbuild;\nexport const farmPlugin = unplugin.farm;\nexport const babelPlugin = babel;\n"]}
@@ -0,0 +1,2 @@
1
+ import*as o from"@babel/standalone";import{transpileFn as k}from"tinyest-for-wgsl";function u(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function y(e,r){let t="",p=r;for(;;)if(p.type==="MemberExpression"){if(p.property.type!=="Identifier")break;t=t?`${p.property.name}.${t}`:p.property.name,p=p.object}else if(p.type==="Identifier"){t=t?`${p.name}.${t}`:p.name;break}else break;return e.tgpuAliases.has(t)}var d=/import.*from\s*['"]typegpu.*['"]/g,b=/import\s*\(\s*['"]\s*typegpu.*['"]/g,x=/require\s*\(\s*['"]\s*typegpu.*['"]\s*\)/g;function c(e,r,t){if(t&&!(e!=null&&e.include)){if(!d.test(t)&&!x.test(t)&&!b.test(t))return!0}else if(e!=null&&e.include&&e.include!=="all"&&(!r||!e.include.some(p=>p.test(r))))return!0;return!1}function m(e,r){if(e.source.value==="typegpu")for(let t of e.specifiers)t.type==="ImportDefaultSpecifier"||t.type==="ImportSpecifier"&&t.imported.type==="Identifier"&&t.imported.name==="tgpu"?r.tgpuAliases.add(t.local.name):t.type==="ImportNamespaceSpecifier"&&r.tgpuAliases.add(`${t.local.name}.tgpu`)}function f(e,r){return e.callee.type==="MemberExpression"&&e.arguments.length===1&&e.callee.property.type==="Identifier"&&(e.callee.property.name==="procedure"&&y(r,e.callee.object)||e.callee.property.name==="does")}var g=o.packages.template,n=o.packages.types;function C(e){return{ImportDeclaration(r){m(r.node,e)},CallExpression(r){let t=r.node;if(f(t,e)){let p=t.arguments[0];if(p&&(p.type==="FunctionExpression"||p.type==="ArrowFunctionExpression")){let{argNames:s,body:a,externalNames:i}=k(p);r.replaceWith(n.callExpression(t.callee,[n.callExpression(g.expression("tgpu.__assignAst")(),[p,g.expression`${u({argNames:s,body:a,externalNames:i})}`(),n.objectExpression(i.map(l=>n.objectProperty(n.identifier(l),n.identifier(l))))])])),r.skip()}}}}}function A(){return{visitor:{Program(e,r){var i;let t=(i=r.file)==null?void 0:i.code,p=r.opts,s=r.filename;if(c(p,s,t))return;let a={tgpuAliases:new Set(["tgpu"])};e.traverse(C(a))}}}}export{u as a,c as b,m as c,f as d,A as e};
2
+ //# sourceMappingURL=chunk-ULMT6YNR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/babel.ts","../src/common.ts"],"sourcesContent":["import * as Babel from '@babel/standalone';\nimport type TemplateGenerator from '@babel/template';\nimport type { TraverseOptions } from '@babel/traverse';\nimport type * as t from '@babel/types';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport {\n type Context,\n type TypegpuPluginOptions,\n embedJSON,\n gatherTgpuAliases,\n isDoesCall,\n shouldSkipFile,\n} from './common';\n\n// NOTE: @babel/standalone does expose internal packages, as specified in the docs, but the\n// typing for @babel/standalone does not expose them.\nconst template = (\n Babel as unknown as { packages: { template: typeof TemplateGenerator } }\n).packages.template;\nconst types = (Babel as unknown as { packages: { types: typeof t } }).packages\n .types;\n\nfunction functionVisitor(ctx: Context): TraverseOptions {\n return {\n ImportDeclaration(path) {\n gatherTgpuAliases(path.node, ctx);\n },\n\n CallExpression(path) {\n const node = path.node;\n\n if (isDoesCall(node, ctx)) {\n const implementation = node.arguments[0];\n\n if (\n implementation &&\n (implementation.type === 'FunctionExpression' ||\n implementation.type === 'ArrowFunctionExpression')\n ) {\n const { argNames, body, externalNames } = transpileFn(implementation);\n\n path.replaceWith(\n types.callExpression(node.callee, [\n types.callExpression(template.expression('tgpu.__assignAst')(), [\n implementation,\n template.expression`${embedJSON({ argNames, body, externalNames })}`(),\n types.objectExpression(\n externalNames.map((name) =>\n types.objectProperty(\n types.identifier(name),\n types.identifier(name),\n ),\n ),\n ),\n ]),\n ]),\n );\n\n path.skip();\n }\n }\n },\n };\n}\n\nexport default function () {\n return {\n visitor: {\n Program(path, state) {\n // @ts-ignore\n const code: string | undefined = state.file?.code;\n // @ts-ignore\n const options: TypegpuPluginOptions | undefined = state.opts;\n // @ts-ignore\n const id: string | undefined = state.filename;\n\n if (shouldSkipFile(options, id, code)) {\n return;\n }\n\n const ctx: Context = {\n tgpuAliases: new Set(['tgpu']),\n };\n\n path.traverse(functionVisitor(ctx));\n },\n } satisfies TraverseOptions,\n };\n}\n","import type * as babel from '@babel/types';\nimport type * as acorn from 'acorn';\n\nexport type Context = {\n /**\n * How the `tgpu` object is used in code. Since it can be aliased, we\n * need to catch that and act accordingly.\n */\n tgpuAliases: Set<string>;\n};\n\nexport interface TypegpuPluginOptions {\n include?: 'all' | RegExp[];\n}\n\nexport function embedJSON(jsValue: unknown) {\n return JSON.stringify(jsValue)\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n}\n\n/**\n * Checks if `node` is an alias for the 'tgpu' object, traditionally\n * available via `import tgpu from 'typegpu'`.\n */\nfunction isTgpu(ctx: Context, node: babel.Node | acorn.AnyNode): boolean {\n let path = '';\n\n let tail = node;\n while (true) {\n if (tail.type === 'MemberExpression') {\n if (tail.property.type !== 'Identifier') {\n // Not handling computed expressions.\n break;\n }\n\n path = path ? `${tail.property.name}.${path}` : tail.property.name;\n tail = tail.object;\n } else if (tail.type === 'Identifier') {\n path = path ? `${tail.name}.${path}` : tail.name;\n break;\n } else {\n break;\n }\n }\n\n return ctx.tgpuAliases.has(path);\n}\n\nconst typegpuImportRegex = /import.*from\\s*['\"]typegpu.*['\"]/g;\nconst typegpuDynamicImportRegex = /import\\s*\\(\\s*['\"]\\s*typegpu.*['\"]/g;\nconst typegpuRequireRegex = /require\\s*\\(\\s*['\"]\\s*typegpu.*['\"]\\s*\\)/g;\n\nexport function shouldSkipFile(\n options: TypegpuPluginOptions | undefined,\n id: string | undefined,\n code: string | undefined,\n) {\n if (code && !options?.include) {\n if (\n !typegpuImportRegex.test(code) &&\n !typegpuRequireRegex.test(code) &&\n !typegpuDynamicImportRegex.test(code)\n ) {\n // No imports to `typegpu` or its sub modules, exiting early.\n return true;\n }\n } else if (\n options?.include &&\n options.include !== 'all' &&\n (!id || !options.include.some((pattern) => pattern.test(id)))\n ) {\n return true;\n }\n\n return false;\n}\n\nexport function gatherTgpuAliases(\n node: acorn.ImportDeclaration | babel.ImportDeclaration,\n ctx: Context,\n) {\n if (node.source.value === 'typegpu') {\n for (const spec of node.specifiers) {\n if (\n // The default export of 'typegpu' is the `tgpu` object.\n spec.type === 'ImportDefaultSpecifier' ||\n // Aliasing 'tgpu' while importing, e.g. import { tgpu as t } from 'typegpu';\n (spec.type === 'ImportSpecifier' &&\n spec.imported.type === 'Identifier' &&\n spec.imported.name === 'tgpu')\n ) {\n ctx.tgpuAliases.add(spec.local.name);\n } else if (spec.type === 'ImportNamespaceSpecifier') {\n // Importing everything, e.g. import * as t from 'typegpu';\n ctx.tgpuAliases.add(`${spec.local.name}.tgpu`);\n }\n }\n }\n}\n\nexport function isDoesCall(\n node: acorn.CallExpression | babel.CallExpression,\n ctx: Context,\n) {\n return (\n node.callee.type === 'MemberExpression' &&\n node.arguments.length === 1 &&\n node.callee.property.type === 'Identifier' &&\n ((node.callee.property.name === 'procedure' &&\n isTgpu(ctx, node.callee.object)) ||\n // Assuming that every call to `.does` is related to TypeGPU\n // because shells can be created separately from calls to `tgpu`,\n // making it hard to detect.\n node.callee.property.name === 'does')\n );\n}\n"],"mappings":"AAAA,UAAYA,MAAW,oBAIvB,OAAS,eAAAC,MAAmB,mBCWrB,SAASC,EAAUC,EAAkB,CAC1C,OAAO,KAAK,UAAUA,CAAO,EAC1B,QAAQ,UAAW,SAAS,EAC5B,QAAQ,UAAW,SAAS,CACjC,CAMA,SAASC,EAAOC,EAAcC,EAA2C,CACvE,IAAIC,EAAO,GAEPC,EAAOF,EACX,OACE,GAAIE,EAAK,OAAS,mBAAoB,CACpC,GAAIA,EAAK,SAAS,OAAS,aAEzB,MAGFD,EAAOA,EAAO,GAAGC,EAAK,SAAS,IAAI,IAAID,CAAI,GAAKC,EAAK,SAAS,KAC9DA,EAAOA,EAAK,MACd,SAAWA,EAAK,OAAS,aAAc,CACrCD,EAAOA,EAAO,GAAGC,EAAK,IAAI,IAAID,CAAI,GAAKC,EAAK,KAC5C,KACF,KACE,OAIJ,OAAOH,EAAI,YAAY,IAAIE,CAAI,CACjC,CAEA,IAAME,EAAqB,oCACrBC,EAA4B,sCAC5BC,EAAsB,4CAErB,SAASC,EACdC,EACAC,EACAC,EACA,CACA,GAAIA,GAAQ,EAACF,GAAA,MAAAA,EAAS,UACpB,GACE,CAACJ,EAAmB,KAAKM,CAAI,GAC7B,CAACJ,EAAoB,KAAKI,CAAI,GAC9B,CAACL,EAA0B,KAAKK,CAAI,EAGpC,MAAO,WAGTF,GAAA,MAAAA,EAAS,SACTA,EAAQ,UAAY,QACnB,CAACC,GAAM,CAACD,EAAQ,QAAQ,KAAMG,GAAYA,EAAQ,KAAKF,CAAE,CAAC,GAE3D,MAAO,GAGT,MAAO,EACT,CAEO,SAASG,EACdX,EACAD,EACA,CACA,GAAIC,EAAK,OAAO,QAAU,UACxB,QAAWY,KAAQZ,EAAK,WAGpBY,EAAK,OAAS,0BAEbA,EAAK,OAAS,mBACbA,EAAK,SAAS,OAAS,cACvBA,EAAK,SAAS,OAAS,OAEzBb,EAAI,YAAY,IAAIa,EAAK,MAAM,IAAI,EAC1BA,EAAK,OAAS,4BAEvBb,EAAI,YAAY,IAAI,GAAGa,EAAK,MAAM,IAAI,OAAO,CAIrD,CAEO,SAASC,EACdb,EACAD,EACA,CACA,OACEC,EAAK,OAAO,OAAS,oBACrBA,EAAK,UAAU,SAAW,GAC1BA,EAAK,OAAO,SAAS,OAAS,eAC5BA,EAAK,OAAO,SAAS,OAAS,aAC9BF,EAAOC,EAAKC,EAAK,OAAO,MAAM,GAI9BA,EAAK,OAAO,SAAS,OAAS,OAEpC,CDpGA,IAAMc,EAEJ,WAAS,SACLC,EAAgE,WACnE,MAEH,SAASC,EAAgBC,EAA+B,CACtD,MAAO,CACL,kBAAkBC,EAAM,CACtBC,EAAkBD,EAAK,KAAMD,CAAG,CAClC,EAEA,eAAeC,EAAM,CACnB,IAAME,EAAOF,EAAK,KAElB,GAAIG,EAAWD,EAAMH,CAAG,EAAG,CACzB,IAAMK,EAAiBF,EAAK,UAAU,CAAC,EAEvC,GACEE,IACCA,EAAe,OAAS,sBACvBA,EAAe,OAAS,2BAC1B,CACA,GAAM,CAAE,SAAAC,EAAU,KAAAC,EAAM,cAAAC,CAAc,EAAIC,EAAYJ,CAAc,EAEpEJ,EAAK,YACHH,EAAM,eAAeK,EAAK,OAAQ,CAChCL,EAAM,eAAeD,EAAS,WAAW,kBAAkB,EAAE,EAAG,CAC9DQ,EACAR,EAAS,aAAaa,EAAU,CAAE,SAAAJ,EAAU,KAAAC,EAAM,cAAAC,CAAc,CAAC,CAAC,GAAG,EACrEV,EAAM,iBACJU,EAAc,IAAKG,GACjBb,EAAM,eACJA,EAAM,WAAWa,CAAI,EACrBb,EAAM,WAAWa,CAAI,CACvB,CACF,CACF,CACF,CAAC,CACH,CAAC,CACH,EAEAV,EAAK,KAAK,CACZ,CACF,CACF,CACF,CACF,CAEe,SAARW,GAAoB,CACzB,MAAO,CACL,QAAS,CACP,QAAQX,EAAMY,EAAO,CApE3B,IAAAC,EAsEQ,IAAMC,GAA2BD,EAAAD,EAAM,OAAN,YAAAC,EAAY,KAEvCE,EAA4CH,EAAM,KAElDI,EAAyBJ,EAAM,SAErC,GAAIK,EAAeF,EAASC,EAAIF,CAAI,EAClC,OAGF,IAAMf,EAAe,CACnB,YAAa,IAAI,IAAI,CAAC,MAAM,CAAC,CAC/B,EAEAC,EAAK,SAASF,EAAgBC,CAAG,CAAC,CACpC,CACF,CACF,CACF","names":["Babel","transpileFn","embedJSON","jsValue","isTgpu","ctx","node","path","tail","typegpuImportRegex","typegpuDynamicImportRegex","typegpuRequireRegex","shouldSkipFile","options","id","code","pattern","gatherTgpuAliases","spec","isDoesCall","template","types","functionVisitor","ctx","path","gatherTgpuAliases","node","isDoesCall","implementation","argNames","body","externalNames","transpileFn","embedJSON","name","babel_default","state","_a","code","options","id","shouldSkipFile"]}
package/esbuild.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEDH7U5CGcjs = require('./chunk-EDH7U5CG.cjs');require('./chunk-4LM3AL5S.cjs');var l=_chunkEDH7U5CGcjs.g;exports.default = l;
2
+ //# sourceMappingURL=esbuild.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/esbuild.cjs","../src/esbuild.ts"],"names":["esbuild_default","esbuildPlugin"],"mappings":"AAAA,iIAAwC,gCAA6B,ICE9DA,CAAAA,CAAQC,mBAAAA,CAAAA,oBAAAA","file":"/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/esbuild.cjs","sourcesContent":[null,"import { esbuildPlugin } from './index';\n\nexport default esbuildPlugin;\n"]}
package/esbuild.d.cts ADDED
@@ -0,0 +1,10 @@
1
+ import { esbuildPlugin } from './index.cjs';
2
+ import 'rollup';
3
+ import 'unplugin';
4
+ import './babel.cjs';
5
+ import '@babel/traverse';
6
+ import '@babel/types';
7
+
8
+
9
+
10
+ export { esbuildPlugin as default };
package/esbuild.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { esbuildPlugin } from './index.js';
2
+ import 'rollup';
3
+ import 'unplugin';
4
+ import './babel.js';
5
+ import '@babel/traverse';
6
+ import '@babel/types';
7
+
8
+
9
+
10
+ export { esbuildPlugin as default };
package/esbuild.js ADDED
@@ -0,0 +1,2 @@
1
+ import{g as e}from"./chunk-AS55AP7V.js";import"./chunk-ULMT6YNR.js";var l=e;export{l as default};
2
+ //# sourceMappingURL=esbuild.js.map
package/esbuild.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/esbuild.ts"],"sourcesContent":["import { esbuildPlugin } from './index';\n\nexport default esbuildPlugin;\n"],"mappings":"oEAEA,IAAOA,EAAQC","names":["esbuild_default","esbuildPlugin"]}
package/farm.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEDH7U5CGcjs = require('./chunk-EDH7U5CG.cjs');require('./chunk-4LM3AL5S.cjs');var m=_chunkEDH7U5CGcjs.h;exports.default = m;
2
+ //# sourceMappingURL=farm.cjs.map
package/farm.cjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/farm.cjs","../src/farm.ts"],"names":["farm_default","farmPlugin"],"mappings":"AAAA,iIAAwC,gCAA6B,ICE9DA,CAAAA,CAAQC,mBAAAA,CAAAA,oBAAAA","file":"/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/farm.cjs","sourcesContent":[null,"import { farmPlugin } from './index';\n\nexport default farmPlugin;\n"]}
package/farm.d.cts ADDED
@@ -0,0 +1,10 @@
1
+ import { farmPlugin } from './index.cjs';
2
+ import 'rollup';
3
+ import 'unplugin';
4
+ import './babel.cjs';
5
+ import '@babel/traverse';
6
+ import '@babel/types';
7
+
8
+
9
+
10
+ export { farmPlugin as default };
package/farm.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { farmPlugin } from './index.js';
2
+ import 'rollup';
3
+ import 'unplugin';
4
+ import './babel.js';
5
+ import '@babel/traverse';
6
+ import '@babel/types';
7
+
8
+
9
+
10
+ export { farmPlugin as default };
package/farm.js ADDED
@@ -0,0 +1,2 @@
1
+ import{h as r}from"./chunk-AS55AP7V.js";import"./chunk-ULMT6YNR.js";var m=r;export{m as default};
2
+ //# sourceMappingURL=farm.js.map
package/farm.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/farm.ts"],"sourcesContent":["import { farmPlugin } from './index';\n\nexport default farmPlugin;\n"],"mappings":"oEAEA,IAAOA,EAAQC","names":["farm_default","farmPlugin"]}
package/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGN3AXEAXcjs = require('./chunk-GN3AXEAX.cjs');var _chunkSPKQUOK3cjs = require('./chunk-SPKQUOK3.cjs');require('./chunk-5YUXNY4J.cjs');var t={babel:_chunkSPKQUOK3cjs.a,rollup:_chunkGN3AXEAXcjs.a};exports.default = t;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEDH7U5CGcjs = require('./chunk-EDH7U5CG.cjs');require('./chunk-4LM3AL5S.cjs');exports.babelPlugin = _chunkEDH7U5CGcjs.i; exports.default = _chunkEDH7U5CGcjs.a; exports.esbuildPlugin = _chunkEDH7U5CGcjs.g; exports.farmPlugin = _chunkEDH7U5CGcjs.h; exports.rolldownPlugin = _chunkEDH7U5CGcjs.d; exports.rollupPlugin = _chunkEDH7U5CGcjs.c; exports.rspackPlugin = _chunkEDH7U5CGcjs.f; exports.vitePlugin = _chunkEDH7U5CGcjs.b; exports.webpackPlugin = _chunkEDH7U5CGcjs.e;
2
2
  //# sourceMappingURL=index.cjs.map
package/index.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["src_default","babel_default","typegpu"],"mappings":"+GAKA,IAAOA,EAAQ,CACb,MAAAC,EACA,OAAAC,CACF","sourcesContent":["import babel from './babel';\nimport rollup from './rollup';\n\nexport type { TypegpuPluginOptions } from './common';\n\nexport default {\n babel,\n rollup,\n};\n"]}
1
+ {"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/index.cjs"],"names":[],"mappings":"AAAA,iIAAmD,gCAA6B,qYAAoK","file":"/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/index.cjs"}
package/index.d.cts CHANGED
@@ -1,13 +1,22 @@
1
+ import * as rollup from 'rollup';
2
+ import * as _unplugin from 'unplugin';
1
3
  import export_default from './babel.cjs';
2
- import { t as typegpu } from './rollup-C-ISXvlZ.cjs';
3
- export { T as TypegpuPluginOptions } from './rollup-C-ISXvlZ.cjs';
4
4
  import '@babel/traverse';
5
5
  import '@babel/types';
6
- import 'rollup';
7
6
 
8
- declare const _default: {
9
- babel: typeof export_default;
10
- rollup: typeof typegpu;
11
- };
7
+ interface TypegpuPluginOptions {
8
+ include?: 'all' | RegExp[];
9
+ }
12
10
 
13
- export { _default as default };
11
+ declare const unplugin: _unplugin.UnpluginInstance<TypegpuPluginOptions, boolean>;
12
+
13
+ declare const vitePlugin: (options: TypegpuPluginOptions) => _unplugin.VitePlugin<any> | _unplugin.VitePlugin<any>[];
14
+ declare const rollupPlugin: (options: TypegpuPluginOptions) => rollup.Plugin<any> | rollup.Plugin<any>[];
15
+ declare const rolldownPlugin: (options: TypegpuPluginOptions) => any;
16
+ declare const webpackPlugin: (options: TypegpuPluginOptions) => WebpackPluginInstance;
17
+ declare const rspackPlugin: (options: TypegpuPluginOptions) => RspackPluginInstance;
18
+ declare const esbuildPlugin: (options: TypegpuPluginOptions) => _unplugin.EsbuildPlugin;
19
+ declare const farmPlugin: (options: TypegpuPluginOptions) => JsPlugin;
20
+ declare const babelPlugin: typeof export_default;
21
+
22
+ export { type TypegpuPluginOptions, babelPlugin, unplugin as default, esbuildPlugin, farmPlugin, rolldownPlugin, rollupPlugin, rspackPlugin, vitePlugin, webpackPlugin };
package/index.d.ts CHANGED
@@ -1,13 +1,22 @@
1
+ import * as rollup from 'rollup';
2
+ import * as _unplugin from 'unplugin';
1
3
  import export_default from './babel.js';
2
- import { t as typegpu } from './rollup-C-ISXvlZ.js';
3
- export { T as TypegpuPluginOptions } from './rollup-C-ISXvlZ.js';
4
4
  import '@babel/traverse';
5
5
  import '@babel/types';
6
- import 'rollup';
7
6
 
8
- declare const _default: {
9
- babel: typeof export_default;
10
- rollup: typeof typegpu;
11
- };
7
+ interface TypegpuPluginOptions {
8
+ include?: 'all' | RegExp[];
9
+ }
12
10
 
13
- export { _default as default };
11
+ declare const unplugin: _unplugin.UnpluginInstance<TypegpuPluginOptions, boolean>;
12
+
13
+ declare const vitePlugin: (options: TypegpuPluginOptions) => _unplugin.VitePlugin<any> | _unplugin.VitePlugin<any>[];
14
+ declare const rollupPlugin: (options: TypegpuPluginOptions) => rollup.Plugin<any> | rollup.Plugin<any>[];
15
+ declare const rolldownPlugin: (options: TypegpuPluginOptions) => any;
16
+ declare const webpackPlugin: (options: TypegpuPluginOptions) => WebpackPluginInstance;
17
+ declare const rspackPlugin: (options: TypegpuPluginOptions) => RspackPluginInstance;
18
+ declare const esbuildPlugin: (options: TypegpuPluginOptions) => _unplugin.EsbuildPlugin;
19
+ declare const farmPlugin: (options: TypegpuPluginOptions) => JsPlugin;
20
+ declare const babelPlugin: typeof export_default;
21
+
22
+ export { type TypegpuPluginOptions, babelPlugin, unplugin as default, esbuildPlugin, farmPlugin, rolldownPlugin, rollupPlugin, rspackPlugin, vitePlugin, webpackPlugin };
package/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as p}from"./chunk-VSVKZFFD.js";import{a as o}from"./chunk-5MLKKHGO.js";import"./chunk-XWE2EDOE.js";var t={babel:o,rollup:p};export{t as default};
1
+ import{a,b,c,d,e,f,g,h,i}from"./chunk-AS55AP7V.js";import"./chunk-ULMT6YNR.js";export{i as babelPlugin,a as default,g as esbuildPlugin,h as farmPlugin,d as rolldownPlugin,c as rollupPlugin,f as rspackPlugin,b as vitePlugin,e as webpackPlugin};
2
2
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import babel from './babel';\nimport rollup from './rollup';\n\nexport type { TypegpuPluginOptions } from './common';\n\nexport default {\n babel,\n rollup,\n};\n"],"mappings":"4GAKA,IAAOA,EAAQ,CACb,MAAAC,EACA,OAAAC,CACF","names":["src_default","babel_default","typegpu"]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "unplugin-typegpu",
3
- "version": "0.1.0-alpha.2",
3
+ "version": "0.1.0-alpha.3",
4
4
  "description": "Build plugins for TypeGPU, enabling seamless JavaScript -> WGSL transpilation and improved debugging.",
5
5
  "keywords": [
6
6
  "rollup-plugin",
7
+ "unplugin",
7
8
  "babel-plugin",
8
9
  "vite-plugin",
9
10
  "typegpu",
@@ -16,10 +17,7 @@
16
17
  ],
17
18
  "license": "MIT",
18
19
  "type": "module",
19
- "main": "./index.js",
20
- "types": "./index.d.ts",
21
20
  "exports": {
22
- "./package.json": "./package.json",
23
21
  ".": {
24
22
  "types": "./index.d.ts",
25
23
  "module": "./index.js",
@@ -37,6 +35,42 @@
37
35
  "module": "./babel.js",
38
36
  "import": "./babel.js",
39
37
  "default": "./babel.cjs"
38
+ },
39
+ "./esbuild": {
40
+ "types": "./esbuild.d.ts",
41
+ "module": "./esbuild.js",
42
+ "import": "./esbuild.js",
43
+ "default": "./esbuild.cjs"
44
+ },
45
+ "./farm": {
46
+ "types": "./farm.d.ts",
47
+ "module": "./farm.js",
48
+ "import": "./farm.js",
49
+ "default": "./farm.cjs"
50
+ },
51
+ "./rolldown": {
52
+ "types": "./rolldown.d.ts",
53
+ "module": "./rolldown.js",
54
+ "import": "./rolldown.js",
55
+ "default": "./rolldown.cjs"
56
+ },
57
+ "./rspack": {
58
+ "types": "./rspack.d.ts",
59
+ "module": "./rspack.js",
60
+ "import": "./rspack.js",
61
+ "default": "./rspack.cjs"
62
+ },
63
+ "./vite": {
64
+ "types": "./vite.d.ts",
65
+ "module": "./vite.js",
66
+ "import": "./vite.js",
67
+ "default": "./vite.cjs"
68
+ },
69
+ "./webpack": {
70
+ "types": "./webpack.d.ts",
71
+ "module": "./webpack.js",
72
+ "import": "./webpack.js",
73
+ "default": "./webpack.cjs"
40
74
  }
41
75
  },
42
76
  "sideEffects": false,
@@ -49,11 +83,14 @@
49
83
  },
50
84
  "homepage": "https://typegpu.com",
51
85
  "dependencies": {
52
- "tinyest-for-wgsl": "~0.1.0-alpha.1",
86
+ "@babel/standalone": "^7.26.6",
87
+ "tinyest-for-wgsl": "~0.1.0-alpha.2",
53
88
  "estree-walker": "^3.0.3",
54
89
  "magic-string": "^0.30.11",
55
- "@babel/standalone": "^7.26.6"
90
+ "unplugin": "^2.2.0"
56
91
  },
92
+ "main": "./index.js",
93
+ "types": "./index.d.ts",
57
94
  "private": false,
58
95
  "scripts": {}
59
96
  }
package/rolldown.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEDH7U5CGcjs = require('./chunk-EDH7U5CG.cjs');require('./chunk-4LM3AL5S.cjs');var r=_chunkEDH7U5CGcjs.d;exports.default = r;
2
+ //# sourceMappingURL=rolldown.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/rolldown.cjs","../src/rolldown.ts"],"names":["rolldown_default","rolldownPlugin"],"mappings":"AAAA,iIAAwC,gCAA6B,ICE9DA,CAAAA,CAAQC,mBAAAA,CAAAA,oBAAAA","file":"/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/rolldown.cjs","sourcesContent":[null,"import { rolldownPlugin } from './index';\n\nexport default rolldownPlugin;\n"]}
package/rolldown.d.cts ADDED
@@ -0,0 +1,10 @@
1
+ import { rolldownPlugin } from './index.cjs';
2
+ import 'rollup';
3
+ import 'unplugin';
4
+ import './babel.cjs';
5
+ import '@babel/traverse';
6
+ import '@babel/types';
7
+
8
+
9
+
10
+ export { rolldownPlugin as default };
package/rolldown.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { rolldownPlugin } from './index.js';
2
+ import 'rollup';
3
+ import 'unplugin';
4
+ import './babel.js';
5
+ import '@babel/traverse';
6
+ import '@babel/types';
7
+
8
+
9
+
10
+ export { rolldownPlugin as default };
package/rolldown.js ADDED
@@ -0,0 +1,2 @@
1
+ import{d as o}from"./chunk-AS55AP7V.js";import"./chunk-ULMT6YNR.js";var r=o;export{r as default};
2
+ //# sourceMappingURL=rolldown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/rolldown.ts"],"sourcesContent":["import { rolldownPlugin } from './index';\n\nexport default rolldownPlugin;\n"],"mappings":"oEAEA,IAAOA,EAAQC","names":["rolldown_default","rolldownPlugin"]}
package/rollup.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGN3AXEAXcjs = require('./chunk-GN3AXEAX.cjs');require('./chunk-5YUXNY4J.cjs');exports.default = _chunkGN3AXEAXcjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEDH7U5CGcjs = require('./chunk-EDH7U5CG.cjs');require('./chunk-4LM3AL5S.cjs');var r=_chunkEDH7U5CGcjs.c;exports.default = r;
2
2
  //# sourceMappingURL=rollup.cjs.map
package/rollup.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}
1
+ {"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/rollup.cjs","../src/rollup.ts"],"names":["rollup_default","rollupPlugin"],"mappings":"AAAA,iIAAwC,gCAA6B,ICE9DA,CAAAA,CAAQC,mBAAAA,CAAAA,oBAAAA","file":"/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/rollup.cjs","sourcesContent":[null,"import { rollupPlugin } from './index';\n\nexport default rollupPlugin;\n"]}
package/rollup.d.cts CHANGED
@@ -1,2 +1,10 @@
1
+ import { rollupPlugin } from './index.cjs';
1
2
  import 'rollup';
2
- export { a as TypegpuRollupPlugin, t as default } from './rollup-C-ISXvlZ.cjs';
3
+ import 'unplugin';
4
+ import './babel.cjs';
5
+ import '@babel/traverse';
6
+ import '@babel/types';
7
+
8
+
9
+
10
+ export { rollupPlugin as default };
package/rollup.d.ts CHANGED
@@ -1,2 +1,10 @@
1
+ import { rollupPlugin } from './index.js';
1
2
  import 'rollup';
2
- export { a as TypegpuRollupPlugin, t as default } from './rollup-C-ISXvlZ.js';
3
+ import 'unplugin';
4
+ import './babel.js';
5
+ import '@babel/traverse';
6
+ import '@babel/types';
7
+
8
+
9
+
10
+ export { rollupPlugin as default };
package/rollup.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-VSVKZFFD.js";import"./chunk-XWE2EDOE.js";export{a as default};
1
+ import{c as l}from"./chunk-AS55AP7V.js";import"./chunk-ULMT6YNR.js";var r=l;export{r as default};
2
2
  //# sourceMappingURL=rollup.js.map
package/rollup.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/rollup.ts"],"sourcesContent":["import { rollupPlugin } from './index';\n\nexport default rollupPlugin;\n"],"mappings":"oEAEA,IAAOA,EAAQC","names":["rollup_default","rollupPlugin"]}
package/rspack.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEDH7U5CGcjs = require('./chunk-EDH7U5CG.cjs');require('./chunk-4LM3AL5S.cjs');var p=_chunkEDH7U5CGcjs.f;exports.default = p;
2
+ //# sourceMappingURL=rspack.cjs.map
package/rspack.cjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/rspack.cjs","../src/rspack.ts"],"names":["rspack_default","rspackPlugin"],"mappings":"AAAA,iIAAwC,gCAA6B,ICE9DA,CAAAA,CAAQC,mBAAAA,CAAAA,oBAAAA","file":"/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/rspack.cjs","sourcesContent":[null,"import { rspackPlugin } from './index';\n\nexport default rspackPlugin;\n"]}
package/rspack.d.cts ADDED
@@ -0,0 +1,10 @@
1
+ import { rspackPlugin } from './index.cjs';
2
+ import 'rollup';
3
+ import 'unplugin';
4
+ import './babel.cjs';
5
+ import '@babel/traverse';
6
+ import '@babel/types';
7
+
8
+
9
+
10
+ export { rspackPlugin as default };
package/rspack.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { rspackPlugin } from './index.js';
2
+ import 'rollup';
3
+ import 'unplugin';
4
+ import './babel.js';
5
+ import '@babel/traverse';
6
+ import '@babel/types';
7
+
8
+
9
+
10
+ export { rspackPlugin as default };
package/rspack.js ADDED
@@ -0,0 +1,2 @@
1
+ import{f as r}from"./chunk-AS55AP7V.js";import"./chunk-ULMT6YNR.js";var p=r;export{p as default};
2
+ //# sourceMappingURL=rspack.js.map
package/rspack.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/rspack.ts"],"sourcesContent":["import { rspackPlugin } from './index';\n\nexport default rspackPlugin;\n"],"mappings":"oEAEA,IAAOA,EAAQC","names":["rspack_default","rspackPlugin"]}
package/vite.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEDH7U5CGcjs = require('./chunk-EDH7U5CG.cjs');require('./chunk-4LM3AL5S.cjs');var i=_chunkEDH7U5CGcjs.b;exports.default = i;
2
+ //# sourceMappingURL=vite.cjs.map
package/vite.cjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/vite.cjs","../src/vite.ts"],"names":["vite_default","vitePlugin"],"mappings":"AAAA,iIAAwC,gCAA6B,ICE9DA,CAAAA,CAAQC,mBAAAA,CAAAA,oBAAAA","file":"/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/vite.cjs","sourcesContent":[null,"import { vitePlugin } from './index';\n\nexport default vitePlugin;\n"]}
package/vite.d.cts ADDED
@@ -0,0 +1,10 @@
1
+ import { vitePlugin } from './index.cjs';
2
+ import 'rollup';
3
+ import 'unplugin';
4
+ import './babel.cjs';
5
+ import '@babel/traverse';
6
+ import '@babel/types';
7
+
8
+
9
+
10
+ export { vitePlugin as default };
package/vite.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { vitePlugin } from './index.js';
2
+ import 'rollup';
3
+ import 'unplugin';
4
+ import './babel.js';
5
+ import '@babel/traverse';
6
+ import '@babel/types';
7
+
8
+
9
+
10
+ export { vitePlugin as default };
package/vite.js ADDED
@@ -0,0 +1,2 @@
1
+ import{b as t}from"./chunk-AS55AP7V.js";import"./chunk-ULMT6YNR.js";var i=t;export{i as default};
2
+ //# sourceMappingURL=vite.js.map
package/vite.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vite.ts"],"sourcesContent":["import { vitePlugin } from './index';\n\nexport default vitePlugin;\n"],"mappings":"oEAEA,IAAOA,EAAQC","names":["vite_default","vitePlugin"]}
package/webpack.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEDH7U5CGcjs = require('./chunk-EDH7U5CG.cjs');require('./chunk-4LM3AL5S.cjs');var p=_chunkEDH7U5CGcjs.e;exports.default = p;
2
+ //# sourceMappingURL=webpack.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/webpack.cjs","../src/webpack.ts"],"names":["webpack_default","webpackPlugin"],"mappings":"AAAA,iIAAmC,gCAA6B,ICEzDA,CAAAA,CAAQC,mBAAAA,CAAAA,oBAAAA","file":"/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/webpack.cjs","sourcesContent":[null,"import { webpackPlugin } from './index';\n\nexport default webpackPlugin;\n"]}
package/webpack.d.cts ADDED
@@ -0,0 +1,10 @@
1
+ import { webpackPlugin } from './index.cjs';
2
+ import 'rollup';
3
+ import 'unplugin';
4
+ import './babel.cjs';
5
+ import '@babel/traverse';
6
+ import '@babel/types';
7
+
8
+
9
+
10
+ export { webpackPlugin as default };
package/webpack.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { webpackPlugin } from './index.js';
2
+ import 'rollup';
3
+ import 'unplugin';
4
+ import './babel.js';
5
+ import '@babel/traverse';
6
+ import '@babel/types';
7
+
8
+
9
+
10
+ export { webpackPlugin as default };
package/webpack.js ADDED
@@ -0,0 +1,2 @@
1
+ import{e}from"./chunk-AS55AP7V.js";import"./chunk-ULMT6YNR.js";var p=e;export{p as default};
2
+ //# sourceMappingURL=webpack.js.map
package/webpack.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/webpack.ts"],"sourcesContent":["import { webpackPlugin } from './index';\n\nexport default webpackPlugin;\n"],"mappings":"+DAEA,IAAOA,EAAQC","names":["webpack_default","webpackPlugin"]}
package/chunk-5MLKKHGO.js DELETED
@@ -1,2 +0,0 @@
1
- import{a as c,b as m,c as u,d as f}from"./chunk-XWE2EDOE.js";import*as a from"@babel/standalone";import{transpileFn as d}from"tinyest-for-wgsl";var g=a.packages.template,n=a.packages.types;function y(i){return{ImportDeclaration(e){u(e.node,i)},CallExpression(e){let s=e.node;if(f(s,i)){let t=s.arguments[0];if(t&&(t.type==="FunctionExpression"||t.type==="ArrowFunctionExpression")){let{argNames:r,body:p,externalNames:o}=d(t);e.replaceWith(n.callExpression(s.callee,[n.callExpression(g.expression("tgpu.__assignAst")(),[t,g.expression`${c({argNames:r,body:p,externalNames:o})}`(),n.objectExpression(o.map(l=>n.objectProperty(n.identifier(l),n.identifier(l))))])])),e.skip()}}}}}function k(){return{visitor:{Program(i,e){var o;let s=(o=e.file)==null?void 0:o.code,t=e.opts,r=e.filename;if(m(t,r,s))return;let p={tgpuAliases:new Set(["tgpu"])};i.traverse(y(p))}}}}export{k as a};
2
- //# sourceMappingURL=chunk-5MLKKHGO.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/babel.ts"],"sourcesContent":["import * as Babel from '@babel/standalone';\nimport type TemplateGenerator from '@babel/template';\nimport type { TraverseOptions } from '@babel/traverse';\nimport type * as t from '@babel/types';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport {\n type Context,\n type TypegpuPluginOptions,\n embedJSON,\n gatherTgpuAliases,\n isDoesCall,\n shouldSkipFile,\n} from './common';\n\n// NOTE: @babel/standalone does expose internal packages, as specified in the docs, but the\n// typing for @babel/standalone does not expose them.\nconst template = (\n Babel as unknown as { packages: { template: typeof TemplateGenerator } }\n).packages.template;\nconst types = (Babel as unknown as { packages: { types: typeof t } }).packages\n .types;\n\nfunction functionVisitor(ctx: Context): TraverseOptions {\n return {\n ImportDeclaration(path) {\n gatherTgpuAliases(path.node, ctx);\n },\n\n CallExpression(path) {\n const node = path.node;\n\n if (isDoesCall(node, ctx)) {\n const implementation = node.arguments[0];\n\n if (\n implementation &&\n (implementation.type === 'FunctionExpression' ||\n implementation.type === 'ArrowFunctionExpression')\n ) {\n const { argNames, body, externalNames } = transpileFn(implementation);\n\n path.replaceWith(\n types.callExpression(node.callee, [\n types.callExpression(template.expression('tgpu.__assignAst')(), [\n implementation,\n template.expression`${embedJSON({ argNames, body, externalNames })}`(),\n types.objectExpression(\n externalNames.map((name) =>\n types.objectProperty(\n types.identifier(name),\n types.identifier(name),\n ),\n ),\n ),\n ]),\n ]),\n );\n\n path.skip();\n }\n }\n },\n };\n}\n\nexport default function () {\n return {\n visitor: {\n Program(path, state) {\n // @ts-ignore\n const code: string | undefined = state.file?.code;\n // @ts-ignore\n const options: TypegpuPluginOptions | undefined = state.opts;\n // @ts-ignore\n const id: string | undefined = state.filename;\n\n if (shouldSkipFile(options, id, code)) {\n return;\n }\n\n const ctx: Context = {\n tgpuAliases: new Set(['tgpu']),\n };\n\n path.traverse(functionVisitor(ctx));\n },\n } satisfies TraverseOptions,\n };\n}\n"],"mappings":"6DAAA,UAAYA,MAAW,oBAIvB,OAAS,eAAAC,MAAmB,mBAY5B,IAAMC,EAEJ,WAAS,SACLC,EAAgE,WACnE,MAEH,SAASC,EAAgBC,EAA+B,CACtD,MAAO,CACL,kBAAkBC,EAAM,CACtBC,EAAkBD,EAAK,KAAMD,CAAG,CAClC,EAEA,eAAeC,EAAM,CACnB,IAAME,EAAOF,EAAK,KAElB,GAAIG,EAAWD,EAAMH,CAAG,EAAG,CACzB,IAAMK,EAAiBF,EAAK,UAAU,CAAC,EAEvC,GACEE,IACCA,EAAe,OAAS,sBACvBA,EAAe,OAAS,2BAC1B,CACA,GAAM,CAAE,SAAAC,EAAU,KAAAC,EAAM,cAAAC,CAAc,EAAIC,EAAYJ,CAAc,EAEpEJ,EAAK,YACHH,EAAM,eAAeK,EAAK,OAAQ,CAChCL,EAAM,eAAeD,EAAS,WAAW,kBAAkB,EAAE,EAAG,CAC9DQ,EACAR,EAAS,aAAaa,EAAU,CAAE,SAAAJ,EAAU,KAAAC,EAAM,cAAAC,CAAc,CAAC,CAAC,GAAG,EACrEV,EAAM,iBACJU,EAAc,IAAKG,GACjBb,EAAM,eACJA,EAAM,WAAWa,CAAI,EACrBb,EAAM,WAAWa,CAAI,CACvB,CACF,CACF,CACF,CAAC,CACH,CAAC,CACH,EAEAV,EAAK,KAAK,CACZ,CACF,CACF,CACF,CACF,CAEe,SAARW,GAAoB,CACzB,MAAO,CACL,QAAS,CACP,QAAQX,EAAMY,EAAO,CApE3B,IAAAC,EAsEQ,IAAMC,GAA2BD,EAAAD,EAAM,OAAN,YAAAC,EAAY,KAEvCE,EAA4CH,EAAM,KAElDI,EAAyBJ,EAAM,SAErC,GAAIK,EAAeF,EAASC,EAAIF,CAAI,EAClC,OAGF,IAAMf,EAAe,CACnB,YAAa,IAAI,IAAI,CAAC,MAAM,CAAC,CAC/B,EAEAC,EAAK,SAASF,EAAgBC,CAAG,CAAC,CACpC,CACF,CACF,CACF","names":["Babel","transpileFn","template","types","functionVisitor","ctx","path","gatherTgpuAliases","node","isDoesCall","implementation","argNames","body","externalNames","transpileFn","embedJSON","name","babel_default","state","_a","code","options","id","shouldSkipFile"]}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});function u(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function a(e,p){let t="",r=p;for(;;)if(r.type==="MemberExpression"){if(r.property.type!=="Identifier")break;t=t?`${r.property.name}.${t}`:r.property.name,r=r.object}else if(r.type==="Identifier"){t=t?`${r.name}.${t}`:r.name;break}else break;return e.tgpuAliases.has(t)}var i=/import.*from\s*['"]typegpu.*['"]/g,l=/import\s*\(\s*['"]\s*typegpu.*['"]/g,n=/require\s*\(\s*['"]\s*typegpu.*['"]\s*\)/g;function s(e,p,t){if(t&&!(e!=null&&e.include)){if(!i.test(t)&&!n.test(t)&&!l.test(t))return!0}else if(e!=null&&e.include&&e.include!=="all"&&(!p||!e.include.some(r=>r.test(p))))return!0;return!1}function o(e,p){if(e.source.value==="typegpu")for(let t of e.specifiers)t.type==="ImportDefaultSpecifier"||t.type==="ImportSpecifier"&&t.imported.type==="Identifier"&&t.imported.name==="tgpu"?p.tgpuAliases.add(t.local.name):t.type==="ImportNamespaceSpecifier"&&p.tgpuAliases.add(`${t.local.name}.tgpu`)}function c(e,p){return e.callee.type==="MemberExpression"&&e.arguments.length===1&&e.callee.property.type==="Identifier"&&(e.callee.property.name==="procedure"&&a(p,e.callee.object)||e.callee.property.name==="does")}exports.a = u; exports.b = s; exports.c = o; exports.d = c;
2
- //# sourceMappingURL=chunk-5YUXNY4J.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/common.ts"],"names":["embedJSON","jsValue","isTgpu","ctx","node","path","tail","typegpuImportRegex","typegpuDynamicImportRegex","typegpuRequireRegex","shouldSkipFile","options","id","code","pattern","gatherTgpuAliases","spec","isDoesCall"],"mappings":"AAeO,SAASA,EAAUC,EAAkB,CAC1C,OAAO,KAAK,UAAUA,CAAO,EAC1B,QAAQ,UAAW,SAAS,EAC5B,QAAQ,UAAW,SAAS,CACjC,CAMA,SAASC,EAAOC,EAAcC,EAA2C,CACvE,IAAIC,EAAO,GAEPC,EAAOF,EACX,OACE,GAAIE,EAAK,OAAS,mBAAoB,CACpC,GAAIA,EAAK,SAAS,OAAS,aAEzB,MAGFD,EAAOA,EAAO,GAAGC,EAAK,SAAS,IAAI,IAAID,CAAI,GAAKC,EAAK,SAAS,KAC9DA,EAAOA,EAAK,MACd,SAAWA,EAAK,OAAS,aAAc,CACrCD,EAAOA,EAAO,GAAGC,EAAK,IAAI,IAAID,CAAI,GAAKC,EAAK,KAC5C,KACF,KACE,OAIJ,OAAOH,EAAI,YAAY,IAAIE,CAAI,CACjC,CAEA,IAAME,EAAqB,oCACrBC,EAA4B,sCAC5BC,EAAsB,4CAErB,SAASC,EACdC,EACAC,EACAC,EACA,CACA,GAAIA,GAAQ,EAACF,GAAA,MAAAA,EAAS,UACpB,GACE,CAACJ,EAAmB,KAAKM,CAAI,GAC7B,CAACJ,EAAoB,KAAKI,CAAI,GAC9B,CAACL,EAA0B,KAAKK,CAAI,EAGpC,MAAO,WAGTF,GAAA,MAAAA,EAAS,SACTA,EAAQ,UAAY,QACnB,CAACC,GAAM,CAACD,EAAQ,QAAQ,KAAMG,GAAYA,EAAQ,KAAKF,CAAE,CAAC,GAE3D,MAAO,GAGT,MAAO,EACT,CAEO,SAASG,EACdX,EACAD,EACA,CACA,GAAIC,EAAK,OAAO,QAAU,UACxB,QAAWY,KAAQZ,EAAK,WAGpBY,EAAK,OAAS,0BAEbA,EAAK,OAAS,mBACbA,EAAK,SAAS,OAAS,cACvBA,EAAK,SAAS,OAAS,OAEzBb,EAAI,YAAY,IAAIa,EAAK,MAAM,IAAI,EAC1BA,EAAK,OAAS,4BAEvBb,EAAI,YAAY,IAAI,GAAGa,EAAK,MAAM,IAAI,OAAO,CAIrD,CAEO,SAASC,EACdb,EACAD,EACA,CACA,OACEC,EAAK,OAAO,OAAS,oBACrBA,EAAK,UAAU,SAAW,GAC1BA,EAAK,OAAO,SAAS,OAAS,eAC5BA,EAAK,OAAO,SAAS,OAAS,aAC9BF,EAAOC,EAAKC,EAAK,OAAO,MAAM,GAI9BA,EAAK,OAAO,SAAS,OAAS,OAEpC","sourcesContent":["import type * as babel from '@babel/types';\nimport type * as acorn from 'acorn';\n\nexport type Context = {\n /**\n * How the `tgpu` object is used in code. Since it can be aliased, we\n * need to catch that and act accordingly.\n */\n tgpuAliases: Set<string>;\n};\n\nexport interface TypegpuPluginOptions {\n include?: 'all' | RegExp[];\n}\n\nexport function embedJSON(jsValue: unknown) {\n return JSON.stringify(jsValue)\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n}\n\n/**\n * Checks if `node` is an alias for the 'tgpu' object, traditionally\n * available via `import tgpu from 'typegpu'`.\n */\nfunction isTgpu(ctx: Context, node: babel.Node | acorn.AnyNode): boolean {\n let path = '';\n\n let tail = node;\n while (true) {\n if (tail.type === 'MemberExpression') {\n if (tail.property.type !== 'Identifier') {\n // Not handling computed expressions.\n break;\n }\n\n path = path ? `${tail.property.name}.${path}` : tail.property.name;\n tail = tail.object;\n } else if (tail.type === 'Identifier') {\n path = path ? `${tail.name}.${path}` : tail.name;\n break;\n } else {\n break;\n }\n }\n\n return ctx.tgpuAliases.has(path);\n}\n\nconst typegpuImportRegex = /import.*from\\s*['\"]typegpu.*['\"]/g;\nconst typegpuDynamicImportRegex = /import\\s*\\(\\s*['\"]\\s*typegpu.*['\"]/g;\nconst typegpuRequireRegex = /require\\s*\\(\\s*['\"]\\s*typegpu.*['\"]\\s*\\)/g;\n\nexport function shouldSkipFile(\n options: TypegpuPluginOptions | undefined,\n id: string | undefined,\n code: string | undefined,\n) {\n if (code && !options?.include) {\n if (\n !typegpuImportRegex.test(code) &&\n !typegpuRequireRegex.test(code) &&\n !typegpuDynamicImportRegex.test(code)\n ) {\n // No imports to `typegpu` or its sub modules, exiting early.\n return true;\n }\n } else if (\n options?.include &&\n options.include !== 'all' &&\n (!id || !options.include.some((pattern) => pattern.test(id)))\n ) {\n return true;\n }\n\n return false;\n}\n\nexport function gatherTgpuAliases(\n node: acorn.ImportDeclaration | babel.ImportDeclaration,\n ctx: Context,\n) {\n if (node.source.value === 'typegpu') {\n for (const spec of node.specifiers) {\n if (\n // The default export of 'typegpu' is the `tgpu` object.\n spec.type === 'ImportDefaultSpecifier' ||\n // Aliasing 'tgpu' while importing, e.g. import { tgpu as t } from 'typegpu';\n (spec.type === 'ImportSpecifier' &&\n spec.imported.type === 'Identifier' &&\n spec.imported.name === 'tgpu')\n ) {\n ctx.tgpuAliases.add(spec.local.name);\n } else if (spec.type === 'ImportNamespaceSpecifier') {\n // Importing everything, e.g. import * as t from 'typegpu';\n ctx.tgpuAliases.add(`${spec.local.name}.tgpu`);\n }\n }\n }\n}\n\nexport function isDoesCall(\n node: acorn.CallExpression | babel.CallExpression,\n ctx: Context,\n) {\n return (\n node.callee.type === 'MemberExpression' &&\n node.arguments.length === 1 &&\n node.callee.property.type === 'Identifier' &&\n ((node.callee.property.name === 'procedure' &&\n isTgpu(ctx, node.callee.object)) ||\n // Assuming that every call to `.does` is related to TypeGPU\n // because shells can be created separately from calls to `tgpu`,\n // making it hard to detect.\n node.callee.property.name === 'does')\n );\n}\n"]}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunk5YUXNY4Jcjs = require('./chunk-5YUXNY4J.cjs');var _estreewalker = require('estree-walker');var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireDefault(_magicstring);var _tinyestforwgsl = require('tinyest-for-wgsl');function T(c){return{name:"rollup-plugin-typegpu",transform(o,d){if(_chunk5YUXNY4Jcjs.b.call(void 0, c,d,o))return;let r={tgpuAliases:new Set(["tgpu"])},y=this.parse(o,{allowReturnOutsideFunction:!0}),a=[];_estreewalker.walk.call(void 0, y,{enter(e,l,s,p){let n=e;if(n.type==="ImportDeclaration"&&_chunk5YUXNY4Jcjs.c.call(void 0, n,r),n.type==="CallExpression"&&_chunk5YUXNY4Jcjs.d.call(void 0, n,r)){let i=n.arguments[0];i&&i.type!=="TemplateLiteral"&&i.type!=="Literal"&&a.push({varDecl:n,implementation:i})}}});let t=new (0, _magicstring2.default)(o);for(let e of a){let{argNames:l,body:s,externalNames:p}=_tinyestforwgsl.transpileFn.call(void 0, e.implementation);t.appendLeft(e.implementation.start,"tgpu.__assignAst("),t.appendRight(e.implementation.end,`, ${_chunk5YUXNY4Jcjs.a.call(void 0, {argNames:l,body:s,externalNames:p})}`),p.length>0?t.appendRight(e.implementation.end,`, {${p.join(", ")}})`):t.appendRight(e.implementation.end,", undefined)")}return{code:t.toString(),map:t.generateMap()}}}}exports.a = T;
2
- //# sourceMappingURL=chunk-GN3AXEAX.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/rollup.ts"],"names":["walk","MagicString","transpileFn","typegpu","options","code","id","shouldSkipFile","ctx","ast","tgslFunctionDefs","_node","_parent","prop","index","node","gatherTgpuAliases","isDoesCall","implementation","magicString","expr","argNames","body","externalNames","embedJSON"],"mappings":"8DACA,OAAS,QAAAA,MAAY,gBACrB,OAAOC,MAAiB,eAExB,OAAS,eAAAC,MAAmB,mBAuBb,SAARC,EACLC,EACqB,CACrB,MAAO,CACL,KAAM,wBACN,UAAUC,EAAMC,EAAI,CAClB,GAAIC,EAAeH,EAASE,EAAID,CAAI,EAClC,OAGF,IAAMG,EAAe,CACnB,YAAa,IAAI,IAAI,CAAC,MAAM,CAAC,CAC/B,EAEMC,EAAM,KAAK,MAAMJ,EAAM,CAC3B,2BAA4B,EAC9B,CAAC,EAEKK,EAAsC,CAAC,EAE7CV,EAAKS,EAAK,CACR,MAAME,EAAOC,EAASC,EAAMC,EAAO,CACjC,IAAMC,EAAOJ,EAMb,GAJII,EAAK,OAAS,qBAChBC,EAAkBD,EAAMP,CAAG,EAGzBO,EAAK,OAAS,kBACZE,EAAWF,EAAMP,CAAG,EAAG,CACzB,IAAMU,EAAiBH,EAAK,UAAU,CAAC,EAGrCG,GACEA,EAAe,OAAS,mBACxBA,EAAe,OAAS,WAE1BR,EAAiB,KAAK,CACpB,QAASK,EACT,eAAAG,CACF,CAAC,CAEL,CAEJ,CACF,CAAC,EAED,IAAMC,EAAc,IAAIlB,EAAYI,CAAI,EAExC,QAAWe,KAAQV,EAAkB,CACnC,GAAM,CAAE,SAAAW,EAAU,KAAAC,EAAM,cAAAC,CAAc,EAAIrB,EACxCkB,EAAK,cACP,EAGAD,EAAY,WAAWC,EAAK,eAAe,MAAO,mBAAmB,EACrED,EAAY,YACVC,EAAK,eAAe,IACpB,KAAKI,EAAU,CAAE,SAAAH,EAAU,KAAAC,EAAM,cAAAC,CAAc,CAAC,CAAC,EACnD,EAEIA,EAAc,OAAS,EACzBJ,EAAY,YACVC,EAAK,eAAe,IACpB,MAAMG,EAAc,KAAK,IAAI,CAAC,IAChC,EAEAJ,EAAY,YAAYC,EAAK,eAAe,IAAK,cAAc,CAEnE,CAEA,MAAO,CACL,KAAMD,EAAY,SAAS,EAC3B,IAAKA,EAAY,YAAY,CAC/B,CACF,CACF,CACF","sourcesContent":["import type { AnyNode, CallExpression } from 'acorn';\nimport { walk } from 'estree-walker';\nimport MagicString from 'magic-string';\nimport type { Plugin, SourceMap } from 'rollup';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport {\n type Context,\n type TypegpuPluginOptions,\n embedJSON,\n gatherTgpuAliases,\n isDoesCall,\n shouldSkipFile,\n} from './common';\n\ntype TgslFunctionDef = {\n varDecl: CallExpression;\n implementation: AnyNode;\n};\n\nexport interface TypegpuRollupPlugin {\n name: 'rollup-plugin-typegpu';\n transform(\n code: string,\n id: string,\n ): { code: string; map: SourceMap } | undefined;\n}\n\nexport default function typegpu(\n options?: TypegpuPluginOptions,\n): TypegpuRollupPlugin {\n return {\n name: 'rollup-plugin-typegpu' as const,\n transform(code, id) {\n if (shouldSkipFile(options, id, code)) {\n return;\n }\n\n const ctx: Context = {\n tgpuAliases: new Set(['tgpu']),\n };\n\n const ast = this.parse(code, {\n allowReturnOutsideFunction: true,\n });\n\n const tgslFunctionDefs: TgslFunctionDef[] = [];\n\n walk(ast, {\n enter(_node, _parent, prop, index) {\n const node = _node as AnyNode;\n\n if (node.type === 'ImportDeclaration') {\n gatherTgpuAliases(node, ctx);\n }\n\n if (node.type === 'CallExpression') {\n if (isDoesCall(node, ctx)) {\n const implementation = node.arguments[0];\n\n if (\n implementation &&\n !(implementation.type === 'TemplateLiteral') &&\n !(implementation.type === 'Literal')\n ) {\n tgslFunctionDefs.push({\n varDecl: node,\n implementation,\n });\n }\n }\n }\n },\n });\n\n const magicString = new MagicString(code);\n\n for (const expr of tgslFunctionDefs) {\n const { argNames, body, externalNames } = transpileFn(\n expr.implementation,\n );\n\n // Wrap the implementation in a call to `tgpu.__assignAst` to associate the AST with the implementation.\n magicString.appendLeft(expr.implementation.start, 'tgpu.__assignAst(');\n magicString.appendRight(\n expr.implementation.end,\n `, ${embedJSON({ argNames, body, externalNames })}`,\n );\n\n if (externalNames.length > 0) {\n magicString.appendRight(\n expr.implementation.end,\n `, {${externalNames.join(', ')}})`,\n );\n } else {\n magicString.appendRight(expr.implementation.end, ', undefined)');\n }\n }\n\n return {\n code: magicString.toString(),\n map: magicString.generateMap(),\n };\n },\n } satisfies Plugin;\n}\n"]}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }var _chunk5YUXNY4Jcjs = require('./chunk-5YUXNY4J.cjs');var _standalone = require('@babel/standalone'); var a = _interopRequireWildcard(_standalone);var _tinyestforwgsl = require('tinyest-for-wgsl');var g=a.packages.template,n=a.packages.types;function y(i){return{ImportDeclaration(e){_chunk5YUXNY4Jcjs.c.call(void 0, e.node,i)},CallExpression(e){let s=e.node;if(_chunk5YUXNY4Jcjs.d.call(void 0, s,i)){let t=s.arguments[0];if(t&&(t.type==="FunctionExpression"||t.type==="ArrowFunctionExpression")){let{argNames:r,body:p,externalNames:o}=_tinyestforwgsl.transpileFn.call(void 0, t);e.replaceWith(n.callExpression(s.callee,[n.callExpression(g.expression("tgpu.__assignAst")(),[t,g.expression`${_chunk5YUXNY4Jcjs.a.call(void 0, {argNames:r,body:p,externalNames:o})}`(),n.objectExpression(o.map(l=>n.objectProperty(n.identifier(l),n.identifier(l))))])])),e.skip()}}}}}function k(){return{visitor:{Program(i,e){var o;let s=(o=e.file)==null?void 0:o.code,t=e.opts,r=e.filename;if(_chunk5YUXNY4Jcjs.b.call(void 0, t,r,s))return;let p={tgpuAliases:new Set(["tgpu"])};i.traverse(y(p))}}}}exports.a = k;
2
- //# sourceMappingURL=chunk-SPKQUOK3.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/babel.ts"],"names":["Babel","transpileFn","template","types","functionVisitor","ctx","path","gatherTgpuAliases","node","isDoesCall","implementation","argNames","body","externalNames","embedJSON","name","babel_default","state","_a","code","options","id","shouldSkipFile"],"mappings":"8DAAA,UAAYA,MAAW,oBAIvB,OAAS,eAAAC,MAAmB,mBAY5B,IAAMC,EAEJ,WAAS,SACLC,EAAgE,WACnE,MAEH,SAASC,EAAgBC,EAA+B,CACtD,MAAO,CACL,kBAAkBC,EAAM,CACtBC,EAAkBD,EAAK,KAAMD,CAAG,CAClC,EAEA,eAAeC,EAAM,CACnB,IAAME,EAAOF,EAAK,KAElB,GAAIG,EAAWD,EAAMH,CAAG,EAAG,CACzB,IAAMK,EAAiBF,EAAK,UAAU,CAAC,EAEvC,GACEE,IACCA,EAAe,OAAS,sBACvBA,EAAe,OAAS,2BAC1B,CACA,GAAM,CAAE,SAAAC,EAAU,KAAAC,EAAM,cAAAC,CAAc,EAAIZ,EAAYS,CAAc,EAEpEJ,EAAK,YACHH,EAAM,eAAeK,EAAK,OAAQ,CAChCL,EAAM,eAAeD,EAAS,WAAW,kBAAkB,EAAE,EAAG,CAC9DQ,EACAR,EAAS,aAAaY,EAAU,CAAE,SAAAH,EAAU,KAAAC,EAAM,cAAAC,CAAc,CAAC,CAAC,GAAG,EACrEV,EAAM,iBACJU,EAAc,IAAKE,GACjBZ,EAAM,eACJA,EAAM,WAAWY,CAAI,EACrBZ,EAAM,WAAWY,CAAI,CACvB,CACF,CACF,CACF,CAAC,CACH,CAAC,CACH,EAEAT,EAAK,KAAK,CACZ,CACF,CACF,CACF,CACF,CAEe,SAARU,GAAoB,CACzB,MAAO,CACL,QAAS,CACP,QAAQV,EAAMW,EAAO,CApE3B,IAAAC,EAsEQ,IAAMC,GAA2BD,EAAAD,EAAM,OAAN,YAAAC,EAAY,KAEvCE,EAA4CH,EAAM,KAElDI,EAAyBJ,EAAM,SAErC,GAAIK,EAAeF,EAASC,EAAIF,CAAI,EAClC,OAGF,IAAMd,EAAe,CACnB,YAAa,IAAI,IAAI,CAAC,MAAM,CAAC,CAC/B,EAEAC,EAAK,SAASF,EAAgBC,CAAG,CAAC,CACpC,CACF,CACF,CACF","sourcesContent":["import * as Babel from '@babel/standalone';\nimport type TemplateGenerator from '@babel/template';\nimport type { TraverseOptions } from '@babel/traverse';\nimport type * as t from '@babel/types';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport {\n type Context,\n type TypegpuPluginOptions,\n embedJSON,\n gatherTgpuAliases,\n isDoesCall,\n shouldSkipFile,\n} from './common';\n\n// NOTE: @babel/standalone does expose internal packages, as specified in the docs, but the\n// typing for @babel/standalone does not expose them.\nconst template = (\n Babel as unknown as { packages: { template: typeof TemplateGenerator } }\n).packages.template;\nconst types = (Babel as unknown as { packages: { types: typeof t } }).packages\n .types;\n\nfunction functionVisitor(ctx: Context): TraverseOptions {\n return {\n ImportDeclaration(path) {\n gatherTgpuAliases(path.node, ctx);\n },\n\n CallExpression(path) {\n const node = path.node;\n\n if (isDoesCall(node, ctx)) {\n const implementation = node.arguments[0];\n\n if (\n implementation &&\n (implementation.type === 'FunctionExpression' ||\n implementation.type === 'ArrowFunctionExpression')\n ) {\n const { argNames, body, externalNames } = transpileFn(implementation);\n\n path.replaceWith(\n types.callExpression(node.callee, [\n types.callExpression(template.expression('tgpu.__assignAst')(), [\n implementation,\n template.expression`${embedJSON({ argNames, body, externalNames })}`(),\n types.objectExpression(\n externalNames.map((name) =>\n types.objectProperty(\n types.identifier(name),\n types.identifier(name),\n ),\n ),\n ),\n ]),\n ]),\n );\n\n path.skip();\n }\n }\n },\n };\n}\n\nexport default function () {\n return {\n visitor: {\n Program(path, state) {\n // @ts-ignore\n const code: string | undefined = state.file?.code;\n // @ts-ignore\n const options: TypegpuPluginOptions | undefined = state.opts;\n // @ts-ignore\n const id: string | undefined = state.filename;\n\n if (shouldSkipFile(options, id, code)) {\n return;\n }\n\n const ctx: Context = {\n tgpuAliases: new Set(['tgpu']),\n };\n\n path.traverse(functionVisitor(ctx));\n },\n } satisfies TraverseOptions,\n };\n}\n"]}
package/chunk-VSVKZFFD.js DELETED
@@ -1,2 +0,0 @@
1
- import{a as u,b as g,c as m,d as f}from"./chunk-XWE2EDOE.js";import{walk as x}from"estree-walker";import h from"magic-string";import{transpileFn as S}from"tinyest-for-wgsl";function T(c){return{name:"rollup-plugin-typegpu",transform(o,d){if(g(c,d,o))return;let r={tgpuAliases:new Set(["tgpu"])},y=this.parse(o,{allowReturnOutsideFunction:!0}),a=[];x(y,{enter(e,l,s,p){let n=e;if(n.type==="ImportDeclaration"&&m(n,r),n.type==="CallExpression"&&f(n,r)){let i=n.arguments[0];i&&i.type!=="TemplateLiteral"&&i.type!=="Literal"&&a.push({varDecl:n,implementation:i})}}});let t=new h(o);for(let e of a){let{argNames:l,body:s,externalNames:p}=S(e.implementation);t.appendLeft(e.implementation.start,"tgpu.__assignAst("),t.appendRight(e.implementation.end,`, ${u({argNames:l,body:s,externalNames:p})}`),p.length>0?t.appendRight(e.implementation.end,`, {${p.join(", ")}})`):t.appendRight(e.implementation.end,", undefined)")}return{code:t.toString(),map:t.generateMap()}}}}export{T as a};
2
- //# sourceMappingURL=chunk-VSVKZFFD.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/rollup.ts"],"sourcesContent":["import type { AnyNode, CallExpression } from 'acorn';\nimport { walk } from 'estree-walker';\nimport MagicString from 'magic-string';\nimport type { Plugin, SourceMap } from 'rollup';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport {\n type Context,\n type TypegpuPluginOptions,\n embedJSON,\n gatherTgpuAliases,\n isDoesCall,\n shouldSkipFile,\n} from './common';\n\ntype TgslFunctionDef = {\n varDecl: CallExpression;\n implementation: AnyNode;\n};\n\nexport interface TypegpuRollupPlugin {\n name: 'rollup-plugin-typegpu';\n transform(\n code: string,\n id: string,\n ): { code: string; map: SourceMap } | undefined;\n}\n\nexport default function typegpu(\n options?: TypegpuPluginOptions,\n): TypegpuRollupPlugin {\n return {\n name: 'rollup-plugin-typegpu' as const,\n transform(code, id) {\n if (shouldSkipFile(options, id, code)) {\n return;\n }\n\n const ctx: Context = {\n tgpuAliases: new Set(['tgpu']),\n };\n\n const ast = this.parse(code, {\n allowReturnOutsideFunction: true,\n });\n\n const tgslFunctionDefs: TgslFunctionDef[] = [];\n\n walk(ast, {\n enter(_node, _parent, prop, index) {\n const node = _node as AnyNode;\n\n if (node.type === 'ImportDeclaration') {\n gatherTgpuAliases(node, ctx);\n }\n\n if (node.type === 'CallExpression') {\n if (isDoesCall(node, ctx)) {\n const implementation = node.arguments[0];\n\n if (\n implementation &&\n !(implementation.type === 'TemplateLiteral') &&\n !(implementation.type === 'Literal')\n ) {\n tgslFunctionDefs.push({\n varDecl: node,\n implementation,\n });\n }\n }\n }\n },\n });\n\n const magicString = new MagicString(code);\n\n for (const expr of tgslFunctionDefs) {\n const { argNames, body, externalNames } = transpileFn(\n expr.implementation,\n );\n\n // Wrap the implementation in a call to `tgpu.__assignAst` to associate the AST with the implementation.\n magicString.appendLeft(expr.implementation.start, 'tgpu.__assignAst(');\n magicString.appendRight(\n expr.implementation.end,\n `, ${embedJSON({ argNames, body, externalNames })}`,\n );\n\n if (externalNames.length > 0) {\n magicString.appendRight(\n expr.implementation.end,\n `, {${externalNames.join(', ')}})`,\n );\n } else {\n magicString.appendRight(expr.implementation.end, ', undefined)');\n }\n }\n\n return {\n code: magicString.toString(),\n map: magicString.generateMap(),\n };\n },\n } satisfies Plugin;\n}\n"],"mappings":"6DACA,OAAS,QAAAA,MAAY,gBACrB,OAAOC,MAAiB,eAExB,OAAS,eAAAC,MAAmB,mBAuBb,SAARC,EACLC,EACqB,CACrB,MAAO,CACL,KAAM,wBACN,UAAUC,EAAMC,EAAI,CAClB,GAAIC,EAAeH,EAASE,EAAID,CAAI,EAClC,OAGF,IAAMG,EAAe,CACnB,YAAa,IAAI,IAAI,CAAC,MAAM,CAAC,CAC/B,EAEMC,EAAM,KAAK,MAAMJ,EAAM,CAC3B,2BAA4B,EAC9B,CAAC,EAEKK,EAAsC,CAAC,EAE7CC,EAAKF,EAAK,CACR,MAAMG,EAAOC,EAASC,EAAMC,EAAO,CACjC,IAAMC,EAAOJ,EAMb,GAJII,EAAK,OAAS,qBAChBC,EAAkBD,EAAMR,CAAG,EAGzBQ,EAAK,OAAS,kBACZE,EAAWF,EAAMR,CAAG,EAAG,CACzB,IAAMW,EAAiBH,EAAK,UAAU,CAAC,EAGrCG,GACEA,EAAe,OAAS,mBACxBA,EAAe,OAAS,WAE1BT,EAAiB,KAAK,CACpB,QAASM,EACT,eAAAG,CACF,CAAC,CAEL,CAEJ,CACF,CAAC,EAED,IAAMC,EAAc,IAAIC,EAAYhB,CAAI,EAExC,QAAWiB,KAAQZ,EAAkB,CACnC,GAAM,CAAE,SAAAa,EAAU,KAAAC,EAAM,cAAAC,CAAc,EAAIC,EACxCJ,EAAK,cACP,EAGAF,EAAY,WAAWE,EAAK,eAAe,MAAO,mBAAmB,EACrEF,EAAY,YACVE,EAAK,eAAe,IACpB,KAAKK,EAAU,CAAE,SAAAJ,EAAU,KAAAC,EAAM,cAAAC,CAAc,CAAC,CAAC,EACnD,EAEIA,EAAc,OAAS,EACzBL,EAAY,YACVE,EAAK,eAAe,IACpB,MAAMG,EAAc,KAAK,IAAI,CAAC,IAChC,EAEAL,EAAY,YAAYE,EAAK,eAAe,IAAK,cAAc,CAEnE,CAEA,MAAO,CACL,KAAMF,EAAY,SAAS,EAC3B,IAAKA,EAAY,YAAY,CAC/B,CACF,CACF,CACF","names":["walk","MagicString","transpileFn","typegpu","options","code","id","shouldSkipFile","ctx","ast","tgslFunctionDefs","walk","_node","_parent","prop","index","node","gatherTgpuAliases","isDoesCall","implementation","magicString","MagicString","expr","argNames","body","externalNames","transpileFn","embedJSON"]}
package/chunk-XWE2EDOE.js DELETED
@@ -1,2 +0,0 @@
1
- function u(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function a(e,p){let t="",r=p;for(;;)if(r.type==="MemberExpression"){if(r.property.type!=="Identifier")break;t=t?`${r.property.name}.${t}`:r.property.name,r=r.object}else if(r.type==="Identifier"){t=t?`${r.name}.${t}`:r.name;break}else break;return e.tgpuAliases.has(t)}var i=/import.*from\s*['"]typegpu.*['"]/g,l=/import\s*\(\s*['"]\s*typegpu.*['"]/g,n=/require\s*\(\s*['"]\s*typegpu.*['"]\s*\)/g;function s(e,p,t){if(t&&!(e!=null&&e.include)){if(!i.test(t)&&!n.test(t)&&!l.test(t))return!0}else if(e!=null&&e.include&&e.include!=="all"&&(!p||!e.include.some(r=>r.test(p))))return!0;return!1}function o(e,p){if(e.source.value==="typegpu")for(let t of e.specifiers)t.type==="ImportDefaultSpecifier"||t.type==="ImportSpecifier"&&t.imported.type==="Identifier"&&t.imported.name==="tgpu"?p.tgpuAliases.add(t.local.name):t.type==="ImportNamespaceSpecifier"&&p.tgpuAliases.add(`${t.local.name}.tgpu`)}function c(e,p){return e.callee.type==="MemberExpression"&&e.arguments.length===1&&e.callee.property.type==="Identifier"&&(e.callee.property.name==="procedure"&&a(p,e.callee.object)||e.callee.property.name==="does")}export{u as a,s as b,o as c,c as d};
2
- //# sourceMappingURL=chunk-XWE2EDOE.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/common.ts"],"sourcesContent":["import type * as babel from '@babel/types';\nimport type * as acorn from 'acorn';\n\nexport type Context = {\n /**\n * How the `tgpu` object is used in code. Since it can be aliased, we\n * need to catch that and act accordingly.\n */\n tgpuAliases: Set<string>;\n};\n\nexport interface TypegpuPluginOptions {\n include?: 'all' | RegExp[];\n}\n\nexport function embedJSON(jsValue: unknown) {\n return JSON.stringify(jsValue)\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n}\n\n/**\n * Checks if `node` is an alias for the 'tgpu' object, traditionally\n * available via `import tgpu from 'typegpu'`.\n */\nfunction isTgpu(ctx: Context, node: babel.Node | acorn.AnyNode): boolean {\n let path = '';\n\n let tail = node;\n while (true) {\n if (tail.type === 'MemberExpression') {\n if (tail.property.type !== 'Identifier') {\n // Not handling computed expressions.\n break;\n }\n\n path = path ? `${tail.property.name}.${path}` : tail.property.name;\n tail = tail.object;\n } else if (tail.type === 'Identifier') {\n path = path ? `${tail.name}.${path}` : tail.name;\n break;\n } else {\n break;\n }\n }\n\n return ctx.tgpuAliases.has(path);\n}\n\nconst typegpuImportRegex = /import.*from\\s*['\"]typegpu.*['\"]/g;\nconst typegpuDynamicImportRegex = /import\\s*\\(\\s*['\"]\\s*typegpu.*['\"]/g;\nconst typegpuRequireRegex = /require\\s*\\(\\s*['\"]\\s*typegpu.*['\"]\\s*\\)/g;\n\nexport function shouldSkipFile(\n options: TypegpuPluginOptions | undefined,\n id: string | undefined,\n code: string | undefined,\n) {\n if (code && !options?.include) {\n if (\n !typegpuImportRegex.test(code) &&\n !typegpuRequireRegex.test(code) &&\n !typegpuDynamicImportRegex.test(code)\n ) {\n // No imports to `typegpu` or its sub modules, exiting early.\n return true;\n }\n } else if (\n options?.include &&\n options.include !== 'all' &&\n (!id || !options.include.some((pattern) => pattern.test(id)))\n ) {\n return true;\n }\n\n return false;\n}\n\nexport function gatherTgpuAliases(\n node: acorn.ImportDeclaration | babel.ImportDeclaration,\n ctx: Context,\n) {\n if (node.source.value === 'typegpu') {\n for (const spec of node.specifiers) {\n if (\n // The default export of 'typegpu' is the `tgpu` object.\n spec.type === 'ImportDefaultSpecifier' ||\n // Aliasing 'tgpu' while importing, e.g. import { tgpu as t } from 'typegpu';\n (spec.type === 'ImportSpecifier' &&\n spec.imported.type === 'Identifier' &&\n spec.imported.name === 'tgpu')\n ) {\n ctx.tgpuAliases.add(spec.local.name);\n } else if (spec.type === 'ImportNamespaceSpecifier') {\n // Importing everything, e.g. import * as t from 'typegpu';\n ctx.tgpuAliases.add(`${spec.local.name}.tgpu`);\n }\n }\n }\n}\n\nexport function isDoesCall(\n node: acorn.CallExpression | babel.CallExpression,\n ctx: Context,\n) {\n return (\n node.callee.type === 'MemberExpression' &&\n node.arguments.length === 1 &&\n node.callee.property.type === 'Identifier' &&\n ((node.callee.property.name === 'procedure' &&\n isTgpu(ctx, node.callee.object)) ||\n // Assuming that every call to `.does` is related to TypeGPU\n // because shells can be created separately from calls to `tgpu`,\n // making it hard to detect.\n node.callee.property.name === 'does')\n );\n}\n"],"mappings":"AAeO,SAASA,EAAUC,EAAkB,CAC1C,OAAO,KAAK,UAAUA,CAAO,EAC1B,QAAQ,UAAW,SAAS,EAC5B,QAAQ,UAAW,SAAS,CACjC,CAMA,SAASC,EAAOC,EAAcC,EAA2C,CACvE,IAAIC,EAAO,GAEPC,EAAOF,EACX,OACE,GAAIE,EAAK,OAAS,mBAAoB,CACpC,GAAIA,EAAK,SAAS,OAAS,aAEzB,MAGFD,EAAOA,EAAO,GAAGC,EAAK,SAAS,IAAI,IAAID,CAAI,GAAKC,EAAK,SAAS,KAC9DA,EAAOA,EAAK,MACd,SAAWA,EAAK,OAAS,aAAc,CACrCD,EAAOA,EAAO,GAAGC,EAAK,IAAI,IAAID,CAAI,GAAKC,EAAK,KAC5C,KACF,KACE,OAIJ,OAAOH,EAAI,YAAY,IAAIE,CAAI,CACjC,CAEA,IAAME,EAAqB,oCACrBC,EAA4B,sCAC5BC,EAAsB,4CAErB,SAASC,EACdC,EACAC,EACAC,EACA,CACA,GAAIA,GAAQ,EAACF,GAAA,MAAAA,EAAS,UACpB,GACE,CAACJ,EAAmB,KAAKM,CAAI,GAC7B,CAACJ,EAAoB,KAAKI,CAAI,GAC9B,CAACL,EAA0B,KAAKK,CAAI,EAGpC,MAAO,WAGTF,GAAA,MAAAA,EAAS,SACTA,EAAQ,UAAY,QACnB,CAACC,GAAM,CAACD,EAAQ,QAAQ,KAAMG,GAAYA,EAAQ,KAAKF,CAAE,CAAC,GAE3D,MAAO,GAGT,MAAO,EACT,CAEO,SAASG,EACdX,EACAD,EACA,CACA,GAAIC,EAAK,OAAO,QAAU,UACxB,QAAWY,KAAQZ,EAAK,WAGpBY,EAAK,OAAS,0BAEbA,EAAK,OAAS,mBACbA,EAAK,SAAS,OAAS,cACvBA,EAAK,SAAS,OAAS,OAEzBb,EAAI,YAAY,IAAIa,EAAK,MAAM,IAAI,EAC1BA,EAAK,OAAS,4BAEvBb,EAAI,YAAY,IAAI,GAAGa,EAAK,MAAM,IAAI,OAAO,CAIrD,CAEO,SAASC,EACdb,EACAD,EACA,CACA,OACEC,EAAK,OAAO,OAAS,oBACrBA,EAAK,UAAU,SAAW,GAC1BA,EAAK,OAAO,SAAS,OAAS,eAC5BA,EAAK,OAAO,SAAS,OAAS,aAC9BF,EAAOC,EAAKC,EAAK,OAAO,MAAM,GAI9BA,EAAK,OAAO,SAAS,OAAS,OAEpC","names":["embedJSON","jsValue","isTgpu","ctx","node","path","tail","typegpuImportRegex","typegpuDynamicImportRegex","typegpuRequireRegex","shouldSkipFile","options","id","code","pattern","gatherTgpuAliases","spec","isDoesCall"]}
@@ -1,16 +0,0 @@
1
- import { SourceMap } from 'rollup';
2
-
3
- interface TypegpuPluginOptions {
4
- include?: 'all' | RegExp[];
5
- }
6
-
7
- interface TypegpuRollupPlugin {
8
- name: 'rollup-plugin-typegpu';
9
- transform(code: string, id: string): {
10
- code: string;
11
- map: SourceMap;
12
- } | undefined;
13
- }
14
- declare function typegpu(options?: TypegpuPluginOptions): TypegpuRollupPlugin;
15
-
16
- export { type TypegpuPluginOptions as T, type TypegpuRollupPlugin as a, typegpu as t };
@@ -1,16 +0,0 @@
1
- import { SourceMap } from 'rollup';
2
-
3
- interface TypegpuPluginOptions {
4
- include?: 'all' | RegExp[];
5
- }
6
-
7
- interface TypegpuRollupPlugin {
8
- name: 'rollup-plugin-typegpu';
9
- transform(code: string, id: string): {
10
- code: string;
11
- map: SourceMap;
12
- } | undefined;
13
- }
14
- declare function typegpu(options?: TypegpuPluginOptions): TypegpuRollupPlugin;
15
-
16
- export { type TypegpuPluginOptions as T, type TypegpuRollupPlugin as a, typegpu as t };