wesl 0.6.6 → 0.6.9
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/dist/index.js +36 -9
- package/dist/index.js.map +1 -1
- package/dist/minified.js +1124 -1091
- package/dist/minified.js.map +1 -1
- package/dist/tools/packages/wesl/src/Linker.d.ts +2 -0
- package/package.json +4 -8
- package/src/Assertions.ts +1 -1
- package/src/BindIdents.ts +1 -1
- package/src/Linker.ts +10 -0
- package/src/WESLCollect.ts +4 -3
- package/src/debug/ASTtoString.ts +0 -2
- package/src/debug/ScopeToString.ts +2 -2
- package/src/test/TransformBindingStructs.test.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
1
2
|
var __typeError = (msg) => {
|
|
2
3
|
throw TypeError(msg);
|
|
3
4
|
};
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
7
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
8
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
@@ -17,6 +20,7 @@ function assertUnreachable$1(value) {
|
|
|
17
20
|
let ErrorWithData$1 = class ErrorWithData extends Error {
|
|
18
21
|
constructor(message, options) {
|
|
19
22
|
super(message, options);
|
|
23
|
+
__publicField(this, "data");
|
|
20
24
|
this.data = options == null ? void 0 : options.data;
|
|
21
25
|
}
|
|
22
26
|
};
|
|
@@ -619,11 +623,15 @@ function skipIgnored(stream) {
|
|
|
619
623
|
class ParseError extends Error {
|
|
620
624
|
constructor(msg, span2) {
|
|
621
625
|
super(msg);
|
|
626
|
+
__publicField(this, "span");
|
|
622
627
|
this.span = span2;
|
|
623
628
|
}
|
|
624
629
|
}
|
|
625
630
|
class Parser {
|
|
626
631
|
constructor(args) {
|
|
632
|
+
/** If tracing is enabled, this exists. Otherwise it does not exist. */
|
|
633
|
+
__publicField(this, "_traceInfo");
|
|
634
|
+
__publicField(this, "fn");
|
|
627
635
|
this.fn = args.fn;
|
|
628
636
|
}
|
|
629
637
|
/** run the parser given an already created parsing context
|
|
@@ -729,6 +737,8 @@ function toParser(p, toParserFn) {
|
|
|
729
737
|
}
|
|
730
738
|
class SrcMap {
|
|
731
739
|
constructor(dest, entries = []) {
|
|
740
|
+
__publicField(this, "entries");
|
|
741
|
+
__publicField(this, "dest");
|
|
732
742
|
this.dest = dest;
|
|
733
743
|
this.entries = entries;
|
|
734
744
|
}
|
|
@@ -892,8 +902,8 @@ _destLength = new WeakMap();
|
|
|
892
902
|
_entries = new WeakMap();
|
|
893
903
|
class CachingStream {
|
|
894
904
|
constructor(inner) {
|
|
905
|
+
__publicField(this, "cache", new Cache(5));
|
|
895
906
|
this.inner = inner;
|
|
896
|
-
this.cache = new Cache(5);
|
|
897
907
|
}
|
|
898
908
|
checkpoint() {
|
|
899
909
|
return this.inner.checkpoint();
|
|
@@ -962,9 +972,9 @@ function matchOneOf(syms) {
|
|
|
962
972
|
}
|
|
963
973
|
class MatchersStream {
|
|
964
974
|
constructor(text2, matchers) {
|
|
975
|
+
__publicField(this, "position", 0);
|
|
965
976
|
this.text = text2;
|
|
966
977
|
this.matchers = matchers;
|
|
967
|
-
this.position = 0;
|
|
968
978
|
}
|
|
969
979
|
checkpoint() {
|
|
970
980
|
return this.position;
|
|
@@ -984,6 +994,8 @@ class MatchersStream {
|
|
|
984
994
|
}
|
|
985
995
|
class RegexMatchers {
|
|
986
996
|
constructor(matchers) {
|
|
997
|
+
__publicField(this, "groups");
|
|
998
|
+
__publicField(this, "exp");
|
|
987
999
|
this.groups = Object.keys(matchers);
|
|
988
1000
|
const expParts = Object.entries(matchers).map(toRegexSource).join("|");
|
|
989
1001
|
this.exp = new RegExp(expParts, "dyu");
|
|
@@ -1023,6 +1035,7 @@ function assertUnreachable(value) {
|
|
|
1023
1035
|
class ErrorWithData2 extends Error {
|
|
1024
1036
|
constructor(message, options) {
|
|
1025
1037
|
super(message, options);
|
|
1038
|
+
__publicField(this, "data");
|
|
1026
1039
|
this.data = options == null ? void 0 : options.data;
|
|
1027
1040
|
}
|
|
1028
1041
|
}
|
|
@@ -1426,12 +1439,12 @@ function scopeToString(scope, indent = 0, shortIdents = true) {
|
|
|
1426
1439
|
if (childScope(elem)) {
|
|
1427
1440
|
const childScope2 = elem;
|
|
1428
1441
|
const childBlock = scopeToString(childScope2, indent + 2, shortIdents);
|
|
1429
|
-
!lastWasScope
|
|
1442
|
+
if (!lastWasScope) str.nl();
|
|
1430
1443
|
str.addBlock(childBlock);
|
|
1431
1444
|
lastWasScope = true;
|
|
1432
1445
|
hasBlock = true;
|
|
1433
1446
|
} else {
|
|
1434
|
-
lastWasScope
|
|
1447
|
+
if (lastWasScope) str.add(" ");
|
|
1435
1448
|
lastWasScope = false;
|
|
1436
1449
|
const ident2 = elem;
|
|
1437
1450
|
if (shortIdents) {
|
|
@@ -1729,7 +1742,7 @@ const fnCollect = collectElem(
|
|
|
1729
1742
|
};
|
|
1730
1743
|
fnScope.ifAttribute = (_a = filterIfAttributes(attributes)) == null ? void 0 : _a[0];
|
|
1731
1744
|
const mergedScope = headerScope;
|
|
1732
|
-
returnScope
|
|
1745
|
+
if (returnScope) mergeScope(mergedScope, returnScope);
|
|
1733
1746
|
mergeScope(mergedScope, bodyScope);
|
|
1734
1747
|
const filtered = [];
|
|
1735
1748
|
for (const e of fnScope.contents) {
|
|
@@ -1838,7 +1851,7 @@ const collectAttribute = collectElem(
|
|
|
1838
1851
|
);
|
|
1839
1852
|
const typeRefCollect = collectElem(
|
|
1840
1853
|
"type",
|
|
1841
|
-
// @ts-
|
|
1854
|
+
// @ts-expect-error type mismatch
|
|
1842
1855
|
(cc, openElem) => {
|
|
1843
1856
|
var _a, _b;
|
|
1844
1857
|
const templateParamsTemp = (_a = cc.tags.templateParam) == null ? void 0 : _a.flat(3);
|
|
@@ -2118,9 +2131,12 @@ function weslExtension(combinator) {
|
|
|
2118
2131
|
}
|
|
2119
2132
|
class WeslStream {
|
|
2120
2133
|
constructor(src) {
|
|
2134
|
+
__publicField(this, "stream");
|
|
2135
|
+
/** New line */
|
|
2136
|
+
__publicField(this, "eolPattern", /[\n\v\f\u{0085}\u{2028}\u{2029}]|\r\n?/gu);
|
|
2137
|
+
/** Block comments */
|
|
2138
|
+
__publicField(this, "blockCommentPattern", /\/\*|\*\//g);
|
|
2121
2139
|
this.src = src;
|
|
2122
|
-
this.eolPattern = /[\n\v\f\u{0085}\u{2028}\u{2029}]|\r\n?/gu;
|
|
2123
|
-
this.blockCommentPattern = /\/\*|\*\//g;
|
|
2124
2140
|
this.stream = new CachingStream(new MatchersStream(src, weslMatcher));
|
|
2125
2141
|
}
|
|
2126
2142
|
checkpoint() {
|
|
@@ -3032,6 +3048,8 @@ class WeslParseError extends Error {
|
|
|
3032
3048
|
super(message, {
|
|
3033
3049
|
cause: opts.cause
|
|
3034
3050
|
});
|
|
3051
|
+
__publicField(this, "span");
|
|
3052
|
+
__publicField(this, "src");
|
|
3035
3053
|
this.span = opts.cause.span;
|
|
3036
3054
|
this.src = opts.src;
|
|
3037
3055
|
}
|
|
@@ -3242,7 +3260,7 @@ function bindIdentsRecursive(scope, bindContext, liveDecls, isRoot = false) {
|
|
|
3242
3260
|
if (!isRoot) liveDecls.decls.set(ident2.originalName, ident2);
|
|
3243
3261
|
} else if (kind2 === "ref") {
|
|
3244
3262
|
const newDecl = handleRef(child, liveDecls, bindContext);
|
|
3245
|
-
newDecl
|
|
3263
|
+
if (newDecl) newGlobals.push(newDecl);
|
|
3246
3264
|
} else {
|
|
3247
3265
|
const fromScope = handleScope(child, liveDecls, bindContext);
|
|
3248
3266
|
if (fromScope) {
|
|
@@ -4191,6 +4209,14 @@ async function link(params) {
|
|
|
4191
4209
|
const srcMap = linkRegistry({ registry, ...params });
|
|
4192
4210
|
return new LinkedWesl(srcMap);
|
|
4193
4211
|
}
|
|
4212
|
+
function _linkSync(params) {
|
|
4213
|
+
const { weslSrc, debugWeslRoot, libs = [] } = params;
|
|
4214
|
+
const registry = parsedRegistry();
|
|
4215
|
+
parseIntoRegistry(weslSrc, registry, "package", debugWeslRoot);
|
|
4216
|
+
parseLibsIntoRegistry(libs, registry);
|
|
4217
|
+
const srcMap = linkRegistry({ registry, ...params });
|
|
4218
|
+
return new LinkedWesl(srcMap);
|
|
4219
|
+
}
|
|
4194
4220
|
function linkRegistry(params) {
|
|
4195
4221
|
const bound = bindAndTransform(params);
|
|
4196
4222
|
const { transformedAst, newDecls, newStatements } = bound;
|
|
@@ -4594,6 +4620,7 @@ export {
|
|
|
4594
4620
|
LinkedWesl,
|
|
4595
4621
|
WeslParseError,
|
|
4596
4622
|
WeslStream,
|
|
4623
|
+
_linkSync,
|
|
4597
4624
|
astToString,
|
|
4598
4625
|
attributeToString$1 as attributeToString,
|
|
4599
4626
|
bindAndTransform,
|