unplugin-typegpu 0.11.6 → 0.12.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/{babel-B7h6V8Bs.js → babel-C62qx26_.js} +16 -5
- 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-C7MhY2Q5.cjs → babel-DpCnkpmi.cjs} +16 -5
- package/babel.cjs +2 -2
- package/babel.d.cts +2 -2
- package/babel.d.ts +2 -2
- package/babel.js +2 -2
- package/{bun-D_FFJG6e.cjs → bun-Bijjhb7w.cjs} +3 -3
- package/{bun-f_IcPQ-M.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-W6dKP7m4.js → factory-BSXzHM_n.js} +10 -70
- package/{factory-BgweY_8-.cjs → factory-CXjNN-uX.cjs} +11 -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-zDnadEd0.d.cts → index-COouFDDA.d.cts} +7 -7
- package/{index-BkLJ1amC.d.ts → index-DaJ1nxWt.d.ts} +1 -1
- 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 +5 -5
- package/{rolldown-browser-DQtD9pV1.cjs → rolldown-browser-0UeIgV94.cjs} +1 -1
- package/{rolldown-browser-D3BM6oXF.d.ts → rolldown-browser-1an_WnxF.d.ts} +13 -9
- package/rolldown-browser-Da9eNbZo.d.cts +44 -0
- package/{rolldown-browser-NmW1NQnD.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-YdrXaMF1.js → src-BPzkBd5O.js} +1 -1
- package/{src-NN6mroxq.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-CvOoUvEH.d.cts +0 -40
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as functionVisitor, n as checkOpts, o as getBlockScope, r as defaultOptions, s as initPluginState, t as METADATA_FORMAT_VERSION } from "./common-Dilxou2I.js";
|
|
2
2
|
import defu from "defu";
|
|
3
3
|
import { transpileFn } from "tinyest-for-wgsl";
|
|
4
4
|
import * as t from "@babel/types";
|
|
@@ -66,12 +66,24 @@ function createFilterForId(filter) {
|
|
|
66
66
|
function i(identifier) {
|
|
67
67
|
return t.identifier(identifier);
|
|
68
68
|
}
|
|
69
|
+
function externalsToNode(externals) {
|
|
70
|
+
return t.objectExpression(Array.from(externals, ([key, value]) => {
|
|
71
|
+
const chain = value.split(".");
|
|
72
|
+
if (!chain[0]) throw new Error("Internal error, expected chain to not be empty");
|
|
73
|
+
const base = chain[0] === "this" ? t.thisExpression() : i(chain[0]);
|
|
74
|
+
const propAccess = chain.slice(1).reduce((obj, prop) => t.memberExpression(obj, t.identifier(prop)), base);
|
|
75
|
+
return t.objectProperty(t.stringLiteral(key), t.arrowFunctionExpression([], propAccess), false);
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
69
78
|
function assignMetadata(path, name, ast) {
|
|
70
79
|
const metadata = t.objectExpression([
|
|
71
80
|
t.objectProperty(i("v"), t.numericLiteral(METADATA_FORMAT_VERSION)),
|
|
72
81
|
t.objectProperty(i("name"), t.valueToNode(name)),
|
|
73
|
-
t.objectProperty(i("ast"), t.valueToNode(
|
|
74
|
-
|
|
82
|
+
t.objectProperty(i("ast"), t.valueToNode({
|
|
83
|
+
params: ast.params,
|
|
84
|
+
body: ast.body
|
|
85
|
+
})),
|
|
86
|
+
t.objectProperty(i("externals"), externalsToNode(ast.externalNames))
|
|
75
87
|
]);
|
|
76
88
|
let expression;
|
|
77
89
|
const visibility = t.isFunctionDeclaration(path.node) ? getBlockScope(path) : void 0;
|
|
@@ -91,7 +103,6 @@ function assignMetadata(path, name, ast) {
|
|
|
91
103
|
}
|
|
92
104
|
if (visibility) {
|
|
93
105
|
visibility.unshiftContainer("body", replacement);
|
|
94
|
-
this.alreadyTransformed.add(expression);
|
|
95
106
|
const id = t.isFunctionDeclaration(path.node) ? path.node.id : void 0;
|
|
96
107
|
if (id && path.parentPath.isExportNamedDeclaration()) path.parentPath.replaceWith(t.exportNamedDeclaration(null, [t.exportSpecifier(t.cloneNode(id), t.cloneNode(id))]));
|
|
97
108
|
else if (id && path.parentPath.isExportDefaultDeclaration()) path.parentPath.replaceWith(t.exportDefaultDeclaration(t.cloneNode(id)));
|
|
@@ -114,7 +125,7 @@ function TypeGPUPlugin() {
|
|
|
114
125
|
return {
|
|
115
126
|
name: "typegpu",
|
|
116
127
|
pre() {
|
|
117
|
-
this.opts = defu(this.opts, defaultOptions);
|
|
128
|
+
this.opts = checkOpts(defu(this.opts, defaultOptions));
|
|
118
129
|
initPluginState(this, {
|
|
119
130
|
warn: (message) => console.warn(message),
|
|
120
131
|
assignMetadata,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_common = require('./common-
|
|
1
|
+
const require_common = require('./common-hMfUmUk0.cjs');
|
|
2
2
|
let defu = require("defu");
|
|
3
3
|
defu = require_common.__toESM(defu);
|
|
4
4
|
let tinyest_for_wgsl = require("tinyest-for-wgsl");
|
|
@@ -71,12 +71,24 @@ function createFilterForId(filter) {
|
|
|
71
71
|
function i(identifier) {
|
|
72
72
|
return __babel_types.identifier(identifier);
|
|
73
73
|
}
|
|
74
|
+
function externalsToNode(externals) {
|
|
75
|
+
return __babel_types.objectExpression(Array.from(externals, ([key, value]) => {
|
|
76
|
+
const chain = value.split(".");
|
|
77
|
+
if (!chain[0]) throw new Error("Internal error, expected chain to not be empty");
|
|
78
|
+
const base = chain[0] === "this" ? __babel_types.thisExpression() : i(chain[0]);
|
|
79
|
+
const propAccess = chain.slice(1).reduce((obj, prop) => __babel_types.memberExpression(obj, __babel_types.identifier(prop)), base);
|
|
80
|
+
return __babel_types.objectProperty(__babel_types.stringLiteral(key), __babel_types.arrowFunctionExpression([], propAccess), false);
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
74
83
|
function assignMetadata(path, name, ast) {
|
|
75
84
|
const metadata = __babel_types.objectExpression([
|
|
76
85
|
__babel_types.objectProperty(i("v"), __babel_types.numericLiteral(require_common.METADATA_FORMAT_VERSION)),
|
|
77
86
|
__babel_types.objectProperty(i("name"), __babel_types.valueToNode(name)),
|
|
78
|
-
__babel_types.objectProperty(i("ast"), __babel_types.valueToNode(
|
|
79
|
-
|
|
87
|
+
__babel_types.objectProperty(i("ast"), __babel_types.valueToNode({
|
|
88
|
+
params: ast.params,
|
|
89
|
+
body: ast.body
|
|
90
|
+
})),
|
|
91
|
+
__babel_types.objectProperty(i("externals"), externalsToNode(ast.externalNames))
|
|
80
92
|
]);
|
|
81
93
|
let expression;
|
|
82
94
|
const visibility = __babel_types.isFunctionDeclaration(path.node) ? require_common.getBlockScope(path) : void 0;
|
|
@@ -96,7 +108,6 @@ function assignMetadata(path, name, ast) {
|
|
|
96
108
|
}
|
|
97
109
|
if (visibility) {
|
|
98
110
|
visibility.unshiftContainer("body", replacement);
|
|
99
|
-
this.alreadyTransformed.add(expression);
|
|
100
111
|
const id = __babel_types.isFunctionDeclaration(path.node) ? path.node.id : void 0;
|
|
101
112
|
if (id && path.parentPath.isExportNamedDeclaration()) path.parentPath.replaceWith(__babel_types.exportNamedDeclaration(null, [__babel_types.exportSpecifier(__babel_types.cloneNode(id), __babel_types.cloneNode(id))]));
|
|
102
113
|
else if (id && path.parentPath.isExportDefaultDeclaration()) path.parentPath.replaceWith(__babel_types.exportDefaultDeclaration(__babel_types.cloneNode(id)));
|
|
@@ -119,7 +130,7 @@ function TypeGPUPlugin() {
|
|
|
119
130
|
return {
|
|
120
131
|
name: "typegpu",
|
|
121
132
|
pre() {
|
|
122
|
-
this.opts = (0, defu.default)(this.opts, require_common.defaultOptions);
|
|
133
|
+
this.opts = require_common.checkOpts((0, defu.default)(this.opts, require_common.defaultOptions));
|
|
123
134
|
require_common.initPluginState(this, {
|
|
124
135
|
warn: (message) => console.warn(message),
|
|
125
136
|
assignMetadata,
|
package/babel.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./common-
|
|
3
|
-
const require_babel = require('./babel-
|
|
2
|
+
require('./common-hMfUmUk0.cjs');
|
|
3
|
+
const require_babel = require('./babel-DpCnkpmi.cjs');
|
|
4
4
|
|
|
5
5
|
exports.default = require_babel.TypeGPUPlugin;
|
package/babel.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import { t as TypeGPUPlugin } from "./babel-
|
|
1
|
+
import "./common-BriEOmpZ.cjs";
|
|
2
|
+
import { t as TypeGPUPlugin } from "./babel-CYu2-eXe.cjs";
|
|
3
3
|
export = TypeGPUPlugin;
|
package/babel.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import { t as TypeGPUPlugin } from "./babel
|
|
1
|
+
import "./common-CWaD5wkm.js";
|
|
2
|
+
import { t as TypeGPUPlugin } from "./babel-DOOIkQDL.js";
|
|
3
3
|
export { TypeGPUPlugin as default };
|
package/babel.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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 defu = require("defu");
|
|
4
4
|
defu = require_common.__toESM(defu);
|
|
5
5
|
|
|
6
6
|
//#region src/bun.ts
|
|
7
7
|
var bun_default = (rawOptions) => {
|
|
8
|
-
const options = (0, defu.default)(rawOptions, require_common.defaultOptions);
|
|
8
|
+
const options = require_common.checkOpts((0, defu.default)(rawOptions, require_common.defaultOptions));
|
|
9
9
|
const include = options.include;
|
|
10
10
|
if (!(include instanceof RegExp)) throw new Error(`Unsupported 'include' options in Bun plugin. Please provide a single regular expression`);
|
|
11
11
|
if (options.exclude) throw new Error(`Unsupported 'exclude' option in Bun plugin`);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { t as unpluginFactory } from "./factory-
|
|
1
|
+
import { i as earlyPruneRegex, n as checkOpts, r as defaultOptions } from "./common-Dilxou2I.js";
|
|
2
|
+
import { t as unpluginFactory } from "./factory-BSXzHM_n.js";
|
|
3
3
|
import defu from "defu";
|
|
4
4
|
|
|
5
5
|
//#region src/bun.ts
|
|
6
6
|
var bun_default = (rawOptions) => {
|
|
7
|
-
const options = defu(rawOptions, defaultOptions);
|
|
7
|
+
const options = checkOpts(defu(rawOptions, defaultOptions));
|
|
8
8
|
const include = options.include;
|
|
9
9
|
if (!(include instanceof RegExp)) throw new Error(`Unsupported 'include' options in Bun plugin. Please provide a single regular expression`);
|
|
10
10
|
if (options.exclude) throw new Error(`Unsupported 'exclude' option in Bun plugin`);
|
package/bun.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./common-
|
|
3
|
-
require('./factory-
|
|
4
|
-
const require_bun = require('./bun-
|
|
2
|
+
require('./common-hMfUmUk0.cjs');
|
|
3
|
+
require('./factory-CXjNN-uX.cjs');
|
|
4
|
+
const require_bun = require('./bun-Bijjhb7w.cjs');
|
|
5
5
|
|
|
6
6
|
exports.default = require_bun.bun_default;
|
package/bun.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import { t as _default } from "./bun-
|
|
1
|
+
import "./common-BriEOmpZ.cjs";
|
|
2
|
+
import { t as _default } from "./bun-YVuHXBJq.cjs";
|
|
3
3
|
export = _default;
|
package/bun.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import { t as _default } from "./bun-
|
|
1
|
+
import "./common-CWaD5wkm.js";
|
|
2
|
+
import { t as _default } from "./bun-DKuUuTVo.js";
|
|
3
3
|
export { _default as default };
|
package/bun.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./common-
|
|
2
|
-
import "./factory-
|
|
3
|
-
import { t as bun_default } from "./bun-
|
|
1
|
+
import "./common-Dilxou2I.js";
|
|
2
|
+
import "./factory-BSXzHM_n.js";
|
|
3
|
+
import { t as bun_default } from "./bun-CJralo3D.js";
|
|
4
4
|
|
|
5
5
|
export { bun_default as default };
|
|
@@ -9,13 +9,20 @@ interface Options {
|
|
|
9
9
|
/** @default [/\.m?[jt]sx?$/] */
|
|
10
10
|
include?: FilterPattern;
|
|
11
11
|
/** @default undefined */
|
|
12
|
-
exclude?: FilterPattern;
|
|
12
|
+
exclude?: FilterPattern | undefined;
|
|
13
13
|
/** @default undefined */
|
|
14
14
|
enforce?: 'post' | 'pre' | undefined;
|
|
15
15
|
/** @default undefined */
|
|
16
16
|
forceTgpuAlias?: string | undefined;
|
|
17
17
|
/** @default true */
|
|
18
|
-
autoNamingEnabled?: boolean
|
|
18
|
+
autoNamingEnabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Obfuscate the generated AST.
|
|
21
|
+
* This results in obfuscation of the generated WGSL, and in smaller bundle sizes.
|
|
22
|
+
*
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
unstable_obfuscate?: boolean;
|
|
19
26
|
/**
|
|
20
27
|
* Skipping files that don't contain "typegpu", "tgpu" or "use gpu".
|
|
21
28
|
* In case this early pruning hinders transformation, you
|
|
@@ -77,9 +84,8 @@ interface PluginState extends TransformMethods {
|
|
|
77
84
|
* In Babel, options are assigned to the property `opts` on the plugin state.
|
|
78
85
|
* We use this pattern everywhere for consistency.
|
|
79
86
|
*/
|
|
80
|
-
opts: Options
|
|
87
|
+
opts: Required<Options>;
|
|
81
88
|
inUseGpuScope: boolean;
|
|
82
|
-
alreadyTransformed: WeakSet<t.Node>;
|
|
83
89
|
}
|
|
84
90
|
//#endregion
|
|
85
91
|
export { PluginState as n, Options as t };
|
|
@@ -10,13 +10,20 @@ interface Options {
|
|
|
10
10
|
/** @default [/\.m?[jt]sx?$/] */
|
|
11
11
|
include?: FilterPattern;
|
|
12
12
|
/** @default undefined */
|
|
13
|
-
exclude?: FilterPattern;
|
|
13
|
+
exclude?: FilterPattern | undefined;
|
|
14
14
|
/** @default undefined */
|
|
15
15
|
enforce?: 'post' | 'pre' | undefined;
|
|
16
16
|
/** @default undefined */
|
|
17
17
|
forceTgpuAlias?: string | undefined;
|
|
18
18
|
/** @default true */
|
|
19
|
-
autoNamingEnabled?: boolean
|
|
19
|
+
autoNamingEnabled?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Obfuscate the generated AST.
|
|
22
|
+
* This results in obfuscation of the generated WGSL, and in smaller bundle sizes.
|
|
23
|
+
*
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
unstable_obfuscate?: boolean;
|
|
20
27
|
/**
|
|
21
28
|
* Skipping files that don't contain "typegpu", "tgpu" or "use gpu".
|
|
22
29
|
* In case this early pruning hinders transformation, you
|
|
@@ -78,9 +85,8 @@ interface PluginState extends TransformMethods {
|
|
|
78
85
|
* In Babel, options are assigned to the property `opts` on the plugin state.
|
|
79
86
|
* We use this pattern everywhere for consistency.
|
|
80
87
|
*/
|
|
81
|
-
opts: Options
|
|
88
|
+
opts: Required<Options>;
|
|
82
89
|
inUseGpuScope: boolean;
|
|
83
|
-
alreadyTransformed: WeakSet<t.Node>;
|
|
84
90
|
}
|
|
85
91
|
//#endregion
|
|
86
92
|
export { PluginState as n, Options as t };
|