unplugin-typegpu 0.10.1 → 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.cjs CHANGED
@@ -1,20 +1,18 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
- const require_common = require('./common.cjs');
4
- const require_filter = require('./filter.cjs');
2
+ const require_filter = require('./filter-CKmD4HRk.cjs');
5
3
  let defu = require("defu");
6
- defu = require_runtime.__toESM(defu);
4
+ defu = require_filter.__toESM(defu);
7
5
  let tinyest_for_wgsl = require("tinyest-for-wgsl");
8
6
  let tinyest = require("tinyest");
9
7
  let _babel_standalone = require("@babel/standalone");
10
- _babel_standalone = require_runtime.__toESM(_babel_standalone);
8
+ _babel_standalone = require_filter.__toESM(_babel_standalone);
11
9
 
12
10
  //#region src/babel.ts
13
11
  const template = _babel_standalone.packages.template;
14
12
  const types = _babel_standalone.packages.types;
15
13
  function containsUseGpuDirective(node) {
16
14
  var _node$body$directives, _node$body;
17
- 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(require_common.useGpuDirective);
15
+ 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(require_filter.useGpuDirective);
18
16
  }
19
17
  function i(identifier) {
20
18
  return types.identifier(identifier);
@@ -23,11 +21,11 @@ const fnNodeToOriginalMap = /* @__PURE__ */ new WeakMap();
23
21
  function functionToTranspiled(node, parent) {
24
22
  var _fnNodeToOriginalMap$;
25
23
  const { params, body, externalNames } = (0, tinyest_for_wgsl.transpileFn)((_fnNodeToOriginalMap$ = fnNodeToOriginalMap.get(node)) !== null && _fnNodeToOriginalMap$ !== void 0 ? _fnNodeToOriginalMap$ : node);
26
- const maybeName = require_common.getFunctionName(node, parent);
24
+ const maybeName = require_filter.getFunctionName(node, parent);
27
25
  const metadata = types.objectExpression([
28
26
  types.objectProperty(i("v"), types.numericLiteral(tinyest.FORMAT_VERSION)),
29
27
  types.objectProperty(i("name"), maybeName ? types.stringLiteral(maybeName) : types.buildUndefinedNode()),
30
- types.objectProperty(i("ast"), template.expression`${require_common.embedJSON({
28
+ types.objectProperty(i("ast"), template.expression`${require_filter.embedJSON({
31
29
  params,
32
30
  body,
33
31
  externalNames
@@ -43,35 +41,35 @@ function functionVisitor(ctx) {
43
41
  let inUseGpuScope = false;
44
42
  return {
45
43
  VariableDeclarator(path) {
46
- require_common.performExpressionNaming(ctx, path.node, (node, name) => {
44
+ require_filter.performExpressionNaming(ctx, path.node, (node, name) => {
47
45
  path.get("init").replaceWith(wrapInAutoName(node, name));
48
46
  });
49
47
  },
50
48
  AssignmentExpression(path) {
51
49
  if (inUseGpuScope) {
52
- const runtimeFn = require_common.operators[path.node.operator];
50
+ const runtimeFn = require_filter.operators[path.node.operator];
53
51
  if (runtimeFn) path.replaceWith(types.assignmentExpression("=", path.node.left, types.callExpression(types.identifier(runtimeFn), [path.node.left, path.node.right])));
54
52
  }
55
- require_common.performExpressionNaming(ctx, path.node, (node, name) => {
53
+ require_filter.performExpressionNaming(ctx, path.node, (node, name) => {
56
54
  path.get("right").replaceWith(wrapInAutoName(node, name));
57
55
  });
58
56
  },
59
57
  ObjectProperty(path) {
60
- require_common.performExpressionNaming(ctx, path.node, (node, name) => {
58
+ require_filter.performExpressionNaming(ctx, path.node, (node, name) => {
61
59
  path.get("value").replaceWith(wrapInAutoName(node, name));
62
60
  });
63
61
  },
64
62
  ClassProperty(path) {
65
- require_common.performExpressionNaming(ctx, path.node, (node, name) => {
63
+ require_filter.performExpressionNaming(ctx, path.node, (node, name) => {
66
64
  path.get("value").replaceWith(wrapInAutoName(node, name));
67
65
  });
68
66
  },
69
67
  ImportDeclaration(path) {
70
- require_common.gatherTgpuAliases(path.node, ctx);
68
+ require_filter.gatherTgpuAliases(path.node, ctx);
71
69
  },
72
70
  BinaryExpression: { exit(path) {
73
71
  if (!inUseGpuScope) return;
74
- const runtimeFn = require_common.operators[path.node.operator];
72
+ const runtimeFn = require_filter.operators[path.node.operator];
75
73
  if (runtimeFn) path.replaceWith(types.callExpression(types.identifier(runtimeFn), [path.node.left, path.node.right]));
76
74
  } },
77
75
  ArrowFunctionExpression: {
@@ -133,7 +131,7 @@ function functionVisitor(ctx) {
133
131
  },
134
132
  CallExpression: { exit(path) {
135
133
  const node = path.node;
136
- if (require_common.isShellImplementationCall(node, ctx)) {
134
+ if (require_filter.isShellImplementationCall(node, ctx)) {
137
135
  const implementation = node.arguments[0];
138
136
  if (implementation && (implementation.type === "FunctionExpression" || implementation.type === "ArrowFunctionExpression")) {
139
137
  const transpiled = functionToTranspiled(implementation, null);
@@ -146,7 +144,7 @@ function functionVisitor(ctx) {
146
144
  }
147
145
  function babel_default() {
148
146
  return { visitor: { Program(path, state) {
149
- const options = (0, defu.default)(state.opts, require_common.defaultOptions);
147
+ const options = (0, defu.default)(state.opts, require_filter.defaultOptions);
150
148
  const id = state.filename;
151
149
  const filter = require_filter.createFilterForId(options);
152
150
  if (id && filter && !(filter === null || filter === void 0 ? void 0 : filter(id))) return;
package/babel.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { Node, Program } from "./node_modules/.pnpm/@babel_types@7.26.5/node_modules/@babel/types/lib/index-legacy.cjs";
1
+ import { n as Program, t as Node } from "./index-legacy-xKi5C2ga.cjs";
2
2
  import * as _babel_traverse0 from "@babel/traverse";
3
3
 
4
4
  //#region src/babel.d.ts
package/babel.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Node, Program } from "./node_modules/.pnpm/@babel_types@7.26.5/node_modules/@babel/types/lib/index-legacy.mjs";
1
+ import { n as Program, t as Node } from "./index-legacy-DRI9LQiG.mjs";
2
2
  import * as _babel_traverse0 from "@babel/traverse";
3
3
 
4
4
  //#region src/babel.d.ts
package/babel.mjs CHANGED
@@ -1,5 +1,4 @@
1
- import { defaultOptions, embedJSON, gatherTgpuAliases, getFunctionName, isShellImplementationCall, operators, performExpressionNaming, useGpuDirective } from "./common.mjs";
2
- import { createFilterForId } from "./filter.mjs";
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";
3
2
  import defu from "defu";
4
3
  import { transpileFn } from "tinyest-for-wgsl";
5
4
  import { FORMAT_VERSION } from "tinyest";
package/bun.cjs CHANGED
@@ -1,15 +1,14 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
- const require_common = require('./common.cjs');
2
+ const require_filter = require('./filter-CKmD4HRk.cjs');
4
3
  const require_babel = require('./babel.cjs');
5
4
  let defu = require("defu");
6
- defu = require_runtime.__toESM(defu);
5
+ defu = require_filter.__toESM(defu);
7
6
  let _babel_standalone = require("@babel/standalone");
8
- _babel_standalone = require_runtime.__toESM(_babel_standalone);
7
+ _babel_standalone = require_filter.__toESM(_babel_standalone);
9
8
 
10
9
  //#region src/bun.ts
11
10
  var bun_default = (rawOptions) => {
12
- const options = (0, defu.default)(rawOptions, require_common.defaultOptions);
11
+ const options = (0, defu.default)(rawOptions, require_filter.defaultOptions);
13
12
  const include = options.include;
14
13
  if (!(include instanceof RegExp)) throw new Error(`Unsupported 'include' options in Bun plugin. Please provide a single regular expression`);
15
14
  if (options.exclude) throw new Error(`Unsupported 'exclude' option in Bun plugin`);
@@ -18,7 +17,7 @@ var bun_default = (rawOptions) => {
18
17
  setup(build) {
19
18
  build.onLoad({ filter: include }, async (args) => {
20
19
  const text = await Bun.file(args.path).text();
21
- if (require_common.earlyPruneRegex.every((pattern) => !pattern.test(text))) return {
20
+ if (require_filter.earlyPruneRegex.every((pattern) => !pattern.test(text))) return {
22
21
  contents: text,
23
22
  loader: args.loader
24
23
  };
package/bun.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { Options } from "./common.cjs";
1
+ import { t as Options } from "./common-Dpl8jppn.cjs";
2
2
 
3
3
  //#region src/bun.d.ts
4
4
  declare const _default: (rawOptions: Options) => BunPlugin;
package/bun.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Options } from "./common.mjs";
1
+ import { t as Options } from "./common-CRPQ2KE6.mjs";
2
2
 
3
3
  //#region src/bun.d.ts
4
4
  declare const _default: (rawOptions: Options) => BunPlugin;
package/bun.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defaultOptions, earlyPruneRegex } from "./common.mjs";
1
+ import { n as defaultOptions, r as earlyPruneRegex } from "./filter-6T-5w4kG.mjs";
2
2
  import babel_default from "./babel.mjs";
3
3
  import defu from "defu";
4
4
  import * as Babel from "@babel/standalone";
@@ -22,4 +22,4 @@ interface Options {
22
22
  earlyPruning?: boolean | undefined;
23
23
  }
24
24
  //#endregion
25
- export { Options };
25
+ export { Options as t };
@@ -22,4 +22,4 @@ interface Options {
22
22
  earlyPruning?: boolean | undefined;
23
23
  }
24
24
  //#endregion
25
- export { Options };
25
+ export { Options as t };
@@ -1,3 +1,5 @@
1
+ import { resolve } from "pathe";
2
+ import picomatch from "picomatch";
1
3
 
2
4
  //#region src/common.ts
3
5
  const defaultOptions = {
@@ -172,12 +174,61 @@ const operators = {
172
174
  };
173
175
 
174
176
  //#endregion
175
- exports.defaultOptions = defaultOptions;
176
- exports.earlyPruneRegex = earlyPruneRegex;
177
- exports.embedJSON = embedJSON;
178
- exports.gatherTgpuAliases = gatherTgpuAliases;
179
- exports.getFunctionName = getFunctionName;
180
- exports.isShellImplementationCall = isShellImplementationCall;
181
- exports.operators = operators;
182
- exports.performExpressionNaming = performExpressionNaming;
183
- exports.useGpuDirective = useGpuDirective;
177
+ //#region src/filter.ts
178
+ function toArray(array) {
179
+ const result = array || [];
180
+ if (Array.isArray(result)) return result;
181
+ return [result];
182
+ }
183
+ const BACKSLASH_REGEX = /\\/g;
184
+ function normalize(path) {
185
+ return path.replace(BACKSLASH_REGEX, "/");
186
+ }
187
+ const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
188
+ function isAbsolute(path) {
189
+ return ABSOLUTE_PATH_REGEX.test(path);
190
+ }
191
+ function getMatcherString(glob, cwd) {
192
+ if (glob.startsWith("**") || isAbsolute(glob)) return normalize(glob);
193
+ return normalize(resolve(cwd, glob));
194
+ }
195
+ function patternToIdFilter(pattern) {
196
+ if (pattern instanceof RegExp) return (id) => {
197
+ const normalizedId = normalize(id);
198
+ const result = pattern.test(normalizedId);
199
+ pattern.lastIndex = 0;
200
+ return result;
201
+ };
202
+ const matcher = picomatch(getMatcherString(pattern, process.cwd()), { dot: true });
203
+ return (id) => {
204
+ return matcher(normalize(id));
205
+ };
206
+ }
207
+ function createFilter(exclude, include) {
208
+ if (!exclude && !include) return;
209
+ return (input) => {
210
+ if (exclude === null || exclude === void 0 ? void 0 : exclude.some((filter) => filter(input))) return false;
211
+ if (include === null || include === void 0 ? void 0 : include.some((filter) => filter(input))) return true;
212
+ return !(include && include.length > 0);
213
+ };
214
+ }
215
+ function normalizeFilter(filter) {
216
+ if (typeof filter === "string" || filter instanceof RegExp) return { include: [filter] };
217
+ if (Array.isArray(filter)) return { include: filter };
218
+ return {
219
+ exclude: filter.exclude ? toArray(filter.exclude) : void 0,
220
+ include: filter.include ? toArray(filter.include) : void 0
221
+ };
222
+ }
223
+ function createIdFilter(filter) {
224
+ if (!filter) return;
225
+ const { exclude, include } = normalizeFilter(filter);
226
+ return createFilter(exclude === null || exclude === void 0 ? void 0 : exclude.map(patternToIdFilter), include === null || include === void 0 ? void 0 : include.map(patternToIdFilter));
227
+ }
228
+ function createFilterForId(filter) {
229
+ const filterFunction = createIdFilter(filter);
230
+ return filterFunction ? (id) => !!filterFunction(id) : void 0;
231
+ }
232
+
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 };
@@ -1,3 +1,34 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+ let pathe = require("pathe");
29
+ let picomatch = require("picomatch");
30
+ picomatch = __toESM(picomatch);
31
+
1
32
  //#region src/common.ts
2
33
  const defaultOptions = {
3
34
  include: /\.m?[jt]sx?(?:\?.*)?$/,
@@ -171,4 +202,126 @@ const operators = {
171
202
  };
172
203
 
173
204
  //#endregion
174
- export { defaultOptions, earlyPruneRegex, embedJSON, gatherTgpuAliases, getFunctionName, isShellImplementationCall, operators, performExpressionNaming, useGpuDirective };
205
+ //#region src/filter.ts
206
+ function toArray(array) {
207
+ const result = array || [];
208
+ if (Array.isArray(result)) return result;
209
+ return [result];
210
+ }
211
+ const BACKSLASH_REGEX = /\\/g;
212
+ function normalize(path) {
213
+ return path.replace(BACKSLASH_REGEX, "/");
214
+ }
215
+ const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
216
+ function isAbsolute(path) {
217
+ return ABSOLUTE_PATH_REGEX.test(path);
218
+ }
219
+ function getMatcherString(glob, cwd) {
220
+ if (glob.startsWith("**") || isAbsolute(glob)) return normalize(glob);
221
+ return normalize((0, pathe.resolve)(cwd, glob));
222
+ }
223
+ function patternToIdFilter(pattern) {
224
+ if (pattern instanceof RegExp) return (id) => {
225
+ const normalizedId = normalize(id);
226
+ const result = pattern.test(normalizedId);
227
+ pattern.lastIndex = 0;
228
+ return result;
229
+ };
230
+ const matcher = (0, picomatch.default)(getMatcherString(pattern, process.cwd()), { dot: true });
231
+ return (id) => {
232
+ return matcher(normalize(id));
233
+ };
234
+ }
235
+ function createFilter(exclude, include) {
236
+ if (!exclude && !include) return;
237
+ return (input) => {
238
+ if (exclude === null || exclude === void 0 ? void 0 : exclude.some((filter) => filter(input))) return false;
239
+ if (include === null || include === void 0 ? void 0 : include.some((filter) => filter(input))) return true;
240
+ return !(include && include.length > 0);
241
+ };
242
+ }
243
+ function normalizeFilter(filter) {
244
+ if (typeof filter === "string" || filter instanceof RegExp) return { include: [filter] };
245
+ if (Array.isArray(filter)) return { include: filter };
246
+ return {
247
+ exclude: filter.exclude ? toArray(filter.exclude) : void 0,
248
+ include: filter.include ? toArray(filter.include) : void 0
249
+ };
250
+ }
251
+ function createIdFilter(filter) {
252
+ if (!filter) return;
253
+ const { exclude, include } = normalizeFilter(filter);
254
+ return createFilter(exclude === null || exclude === void 0 ? void 0 : exclude.map(patternToIdFilter), include === null || include === void 0 ? void 0 : include.map(patternToIdFilter));
255
+ }
256
+ function createFilterForId(filter) {
257
+ const filterFunction = createIdFilter(filter);
258
+ return filterFunction ? (id) => !!filterFunction(id) : void 0;
259
+ }
260
+
261
+ //#endregion
262
+ Object.defineProperty(exports, '__toESM', {
263
+ enumerable: true,
264
+ get: function () {
265
+ return __toESM;
266
+ }
267
+ });
268
+ Object.defineProperty(exports, 'createFilterForId', {
269
+ enumerable: true,
270
+ get: function () {
271
+ return createFilterForId;
272
+ }
273
+ });
274
+ Object.defineProperty(exports, 'defaultOptions', {
275
+ enumerable: true,
276
+ get: function () {
277
+ return defaultOptions;
278
+ }
279
+ });
280
+ Object.defineProperty(exports, 'earlyPruneRegex', {
281
+ enumerable: true,
282
+ get: function () {
283
+ return earlyPruneRegex;
284
+ }
285
+ });
286
+ Object.defineProperty(exports, 'embedJSON', {
287
+ enumerable: true,
288
+ get: function () {
289
+ return embedJSON;
290
+ }
291
+ });
292
+ Object.defineProperty(exports, 'gatherTgpuAliases', {
293
+ enumerable: true,
294
+ get: function () {
295
+ return gatherTgpuAliases;
296
+ }
297
+ });
298
+ Object.defineProperty(exports, 'getFunctionName', {
299
+ enumerable: true,
300
+ get: function () {
301
+ return getFunctionName;
302
+ }
303
+ });
304
+ Object.defineProperty(exports, 'isShellImplementationCall', {
305
+ enumerable: true,
306
+ get: function () {
307
+ return isShellImplementationCall;
308
+ }
309
+ });
310
+ Object.defineProperty(exports, 'operators', {
311
+ enumerable: true,
312
+ get: function () {
313
+ return operators;
314
+ }
315
+ });
316
+ Object.defineProperty(exports, 'performExpressionNaming', {
317
+ enumerable: true,
318
+ get: function () {
319
+ return performExpressionNaming;
320
+ }
321
+ });
322
+ Object.defineProperty(exports, 'useGpuDirective', {
323
+ enumerable: true,
324
+ get: function () {
325
+ return useGpuDirective;
326
+ }
327
+ });