unplugin-typegpu 0.10.2 → 0.11.1
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/README.md +14 -4
- package/babel-C8UzthFd.d.cts +13 -0
- package/babel-CbManzjz.js +128 -0
- package/babel-CmCnq-43.d.ts +13 -0
- package/babel-Dis-Pwfu.cjs +140 -0
- package/babel.cjs +4 -160
- package/babel.d.cts +3 -10
- package/babel.d.ts +3 -0
- package/babel.js +4 -0
- package/bun-CDECNeIU.js +134 -0
- package/bun-DCACcaN2.cjs +154 -0
- package/bun-cwXs2EDP.d.cts +6 -0
- package/bun-ovScJ4Es.d.ts +6 -0
- package/bun.cjs +4 -38
- package/bun.d.cts +2 -4
- package/bun.d.ts +3 -0
- package/bun.js +4 -0
- package/common-BlvLUwEz.d.ts +85 -0
- package/common-BoeQmwpt.cjs +340 -0
- package/common-CElmMmuq.js +279 -0
- package/common-DZ2cLtbe.d.cts +84 -0
- package/esbuild.cjs +6 -3
- package/esbuild.d.cts +4 -1
- package/esbuild.d.ts +5 -0
- package/esbuild.js +10 -0
- package/farm.cjs +6 -3
- package/farm.d.cts +4 -1
- package/farm.d.ts +5 -0
- package/farm.js +10 -0
- package/index-COIv1oYx.d.cts +48 -0
- package/index-PPreQbn5.d.ts +48 -0
- package/index.cjs +17 -28
- package/index.d.cts +5 -17
- package/index.d.ts +5 -0
- package/index.js +6 -0
- package/package.json +11 -9
- package/rolldown.cjs +6 -3
- package/rolldown.d.cts +4 -1
- package/rolldown.d.ts +5 -0
- package/rolldown.js +10 -0
- package/rollup.cjs +6 -3
- package/rollup.d.cts +4 -1
- package/rollup.d.ts +5 -0
- package/rollup.js +10 -0
- package/rspack.cjs +6 -3
- package/rspack.d.cts +4 -1
- package/rspack.d.ts +5 -0
- package/rspack.js +10 -0
- package/src-D84rmPxv.js +21 -0
- package/src-bIj7OBnd.cjs +82 -0
- package/vite.cjs +6 -3
- package/vite.d.cts +4 -1
- package/vite.d.ts +5 -0
- package/vite.js +10 -0
- package/webpack.cjs +6 -3
- package/webpack.d.cts +4 -1
- package/webpack.d.ts +5 -0
- package/webpack.js +10 -0
- package/babel.d.mts +0 -11
- package/babel.mjs +0 -158
- package/bun.d.mts +0 -6
- package/bun.mjs +0 -36
- package/common-CRPQ2KE6.d.mts +0 -25
- package/common-Dpl8jppn.d.cts +0 -25
- package/esbuild.d.mts +0 -2
- package/esbuild.mjs +0 -7
- package/farm.d.mts +0 -2
- package/farm.mjs +0 -7
- package/filter-6T-5w4kG.mjs +0 -234
- package/filter-CKmD4HRk.cjs +0 -327
- package/index-legacy-DRI9LQiG.d.mts +0 -1488
- package/index-legacy-xKi5C2ga.d.cts +0 -1488
- package/index.d.mts +0 -17
- package/index.mjs +0 -17
- package/rolldown-browser-DKeiFM_e.mjs +0 -129
- package/rolldown-browser-DUanNY-R.cjs +0 -141
- package/rolldown-browser-JYqfNLQ8.d.mts +0 -1247
- package/rolldown.d.mts +0 -2
- package/rolldown.mjs +0 -7
- package/rollup-impl-DqC_d-_W.d.cts +0 -1246
- package/rollup.d.mts +0 -2
- package/rollup.mjs +0 -7
- package/rspack.d.mts +0 -2
- package/rspack.mjs +0 -7
- package/vite.d.mts +0 -2
- package/vite.mjs +0 -7
- package/webpack.d.mts +0 -2
- package/webpack.mjs +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-typegpu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Build plugins for TypeGPU, enabling seamless JavaScript -> WGSL transpilation and improved debugging.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"babel-plugin",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
|
-
"url": "git+https://github.com/software-mansion/TypeGPU.git"
|
|
25
|
+
"url": "git+https://github.com/software-mansion/TypeGPU.git",
|
|
26
|
+
"directory": "packages/unplugin-typegpu"
|
|
26
27
|
},
|
|
27
28
|
"type": "module",
|
|
28
|
-
"sideEffects": false,
|
|
29
29
|
"exports": {
|
|
30
30
|
"./package.json": "./package.json",
|
|
31
31
|
".": {
|
|
@@ -140,18 +140,20 @@
|
|
|
140
140
|
}
|
|
141
141
|
},
|
|
142
142
|
"dependencies": {
|
|
143
|
-
"@babel/
|
|
143
|
+
"@babel/parser": "^7.29.0",
|
|
144
|
+
"@babel/traverse": "^7.29.0",
|
|
145
|
+
"@babel/types": "^7.29.0",
|
|
146
|
+
"ast-kit": "^2.2.0",
|
|
144
147
|
"defu": "^6.1.4",
|
|
145
|
-
"
|
|
146
|
-
"magic-string-ast": "^1.0.0",
|
|
148
|
+
"magic-string-ast": "^1.0.3",
|
|
147
149
|
"pathe": "^2.0.3",
|
|
148
|
-
"picomatch": "^4.0.
|
|
150
|
+
"picomatch": "^4.0.4",
|
|
149
151
|
"tinyest": "~0.3.1",
|
|
150
152
|
"tinyest-for-wgsl": "~0.3.2",
|
|
151
|
-
"unplugin": "^
|
|
153
|
+
"unplugin": "^3.0.0"
|
|
152
154
|
},
|
|
153
155
|
"peerDependencies": {
|
|
154
|
-
"typegpu": "^0.
|
|
156
|
+
"typegpu": "^0.11.3"
|
|
155
157
|
},
|
|
156
158
|
"main": "./index.mjs",
|
|
157
159
|
"types": "./index.d.mts",
|
package/rolldown.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
Object.
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
require('./common-BoeQmwpt.cjs');
|
|
3
|
+
require('./babel-Dis-Pwfu.cjs');
|
|
4
|
+
require('./bun-DCACcaN2.cjs');
|
|
5
|
+
const require_src = require('./src-bIj7OBnd.cjs');
|
|
3
6
|
|
|
4
7
|
//#region src/rolldown.ts
|
|
5
|
-
var rolldown_default =
|
|
8
|
+
var rolldown_default = require_src.rolldownPlugin;
|
|
6
9
|
|
|
7
10
|
//#endregion
|
|
8
11
|
exports.default = rolldown_default;
|
package/rolldown.d.cts
CHANGED
package/rolldown.d.ts
ADDED
package/rolldown.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./common-CElmMmuq.js";
|
|
2
|
+
import "./babel-CbManzjz.js";
|
|
3
|
+
import "./bun-CDECNeIU.js";
|
|
4
|
+
import { r as rolldownPlugin } from "./src-D84rmPxv.js";
|
|
5
|
+
|
|
6
|
+
//#region src/rolldown.ts
|
|
7
|
+
var rolldown_default = rolldownPlugin;
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { rolldown_default as default };
|
package/rollup.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
Object.
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
require('./common-BoeQmwpt.cjs');
|
|
3
|
+
require('./babel-Dis-Pwfu.cjs');
|
|
4
|
+
require('./bun-DCACcaN2.cjs');
|
|
5
|
+
const require_src = require('./src-bIj7OBnd.cjs');
|
|
3
6
|
|
|
4
7
|
//#region src/rollup.ts
|
|
5
|
-
var rollup_default =
|
|
8
|
+
var rollup_default = require_src.rollupPlugin;
|
|
6
9
|
|
|
7
10
|
//#endregion
|
|
8
11
|
exports.default = rollup_default;
|
package/rollup.d.cts
CHANGED
package/rollup.d.ts
ADDED
package/rollup.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./common-CElmMmuq.js";
|
|
2
|
+
import "./babel-CbManzjz.js";
|
|
3
|
+
import "./bun-CDECNeIU.js";
|
|
4
|
+
import { i as rollupPlugin } from "./src-D84rmPxv.js";
|
|
5
|
+
|
|
6
|
+
//#region src/rollup.ts
|
|
7
|
+
var rollup_default = rollupPlugin;
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { rollup_default as default };
|
package/rspack.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
Object.
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
require('./common-BoeQmwpt.cjs');
|
|
3
|
+
require('./babel-Dis-Pwfu.cjs');
|
|
4
|
+
require('./bun-DCACcaN2.cjs');
|
|
5
|
+
const require_src = require('./src-bIj7OBnd.cjs');
|
|
3
6
|
|
|
4
7
|
//#region src/rspack.ts
|
|
5
|
-
var rspack_default =
|
|
8
|
+
var rspack_default = require_src.rspackPlugin;
|
|
6
9
|
|
|
7
10
|
//#endregion
|
|
8
11
|
exports.default = rspack_default;
|
package/rspack.d.cts
CHANGED
package/rspack.d.ts
ADDED
package/rspack.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./common-CElmMmuq.js";
|
|
2
|
+
import "./babel-CbManzjz.js";
|
|
3
|
+
import "./bun-CDECNeIU.js";
|
|
4
|
+
import { a as rspackPlugin } from "./src-D84rmPxv.js";
|
|
5
|
+
|
|
6
|
+
//#region src/rspack.ts
|
|
7
|
+
var rspack_default = rspackPlugin;
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { rspack_default as default };
|
package/src-D84rmPxv.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { n as unpluginFactory } from "./bun-CDECNeIU.js";
|
|
2
|
+
import { createUnplugin } from "unplugin";
|
|
3
|
+
|
|
4
|
+
//#region src/rolldown-browser.ts
|
|
5
|
+
var rolldown_browser_default = (options) => unpluginFactory(options !== null && options !== void 0 ? options : {}, { framework: "rolldown" });
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/index.ts
|
|
9
|
+
const typegpu = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
|
10
|
+
var src_default = typegpu;
|
|
11
|
+
const vitePlugin = typegpu.vite;
|
|
12
|
+
const rollupPlugin = typegpu.rollup;
|
|
13
|
+
const rolldownPlugin = typegpu.rolldown;
|
|
14
|
+
const webpackPlugin = typegpu.webpack;
|
|
15
|
+
const rspackPlugin = typegpu.rspack;
|
|
16
|
+
const esbuildPlugin = typegpu.esbuild;
|
|
17
|
+
const farmPlugin = typegpu.farm;
|
|
18
|
+
const unloaderPlugin = typegpu.unloader;
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { rspackPlugin as a, vitePlugin as c, rollupPlugin as i, webpackPlugin as l, farmPlugin as n, src_default as o, rolldownPlugin as r, unloaderPlugin as s, esbuildPlugin as t, rolldown_browser_default as u };
|
package/src-bIj7OBnd.cjs
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const require_common = require('./common-BoeQmwpt.cjs');
|
|
2
|
+
const require_bun = require('./bun-DCACcaN2.cjs');
|
|
3
|
+
let unplugin = require("unplugin");
|
|
4
|
+
unplugin = require_common.__toESM(unplugin);
|
|
5
|
+
|
|
6
|
+
//#region src/rolldown-browser.ts
|
|
7
|
+
var rolldown_browser_default = (options) => require_bun.unpluginFactory(options !== null && options !== void 0 ? options : {}, { framework: "rolldown" });
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/index.ts
|
|
11
|
+
const typegpu = /* @__PURE__ */ (0, unplugin.createUnplugin)(require_bun.unpluginFactory);
|
|
12
|
+
var src_default = typegpu;
|
|
13
|
+
const vitePlugin = typegpu.vite;
|
|
14
|
+
const rollupPlugin = typegpu.rollup;
|
|
15
|
+
const rolldownPlugin = typegpu.rolldown;
|
|
16
|
+
const webpackPlugin = typegpu.webpack;
|
|
17
|
+
const rspackPlugin = typegpu.rspack;
|
|
18
|
+
const esbuildPlugin = typegpu.esbuild;
|
|
19
|
+
const farmPlugin = typegpu.farm;
|
|
20
|
+
const unloaderPlugin = typegpu.unloader;
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
Object.defineProperty(exports, 'esbuildPlugin', {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () {
|
|
26
|
+
return esbuildPlugin;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports, 'farmPlugin', {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () {
|
|
32
|
+
return farmPlugin;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, 'rolldownPlugin', {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () {
|
|
38
|
+
return rolldownPlugin;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(exports, 'rolldown_browser_default', {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () {
|
|
44
|
+
return rolldown_browser_default;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(exports, 'rollupPlugin', {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function () {
|
|
50
|
+
return rollupPlugin;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(exports, 'rspackPlugin', {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function () {
|
|
56
|
+
return rspackPlugin;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(exports, 'src_default', {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function () {
|
|
62
|
+
return src_default;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
Object.defineProperty(exports, 'unloaderPlugin', {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return unloaderPlugin;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(exports, 'vitePlugin', {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
get: function () {
|
|
74
|
+
return vitePlugin;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(exports, 'webpackPlugin', {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function () {
|
|
80
|
+
return webpackPlugin;
|
|
81
|
+
}
|
|
82
|
+
});
|
package/vite.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
Object.
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
require('./common-BoeQmwpt.cjs');
|
|
3
|
+
require('./babel-Dis-Pwfu.cjs');
|
|
4
|
+
require('./bun-DCACcaN2.cjs');
|
|
5
|
+
const require_src = require('./src-bIj7OBnd.cjs');
|
|
3
6
|
|
|
4
7
|
//#region src/vite.ts
|
|
5
|
-
var vite_default =
|
|
8
|
+
var vite_default = require_src.vitePlugin;
|
|
6
9
|
|
|
7
10
|
//#endregion
|
|
8
11
|
exports.default = vite_default;
|
package/vite.d.cts
CHANGED
package/vite.d.ts
ADDED
package/vite.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./common-CElmMmuq.js";
|
|
2
|
+
import "./babel-CbManzjz.js";
|
|
3
|
+
import "./bun-CDECNeIU.js";
|
|
4
|
+
import { c as vitePlugin } from "./src-D84rmPxv.js";
|
|
5
|
+
|
|
6
|
+
//#region src/vite.ts
|
|
7
|
+
var vite_default = vitePlugin;
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { vite_default as default };
|
package/webpack.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
Object.
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
require('./common-BoeQmwpt.cjs');
|
|
3
|
+
require('./babel-Dis-Pwfu.cjs');
|
|
4
|
+
require('./bun-DCACcaN2.cjs');
|
|
5
|
+
const require_src = require('./src-bIj7OBnd.cjs');
|
|
3
6
|
|
|
4
7
|
//#region src/webpack.ts
|
|
5
|
-
var webpack_default =
|
|
8
|
+
var webpack_default = require_src.webpackPlugin;
|
|
6
9
|
|
|
7
10
|
//#endregion
|
|
8
11
|
exports.default = webpack_default;
|
package/webpack.d.cts
CHANGED
package/webpack.d.ts
ADDED
package/webpack.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./common-CElmMmuq.js";
|
|
2
|
+
import "./babel-CbManzjz.js";
|
|
3
|
+
import "./bun-CDECNeIU.js";
|
|
4
|
+
import { l as webpackPlugin } from "./src-D84rmPxv.js";
|
|
5
|
+
|
|
6
|
+
//#region src/webpack.ts
|
|
7
|
+
var webpack_default = webpackPlugin;
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { webpack_default as default };
|
package/babel.d.mts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { n as Program, t as Node } from "./index-legacy-DRI9LQiG.mjs";
|
|
2
|
-
import * as _babel_traverse0 from "@babel/traverse";
|
|
3
|
-
|
|
4
|
-
//#region src/babel.d.ts
|
|
5
|
-
declare function export_default(): {
|
|
6
|
-
visitor: {
|
|
7
|
-
Program(this: Node, path: _babel_traverse0.NodePath<Program>, state: Node): void;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
//#endregion
|
|
11
|
-
export { export_default as default };
|
package/babel.mjs
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { a as gatherTgpuAliases, c as operators, i as embedJSON, l as performExpressionNaming, n as defaultOptions, o as getFunctionName, s as isShellImplementationCall, t as createFilterForId, u as useGpuDirective } from "./filter-6T-5w4kG.mjs";
|
|
2
|
-
import defu from "defu";
|
|
3
|
-
import { transpileFn } from "tinyest-for-wgsl";
|
|
4
|
-
import { FORMAT_VERSION } from "tinyest";
|
|
5
|
-
import * as Babel from "@babel/standalone";
|
|
6
|
-
|
|
7
|
-
//#region src/babel.ts
|
|
8
|
-
const template = Babel.packages.template;
|
|
9
|
-
const types = Babel.packages.types;
|
|
10
|
-
function containsUseGpuDirective(node) {
|
|
11
|
-
var _node$body$directives, _node$body;
|
|
12
|
-
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(useGpuDirective);
|
|
13
|
-
}
|
|
14
|
-
function i(identifier) {
|
|
15
|
-
return types.identifier(identifier);
|
|
16
|
-
}
|
|
17
|
-
const fnNodeToOriginalMap = /* @__PURE__ */ new WeakMap();
|
|
18
|
-
function functionToTranspiled(node, parent) {
|
|
19
|
-
var _fnNodeToOriginalMap$;
|
|
20
|
-
const { params, body, externalNames } = transpileFn((_fnNodeToOriginalMap$ = fnNodeToOriginalMap.get(node)) !== null && _fnNodeToOriginalMap$ !== void 0 ? _fnNodeToOriginalMap$ : node);
|
|
21
|
-
const maybeName = getFunctionName(node, parent);
|
|
22
|
-
const metadata = types.objectExpression([
|
|
23
|
-
types.objectProperty(i("v"), types.numericLiteral(FORMAT_VERSION)),
|
|
24
|
-
types.objectProperty(i("name"), maybeName ? types.stringLiteral(maybeName) : types.buildUndefinedNode()),
|
|
25
|
-
types.objectProperty(i("ast"), template.expression`${embedJSON({
|
|
26
|
-
params,
|
|
27
|
-
body,
|
|
28
|
-
externalNames
|
|
29
|
-
})}`()),
|
|
30
|
-
types.objectProperty(i("externals"), types.arrowFunctionExpression([], types.blockStatement([types.returnStatement(types.objectExpression(externalNames.map((name) => types.objectProperty(i(name), i(name), false, name !== "this"))))])))
|
|
31
|
-
]);
|
|
32
|
-
return types.callExpression(types.arrowFunctionExpression([i("$")], types.logicalExpression("&&", types.callExpression(types.memberExpression(types.assignmentExpression("??=", types.memberExpression(i("globalThis"), i("__TYPEGPU_META__")), types.newExpression(i("WeakMap"), [])), i("set")), [types.assignmentExpression("=", types.memberExpression(i("$"), i("f")), node), metadata]), types.memberExpression(i("$"), i("f")))), [types.objectExpression([])]);
|
|
33
|
-
}
|
|
34
|
-
function wrapInAutoName(node, name) {
|
|
35
|
-
return types.callExpression(template.expression("globalThis.__TYPEGPU_AUTONAME__ ?? (a => a)", { placeholderPattern: false })(), [node, types.stringLiteral(name)]);
|
|
36
|
-
}
|
|
37
|
-
function functionVisitor(ctx) {
|
|
38
|
-
let inUseGpuScope = false;
|
|
39
|
-
return {
|
|
40
|
-
VariableDeclarator(path) {
|
|
41
|
-
performExpressionNaming(ctx, path.node, (node, name) => {
|
|
42
|
-
path.get("init").replaceWith(wrapInAutoName(node, name));
|
|
43
|
-
});
|
|
44
|
-
},
|
|
45
|
-
AssignmentExpression(path) {
|
|
46
|
-
if (inUseGpuScope) {
|
|
47
|
-
const runtimeFn = operators[path.node.operator];
|
|
48
|
-
if (runtimeFn) path.replaceWith(types.assignmentExpression("=", path.node.left, types.callExpression(types.identifier(runtimeFn), [path.node.left, path.node.right])));
|
|
49
|
-
}
|
|
50
|
-
performExpressionNaming(ctx, path.node, (node, name) => {
|
|
51
|
-
path.get("right").replaceWith(wrapInAutoName(node, name));
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
ObjectProperty(path) {
|
|
55
|
-
performExpressionNaming(ctx, path.node, (node, name) => {
|
|
56
|
-
path.get("value").replaceWith(wrapInAutoName(node, name));
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
ClassProperty(path) {
|
|
60
|
-
performExpressionNaming(ctx, path.node, (node, name) => {
|
|
61
|
-
path.get("value").replaceWith(wrapInAutoName(node, name));
|
|
62
|
-
});
|
|
63
|
-
},
|
|
64
|
-
ImportDeclaration(path) {
|
|
65
|
-
gatherTgpuAliases(path.node, ctx);
|
|
66
|
-
},
|
|
67
|
-
BinaryExpression: { exit(path) {
|
|
68
|
-
if (!inUseGpuScope) return;
|
|
69
|
-
const runtimeFn = operators[path.node.operator];
|
|
70
|
-
if (runtimeFn) path.replaceWith(types.callExpression(types.identifier(runtimeFn), [path.node.left, path.node.right]));
|
|
71
|
-
} },
|
|
72
|
-
ArrowFunctionExpression: {
|
|
73
|
-
enter(path) {
|
|
74
|
-
if (containsUseGpuDirective(path.node)) {
|
|
75
|
-
fnNodeToOriginalMap.set(path.node, types.cloneNode(path.node, true));
|
|
76
|
-
if (inUseGpuScope) throw new Error(`Nesting 'use gpu' functions is not allowed`);
|
|
77
|
-
inUseGpuScope = true;
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
exit(path) {
|
|
81
|
-
const node = path.node;
|
|
82
|
-
if (containsUseGpuDirective(node)) {
|
|
83
|
-
inUseGpuScope = false;
|
|
84
|
-
const parent = path.parentPath.node;
|
|
85
|
-
path.replaceWith(functionToTranspiled(node, parent));
|
|
86
|
-
path.skip();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
FunctionExpression: {
|
|
91
|
-
enter(path) {
|
|
92
|
-
if (containsUseGpuDirective(path.node)) {
|
|
93
|
-
fnNodeToOriginalMap.set(path.node, types.cloneNode(path.node, true));
|
|
94
|
-
if (inUseGpuScope) throw new Error(`Nesting 'use gpu' functions is not allowed`);
|
|
95
|
-
inUseGpuScope = true;
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
exit(path) {
|
|
99
|
-
const node = path.node;
|
|
100
|
-
if (containsUseGpuDirective(node)) {
|
|
101
|
-
inUseGpuScope = false;
|
|
102
|
-
const parent = path.parentPath.node;
|
|
103
|
-
path.replaceWith(functionToTranspiled(node, parent));
|
|
104
|
-
path.skip();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
FunctionDeclaration: {
|
|
109
|
-
enter(path) {
|
|
110
|
-
if (containsUseGpuDirective(path.node)) {
|
|
111
|
-
fnNodeToOriginalMap.set(path.node, types.cloneNode(path.node, true));
|
|
112
|
-
if (inUseGpuScope) throw new Error(`Nesting 'use gpu' functions is not allowed`);
|
|
113
|
-
inUseGpuScope = true;
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
exit(path) {
|
|
117
|
-
var _fnNodeToOriginalMap$2;
|
|
118
|
-
const node = (_fnNodeToOriginalMap$2 = fnNodeToOriginalMap.get(path.node)) !== null && _fnNodeToOriginalMap$2 !== void 0 ? _fnNodeToOriginalMap$2 : path.node;
|
|
119
|
-
if (containsUseGpuDirective(node)) {
|
|
120
|
-
inUseGpuScope = false;
|
|
121
|
-
if (!node.id) return;
|
|
122
|
-
const parent = path.parentPath.node;
|
|
123
|
-
const expression = types.functionExpression(node.id, node.params, node.body);
|
|
124
|
-
path.replaceWith(types.variableDeclaration("const", [types.variableDeclarator(node.id, functionToTranspiled(expression, parent))]));
|
|
125
|
-
path.skip();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
CallExpression: { exit(path) {
|
|
130
|
-
const node = path.node;
|
|
131
|
-
if (isShellImplementationCall(node, ctx)) {
|
|
132
|
-
const implementation = node.arguments[0];
|
|
133
|
-
if (implementation && (implementation.type === "FunctionExpression" || implementation.type === "ArrowFunctionExpression")) {
|
|
134
|
-
const transpiled = functionToTranspiled(implementation, null);
|
|
135
|
-
path.replaceWith(types.callExpression(node.callee, [transpiled]));
|
|
136
|
-
path.skip();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
} }
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
function babel_default() {
|
|
143
|
-
return { visitor: { Program(path, state) {
|
|
144
|
-
const options = defu(state.opts, defaultOptions);
|
|
145
|
-
const id = state.filename;
|
|
146
|
-
const filter = createFilterForId(options);
|
|
147
|
-
if (id && filter && !(filter === null || filter === void 0 ? void 0 : filter(id))) return;
|
|
148
|
-
const ctx = {
|
|
149
|
-
tgpuAliases: new Set(options.forceTgpuAlias ? [options.forceTgpuAlias] : []),
|
|
150
|
-
fileId: id,
|
|
151
|
-
autoNamingEnabled: options.autoNamingEnabled
|
|
152
|
-
};
|
|
153
|
-
path.traverse(functionVisitor(ctx));
|
|
154
|
-
} } };
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
//#endregion
|
|
158
|
-
export { babel_default as default };
|
package/bun.d.mts
DELETED
package/bun.mjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { n as defaultOptions, r as earlyPruneRegex } from "./filter-6T-5w4kG.mjs";
|
|
2
|
-
import babel_default from "./babel.mjs";
|
|
3
|
-
import defu from "defu";
|
|
4
|
-
import * as Babel from "@babel/standalone";
|
|
5
|
-
|
|
6
|
-
//#region src/bun.ts
|
|
7
|
-
var bun_default = (rawOptions) => {
|
|
8
|
-
const options = defu(rawOptions, defaultOptions);
|
|
9
|
-
const include = options.include;
|
|
10
|
-
if (!(include instanceof RegExp)) throw new Error(`Unsupported 'include' options in Bun plugin. Please provide a single regular expression`);
|
|
11
|
-
if (options.exclude) throw new Error(`Unsupported 'exclude' option in Bun plugin`);
|
|
12
|
-
return {
|
|
13
|
-
name: "unplugin-typegpu",
|
|
14
|
-
setup(build) {
|
|
15
|
-
build.onLoad({ filter: include }, async (args) => {
|
|
16
|
-
const text = await Bun.file(args.path).text();
|
|
17
|
-
if (earlyPruneRegex.every((pattern) => !pattern.test(text))) return {
|
|
18
|
-
contents: text,
|
|
19
|
-
loader: args.loader
|
|
20
|
-
};
|
|
21
|
-
const result = Babel.transform(text, {
|
|
22
|
-
presets: [["typescript", { allowDeclareFields: true }]],
|
|
23
|
-
filename: args.path,
|
|
24
|
-
plugins: [babel_default]
|
|
25
|
-
}).code;
|
|
26
|
-
return {
|
|
27
|
-
contents: result !== null && result !== void 0 ? result : text,
|
|
28
|
-
loader: args.loader
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
36
|
-
export { bun_default as default };
|
package/common-CRPQ2KE6.d.mts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { FilterPattern } from "unplugin";
|
|
2
|
-
|
|
3
|
-
//#region src/common.d.ts
|
|
4
|
-
interface Options {
|
|
5
|
-
/** @default [/\.m?[jt]sx?$/] */
|
|
6
|
-
include?: FilterPattern;
|
|
7
|
-
/** @default undefined */
|
|
8
|
-
exclude?: FilterPattern;
|
|
9
|
-
/** @default undefined */
|
|
10
|
-
enforce?: 'post' | 'pre' | undefined;
|
|
11
|
-
/** @default undefined */
|
|
12
|
-
forceTgpuAlias?: string | undefined;
|
|
13
|
-
/** @default true */
|
|
14
|
-
autoNamingEnabled?: boolean | undefined;
|
|
15
|
-
/**
|
|
16
|
-
* Skipping files that don't contain "typegpu", "tgpu" or "use gpu".
|
|
17
|
-
* In case this early pruning hinders transformation, you
|
|
18
|
-
* can disable it.
|
|
19
|
-
*
|
|
20
|
-
* @default true
|
|
21
|
-
*/
|
|
22
|
-
earlyPruning?: boolean | undefined;
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
export { Options as t };
|
package/common-Dpl8jppn.d.cts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { FilterPattern } from "unplugin";
|
|
2
|
-
|
|
3
|
-
//#region src/common.d.ts
|
|
4
|
-
interface Options {
|
|
5
|
-
/** @default [/\.m?[jt]sx?$/] */
|
|
6
|
-
include?: FilterPattern;
|
|
7
|
-
/** @default undefined */
|
|
8
|
-
exclude?: FilterPattern;
|
|
9
|
-
/** @default undefined */
|
|
10
|
-
enforce?: 'post' | 'pre' | undefined;
|
|
11
|
-
/** @default undefined */
|
|
12
|
-
forceTgpuAlias?: string | undefined;
|
|
13
|
-
/** @default true */
|
|
14
|
-
autoNamingEnabled?: boolean | undefined;
|
|
15
|
-
/**
|
|
16
|
-
* Skipping files that don't contain "typegpu", "tgpu" or "use gpu".
|
|
17
|
-
* In case this early pruning hinders transformation, you
|
|
18
|
-
* can disable it.
|
|
19
|
-
*
|
|
20
|
-
* @default true
|
|
21
|
-
*/
|
|
22
|
-
earlyPruning?: boolean | undefined;
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
export { Options as t };
|
package/esbuild.d.mts
DELETED
package/esbuild.mjs
DELETED
package/farm.d.mts
DELETED