unplugin-typegpu 0.1.0 → 0.1.2
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.
- package/LICENSE.md +11 -12
- package/README.md +22 -15
- package/babel.cjs +1 -1
- package/babel.cjs.map +1 -1
- package/babel.js +1 -1
- package/{chunk-Y4WARDXR.js → chunk-4ONRHQSA.js} +2 -2
- package/chunk-4ONRHQSA.js.map +1 -0
- package/{chunk-HQFSG5ZM.cjs → chunk-BCOJLF4T.cjs} +2 -2
- package/chunk-BCOJLF4T.cjs.map +1 -0
- package/{chunk-EX5XCHMD.js → chunk-CTUSYGR2.js} +2 -2
- package/chunk-CTUSYGR2.js.map +1 -0
- package/chunk-EPZPFIYG.cjs +2 -0
- package/chunk-EPZPFIYG.cjs.map +1 -0
- package/esbuild.cjs +1 -1
- package/esbuild.cjs.map +1 -1
- package/esbuild.js +1 -1
- package/farm.cjs +1 -1
- package/farm.cjs.map +1 -1
- package/farm.js +1 -1
- package/index.cjs +1 -1
- package/index.cjs.map +1 -1
- package/index.js +1 -1
- package/package.json +4 -3
- package/rolldown.cjs +1 -1
- package/rolldown.cjs.map +1 -1
- package/rolldown.js +1 -1
- package/rollup.cjs +1 -1
- package/rollup.cjs.map +1 -1
- package/rollup.js +1 -1
- package/rspack.cjs +1 -1
- package/rspack.cjs.map +1 -1
- package/rspack.js +1 -1
- package/vite.cjs +1 -1
- package/vite.cjs.map +1 -1
- package/vite.js +1 -1
- package/webpack.cjs +1 -1
- package/webpack.cjs.map +1 -1
- package/webpack.js +1 -1
- package/chunk-EX5XCHMD.js.map +0 -1
- package/chunk-HPSWWSWV.cjs +0 -2
- package/chunk-HPSWWSWV.cjs.map +0 -1
- package/chunk-HQFSG5ZM.cjs.map +0 -1
- package/chunk-Y4WARDXR.js.map +0 -1
package/LICENSE.md
CHANGED
|
@@ -2,20 +2,19 @@ MIT License
|
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2025 Software Mansion <swmansion.com>
|
|
4
4
|
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
11
|
|
|
12
12
|
The above copyright notice and this permission notice shall be included in all
|
|
13
13
|
copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
SOFTWARE.
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,16 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
# unplugin-typegpu
|
|
4
4
|
|
|
5
|
-
🚧 **Under Construction** 🚧 -
|
|
5
|
+
🚧 **Under Construction** 🚧 -
|
|
6
|
+
[GitHub](https://github.com/software-mansion/TypeGPU/tree/main/packages/unplugin-typegpu)
|
|
7
|
+
|
|
8
|
+
Read more about the plugin in the
|
|
9
|
+
[TypeGPU documentation](https://docs.swmansion.com/TypeGPU/tooling/unplugin-typegpu/).
|
|
6
10
|
|
|
7
11
|
</div>
|
|
8
12
|
|
|
9
13
|
Build plugins for [TypeGPU](https://typegpu.com) that enable:
|
|
14
|
+
|
|
10
15
|
- Seamless JavaScript -> WGSL transpilation
|
|
11
16
|
- [🚧 TODO] Improved debugging with automatic naming of resources
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
## Getting Started
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm install unplugin-typegpu
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- babel
|
|
25
|
+
|
|
15
26
|
```js
|
|
16
27
|
// babel.config.js (React Native with Expo)
|
|
17
28
|
|
|
@@ -19,34 +30,30 @@ module.exports = function (api) {
|
|
|
19
30
|
api.cache(true);
|
|
20
31
|
return {
|
|
21
32
|
presets: ['babel-preset-expo'],
|
|
22
|
-
plugins: ['unplugin-typegpu/babel']
|
|
33
|
+
plugins: ['unplugin-typegpu/babel'],
|
|
23
34
|
};
|
|
24
35
|
};
|
|
25
|
-
|
|
26
36
|
```
|
|
27
37
|
|
|
28
|
-
|
|
38
|
+
- vite
|
|
29
39
|
|
|
30
40
|
```ts
|
|
31
41
|
// vite.config.js
|
|
32
42
|
|
|
33
43
|
import { defineConfig } from 'vite';
|
|
34
|
-
import typegpu from 'unplugin-typegpu/
|
|
44
|
+
import typegpu from 'unplugin-typegpu/vite';
|
|
35
45
|
|
|
36
46
|
export default defineConfig({
|
|
37
47
|
plugins: [typegpu()],
|
|
38
48
|
});
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Getting Started
|
|
43
|
-
|
|
44
|
-
```sh
|
|
45
|
-
npm install unplugin-typegpu
|
|
46
49
|
```
|
|
47
50
|
|
|
48
51
|
## TypeGPU is created by Software Mansion
|
|
49
52
|
|
|
50
53
|
[](https://swmansion.com)
|
|
51
54
|
|
|
52
|
-
Since 2012 [Software Mansion](https://swmansion.com) is a software agency with
|
|
55
|
+
Since 2012 [Software Mansion](https://swmansion.com) is a software agency with
|
|
56
|
+
experience in building web and mobile apps. We are Core React Native
|
|
57
|
+
Contributors and experts in dealing with all kinds of React Native issues. We
|
|
58
|
+
can help you build your next dream product –
|
|
59
|
+
[Hire us](https://swmansion.com/contact/projects?utm_source=typegpu&utm_medium=readme).
|
package/babel.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBCOJLF4Tcjs = require('./chunk-BCOJLF4T.cjs');exports.default = _chunkBCOJLF4Tcjs.h;
|
|
2
2
|
//# sourceMappingURL=babel.cjs.map
|
package/babel.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/
|
|
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{h as a}from"./chunk-
|
|
1
|
+
import{h as a}from"./chunk-4ONRHQSA.js";export{a as default};
|
|
2
2
|
//# sourceMappingURL=babel.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var D=Object.defineProperty;var b=Object.getOwnPropertySymbols;var
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
var D=Object.defineProperty;var b=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var x=(e,n,t)=>n in e?D(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,V=(e,n)=>{for(var t in n||(n={}))O.call(n,t)&&x(e,t,n[t]);if(b)for(var t of b(n))R.call(n,t)&&x(e,t,n[t]);return e};import*as g from"@babel/standalone";import{transpileFn as P}from"tinyest-for-wgsl";var L={include:[/\.m?[jt]sx?$/]};function d(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function F(e,n){let t="",r=n;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 $=/import.*from\s*['"]typegpu.*['"]/,w=/import\s*\(\s*['"]\s*typegpu.*['"]/,N=/require\s*\(\s*['"]\s*typegpu.*['"]\s*\)/,E=[$,w,N];function A(e,n){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"?n.tgpuAliases.add(t.local.name):t.type==="ImportNamespaceSpecifier"&&n.tgpuAliases.add(`${t.local.name}.tgpu`)}var j=["fn","vertexFn","fragmentFn","computeFn"];function v(e,n){return e.callee.type==="CallExpression"&&e.callee.callee.type==="MemberExpression"&&e.callee.callee.property.type==="Identifier"&&j.includes(e.callee.callee.property.name)&&e.arguments.length===1&&(e.callee.callee.object.type==="MemberExpression"?F(n,e.callee.callee.object.object):F(n,e.callee.callee.object))||e.callee.type==="MemberExpression"&&e.arguments.length===1&&e.callee.property.type==="Identifier"&&e.callee.property.name==="does"}var I=["kernel","kernel & js"];import{resolve as h}from"node:path";import _ from"picomatch";function S(e){let n=e||[];return Array.isArray(n)?n:[n]}var z=/\\/g;function f(e){return e.replace(z,"/")}var B=/^(?:\/|(?:[A-Z]:)?[/\\|])/i;function J(e){return B.test(e)}function K(e,n){if(e.startsWith("**")||J(e))return f(e);let t=h(n,e);return f(t)}function k(e){if(e instanceof RegExp)return i=>{let o=f(i),l=e.test(o);return e.lastIndex=0,l};let n=process.cwd(),t=K(e,n),r=_(t,{dot:!0});return i=>{let o=f(i);return r(o)}}function M(e,n){if(!(!e&&!n))return t=>e!=null&&e.some(r=>r(t))?!1:n!=null&&n.some(r=>r(t))?!0:!(n&&n.length>0)}function W(e){return typeof e=="string"||e instanceof RegExp?{include:[e]}:Array.isArray(e)?{include:e}:{exclude:e.exclude?S(e.exclude):void 0,include:e.include?S(e.include):void 0}}function G(e){if(!e)return;let{exclude:n,include:t}=W(e),r=n==null?void 0:n.map(k),i=t==null?void 0:t.map(k);return M(r,i)}function T(e){let n=G(e);return n?t=>!!n(t):void 0}var c=g.packages.template,s=g.packages.types;function C(e){var t,r;let n=("directives"in e.body?(r=(t=e.body)==null?void 0:t.directives)!=null?r:[]:[]).map(i=>i.value.value);for(let i of I)if(n.includes(i))return i}function m(e,n,t){var p;let r=C(e);if(!r)return null;let{params:i,body:o,externalNames:l}=P(e),a=n.tgpuAliases.values().next().value;if(a===void 0)throw new Error(`No tgpu import found, cannot assign ast to function in file: ${(p=n.fileId)!=null?p:""}`);return s.callExpression(c.expression(`${a}.__assignAst`)(),[r==="kernel & js"?e:c.expression`${a}.__removedJsImpl(${t?`"${t}"`:""})`(),c.expression`${d({params:i,body:o,externalNames:l})}`(),s.objectExpression(l.map(u=>s.objectProperty(s.identifier(u),s.identifier(u))))])}function H(e){return{ImportDeclaration(n){A(n.node,e)},ArrowFunctionExpression(n){let t=m(n.node,e,n.parentPath.node.type==="VariableDeclarator"&&n.parentPath.node.id.type==="Identifier"?n.parentPath.node.id.name:void 0);t&&(n.replaceWith(t),n.skip())},FunctionExpression(n){var r;let t=m(n.node,e,(r=n.node.id)!=null&&r.name?n.node.id.name:n.parentPath.node.type==="VariableDeclarator"&&n.parentPath.node.id.type==="Identifier"?n.parentPath.node.id.name:void 0);t&&(n.replaceWith(t),n.skip())},FunctionDeclaration(n){var o;let t=n.node,r=s.functionExpression(t.id,t.params,t.body),i=m(r,e,(o=t.id)==null?void 0:o.name);i&&t.id&&(n.replaceWith(s.variableDeclaration("const",[s.variableDeclarator(t.id,i)])),n.skip())},CallExpression(n){var r;let t=n.node;if(v(t,e)){let i=t.arguments[0];if(i&&(i.type==="FunctionExpression"||i.type==="ArrowFunctionExpression")){let{params:o,body:l,externalNames:a}=P(i),p=e.tgpuAliases.values().next().value;if(p===void 0)throw new Error(`No tgpu import found, cannot assign ast to function in file: ${(r=e.fileId)!=null?r:""}`);let u=C(i);n.replaceWith(s.callExpression(t.callee,[s.callExpression(c.expression(`${p}.__assignAst`)(),[u!=="kernel & js"?c.expression`${p}.__removedJsImpl()`():i,c.expression`${d({params:o,body:l,externalNames:a})}`(),s.objectExpression(a.map(y=>s.objectProperty(s.identifier(y),s.identifier(y))))])])),n.skip()}}}}}function te(){return{visitor:{Program(e,n){var a;let t=(a=n.file)==null?void 0:a.code,r=n.opts,i=n.filename,o=T(r);if(i&&o&&!(o!=null&&o(i))||!(r!=null&&r.forceTgpuAlias)&&t&&!E.some(p=>p.test(t)))return;let l={tgpuAliases:new Set(r!=null&&r.forceTgpuAlias?[r.forceTgpuAlias]:[]),fileId:i};e.traverse(H(l))}}}}export{V as a,L as b,d as c,E as d,A as e,v as f,I as g,te as h};
|
|
2
|
+
//# sourceMappingURL=chunk-4ONRHQSA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/babel.ts","../src/common.ts","../src/filter.ts"],"sourcesContent":["import * as Babel from '@babel/standalone';\nimport type TemplateGenerator from '@babel/template';\nimport type { TraverseOptions } from '@babel/traverse';\nimport type * as babel from '@babel/types';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport {\n codeFilterRegexes,\n type Context,\n embedJSON,\n gatherTgpuAliases,\n isShellImplementationCall,\n type KernelDirective,\n kernelDirectives,\n type Options,\n} from './common.ts';\nimport { createFilterForId } from './filter.ts';\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 babel } })\n .packages.types;\n\nfunction getKernelDirective(\n node:\n | babel.FunctionDeclaration\n | babel.FunctionExpression\n | babel.ArrowFunctionExpression,\n): KernelDirective | undefined {\n const directives = (\n 'directives' in node.body ? (node.body?.directives ?? []) : []\n ).map((directive) => directive.value.value);\n\n for (const directive of kernelDirectives) {\n if (directives.includes(directive)) {\n return directive;\n }\n }\n}\n\nfunction functionToTranspiled(\n node: babel.ArrowFunctionExpression | babel.FunctionExpression,\n ctx: Context,\n name?: string | undefined,\n): babel.CallExpression | null {\n const directive = getKernelDirective(node);\n if (!directive) {\n return null;\n }\n\n const { params, body, externalNames } = transpileFn(node);\n const tgpuAlias = ctx.tgpuAliases.values().next().value;\n if (tgpuAlias === undefined) {\n throw new Error(\n `No tgpu import found, cannot assign ast to function in file: ${\n ctx.fileId ?? ''\n }`,\n );\n }\n\n return types.callExpression(\n template.expression(`${tgpuAlias}.__assignAst`)(),\n [\n directive === 'kernel & js'\n ? node\n : template.expression`${tgpuAlias}.__removedJsImpl(${\n name ? `\"${name}\"` : ''\n })`(),\n template.expression`${embedJSON({ params, body, externalNames })}`(),\n types.objectExpression(\n externalNames.map((name) =>\n types.objectProperty(types.identifier(name), types.identifier(name))\n ),\n ),\n ],\n );\n}\n\nfunction functionVisitor(ctx: Context): TraverseOptions {\n return {\n ImportDeclaration(path) {\n gatherTgpuAliases(path.node, ctx);\n },\n\n ArrowFunctionExpression(path) {\n const transpiled = functionToTranspiled(\n path.node,\n ctx,\n path.parentPath.node.type === 'VariableDeclarator'\n ? path.parentPath.node.id.type === 'Identifier'\n ? path.parentPath.node.id.name\n : undefined\n : undefined,\n );\n if (transpiled) {\n path.replaceWith(transpiled);\n path.skip();\n }\n },\n\n FunctionExpression(path) {\n const transpiled = functionToTranspiled(\n path.node,\n ctx,\n path.node.id?.name\n ? path.node.id.name\n : path.parentPath.node.type === 'VariableDeclarator'\n ? path.parentPath.node.id.type === 'Identifier'\n ? path.parentPath.node.id.name\n : undefined\n : undefined,\n );\n if (transpiled) {\n path.replaceWith(transpiled);\n path.skip();\n }\n },\n\n FunctionDeclaration(path) {\n const node = path.node;\n const expression = types.functionExpression(\n node.id,\n node.params,\n node.body,\n );\n const transpiled = functionToTranspiled(expression, ctx, node.id?.name);\n if (transpiled && node.id) {\n path.replaceWith(\n types.variableDeclaration('const', [\n types.variableDeclarator(node.id, transpiled),\n ]),\n );\n path.skip();\n }\n },\n\n CallExpression(path) {\n const node = path.node;\n\n if (isShellImplementationCall(node, ctx)) {\n const implementation = node.arguments[0];\n\n if (\n implementation &&\n (implementation.type === 'FunctionExpression' ||\n implementation.type === 'ArrowFunctionExpression')\n ) {\n const { params, body, externalNames } = transpileFn(implementation);\n const tgpuAlias = ctx.tgpuAliases.values().next().value;\n if (tgpuAlias === undefined) {\n throw new Error(\n `No tgpu import found, cannot assign ast to function in file: ${\n ctx.fileId ?? ''\n }`,\n );\n }\n\n const directive = getKernelDirective(implementation);\n\n path.replaceWith(\n types.callExpression(node.callee, [\n types.callExpression(\n template.expression(`${tgpuAlias}.__assignAst`)(),\n [\n directive !== 'kernel & js'\n ? template.expression`${tgpuAlias}.__removedJsImpl()`()\n : implementation,\n template.expression`${\n embedJSON({ params, body, externalNames })\n }`(),\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\n path.skip();\n }\n }\n },\n };\n}\n\nexport default function () {\n return {\n visitor: {\n Program(path, state) {\n // biome-ignore lint/suspicious/noExplicitAny: <oh babel babel...>\n const code: string | undefined = (state as any).file?.code;\n // biome-ignore lint/suspicious/noExplicitAny: <oh babel babel...>\n const options: Options | undefined = (state as any).opts;\n // biome-ignore lint/suspicious/noExplicitAny: <oh babel babel...>\n const id: string | undefined = (state as any).filename;\n\n const filter = createFilterForId(options);\n if (id && filter && !filter?.(id)) {\n return;\n }\n\n if (\n !options?.forceTgpuAlias &&\n code &&\n !codeFilterRegexes.some((reg) => reg.test(code))\n ) {\n return;\n }\n\n const ctx: Context = {\n tgpuAliases: new Set<string>(\n options?.forceTgpuAlias ? [options.forceTgpuAlias] : [],\n ),\n fileId: id,\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';\nimport type { FilterPattern } from 'unplugin';\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 fileId?: string | undefined;\n};\n\nexport interface Options {\n include?: FilterPattern;\n exclude?: FilterPattern;\n enforce?: 'post' | 'pre' | undefined;\n forceTgpuAlias?: string;\n}\n\nexport const defaultOptions = {\n include: [/\\.m?[jt]sx?$/],\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.*['\"]/;\nconst typegpuDynamicImportRegex = /import\\s*\\(\\s*['\"]\\s*typegpu.*['\"]/;\nconst typegpuRequireRegex = /require\\s*\\(\\s*['\"]\\s*typegpu.*['\"]\\s*\\)/;\n\n/**\n * Regexes used to efficiently determine if a file is\n * meant to be processed by our plugin. We assume every file\n * that should be processed imports `typegpu` in some way.\n */\nexport const codeFilterRegexes = [\n typegpuImportRegex,\n typegpuDynamicImportRegex,\n typegpuRequireRegex,\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\nconst fnShellFunctionNames = ['fn', 'vertexFn', 'fragmentFn', 'computeFn'];\n\nexport function isShellImplementationCall(\n node: acorn.CallExpression | babel.CallExpression,\n ctx: Context,\n) {\n return (\n (node.callee.type === 'CallExpression' &&\n node.callee.callee.type === 'MemberExpression' &&\n node.callee.callee.property.type === 'Identifier' &&\n fnShellFunctionNames.includes(node.callee.callee.property.name) &&\n node.arguments.length === 1 &&\n (node.callee.callee.object.type === 'MemberExpression'\n ? isTgpu(ctx, node.callee.callee.object.object)\n : isTgpu(ctx, node.callee.callee.object))) || // TODO: remove along with the deprecated 'does' method\n (node.callee.type === 'MemberExpression' &&\n node.arguments.length === 1 &&\n node.callee.property.type === 'Identifier' &&\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\nexport const kernelDirectives = ['kernel', 'kernel & js'] as const;\nexport type KernelDirective = (typeof kernelDirectives)[number];\n","// Copied from https://github.com/unjs/unplugin/blob/f514bf8e2d751b48b3a5acb1077eb1292d9711b3/src/utils/filter.ts#L2\n// Used only in the babel version of the plugin, since others can rely on native unplugin functionality.\n\nimport { resolve } from 'node:path';\nimport picomatch from 'picomatch';\nimport type {\n Arrayable,\n Nullable,\n StringFilter,\n StringOrRegExp,\n} from 'unplugin';\n\nfunction toArray<T>(array?: Nullable<Arrayable<T>>): Array<T> {\n const result = array || [];\n if (Array.isArray(result)) return result;\n return [result];\n}\n\nconst BACKSLASH_REGEX = /\\\\/g;\nfunction normalize(path: string): string {\n return path.replace(BACKSLASH_REGEX, '/');\n}\n\nconst ABSOLUTE_PATH_REGEX = /^(?:\\/|(?:[A-Z]:)?[/\\\\|])/i;\nfunction isAbsolute(path: string): boolean {\n return ABSOLUTE_PATH_REGEX.test(path);\n}\n\nexport type PluginFilter = (input: string) => boolean;\nexport type TransformHookFilter = (id: string, code: string) => boolean;\n\ninterface NormalizedStringFilter {\n include?: StringOrRegExp[] | undefined;\n exclude?: StringOrRegExp[] | undefined;\n}\n\nfunction getMatcherString(glob: string, cwd: string) {\n if (glob.startsWith('**') || isAbsolute(glob)) {\n return normalize(glob);\n }\n\n const resolved = resolve(cwd, glob);\n return normalize(resolved);\n}\n\nfunction patternToIdFilter(pattern: StringOrRegExp): PluginFilter {\n if (pattern instanceof RegExp) {\n return (id: string) => {\n const normalizedId = normalize(id);\n const result = pattern.test(normalizedId);\n pattern.lastIndex = 0;\n return result;\n };\n }\n const cwd = process.cwd();\n const glob = getMatcherString(pattern, cwd);\n const matcher = picomatch(glob, { dot: true });\n return (id: string) => {\n const normalizedId = normalize(id);\n return matcher(normalizedId);\n };\n}\n\nfunction patternToCodeFilter(pattern: StringOrRegExp): PluginFilter {\n if (pattern instanceof RegExp) {\n return (code: string) => {\n const result = pattern.test(code);\n pattern.lastIndex = 0;\n return result;\n };\n }\n return (code: string) => code.includes(pattern);\n}\n\nfunction createFilter(\n exclude: PluginFilter[] | undefined,\n include: PluginFilter[] | undefined,\n): PluginFilter | undefined {\n if (!exclude && !include) {\n return;\n }\n\n return (input) => {\n if (exclude?.some((filter) => filter(input))) {\n return false;\n }\n if (include?.some((filter) => filter(input))) {\n return true;\n }\n return !(include && include.length > 0);\n };\n}\n\nfunction normalizeFilter(filter: StringFilter): NormalizedStringFilter {\n if (typeof filter === 'string' || filter instanceof RegExp) {\n return {\n include: [filter],\n };\n }\n if (Array.isArray(filter)) {\n return {\n include: filter,\n };\n }\n return {\n exclude: filter.exclude ? toArray(filter.exclude) : undefined,\n include: filter.include ? toArray(filter.include) : undefined,\n };\n}\n\nfunction createIdFilter(\n filter: StringFilter | undefined,\n): PluginFilter | undefined {\n if (!filter) return;\n const { exclude, include } = normalizeFilter(filter);\n const excludeFilter = exclude?.map(patternToIdFilter);\n const includeFilter = include?.map(patternToIdFilter);\n return createFilter(excludeFilter, includeFilter);\n}\n\nfunction createCodeFilter(\n filter: StringFilter | undefined,\n): PluginFilter | undefined {\n if (!filter) return;\n const { exclude, include } = normalizeFilter(filter);\n const excludeFilter = exclude?.map(patternToCodeFilter);\n const includeFilter = include?.map(patternToCodeFilter);\n return createFilter(excludeFilter, includeFilter);\n}\n\nexport function createFilterForId(\n filter: StringFilter | undefined,\n): PluginFilter | undefined {\n const filterFunction = createIdFilter(filter);\n return filterFunction ? (id) => !!filterFunction(id) : undefined;\n}\n\nfunction createFilterForTransform(\n idFilter: StringFilter | undefined,\n codeFilter: StringFilter | undefined,\n): TransformHookFilter | undefined {\n if (!idFilter && !codeFilter) return;\n const idFilterFunction = createIdFilter(idFilter);\n const codeFilterFunction = createCodeFilter(codeFilter);\n return (id, code) => {\n let fallback = true;\n if (idFilterFunction) {\n fallback &&= idFilterFunction(id);\n }\n if (!fallback) {\n return false;\n }\n\n if (codeFilterFunction) {\n fallback &&= codeFilterFunction(code);\n }\n return fallback;\n };\n}\n"],"mappings":"yVAAA,UAAYA,MAAW,oBAIvB,OAAS,eAAAC,MAAmB,mBCgBrB,IAAMC,EAAiB,CAC5B,QAAS,CAAC,cAAc,CAC1B,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,WAAWU,CAAI,CACvB,CACF,CACF,CACF,CACF,CACF,CAAC,CACH,EAEAQ,EAAK,KAAK,CACZ,CACF,CACF,CACF,CACF,CAEe,SAARM,IAAoB,CACzB,MAAO,CACL,QAAS,CACP,QAAQN,EAAMO,EAAO,CAnM3B,IAAAtB,EAqMQ,IAAMuB,GAA4BvB,EAAAsB,EAAc,OAAd,YAAAtB,EAAoB,KAEhDwB,EAAgCF,EAAc,KAE9CG,EAA0BH,EAAc,SAExCI,EAASC,EAAkBH,CAAO,EAKxC,GAJIC,GAAMC,GAAU,EAACA,GAAA,MAAAA,EAASD,KAK5B,EAACD,GAAA,MAAAA,EAAS,iBACVD,GACA,CAACK,EAAkB,KAAMC,GAAQA,EAAI,KAAKN,CAAI,CAAC,EAE/C,OAGF,IAAMjB,EAAe,CACnB,YAAa,IAAI,IACfkB,GAAA,MAAAA,EAAS,eAAiB,CAACA,EAAQ,cAAc,EAAI,CAAC,CACxD,EACA,OAAQC,CACV,EAEAV,EAAK,SAASD,EAAgBR,CAAG,CAAC,CACpC,CACF,CACF,CACF","names":["Babel","transpileFn","defaultOptions","embedJSON","jsValue","isTgpu","ctx","node","path","tail","typegpuImportRegex","typegpuDynamicImportRegex","typegpuRequireRegex","codeFilterRegexes","gatherTgpuAliases","spec","fnShellFunctionNames","isShellImplementationCall","kernelDirectives","resolve","picomatch","toArray","array","result","BACKSLASH_REGEX","normalize","path","ABSOLUTE_PATH_REGEX","isAbsolute","getMatcherString","glob","cwd","resolved","patternToIdFilter","pattern","id","normalizedId","matcher","createFilter","exclude","include","input","filter","normalizeFilter","toArray","createIdFilter","excludeFilter","patternToIdFilter","includeFilter","createFilterForId","filter","filterFunction","createIdFilter","id","template","types","getKernelDirective","node","_a","_b","directives","directive","kernelDirectives","functionToTranspiled","ctx","name","params","body","externalNames","transpileFn","tgpuAlias","embedJSON","functionVisitor","path","gatherTgpuAliases","transpiled","expression","isShellImplementationCall","implementation","babel_default","state","code","options","id","filter","createFilterForId","codeFilterRegexes","reg"]}
|
|
@@ -1,2 +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; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var D=Object.defineProperty;var b=Object.getOwnPropertySymbols;var
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
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; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var D=Object.defineProperty;var b=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var x=(e,n,t)=>n in e?D(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,V= exports.a =(e,n)=>{for(var t in n||(n={}))O.call(n,t)&&x(e,t,n[t]);if(b)for(var t of b(n))R.call(n,t)&&x(e,t,n[t]);return e};var _standalone = require('@babel/standalone'); var g = _interopRequireWildcard(_standalone);var _tinyestforwgsl = require('tinyest-for-wgsl');var L={include:[/\.m?[jt]sx?$/]};function d(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function F(e,n){let t="",r=n;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 $=/import.*from\s*['"]typegpu.*['"]/,w=/import\s*\(\s*['"]\s*typegpu.*['"]/,N=/require\s*\(\s*['"]\s*typegpu.*['"]\s*\)/,E= exports.d =[$,w,N];function A(e,n){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"?n.tgpuAliases.add(t.local.name):t.type==="ImportNamespaceSpecifier"&&n.tgpuAliases.add(`${t.local.name}.tgpu`)}var j=["fn","vertexFn","fragmentFn","computeFn"];function v(e,n){return e.callee.type==="CallExpression"&&e.callee.callee.type==="MemberExpression"&&e.callee.callee.property.type==="Identifier"&&j.includes(e.callee.callee.property.name)&&e.arguments.length===1&&(e.callee.callee.object.type==="MemberExpression"?F(n,e.callee.callee.object.object):F(n,e.callee.callee.object))||e.callee.type==="MemberExpression"&&e.arguments.length===1&&e.callee.property.type==="Identifier"&&e.callee.property.name==="does"}var I=["kernel","kernel & js"];var _path = require('path');var _picomatch = require('picomatch'); var _picomatch2 = _interopRequireDefault(_picomatch);function S(e){let n=e||[];return Array.isArray(n)?n:[n]}var z=/\\/g;function f(e){return e.replace(z,"/")}var B=/^(?:\/|(?:[A-Z]:)?[/\\|])/i;function J(e){return B.test(e)}function K(e,n){if(e.startsWith("**")||J(e))return f(e);let t=_path.resolve.call(void 0, n,e);return f(t)}function k(e){if(e instanceof RegExp)return i=>{let o=f(i),l=e.test(o);return e.lastIndex=0,l};let n=process.cwd(),t=K(e,n),r=_picomatch2.default.call(void 0, t,{dot:!0});return i=>{let o=f(i);return r(o)}}function M(e,n){if(!(!e&&!n))return t=>e!=null&&e.some(r=>r(t))?!1:n!=null&&n.some(r=>r(t))?!0:!(n&&n.length>0)}function W(e){return typeof e=="string"||e instanceof RegExp?{include:[e]}:Array.isArray(e)?{include:e}:{exclude:e.exclude?S(e.exclude):void 0,include:e.include?S(e.include):void 0}}function G(e){if(!e)return;let{exclude:n,include:t}=W(e),r=n==null?void 0:n.map(k),i=t==null?void 0:t.map(k);return M(r,i)}function T(e){let n=G(e);return n?t=>!!n(t):void 0}var c=g.packages.template,s=g.packages.types;function C(e){var t,r;let n=("directives"in e.body?(r=(t=e.body)==null?void 0:t.directives)!=null?r:[]:[]).map(i=>i.value.value);for(let i of I)if(n.includes(i))return i}function m(e,n,t){var p;let r=C(e);if(!r)return null;let{params:i,body:o,externalNames:l}=_tinyestforwgsl.transpileFn.call(void 0, e),a=n.tgpuAliases.values().next().value;if(a===void 0)throw new Error(`No tgpu import found, cannot assign ast to function in file: ${(p=n.fileId)!=null?p:""}`);return s.callExpression(c.expression(`${a}.__assignAst`)(),[r==="kernel & js"?e:c.expression`${a}.__removedJsImpl(${t?`"${t}"`:""})`(),c.expression`${d({params:i,body:o,externalNames:l})}`(),s.objectExpression(l.map(u=>s.objectProperty(s.identifier(u),s.identifier(u))))])}function H(e){return{ImportDeclaration(n){A(n.node,e)},ArrowFunctionExpression(n){let t=m(n.node,e,n.parentPath.node.type==="VariableDeclarator"&&n.parentPath.node.id.type==="Identifier"?n.parentPath.node.id.name:void 0);t&&(n.replaceWith(t),n.skip())},FunctionExpression(n){var r;let t=m(n.node,e,(r=n.node.id)!=null&&r.name?n.node.id.name:n.parentPath.node.type==="VariableDeclarator"&&n.parentPath.node.id.type==="Identifier"?n.parentPath.node.id.name:void 0);t&&(n.replaceWith(t),n.skip())},FunctionDeclaration(n){var o;let t=n.node,r=s.functionExpression(t.id,t.params,t.body),i=m(r,e,(o=t.id)==null?void 0:o.name);i&&t.id&&(n.replaceWith(s.variableDeclaration("const",[s.variableDeclarator(t.id,i)])),n.skip())},CallExpression(n){var r;let t=n.node;if(v(t,e)){let i=t.arguments[0];if(i&&(i.type==="FunctionExpression"||i.type==="ArrowFunctionExpression")){let{params:o,body:l,externalNames:a}=_tinyestforwgsl.transpileFn.call(void 0, i),p=e.tgpuAliases.values().next().value;if(p===void 0)throw new Error(`No tgpu import found, cannot assign ast to function in file: ${(r=e.fileId)!=null?r:""}`);let u=C(i);n.replaceWith(s.callExpression(t.callee,[s.callExpression(c.expression(`${p}.__assignAst`)(),[u!=="kernel & js"?c.expression`${p}.__removedJsImpl()`():i,c.expression`${d({params:o,body:l,externalNames:a})}`(),s.objectExpression(a.map(y=>s.objectProperty(s.identifier(y),s.identifier(y))))])])),n.skip()}}}}}function te(){return{visitor:{Program(e,n){var a;let t=(a=n.file)==null?void 0:a.code,r=n.opts,i=n.filename,o=T(r);if(i&&o&&!(o!=null&&o(i))||!(r!=null&&r.forceTgpuAlias)&&t&&!E.some(p=>p.test(t)))return;let l={tgpuAliases:new Set(r!=null&&r.forceTgpuAlias?[r.forceTgpuAlias]:[]),fileId:i};e.traverse(H(l))}}}}exports.a = V; exports.b = L; exports.c = d; exports.d = E; exports.e = A; exports.f = v; exports.g = I; exports.h = te;
|
|
2
|
+
//# sourceMappingURL=chunk-BCOJLF4T.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/chunk-BCOJLF4T.cjs","../src/babel.ts","../src/common.ts"],"names":["defaultOptions","embedJSON","jsValue","isTgpu","ctx","node","path","tail"],"mappings":"AAAA,+bAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CCAxV,6FAAuB,kDAIK,ICgBfA,CAAAA,CAAiB,CAC5B,OAAA,CAAS,CAAC,cAAc,CAC1B,CAAA,CAEO,SAASC,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-BCOJLF4T.cjs","sourcesContent":[null,"import * as Babel from '@babel/standalone';\nimport type TemplateGenerator from '@babel/template';\nimport type { TraverseOptions } from '@babel/traverse';\nimport type * as babel from '@babel/types';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport {\n codeFilterRegexes,\n type Context,\n embedJSON,\n gatherTgpuAliases,\n isShellImplementationCall,\n type KernelDirective,\n kernelDirectives,\n type Options,\n} from './common.ts';\nimport { createFilterForId } from './filter.ts';\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 babel } })\n .packages.types;\n\nfunction getKernelDirective(\n node:\n | babel.FunctionDeclaration\n | babel.FunctionExpression\n | babel.ArrowFunctionExpression,\n): KernelDirective | undefined {\n const directives = (\n 'directives' in node.body ? (node.body?.directives ?? []) : []\n ).map((directive) => directive.value.value);\n\n for (const directive of kernelDirectives) {\n if (directives.includes(directive)) {\n return directive;\n }\n }\n}\n\nfunction functionToTranspiled(\n node: babel.ArrowFunctionExpression | babel.FunctionExpression,\n ctx: Context,\n name?: string | undefined,\n): babel.CallExpression | null {\n const directive = getKernelDirective(node);\n if (!directive) {\n return null;\n }\n\n const { params, body, externalNames } = transpileFn(node);\n const tgpuAlias = ctx.tgpuAliases.values().next().value;\n if (tgpuAlias === undefined) {\n throw new Error(\n `No tgpu import found, cannot assign ast to function in file: ${\n ctx.fileId ?? ''\n }`,\n );\n }\n\n return types.callExpression(\n template.expression(`${tgpuAlias}.__assignAst`)(),\n [\n directive === 'kernel & js'\n ? node\n : template.expression`${tgpuAlias}.__removedJsImpl(${\n name ? `\"${name}\"` : ''\n })`(),\n template.expression`${embedJSON({ params, body, externalNames })}`(),\n types.objectExpression(\n externalNames.map((name) =>\n types.objectProperty(types.identifier(name), types.identifier(name))\n ),\n ),\n ],\n );\n}\n\nfunction functionVisitor(ctx: Context): TraverseOptions {\n return {\n ImportDeclaration(path) {\n gatherTgpuAliases(path.node, ctx);\n },\n\n ArrowFunctionExpression(path) {\n const transpiled = functionToTranspiled(\n path.node,\n ctx,\n path.parentPath.node.type === 'VariableDeclarator'\n ? path.parentPath.node.id.type === 'Identifier'\n ? path.parentPath.node.id.name\n : undefined\n : undefined,\n );\n if (transpiled) {\n path.replaceWith(transpiled);\n path.skip();\n }\n },\n\n FunctionExpression(path) {\n const transpiled = functionToTranspiled(\n path.node,\n ctx,\n path.node.id?.name\n ? path.node.id.name\n : path.parentPath.node.type === 'VariableDeclarator'\n ? path.parentPath.node.id.type === 'Identifier'\n ? path.parentPath.node.id.name\n : undefined\n : undefined,\n );\n if (transpiled) {\n path.replaceWith(transpiled);\n path.skip();\n }\n },\n\n FunctionDeclaration(path) {\n const node = path.node;\n const expression = types.functionExpression(\n node.id,\n node.params,\n node.body,\n );\n const transpiled = functionToTranspiled(expression, ctx, node.id?.name);\n if (transpiled && node.id) {\n path.replaceWith(\n types.variableDeclaration('const', [\n types.variableDeclarator(node.id, transpiled),\n ]),\n );\n path.skip();\n }\n },\n\n CallExpression(path) {\n const node = path.node;\n\n if (isShellImplementationCall(node, ctx)) {\n const implementation = node.arguments[0];\n\n if (\n implementation &&\n (implementation.type === 'FunctionExpression' ||\n implementation.type === 'ArrowFunctionExpression')\n ) {\n const { params, body, externalNames } = transpileFn(implementation);\n const tgpuAlias = ctx.tgpuAliases.values().next().value;\n if (tgpuAlias === undefined) {\n throw new Error(\n `No tgpu import found, cannot assign ast to function in file: ${\n ctx.fileId ?? ''\n }`,\n );\n }\n\n const directive = getKernelDirective(implementation);\n\n path.replaceWith(\n types.callExpression(node.callee, [\n types.callExpression(\n template.expression(`${tgpuAlias}.__assignAst`)(),\n [\n directive !== 'kernel & js'\n ? template.expression`${tgpuAlias}.__removedJsImpl()`()\n : implementation,\n template.expression`${\n embedJSON({ params, body, externalNames })\n }`(),\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\n path.skip();\n }\n }\n },\n };\n}\n\nexport default function () {\n return {\n visitor: {\n Program(path, state) {\n // biome-ignore lint/suspicious/noExplicitAny: <oh babel babel...>\n const code: string | undefined = (state as any).file?.code;\n // biome-ignore lint/suspicious/noExplicitAny: <oh babel babel...>\n const options: Options | undefined = (state as any).opts;\n // biome-ignore lint/suspicious/noExplicitAny: <oh babel babel...>\n const id: string | undefined = (state as any).filename;\n\n const filter = createFilterForId(options);\n if (id && filter && !filter?.(id)) {\n return;\n }\n\n if (\n !options?.forceTgpuAlias &&\n code &&\n !codeFilterRegexes.some((reg) => reg.test(code))\n ) {\n return;\n }\n\n const ctx: Context = {\n tgpuAliases: new Set<string>(\n options?.forceTgpuAlias ? [options.forceTgpuAlias] : [],\n ),\n fileId: id,\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';\nimport type { FilterPattern } from 'unplugin';\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 fileId?: string | undefined;\n};\n\nexport interface Options {\n include?: FilterPattern;\n exclude?: FilterPattern;\n enforce?: 'post' | 'pre' | undefined;\n forceTgpuAlias?: string;\n}\n\nexport const defaultOptions = {\n include: [/\\.m?[jt]sx?$/],\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.*['\"]/;\nconst typegpuDynamicImportRegex = /import\\s*\\(\\s*['\"]\\s*typegpu.*['\"]/;\nconst typegpuRequireRegex = /require\\s*\\(\\s*['\"]\\s*typegpu.*['\"]\\s*\\)/;\n\n/**\n * Regexes used to efficiently determine if a file is\n * meant to be processed by our plugin. We assume every file\n * that should be processed imports `typegpu` in some way.\n */\nexport const codeFilterRegexes = [\n typegpuImportRegex,\n typegpuDynamicImportRegex,\n typegpuRequireRegex,\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\nconst fnShellFunctionNames = ['fn', 'vertexFn', 'fragmentFn', 'computeFn'];\n\nexport function isShellImplementationCall(\n node: acorn.CallExpression | babel.CallExpression,\n ctx: Context,\n) {\n return (\n (node.callee.type === 'CallExpression' &&\n node.callee.callee.type === 'MemberExpression' &&\n node.callee.callee.property.type === 'Identifier' &&\n fnShellFunctionNames.includes(node.callee.callee.property.name) &&\n node.arguments.length === 1 &&\n (node.callee.callee.object.type === 'MemberExpression'\n ? isTgpu(ctx, node.callee.callee.object.object)\n : isTgpu(ctx, node.callee.callee.object))) || // TODO: remove along with the deprecated 'does' method\n (node.callee.type === 'MemberExpression' &&\n node.arguments.length === 1 &&\n node.callee.property.type === 'Identifier' &&\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\nexport const kernelDirectives = ['kernel', 'kernel & js'] as const;\nexport type KernelDirective = (typeof kernelDirectives)[number];\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as x,b as v,c as b,d as F,e as w,f as h,g,h as D}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as x,b as v,c as b,d as F,e as w,f as h,g,h as D}from"./chunk-4ONRHQSA.js";import I from"defu";import{walk as N}from"estree-walker";import{generateTransform as S,MagicStringAST as P}from"magic-string-ast";import{transpileFn as K}from"tinyest-for-wgsl";import{createUnplugin as J}from"unplugin";function k(c){if(c.body.type==="BlockStatement"){for(let n of c.body.body)if(n.type==="ExpressionStatement"&&g.includes(n.directive))return n.directive}}function A(c){let n=structuredClone(c);return n.body.type==="BlockStatement"&&(n.body.body=n.body.body.filter(s=>!(s.type==="ExpressionStatement"&&s.directive&&g.includes(s.directive)))),n}var r=J(c=>{let n=I(c,v);return{name:"unplugin-typegpu",enforce:n.enforce,transform:{filter:x({id:n},n.forceTgpuAlias?{}:{code:F}),handler(s,l){let d={tgpuAliases:new Set(n.forceTgpuAlias?[n.forceTgpuAlias]:[]),fileId:l},$=this.parse(s,{allowReturnOutsideFunction:!0}),u=[],p=new P(s);N($,{enter(i,t,m,y){var a;let e=i;if(e.type==="ImportDeclaration"&&w(e,d),e.type==="CallExpression"&&h(e,d)){let o=e.arguments[0];if(o&&(o.type==="FunctionExpression"||o.type==="ArrowFunctionExpression")){let E=k(o);u.push({def:A(o),removeJsImplementation:E!=="kernel & js"}),this.skip()}}if(e.type==="ArrowFunctionExpression"||e.type==="FunctionExpression"||e.type==="FunctionDeclaration"){let o=k(e);o&&(u.push({def:A(e),name:e.type==="FunctionDeclaration"||e.type==="FunctionExpression"?(a=e.id)==null?void 0:a.name:(t==null?void 0:t.type)==="VariableDeclarator"&&t.id.type==="Identifier"?t.id.name:void 0,removeJsImplementation:o!=="kernel & js"}),this.skip())}}});let f=d.tgpuAliases.values().next().value;if(f===void 0&&u.length>0)throw new Error(`No tgpu import found, cannot assign ast to function in file: ${l}`);for(let{def:i,name:t,removeJsImplementation:m}of u){let{params:y,body:e,externalNames:a}=K(i),o=i.type==="FunctionDeclaration";if(o&&t&&s.slice(0,i.start).search(new RegExp(`(?<![\\w_.])${t}(?![\\w_])`))!==-1)throw new Error(`File ${l}: function "${t}", containing ${m?"kernel":"kernel & js"} directive, is referenced before its usage. Function statements are no longer hoisted after being transformed by the plugin.`);p.appendLeft(i.start,`${o&&t?`const ${t} = `:""}${f}.__assignAst(`),p.appendRight(i.end,`, ${b({params:y,body:e,externalNames:a})}`),a.length>0?p.appendRight(i.end,`, {${a.join(", ")}})`):p.appendRight(i.end,`)${o&&t?";":""}`),m&&p.overwriteNode(i,`${f}.__removedJsImpl(${t?`"${t}"`:""})`)}return S(p,l)}}}}),L=r,M=r.vite,V=r.rollup,q=r.rolldown,z=r.webpack,G=r.rspack,H=r.esbuild,Q=r.farm,W=D;export{L as a,M as b,V as c,q as d,z as e,G as f,H as g,Q as h,W as i};
|
|
2
|
+
//# sourceMappingURL=chunk-CTUSYGR2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type * as acorn from 'acorn';\nimport defu from 'defu';\nimport { type Node, walk } from 'estree-walker';\nimport { generateTransform, MagicStringAST } from 'magic-string-ast';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport { createUnplugin, type UnpluginInstance } from 'unplugin';\nimport babel from './babel.ts';\nimport {\n codeFilterRegexes,\n type Context,\n defaultOptions,\n embedJSON,\n gatherTgpuAliases,\n isShellImplementationCall,\n type KernelDirective,\n kernelDirectives,\n type Options,\n} from './common.ts';\n\ntype FunctionNode =\n | acorn.FunctionDeclaration\n | acorn.AnonymousFunctionDeclaration\n | acorn.FunctionExpression\n | acorn.ArrowFunctionExpression;\n\nfunction getKernelDirective(node: FunctionNode): KernelDirective | undefined {\n if (node.body.type === 'BlockStatement') {\n for (const statement of node.body.body) {\n if (statement.type === 'ExpressionStatement') {\n if (kernelDirectives.includes(statement.directive as KernelDirective)) {\n return statement.directive as KernelDirective;\n }\n }\n }\n }\n}\n\nfunction removeKernelDirective(node: FunctionNode) {\n const cloned = structuredClone(node);\n\n if (cloned.body.type === 'BlockStatement') {\n cloned.body.body = cloned.body.body.filter(\n (statement) =>\n !(\n statement.type === 'ExpressionStatement' &&\n statement.directive &&\n kernelDirectives.includes(statement.directive as KernelDirective)\n ),\n );\n }\n\n return cloned;\n}\n\nconst typegpu: UnpluginInstance<Options, false> = createUnplugin(\n (rawOptions) => {\n const options = defu(rawOptions, defaultOptions);\n\n return {\n name: 'unplugin-typegpu' as const,\n enforce: options.enforce,\n transform: {\n filter: {\n id: options,\n ...(options.forceTgpuAlias ? {} : { code: codeFilterRegexes }),\n },\n handler(code, id) {\n const ctx: Context = {\n tgpuAliases: new Set<string>(\n options.forceTgpuAlias ? [options.forceTgpuAlias] : [],\n ),\n fileId: id,\n };\n\n const ast = this.parse(code, {\n allowReturnOutsideFunction: true,\n }) as Node;\n\n const tgslFunctionDefs: {\n def: FunctionNode;\n name?: string | undefined;\n removeJsImplementation: boolean;\n }[] = [];\n\n const magicString = new MagicStringAST(code);\n\n walk(ast, {\n enter(_node, _parent, prop, index) {\n const node = _node as acorn.AnyNode;\n\n if (node.type === 'ImportDeclaration') {\n gatherTgpuAliases(node, ctx);\n }\n\n if (node.type === 'CallExpression') {\n if (isShellImplementationCall(node, ctx)) {\n const implementation = node.arguments[0];\n\n if (\n implementation &&\n (implementation.type === 'FunctionExpression' ||\n implementation.type === 'ArrowFunctionExpression')\n ) {\n const directive = getKernelDirective(implementation);\n tgslFunctionDefs.push({\n def: removeKernelDirective(implementation),\n removeJsImplementation: directive !== 'kernel & js',\n });\n this.skip();\n }\n }\n }\n\n if (\n node.type === 'ArrowFunctionExpression' ||\n node.type === 'FunctionExpression' ||\n node.type === 'FunctionDeclaration'\n ) {\n const directive = getKernelDirective(node);\n if (directive) {\n tgslFunctionDefs.push({\n def: removeKernelDirective(node),\n name: node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression'\n ? node.id?.name\n : _parent?.type === 'VariableDeclarator'\n ? _parent.id.type === 'Identifier'\n ? _parent.id.name\n : undefined\n : undefined,\n removeJsImplementation: directive !== 'kernel & js',\n });\n this.skip();\n }\n }\n },\n });\n\n const tgpuAlias = ctx.tgpuAliases.values().next().value;\n\n if (tgpuAlias === undefined && tgslFunctionDefs.length > 0) {\n throw new Error(\n `No tgpu import found, cannot assign ast to function in file: ${id}`,\n );\n }\n\n for (\n const {\n def,\n name,\n removeJsImplementation,\n } of tgslFunctionDefs\n ) {\n const { params, body, externalNames } = transpileFn(def);\n const isFunctionStatement = def.type === 'FunctionDeclaration';\n\n if (\n isFunctionStatement &&\n name &&\n code\n .slice(0, def.start)\n .search(new RegExp(`(?<![\\\\w_.])${name}(?![\\\\w_])`)) !== -1\n ) {\n throw new Error(\n `File ${id}: function \"${name}\", containing ${\n removeJsImplementation ? 'kernel' : 'kernel & js'\n } directive, is referenced before its usage. Function statements are no longer hoisted after being transformed by the plugin.`,\n );\n }\n\n // Wrap the implementation in a call to `tgpu.__assignAst` to associate the AST with the implementation.\n magicString.appendLeft(\n def.start,\n `${\n isFunctionStatement && name ? `const ${name} = ` : ''\n }${tgpuAlias}.__assignAst(`,\n );\n magicString.appendRight(\n def.end,\n `, ${embedJSON({ params, body, externalNames })}`,\n );\n\n if (externalNames.length > 0) {\n magicString.appendRight(\n def.end,\n `, {${externalNames.join(', ')}})`,\n );\n } else {\n magicString.appendRight(\n def.end,\n `)${isFunctionStatement && name ? ';' : ''}`,\n );\n }\n\n if (removeJsImplementation) {\n magicString.overwriteNode(\n def,\n `${tgpuAlias}.__removedJsImpl(${name ? `\"${name}\"` : ''})`,\n );\n }\n }\n\n return generateTransform(magicString, id);\n },\n },\n };\n },\n);\n\nexport type { Options } from './common.ts';\n\nexport default typegpu;\n\nexport const vitePlugin = typegpu.vite;\nexport const rollupPlugin = typegpu.rollup;\nexport const rolldownPlugin = typegpu.rolldown;\nexport const webpackPlugin = typegpu.webpack;\nexport const rspackPlugin = typegpu.rspack;\nexport const esbuildPlugin = typegpu.esbuild;\nexport const farmPlugin = typegpu.farm;\nexport const babelPlugin = babel;\n"],"mappings":"oFACA,OAAOA,MAAU,OACjB,OAAoB,QAAAC,MAAY,gBAChC,OAAS,qBAAAC,EAAmB,kBAAAC,MAAsB,mBAClD,OAAS,eAAAC,MAAmB,mBAC5B,OAAS,kBAAAC,MAA6C,WAoBtD,SAASC,EAAmBC,EAAiD,CAC3E,GAAIA,EAAK,KAAK,OAAS,kBACrB,QAAWC,KAAaD,EAAK,KAAK,KAChC,GAAIC,EAAU,OAAS,uBACjBC,EAAiB,SAASD,EAAU,SAA4B,EAClE,OAAOA,EAAU,UAK3B,CAEA,SAASE,EAAsBH,EAAoB,CACjD,IAAMI,EAAS,gBAAgBJ,CAAI,EAEnC,OAAII,EAAO,KAAK,OAAS,mBACvBA,EAAO,KAAK,KAAOA,EAAO,KAAK,KAAK,OACjCH,GACC,EACEA,EAAU,OAAS,uBACnBA,EAAU,WACVC,EAAiB,SAASD,EAAU,SAA4B,EAEtE,GAGKG,CACT,CAEA,IAAMC,EAA4CC,EAC/CC,GAAe,CACd,IAAMC,EAAUC,EAAKF,EAAYG,CAAc,EAE/C,MAAO,CACL,KAAM,mBACN,QAASF,EAAQ,QACjB,UAAW,CACT,OAAQG,EAAA,CACN,GAAIH,GACAA,EAAQ,eAAiB,CAAC,EAAI,CAAE,KAAMI,CAAkB,GAE9D,QAAQC,EAAMC,EAAI,CAChB,IAAMC,EAAe,CACnB,YAAa,IAAI,IACfP,EAAQ,eAAiB,CAACA,EAAQ,cAAc,EAAI,CAAC,CACvD,EACA,OAAQM,CACV,EAEME,EAAM,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cAAAC,CAAc,EAAIC,EAAYN,CAAG,EACjDO,EAAsBP,EAAI,OAAS,sBAEzC,GACEO,GACAN,GACAnB,EACK,MAAM,EAAGkB,EAAI,KAAK,EAClB,OAAO,IAAI,OAAO,eAAeC,CAAI,YAAY,CAAC,IAAM,GAE7D,MAAM,IAAI,MACR,QAAQlB,CAAE,eAAekB,CAAI,iBAC3BC,EAAyB,SAAW,aACtC,8HACF,EAIFf,EAAY,WACVa,EAAI,MACJ,GACEO,GAAuBN,EAAO,SAASA,CAAI,MAAQ,EACrD,GAAGF,CAAS,eACd,EACAZ,EAAY,YACVa,EAAI,IACJ,KAAKQ,EAAU,CAAE,OAAAL,EAAQ,KAAAC,EAAM,cAAAC,CAAc,CAAC,CAAC,EACjD,EAEIA,EAAc,OAAS,EACzBlB,EAAY,YACVa,EAAI,IACJ,MAAMK,EAAc,KAAK,IAAI,CAAC,IAChC,EAEAlB,EAAY,YACVa,EAAI,IACJ,IAAIO,GAAuBN,EAAO,IAAM,EAAE,EAC5C,EAGEC,GACFf,EAAY,cACVa,EACA,GAAGD,CAAS,oBAAoBE,EAAO,IAAIA,CAAI,IAAM,EAAE,GACzD,CAEJ,CAEA,OAAOQ,EAAkBtB,EAAaJ,CAAE,CAC1C,CACF,CACF,CACF,CACF,EAIO2B,EAAQpC,EAEFqC,EAAarC,EAAQ,KACrBsC,EAAetC,EAAQ,OACvBuC,EAAiBvC,EAAQ,SACzBwC,EAAgBxC,EAAQ,QACxByC,EAAezC,EAAQ,OACvB0C,EAAgB1C,EAAQ,QACxB2C,EAAa3C,EAAQ,KACrB4C,EAAcC","names":["defu","walk","generateTransform","MagicStringAST","transpileFn","createUnplugin","getKernelDirective","node","statement","kernelDirectives","removeKernelDirective","cloned","typegpu","createUnplugin","rawOptions","options","defu","defaultOptions","__spreadValues","codeFilterRegexes","code","id","ctx","ast","tgslFunctionDefs","magicString","MagicStringAST","walk","_node","_parent","prop","index","_a","gatherTgpuAliases","isShellImplementationCall","implementation","directive","tgpuAlias","def","name","removeJsImplementation","params","body","externalNames","transpileFn","isFunctionStatement","embedJSON","generateTransform","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 _chunkBCOJLF4Tcjs = require('./chunk-BCOJLF4T.cjs');var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);var _estreewalker = require('estree-walker');var _magicstringast = require('magic-string-ast');var _tinyestforwgsl = require('tinyest-for-wgsl');var _unplugin = require('unplugin');function k(c){if(c.body.type==="BlockStatement"){for(let n of c.body.body)if(n.type==="ExpressionStatement"&&_chunkBCOJLF4Tcjs.g.includes(n.directive))return n.directive}}function A(c){let n=structuredClone(c);return n.body.type==="BlockStatement"&&(n.body.body=n.body.body.filter(s=>!(s.type==="ExpressionStatement"&&s.directive&&_chunkBCOJLF4Tcjs.g.includes(s.directive)))),n}var r=_unplugin.createUnplugin.call(void 0, c=>{let n=_defu2.default.call(void 0, c,_chunkBCOJLF4Tcjs.b);return{name:"unplugin-typegpu",enforce:n.enforce,transform:{filter:_chunkBCOJLF4Tcjs.a.call(void 0, {id:n},n.forceTgpuAlias?{}:{code:_chunkBCOJLF4Tcjs.d}),handler(s,l){let d={tgpuAliases:new Set(n.forceTgpuAlias?[n.forceTgpuAlias]:[]),fileId:l},$=this.parse(s,{allowReturnOutsideFunction:!0}),u=[],p=new (0, _magicstringast.MagicStringAST)(s);_estreewalker.walk.call(void 0, $,{enter(i,t,m,y){var a;let e=i;if(e.type==="ImportDeclaration"&&_chunkBCOJLF4Tcjs.e.call(void 0, e,d),e.type==="CallExpression"&&_chunkBCOJLF4Tcjs.f.call(void 0, e,d)){let o=e.arguments[0];if(o&&(o.type==="FunctionExpression"||o.type==="ArrowFunctionExpression")){let E=k(o);u.push({def:A(o),removeJsImplementation:E!=="kernel & js"}),this.skip()}}if(e.type==="ArrowFunctionExpression"||e.type==="FunctionExpression"||e.type==="FunctionDeclaration"){let o=k(e);o&&(u.push({def:A(e),name:e.type==="FunctionDeclaration"||e.type==="FunctionExpression"?(a=e.id)==null?void 0:a.name:(t==null?void 0:t.type)==="VariableDeclarator"&&t.id.type==="Identifier"?t.id.name:void 0,removeJsImplementation:o!=="kernel & js"}),this.skip())}}});let f=d.tgpuAliases.values().next().value;if(f===void 0&&u.length>0)throw new Error(`No tgpu import found, cannot assign ast to function in file: ${l}`);for(let{def:i,name:t,removeJsImplementation:m}of u){let{params:y,body:e,externalNames:a}=_tinyestforwgsl.transpileFn.call(void 0, i),o=i.type==="FunctionDeclaration";if(o&&t&&s.slice(0,i.start).search(new RegExp(`(?<![\\w_.])${t}(?![\\w_])`))!==-1)throw new Error(`File ${l}: function "${t}", containing ${m?"kernel":"kernel & js"} directive, is referenced before its usage. Function statements are no longer hoisted after being transformed by the plugin.`);p.appendLeft(i.start,`${o&&t?`const ${t} = `:""}${f}.__assignAst(`),p.appendRight(i.end,`, ${_chunkBCOJLF4Tcjs.c.call(void 0, {params:y,body:e,externalNames:a})}`),a.length>0?p.appendRight(i.end,`, {${a.join(", ")}})`):p.appendRight(i.end,`)${o&&t?";":""}`),m&&p.overwriteNode(i,`${f}.__removedJsImpl(${t?`"${t}"`:""})`)}return _magicstringast.generateTransform.call(void 0, p,l)}}}}),L= exports.a =r,M= exports.b =r.vite,V= exports.c =r.rollup,q= exports.d =r.rolldown,z= exports.e =r.webpack,G= exports.f =r.rspack,H= exports.g =r.esbuild,Q= exports.h =r.farm,W= exports.i =_chunkBCOJLF4Tcjs.h;exports.a = L; exports.b = M; exports.c = V; exports.d = q; exports.e = z; exports.f = G; exports.g = H; exports.h = Q; exports.i = W;
|
|
2
|
+
//# sourceMappingURL=chunk-EPZPFIYG.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/chunk-EPZPFIYG.cjs","../src/index.ts"],"names":["getKernelDirective","node","statement","kernelDirectives","removeKernelDirective","cloned","typegpu","createUnplugin","rawOptions","options","defu","defaultOptions","__spreadValues","codeFilterRegexes","code","id","ctx","ast","tgslFunctionDefs","magicString","MagicStringAST","walk","_node","_parent","prop","index","_a","gatherTgpuAliases","isShellImplementationCall","implementation","directive","tgpuAlias"],"mappings":"AAAA,iOAAoF,wECCnE,6CACe,kDACkB,kDACtB,oCAC0B,SAoB7CA,CAAAA,CAAmBC,CAAAA,CAAiD,CAC3E,EAAA,CAAIA,CAAAA,CAAK,IAAA,CAAK,IAAA,GAAS,gBAAA,CAAA,CACrB,GAAA,CAAA,IAAWC,EAAAA,GAAaD,CAAAA,CAAK,IAAA,CAAK,IAAA,CAChC,EAAA,CAAIC,CAAAA,CAAU,IAAA,GAAS,qBAAA,EACjBC,mBAAAA,CAAiB,QAAA,CAASD,CAAAA,CAAU,SAA4B,CAAA,CAClE,OAAOA,CAAAA,CAAU,SAAA,CAK3B,CAEA,SAASE,CAAAA,CAAsBH,CAAAA,CAAoB,CACjD,IAAMI,CAAAA,CAAS,eAAA,CAAgBJ,CAAI,CAAA,CAEnC,OAAII,CAAAA,CAAO,IAAA,CAAK,IAAA,GAAS,gBAAA,EAAA,CACvBA,CAAAA,CAAO,IAAA,CAAK,IAAA,CAAOA,CAAAA,CAAO,IAAA,CAAK,IAAA,CAAK,MAAA,CACjCH,CAAAA,EACC,CAAA,CACEA,CAAAA,CAAU,IAAA,GAAS,qBAAA,EACnBA,CAAAA,CAAU,SAAA,EACVC,mBAAAA,CAAiB,QAAA,CAASD,CAAAA,CAAU,SAA4B,CAAA,CAEtE,CAAA,CAAA,CAGKG,CACT,CAEA,IAAMC,CAAAA,CAA4CC,sCAAAA,CAC/CC,EAAe,CACd,IAAMC,CAAAA,CAAUC,4BAAAA,CAAKF,CAAYG,mBAAc,CAAA,CAE/C,MAAO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CAAA,6DAAA,EAAgEH,CAAE,CAAA,CAAA","file":"/Users/iwo/Projects/wigsill/packages/unplugin-typegpu/dist/chunk-EPZPFIYG.cjs","sourcesContent":[null,"import type * as acorn from 'acorn';\nimport defu from 'defu';\nimport { type Node, walk } from 'estree-walker';\nimport { generateTransform, MagicStringAST } from 'magic-string-ast';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport { createUnplugin, type UnpluginInstance } from 'unplugin';\nimport babel from './babel.ts';\nimport {\n codeFilterRegexes,\n type Context,\n defaultOptions,\n embedJSON,\n gatherTgpuAliases,\n isShellImplementationCall,\n type KernelDirective,\n kernelDirectives,\n type Options,\n} from './common.ts';\n\ntype FunctionNode =\n | acorn.FunctionDeclaration\n | acorn.AnonymousFunctionDeclaration\n | acorn.FunctionExpression\n | acorn.ArrowFunctionExpression;\n\nfunction getKernelDirective(node: FunctionNode): KernelDirective | undefined {\n if (node.body.type === 'BlockStatement') {\n for (const statement of node.body.body) {\n if (statement.type === 'ExpressionStatement') {\n if (kernelDirectives.includes(statement.directive as KernelDirective)) {\n return statement.directive as KernelDirective;\n }\n }\n }\n }\n}\n\nfunction removeKernelDirective(node: FunctionNode) {\n const cloned = structuredClone(node);\n\n if (cloned.body.type === 'BlockStatement') {\n cloned.body.body = cloned.body.body.filter(\n (statement) =>\n !(\n statement.type === 'ExpressionStatement' &&\n statement.directive &&\n kernelDirectives.includes(statement.directive as KernelDirective)\n ),\n );\n }\n\n return cloned;\n}\n\nconst typegpu: UnpluginInstance<Options, false> = createUnplugin(\n (rawOptions) => {\n const options = defu(rawOptions, defaultOptions);\n\n return {\n name: 'unplugin-typegpu' as const,\n enforce: options.enforce,\n transform: {\n filter: {\n id: options,\n ...(options.forceTgpuAlias ? {} : { code: codeFilterRegexes }),\n },\n handler(code, id) {\n const ctx: Context = {\n tgpuAliases: new Set<string>(\n options.forceTgpuAlias ? [options.forceTgpuAlias] : [],\n ),\n fileId: id,\n };\n\n const ast = this.parse(code, {\n allowReturnOutsideFunction: true,\n }) as Node;\n\n const tgslFunctionDefs: {\n def: FunctionNode;\n name?: string | undefined;\n removeJsImplementation: boolean;\n }[] = [];\n\n const magicString = new MagicStringAST(code);\n\n walk(ast, {\n enter(_node, _parent, prop, index) {\n const node = _node as acorn.AnyNode;\n\n if (node.type === 'ImportDeclaration') {\n gatherTgpuAliases(node, ctx);\n }\n\n if (node.type === 'CallExpression') {\n if (isShellImplementationCall(node, ctx)) {\n const implementation = node.arguments[0];\n\n if (\n implementation &&\n (implementation.type === 'FunctionExpression' ||\n implementation.type === 'ArrowFunctionExpression')\n ) {\n const directive = getKernelDirective(implementation);\n tgslFunctionDefs.push({\n def: removeKernelDirective(implementation),\n removeJsImplementation: directive !== 'kernel & js',\n });\n this.skip();\n }\n }\n }\n\n if (\n node.type === 'ArrowFunctionExpression' ||\n node.type === 'FunctionExpression' ||\n node.type === 'FunctionDeclaration'\n ) {\n const directive = getKernelDirective(node);\n if (directive) {\n tgslFunctionDefs.push({\n def: removeKernelDirective(node),\n name: node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression'\n ? node.id?.name\n : _parent?.type === 'VariableDeclarator'\n ? _parent.id.type === 'Identifier'\n ? _parent.id.name\n : undefined\n : undefined,\n removeJsImplementation: directive !== 'kernel & js',\n });\n this.skip();\n }\n }\n },\n });\n\n const tgpuAlias = ctx.tgpuAliases.values().next().value;\n\n if (tgpuAlias === undefined && tgslFunctionDefs.length > 0) {\n throw new Error(\n `No tgpu import found, cannot assign ast to function in file: ${id}`,\n );\n }\n\n for (\n const {\n def,\n name,\n removeJsImplementation,\n } of tgslFunctionDefs\n ) {\n const { params, body, externalNames } = transpileFn(def);\n const isFunctionStatement = def.type === 'FunctionDeclaration';\n\n if (\n isFunctionStatement &&\n name &&\n code\n .slice(0, def.start)\n .search(new RegExp(`(?<![\\\\w_.])${name}(?![\\\\w_])`)) !== -1\n ) {\n throw new Error(\n `File ${id}: function \"${name}\", containing ${\n removeJsImplementation ? 'kernel' : 'kernel & js'\n } directive, is referenced before its usage. Function statements are no longer hoisted after being transformed by the plugin.`,\n );\n }\n\n // Wrap the implementation in a call to `tgpu.__assignAst` to associate the AST with the implementation.\n magicString.appendLeft(\n def.start,\n `${\n isFunctionStatement && name ? `const ${name} = ` : ''\n }${tgpuAlias}.__assignAst(`,\n );\n magicString.appendRight(\n def.end,\n `, ${embedJSON({ params, body, externalNames })}`,\n );\n\n if (externalNames.length > 0) {\n magicString.appendRight(\n def.end,\n `, {${externalNames.join(', ')}})`,\n );\n } else {\n magicString.appendRight(\n def.end,\n `)${isFunctionStatement && name ? ';' : ''}`,\n );\n }\n\n if (removeJsImplementation) {\n magicString.overwriteNode(\n def,\n `${tgpuAlias}.__removedJsImpl(${name ? `\"${name}\"` : ''})`,\n );\n }\n }\n\n return generateTransform(magicString, id);\n },\n },\n };\n },\n);\n\nexport type { Options } from './common.ts';\n\nexport default typegpu;\n\nexport const vitePlugin = typegpu.vite;\nexport const rollupPlugin = typegpu.rollup;\nexport const rolldownPlugin = typegpu.rolldown;\nexport const webpackPlugin = typegpu.webpack;\nexport const rspackPlugin = typegpu.rspack;\nexport const esbuildPlugin = typegpu.esbuild;\nexport const farmPlugin = typegpu.farm;\nexport const babelPlugin = babel;\n"]}
|
package/esbuild.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEPZPFIYGcjs = require('./chunk-EPZPFIYG.cjs');require('./chunk-BCOJLF4T.cjs');var l=_chunkEPZPFIYGcjs.g;exports.default = l;
|
|
2
2
|
//# sourceMappingURL=esbuild.cjs.map
|
package/esbuild.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/
|
|
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.ts';\n\nexport default esbuildPlugin;\n"]}
|
package/esbuild.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{g as e}from"./chunk-
|
|
1
|
+
import{g as e}from"./chunk-CTUSYGR2.js";import"./chunk-4ONRHQSA.js";var l=e;export{l as default};
|
|
2
2
|
//# sourceMappingURL=esbuild.js.map
|
package/farm.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEPZPFIYGcjs = require('./chunk-EPZPFIYG.cjs');require('./chunk-BCOJLF4T.cjs');var m=_chunkEPZPFIYGcjs.h;exports.default = m;
|
|
2
2
|
//# sourceMappingURL=farm.cjs.map
|
package/farm.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/
|
|
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.ts';\n\nexport default farmPlugin;\n"]}
|
package/farm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{h as r}from"./chunk-
|
|
1
|
+
import{h as r}from"./chunk-CTUSYGR2.js";import"./chunk-4ONRHQSA.js";var m=r;export{m as default};
|
|
2
2
|
//# sourceMappingURL=farm.js.map
|
package/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEPZPFIYGcjs = require('./chunk-EPZPFIYG.cjs');require('./chunk-BCOJLF4T.cjs');exports.babelPlugin = _chunkEPZPFIYGcjs.i; exports.default = _chunkEPZPFIYGcjs.a; exports.esbuildPlugin = _chunkEPZPFIYGcjs.g; exports.farmPlugin = _chunkEPZPFIYGcjs.h; exports.rolldownPlugin = _chunkEPZPFIYGcjs.d; exports.rollupPlugin = _chunkEPZPFIYGcjs.c; exports.rspackPlugin = _chunkEPZPFIYGcjs.f; exports.vitePlugin = _chunkEPZPFIYGcjs.b; exports.webpackPlugin = _chunkEPZPFIYGcjs.e;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/
|
|
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.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i}from"./chunk-CTUSYGR2.js";import"./chunk-4ONRHQSA.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-typegpu",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Build plugins for TypeGPU, enabling seamless JavaScript -> WGSL transpilation and improved debugging.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rollup-plugin",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"type": "module",
|
|
20
20
|
"exports": {
|
|
21
|
+
"./package.json": "./package.json",
|
|
21
22
|
".": {
|
|
22
23
|
"types": "./index.d.ts",
|
|
23
24
|
"module": "./index.js",
|
|
@@ -88,11 +89,11 @@
|
|
|
88
89
|
"magic-string-ast": "^0.9.1",
|
|
89
90
|
"picomatch": "^4.0.2",
|
|
90
91
|
"defu": "^6.1.4",
|
|
91
|
-
"tinyest-for-wgsl": "~0.1.
|
|
92
|
+
"tinyest-for-wgsl": "~0.1.2",
|
|
92
93
|
"unplugin": "^2.3.1"
|
|
93
94
|
},
|
|
94
95
|
"peerDependencies": {
|
|
95
|
-
"typegpu": "^0.5.
|
|
96
|
+
"typegpu": "^0.5.8"
|
|
96
97
|
},
|
|
97
98
|
"main": "./index.js",
|
|
98
99
|
"types": "./index.d.ts",
|
package/rolldown.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEPZPFIYGcjs = require('./chunk-EPZPFIYG.cjs');require('./chunk-BCOJLF4T.cjs');var r=_chunkEPZPFIYGcjs.d;exports.default = r;
|
|
2
2
|
//# sourceMappingURL=rolldown.cjs.map
|
package/rolldown.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/
|
|
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.ts';\n\nexport default rolldownPlugin;\n"]}
|
package/rolldown.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as o}from"./chunk-
|
|
1
|
+
import{d as o}from"./chunk-CTUSYGR2.js";import"./chunk-4ONRHQSA.js";var r=o;export{r as default};
|
|
2
2
|
//# sourceMappingURL=rolldown.js.map
|
package/rollup.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEPZPFIYGcjs = require('./chunk-EPZPFIYG.cjs');require('./chunk-BCOJLF4T.cjs');var r=_chunkEPZPFIYGcjs.c;exports.default = r;
|
|
2
2
|
//# sourceMappingURL=rollup.cjs.map
|
package/rollup.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/
|
|
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.ts';\n\nexport default rollupPlugin;\n"]}
|
package/rollup.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as l}from"./chunk-
|
|
1
|
+
import{c as l}from"./chunk-CTUSYGR2.js";import"./chunk-4ONRHQSA.js";var r=l;export{r as default};
|
|
2
2
|
//# sourceMappingURL=rollup.js.map
|
package/rspack.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEPZPFIYGcjs = require('./chunk-EPZPFIYG.cjs');require('./chunk-BCOJLF4T.cjs');var p=_chunkEPZPFIYGcjs.f;exports.default = p;
|
|
2
2
|
//# sourceMappingURL=rspack.cjs.map
|
package/rspack.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/
|
|
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.ts';\n\nexport default rspackPlugin;\n"]}
|
package/rspack.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{f as r}from"./chunk-
|
|
1
|
+
import{f as r}from"./chunk-CTUSYGR2.js";import"./chunk-4ONRHQSA.js";var p=r;export{p as default};
|
|
2
2
|
//# sourceMappingURL=rspack.js.map
|
package/vite.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEPZPFIYGcjs = require('./chunk-EPZPFIYG.cjs');require('./chunk-BCOJLF4T.cjs');var i=_chunkEPZPFIYGcjs.b;exports.default = i;
|
|
2
2
|
//# sourceMappingURL=vite.cjs.map
|
package/vite.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/
|
|
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.ts';\n\nexport default vitePlugin;\n"]}
|
package/vite.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as t}from"./chunk-
|
|
1
|
+
import{b as t}from"./chunk-CTUSYGR2.js";import"./chunk-4ONRHQSA.js";var i=t;export{i as default};
|
|
2
2
|
//# sourceMappingURL=vite.js.map
|
package/webpack.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEPZPFIYGcjs = require('./chunk-EPZPFIYG.cjs');require('./chunk-BCOJLF4T.cjs');var p=_chunkEPZPFIYGcjs.e;exports.default = p;
|
|
2
2
|
//# sourceMappingURL=webpack.cjs.map
|
package/webpack.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/
|
|
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.ts';\n\nexport default webpackPlugin;\n"]}
|
package/webpack.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e}from"./chunk-
|
|
1
|
+
import{e}from"./chunk-CTUSYGR2.js";import"./chunk-4ONRHQSA.js";var p=e;export{p as default};
|
|
2
2
|
//# sourceMappingURL=webpack.js.map
|
package/chunk-EX5XCHMD.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type * as acorn from 'acorn';\nimport defu from 'defu';\nimport { type Node, walk } from 'estree-walker';\nimport { MagicStringAST, generateTransform } from 'magic-string-ast';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport { type UnpluginInstance, createUnplugin } from 'unplugin';\nimport babel from './babel.ts';\nimport {\n type Context,\n type KernelDirective,\n type Options,\n codeFilterRegexes,\n defaultOptions,\n embedJSON,\n gatherTgpuAliases,\n isShellImplementationCall,\n kernelDirectives,\n} from './common.ts';\n\ntype FunctionNode =\n | acorn.FunctionDeclaration\n | acorn.AnonymousFunctionDeclaration\n | acorn.FunctionExpression\n | acorn.ArrowFunctionExpression;\n\nfunction getKernelDirective(node: FunctionNode): KernelDirective | undefined {\n if (node.body.type === 'BlockStatement') {\n for (const statement of node.body.body) {\n if (statement.type === 'ExpressionStatement') {\n if (kernelDirectives.includes(statement.directive as KernelDirective)) {\n return statement.directive as KernelDirective;\n }\n }\n }\n }\n}\n\nfunction removeKernelDirective(node: FunctionNode) {\n const cloned = structuredClone(node);\n\n if (cloned.body.type === 'BlockStatement') {\n cloned.body.body = cloned.body.body.filter(\n (statement) =>\n !(\n statement.type === 'ExpressionStatement' &&\n statement.directive &&\n kernelDirectives.includes(statement.directive as KernelDirective)\n ),\n );\n }\n\n return cloned;\n}\n\nconst typegpu: UnpluginInstance<Options, false> = createUnplugin(\n (rawOptions) => {\n const options = defu(rawOptions, defaultOptions);\n\n return {\n name: 'unplugin-typegpu' as const,\n enforce: options.enforce,\n transform: {\n filter: {\n id: options,\n ...(options.forceTgpuAlias ? {} : { code: codeFilterRegexes }),\n },\n handler(code, id) {\n const ctx: Context = {\n tgpuAliases: new Set<string>(\n options.forceTgpuAlias ? [options.forceTgpuAlias] : [],\n ),\n fileId: id,\n };\n\n const ast = this.parse(code, {\n allowReturnOutsideFunction: true,\n }) as Node;\n\n const tgslFunctionDefs: {\n def: FunctionNode;\n name?: string | undefined;\n removeJsImplementation: boolean;\n }[] = [];\n\n const magicString = new MagicStringAST(code);\n\n walk(ast, {\n enter(_node, _parent, prop, index) {\n const node = _node as acorn.AnyNode;\n\n if (node.type === 'ImportDeclaration') {\n gatherTgpuAliases(node, ctx);\n }\n\n if (node.type === 'CallExpression') {\n if (isShellImplementationCall(node, ctx)) {\n const implementation = node.arguments[0];\n\n if (\n implementation &&\n (implementation.type === 'FunctionExpression' ||\n implementation.type === 'ArrowFunctionExpression')\n ) {\n const directive = getKernelDirective(implementation);\n tgslFunctionDefs.push({\n def: removeKernelDirective(implementation),\n removeJsImplementation: directive !== 'kernel & js',\n });\n this.skip();\n }\n }\n }\n\n if (\n node.type === 'ArrowFunctionExpression' ||\n node.type === 'FunctionExpression' ||\n node.type === 'FunctionDeclaration'\n ) {\n const directive = getKernelDirective(node);\n if (directive) {\n tgslFunctionDefs.push({\n def: removeKernelDirective(node),\n name:\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression'\n ? node.id?.name\n : _parent?.type === 'VariableDeclarator'\n ? _parent.id.type === 'Identifier'\n ? _parent.id.name\n : undefined\n : undefined,\n removeJsImplementation: directive !== 'kernel & js',\n });\n this.skip();\n }\n }\n },\n });\n\n const tgpuAlias = ctx.tgpuAliases.values().next().value;\n\n if (tgpuAlias === undefined && tgslFunctionDefs.length > 0) {\n throw new Error(\n `No tgpu import found, cannot assign ast to function in file: ${id}`,\n );\n }\n\n for (const {\n def,\n name,\n removeJsImplementation,\n } of tgslFunctionDefs) {\n const { argNames, body, externalNames } = transpileFn(def);\n const isFunctionStatement = def.type === 'FunctionDeclaration';\n\n if (\n isFunctionStatement &&\n name &&\n code\n .slice(0, def.start)\n .search(new RegExp(`(?<![\\\\w_.])${name}(?![\\\\w_])`)) !== -1\n ) {\n throw new Error(\n `File ${id}: function \"${name}\", containing ${removeJsImplementation ? 'kernel' : 'kernel & js'} directive, is referenced before its usage. Function statements are no longer hoisted after being transformed by the plugin.`,\n );\n }\n\n // Wrap the implementation in a call to `tgpu.__assignAst` to associate the AST with the implementation.\n magicString.appendLeft(\n def.start,\n `${isFunctionStatement && name ? `const ${name} = ` : ''}${tgpuAlias}.__assignAst(`,\n );\n magicString.appendRight(\n def.end,\n `, ${embedJSON({ argNames, body, externalNames })}`,\n );\n\n if (externalNames.length > 0) {\n magicString.appendRight(\n def.end,\n `, {${externalNames.join(', ')}})`,\n );\n } else {\n magicString.appendRight(\n def.end,\n `)${isFunctionStatement && name ? ';' : ''}`,\n );\n }\n\n if (removeJsImplementation) {\n magicString.overwriteNode(\n def,\n `${tgpuAlias}.__removedJsImpl(${name ? `\"${name}\"` : ''})`,\n );\n }\n }\n\n return generateTransform(magicString, id);\n },\n },\n };\n },\n);\n\nexport type { Options } from './common.ts';\n\nexport default typegpu;\n\nexport const vitePlugin = typegpu.vite;\nexport const rollupPlugin = typegpu.rollup;\nexport const rolldownPlugin = typegpu.rolldown;\nexport const webpackPlugin = typegpu.webpack;\nexport const rspackPlugin = typegpu.rspack;\nexport const esbuildPlugin = typegpu.esbuild;\nexport const farmPlugin = typegpu.farm;\nexport const babelPlugin = babel;\n"],"mappings":"oFACA,OAAOA,MAAU,OACjB,OAAoB,QAAAC,MAAY,gBAChC,OAAS,kBAAAC,EAAgB,qBAAAC,MAAyB,mBAClD,OAAS,eAAAC,MAAmB,mBAC5B,OAAgC,kBAAAC,MAAsB,WAoBtD,SAASC,EAAmBC,EAAiD,CAC3E,GAAIA,EAAK,KAAK,OAAS,kBACrB,QAAWC,KAAaD,EAAK,KAAK,KAChC,GAAIC,EAAU,OAAS,uBACjBC,EAAiB,SAASD,EAAU,SAA4B,EAClE,OAAOA,EAAU,UAK3B,CAEA,SAASE,EAAsBH,EAAoB,CACjD,IAAMI,EAAS,gBAAgBJ,CAAI,EAEnC,OAAII,EAAO,KAAK,OAAS,mBACvBA,EAAO,KAAK,KAAOA,EAAO,KAAK,KAAK,OACjCH,GACC,EACEA,EAAU,OAAS,uBACnBA,EAAU,WACVC,EAAiB,SAASD,EAAU,SAA4B,EAEtE,GAGKG,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C,EAAiBvC,EAAQ,SACzBwC,EAAgBxC,EAAQ,QACxByC,EAAezC,EAAQ,OACvB0C,EAAgB1C,EAAQ,QACxB2C,EAAa3C,EAAQ,KACrB4C,EAAcC","names":["defu","walk","MagicStringAST","generateTransform","transpileFn","createUnplugin","getKernelDirective","node","statement","kernelDirectives","removeKernelDirective","cloned","typegpu","createUnplugin","rawOptions","options","defu","defaultOptions","__spreadValues","codeFilterRegexes","code","id","ctx","ast","tgslFunctionDefs","magicString","MagicStringAST","walk","_node","_parent","prop","index","_a","gatherTgpuAliases","isShellImplementationCall","implementation","directive","tgpuAlias","def","name","removeJsImplementation","argNames","body","externalNames","transpileFn","isFunctionStatement","embedJSON","generateTransform","index_default","vitePlugin","rollupPlugin","rolldownPlugin","webpackPlugin","rspackPlugin","esbuildPlugin","farmPlugin","babelPlugin","babel_default"]}
|
package/chunk-HPSWWSWV.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkHQFSG5ZMcjs = require('./chunk-HQFSG5ZM.cjs');var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);var _estreewalker = require('estree-walker');var _magicstringast = require('magic-string-ast');var _tinyestforwgsl = require('tinyest-for-wgsl');var _unplugin = require('unplugin');function k(c){if(c.body.type==="BlockStatement"){for(let n of c.body.body)if(n.type==="ExpressionStatement"&&_chunkHQFSG5ZMcjs.g.includes(n.directive))return n.directive}}function A(c){let n=structuredClone(c);return n.body.type==="BlockStatement"&&(n.body.body=n.body.body.filter(s=>!(s.type==="ExpressionStatement"&&s.directive&&_chunkHQFSG5ZMcjs.g.includes(s.directive)))),n}var r=_unplugin.createUnplugin.call(void 0, c=>{let n=_defu2.default.call(void 0, c,_chunkHQFSG5ZMcjs.b);return{name:"unplugin-typegpu",enforce:n.enforce,transform:{filter:_chunkHQFSG5ZMcjs.a.call(void 0, {id:n},n.forceTgpuAlias?{}:{code:_chunkHQFSG5ZMcjs.d}),handler(s,l){let d={tgpuAliases:new Set(n.forceTgpuAlias?[n.forceTgpuAlias]:[]),fileId:l},$=this.parse(s,{allowReturnOutsideFunction:!0}),u=[],a=new (0, _magicstringast.MagicStringAST)(s);_estreewalker.walk.call(void 0, $,{enter(i,t,m,y){var p;let e=i;if(e.type==="ImportDeclaration"&&_chunkHQFSG5ZMcjs.e.call(void 0, e,d),e.type==="CallExpression"&&_chunkHQFSG5ZMcjs.f.call(void 0, e,d)){let o=e.arguments[0];if(o&&(o.type==="FunctionExpression"||o.type==="ArrowFunctionExpression")){let E=k(o);u.push({def:A(o),removeJsImplementation:E!=="kernel & js"}),this.skip()}}if(e.type==="ArrowFunctionExpression"||e.type==="FunctionExpression"||e.type==="FunctionDeclaration"){let o=k(e);o&&(u.push({def:A(e),name:e.type==="FunctionDeclaration"||e.type==="FunctionExpression"?(p=e.id)==null?void 0:p.name:(t==null?void 0:t.type)==="VariableDeclarator"&&t.id.type==="Identifier"?t.id.name:void 0,removeJsImplementation:o!=="kernel & js"}),this.skip())}}});let f=d.tgpuAliases.values().next().value;if(f===void 0&&u.length>0)throw new Error(`No tgpu import found, cannot assign ast to function in file: ${l}`);for(let{def:i,name:t,removeJsImplementation:m}of u){let{argNames:y,body:e,externalNames:p}=_tinyestforwgsl.transpileFn.call(void 0, i),o=i.type==="FunctionDeclaration";if(o&&t&&s.slice(0,i.start).search(new RegExp(`(?<![\\w_.])${t}(?![\\w_])`))!==-1)throw new Error(`File ${l}: function "${t}", containing ${m?"kernel":"kernel & js"} directive, is referenced before its usage. Function statements are no longer hoisted after being transformed by the plugin.`);a.appendLeft(i.start,`${o&&t?`const ${t} = `:""}${f}.__assignAst(`),a.appendRight(i.end,`, ${_chunkHQFSG5ZMcjs.c.call(void 0, {argNames:y,body:e,externalNames:p})}`),p.length>0?a.appendRight(i.end,`, {${p.join(", ")}})`):a.appendRight(i.end,`)${o&&t?";":""}`),m&&a.overwriteNode(i,`${f}.__removedJsImpl(${t?`"${t}"`:""})`)}return _magicstringast.generateTransform.call(void 0, a,l)}}}}),L= exports.a =r,M= exports.b =r.vite,V= exports.c =r.rollup,q= exports.d =r.rolldown,z= exports.e =r.webpack,G= exports.f =r.rspack,H= exports.g =r.esbuild,Q= exports.h =r.farm,W= exports.i =_chunkHQFSG5ZMcjs.h;exports.a = L; exports.b = M; exports.c = V; exports.d = q; exports.e = z; exports.f = G; exports.g = H; exports.h = Q; exports.i = W;
|
|
2
|
-
//# sourceMappingURL=chunk-HPSWWSWV.cjs.map
|
package/chunk-HPSWWSWV.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/marcinhawryluk/Documents/wigsill/packages/unplugin-typegpu/dist/chunk-HPSWWSWV.cjs","../src/index.ts"],"names":["getKernelDirective","node","statement","kernelDirectives","removeKernelDirective","cloned","typegpu","createUnplugin","rawOptions","options","defu","defaultOptions","__spreadValues","codeFilterRegexes","code","id","ctx","ast","tgslFunctionDefs","magicString","MagicStringAST","walk","_node","_parent","prop","index","_a","gatherTgpuAliases","isShellImplementationCall","implementation","directive","tgpuAlias"],"mappings":"AAAA,iOAAoF,wECCnE,6CACe,kDACkB,kDACtB,oCAC0B,SAoB7CA,CAAAA,CAAmBC,CAAAA,CAAiD,CAC3E,EAAA,CAAIA,CAAAA,CAAK,IAAA,CAAK,IAAA,GAAS,gBAAA,CAAA,CACrB,GAAA,CAAA,IAAWC,EAAAA,GAAaD,CAAAA,CAAK,IAAA,CAAK,IAAA,CAChC,EAAA,CAAIC,CAAAA,CAAU,IAAA,GAAS,qBAAA,EACjBC,mBAAAA,CAAiB,QAAA,CAASD,CAAAA,CAAU,SAA4B,CAAA,CAClE,OAAOA,CAAAA,CAAU,SAAA,CAK3B,CAEA,SAASE,CAAAA,CAAsBH,CAAAA,CAAoB,CACjD,IAAMI,CAAAA,CAAS,eAAA,CAAgBJ,CAAI,CAAA,CAEnC,OAAII,CA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EAChBA,CAAAA,CAAQ,EAAA,CAAG,IAAA,GAAS,YAAA,CAClBA,CAAAA,CAAQ,EAAA,CAAG,IAAA,CAEb,KAAA,CAAA,CACR,sBAAA,CAAwBO,CAAAA,GAAc,aACxC,CAAC,CAAA,CACD,IAAA,CAAK,IAAA,CAAK,CAAA,CAEd,CACF,CACF,CAAC,CAAA,CAED,IAAMC,CAAAA,CAAYf,CAAAA,CAAI,WAAA,CAAY,MAAA,CAAO,CAAA,CAAE,IAAA,CAAK,CAAA,CAAE,KAAA,CAElD,EAAA,CAAIe,CAAAA,GAAc,KAAA,CAAA,EAAab,CAAAA,CAAiB,MAAA,CAAS,CAAA,CACvD,MAAM,IAAI,KAAA,CACR,CAAA,6DAAA,EAAgEH,CAAE,CAAA,CAAA","file":"/Users/marcinhawryluk/Documents/wigsill/packages/unplugin-typegpu/dist/chunk-HPSWWSWV.cjs","sourcesContent":[null,"import type * as acorn from 'acorn';\nimport defu from 'defu';\nimport { type Node, walk } from 'estree-walker';\nimport { MagicStringAST, generateTransform } from 'magic-string-ast';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport { type UnpluginInstance, createUnplugin } from 'unplugin';\nimport babel from './babel.ts';\nimport {\n type Context,\n type KernelDirective,\n type Options,\n codeFilterRegexes,\n defaultOptions,\n embedJSON,\n gatherTgpuAliases,\n isShellImplementationCall,\n kernelDirectives,\n} from './common.ts';\n\ntype FunctionNode =\n | acorn.FunctionDeclaration\n | acorn.AnonymousFunctionDeclaration\n | acorn.FunctionExpression\n | acorn.ArrowFunctionExpression;\n\nfunction getKernelDirective(node: FunctionNode): KernelDirective | undefined {\n if (node.body.type === 'BlockStatement') {\n for (const statement of node.body.body) {\n if (statement.type === 'ExpressionStatement') {\n if (kernelDirectives.includes(statement.directive as KernelDirective)) {\n return statement.directive as KernelDirective;\n }\n }\n }\n }\n}\n\nfunction removeKernelDirective(node: FunctionNode) {\n const cloned = structuredClone(node);\n\n if (cloned.body.type === 'BlockStatement') {\n cloned.body.body = cloned.body.body.filter(\n (statement) =>\n !(\n statement.type === 'ExpressionStatement' &&\n statement.directive &&\n kernelDirectives.includes(statement.directive as KernelDirective)\n ),\n );\n }\n\n return cloned;\n}\n\nconst typegpu: UnpluginInstance<Options, false> = createUnplugin(\n (rawOptions) => {\n const options = defu(rawOptions, defaultOptions);\n\n return {\n name: 'unplugin-typegpu' as const,\n enforce: options.enforce,\n transform: {\n filter: {\n id: options,\n ...(options.forceTgpuAlias ? {} : { code: codeFilterRegexes }),\n },\n handler(code, id) {\n const ctx: Context = {\n tgpuAliases: new Set<string>(\n options.forceTgpuAlias ? [options.forceTgpuAlias] : [],\n ),\n fileId: id,\n };\n\n const ast = this.parse(code, {\n allowReturnOutsideFunction: true,\n }) as Node;\n\n const tgslFunctionDefs: {\n def: FunctionNode;\n name?: string | undefined;\n removeJsImplementation: boolean;\n }[] = [];\n\n const magicString = new MagicStringAST(code);\n\n walk(ast, {\n enter(_node, _parent, prop, index) {\n const node = _node as acorn.AnyNode;\n\n if (node.type === 'ImportDeclaration') {\n gatherTgpuAliases(node, ctx);\n }\n\n if (node.type === 'CallExpression') {\n if (isShellImplementationCall(node, ctx)) {\n const implementation = node.arguments[0];\n\n if (\n implementation &&\n (implementation.type === 'FunctionExpression' ||\n implementation.type === 'ArrowFunctionExpression')\n ) {\n const directive = getKernelDirective(implementation);\n tgslFunctionDefs.push({\n def: removeKernelDirective(implementation),\n removeJsImplementation: directive !== 'kernel & js',\n });\n this.skip();\n }\n }\n }\n\n if (\n node.type === 'ArrowFunctionExpression' ||\n node.type === 'FunctionExpression' ||\n node.type === 'FunctionDeclaration'\n ) {\n const directive = getKernelDirective(node);\n if (directive) {\n tgslFunctionDefs.push({\n def: removeKernelDirective(node),\n name:\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression'\n ? node.id?.name\n : _parent?.type === 'VariableDeclarator'\n ? _parent.id.type === 'Identifier'\n ? _parent.id.name\n : undefined\n : undefined,\n removeJsImplementation: directive !== 'kernel & js',\n });\n this.skip();\n }\n }\n },\n });\n\n const tgpuAlias = ctx.tgpuAliases.values().next().value;\n\n if (tgpuAlias === undefined && tgslFunctionDefs.length > 0) {\n throw new Error(\n `No tgpu import found, cannot assign ast to function in file: ${id}`,\n );\n }\n\n for (const {\n def,\n name,\n removeJsImplementation,\n } of tgslFunctionDefs) {\n const { argNames, body, externalNames } = transpileFn(def);\n const isFunctionStatement = def.type === 'FunctionDeclaration';\n\n if (\n isFunctionStatement &&\n name &&\n code\n .slice(0, def.start)\n .search(new RegExp(`(?<![\\\\w_.])${name}(?![\\\\w_])`)) !== -1\n ) {\n throw new Error(\n `File ${id}: function \"${name}\", containing ${removeJsImplementation ? 'kernel' : 'kernel & js'} directive, is referenced before its usage. Function statements are no longer hoisted after being transformed by the plugin.`,\n );\n }\n\n // Wrap the implementation in a call to `tgpu.__assignAst` to associate the AST with the implementation.\n magicString.appendLeft(\n def.start,\n `${isFunctionStatement && name ? `const ${name} = ` : ''}${tgpuAlias}.__assignAst(`,\n );\n magicString.appendRight(\n def.end,\n `, ${embedJSON({ argNames, body, externalNames })}`,\n );\n\n if (externalNames.length > 0) {\n magicString.appendRight(\n def.end,\n `, {${externalNames.join(', ')}})`,\n );\n } else {\n magicString.appendRight(\n def.end,\n `)${isFunctionStatement && name ? ';' : ''}`,\n );\n }\n\n if (removeJsImplementation) {\n magicString.overwriteNode(\n def,\n `${tgpuAlias}.__removedJsImpl(${name ? `\"${name}\"` : ''})`,\n );\n }\n }\n\n return generateTransform(magicString, id);\n },\n },\n };\n },\n);\n\nexport type { Options } from './common.ts';\n\nexport default typegpu;\n\nexport const vitePlugin = typegpu.vite;\nexport const rollupPlugin = typegpu.rollup;\nexport const rolldownPlugin = typegpu.rolldown;\nexport const webpackPlugin = typegpu.webpack;\nexport const rspackPlugin = typegpu.rspack;\nexport const esbuildPlugin = typegpu.esbuild;\nexport const farmPlugin = typegpu.farm;\nexport const babelPlugin = babel;\n"]}
|
package/chunk-HQFSG5ZM.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/marcinhawryluk/Documents/wigsill/packages/unplugin-typegpu/dist/chunk-HQFSG5ZM.cjs","../src/babel.ts","../src/common.ts"],"names":["defaultOptions","embedJSON","jsValue","isTgpu","ctx","node","path","tail"],"mappings":"AAAA,+bAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CCAxV,6FAAuB,kDAIK,ICgBfA,CAAAA,CAAiB,CAC5B,OAAA,CAAS,CAAC,cAAc,CAC1B,CAAA,CAEO,SAASC,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/marcinhawryluk/Documents/wigsill/packages/unplugin-typegpu/dist/chunk-HQFSG5ZM.cjs","sourcesContent":[null,"import * as Babel from '@babel/standalone';\nimport type TemplateGenerator from '@babel/template';\nimport type { TraverseOptions } from '@babel/traverse';\nimport type * as babel from '@babel/types';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport {\n type Context,\n type KernelDirective,\n type Options,\n codeFilterRegexes,\n embedJSON,\n gatherTgpuAliases,\n isShellImplementationCall,\n kernelDirectives,\n} from './common.ts';\nimport { createFilterForId } from './filter.ts';\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 babel } })\n .packages.types;\n\nfunction getKernelDirective(\n node:\n | babel.FunctionDeclaration\n | babel.FunctionExpression\n | babel.ArrowFunctionExpression,\n): KernelDirective | undefined {\n const directives = (\n 'directives' in node.body ? (node.body?.directives ?? []) : []\n ).map((directive) => directive.value.value);\n\n for (const directive of kernelDirectives) {\n if (directives.includes(directive)) {\n return directive;\n }\n }\n}\n\nfunction functionToTranspiled(\n node: babel.ArrowFunctionExpression | babel.FunctionExpression,\n ctx: Context,\n name?: string | undefined,\n): babel.CallExpression | null {\n const directive = getKernelDirective(node);\n if (!directive) {\n return null;\n }\n\n const { argNames, body, externalNames } = transpileFn(node);\n const tgpuAlias = ctx.tgpuAliases.values().next().value;\n if (tgpuAlias === undefined) {\n throw new Error(\n `No tgpu import found, cannot assign ast to function in file: ${ctx.fileId ?? ''}`,\n );\n }\n\n return types.callExpression(\n template.expression(`${tgpuAlias}.__assignAst`)(),\n [\n directive === 'kernel & js'\n ? node\n : template.expression`${tgpuAlias}.__removedJsImpl(${name ? `\"${name}\"` : ''})`(),\n template.expression`${embedJSON({ argNames, body, externalNames })}`(),\n types.objectExpression(\n externalNames.map((name) =>\n types.objectProperty(types.identifier(name), types.identifier(name)),\n ),\n ),\n ],\n );\n}\n\nfunction functionVisitor(ctx: Context): TraverseOptions {\n return {\n ImportDeclaration(path) {\n gatherTgpuAliases(path.node, ctx);\n },\n\n ArrowFunctionExpression(path) {\n const transpiled = functionToTranspiled(\n path.node,\n ctx,\n path.parentPath.node.type === 'VariableDeclarator'\n ? path.parentPath.node.id.type === 'Identifier'\n ? path.parentPath.node.id.name\n : undefined\n : undefined,\n );\n if (transpiled) {\n path.replaceWith(transpiled);\n path.skip();\n }\n },\n\n FunctionExpression(path) {\n const transpiled = functionToTranspiled(\n path.node,\n ctx,\n path.node.id?.name\n ? path.node.id.name\n : path.parentPath.node.type === 'VariableDeclarator'\n ? path.parentPath.node.id.type === 'Identifier'\n ? path.parentPath.node.id.name\n : undefined\n : undefined,\n );\n if (transpiled) {\n path.replaceWith(transpiled);\n path.skip();\n }\n },\n\n FunctionDeclaration(path) {\n const node = path.node;\n const expression = types.functionExpression(\n node.id,\n node.params,\n node.body,\n );\n const transpiled = functionToTranspiled(expression, ctx, node.id?.name);\n if (transpiled && node.id) {\n path.replaceWith(\n types.variableDeclaration('const', [\n types.variableDeclarator(node.id, transpiled),\n ]),\n );\n path.skip();\n }\n },\n\n CallExpression(path) {\n const node = path.node;\n\n if (isShellImplementationCall(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 const tgpuAlias = ctx.tgpuAliases.values().next().value;\n if (tgpuAlias === undefined) {\n throw new Error(\n `No tgpu import found, cannot assign ast to function in file: ${ctx.fileId ?? ''}`,\n );\n }\n\n const directive = getKernelDirective(implementation);\n\n path.replaceWith(\n types.callExpression(node.callee, [\n types.callExpression(\n template.expression(`${tgpuAlias}.__assignAst`)(),\n [\n directive !== 'kernel & js'\n ? template.expression`${tgpuAlias}.__removedJsImpl()`()\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\n path.skip();\n }\n }\n },\n };\n}\n\nexport default function () {\n return {\n visitor: {\n Program(path, state) {\n // biome-ignore lint/suspicious/noExplicitAny: <oh babel babel...>\n const code: string | undefined = (state as any).file?.code;\n // biome-ignore lint/suspicious/noExplicitAny: <oh babel babel...>\n const options: Options | undefined = (state as any).opts;\n // biome-ignore lint/suspicious/noExplicitAny: <oh babel babel...>\n const id: string | undefined = (state as any).filename;\n\n const filter = createFilterForId(options);\n if (id && filter && !filter?.(id)) {\n return;\n }\n\n if (\n !options?.forceTgpuAlias &&\n code &&\n !codeFilterRegexes.some((reg) => reg.test(code))\n ) {\n return;\n }\n\n const ctx: Context = {\n tgpuAliases: new Set<string>(\n options?.forceTgpuAlias ? [options.forceTgpuAlias] : [],\n ),\n fileId: id,\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';\nimport type { FilterPattern } from 'unplugin';\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 fileId?: string | undefined;\n};\n\nexport interface Options {\n include?: FilterPattern;\n exclude?: FilterPattern;\n enforce?: 'post' | 'pre' | undefined;\n forceTgpuAlias?: string;\n}\n\nexport const defaultOptions = {\n include: [/\\.m?[jt]sx?$/],\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.*['\"]/;\nconst typegpuDynamicImportRegex = /import\\s*\\(\\s*['\"]\\s*typegpu.*['\"]/;\nconst typegpuRequireRegex = /require\\s*\\(\\s*['\"]\\s*typegpu.*['\"]\\s*\\)/;\n\n/**\n * Regexes used to efficiently determine if a file is\n * meant to be processed by our plugin. We assume every file\n * that should be processed imports `typegpu` in some way.\n */\nexport const codeFilterRegexes = [\n typegpuImportRegex,\n typegpuDynamicImportRegex,\n typegpuRequireRegex,\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\nconst fnShellFunctionNames = ['fn', 'vertexFn', 'fragmentFn', 'computeFn'];\n\nexport function isShellImplementationCall(\n node: acorn.CallExpression | babel.CallExpression,\n ctx: Context,\n) {\n return (\n (node.callee.type === 'CallExpression' &&\n node.callee.callee.type === 'MemberExpression' &&\n node.callee.callee.property.type === 'Identifier' &&\n fnShellFunctionNames.includes(node.callee.callee.property.name) &&\n node.arguments.length === 1 &&\n (node.callee.callee.object.type === 'MemberExpression'\n ? isTgpu(ctx, node.callee.callee.object.object)\n : isTgpu(ctx, node.callee.callee.object))) || // TODO: remove along with the deprecated 'does' method\n (node.callee.type === 'MemberExpression' &&\n node.arguments.length === 1 &&\n node.callee.property.type === 'Identifier' &&\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\nexport const kernelDirectives = ['kernel', 'kernel & js'] as const;\nexport type KernelDirective = (typeof kernelDirectives)[number];\n"]}
|
package/chunk-Y4WARDXR.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/babel.ts","../src/common.ts","../src/filter.ts"],"sourcesContent":["import * as Babel from '@babel/standalone';\nimport type TemplateGenerator from '@babel/template';\nimport type { TraverseOptions } from '@babel/traverse';\nimport type * as babel from '@babel/types';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport {\n type Context,\n type KernelDirective,\n type Options,\n codeFilterRegexes,\n embedJSON,\n gatherTgpuAliases,\n isShellImplementationCall,\n kernelDirectives,\n} from './common.ts';\nimport { createFilterForId } from './filter.ts';\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 babel } })\n .packages.types;\n\nfunction getKernelDirective(\n node:\n | babel.FunctionDeclaration\n | babel.FunctionExpression\n | babel.ArrowFunctionExpression,\n): KernelDirective | undefined {\n const directives = (\n 'directives' in node.body ? (node.body?.directives ?? []) : []\n ).map((directive) => directive.value.value);\n\n for (const directive of kernelDirectives) {\n if (directives.includes(directive)) {\n return directive;\n }\n }\n}\n\nfunction functionToTranspiled(\n node: babel.ArrowFunctionExpression | babel.FunctionExpression,\n ctx: Context,\n name?: string | undefined,\n): babel.CallExpression | null {\n const directive = getKernelDirective(node);\n if (!directive) {\n return null;\n }\n\n const { argNames, body, externalNames } = transpileFn(node);\n const tgpuAlias = ctx.tgpuAliases.values().next().value;\n if (tgpuAlias === undefined) {\n throw new Error(\n `No tgpu import found, cannot assign ast to function in file: ${ctx.fileId ?? ''}`,\n );\n }\n\n return types.callExpression(\n template.expression(`${tgpuAlias}.__assignAst`)(),\n [\n directive === 'kernel & js'\n ? node\n : template.expression`${tgpuAlias}.__removedJsImpl(${name ? `\"${name}\"` : ''})`(),\n template.expression`${embedJSON({ argNames, body, externalNames })}`(),\n types.objectExpression(\n externalNames.map((name) =>\n types.objectProperty(types.identifier(name), types.identifier(name)),\n ),\n ),\n ],\n );\n}\n\nfunction functionVisitor(ctx: Context): TraverseOptions {\n return {\n ImportDeclaration(path) {\n gatherTgpuAliases(path.node, ctx);\n },\n\n ArrowFunctionExpression(path) {\n const transpiled = functionToTranspiled(\n path.node,\n ctx,\n path.parentPath.node.type === 'VariableDeclarator'\n ? path.parentPath.node.id.type === 'Identifier'\n ? path.parentPath.node.id.name\n : undefined\n : undefined,\n );\n if (transpiled) {\n path.replaceWith(transpiled);\n path.skip();\n }\n },\n\n FunctionExpression(path) {\n const transpiled = functionToTranspiled(\n path.node,\n ctx,\n path.node.id?.name\n ? path.node.id.name\n : path.parentPath.node.type === 'VariableDeclarator'\n ? path.parentPath.node.id.type === 'Identifier'\n ? path.parentPath.node.id.name\n : undefined\n : undefined,\n );\n if (transpiled) {\n path.replaceWith(transpiled);\n path.skip();\n }\n },\n\n FunctionDeclaration(path) {\n const node = path.node;\n const expression = types.functionExpression(\n node.id,\n node.params,\n node.body,\n );\n const transpiled = functionToTranspiled(expression, ctx, node.id?.name);\n if (transpiled && node.id) {\n path.replaceWith(\n types.variableDeclaration('const', [\n types.variableDeclarator(node.id, transpiled),\n ]),\n );\n path.skip();\n }\n },\n\n CallExpression(path) {\n const node = path.node;\n\n if (isShellImplementationCall(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 const tgpuAlias = ctx.tgpuAliases.values().next().value;\n if (tgpuAlias === undefined) {\n throw new Error(\n `No tgpu import found, cannot assign ast to function in file: ${ctx.fileId ?? ''}`,\n );\n }\n\n const directive = getKernelDirective(implementation);\n\n path.replaceWith(\n types.callExpression(node.callee, [\n types.callExpression(\n template.expression(`${tgpuAlias}.__assignAst`)(),\n [\n directive !== 'kernel & js'\n ? template.expression`${tgpuAlias}.__removedJsImpl()`()\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\n path.skip();\n }\n }\n },\n };\n}\n\nexport default function () {\n return {\n visitor: {\n Program(path, state) {\n // biome-ignore lint/suspicious/noExplicitAny: <oh babel babel...>\n const code: string | undefined = (state as any).file?.code;\n // biome-ignore lint/suspicious/noExplicitAny: <oh babel babel...>\n const options: Options | undefined = (state as any).opts;\n // biome-ignore lint/suspicious/noExplicitAny: <oh babel babel...>\n const id: string | undefined = (state as any).filename;\n\n const filter = createFilterForId(options);\n if (id && filter && !filter?.(id)) {\n return;\n }\n\n if (\n !options?.forceTgpuAlias &&\n code &&\n !codeFilterRegexes.some((reg) => reg.test(code))\n ) {\n return;\n }\n\n const ctx: Context = {\n tgpuAliases: new Set<string>(\n options?.forceTgpuAlias ? [options.forceTgpuAlias] : [],\n ),\n fileId: id,\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';\nimport type { FilterPattern } from 'unplugin';\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 fileId?: string | undefined;\n};\n\nexport interface Options {\n include?: FilterPattern;\n exclude?: FilterPattern;\n enforce?: 'post' | 'pre' | undefined;\n forceTgpuAlias?: string;\n}\n\nexport const defaultOptions = {\n include: [/\\.m?[jt]sx?$/],\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.*['\"]/;\nconst typegpuDynamicImportRegex = /import\\s*\\(\\s*['\"]\\s*typegpu.*['\"]/;\nconst typegpuRequireRegex = /require\\s*\\(\\s*['\"]\\s*typegpu.*['\"]\\s*\\)/;\n\n/**\n * Regexes used to efficiently determine if a file is\n * meant to be processed by our plugin. We assume every file\n * that should be processed imports `typegpu` in some way.\n */\nexport const codeFilterRegexes = [\n typegpuImportRegex,\n typegpuDynamicImportRegex,\n typegpuRequireRegex,\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\nconst fnShellFunctionNames = ['fn', 'vertexFn', 'fragmentFn', 'computeFn'];\n\nexport function isShellImplementationCall(\n node: acorn.CallExpression | babel.CallExpression,\n ctx: Context,\n) {\n return (\n (node.callee.type === 'CallExpression' &&\n node.callee.callee.type === 'MemberExpression' &&\n node.callee.callee.property.type === 'Identifier' &&\n fnShellFunctionNames.includes(node.callee.callee.property.name) &&\n node.arguments.length === 1 &&\n (node.callee.callee.object.type === 'MemberExpression'\n ? isTgpu(ctx, node.callee.callee.object.object)\n : isTgpu(ctx, node.callee.callee.object))) || // TODO: remove along with the deprecated 'does' method\n (node.callee.type === 'MemberExpression' &&\n node.arguments.length === 1 &&\n node.callee.property.type === 'Identifier' &&\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\nexport const kernelDirectives = ['kernel', 'kernel & js'] as const;\nexport type KernelDirective = (typeof kernelDirectives)[number];\n","// Copied from https://github.com/unjs/unplugin/blob/f514bf8e2d751b48b3a5acb1077eb1292d9711b3/src/utils/filter.ts#L2\n// Used only in the babel version of the plugin, since others can rely on native unplugin functionality.\n\nimport { resolve } from 'node:path';\nimport picomatch from 'picomatch';\nimport type {\n Arrayable,\n Nullable,\n StringFilter,\n StringOrRegExp,\n} from 'unplugin';\n\nfunction toArray<T>(array?: Nullable<Arrayable<T>>): Array<T> {\n const result = array || [];\n if (Array.isArray(result)) return result;\n return [result];\n}\n\nconst BACKSLASH_REGEX = /\\\\/g;\nfunction normalize(path: string): string {\n return path.replace(BACKSLASH_REGEX, '/');\n}\n\nconst ABSOLUTE_PATH_REGEX = /^(?:\\/|(?:[A-Z]:)?[/\\\\|])/i;\nfunction isAbsolute(path: string): boolean {\n return ABSOLUTE_PATH_REGEX.test(path);\n}\n\nexport type PluginFilter = (input: string) => boolean;\nexport type TransformHookFilter = (id: string, code: string) => boolean;\n\ninterface NormalizedStringFilter {\n include?: StringOrRegExp[] | undefined;\n exclude?: StringOrRegExp[] | undefined;\n}\n\nfunction getMatcherString(glob: string, cwd: string) {\n if (glob.startsWith('**') || isAbsolute(glob)) {\n return normalize(glob);\n }\n\n const resolved = resolve(cwd, glob);\n return normalize(resolved);\n}\n\nfunction patternToIdFilter(pattern: StringOrRegExp): PluginFilter {\n if (pattern instanceof RegExp) {\n return (id: string) => {\n const normalizedId = normalize(id);\n const result = pattern.test(normalizedId);\n pattern.lastIndex = 0;\n return result;\n };\n }\n const cwd = process.cwd();\n const glob = getMatcherString(pattern, cwd);\n const matcher = picomatch(glob, { dot: true });\n return (id: string) => {\n const normalizedId = normalize(id);\n return matcher(normalizedId);\n };\n}\n\nfunction patternToCodeFilter(pattern: StringOrRegExp): PluginFilter {\n if (pattern instanceof RegExp) {\n return (code: string) => {\n const result = pattern.test(code);\n pattern.lastIndex = 0;\n return result;\n };\n }\n return (code: string) => code.includes(pattern);\n}\n\nfunction createFilter(\n exclude: PluginFilter[] | undefined,\n include: PluginFilter[] | undefined,\n): PluginFilter | undefined {\n if (!exclude && !include) {\n return;\n }\n\n return (input) => {\n if (exclude?.some((filter) => filter(input))) {\n return false;\n }\n if (include?.some((filter) => filter(input))) {\n return true;\n }\n return !(include && include.length > 0);\n };\n}\n\nfunction normalizeFilter(filter: StringFilter): NormalizedStringFilter {\n if (typeof filter === 'string' || filter instanceof RegExp) {\n return {\n include: [filter],\n };\n }\n if (Array.isArray(filter)) {\n return {\n include: filter,\n };\n }\n return {\n exclude: filter.exclude ? toArray(filter.exclude) : undefined,\n include: filter.include ? toArray(filter.include) : undefined,\n };\n}\n\nfunction createIdFilter(\n filter: StringFilter | undefined,\n): PluginFilter | undefined {\n if (!filter) return;\n const { exclude, include } = normalizeFilter(filter);\n const excludeFilter = exclude?.map(patternToIdFilter);\n const includeFilter = include?.map(patternToIdFilter);\n return createFilter(excludeFilter, includeFilter);\n}\n\nfunction createCodeFilter(\n filter: StringFilter | undefined,\n): PluginFilter | undefined {\n if (!filter) return;\n const { exclude, include } = normalizeFilter(filter);\n const excludeFilter = exclude?.map(patternToCodeFilter);\n const includeFilter = include?.map(patternToCodeFilter);\n return createFilter(excludeFilter, includeFilter);\n}\n\nexport function createFilterForId(\n filter: StringFilter | undefined,\n): PluginFilter | undefined {\n const filterFunction = createIdFilter(filter);\n return filterFunction ? (id) => !!filterFunction(id) : undefined;\n}\n\nfunction createFilterForTransform(\n idFilter: StringFilter | undefined,\n codeFilter: StringFilter | undefined,\n): TransformHookFilter | undefined {\n if (!idFilter && !codeFilter) return;\n const idFilterFunction = createIdFilter(idFilter);\n const codeFilterFunction = createCodeFilter(codeFilter);\n return (id, code) => {\n let fallback = true;\n if (idFilterFunction) {\n fallback &&= idFilterFunction(id);\n }\n if (!fallback) {\n return false;\n }\n\n if (codeFilterFunction) {\n fallback &&= codeFilterFunction(code);\n }\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,EAAU,KAAAC,EAAM,cAAAC,CAAc,CAAC,CAAC,GAAG,EACrEb,EAAM,iBACJa,EAAc,IAAKH,GACjBV,EAAM,eACJA,EAAM,WAAWU,CAAI,EACrBV,EAAM,WAAWU,CAAI,CACvB,CACF,CACF,CACF,CACF,CACF,CAAC,CACH,EAEAQ,EAAK,KAAK,CACZ,CACF,CACF,CACF,CACF,CAEe,SAARM,IAAoB,CACzB,MAAO,CACL,QAAS,CACP,QAAQN,EAAMO,EAAO,CA3L3B,IAAAtB,EA6LQ,IAAMuB,GAA4BvB,EAAAsB,EAAc,OAAd,YAAAtB,EAAoB,KAEhDwB,EAAgCF,EAAc,KAE9CG,EAA0BH,EAAc,SAExCI,EAASC,EAAkBH,CAAO,EAKxC,GAJIC,GAAMC,GAAU,EAACA,GAAA,MAAAA,EAASD,KAK5B,EAACD,GAAA,MAAAA,EAAS,iBACVD,GACA,CAACK,EAAkB,KAAMC,GAAQA,EAAI,KAAKN,CAAI,CAAC,EAE/C,OAGF,IAAMjB,EAAe,CACnB,YAAa,IAAI,IACfkB,GAAA,MAAAA,EAAS,eAAiB,CAACA,EAAQ,cAAc,EAAI,CAAC,CACxD,EACA,OAAQC,CACV,EAEAV,EAAK,SAASD,EAAgBR,CAAG,CAAC,CACpC,CACF,CACF,CACF","names":["Babel","transpileFn","defaultOptions","embedJSON","jsValue","isTgpu","ctx","node","path","tail","typegpuImportRegex","typegpuDynamicImportRegex","typegpuRequireRegex","codeFilterRegexes","gatherTgpuAliases","spec","fnShellFunctionNames","isShellImplementationCall","kernelDirectives","resolve","picomatch","toArray","array","result","BACKSLASH_REGEX","normalize","path","ABSOLUTE_PATH_REGEX","isAbsolute","getMatcherString","glob","cwd","resolved","patternToIdFilter","pattern","id","normalizedId","matcher","createFilter","exclude","include","input","filter","normalizeFilter","toArray","createIdFilter","excludeFilter","patternToIdFilter","includeFilter","createFilterForId","filter","filterFunction","createIdFilter","id","template","types","getKernelDirective","node","_a","_b","directives","directive","kernelDirectives","functionToTranspiled","ctx","name","argNames","body","externalNames","transpileFn","tgpuAlias","embedJSON","functionVisitor","path","gatherTgpuAliases","transpiled","expression","isShellImplementationCall","implementation","babel_default","state","code","options","id","filter","createFilterForId","codeFilterRegexes","reg"]}
|