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
|
@@ -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;
|
|
@@ -83,12 +95,18 @@ function assignMetadata(path, name, ast) {
|
|
|
83
95
|
if (t.isFunctionDeclaration(path.node) && path.node.id) {
|
|
84
96
|
const declaration = t.variableDeclaration("const", [t.variableDeclarator(path.node.id, callExpr)]);
|
|
85
97
|
t.inheritLeadingComments(declaration, path.node);
|
|
98
|
+
if (path.parentPath && (path.parentPath.isExportNamedDeclaration() || path.parentPath.isExportDefaultDeclaration())) {
|
|
99
|
+
t.inheritLeadingComments(declaration, path.parentPath.node);
|
|
100
|
+
path.parentPath.node.leadingComments = null;
|
|
101
|
+
}
|
|
86
102
|
replacement = declaration;
|
|
87
103
|
}
|
|
88
104
|
if (visibility) {
|
|
89
105
|
visibility.unshiftContainer("body", replacement);
|
|
90
|
-
|
|
91
|
-
path.
|
|
106
|
+
const id = t.isFunctionDeclaration(path.node) ? path.node.id : void 0;
|
|
107
|
+
if (id && path.parentPath.isExportNamedDeclaration()) path.parentPath.replaceWith(t.exportNamedDeclaration(null, [t.exportSpecifier(t.cloneNode(id), t.cloneNode(id))]));
|
|
108
|
+
else if (id && path.parentPath.isExportDefaultDeclaration()) path.parentPath.replaceWith(t.exportDefaultDeclaration(t.cloneNode(id)));
|
|
109
|
+
else path.remove();
|
|
92
110
|
} else path.replaceWith(replacement);
|
|
93
111
|
path.skip();
|
|
94
112
|
}
|
|
@@ -107,7 +125,7 @@ function TypeGPUPlugin() {
|
|
|
107
125
|
return {
|
|
108
126
|
name: "typegpu",
|
|
109
127
|
pre() {
|
|
110
|
-
this.opts = defu(this.opts, defaultOptions);
|
|
128
|
+
this.opts = checkOpts(defu(this.opts, defaultOptions));
|
|
111
129
|
initPluginState(this, {
|
|
112
130
|
warn: (message) => console.warn(message),
|
|
113
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;
|
|
@@ -88,12 +100,18 @@ function assignMetadata(path, name, ast) {
|
|
|
88
100
|
if (__babel_types.isFunctionDeclaration(path.node) && path.node.id) {
|
|
89
101
|
const declaration = __babel_types.variableDeclaration("const", [__babel_types.variableDeclarator(path.node.id, callExpr)]);
|
|
90
102
|
__babel_types.inheritLeadingComments(declaration, path.node);
|
|
103
|
+
if (path.parentPath && (path.parentPath.isExportNamedDeclaration() || path.parentPath.isExportDefaultDeclaration())) {
|
|
104
|
+
__babel_types.inheritLeadingComments(declaration, path.parentPath.node);
|
|
105
|
+
path.parentPath.node.leadingComments = null;
|
|
106
|
+
}
|
|
91
107
|
replacement = declaration;
|
|
92
108
|
}
|
|
93
109
|
if (visibility) {
|
|
94
110
|
visibility.unshiftContainer("body", replacement);
|
|
95
|
-
|
|
96
|
-
path.
|
|
111
|
+
const id = __babel_types.isFunctionDeclaration(path.node) ? path.node.id : void 0;
|
|
112
|
+
if (id && path.parentPath.isExportNamedDeclaration()) path.parentPath.replaceWith(__babel_types.exportNamedDeclaration(null, [__babel_types.exportSpecifier(__babel_types.cloneNode(id), __babel_types.cloneNode(id))]));
|
|
113
|
+
else if (id && path.parentPath.isExportDefaultDeclaration()) path.parentPath.replaceWith(__babel_types.exportDefaultDeclaration(__babel_types.cloneNode(id)));
|
|
114
|
+
else path.remove();
|
|
97
115
|
} else path.replaceWith(replacement);
|
|
98
116
|
path.skip();
|
|
99
117
|
}
|
|
@@ -112,7 +130,7 @@ function TypeGPUPlugin() {
|
|
|
112
130
|
return {
|
|
113
131
|
name: "typegpu",
|
|
114
132
|
pre() {
|
|
115
|
-
this.opts = (0, defu.default)(this.opts, require_common.defaultOptions);
|
|
133
|
+
this.opts = require_common.checkOpts((0, defu.default)(this.opts, require_common.defaultOptions));
|
|
116
134
|
require_common.initPluginState(this, {
|
|
117
135
|
warn: (message) => console.warn(message),
|
|
118
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 };
|