unplugin-typegpu 0.11.5 → 0.12.0
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-CMd2SDJ6.js → babel-C62qx26_.js} +24 -6
- package/{babel-ZVrKmopN.d.cts → babel-CYu2-eXe.d.cts} +1 -1
- package/{babel--cjzbyRs.d.ts → babel-DOOIkQDL.d.ts} +1 -1
- package/{babel-DQ_yyPsa.cjs → babel-DpCnkpmi.cjs} +24 -6
- package/babel.cjs +2 -2
- package/babel.d.cts +2 -2
- package/babel.d.ts +2 -2
- package/babel.js +2 -2
- package/{bun-dlY1pjqd.cjs → bun-Bijjhb7w.cjs} +3 -3
- package/{bun-CCcdC3SW.js → bun-CJralo3D.js} +3 -3
- package/{bun-CF67VgNO.d.ts → bun-DKuUuTVo.d.ts} +1 -1
- package/{bun-iEmr0VLQ.d.cts → bun-YVuHXBJq.d.cts} +1 -1
- package/bun.cjs +3 -3
- package/bun.d.cts +2 -2
- package/bun.d.ts +2 -2
- package/bun.js +3 -3
- package/{common-CmJ77T6N.d.cts → common-BriEOmpZ.d.cts} +10 -4
- package/{common-BZrmpQ_X.d.ts → common-CWaD5wkm.d.ts} +10 -4
- package/common-Dilxou2I.js +710 -0
- package/common-hMfUmUk0.cjs +790 -0
- package/esbuild.cjs +6 -6
- package/esbuild.d.cts +5 -5
- package/esbuild.d.ts +5 -5
- package/esbuild.js +6 -6
- package/{factory-DjhDJrOh.js → factory-BSXzHM_n.js} +14 -70
- package/{factory-B8-_pu6k.cjs → factory-CXjNN-uX.cjs} +15 -71
- package/farm.cjs +6 -6
- package/farm.d.cts +5 -5
- package/farm.d.ts +5 -5
- package/farm.js +6 -6
- package/{index-B6hcp9YT.d.cts → index-COouFDDA.d.cts} +3 -2
- package/{index-BC8jb6u9.d.ts → index-Hki1C6Ab.d.ts} +9 -8
- package/index.cjs +6 -6
- package/index.d.cts +5 -5
- package/index.d.ts +5 -5
- package/index.js +6 -6
- package/package.json +2 -2
- package/{rolldown-browser-RuB75ubR.cjs → rolldown-browser-0UeIgV94.cjs} +1 -1
- package/rolldown-browser-ClzBk-Ua.d.ts +44 -0
- package/rolldown-browser-Da9eNbZo.d.cts +44 -0
- package/{rolldown-browser-DE5WZuwp.js → rolldown-browser-XH90sRcH.js} +1 -1
- package/rolldown-browser.cjs +3 -3
- package/rolldown-browser.d.cts +2 -2
- package/rolldown-browser.d.ts +2 -2
- package/rolldown-browser.js +3 -3
- package/rolldown.cjs +6 -6
- package/rolldown.d.cts +5 -5
- package/rolldown.d.ts +5 -5
- package/rolldown.js +6 -6
- package/rollup.cjs +6 -6
- package/rollup.d.cts +5 -5
- package/rollup.d.ts +5 -5
- package/rollup.js +6 -6
- package/rspack.cjs +6 -6
- package/rspack.d.cts +5 -5
- package/rspack.d.ts +5 -5
- package/rspack.js +6 -6
- package/{src-CawM5q6P.js → src-BPzkBd5O.js} +1 -1
- package/{src-D3HrJuJR.cjs → src-CYnpqmx5.cjs} +2 -2
- package/vite.cjs +6 -6
- package/vite.d.cts +5 -5
- package/vite.d.ts +5 -5
- package/vite.js +6 -6
- package/webpack.cjs +6 -6
- package/webpack.d.cts +5 -5
- package/webpack.d.ts +5 -5
- package/webpack.js +6 -6
- package/common-CK7zOjbK.js +0 -279
- package/common-ddv56_tk.cjs +0 -346
- package/rolldown-browser-BKqmcxE8.d.ts +0 -40
- package/rolldown-browser-_T3AdKqA.d.cts +0 -40
package/rolldown.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./common-
|
|
3
|
-
require('./babel-
|
|
4
|
-
require('./factory-
|
|
5
|
-
require('./bun-
|
|
6
|
-
require('./rolldown-browser-
|
|
7
|
-
const require_src = require('./src-
|
|
2
|
+
require('./common-hMfUmUk0.cjs');
|
|
3
|
+
require('./babel-DpCnkpmi.cjs');
|
|
4
|
+
require('./factory-CXjNN-uX.cjs');
|
|
5
|
+
require('./bun-Bijjhb7w.cjs');
|
|
6
|
+
require('./rolldown-browser-0UeIgV94.cjs');
|
|
7
|
+
const require_src = require('./src-CYnpqmx5.cjs');
|
|
8
8
|
|
|
9
9
|
//#region src/rolldown.ts
|
|
10
10
|
var rolldown_default = require_src.rolldownPlugin;
|
package/rolldown.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import "./babel-
|
|
3
|
-
import "./bun-
|
|
4
|
-
import "./rolldown-browser-
|
|
5
|
-
import { r as rolldownPlugin } from "./index-
|
|
1
|
+
import "./common-BriEOmpZ.cjs";
|
|
2
|
+
import "./babel-CYu2-eXe.cjs";
|
|
3
|
+
import "./bun-YVuHXBJq.cjs";
|
|
4
|
+
import "./rolldown-browser-Da9eNbZo.cjs";
|
|
5
|
+
import { r as rolldownPlugin } from "./index-COouFDDA.cjs";
|
|
6
6
|
export = rolldownPlugin;
|
package/rolldown.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import "./babel
|
|
3
|
-
import "./bun-
|
|
4
|
-
import "./rolldown-browser-
|
|
5
|
-
import { r as rolldownPlugin } from "./index-
|
|
1
|
+
import "./common-CWaD5wkm.js";
|
|
2
|
+
import "./babel-DOOIkQDL.js";
|
|
3
|
+
import "./bun-DKuUuTVo.js";
|
|
4
|
+
import "./rolldown-browser-ClzBk-Ua.js";
|
|
5
|
+
import { r as rolldownPlugin } from "./index-Hki1C6Ab.js";
|
|
6
6
|
export { rolldownPlugin as default };
|
package/rolldown.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import "./babel-
|
|
3
|
-
import "./factory-
|
|
4
|
-
import "./bun-
|
|
5
|
-
import "./rolldown-browser-
|
|
6
|
-
import { r as rolldownPlugin } from "./src-
|
|
1
|
+
import "./common-Dilxou2I.js";
|
|
2
|
+
import "./babel-C62qx26_.js";
|
|
3
|
+
import "./factory-BSXzHM_n.js";
|
|
4
|
+
import "./bun-CJralo3D.js";
|
|
5
|
+
import "./rolldown-browser-XH90sRcH.js";
|
|
6
|
+
import { r as rolldownPlugin } from "./src-BPzkBd5O.js";
|
|
7
7
|
|
|
8
8
|
//#region src/rolldown.ts
|
|
9
9
|
var rolldown_default = rolldownPlugin;
|
package/rollup.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./common-
|
|
3
|
-
require('./babel-
|
|
4
|
-
require('./factory-
|
|
5
|
-
require('./bun-
|
|
6
|
-
require('./rolldown-browser-
|
|
7
|
-
const require_src = require('./src-
|
|
2
|
+
require('./common-hMfUmUk0.cjs');
|
|
3
|
+
require('./babel-DpCnkpmi.cjs');
|
|
4
|
+
require('./factory-CXjNN-uX.cjs');
|
|
5
|
+
require('./bun-Bijjhb7w.cjs');
|
|
6
|
+
require('./rolldown-browser-0UeIgV94.cjs');
|
|
7
|
+
const require_src = require('./src-CYnpqmx5.cjs');
|
|
8
8
|
|
|
9
9
|
//#region src/rollup.ts
|
|
10
10
|
var rollup_default = require_src.rollupPlugin;
|
package/rollup.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import "./babel-
|
|
3
|
-
import "./bun-
|
|
4
|
-
import "./rolldown-browser-
|
|
5
|
-
import { i as rollupPlugin } from "./index-
|
|
1
|
+
import "./common-BriEOmpZ.cjs";
|
|
2
|
+
import "./babel-CYu2-eXe.cjs";
|
|
3
|
+
import "./bun-YVuHXBJq.cjs";
|
|
4
|
+
import "./rolldown-browser-Da9eNbZo.cjs";
|
|
5
|
+
import { i as rollupPlugin } from "./index-COouFDDA.cjs";
|
|
6
6
|
export = rollupPlugin;
|
package/rollup.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import "./babel
|
|
3
|
-
import "./bun-
|
|
4
|
-
import "./rolldown-browser-
|
|
5
|
-
import { i as rollupPlugin } from "./index-
|
|
1
|
+
import "./common-CWaD5wkm.js";
|
|
2
|
+
import "./babel-DOOIkQDL.js";
|
|
3
|
+
import "./bun-DKuUuTVo.js";
|
|
4
|
+
import "./rolldown-browser-ClzBk-Ua.js";
|
|
5
|
+
import { i as rollupPlugin } from "./index-Hki1C6Ab.js";
|
|
6
6
|
export { rollupPlugin as default };
|
package/rollup.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import "./babel-
|
|
3
|
-
import "./factory-
|
|
4
|
-
import "./bun-
|
|
5
|
-
import "./rolldown-browser-
|
|
6
|
-
import { i as rollupPlugin } from "./src-
|
|
1
|
+
import "./common-Dilxou2I.js";
|
|
2
|
+
import "./babel-C62qx26_.js";
|
|
3
|
+
import "./factory-BSXzHM_n.js";
|
|
4
|
+
import "./bun-CJralo3D.js";
|
|
5
|
+
import "./rolldown-browser-XH90sRcH.js";
|
|
6
|
+
import { i as rollupPlugin } from "./src-BPzkBd5O.js";
|
|
7
7
|
|
|
8
8
|
//#region src/rollup.ts
|
|
9
9
|
var rollup_default = rollupPlugin;
|
package/rspack.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./common-
|
|
3
|
-
require('./babel-
|
|
4
|
-
require('./factory-
|
|
5
|
-
require('./bun-
|
|
6
|
-
require('./rolldown-browser-
|
|
7
|
-
const require_src = require('./src-
|
|
2
|
+
require('./common-hMfUmUk0.cjs');
|
|
3
|
+
require('./babel-DpCnkpmi.cjs');
|
|
4
|
+
require('./factory-CXjNN-uX.cjs');
|
|
5
|
+
require('./bun-Bijjhb7w.cjs');
|
|
6
|
+
require('./rolldown-browser-0UeIgV94.cjs');
|
|
7
|
+
const require_src = require('./src-CYnpqmx5.cjs');
|
|
8
8
|
|
|
9
9
|
//#region src/rspack.ts
|
|
10
10
|
var rspack_default = require_src.rspackPlugin;
|
package/rspack.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import "./babel-
|
|
3
|
-
import "./bun-
|
|
4
|
-
import "./rolldown-browser-
|
|
5
|
-
import { a as rspackPlugin } from "./index-
|
|
1
|
+
import "./common-BriEOmpZ.cjs";
|
|
2
|
+
import "./babel-CYu2-eXe.cjs";
|
|
3
|
+
import "./bun-YVuHXBJq.cjs";
|
|
4
|
+
import "./rolldown-browser-Da9eNbZo.cjs";
|
|
5
|
+
import { a as rspackPlugin } from "./index-COouFDDA.cjs";
|
|
6
6
|
export = rspackPlugin;
|
package/rspack.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import "./babel
|
|
3
|
-
import "./bun-
|
|
4
|
-
import "./rolldown-browser-
|
|
5
|
-
import { a as rspackPlugin } from "./index-
|
|
1
|
+
import "./common-CWaD5wkm.js";
|
|
2
|
+
import "./babel-DOOIkQDL.js";
|
|
3
|
+
import "./bun-DKuUuTVo.js";
|
|
4
|
+
import "./rolldown-browser-ClzBk-Ua.js";
|
|
5
|
+
import { a as rspackPlugin } from "./index-Hki1C6Ab.js";
|
|
6
6
|
export { rspackPlugin as default };
|
package/rspack.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import "./babel-
|
|
3
|
-
import "./factory-
|
|
4
|
-
import "./bun-
|
|
5
|
-
import "./rolldown-browser-
|
|
6
|
-
import { a as rspackPlugin } from "./src-
|
|
1
|
+
import "./common-Dilxou2I.js";
|
|
2
|
+
import "./babel-C62qx26_.js";
|
|
3
|
+
import "./factory-BSXzHM_n.js";
|
|
4
|
+
import "./bun-CJralo3D.js";
|
|
5
|
+
import "./rolldown-browser-XH90sRcH.js";
|
|
6
|
+
import { a as rspackPlugin } from "./src-BPzkBd5O.js";
|
|
7
7
|
|
|
8
8
|
//#region src/rspack.ts
|
|
9
9
|
var rspack_default = rspackPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_common = require('./common-
|
|
2
|
-
const require_factory = require('./factory-
|
|
1
|
+
const require_common = require('./common-hMfUmUk0.cjs');
|
|
2
|
+
const require_factory = require('./factory-CXjNN-uX.cjs');
|
|
3
3
|
let unplugin = require("unplugin");
|
|
4
4
|
unplugin = require_common.__toESM(unplugin);
|
|
5
5
|
|
package/vite.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./common-
|
|
3
|
-
require('./babel-
|
|
4
|
-
require('./factory-
|
|
5
|
-
require('./bun-
|
|
6
|
-
require('./rolldown-browser-
|
|
7
|
-
const require_src = require('./src-
|
|
2
|
+
require('./common-hMfUmUk0.cjs');
|
|
3
|
+
require('./babel-DpCnkpmi.cjs');
|
|
4
|
+
require('./factory-CXjNN-uX.cjs');
|
|
5
|
+
require('./bun-Bijjhb7w.cjs');
|
|
6
|
+
require('./rolldown-browser-0UeIgV94.cjs');
|
|
7
|
+
const require_src = require('./src-CYnpqmx5.cjs');
|
|
8
8
|
|
|
9
9
|
//#region src/vite.ts
|
|
10
10
|
var vite_default = require_src.vitePlugin;
|
package/vite.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import "./babel-
|
|
3
|
-
import "./bun-
|
|
4
|
-
import "./rolldown-browser-
|
|
5
|
-
import { c as vitePlugin } from "./index-
|
|
1
|
+
import "./common-BriEOmpZ.cjs";
|
|
2
|
+
import "./babel-CYu2-eXe.cjs";
|
|
3
|
+
import "./bun-YVuHXBJq.cjs";
|
|
4
|
+
import "./rolldown-browser-Da9eNbZo.cjs";
|
|
5
|
+
import { c as vitePlugin } from "./index-COouFDDA.cjs";
|
|
6
6
|
export = vitePlugin;
|
package/vite.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import "./babel
|
|
3
|
-
import "./bun-
|
|
4
|
-
import "./rolldown-browser-
|
|
5
|
-
import { c as vitePlugin } from "./index-
|
|
1
|
+
import "./common-CWaD5wkm.js";
|
|
2
|
+
import "./babel-DOOIkQDL.js";
|
|
3
|
+
import "./bun-DKuUuTVo.js";
|
|
4
|
+
import "./rolldown-browser-ClzBk-Ua.js";
|
|
5
|
+
import { c as vitePlugin } from "./index-Hki1C6Ab.js";
|
|
6
6
|
export { vitePlugin as default };
|
package/vite.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import "./babel-
|
|
3
|
-
import "./factory-
|
|
4
|
-
import "./bun-
|
|
5
|
-
import "./rolldown-browser-
|
|
6
|
-
import { c as vitePlugin } from "./src-
|
|
1
|
+
import "./common-Dilxou2I.js";
|
|
2
|
+
import "./babel-C62qx26_.js";
|
|
3
|
+
import "./factory-BSXzHM_n.js";
|
|
4
|
+
import "./bun-CJralo3D.js";
|
|
5
|
+
import "./rolldown-browser-XH90sRcH.js";
|
|
6
|
+
import { c as vitePlugin } from "./src-BPzkBd5O.js";
|
|
7
7
|
|
|
8
8
|
//#region src/vite.ts
|
|
9
9
|
var vite_default = vitePlugin;
|
package/webpack.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./common-
|
|
3
|
-
require('./babel-
|
|
4
|
-
require('./factory-
|
|
5
|
-
require('./bun-
|
|
6
|
-
require('./rolldown-browser-
|
|
7
|
-
const require_src = require('./src-
|
|
2
|
+
require('./common-hMfUmUk0.cjs');
|
|
3
|
+
require('./babel-DpCnkpmi.cjs');
|
|
4
|
+
require('./factory-CXjNN-uX.cjs');
|
|
5
|
+
require('./bun-Bijjhb7w.cjs');
|
|
6
|
+
require('./rolldown-browser-0UeIgV94.cjs');
|
|
7
|
+
const require_src = require('./src-CYnpqmx5.cjs');
|
|
8
8
|
|
|
9
9
|
//#region src/webpack.ts
|
|
10
10
|
var webpack_default = require_src.webpackPlugin;
|
package/webpack.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import "./babel-
|
|
3
|
-
import "./bun-
|
|
4
|
-
import "./rolldown-browser-
|
|
5
|
-
import { l as webpackPlugin } from "./index-
|
|
1
|
+
import "./common-BriEOmpZ.cjs";
|
|
2
|
+
import "./babel-CYu2-eXe.cjs";
|
|
3
|
+
import "./bun-YVuHXBJq.cjs";
|
|
4
|
+
import "./rolldown-browser-Da9eNbZo.cjs";
|
|
5
|
+
import { l as webpackPlugin } from "./index-COouFDDA.cjs";
|
|
6
6
|
export = webpackPlugin;
|
package/webpack.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import "./babel
|
|
3
|
-
import "./bun-
|
|
4
|
-
import "./rolldown-browser-
|
|
5
|
-
import { l as webpackPlugin } from "./index-
|
|
1
|
+
import "./common-CWaD5wkm.js";
|
|
2
|
+
import "./babel-DOOIkQDL.js";
|
|
3
|
+
import "./bun-DKuUuTVo.js";
|
|
4
|
+
import "./rolldown-browser-ClzBk-Ua.js";
|
|
5
|
+
import { l as webpackPlugin } from "./index-Hki1C6Ab.js";
|
|
6
6
|
export { webpackPlugin as default };
|
package/webpack.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import "./babel-
|
|
3
|
-
import "./factory-
|
|
4
|
-
import "./bun-
|
|
5
|
-
import "./rolldown-browser-
|
|
6
|
-
import { l as webpackPlugin } from "./src-
|
|
1
|
+
import "./common-Dilxou2I.js";
|
|
2
|
+
import "./babel-C62qx26_.js";
|
|
3
|
+
import "./factory-BSXzHM_n.js";
|
|
4
|
+
import "./bun-CJralo3D.js";
|
|
5
|
+
import "./rolldown-browser-XH90sRcH.js";
|
|
6
|
+
import { l as webpackPlugin } from "./src-BPzkBd5O.js";
|
|
7
7
|
|
|
8
8
|
//#region src/webpack.ts
|
|
9
9
|
var webpack_default = webpackPlugin;
|
package/common-CK7zOjbK.js
DELETED
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import { transpileFn } from "tinyest-for-wgsl";
|
|
2
|
-
import * as t from "@babel/types";
|
|
3
|
-
import MagicString from "magic-string";
|
|
4
|
-
|
|
5
|
-
//#region src/core/common.ts
|
|
6
|
-
/**
|
|
7
|
-
* Each breaking change to the metadata format requires a bump to this number.
|
|
8
|
-
* It's used at runtime by `typegpu` to determine how to interpret a function's metadata.
|
|
9
|
-
*/
|
|
10
|
-
const METADATA_FORMAT_VERSION = 1;
|
|
11
|
-
function initPluginState(state, methods) {
|
|
12
|
-
var _state$opts$autoNamin;
|
|
13
|
-
state.tgpuAliases = new Set(state.opts.forceTgpuAlias ? [state.opts.forceTgpuAlias] : []);
|
|
14
|
-
state.autoNamingEnabled = (_state$opts$autoNamin = state.opts.autoNamingEnabled) !== null && _state$opts$autoNamin !== void 0 ? _state$opts$autoNamin : true;
|
|
15
|
-
state.inUseGpuScope = false;
|
|
16
|
-
state.alreadyTransformed = /* @__PURE__ */ new WeakSet();
|
|
17
|
-
Object.assign(state, methods);
|
|
18
|
-
}
|
|
19
|
-
/** Regular expressions used for early pruning (to avoid unnecessary parsing, which is expensive) */
|
|
20
|
-
const earlyPruneRegex = [/["']use gpu["']/, /t(ype)?gpu/];
|
|
21
|
-
const defaultOptions = {
|
|
22
|
-
include: /\.m?[jt]sx?(?:\?.*)?$/,
|
|
23
|
-
autoNamingEnabled: true,
|
|
24
|
-
earlyPruning: true
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Returns the block scope of a function declaration, if one exists.
|
|
28
|
-
* Used to hoist a function declaration to the top of the scope it's visible in.
|
|
29
|
-
*/
|
|
30
|
-
function getBlockScope(path) {
|
|
31
|
-
if (!path.node.id) return;
|
|
32
|
-
const binding = path.scope.getBinding(path.node.id.name);
|
|
33
|
-
if (!binding) return;
|
|
34
|
-
let scopePath = binding.scope.path;
|
|
35
|
-
if (t.isNode(scopePath.node.body)) scopePath = scopePath.get("body");
|
|
36
|
-
if (t.isBlockStatement(scopePath.node) || t.isProgram(scopePath.node)) return scopePath;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Checks if `node` is an alias for the 'tgpu' object, traditionally
|
|
40
|
-
* available via `import tgpu from 'typegpu'`.
|
|
41
|
-
*/
|
|
42
|
-
function isTgpu(state, node) {
|
|
43
|
-
let path = "";
|
|
44
|
-
let tail = node;
|
|
45
|
-
while (true) if (tail.type === "MemberExpression") {
|
|
46
|
-
if (tail.property.type === "StringLiteral" && tail.property.value === "~unstable") {
|
|
47
|
-
tail = tail.object;
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
if (tail.property.type !== "Identifier") break;
|
|
51
|
-
path = path ? `${tail.property.name}.${path}` : tail.property.name;
|
|
52
|
-
tail = tail.object;
|
|
53
|
-
} else if (tail.type === "Identifier") {
|
|
54
|
-
path = path ? `${tail.name}.${path}` : tail.name;
|
|
55
|
-
break;
|
|
56
|
-
} else break;
|
|
57
|
-
return state.tgpuAliases.has(path);
|
|
58
|
-
}
|
|
59
|
-
function gatherTgpuAliases(state, node) {
|
|
60
|
-
if (node.source.value !== "typegpu") return;
|
|
61
|
-
for (const spec of node.specifiers) if (spec.type === "ImportDefaultSpecifier" || spec.type === "ImportSpecifier" && spec.imported.type === "Identifier" && spec.imported.name === "tgpu") state.tgpuAliases.add(spec.local.name);
|
|
62
|
-
else if (spec.type === "ImportNamespaceSpecifier") state.tgpuAliases.add(`${spec.local.name}.tgpu`);
|
|
63
|
-
}
|
|
64
|
-
const fnShellFunctionNames = [
|
|
65
|
-
"fn",
|
|
66
|
-
"vertexFn",
|
|
67
|
-
"fragmentFn",
|
|
68
|
-
"computeFn"
|
|
69
|
-
];
|
|
70
|
-
function isShellImplementationCall(node, state) {
|
|
71
|
-
return node.callee.type === "CallExpression" && node.callee.callee.type === "MemberExpression" && node.callee.callee.property.type === "Identifier" && fnShellFunctionNames.includes(node.callee.callee.property.name) && node.arguments.length === 1 && isTgpu(state, node.callee.callee.object);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Extracts a name and expression from nodes that contain a label and an expression,
|
|
75
|
-
* such as VariableDeclarator or PropertyDefinition.
|
|
76
|
-
* Returns a tuple of [name, expression] if found, otherwise undefined.
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* extractLabelledExpression(node`let name = tgpu.bindGroupLayout({});`)
|
|
80
|
-
* // ["name", node`tgpu.bindGroupLayout({})`]
|
|
81
|
-
*/
|
|
82
|
-
function extractLabelledExpression(path) {
|
|
83
|
-
if (path.node.type === "VariableDeclarator" && path.node.id.type === "Identifier" && path.node.init) return [path.node.id.name, path.get("init")];
|
|
84
|
-
else if (path.node.type === "AssignmentExpression") {
|
|
85
|
-
const maybeName = tryFindIdentifier(path.node.left);
|
|
86
|
-
if (maybeName) return [maybeName, path.get("right")];
|
|
87
|
-
} else if (path.node.type === "ObjectProperty" && path.node.key.type === "Identifier") return [path.node.key.name, path.get("value")];
|
|
88
|
-
else if (path.node.type === "ClassProperty" && path.node.value && path.node.key.type === "Identifier") return [path.node.key.name, path.get("value")];
|
|
89
|
-
}
|
|
90
|
-
function getFunctionName(path) {
|
|
91
|
-
var _extractLabelledExpre, _path$node$id;
|
|
92
|
-
const maybeName = path.parentPath ? (_extractLabelledExpre = extractLabelledExpression(path.parentPath)) === null || _extractLabelledExpre === void 0 ? void 0 : _extractLabelledExpre[0] : void 0;
|
|
93
|
-
return maybeName !== null && maybeName !== void 0 ? maybeName : path.node.type === "FunctionDeclaration" || path.node.type === "FunctionExpression" ? (_path$node$id = path.node.id) === null || _path$node$id === void 0 ? void 0 : _path$node$id.name : void 0;
|
|
94
|
-
}
|
|
95
|
-
const resourceConstructors = [
|
|
96
|
-
"bindGroupLayout",
|
|
97
|
-
"vertexLayout",
|
|
98
|
-
"privateVar",
|
|
99
|
-
"workgroupVar",
|
|
100
|
-
"const",
|
|
101
|
-
"slot",
|
|
102
|
-
"accessor",
|
|
103
|
-
"mutableAccessor",
|
|
104
|
-
"comptime",
|
|
105
|
-
...fnShellFunctionNames,
|
|
106
|
-
"createBuffer",
|
|
107
|
-
"createMutable",
|
|
108
|
-
"createReadonly",
|
|
109
|
-
"createUniform",
|
|
110
|
-
"createQuerySet",
|
|
111
|
-
"createPipeline",
|
|
112
|
-
"createComputePipeline",
|
|
113
|
-
"createGuardedComputePipeline",
|
|
114
|
-
"createRenderPipeline",
|
|
115
|
-
"createTexture",
|
|
116
|
-
"createSampler",
|
|
117
|
-
"createComparisonSampler",
|
|
118
|
-
"struct",
|
|
119
|
-
"unstruct",
|
|
120
|
-
"createView"
|
|
121
|
-
];
|
|
122
|
-
/**
|
|
123
|
-
* Checks if `node` should be wrapped in an autoname function.
|
|
124
|
-
* Since it is mostly for debugging and clean WGSL generation,
|
|
125
|
-
* some false positives and false negatives are admissible.
|
|
126
|
-
*/
|
|
127
|
-
function containsResourceConstructorCall(node, state) {
|
|
128
|
-
if (node.type === "CallExpression") {
|
|
129
|
-
if (isShellImplementationCall(node, state)) return true;
|
|
130
|
-
if (node.callee.type === "Identifier" && resourceConstructors.includes(node.callee.name)) return true;
|
|
131
|
-
if (node.callee.type === "MemberExpression") {
|
|
132
|
-
if (node.callee.property.type === "Identifier") {
|
|
133
|
-
if (resourceConstructors.includes(node.callee.property.name)) return true;
|
|
134
|
-
if (node.callee.property.name === "$name") return false;
|
|
135
|
-
}
|
|
136
|
-
return containsResourceConstructorCall(node.callee.object, state);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
if (node.type === "TaggedTemplateExpression") return containsResourceConstructorCall(node.tag, state);
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Tries to find an identifier in a node.
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* // syntax is simplified, imagine the arguments are appropriate nodes instead
|
|
147
|
-
* tryFindIdentifier('myBuffer'); // 'myBuffer'
|
|
148
|
-
* tryFindIdentifier('buffers.myBuffer'); // 'myBuffer'
|
|
149
|
-
* tryFindIdentifier('this.myBuffer'); // 'myBuffer'
|
|
150
|
-
* tryFindIdentifier('[a, b]'); // undefined
|
|
151
|
-
*/
|
|
152
|
-
function tryFindIdentifier(node) {
|
|
153
|
-
if (node.type === "Identifier") return node.name;
|
|
154
|
-
if (node.type === "PrivateName") return tryFindIdentifier(node.id);
|
|
155
|
-
if (node.type === "MemberExpression") return tryFindIdentifier(node.property);
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Checks if `node` contains a label and a tgpu expression that could be named.
|
|
159
|
-
* If so, it calls the provided callback. Nodes selected for naming include:
|
|
160
|
-
*
|
|
161
|
-
* `let name = tgpu.bindGroupLayout({});` (VariableDeclarator)
|
|
162
|
-
*
|
|
163
|
-
* `name = tgpu.bindGroupLayout({});` (AssignmentExpression)
|
|
164
|
-
*
|
|
165
|
-
* `property: tgpu.bindGroupLayout({})` (Property/ObjectProperty)
|
|
166
|
-
*
|
|
167
|
-
* Since it is mostly for debugging and clean WGSL generation,
|
|
168
|
-
* some false positives and false negatives are admissible.
|
|
169
|
-
*
|
|
170
|
-
* This function is NOT used for auto-naming shell-less functions.
|
|
171
|
-
* Those are handled separately.
|
|
172
|
-
*
|
|
173
|
-
* @privateRemarks
|
|
174
|
-
* When adding new checks, you need to call this method in the corresponding node in Babel.
|
|
175
|
-
*/
|
|
176
|
-
function performExpressionNaming(state, path, namingCallback) {
|
|
177
|
-
if (!state.autoNamingEnabled) return;
|
|
178
|
-
const labelledExpression = extractLabelledExpression(path);
|
|
179
|
-
if (labelledExpression) {
|
|
180
|
-
const [label, expressionPath] = labelledExpression;
|
|
181
|
-
if (containsResourceConstructorCall(expressionPath.node, state)) namingCallback(expressionPath, label);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
const operators = {
|
|
185
|
-
"+": "__tsover_add",
|
|
186
|
-
"-": "__tsover_sub",
|
|
187
|
-
"*": "__tsover_mul",
|
|
188
|
-
"/": "__tsover_div",
|
|
189
|
-
"%": "__tsover_mod",
|
|
190
|
-
"+=": "__tsover_add",
|
|
191
|
-
"-=": "__tsover_sub",
|
|
192
|
-
"*=": "__tsover_mul",
|
|
193
|
-
"/=": "__tsover_div",
|
|
194
|
-
"%=": "__tsover_mod"
|
|
195
|
-
};
|
|
196
|
-
function containsUseGpuDirective(node) {
|
|
197
|
-
var _node$body$directives, _node$body;
|
|
198
|
-
return ("directives" in node.body ? (_node$body$directives = (_node$body = node.body) === null || _node$body === void 0 ? void 0 : _node$body.directives) !== null && _node$body$directives !== void 0 ? _node$body$directives : [] : []).map((directive) => directive.value.value).includes("use gpu");
|
|
199
|
-
}
|
|
200
|
-
const fnNodeToTranspiledMap = /* @__PURE__ */ new WeakMap();
|
|
201
|
-
function functionOnExit(path, state) {
|
|
202
|
-
const node = path.node;
|
|
203
|
-
if (!containsUseGpuDirective(node)) return;
|
|
204
|
-
state.inUseGpuScope = false;
|
|
205
|
-
if (state.alreadyTransformed.has(node)) return;
|
|
206
|
-
const ast = fnNodeToTranspiledMap.get(path.node);
|
|
207
|
-
const maybeName = getFunctionName(path);
|
|
208
|
-
if (!ast) throw new Error(`No metadata found for function ${maybeName !== null && maybeName !== void 0 ? maybeName : "<unnamed>"}`);
|
|
209
|
-
state.assignMetadata(path, maybeName, ast);
|
|
210
|
-
state.alreadyTransformed.add(node);
|
|
211
|
-
path.skip();
|
|
212
|
-
}
|
|
213
|
-
const functionVisitor = {
|
|
214
|
-
ImportDeclaration(path, state) {
|
|
215
|
-
gatherTgpuAliases(state, path.node);
|
|
216
|
-
},
|
|
217
|
-
VariableDeclarator(path, state) {
|
|
218
|
-
performExpressionNaming(state, path, (pathToName, name) => {
|
|
219
|
-
state.wrapInAutoName(pathToName, name);
|
|
220
|
-
});
|
|
221
|
-
},
|
|
222
|
-
ObjectProperty(path, state) {
|
|
223
|
-
performExpressionNaming(state, path, (pathToName, name) => state.wrapInAutoName(pathToName, name));
|
|
224
|
-
},
|
|
225
|
-
ClassProperty(path, state) {
|
|
226
|
-
performExpressionNaming(state, path, (pathToName, name) => state.wrapInAutoName(pathToName, name));
|
|
227
|
-
},
|
|
228
|
-
AssignmentExpression: { exit(path, state) {
|
|
229
|
-
const runtimeFn = operators[path.node.operator];
|
|
230
|
-
if (state.inUseGpuScope && runtimeFn) state.replaceWithAssignmentOverload(path, runtimeFn);
|
|
231
|
-
performExpressionNaming(state, path, (pathToName, name) => state.wrapInAutoName(pathToName, name));
|
|
232
|
-
path.skip();
|
|
233
|
-
} },
|
|
234
|
-
BinaryExpression: { exit(path, state) {
|
|
235
|
-
const runtimeFn = operators[path.node.operator];
|
|
236
|
-
if (state.inUseGpuScope && runtimeFn) state.replaceWithBinaryOverload(path, runtimeFn);
|
|
237
|
-
path.skip();
|
|
238
|
-
} },
|
|
239
|
-
ArrowFunctionExpression: {
|
|
240
|
-
enter(path, state) {
|
|
241
|
-
if (containsUseGpuDirective(path.node)) {
|
|
242
|
-
fnNodeToTranspiledMap.set(path.node, transpileFn(path.node));
|
|
243
|
-
if (state.inUseGpuScope) throw new Error(`Nesting 'use gpu' functions is not allowed`);
|
|
244
|
-
state.inUseGpuScope = true;
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
|
-
exit: functionOnExit
|
|
248
|
-
},
|
|
249
|
-
FunctionExpression: {
|
|
250
|
-
enter(path, state) {
|
|
251
|
-
if (containsUseGpuDirective(path.node)) {
|
|
252
|
-
fnNodeToTranspiledMap.set(path.node, transpileFn(path.node));
|
|
253
|
-
if (state.inUseGpuScope) throw new Error(`Nesting 'use gpu' functions is not allowed`);
|
|
254
|
-
state.inUseGpuScope = true;
|
|
255
|
-
}
|
|
256
|
-
},
|
|
257
|
-
exit: functionOnExit
|
|
258
|
-
},
|
|
259
|
-
FunctionDeclaration: {
|
|
260
|
-
enter(path, state) {
|
|
261
|
-
if (containsUseGpuDirective(path.node)) {
|
|
262
|
-
fnNodeToTranspiledMap.set(path.node, transpileFn(path.node));
|
|
263
|
-
if (state.inUseGpuScope) throw new Error(`Nesting 'use gpu' functions is not allowed`);
|
|
264
|
-
state.inUseGpuScope = true;
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
exit: functionOnExit
|
|
268
|
-
},
|
|
269
|
-
CallExpression: { exit(path, state) {
|
|
270
|
-
const node = path.node;
|
|
271
|
-
if (isShellImplementationCall(node, state)) {
|
|
272
|
-
const implementation = node.arguments[0];
|
|
273
|
-
if (implementation && (implementation.type === "FunctionExpression" || implementation.type === "ArrowFunctionExpression") && !containsUseGpuDirective(implementation)) state.assignMetadata(path.get("arguments.0"), getFunctionName(path.get("arguments.0")), transpileFn(implementation));
|
|
274
|
-
}
|
|
275
|
-
} }
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
//#endregion
|
|
279
|
-
export { getBlockScope as a, functionVisitor as i, defaultOptions as n, initPluginState as o, earlyPruneRegex as r, METADATA_FORMAT_VERSION as t };
|