wesl-packager 0.6.46 → 0.6.47

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 (2) hide show
  1. package/bin/wesl-packager +1 -120
  2. package/package.json +2 -2
package/bin/wesl-packager CHANGED
@@ -4,7 +4,7 @@ import process$1, { exit } from "node:process";
4
4
  import { hideBin } from "yargs/helpers";
5
5
  import * as actualFS from "node:fs";
6
6
  import fs, { realpathSync, statSync } from "node:fs";
7
- import { RecordResolver, WeslParseError, bindIdentsRecursive, filterMap, findValidRootDecls, minimalMangle, noSuffix } from "wesl";
7
+ import { RecordResolver, WeslParseError, filterMap, findUnboundIdents, noSuffix, npmNameVariations, sanitizePackageName } from "wesl";
8
8
  import fs$1, { lstat, mkdir, readdir, readlink, realpath } from "node:fs/promises";
9
9
  import path, { posix, win32 } from "node:path";
10
10
  import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
@@ -43,41 +43,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
43
43
  enumerable: true
44
44
  }) : target, mod));
45
45
 
46
- //#endregion
47
- //#region ../wesl-tooling/src/FindUnboundIdents.ts
48
- /**
49
- * Find unbound package references in library sources.
50
- *
51
- * Binds local references without following cross-package imports, revealing
52
- * which external packages are referenced but not resolved.
53
- *
54
- * @param resolver - Module resolver that supports batch operations
55
- * @returns Array of unbound module paths, each as an array of path segments
56
- * (e.g., [['foo', 'bar', 'baz'], ['other', 'pkg']])
57
- */
58
- function findUnboundIdents(resolver) {
59
- const bindContext = {
60
- resolver,
61
- conditions: {},
62
- knownDecls: /* @__PURE__ */ new Set(),
63
- foundScopes: /* @__PURE__ */ new Set(),
64
- globalNames: /* @__PURE__ */ new Set(),
65
- globalStatements: /* @__PURE__ */ new Map(),
66
- mangler: minimalMangle,
67
- unbound: [],
68
- dontFollowDecls: true
69
- };
70
- for (const [_modulePath, ast] of resolver.allModules()) {
71
- const declEntries = findValidRootDecls(ast.rootScope, {}).map((d) => [d.originalName, d]);
72
- const liveDecls = {
73
- decls: new Map(declEntries),
74
- parent: null
75
- };
76
- bindIdentsRecursive(ast.rootScope, bindContext, liveDecls, true);
77
- }
78
- return bindContext.unbound;
79
- }
80
-
81
46
  //#endregion
82
47
  //#region ../../node_modules/.pnpm/@isaacs+balanced-match@4.0.1/node_modules/@isaacs/balanced-match/dist/esm/index.js
83
48
  const balanced = (a, b, str) => {
@@ -9759,90 +9724,6 @@ function zip(as, bs) {
9759
9724
  return as.map((a, i) => [a, bs[i]]);
9760
9725
  }
9761
9726
 
9762
- //#endregion
9763
- //#region ../wesl-tooling/src/PackageNameUtils.ts
9764
- /** Package name sanitization for WESL.
9765
- *
9766
- * Converts typical npm package names to WGSL-safe identifiers using double-underscore encoding.
9767
- * NPM package names can contain `@`, `/`, and `-`, which are not allowed in WGSL identifiers.
9768
- *
9769
- * ## Encoding Scheme
9770
- *
9771
- * ```
9772
- * @ ==> (remove)
9773
- * / ==> __ (double underscore)
9774
- * - ==> _ (single underscore)
9775
- * ```
9776
- *
9777
- * ## Forward Mapping (npm ==> WGSL identifier)
9778
- *
9779
- * ```
9780
- * my_package ==> my_package
9781
- * random-wgsl ==> random_wgsl
9782
- * @scope/my-pkg ==> scope__my_pkg
9783
- * ```
9784
- *
9785
- * ## Reverse Mapping (WGSL identifier ==> npm package)
9786
- *
9787
- * ```
9788
- * scope__my_pkg ==> try: @scope/my_pkg, @scope/my-pkg
9789
- * random_wgsl ==> try: random_wgsl, random-wgsl
9790
- * ```
9791
- *
9792
- * ## package.json Subpath Exports
9793
- *
9794
- * Subpaths don't create ambiguity because WeslBundle `name` field only contains package name:
9795
- *
9796
- * Scoped package:
9797
- * ```
9798
- * npm: @foo/shader-utils
9799
- * weslBundle: { name: "foo__shader_utils", modules: {...} }
9800
- * WESL: import foo__shader_utils::color::rgb2hsv
9801
- * ```
9802
- *
9803
- * Unscoped package with subpath export:
9804
- * ```
9805
- * npm: "foo" (with exports: "./shader-utils": "./dist/...")
9806
- * weslBundle: { name: "foo", modules: {...} } // NOT foo__shader_utils!
9807
- * WESL: import foo::shader_utils::color::rgb2hsv // Different identifier!
9808
- * ```
9809
- *
9810
- * The `__` only appears when the package name itself contains `/`, never for subpaths.
9811
- */
9812
- /** Convert npm package name to WGSL-safe identifier using double-underscore encoding. */
9813
- function sanitizePackageName(npmName) {
9814
- return npmName.replace(/^@/, "").replaceAll("/", "__").replaceAll("-", "_");
9815
- }
9816
- /** Generate npm package name variations from sanitized WESL identifier.
9817
- *
9818
- * Uses double-underscore encoding to distinguish scoped vs unscoped packages:
9819
- * - Has __ → scoped package (try @scope/pkg variants)
9820
- * - No __ → unscoped package (try pkg variants)
9821
- *
9822
- * Examples:
9823
- * "lygia__shader_utils" → ["@lygia/shader_utils", "@lygia/shader-utils"]
9824
- * "random_wgsl" → ["random_wgsl", "random-wgsl"]
9825
- */
9826
- function* npmNameVariations(sanitizedPath) {
9827
- const [pkg, sub] = breakAt(sanitizedPath, "/");
9828
- let pkgName = pkg;
9829
- let scopePrefix = "";
9830
- if (pkg.includes("__")) {
9831
- const [scope, ...rest] = pkg.split("__");
9832
- pkgName = rest.join("__");
9833
- scopePrefix = `@${scope}/`;
9834
- }
9835
- yield `${scopePrefix}${pkgName}${sub}`;
9836
- yield `${scopePrefix}${pkgName.replaceAll("_", "-")}${sub}`;
9837
- }
9838
- /** Break string at first occurrence of delimiter.
9839
- * @returns [before, after] where after includes the delimiter */
9840
- function breakAt(str, delimiter) {
9841
- const index = str.indexOf(delimiter);
9842
- if (index === -1) return [str, ""];
9843
- return [str.slice(0, index), str.slice(index)];
9844
- }
9845
-
9846
9727
  //#endregion
9847
9728
  //#region ../../node_modules/.pnpm/import-meta-resolve@4.1.0/node_modules/import-meta-resolve/lib/errors.js
9848
9729
  const own$1 = {}.hasOwnProperty;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wesl-packager",
3
- "version": "0.6.46",
3
+ "version": "0.6.47",
4
4
  "type": "module",
5
5
  "bin": "bin/wesl-packager",
6
6
  "files": [
@@ -11,7 +11,7 @@
11
11
  "@biomejs/js-api": "^1.0.0",
12
12
  "@biomejs/wasm-nodejs": "^2.0.6",
13
13
  "yargs": "^18.0.0",
14
- "wesl": "0.6.46"
14
+ "wesl": "0.6.47"
15
15
  },
16
16
  "devDependencies": {
17
17
  "dependent_package": "x",