unplugin-typegpu 0.11.3 → 0.11.5

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.
Files changed (68) hide show
  1. package/{babel-BtEAIwcz.d.ts → babel--cjzbyRs.d.ts} +1 -1
  2. package/{babel-CAEdZVus.js → babel-CMd2SDJ6.js} +2 -3
  3. package/{babel-Dh30Kt6S.cjs → babel-DQ_yyPsa.cjs} +2 -4
  4. package/{babel-mqeTZT8y.d.cts → babel-ZVrKmopN.d.cts} +1 -1
  5. package/babel.cjs +2 -2
  6. package/babel.d.cts +2 -2
  7. package/babel.d.ts +2 -2
  8. package/babel.js +2 -2
  9. package/{bun--yeG3v60.js → bun-CCcdC3SW.js} +2 -2
  10. package/{bun-BEJk_QgR.d.ts → bun-CF67VgNO.d.ts} +1 -1
  11. package/{bun-5HFBYRLX.cjs → bun-dlY1pjqd.cjs} +2 -2
  12. package/{bun-Df2nJEmj.d.cts → bun-iEmr0VLQ.d.cts} +1 -1
  13. package/bun.cjs +3 -3
  14. package/bun.d.cts +2 -2
  15. package/bun.d.ts +2 -2
  16. package/bun.js +3 -3
  17. package/{common-DLS92R6o.d.ts → common-BZrmpQ_X.d.ts} +2 -1
  18. package/{common-DAlNUXzt.js → common-CK7zOjbK.js} +7 -2
  19. package/{common-BaikgpzR.d.cts → common-CmJ77T6N.d.cts} +1 -0
  20. package/{common-DsNLIpl2.cjs → common-ddv56_tk.cjs} +13 -2
  21. package/esbuild.cjs +6 -6
  22. package/esbuild.d.cts +5 -5
  23. package/esbuild.d.ts +5 -5
  24. package/esbuild.js +6 -6
  25. package/{factory-DpKZsJoL.cjs → factory-B8-_pu6k.cjs} +109 -23
  26. package/factory-DjhDJrOh.js +194 -0
  27. package/farm.cjs +6 -6
  28. package/farm.d.cts +5 -5
  29. package/farm.d.ts +5 -5
  30. package/farm.js +6 -6
  31. package/{index-Dq70sYN7.d.cts → index-B6hcp9YT.d.cts} +1 -1
  32. package/{index-pvEoqPl0.d.ts → index-BC8jb6u9.d.ts} +1 -1
  33. package/index.cjs +6 -6
  34. package/index.d.cts +5 -5
  35. package/index.d.ts +5 -5
  36. package/index.js +6 -6
  37. package/package.json +3 -3
  38. package/{rolldown-browser-BeO_gjfe.d.cts → rolldown-browser-BKqmcxE8.d.ts} +6 -3
  39. package/{rolldown-browser-D2u-yWpA.js → rolldown-browser-DE5WZuwp.js} +1 -1
  40. package/{rolldown-browser-2X8xghF4.cjs → rolldown-browser-RuB75ubR.cjs} +1 -1
  41. package/{rolldown-browser-CLu5Nu_x.d.ts → rolldown-browser-_T3AdKqA.d.cts} +6 -3
  42. package/rolldown-browser.cjs +3 -3
  43. package/rolldown-browser.d.cts +2 -2
  44. package/rolldown-browser.d.ts +2 -2
  45. package/rolldown-browser.js +3 -3
  46. package/rolldown.cjs +6 -6
  47. package/rolldown.d.cts +5 -5
  48. package/rolldown.d.ts +5 -5
  49. package/rolldown.js +6 -6
  50. package/rollup.cjs +6 -6
  51. package/rollup.d.cts +5 -5
  52. package/rollup.d.ts +5 -5
  53. package/rollup.js +6 -6
  54. package/rspack.cjs +6 -6
  55. package/rspack.d.cts +5 -5
  56. package/rspack.d.ts +5 -5
  57. package/rspack.js +6 -6
  58. package/{src-CrU_oTgc.js → src-CawM5q6P.js} +1 -1
  59. package/{src-Ctdak0KH.cjs → src-D3HrJuJR.cjs} +2 -2
  60. package/vite.cjs +6 -6
  61. package/vite.d.cts +5 -5
  62. package/vite.d.ts +5 -5
  63. package/vite.js +6 -6
  64. package/webpack.cjs +6 -6
  65. package/webpack.d.cts +5 -5
  66. package/webpack.d.ts +5 -5
  67. package/webpack.js +6 -6
  68. package/factory-BhxFJhLe.js +0 -107
@@ -1,4 +1,4 @@
1
- import { n as PluginState } from "./common-DLS92R6o.js";
1
+ import { n as PluginState } from "./common-BZrmpQ_X.js";
2
2
  import * as t from "@babel/types";
3
3
  import { NodePath } from "@babel/traverse";
4
4
 
@@ -1,7 +1,6 @@
1
- import { a as initPluginState, i as getBlockScope, r as functionVisitor, t as defaultOptions } from "./common-DAlNUXzt.js";
1
+ import { a as getBlockScope, i as functionVisitor, n as defaultOptions, o as initPluginState, t as METADATA_FORMAT_VERSION } from "./common-CK7zOjbK.js";
2
2
  import defu from "defu";
3
3
  import { transpileFn } from "tinyest-for-wgsl";
4
- import { FORMAT_VERSION } from "tinyest";
5
4
  import * as t from "@babel/types";
6
5
  import { resolve } from "pathe";
7
6
  import picomatch from "picomatch";
@@ -69,7 +68,7 @@ function i(identifier) {
69
68
  }
70
69
  function assignMetadata(path, name, ast) {
71
70
  const metadata = t.objectExpression([
72
- t.objectProperty(i("v"), t.numericLiteral(FORMAT_VERSION)),
71
+ t.objectProperty(i("v"), t.numericLiteral(METADATA_FORMAT_VERSION)),
73
72
  t.objectProperty(i("name"), t.valueToNode(name)),
74
73
  t.objectProperty(i("ast"), t.valueToNode(ast)),
75
74
  t.objectProperty(i("externals"), t.arrowFunctionExpression([], t.blockStatement([t.returnStatement(t.objectExpression(ast.externalNames.map((name$1) => name$1 === "this" ? t.objectProperty(i("this"), t.thisExpression()) : t.objectProperty(i(name$1), i(name$1), false, name$1 !== "this"))))])))
@@ -1,10 +1,8 @@
1
- const require_common = require('./common-DsNLIpl2.cjs');
1
+ const require_common = require('./common-ddv56_tk.cjs');
2
2
  let defu = require("defu");
3
3
  defu = require_common.__toESM(defu);
4
4
  let tinyest_for_wgsl = require("tinyest-for-wgsl");
5
5
  tinyest_for_wgsl = require_common.__toESM(tinyest_for_wgsl);
6
- let tinyest = require("tinyest");
7
- tinyest = require_common.__toESM(tinyest);
8
6
  let __babel_types = require("@babel/types");
9
7
  __babel_types = require_common.__toESM(__babel_types);
10
8
  let pathe = require("pathe");
@@ -75,7 +73,7 @@ function i(identifier) {
75
73
  }
76
74
  function assignMetadata(path, name, ast) {
77
75
  const metadata = __babel_types.objectExpression([
78
- __babel_types.objectProperty(i("v"), __babel_types.numericLiteral(tinyest.FORMAT_VERSION)),
76
+ __babel_types.objectProperty(i("v"), __babel_types.numericLiteral(require_common.METADATA_FORMAT_VERSION)),
79
77
  __babel_types.objectProperty(i("name"), __babel_types.valueToNode(name)),
80
78
  __babel_types.objectProperty(i("ast"), __babel_types.valueToNode(ast)),
81
79
  __babel_types.objectProperty(i("externals"), __babel_types.arrowFunctionExpression([], __babel_types.blockStatement([__babel_types.returnStatement(__babel_types.objectExpression(ast.externalNames.map((name$1) => name$1 === "this" ? __babel_types.objectProperty(i("this"), __babel_types.thisExpression()) : __babel_types.objectProperty(i(name$1), i(name$1), false, name$1 !== "this"))))])))
@@ -1,4 +1,4 @@
1
- import { n as PluginState } from "./common-BaikgpzR.cjs";
1
+ import { n as PluginState } from "./common-CmJ77T6N.cjs";
2
2
  import { NodePath } from "@babel/traverse";
3
3
  import * as t from "@babel/types";
4
4
 
package/babel.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- require('./common-DsNLIpl2.cjs');
3
- const require_babel = require('./babel-Dh30Kt6S.cjs');
2
+ require('./common-ddv56_tk.cjs');
3
+ const require_babel = require('./babel-DQ_yyPsa.cjs');
4
4
 
5
5
  exports.default = require_babel.TypeGPUPlugin;
package/babel.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- import "./common-BaikgpzR.cjs";
2
- import { t as TypeGPUPlugin } from "./babel-mqeTZT8y.cjs";
1
+ import "./common-CmJ77T6N.cjs";
2
+ import { t as TypeGPUPlugin } from "./babel-ZVrKmopN.cjs";
3
3
  export = TypeGPUPlugin;
package/babel.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import "./common-DLS92R6o.js";
2
- import { t as TypeGPUPlugin } from "./babel-BtEAIwcz.js";
1
+ import "./common-BZrmpQ_X.js";
2
+ import { t as TypeGPUPlugin } from "./babel--cjzbyRs.js";
3
3
  export { TypeGPUPlugin as default };
package/babel.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./common-DAlNUXzt.js";
2
- import { t as TypeGPUPlugin } from "./babel-CAEdZVus.js";
1
+ import "./common-CK7zOjbK.js";
2
+ import { t as TypeGPUPlugin } from "./babel-CMd2SDJ6.js";
3
3
 
4
4
  export { TypeGPUPlugin as default };
@@ -1,5 +1,5 @@
1
- import { n as earlyPruneRegex, t as defaultOptions } from "./common-DAlNUXzt.js";
2
- import { t as unpluginFactory } from "./factory-BhxFJhLe.js";
1
+ import { n as defaultOptions, r as earlyPruneRegex } from "./common-CK7zOjbK.js";
2
+ import { t as unpluginFactory } from "./factory-DjhDJrOh.js";
3
3
  import defu from "defu";
4
4
 
5
5
  //#region src/bun.ts
@@ -1,4 +1,4 @@
1
- import { t as Options } from "./common-DLS92R6o.js";
1
+ import { t as Options } from "./common-BZrmpQ_X.js";
2
2
 
3
3
  //#region src/bun.d.ts
4
4
  declare const _default: (rawOptions?: Options) => Bun.BunPlugin;
@@ -1,5 +1,5 @@
1
- const require_common = require('./common-DsNLIpl2.cjs');
2
- const require_factory = require('./factory-DpKZsJoL.cjs');
1
+ const require_common = require('./common-ddv56_tk.cjs');
2
+ const require_factory = require('./factory-B8-_pu6k.cjs');
3
3
  let defu = require("defu");
4
4
  defu = require_common.__toESM(defu);
5
5
 
@@ -1,4 +1,4 @@
1
- import { t as Options } from "./common-BaikgpzR.cjs";
1
+ import { t as Options } from "./common-CmJ77T6N.cjs";
2
2
 
3
3
  //#region src/bun.d.ts
4
4
  declare const _default: (rawOptions?: Options) => Bun.BunPlugin;
package/bun.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- require('./common-DsNLIpl2.cjs');
3
- require('./factory-DpKZsJoL.cjs');
4
- const require_bun = require('./bun-5HFBYRLX.cjs');
2
+ require('./common-ddv56_tk.cjs');
3
+ require('./factory-B8-_pu6k.cjs');
4
+ const require_bun = require('./bun-dlY1pjqd.cjs');
5
5
 
6
6
  exports.default = require_bun.bun_default;
package/bun.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- import "./common-BaikgpzR.cjs";
2
- import { t as _default } from "./bun-Df2nJEmj.cjs";
1
+ import "./common-CmJ77T6N.cjs";
2
+ import { t as _default } from "./bun-iEmr0VLQ.cjs";
3
3
  export = _default;
package/bun.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import "./common-DLS92R6o.js";
2
- import { t as _default } from "./bun-BEJk_QgR.js";
1
+ import "./common-BZrmpQ_X.js";
2
+ import { t as _default } from "./bun-CF67VgNO.js";
3
3
  export { _default as default };
package/bun.js CHANGED
@@ -1,5 +1,5 @@
1
- import "./common-DAlNUXzt.js";
2
- import "./factory-BhxFJhLe.js";
3
- import { t as bun_default } from "./bun--yeG3v60.js";
1
+ import "./common-CK7zOjbK.js";
2
+ import "./factory-DjhDJrOh.js";
3
+ import { t as bun_default } from "./bun-CCcdC3SW.js";
4
4
 
5
5
  export { bun_default as default };
@@ -1,10 +1,11 @@
1
1
  import { transpileFn } from "tinyest-for-wgsl";
2
2
  import * as t from "@babel/types";
3
- import { MagicStringAST } from "magic-string-ast";
3
+ import MagicString from "magic-string";
4
4
  import { NodePath } from "@babel/traverse";
5
5
  import { FilterPattern } from "unplugin";
6
6
 
7
7
  //#region src/core/common.d.ts
8
+
8
9
  interface Options {
9
10
  /** @default [/\.m?[jt]sx?$/] */
10
11
  include?: FilterPattern;
@@ -1,8 +1,13 @@
1
1
  import { transpileFn } from "tinyest-for-wgsl";
2
2
  import * as t from "@babel/types";
3
- import { MagicStringAST } from "magic-string-ast";
3
+ import MagicString from "magic-string";
4
4
 
5
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;
6
11
  function initPluginState(state, methods) {
7
12
  var _state$opts$autoNamin;
8
13
  state.tgpuAliases = new Set(state.opts.forceTgpuAlias ? [state.opts.forceTgpuAlias] : []);
@@ -271,4 +276,4 @@ const functionVisitor = {
271
276
  };
272
277
 
273
278
  //#endregion
274
- export { initPluginState as a, getBlockScope as i, earlyPruneRegex as n, functionVisitor as r, defaultOptions as t };
279
+ export { getBlockScope as a, functionVisitor as i, defaultOptions as n, initPluginState as o, earlyPruneRegex as r, METADATA_FORMAT_VERSION as t };
@@ -4,6 +4,7 @@ import { FilterPattern } from "unplugin";
4
4
  import { transpileFn } from "tinyest-for-wgsl";
5
5
 
6
6
  //#region src/core/common.d.ts
7
+
7
8
  interface Options {
8
9
  /** @default [/\.m?[jt]sx?$/] */
9
10
  include?: FilterPattern;
@@ -25,10 +25,15 @@ let tinyest_for_wgsl = require("tinyest-for-wgsl");
25
25
  tinyest_for_wgsl = __toESM(tinyest_for_wgsl);
26
26
  let __babel_types = require("@babel/types");
27
27
  __babel_types = __toESM(__babel_types);
28
- let magic_string_ast = require("magic-string-ast");
29
- magic_string_ast = __toESM(magic_string_ast);
28
+ let magic_string = require("magic-string");
29
+ magic_string = __toESM(magic_string);
30
30
 
31
31
  //#region src/core/common.ts
32
+ /**
33
+ * Each breaking change to the metadata format requires a bump to this number.
34
+ * It's used at runtime by `typegpu` to determine how to interpret a function's metadata.
35
+ */
36
+ const METADATA_FORMAT_VERSION = 1;
32
37
  function initPluginState(state, methods) {
33
38
  var _state$opts$autoNamin;
34
39
  state.tgpuAliases = new Set(state.opts.forceTgpuAlias ? [state.opts.forceTgpuAlias] : []);
@@ -297,6 +302,12 @@ const functionVisitor = {
297
302
  };
298
303
 
299
304
  //#endregion
305
+ Object.defineProperty(exports, 'METADATA_FORMAT_VERSION', {
306
+ enumerable: true,
307
+ get: function () {
308
+ return METADATA_FORMAT_VERSION;
309
+ }
310
+ });
300
311
  Object.defineProperty(exports, '__toESM', {
301
312
  enumerable: true,
302
313
  get: function () {
package/esbuild.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- require('./common-DsNLIpl2.cjs');
3
- require('./babel-Dh30Kt6S.cjs');
4
- require('./factory-DpKZsJoL.cjs');
5
- require('./bun-5HFBYRLX.cjs');
6
- require('./rolldown-browser-2X8xghF4.cjs');
7
- const require_src = require('./src-Ctdak0KH.cjs');
2
+ require('./common-ddv56_tk.cjs');
3
+ require('./babel-DQ_yyPsa.cjs');
4
+ require('./factory-B8-_pu6k.cjs');
5
+ require('./bun-dlY1pjqd.cjs');
6
+ require('./rolldown-browser-RuB75ubR.cjs');
7
+ const require_src = require('./src-D3HrJuJR.cjs');
8
8
 
9
9
  //#region src/esbuild.ts
10
10
  var esbuild_default = require_src.esbuildPlugin;
package/esbuild.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import "./common-BaikgpzR.cjs";
2
- import "./babel-mqeTZT8y.cjs";
3
- import "./bun-Df2nJEmj.cjs";
4
- import "./rolldown-browser-BeO_gjfe.cjs";
5
- import { t as esbuildPlugin } from "./index-Dq70sYN7.cjs";
1
+ import "./common-CmJ77T6N.cjs";
2
+ import "./babel-ZVrKmopN.cjs";
3
+ import "./bun-iEmr0VLQ.cjs";
4
+ import "./rolldown-browser-_T3AdKqA.cjs";
5
+ import { t as esbuildPlugin } from "./index-B6hcp9YT.cjs";
6
6
  export = esbuildPlugin;
package/esbuild.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import "./common-DLS92R6o.js";
2
- import "./babel-BtEAIwcz.js";
3
- import "./bun-BEJk_QgR.js";
4
- import "./rolldown-browser-CLu5Nu_x.js";
5
- import { t as esbuildPlugin } from "./index-pvEoqPl0.js";
1
+ import "./common-BZrmpQ_X.js";
2
+ import "./babel--cjzbyRs.js";
3
+ import "./bun-CF67VgNO.js";
4
+ import "./rolldown-browser-BKqmcxE8.js";
5
+ import { t as esbuildPlugin } from "./index-BC8jb6u9.js";
6
6
  export { esbuildPlugin as default };
package/esbuild.js CHANGED
@@ -1,9 +1,9 @@
1
- import "./common-DAlNUXzt.js";
2
- import "./babel-CAEdZVus.js";
3
- import "./factory-BhxFJhLe.js";
4
- import "./bun--yeG3v60.js";
5
- import "./rolldown-browser-D2u-yWpA.js";
6
- import { t as esbuildPlugin } from "./src-CrU_oTgc.js";
1
+ import "./common-CK7zOjbK.js";
2
+ import "./babel-CMd2SDJ6.js";
3
+ import "./factory-DjhDJrOh.js";
4
+ import "./bun-CCcdC3SW.js";
5
+ import "./rolldown-browser-DE5WZuwp.js";
6
+ import { t as esbuildPlugin } from "./src-CawM5q6P.js";
7
7
 
8
8
  //#region src/esbuild.ts
9
9
  var esbuild_default = esbuildPlugin;
@@ -1,14 +1,12 @@
1
- const require_common = require('./common-DsNLIpl2.cjs');
1
+ const require_common = require('./common-ddv56_tk.cjs');
2
2
  let defu = require("defu");
3
3
  defu = require_common.__toESM(defu);
4
4
  let tinyest_for_wgsl = require("tinyest-for-wgsl");
5
5
  tinyest_for_wgsl = require_common.__toESM(tinyest_for_wgsl);
6
- let tinyest = require("tinyest");
7
- tinyest = require_common.__toESM(tinyest);
8
6
  let __babel_types = require("@babel/types");
9
7
  __babel_types = require_common.__toESM(__babel_types);
10
- let magic_string_ast = require("magic-string-ast");
11
- magic_string_ast = require_common.__toESM(magic_string_ast);
8
+ let magic_string = require("magic-string");
9
+ magic_string = require_common.__toESM(magic_string);
12
10
  let ast_kit = require("ast-kit");
13
11
  ast_kit = require_common.__toESM(ast_kit);
14
12
  let __babel_traverse = require("@babel/traverse");
@@ -16,6 +14,72 @@ __babel_traverse = require_common.__toESM(__babel_traverse);
16
14
  let __babel_parser = require("@babel/parser");
17
15
  __babel_parser = require_common.__toESM(__babel_parser);
18
16
 
17
+ //#region \0@oxc-project+runtime@0.95.0/helpers/typeof.js
18
+ function _typeof(o) {
19
+ "@babel/helpers - typeof";
20
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
21
+ return typeof o$1;
22
+ } : function(o$1) {
23
+ return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
24
+ }, _typeof(o);
25
+ }
26
+
27
+ //#endregion
28
+ //#region \0@oxc-project+runtime@0.95.0/helpers/toPrimitive.js
29
+ function toPrimitive(t, r) {
30
+ if ("object" != _typeof(t) || !t) return t;
31
+ var e = t[Symbol.toPrimitive];
32
+ if (void 0 !== e) {
33
+ var i = e.call(t, r || "default");
34
+ if ("object" != _typeof(i)) return i;
35
+ throw new TypeError("@@toPrimitive must return a primitive value.");
36
+ }
37
+ return ("string" === r ? String : Number)(t);
38
+ }
39
+
40
+ //#endregion
41
+ //#region \0@oxc-project+runtime@0.95.0/helpers/toPropertyKey.js
42
+ function toPropertyKey(t) {
43
+ var i = toPrimitive(t, "string");
44
+ return "symbol" == _typeof(i) ? i : i + "";
45
+ }
46
+
47
+ //#endregion
48
+ //#region \0@oxc-project+runtime@0.95.0/helpers/defineProperty.js
49
+ function _defineProperty(e, r, t) {
50
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
51
+ value: t,
52
+ enumerable: !0,
53
+ configurable: !0,
54
+ writable: !0
55
+ }) : e[r] = t, e;
56
+ }
57
+
58
+ //#endregion
59
+ //#region \0@oxc-project+runtime@0.95.0/helpers/objectSpread2.js
60
+ function ownKeys(e, r) {
61
+ var t = Object.keys(e);
62
+ if (Object.getOwnPropertySymbols) {
63
+ var o = Object.getOwnPropertySymbols(e);
64
+ r && (o = o.filter(function(r$1) {
65
+ return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
66
+ })), t.push.apply(t, o);
67
+ }
68
+ return t;
69
+ }
70
+ function _objectSpread2(e) {
71
+ for (var r = 1; r < arguments.length; r++) {
72
+ var t = null != arguments[r] ? arguments[r] : {};
73
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
74
+ _defineProperty(e, r$1, t[r$1]);
75
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
76
+ Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
77
+ });
78
+ }
79
+ return e;
80
+ }
81
+
82
+ //#endregion
19
83
  //#region src/core/factory.ts
20
84
  let traverse = __babel_traverse.default;
21
85
  if (typeof traverse.default === "function") traverse = traverse.default;
@@ -26,13 +90,13 @@ function embedJSON(jsValue) {
26
90
  function assignMetadata(path, name, ast) {
27
91
  var _path$node$start, _path$node$start2;
28
92
  const metadata = `{
29
- v: ${tinyest.FORMAT_VERSION},
93
+ v: ${require_common.METADATA_FORMAT_VERSION},
30
94
  name: ${name ? `"${name}"` : "undefined"},
31
95
  ast: ${embedJSON(ast)},
32
96
  externals: () => ({${ast.externalNames.map((e) => e === "this" ? "\"this\": this" : e).join(", ")}}),
33
97
  }`;
34
98
  const visibility = __babel_types.isFunctionDeclaration(path.node) ? require_common.getBlockScope(path) : void 0;
35
- const fnCode = this.magicString.sliceNode(path.node);
99
+ const fnCode = this.slice(path.node);
36
100
  let nodeToOverride = path.node;
37
101
  let code = fnWrapperTemplate(fnCode, metadata);
38
102
  let insertPos = (_path$node$start = path.node.start) !== null && _path$node$start !== void 0 ? _path$node$start : 0;
@@ -47,29 +111,42 @@ function assignMetadata(path, name, ast) {
47
111
  }
48
112
  if (insertPos < ((_path$node$start2 = path.node.start) !== null && _path$node$start2 !== void 0 ? _path$node$start2 : 0)) {
49
113
  var _nodeToOverride$leadi, _nodeToOverride$leadi2;
50
- for (const comment of (_nodeToOverride$leadi = (_nodeToOverride$leadi2 = nodeToOverride.leadingComments) === null || _nodeToOverride$leadi2 === void 0 ? void 0 : _nodeToOverride$leadi2.toReversed()) !== null && _nodeToOverride$leadi !== void 0 ? _nodeToOverride$leadi : []) {
51
- var _comment$start, _comment$end;
52
- code = `${this.magicString.slice((_comment$start = comment.start) !== null && _comment$start !== void 0 ? _comment$start : 0, (_comment$end = comment.end) !== null && _comment$end !== void 0 ? _comment$end : 0)}\n${code}`;
53
- this.magicString.removeNode(comment);
114
+ for (const comment of (_nodeToOverride$leadi = (_nodeToOverride$leadi2 = nodeToOverride.leadingComments) === null || _nodeToOverride$leadi2 === void 0 ? void 0 : _nodeToOverride$leadi2.toReversed()) !== null && _nodeToOverride$leadi !== void 0 ? _nodeToOverride$leadi : []) if (comment) {
115
+ code = `${this.slice(comment)}\n${code}`;
116
+ this.remove(comment);
54
117
  }
55
- this.magicString.removeNode(nodeToOverride);
118
+ this.remove(nodeToOverride);
56
119
  this.magicString.prependLeft(insertPos, code);
57
- } else this.magicString.overwriteNode(nodeToOverride, code);
120
+ } else this.overwrite(nodeToOverride, code);
58
121
  }
59
122
  function wrapInAutoName(path, name) {
60
123
  var _path$node$start3, _path$node$end;
61
124
  this.magicString.appendLeft((_path$node$start3 = path.node.start) !== null && _path$node$start3 !== void 0 ? _path$node$start3 : 0, "(/*#__PURE__*/(globalThis.__TYPEGPU_AUTONAME__ ?? (a => a))(").prependRight((_path$node$end = path.node.end) !== null && _path$node$end !== void 0 ? _path$node$end : 0, `, "${name}"))`);
62
125
  }
63
126
  function replaceWithAssignmentOverload(path, runtimeFn) {
64
- const lhs = this.magicString.sliceNode(path.node.left);
65
- const rhs = this.magicString.sliceNode(path.node.right);
66
- this.magicString.overwriteNode(path.node, `${lhs} = ${runtimeFn}(${lhs}, ${rhs})`);
127
+ const lhs = this.slice(path.node.left);
128
+ const rhs = this.slice(path.node.right);
129
+ this.overwrite(path.node, `${lhs} = ${runtimeFn}(${lhs}, ${rhs})`);
67
130
  }
68
131
  function replaceWithBinaryOverload(path, runtimeFn) {
69
- const lhs = this.magicString.sliceNode(path.node.left);
70
- const rhs = this.magicString.sliceNode(path.node.right);
71
- this.magicString.overwriteNode(path.node, `${runtimeFn}(${lhs}, ${rhs})`);
132
+ const lhs = this.slice(path.node.left);
133
+ const rhs = this.slice(path.node.right);
134
+ this.overwrite(path.node, `${runtimeFn}(${lhs}, ${rhs})`);
72
135
  }
136
+ const NodeUtils = {
137
+ slice(node) {
138
+ var _node$start, _node$end;
139
+ return this.magicString.slice((_node$start = node.start) !== null && _node$start !== void 0 ? _node$start : 0, (_node$end = node.end) !== null && _node$end !== void 0 ? _node$end : 0);
140
+ },
141
+ remove(node) {
142
+ var _node$start2, _node$end2;
143
+ this.magicString.remove((_node$start2 = node.start) !== null && _node$start2 !== void 0 ? _node$start2 : 0, (_node$end2 = node.end) !== null && _node$end2 !== void 0 ? _node$end2 : 0);
144
+ },
145
+ overwrite(node, content) {
146
+ var _node$start3, _node$end3;
147
+ this.magicString.overwrite((_node$start3 = node.start) !== null && _node$start3 !== void 0 ? _node$start3 : 0, (_node$end3 = node.end) !== null && _node$end3 !== void 0 ? _node$end3 : 0, content);
148
+ }
149
+ };
73
150
  const unpluginFactory = ((rawOptions, _meta) => {
74
151
  const options = (0, defu.default)(rawOptions, require_common.defaultOptions);
75
152
  return {
@@ -91,12 +168,12 @@ const unpluginFactory = ((rawOptions, _meta) => {
91
168
  console.warn(`[unplugin-typegpu] Failed to parse ${id}. Cause: ${typeof cause === "object" && cause && "message" in cause ? cause.message : cause}`);
92
169
  return;
93
170
  }
94
- const magicString = new magic_string_ast.MagicStringAST(code);
95
- const state = {
171
+ const magicString = new magic_string.default(code);
172
+ const state = _objectSpread2({
96
173
  filename: id,
97
174
  magicString,
98
175
  opts: options
99
- };
176
+ }, NodeUtils);
100
177
  require_common.initPluginState(state, {
101
178
  warn: (message) => this.warn(message),
102
179
  assignMetadata,
@@ -105,7 +182,16 @@ const unpluginFactory = ((rawOptions, _meta) => {
105
182
  replaceWithBinaryOverload
106
183
  });
107
184
  traverse(ast, require_common.functionVisitor, void 0, state);
108
- return (0, magic_string_ast.generateTransform)(magicString, id);
185
+ if (magicString.hasChanged()) return {
186
+ code: magicString.toString(),
187
+ get map() {
188
+ return magicString.generateMap({
189
+ source: id,
190
+ includeContent: true,
191
+ hires: "boundary"
192
+ });
193
+ }
194
+ };
109
195
  }
110
196
  }
111
197
  };