wesl-link 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.
- package/bin/wesl-link +1 -68
- package/package.json +3 -3
package/bin/wesl-link
CHANGED
|
@@ -4,7 +4,7 @@ import path, { posix, win32 } from "node:path";
|
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
5
|
import { resolve } from "import-meta-resolve";
|
|
6
6
|
import { enableTracing, log } from "mini-parse";
|
|
7
|
-
import { RecordResolver, WeslParseError, astToString,
|
|
7
|
+
import { RecordResolver, WeslParseError, astToString, filterMap, findUnboundIdents, link, npmNameVariations, scopeToString } from "wesl";
|
|
8
8
|
import * as actualFS from "node:fs";
|
|
9
9
|
import fs, { lstat, readdir, readlink, realpath } from "node:fs/promises";
|
|
10
10
|
import { lstatSync, readdir as readdir$1, readdirSync, readlinkSync, realpathSync } from "fs";
|
|
@@ -38,41 +38,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
38
38
|
enumerable: true
|
|
39
39
|
}) : target, mod));
|
|
40
40
|
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region ../wesl-tooling/src/FindUnboundIdents.ts
|
|
43
|
-
/**
|
|
44
|
-
* Find unbound package references in library sources.
|
|
45
|
-
*
|
|
46
|
-
* Binds local references without following cross-package imports, revealing
|
|
47
|
-
* which external packages are referenced but not resolved.
|
|
48
|
-
*
|
|
49
|
-
* @param resolver - Module resolver that supports batch operations
|
|
50
|
-
* @returns Array of unbound module paths, each as an array of path segments
|
|
51
|
-
* (e.g., [['foo', 'bar', 'baz'], ['other', 'pkg']])
|
|
52
|
-
*/
|
|
53
|
-
function findUnboundIdents(resolver) {
|
|
54
|
-
const bindContext = {
|
|
55
|
-
resolver,
|
|
56
|
-
conditions: {},
|
|
57
|
-
knownDecls: /* @__PURE__ */ new Set(),
|
|
58
|
-
foundScopes: /* @__PURE__ */ new Set(),
|
|
59
|
-
globalNames: /* @__PURE__ */ new Set(),
|
|
60
|
-
globalStatements: /* @__PURE__ */ new Map(),
|
|
61
|
-
mangler: minimalMangle,
|
|
62
|
-
unbound: [],
|
|
63
|
-
dontFollowDecls: true
|
|
64
|
-
};
|
|
65
|
-
for (const [_modulePath, ast] of resolver.allModules()) {
|
|
66
|
-
const declEntries = findValidRootDecls(ast.rootScope, {}).map((d) => [d.originalName, d]);
|
|
67
|
-
const liveDecls = {
|
|
68
|
-
decls: new Map(declEntries),
|
|
69
|
-
parent: null
|
|
70
|
-
};
|
|
71
|
-
bindIdentsRecursive(ast.rootScope, bindContext, liveDecls, true);
|
|
72
|
-
}
|
|
73
|
-
return bindContext.unbound;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
41
|
//#endregion
|
|
77
42
|
//#region ../../node_modules/.pnpm/@isaacs+balanced-match@4.0.1/node_modules/@isaacs/balanced-match/dist/esm/index.js
|
|
78
43
|
const balanced = (a, b, str) => {
|
|
@@ -9754,38 +9719,6 @@ function zip(as, bs) {
|
|
|
9754
9719
|
return as.map((a, i) => [a, bs[i]]);
|
|
9755
9720
|
}
|
|
9756
9721
|
|
|
9757
|
-
//#endregion
|
|
9758
|
-
//#region ../wesl-tooling/src/PackageNameUtils.ts
|
|
9759
|
-
/** Generate npm package name variations from sanitized WESL identifier.
|
|
9760
|
-
*
|
|
9761
|
-
* Uses double-underscore encoding to distinguish scoped vs unscoped packages:
|
|
9762
|
-
* - Has __ → scoped package (try @scope/pkg variants)
|
|
9763
|
-
* - No __ → unscoped package (try pkg variants)
|
|
9764
|
-
*
|
|
9765
|
-
* Examples:
|
|
9766
|
-
* "lygia__shader_utils" → ["@lygia/shader_utils", "@lygia/shader-utils"]
|
|
9767
|
-
* "random_wgsl" → ["random_wgsl", "random-wgsl"]
|
|
9768
|
-
*/
|
|
9769
|
-
function* npmNameVariations(sanitizedPath) {
|
|
9770
|
-
const [pkg, sub] = breakAt(sanitizedPath, "/");
|
|
9771
|
-
let pkgName = pkg;
|
|
9772
|
-
let scopePrefix = "";
|
|
9773
|
-
if (pkg.includes("__")) {
|
|
9774
|
-
const [scope, ...rest] = pkg.split("__");
|
|
9775
|
-
pkgName = rest.join("__");
|
|
9776
|
-
scopePrefix = `@${scope}/`;
|
|
9777
|
-
}
|
|
9778
|
-
yield `${scopePrefix}${pkgName}${sub}`;
|
|
9779
|
-
yield `${scopePrefix}${pkgName.replaceAll("_", "-")}${sub}`;
|
|
9780
|
-
}
|
|
9781
|
-
/** Break string at first occurrence of delimiter.
|
|
9782
|
-
* @returns [before, after] where after includes the delimiter */
|
|
9783
|
-
function breakAt(str, delimiter) {
|
|
9784
|
-
const index = str.indexOf(delimiter);
|
|
9785
|
-
if (index === -1) return [str, ""];
|
|
9786
|
-
return [str.slice(0, index), str.slice(index)];
|
|
9787
|
-
}
|
|
9788
|
-
|
|
9789
9722
|
//#endregion
|
|
9790
9723
|
//#region ../wesl-tooling/src/NpmResolver.ts
|
|
9791
9724
|
/** Find longest resolvable npm subpath from WESL module path segments.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wesl-link",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.47",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": "bin/wesl-link",
|
|
6
6
|
"files": [
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"import-meta-resolve": "^4.1.0",
|
|
13
13
|
"yargs": "^18.0.0",
|
|
14
|
-
"mini-parse": "0.6.
|
|
15
|
-
"wesl": "0.6.
|
|
14
|
+
"mini-parse": "0.6.41",
|
|
15
|
+
"wesl": "0.6.47"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"wesl-tooling": "x"
|