unplugin-typegpu 0.10.0 → 0.10.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/babel.d.cts +1 -2
- package/babel.d.mts +1 -2
- package/babel.mjs +1 -2
- package/bun.d.cts +1 -2
- package/bun.d.mts +1 -2
- package/bun.mjs +1 -2
- package/common-CRPQ2KE6.d.mts +1 -2
- package/common-Dpl8jppn.d.cts +1 -2
- package/esbuild.d.cts +0 -1
- package/esbuild.d.mts +0 -2
- package/esbuild.mjs +1 -2
- package/farm.d.cts +0 -1
- package/farm.d.mts +0 -2
- package/farm.mjs +1 -2
- package/filter-6T-5w4kG.mjs +1 -2
- package/index-legacy-DRI9LQiG.d.mts +1 -2
- package/index-legacy-xKi5C2ga.d.cts +1 -2
- package/index.d.cts +1 -2
- package/index.d.mts +1 -2
- package/index.mjs +1 -2
- package/package.json +19 -19
- package/rolldown-browser-DKeiFM_e.mjs +1 -2
- package/rolldown-browser-JYqfNLQ8.d.mts +1 -2
- package/rolldown.d.cts +0 -1
- package/rolldown.d.mts +0 -2
- package/rolldown.mjs +1 -2
- package/rollup-impl-DqC_d-_W.d.cts +1 -2
- package/rollup.d.cts +0 -1
- package/rollup.d.mts +0 -2
- package/rollup.mjs +1 -2
- package/rspack.d.cts +0 -1
- package/rspack.d.mts +0 -2
- package/rspack.mjs +1 -2
- package/vite.d.cts +0 -1
- package/vite.d.mts +0 -2
- package/vite.mjs +1 -2
- package/webpack.d.cts +0 -1
- package/webpack.d.mts +0 -2
- package/webpack.mjs +1 -2
- package/babel.d.cts.map +0 -1
- package/babel.d.mts.map +0 -1
- package/babel.mjs.map +0 -1
- package/bun.d.cts.map +0 -1
- package/bun.d.mts.map +0 -1
- package/bun.mjs.map +0 -1
- package/common-CRPQ2KE6.d.mts.map +0 -1
- package/common-Dpl8jppn.d.cts.map +0 -1
- package/esbuild.mjs.map +0 -1
- package/farm.mjs.map +0 -1
- package/filter-6T-5w4kG.mjs.map +0 -1
- package/index-legacy-DRI9LQiG.d.mts.map +0 -1
- package/index-legacy-xKi5C2ga.d.cts.map +0 -1
- package/index.d.cts.map +0 -1
- package/index.d.mts.map +0 -1
- package/index.mjs.map +0 -1
- package/rolldown-browser-DKeiFM_e.mjs.map +0 -1
- package/rolldown-browser-JYqfNLQ8.d.mts.map +0 -1
- package/rolldown.mjs.map +0 -1
- package/rollup-impl-DqC_d-_W.d.cts.map +0 -1
- package/rollup.mjs.map +0 -1
- package/rspack.mjs.map +0 -1
- package/vite.mjs.map +0 -1
- package/webpack.mjs.map +0 -1
package/babel.d.cts
CHANGED
package/babel.d.mts
CHANGED
package/babel.mjs
CHANGED
package/bun.d.cts
CHANGED
package/bun.d.mts
CHANGED
package/bun.mjs
CHANGED
package/common-CRPQ2KE6.d.mts
CHANGED
package/common-Dpl8jppn.d.cts
CHANGED
package/esbuild.d.cts
CHANGED
package/esbuild.d.mts
CHANGED
package/esbuild.mjs
CHANGED
package/farm.d.cts
CHANGED
package/farm.d.mts
CHANGED
package/farm.mjs
CHANGED
package/filter-6T-5w4kG.mjs
CHANGED
|
@@ -231,5 +231,4 @@ function createFilterForId(filter) {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
//#endregion
|
|
234
|
-
export { gatherTgpuAliases as a, operators as c, embedJSON as i, performExpressionNaming as l, defaultOptions as n, getFunctionName as o, earlyPruneRegex as r, isShellImplementationCall as s, createFilterForId as t, useGpuDirective as u };
|
|
235
|
-
//# sourceMappingURL=filter-6T-5w4kG.mjs.map
|
|
234
|
+
export { gatherTgpuAliases as a, operators as c, embedJSON as i, performExpressionNaming as l, defaultOptions as n, getFunctionName as o, earlyPruneRegex as r, isShellImplementationCall as s, createFilterForId as t, useGpuDirective as u };
|
|
@@ -1485,5 +1485,4 @@ type TSType = TSAnyKeyword | TSBooleanKeyword | TSBigIntKeyword | TSIntrinsicKey
|
|
|
1485
1485
|
type TSBaseType = TSAnyKeyword | TSBooleanKeyword | TSBigIntKeyword | TSIntrinsicKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSThisType | TSLiteralType;
|
|
1486
1486
|
type ModuleDeclaration = ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ImportDeclaration;
|
|
1487
1487
|
//#endregion
|
|
1488
|
-
export { Program as n, Node as t };
|
|
1489
|
-
//# sourceMappingURL=index-legacy-DRI9LQiG.d.mts.map
|
|
1488
|
+
export { Program as n, Node as t };
|
|
@@ -1485,5 +1485,4 @@ type TSType = TSAnyKeyword | TSBooleanKeyword | TSBigIntKeyword | TSIntrinsicKey
|
|
|
1485
1485
|
type TSBaseType = TSAnyKeyword | TSBooleanKeyword | TSBigIntKeyword | TSIntrinsicKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSThisType | TSLiteralType;
|
|
1486
1486
|
type ModuleDeclaration = ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ImportDeclaration;
|
|
1487
1487
|
//#endregion
|
|
1488
|
-
export { Program as n, Node as t };
|
|
1489
|
-
//# sourceMappingURL=index-legacy-xKi5C2ga.d.cts.map
|
|
1488
|
+
export { Program as n, Node as t };
|
package/index.d.cts
CHANGED
|
@@ -14,5 +14,4 @@ declare const rspackPlugin: (options: Options) => RspackPluginInstance;
|
|
|
14
14
|
declare const esbuildPlugin: (options: Options) => unplugin.EsbuildPlugin;
|
|
15
15
|
declare const farmPlugin: (options: Options) => JsPlugin;
|
|
16
16
|
//#endregion
|
|
17
|
-
export { type Options, export_default as babelPlugin, _default as bunPlugin, typegpu as default, esbuildPlugin, farmPlugin, rollUpImpl as rolldownBrowserPlugin, rolldownPlugin, rollupPlugin, rspackPlugin, vitePlugin, webpackPlugin };
|
|
18
|
-
//# sourceMappingURL=index.d.cts.map
|
|
17
|
+
export { type Options, export_default as babelPlugin, _default as bunPlugin, typegpu as default, esbuildPlugin, farmPlugin, rollUpImpl as rolldownBrowserPlugin, rolldownPlugin, rollupPlugin, rspackPlugin, vitePlugin, webpackPlugin };
|
package/index.d.mts
CHANGED
|
@@ -14,5 +14,4 @@ declare const rspackPlugin: (options: Options) => RspackPluginInstance;
|
|
|
14
14
|
declare const esbuildPlugin: (options: Options) => unplugin.EsbuildPlugin;
|
|
15
15
|
declare const farmPlugin: (options: Options) => JsPlugin;
|
|
16
16
|
//#endregion
|
|
17
|
-
export { type Options, export_default as babelPlugin, _default as bunPlugin, typegpu as default, esbuildPlugin, farmPlugin, rollUpImpl as rolldownBrowserPlugin, rolldownPlugin, rollupPlugin, rspackPlugin, vitePlugin, webpackPlugin };
|
|
18
|
-
//# sourceMappingURL=index.d.mts.map
|
|
17
|
+
export { type Options, export_default as babelPlugin, _default as bunPlugin, typegpu as default, esbuildPlugin, farmPlugin, rollUpImpl as rolldownBrowserPlugin, rolldownPlugin, rollupPlugin, rspackPlugin, vitePlugin, webpackPlugin };
|
package/index.mjs
CHANGED
|
@@ -14,5 +14,4 @@ const esbuildPlugin = typegpu.esbuild;
|
|
|
14
14
|
const farmPlugin = typegpu.farm;
|
|
15
15
|
|
|
16
16
|
//#endregion
|
|
17
|
-
export { babel_default as babelPlugin, bun_default as bunPlugin, typegpu as default, esbuildPlugin, farmPlugin, rolldown_browser_default as rolldownBrowserPlugin, rolldownPlugin, rollupPlugin, rspackPlugin, vitePlugin, webpackPlugin };
|
|
18
|
-
//# sourceMappingURL=index.mjs.map
|
|
17
|
+
export { babel_default as babelPlugin, bun_default as bunPlugin, typegpu as default, esbuildPlugin, farmPlugin, rolldown_browser_default as rolldownBrowserPlugin, rolldownPlugin, rollupPlugin, rspackPlugin, vitePlugin, webpackPlugin };
|
package/package.json
CHANGED
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-typegpu",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "Build plugins for TypeGPU, enabling seamless JavaScript -> WGSL transpilation and improved debugging.",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"babel-plugin",
|
|
7
|
+
"gpgpu",
|
|
6
8
|
"rollup-plugin",
|
|
9
|
+
"shaders",
|
|
10
|
+
"typegpu",
|
|
11
|
+
"typescript",
|
|
7
12
|
"unplugin",
|
|
8
|
-
"babel-plugin",
|
|
9
13
|
"vite-plugin",
|
|
10
|
-
"typegpu",
|
|
11
|
-
"gpgpu",
|
|
12
14
|
"webgpu",
|
|
13
15
|
"wgpu",
|
|
14
|
-
"wgsl"
|
|
15
|
-
"typescript",
|
|
16
|
-
"shaders"
|
|
16
|
+
"wgsl"
|
|
17
17
|
],
|
|
18
|
+
"homepage": "https://typegpu.com",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/software-mansion/TypeGPU/issues"
|
|
21
|
+
},
|
|
18
22
|
"license": "MIT",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/software-mansion/TypeGPU.git"
|
|
26
|
+
},
|
|
19
27
|
"type": "module",
|
|
28
|
+
"sideEffects": false,
|
|
20
29
|
"exports": {
|
|
21
30
|
"./package.json": "./package.json",
|
|
22
31
|
".": {
|
|
@@ -130,15 +139,6 @@
|
|
|
130
139
|
}
|
|
131
140
|
}
|
|
132
141
|
},
|
|
133
|
-
"sideEffects": false,
|
|
134
|
-
"repository": {
|
|
135
|
-
"type": "git",
|
|
136
|
-
"url": "git+https://github.com/software-mansion/TypeGPU.git"
|
|
137
|
-
},
|
|
138
|
-
"bugs": {
|
|
139
|
-
"url": "https://github.com/software-mansion/TypeGPU/issues"
|
|
140
|
-
},
|
|
141
|
-
"homepage": "https://typegpu.com",
|
|
142
142
|
"dependencies": {
|
|
143
143
|
"@babel/standalone": "^7.28.6",
|
|
144
144
|
"defu": "^6.1.4",
|
|
@@ -146,12 +146,12 @@
|
|
|
146
146
|
"magic-string-ast": "^1.0.0",
|
|
147
147
|
"pathe": "^2.0.3",
|
|
148
148
|
"picomatch": "^4.0.3",
|
|
149
|
-
"tinyest": "~0.3.
|
|
150
|
-
"tinyest-for-wgsl": "~0.3.
|
|
149
|
+
"tinyest": "~0.3.1",
|
|
150
|
+
"tinyest-for-wgsl": "~0.3.2",
|
|
151
151
|
"unplugin": "^2.3.5"
|
|
152
152
|
},
|
|
153
153
|
"peerDependencies": {
|
|
154
|
-
"typegpu": "^0.10.
|
|
154
|
+
"typegpu": "^0.10.2"
|
|
155
155
|
},
|
|
156
156
|
"main": "./index.mjs",
|
|
157
157
|
"types": "./index.d.mts",
|
|
@@ -126,5 +126,4 @@ const rollUpImpl = (rawOptions) => {
|
|
|
126
126
|
var rolldown_browser_default = rollUpImpl;
|
|
127
127
|
|
|
128
128
|
//#endregion
|
|
129
|
-
export { rollUpImpl as n, rolldown_browser_default as t };
|
|
130
|
-
//# sourceMappingURL=rolldown-browser-DKeiFM_e.mjs.map
|
|
129
|
+
export { rollUpImpl as n, rolldown_browser_default as t };
|
package/rolldown.d.cts
CHANGED
package/rolldown.d.mts
CHANGED
package/rolldown.mjs
CHANGED
package/rollup.d.cts
CHANGED
package/rollup.d.mts
CHANGED
package/rollup.mjs
CHANGED
package/rspack.d.cts
CHANGED
package/rspack.d.mts
CHANGED
package/rspack.mjs
CHANGED
package/vite.d.cts
CHANGED
package/vite.d.mts
CHANGED
package/vite.mjs
CHANGED
package/webpack.d.cts
CHANGED
package/webpack.d.mts
CHANGED
package/webpack.mjs
CHANGED
package/babel.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"babel.d.cts","names":[],"sources":["../src/babel.ts"],"mappings":";;;;iBAG2C,cAAA,CAAA"}
|
package/babel.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"babel.d.mts","names":[],"sources":["../src/babel.ts"],"mappings":";;;;iBAG2C,cAAA,CAAA"}
|
package/babel.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"babel.mjs","names":[],"sources":["../src/babel.ts"],"sourcesContent":["import * as Babel from '@babel/standalone';\nimport type TemplateGenerator from '@babel/template';\nimport type { TraverseOptions } from '@babel/traverse';\nimport type * as babel from '@babel/types';\nimport defu from 'defu';\nimport { FORMAT_VERSION } from 'tinyest';\nimport { transpileFn } from 'tinyest-for-wgsl';\nimport {\n type Context,\n defaultOptions,\n embedJSON,\n gatherTgpuAliases,\n getFunctionName,\n isShellImplementationCall,\n operators,\n type Options,\n performExpressionNaming,\n useGpuDirective,\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 containsUseGpuDirective(\n node:\n | babel.FunctionDeclaration\n | babel.FunctionExpression\n | babel.ArrowFunctionExpression,\n): boolean {\n return ((\n 'directives' in node.body ? (node.body?.directives ?? []) : []\n )\n .map((directive) => directive.value.value))\n .includes(useGpuDirective);\n}\n\nfunction i(identifier: string): babel.Identifier {\n return types.identifier(identifier);\n}\n\nconst fnNodeToOriginalMap = new WeakMap<\n | babel.FunctionDeclaration\n | babel.FunctionExpression\n | babel.ArrowFunctionExpression,\n | babel.FunctionDeclaration\n | babel.FunctionExpression\n | babel.ArrowFunctionExpression\n>();\n\nfunction functionToTranspiled(\n node: babel.ArrowFunctionExpression | babel.FunctionExpression,\n parent: babel.Node | null,\n): babel.CallExpression {\n const { params, body, externalNames } = transpileFn(\n fnNodeToOriginalMap.get(node) ?? node,\n );\n const maybeName = getFunctionName(node, parent);\n\n const metadata = types.objectExpression([\n types.objectProperty(\n i('v'),\n types.numericLiteral(FORMAT_VERSION),\n ),\n types.objectProperty(\n i('name'),\n maybeName ? types.stringLiteral(maybeName) : types.buildUndefinedNode(),\n ),\n types.objectProperty(\n i('ast'),\n template.expression`${embedJSON({ params, body, externalNames })}`(),\n ),\n types.objectProperty(\n i('externals'),\n types.arrowFunctionExpression(\n [],\n types.blockStatement([\n types.returnStatement(\n types.objectExpression(\n externalNames.map((name) =>\n types.objectProperty(\n i(name),\n i(name),\n false,\n /* shorthand */ name !== 'this',\n )\n ),\n ),\n ),\n ]),\n ),\n ),\n ]);\n\n return types.callExpression(\n types.arrowFunctionExpression(\n [i('$')],\n types.logicalExpression(\n '&&',\n types.callExpression(\n types.memberExpression(\n types.assignmentExpression(\n '??=',\n types.memberExpression(i('globalThis'), i('__TYPEGPU_META__')),\n types.newExpression(i('WeakMap'), []),\n ),\n i('set'),\n ),\n [\n types.assignmentExpression(\n '=',\n types.memberExpression(i('$'), i('f')),\n node,\n ),\n metadata,\n ],\n ),\n types.memberExpression(i('$'), i('f')),\n ),\n ),\n [types.objectExpression([])],\n );\n}\n\nfunction wrapInAutoName(\n node: babel.Expression,\n name: string,\n) {\n return types.callExpression(\n template.expression('globalThis.__TYPEGPU_AUTONAME__ ?? (a => a)', {\n placeholderPattern: false,\n })(),\n [node, types.stringLiteral(name)],\n );\n}\n\nfunction functionVisitor(ctx: Context): TraverseOptions {\n let inUseGpuScope = false;\n\n return {\n VariableDeclarator(path) {\n performExpressionNaming(ctx, path.node, (node, name) => {\n path.get('init').replaceWith(wrapInAutoName(node, name));\n });\n },\n\n AssignmentExpression(path) {\n if (inUseGpuScope) {\n const runtimeFn =\n operators[path.node.operator as keyof typeof operators];\n\n if (runtimeFn) {\n path.replaceWith(\n types.assignmentExpression(\n '=',\n path.node.left,\n types.callExpression(types.identifier(runtimeFn), [\n path.node.left as babel.Expression,\n path.node.right,\n ]),\n ),\n );\n }\n }\n\n performExpressionNaming(ctx, path.node, (node, name) => {\n path.get('right').replaceWith(wrapInAutoName(node, name));\n });\n },\n\n ObjectProperty(path) {\n performExpressionNaming(ctx, path.node, (node, name) => {\n path.get('value').replaceWith(wrapInAutoName(node, name));\n });\n },\n\n ClassProperty(path) {\n performExpressionNaming(ctx, path.node, (node, name) => {\n path.get('value').replaceWith(wrapInAutoName(node, name));\n });\n },\n\n ImportDeclaration(path) {\n gatherTgpuAliases(path.node, ctx);\n },\n\n BinaryExpression: {\n exit(path) {\n if (!inUseGpuScope) {\n return;\n }\n\n const runtimeFn =\n operators[path.node.operator as keyof typeof operators];\n\n if (runtimeFn) {\n path.replaceWith(\n types.callExpression(types.identifier(runtimeFn), [\n path.node.left as babel.Expression,\n path.node.right,\n ]),\n );\n }\n },\n },\n\n ArrowFunctionExpression: {\n enter(path) {\n if (containsUseGpuDirective(path.node)) {\n fnNodeToOriginalMap.set(path.node, types.cloneNode(path.node, true));\n if (inUseGpuScope) {\n throw new Error(`Nesting 'use gpu' functions is not allowed`);\n }\n inUseGpuScope = true;\n }\n },\n exit(path) {\n const node = path.node;\n if (containsUseGpuDirective(node)) {\n inUseGpuScope = false;\n const parent = path.parentPath.node;\n path.replaceWith(functionToTranspiled(node, parent));\n path.skip();\n }\n },\n },\n\n FunctionExpression: {\n enter(path) {\n if (containsUseGpuDirective(path.node)) {\n fnNodeToOriginalMap.set(path.node, types.cloneNode(path.node, true));\n if (inUseGpuScope) {\n throw new Error(`Nesting 'use gpu' functions is not allowed`);\n }\n inUseGpuScope = true;\n }\n },\n exit(path) {\n const node = path.node;\n if (containsUseGpuDirective(node)) {\n inUseGpuScope = false;\n const parent = path.parentPath.node;\n path.replaceWith(functionToTranspiled(node, parent));\n path.skip();\n }\n },\n },\n\n FunctionDeclaration: {\n enter(path) {\n if (containsUseGpuDirective(path.node)) {\n fnNodeToOriginalMap.set(path.node, types.cloneNode(path.node, true));\n if (inUseGpuScope) {\n throw new Error(`Nesting 'use gpu' functions is not allowed`);\n }\n inUseGpuScope = true;\n }\n },\n exit(path) {\n const node = (fnNodeToOriginalMap.get(path.node) ??\n path.node) as babel.FunctionDeclaration;\n if (containsUseGpuDirective(node)) {\n inUseGpuScope = false;\n\n if (!node.id) {\n return;\n }\n\n const parent = path.parentPath.node;\n const expression = types.functionExpression(\n node.id,\n node.params,\n node.body,\n );\n\n path.replaceWith(\n types.variableDeclaration('const', [\n types.variableDeclarator(\n node.id,\n functionToTranspiled(expression, parent),\n ),\n ]),\n );\n path.skip();\n }\n },\n },\n\n CallExpression: {\n exit(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 transpiled = functionToTranspiled(\n implementation,\n null,\n );\n\n path.replaceWith(\n types.callExpression(node.callee, [\n transpiled,\n ]),\n );\n\n path.skip();\n }\n }\n },\n },\n };\n}\n\nexport default function () {\n return {\n visitor: {\n Program(path, state) {\n // oxlint-disable-next-line typescript/no-explicit-any <oh babel babel...>\n const options = defu((state as any).opts as Options, defaultOptions);\n // oxlint-disable-next-line typescript/no-explicit-any <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 const ctx: Context = {\n tgpuAliases: new Set<string>(\n options.forceTgpuAlias ? [options.forceTgpuAlias] : [],\n ),\n fileId: id,\n autoNamingEnabled: options.autoNamingEnabled,\n };\n\n path.traverse(functionVisitor(ctx));\n },\n } satisfies TraverseOptions,\n };\n}\n"],"mappings":";;;;;;;AAuBA,MAAM,WACJ,MACA,SAAS;AACX,MAAM,QAAS,MACZ,SAAS;AAEZ,SAAS,wBACP,MAIS;;AACT,SACE,gBAAgB,KAAK,8CAAQ,KAAK,8DAAM,mFAAc,EAAE,GAAI,EAAE,EAE7D,KAAK,cAAc,UAAU,MAAM,MAAM,CACzC,SAAS,gBAAgB;;AAG9B,SAAS,EAAE,YAAsC;AAC/C,QAAO,MAAM,WAAW,WAAW;;AAGrC,MAAM,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CACzC,CACF,CAAC,CACH;AACD,UAAK,MAAM;;;GAGhB;EAED,gBAAgB,EACd,KAAK,MAAM;GACT,MAAM,OAAO,KAAK;AAElB,OAAI,0BAA0B,MAAM,IAAI,EAAE;IACxC,MAAM,iBAAiB,KAAK,UAAU;AAEtC,QACE,mBACC,eAAe,SAAS,wBACvB,eAAe,SAAS,4BAC1B;KACA,MAAM,aAAa,qBACjB,gBACA,KACD;AAED,UAAK,YACH,MAAM,eAAe,KAAK,QAAQ,CAChC,WACD,CAAC,CACH;AAED,UAAK,MAAM;;;KAIlB;EACF;;AAGH,yBAA2B;AACzB,QAAO,EACL,SAAS,EACP,QAAQ,MAAM,OAAO;EAEnB,MAAM,UAAU,KAAM,MAAc,MAAiB,eAAe;EAEpE,MAAM,KAA0B,MAAc;EAE9C,MAAM,SAAS,kBAAkB,QAAQ;AACzC,MAAI,MAAM,UAAU,kDAAC,OAAS,GAAG,EAC/B;EAGF,MAAM,MAAe;GACnB,aAAa,IAAI,IACf,QAAQ,iBAAiB,CAAC,QAAQ,eAAe,GAAG,EAAE,CACvD;GACD,QAAQ;GACR,mBAAmB,QAAQ;GAC5B;AAED,OAAK,SAAS,gBAAgB,IAAI,CAAC;IAEtC,EACF"}
|
package/bun.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bun.d.cts","names":[],"sources":["../src/bun.ts"],"mappings":";;;cAG4E,QAAA,GAG5D,UAAA,EAAY,OAAA,KAAU,SAAA;AAAA"}
|
package/bun.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bun.d.mts","names":[],"sources":["../src/bun.ts"],"mappings":";;;cAG4E,QAAA,GAG5D,UAAA,EAAY,OAAA,KAAU,SAAA"}
|
package/bun.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bun.mjs","names":["babelPlugin"],"sources":["../src/bun.ts"],"sourcesContent":["import type { BunPlugin } from 'bun';\nimport * as Babel from '@babel/standalone';\nimport defu from 'defu';\nimport { defaultOptions, earlyPruneRegex, type Options } from './common.ts';\nimport babelPlugin from './babel.ts';\n\nexport default (rawOptions: Options): BunPlugin => {\n const options = defu(rawOptions, defaultOptions);\n const include = options.include;\n if (!(include instanceof RegExp)) {\n throw new Error(\n `Unsupported 'include' options in Bun plugin. Please provide a single regular expression`,\n );\n }\n if (options.exclude) {\n throw new Error(`Unsupported 'exclude' option in Bun plugin`);\n }\n\n return {\n name: 'unplugin-typegpu',\n setup(build) {\n build.onLoad({ filter: include }, async (args) => {\n const text = await Bun.file(args.path).text();\n\n // Pruning early before more expensive operations\n if (earlyPruneRegex.every((pattern) => !pattern.test(text))) {\n return {\n contents: text,\n loader: args.loader,\n };\n }\n\n const result = Babel.transform(text, {\n presets: [['typescript', { allowDeclareFields: true }]],\n filename: args.path,\n plugins: [babelPlugin],\n }).code;\n\n return {\n contents: result ?? text,\n loader: args.loader,\n };\n });\n },\n };\n};\n"],"mappings":";;;;;;AAMA,mBAAgB,eAAmC;CACjD,MAAM,UAAU,KAAK,YAAY,eAAe;CAChD,MAAM,UAAU,QAAQ;AACxB,KAAI,EAAE,mBAAmB,QACvB,OAAM,IAAI,MACR,0FACD;AAEH,KAAI,QAAQ,QACV,OAAM,IAAI,MAAM,6CAA6C;AAG/D,QAAO;EACL,MAAM;EACN,MAAM,OAAO;AACX,SAAM,OAAO,EAAE,QAAQ,SAAS,EAAE,OAAO,SAAS;IAChD,MAAM,OAAO,MAAM,IAAI,KAAK,KAAK,KAAK,CAAC,MAAM;AAG7C,QAAI,gBAAgB,OAAO,YAAY,CAAC,QAAQ,KAAK,KAAK,CAAC,CACzD,QAAO;KACL,UAAU;KACV,QAAQ,KAAK;KACd;IAGH,MAAM,SAAS,MAAM,UAAU,MAAM;KACnC,SAAS,CAAC,CAAC,cAAc,EAAE,oBAAoB,MAAM,CAAC,CAAC;KACvD,UAAU,KAAK;KACf,SAAS,CAACA,cAAY;KACvB,CAAC,CAAC;AAEH,WAAO;KACL,UAAU,gDAAU;KACpB,QAAQ,KAAK;KACd;KACD;;EAEL"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common-CRPQ2KE6.d.mts","names":[],"sources":["../src/common.ts"],"mappings":";;;UAciB,OAAA;EAcf;EAZA,OAAA,GAAU,aAAA;EAqBE;EAlBZ,OAAA,GAAU,aAAA;;EAGV,OAAA;;EAGA,cAAA;;EAGA,iBAAA;;;;;;;;EASA,YAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common-Dpl8jppn.d.cts","names":[],"sources":["../src/common.ts"],"mappings":";;;UAciB,OAAA;EAcf;EAZA,OAAA,GAAU,aAAA;EAqBE;EAlBZ,OAAA,GAAU,aAAA;;EAGV,OAAA;;EAGA,cAAA;;EAGA,iBAAA;;;;;;;;EASA,YAAA;AAAA"}
|
package/esbuild.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild.mjs","names":[],"sources":["../src/esbuild.ts"],"sourcesContent":["import { esbuildPlugin } from './index.ts';\n\nexport default esbuildPlugin;\n"],"mappings":";;;AAEA,sBAAe"}
|
package/farm.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"farm.mjs","names":[],"sources":["../src/farm.ts"],"sourcesContent":["import { farmPlugin } from './index.ts';\n\nexport default farmPlugin;\n"],"mappings":";;;AAEA,mBAAe"}
|
package/filter-6T-5w4kG.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filter-6T-5w4kG.mjs","names":[],"sources":["../src/common.ts","../src/filter.ts"],"sourcesContent":["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 autoNamingEnabled: boolean;\n};\n\nexport interface Options {\n /** @default [/\\.m?[jt]sx?$/] */\n include?: FilterPattern;\n\n /** @default undefined */\n exclude?: FilterPattern;\n\n /** @default undefined */\n enforce?: 'post' | 'pre' | undefined;\n\n /** @default undefined */\n forceTgpuAlias?: string | undefined;\n\n /** @default true */\n autoNamingEnabled?: boolean | undefined;\n\n /**\n * Skipping files that don't contain \"typegpu\", \"tgpu\" or \"use gpu\".\n * In case this early pruning hinders transformation, you\n * can disable it.\n *\n * @default true\n */\n earlyPruning?: boolean | undefined;\n}\n\nexport const defaultOptions = {\n include: /\\.m?[jt]sx?(?:\\?.*)?$/,\n autoNamingEnabled: true,\n earlyPruning: true,\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 (\n (tail.property.type === 'Literal' ||\n tail.property.type === 'StringLiteral') &&\n tail.property.value === '~unstable'\n ) {\n // Bypassing the '~unstable' property.\n tail = tail.object;\n continue;\n }\n\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\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 && isTgpu(ctx, node.callee.callee.object)\n );\n}\n\n/**\n * Extracts a name and expression from nodes that contain a label and an expression,\n * such as VariableDeclarator or PropertyDefinition.\n * Returns a tuple of [name, expression] if found, otherwise undefined.\n *\n * @example\n * extractLabelledExpression(node`let name = tgpu.bindGroupLayout({});`)\n * // [\"name\", node`tgpu.bindGroupLayout({})`]\n */\nfunction extractLabelledExpression<T extends acorn.AnyNode | babel.Node>(\n node: T,\n): [string, ExpressionFor<T>] | undefined {\n if (\n node.type === 'VariableDeclarator' &&\n node.id.type === 'Identifier' &&\n node.init\n ) {\n // let id = init;\n return [node.id.name, node.init as ExpressionFor<T>];\n } else if (node.type === 'AssignmentExpression') {\n // left = right;\n const maybeName = tryFindIdentifier(node.left);\n if (maybeName) {\n return [maybeName, node.right as ExpressionFor<T>];\n }\n } else if (\n (node.type === 'Property' || node.type === 'ObjectProperty') &&\n node.key.type === 'Identifier'\n ) {\n // const a = { key: value }\n return [node.key.name, node.value as ExpressionFor<T>];\n } else if (\n (node.type === 'ClassProperty' || node.type === 'PropertyDefinition') &&\n node.value &&\n node.key.type === 'Identifier'\n ) {\n // class Class {\n //\t key = value;\n // }\n return [node.key.name, node.value as ExpressionFor<T>];\n }\n}\n\nexport function getFunctionName(\n node: acorn.AnyNode | babel.Node,\n parent: acorn.AnyNode | babel.Node | null,\n): string | undefined {\n const maybeName = parent ? extractLabelledExpression(parent)?.[0] : undefined;\n return maybeName ??\n (node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression'\n ? node.id?.name\n : undefined);\n}\n\nconst resourceConstructors: string[] = [\n // tgpu\n 'bindGroupLayout',\n 'vertexLayout',\n 'privateVar',\n 'workgroupVar',\n 'const',\n 'slot',\n 'accessor',\n 'comptime',\n ...fnShellFunctionNames,\n // root\n 'createBuffer',\n 'createMutable',\n 'createReadonly',\n 'createUniform',\n 'createQuerySet',\n 'createPipeline',\n 'createComputePipeline',\n 'createGuardedComputePipeline',\n 'createRenderPipeline',\n 'createTexture',\n 'createSampler',\n 'createComparisonSampler',\n // d\n 'struct',\n 'unstruct',\n // other\n 'createView',\n];\n\n/**\n * Checks if `node` should be wrapped in an autoname function.\n * Since it is mostly for debugging and clean WGSL generation,\n * some false positives and false negatives are admissible.\n */\nfunction containsResourceConstructorCall(\n node: acorn.AnyNode | babel.Node,\n ctx: Context,\n) {\n if (node.type === 'CallExpression') {\n if (isShellImplementationCall(node, ctx)) {\n return true;\n }\n // struct({...})\n if (\n node.callee.type === 'Identifier' &&\n resourceConstructors.includes(node.callee.name)\n ) {\n return true;\n }\n if (node.callee.type === 'MemberExpression') {\n if (node.callee.property.type === 'Identifier') {\n // root.createBuffer({...})\n if (resourceConstructors.includes(node.callee.property.name)) {\n return true;\n }\n if (node.callee.property.name === '$name') {\n return false;\n }\n }\n // root.createBuffer(d.f32).$usage('storage')\n return containsResourceConstructorCall(node.callee.object, ctx);\n }\n }\n if (node.type === 'TaggedTemplateExpression') {\n return containsResourceConstructorCall(node.tag, ctx);\n }\n return false;\n}\n\n/**\n * Tries to find an identifier in a node.\n *\n * @example\n * // syntax is simplified, imagine the arguments are appropriate nodes instead\n * tryFindIdentifier('myBuffer'); // 'myBuffer'\n * tryFindIdentifier('buffers.myBuffer'); // 'myBuffer'\n * tryFindIdentifier('this.myBuffer'); // 'myBuffer'\n * tryFindIdentifier('[a, b]'); // undefined\n */\nfunction tryFindIdentifier(\n node: acorn.AnyNode | babel.Node,\n): string | undefined {\n if (node.type === 'Identifier') {\n return node.name;\n }\n if (node.type === 'PrivateName') {\n return tryFindIdentifier(node.id);\n }\n if (node.type === 'PrivateIdentifier') {\n return node.name;\n }\n if (node.type === 'MemberExpression') {\n return tryFindIdentifier(node.property);\n }\n}\n\ntype ExpressionFor<T extends acorn.AnyNode | babel.Node> = T extends\n acorn.AnyNode ? acorn.Expression : babel.Expression;\n\n/**\n * Checks if `node` contains a label and a tgpu expression that could be named.\n * If so, it calls the provided callback. Nodes selected for naming include:\n *\n * `let name = tgpu.bindGroupLayout({});` (VariableDeclarator)\n *\n * `name = tgpu.bindGroupLayout({});` (AssignmentExpression)\n *\n * `property: tgpu.bindGroupLayout({})` (Property/ObjectProperty)\n *\n * Since it is mostly for debugging and clean WGSL generation,\n * some false positives and false negatives are admissible.\n *\n * This function is NOT used for auto-naming shell-less functions.\n * Those are handled separately.\n *\n * @privateRemarks\n * When adding new checks, you need to call this method in the corresponding node in Babel.\n */\nexport function performExpressionNaming<T extends acorn.AnyNode | babel.Node>(\n ctx: Context,\n node: T,\n namingCallback: (node: ExpressionFor<T>, name: string) => void,\n) {\n if (!ctx.autoNamingEnabled) {\n return;\n }\n\n const labelledExpression = extractLabelledExpression(node);\n if (labelledExpression) {\n const [label, expression] = labelledExpression;\n if (containsResourceConstructorCall(expression, ctx)) {\n namingCallback(expression, label);\n }\n }\n}\n\nexport const useGpuDirective = 'use gpu';\n\n/** Regular expressions used for early pruning (to avoid unnecessary parsing, which is expensive) */\nexport const earlyPruneRegex = [/[\"']use gpu[\"']/, /t(ype)?gpu/];\n\nexport const operators = {\n '+': '__tsover_add',\n '-': '__tsover_sub',\n '*': '__tsover_mul',\n '/': '__tsover_div',\n '%': '__tsover_mod',\n '+=': '__tsover_add',\n '-=': '__tsover_sub',\n '*=': '__tsover_mul',\n '/=': '__tsover_div',\n '%=': '__tsover_mod',\n};\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 'pathe';\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 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\nexport function createFilterForId(\n filter: StringFilter | undefined,\n): PluginFilter | undefined {\n const filterFunction = createIdFilter(filter);\n return filterFunction ? (id) => !!filterFunction(id) : undefined;\n}\n"],"mappings":";;;;AAwCA,MAAa,iBAAiB;CAC5B,SAAS;CACT,mBAAmB;CACnB,cAAc;CACf;AAED,SAAgB,UAAU,SAAkB;AAC1C,QAAO,KAAK,UAAU,QAAQ,CAC3B,QAAQ,WAAW,UAAU,CAC7B,QAAQ,WAAW,UAAU;;;;;;AAOlC,SAAS,OAAO,KAAc,MAA2C;CACvE,IAAI,OAAO;CAEX,IAAI,OAAO;AACX,QAAO,KACL,KAAI,KAAK,SAAS,oBAAoB;AACpC,OACG,KAAK,SAAS,SAAS,aACtB,KAAK,SAAS,SAAS,oBACzB,KAAK,SAAS,UAAU,aACxB;AAEA,UAAO,KAAK;AACZ;;AAGF,MAAI,KAAK,SAAS,SAAS,aAEzB;AAGF,SAAO,OAAO,GAAG,KAAK,SAAS,KAAK,GAAG,SAAS,KAAK,SAAS;AAC9D,SAAO,KAAK;YACH,KAAK,SAAS,cAAc;AACrC,SAAO,OAAO,GAAG,KAAK,KAAK,GAAG,SAAS,KAAK;AAC5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