wesl-packager 0.6.1 → 0.6.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/bin/wesl-packager +419 -235
- package/package.json +8 -6
package/bin/wesl-packager
CHANGED
|
@@ -723,13 +723,13 @@ var YargsParser = class {
|
|
|
723
723
|
function applyEnvVars(argv2, configOnly) {
|
|
724
724
|
if (typeof envPrefix === "undefined")
|
|
725
725
|
return;
|
|
726
|
-
const
|
|
726
|
+
const prefix2 = typeof envPrefix === "string" ? envPrefix : "";
|
|
727
727
|
const env2 = mixin.env();
|
|
728
728
|
Object.keys(env2).forEach(function(envVar) {
|
|
729
|
-
if (
|
|
729
|
+
if (prefix2 === "" || envVar.lastIndexOf(prefix2, 0) === 0) {
|
|
730
730
|
const keys = envVar.split("__").map(function(key, i) {
|
|
731
731
|
if (i === 0) {
|
|
732
|
-
key = key.substring(
|
|
732
|
+
key = key.substring(prefix2.length);
|
|
733
733
|
}
|
|
734
734
|
return camelCase(key);
|
|
735
735
|
});
|
|
@@ -2461,9 +2461,9 @@ function usage(yargs, shim3) {
|
|
|
2461
2461
|
if (yargs.getInternalMethods().getParserConfiguration()["sort-commands"] === true) {
|
|
2462
2462
|
commands = commands.sort((a, b) => a[0].localeCompare(b[0]));
|
|
2463
2463
|
}
|
|
2464
|
-
const
|
|
2464
|
+
const prefix2 = base$0 ? `${base$0} ` : "";
|
|
2465
2465
|
commands.forEach((command2) => {
|
|
2466
|
-
const commandString = `${
|
|
2466
|
+
const commandString = `${prefix2}${parentCommands}${command2[0].replace(/^\$0 ?/, "")}`;
|
|
2467
2467
|
ui2.span({
|
|
2468
2468
|
text: commandString,
|
|
2469
2469
|
padding: [0, 2, 0, 2],
|
|
@@ -3762,12 +3762,12 @@ var YargsInstance = class {
|
|
|
3762
3762
|
__classPrivateFieldSet(this, _YargsInstance_detectLocale, detect, "f");
|
|
3763
3763
|
return this;
|
|
3764
3764
|
}
|
|
3765
|
-
env(
|
|
3766
|
-
argsert("[string|boolean]", [
|
|
3767
|
-
if (
|
|
3765
|
+
env(prefix2) {
|
|
3766
|
+
argsert("[string|boolean]", [prefix2], arguments.length);
|
|
3767
|
+
if (prefix2 === false)
|
|
3768
3768
|
delete __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
|
|
3769
3769
|
else
|
|
3770
|
-
__classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix =
|
|
3770
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix = prefix2 || "";
|
|
3771
3771
|
return this;
|
|
3772
3772
|
}
|
|
3773
3773
|
epilogue(msg) {
|
|
@@ -4963,12 +4963,10 @@ function logInternalSrc(log2, src, pos, ...msgs) {
|
|
|
4963
4963
|
log2(caret);
|
|
4964
4964
|
}
|
|
4965
4965
|
function carets(linePos, linePos2) {
|
|
4966
|
-
const
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
}
|
|
4971
|
-
return firstCaret + secondCaret;
|
|
4966
|
+
const indent = " ".repeat(linePos);
|
|
4967
|
+
const numCarets = linePos2 ? linePos2 - linePos : 1;
|
|
4968
|
+
const carets2 = "^".repeat(numCarets);
|
|
4969
|
+
return indent + carets2;
|
|
4972
4970
|
}
|
|
4973
4971
|
var startCache = /* @__PURE__ */ new Map();
|
|
4974
4972
|
function srcLine(src, position) {
|
|
@@ -5224,6 +5222,18 @@ function opt(arg) {
|
|
|
5224
5222
|
}
|
|
5225
5223
|
);
|
|
5226
5224
|
}
|
|
5225
|
+
function not(arg) {
|
|
5226
|
+
const p = parserArg(arg);
|
|
5227
|
+
return parser2("not", function _not(state) {
|
|
5228
|
+
const pos = state.stream.checkpoint();
|
|
5229
|
+
const result = p._run(state);
|
|
5230
|
+
if (result === null) {
|
|
5231
|
+
state.stream.reset(pos);
|
|
5232
|
+
return { value: true };
|
|
5233
|
+
}
|
|
5234
|
+
return null;
|
|
5235
|
+
});
|
|
5236
|
+
}
|
|
5227
5237
|
function repeat(arg) {
|
|
5228
5238
|
const p = parserArg(arg);
|
|
5229
5239
|
return parser2("repeat", repeatWhileFilter(p));
|
|
@@ -5930,6 +5940,110 @@ function errorHighlight(source, span2) {
|
|
|
5930
5940
|
];
|
|
5931
5941
|
}
|
|
5932
5942
|
|
|
5943
|
+
// ../wesl/src/vlq/vlq.ts
|
|
5944
|
+
var char_to_integer = {};
|
|
5945
|
+
var integer_to_char = {};
|
|
5946
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split("").forEach((char, i) => {
|
|
5947
|
+
char_to_integer[char] = i;
|
|
5948
|
+
integer_to_char[i] = char;
|
|
5949
|
+
});
|
|
5950
|
+
function encodeVlq(value) {
|
|
5951
|
+
if (typeof value === "number") {
|
|
5952
|
+
return encode_integer(value);
|
|
5953
|
+
}
|
|
5954
|
+
let result = "";
|
|
5955
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
5956
|
+
result += encode_integer(value[i]);
|
|
5957
|
+
}
|
|
5958
|
+
return result;
|
|
5959
|
+
}
|
|
5960
|
+
function encode_integer(num) {
|
|
5961
|
+
let result = "";
|
|
5962
|
+
if (num < 0) {
|
|
5963
|
+
num = -num << 1 | 1;
|
|
5964
|
+
} else {
|
|
5965
|
+
num <<= 1;
|
|
5966
|
+
}
|
|
5967
|
+
do {
|
|
5968
|
+
let clamped = num & 31;
|
|
5969
|
+
num >>>= 5;
|
|
5970
|
+
if (num > 0) {
|
|
5971
|
+
clamped |= 32;
|
|
5972
|
+
}
|
|
5973
|
+
result += integer_to_char[clamped];
|
|
5974
|
+
} while (num > 0);
|
|
5975
|
+
return result;
|
|
5976
|
+
}
|
|
5977
|
+
|
|
5978
|
+
// ../wesl/src/ClickableError.ts
|
|
5979
|
+
function throwClickableError(params) {
|
|
5980
|
+
const { url, text: text2, lineNumber, lineColumn, length, error } = params;
|
|
5981
|
+
const mappings = encodeVlq([
|
|
5982
|
+
0,
|
|
5983
|
+
0,
|
|
5984
|
+
Math.max(0, lineNumber - 1),
|
|
5985
|
+
Math.max(0, lineColumn - 1)
|
|
5986
|
+
]) + "," + // Sadly no browser makes use of this info to map the error properly
|
|
5987
|
+
encodeVlq([
|
|
5988
|
+
18,
|
|
5989
|
+
// Arbitrary number that is high enough
|
|
5990
|
+
0,
|
|
5991
|
+
Math.max(0, lineNumber - 1),
|
|
5992
|
+
Math.max(0, lineColumn - 1) + length
|
|
5993
|
+
]);
|
|
5994
|
+
const sourceMap = {
|
|
5995
|
+
version: 3,
|
|
5996
|
+
file: null,
|
|
5997
|
+
sources: [url],
|
|
5998
|
+
sourcesContent: [text2 ?? null],
|
|
5999
|
+
names: [],
|
|
6000
|
+
mappings
|
|
6001
|
+
};
|
|
6002
|
+
let generatedCode = `throw new Error(${JSON.stringify(error.message + "")})`;
|
|
6003
|
+
generatedCode += "\n//# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
|
|
6004
|
+
generatedCode += "\n//# sourceURL=" + sourceMap.sources[0];
|
|
6005
|
+
let oldLimit = 0;
|
|
6006
|
+
if ("stackTraceLimit" in Error) {
|
|
6007
|
+
oldLimit = Error.stackTraceLimit;
|
|
6008
|
+
Error.stackTraceLimit = 1;
|
|
6009
|
+
}
|
|
6010
|
+
try {
|
|
6011
|
+
(0, eval)(generatedCode);
|
|
6012
|
+
} catch (e) {
|
|
6013
|
+
if ("stackTraceLimit" in Error) {
|
|
6014
|
+
Error.stackTraceLimit = oldLimit;
|
|
6015
|
+
}
|
|
6016
|
+
error.message = "";
|
|
6017
|
+
if (tracing) e.cause = error;
|
|
6018
|
+
throw e;
|
|
6019
|
+
}
|
|
6020
|
+
}
|
|
6021
|
+
function failIdent(ident2, msg) {
|
|
6022
|
+
const { refIdentElem, originalName } = ident2;
|
|
6023
|
+
const baseMessage = msg ?? `'${originalName}'`;
|
|
6024
|
+
if (refIdentElem) {
|
|
6025
|
+
failIdentElem(refIdentElem, baseMessage);
|
|
6026
|
+
} else {
|
|
6027
|
+
throw new Error(baseMessage);
|
|
6028
|
+
}
|
|
6029
|
+
}
|
|
6030
|
+
function failIdentElem(identElem, msg = "") {
|
|
6031
|
+
const { srcModule, start, end } = identElem;
|
|
6032
|
+
const { debugFilePath, src } = srcModule;
|
|
6033
|
+
const detailedMessage = `${msg} in file: ${debugFilePath}`;
|
|
6034
|
+
srcLog(src, [start, end], detailedMessage);
|
|
6035
|
+
const [lineNumber, lineColumn] = offsetToLineNumber(start, src);
|
|
6036
|
+
const length = end - start;
|
|
6037
|
+
throwClickableError({
|
|
6038
|
+
url: debugFilePath,
|
|
6039
|
+
text: src,
|
|
6040
|
+
lineNumber,
|
|
6041
|
+
lineColumn,
|
|
6042
|
+
length,
|
|
6043
|
+
error: new Error(detailedMessage)
|
|
6044
|
+
});
|
|
6045
|
+
}
|
|
6046
|
+
|
|
5933
6047
|
// ../wesl/src/Conditions.ts
|
|
5934
6048
|
function elementValid(elem, conditions) {
|
|
5935
6049
|
const attributes = elem.attributes;
|
|
@@ -5952,10 +6066,10 @@ function evaluateIfAttribute(ifAttribute, conditions) {
|
|
|
5952
6066
|
}
|
|
5953
6067
|
function evaluateIfExpression(expression2, conditions) {
|
|
5954
6068
|
const { kind: kind2 } = expression2;
|
|
5955
|
-
if (kind2
|
|
6069
|
+
if (kind2 === "unary-expression") {
|
|
5956
6070
|
assertThatDebug(expression2.operator.value === "!");
|
|
5957
6071
|
return !evaluateIfExpression(expression2.expression, conditions);
|
|
5958
|
-
} else if (kind2
|
|
6072
|
+
} else if (kind2 === "binary-expression") {
|
|
5959
6073
|
const op = expression2.operator.value;
|
|
5960
6074
|
assertThatDebug(op === "||" || op === "&&");
|
|
5961
6075
|
const leftResult = evaluateIfExpression(expression2.left, conditions);
|
|
@@ -5966,11 +6080,11 @@ function evaluateIfExpression(expression2, conditions) {
|
|
|
5966
6080
|
} else {
|
|
5967
6081
|
assertUnreachable(op);
|
|
5968
6082
|
}
|
|
5969
|
-
} else if (kind2
|
|
6083
|
+
} else if (kind2 === "literal") {
|
|
5970
6084
|
const { value } = expression2;
|
|
5971
6085
|
assertThatDebug(value === "true" || value === "false");
|
|
5972
6086
|
return value === "true";
|
|
5973
|
-
} else if (kind2
|
|
6087
|
+
} else if (kind2 === "parenthesized-expression") {
|
|
5974
6088
|
return evaluateIfExpression(expression2.expression, conditions);
|
|
5975
6089
|
} else if (kind2 === "translate-time-feature") {
|
|
5976
6090
|
return conditions[expression2.name];
|
|
@@ -6110,7 +6224,7 @@ function importElem(cc) {
|
|
|
6110
6224
|
function addToOpenElem(cc, elem) {
|
|
6111
6225
|
const weslContext = cc.app.context;
|
|
6112
6226
|
const { openElems } = weslContext;
|
|
6113
|
-
if (openElems
|
|
6227
|
+
if (openElems?.length) {
|
|
6114
6228
|
const open = openElems[openElems.length - 1];
|
|
6115
6229
|
open.contents.push(elem);
|
|
6116
6230
|
}
|
|
@@ -6272,7 +6386,7 @@ var fnCollect = collectElem(
|
|
|
6272
6386
|
mergeScope(mergedScope, bodyScope);
|
|
6273
6387
|
const filtered = [];
|
|
6274
6388
|
for (const e of fnScope.contents) {
|
|
6275
|
-
if (e === headerScope || e
|
|
6389
|
+
if (e === headerScope || e === returnScope) {
|
|
6276
6390
|
continue;
|
|
6277
6391
|
} else if (e === bodyScope) {
|
|
6278
6392
|
filtered.push(mergedScope);
|
|
@@ -6373,7 +6487,7 @@ var typeRefCollect = collectElem(
|
|
|
6373
6487
|
"type",
|
|
6374
6488
|
// @ts-ignore
|
|
6375
6489
|
(cc, openElem) => {
|
|
6376
|
-
|
|
6490
|
+
const templateParamsTemp = cc.tags.templateParam?.flat(3);
|
|
6377
6491
|
const typeRef = cc.tags.typeRefName?.[0];
|
|
6378
6492
|
const name2 = typeof typeRef === "string" ? typeRef : typeRef.ident;
|
|
6379
6493
|
const partElem = {
|
|
@@ -6408,7 +6522,7 @@ var memberRefCollect = collectElem(
|
|
|
6408
6522
|
"memberRef",
|
|
6409
6523
|
(cc, openElem) => {
|
|
6410
6524
|
const { component, structRef, extra_components } = cc.tags;
|
|
6411
|
-
const member = component[0];
|
|
6525
|
+
const member = component?.[0];
|
|
6412
6526
|
const name2 = structRef?.flat()[0];
|
|
6413
6527
|
const extraComponents = extra_components?.flat()[0];
|
|
6414
6528
|
const partElem = {
|
|
@@ -6504,7 +6618,10 @@ function coverWithText(cc, elem) {
|
|
|
6504
6618
|
// ../wesl/src/parse/WeslBaseGrammar.ts
|
|
6505
6619
|
var word = kind("word");
|
|
6506
6620
|
var keyword = kind("keyword");
|
|
6507
|
-
var qualified_ident = withSepPlus(
|
|
6621
|
+
var qualified_ident = withSepPlus(
|
|
6622
|
+
"::",
|
|
6623
|
+
or(word, keyword, "package", "super")
|
|
6624
|
+
);
|
|
6508
6625
|
var number = kind("number");
|
|
6509
6626
|
|
|
6510
6627
|
// ../wesl/src/parse/ImportGrammar.ts
|
|
@@ -6528,8 +6645,10 @@ function prependSegments(segments, statement2) {
|
|
|
6528
6645
|
return statement2;
|
|
6529
6646
|
}
|
|
6530
6647
|
var import_collection = null;
|
|
6648
|
+
var segment_blacklist = or("super", "package", "import", "as");
|
|
6649
|
+
var packageWord = preceded(not(segment_blacklist), or(word, keyword));
|
|
6531
6650
|
var import_path_or_item = seq(
|
|
6532
|
-
|
|
6651
|
+
packageWord,
|
|
6533
6652
|
or(
|
|
6534
6653
|
preceded(
|
|
6535
6654
|
"::",
|
|
@@ -6689,7 +6808,7 @@ var WeslStream = class {
|
|
|
6689
6808
|
this.stream.reset(this.skipBlockComment(token2.span[1]));
|
|
6690
6809
|
}
|
|
6691
6810
|
} else if (kind2 === "word") {
|
|
6692
|
-
|
|
6811
|
+
const returnToken = token2;
|
|
6693
6812
|
if (keywordOrReserved.has(token2.text)) {
|
|
6694
6813
|
returnToken.kind = "keyword";
|
|
6695
6814
|
}
|
|
@@ -6777,7 +6896,7 @@ var WeslStream = class {
|
|
|
6777
6896
|
if (nextToken.text === "<") {
|
|
6778
6897
|
pendingCounter += 1;
|
|
6779
6898
|
} else if (nextToken.text[0] === ">") {
|
|
6780
|
-
if (nextToken.text === ">" || nextToken.text
|
|
6899
|
+
if (nextToken.text === ">" || nextToken.text === ">=") {
|
|
6781
6900
|
pendingCounter -= 1;
|
|
6782
6901
|
} else if (nextToken.text === ">>=" || nextToken.text === ">>") {
|
|
6783
6902
|
pendingCounter -= 2;
|
|
@@ -7017,11 +7136,25 @@ var special_attribute = tagScope(
|
|
|
7017
7136
|
"@",
|
|
7018
7137
|
or(
|
|
7019
7138
|
// These attributes have no arguments
|
|
7020
|
-
or("compute", "const", "fragment", "invariant", "must_use", "vertex").map(
|
|
7139
|
+
or("compute", "const", "fragment", "invariant", "must_use", "vertex").map(
|
|
7140
|
+
(name2) => makeStandardAttribute([name2, []])
|
|
7141
|
+
),
|
|
7021
7142
|
// These attributes have arguments, but the argument doesn't have any identifiers
|
|
7022
|
-
preceded(
|
|
7023
|
-
|
|
7024
|
-
|
|
7143
|
+
preceded(
|
|
7144
|
+
"interpolate",
|
|
7145
|
+
req(
|
|
7146
|
+
delimited("(", name_list, ")"),
|
|
7147
|
+
"invalid @interpolate, expected '('"
|
|
7148
|
+
)
|
|
7149
|
+
).map(makeInterpolateAttribute),
|
|
7150
|
+
preceded(
|
|
7151
|
+
"builtin",
|
|
7152
|
+
req(delimited("(", name, ")"), "invalid @builtin, expected '('")
|
|
7153
|
+
).map(makeBuiltinAttribute),
|
|
7154
|
+
preceded(
|
|
7155
|
+
"diagnostic",
|
|
7156
|
+
req(diagnostic_control, "invalid @diagnostic, expected '('")
|
|
7157
|
+
).map(makeDiagnosticAttribute)
|
|
7025
7158
|
).ptag("attr_variant")
|
|
7026
7159
|
).collect(specialAttribute)
|
|
7027
7160
|
);
|
|
@@ -7057,7 +7190,7 @@ var normal_attribute = tagScope(
|
|
|
7057
7190
|
),
|
|
7058
7191
|
// Everything else is also a normal attribute, optional expression list
|
|
7059
7192
|
seq(
|
|
7060
|
-
// we don't want this to interfere with if_attribute,
|
|
7193
|
+
// we don't want this to interfere with if_attribute,
|
|
7061
7194
|
// but not("if") isn't necessary for now, since 'if' is a keyword, not a word
|
|
7062
7195
|
word.ptag("name"),
|
|
7063
7196
|
opt(() => attribute_argument_list)
|
|
@@ -7074,10 +7207,9 @@ var attribute_argument_list = delimited(
|
|
|
7074
7207
|
),
|
|
7075
7208
|
req(")", "invalid attribute arguments, expected ')'")
|
|
7076
7209
|
);
|
|
7077
|
-
var attribute_no_if = or(
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
).ctag("attribute");
|
|
7210
|
+
var attribute_no_if = or(special_attribute, normal_attribute).ctag(
|
|
7211
|
+
"attribute"
|
|
7212
|
+
);
|
|
7081
7213
|
var attribute_incl_if = or(
|
|
7082
7214
|
if_attribute,
|
|
7083
7215
|
special_attribute,
|
|
@@ -7118,7 +7250,10 @@ var struct_member = tagScope(
|
|
|
7118
7250
|
).collect(collectStructMember)
|
|
7119
7251
|
).ctag("members");
|
|
7120
7252
|
var struct_decl = seq(
|
|
7121
|
-
weslExtension(opt_attributes).collect(
|
|
7253
|
+
weslExtension(opt_attributes).collect(
|
|
7254
|
+
(cc) => cc.tags.attribute,
|
|
7255
|
+
"attributes"
|
|
7256
|
+
),
|
|
7122
7257
|
"struct",
|
|
7123
7258
|
req(globalTypeNameDecl, "invalid struct, expected name"),
|
|
7124
7259
|
seq(
|
|
@@ -7136,7 +7271,12 @@ var fnParam = tagScope(
|
|
|
7136
7271
|
seq(
|
|
7137
7272
|
opt_attributes.collect((cc) => cc.tags.attribute, "attributes"),
|
|
7138
7273
|
word.collect(declCollect, "decl_elem"),
|
|
7139
|
-
opt(
|
|
7274
|
+
opt(
|
|
7275
|
+
seq(
|
|
7276
|
+
":",
|
|
7277
|
+
req(type_specifier, "invalid fn parameter, expected type specifier")
|
|
7278
|
+
)
|
|
7279
|
+
).collect(typedDecl, "param_name")
|
|
7140
7280
|
).collect(collectFnParam)
|
|
7141
7281
|
).ctag("fn_param");
|
|
7142
7282
|
var fnParamList = seq("(", withSep(",", fnParam), ")");
|
|
@@ -7328,16 +7468,10 @@ var regular_statement = or(
|
|
|
7328
7468
|
)
|
|
7329
7469
|
);
|
|
7330
7470
|
var conditional_statement = tagScope(
|
|
7331
|
-
seq(
|
|
7332
|
-
opt_attributes,
|
|
7333
|
-
regular_statement
|
|
7334
|
-
).collect(statementCollect).collect(partialScopeCollect)
|
|
7471
|
+
seq(opt_attributes, regular_statement).collect(statementCollect).collect(partialScopeCollect)
|
|
7335
7472
|
);
|
|
7336
7473
|
var unconditional_statement = tagScope(
|
|
7337
|
-
seq(
|
|
7338
|
-
opt_attributes_no_if,
|
|
7339
|
-
regular_statement
|
|
7340
|
-
)
|
|
7474
|
+
seq(opt_attributes_no_if, regular_statement)
|
|
7341
7475
|
);
|
|
7342
7476
|
var statement = or(
|
|
7343
7477
|
compound_statement,
|
|
@@ -7346,10 +7480,7 @@ var statement = or(
|
|
|
7346
7480
|
);
|
|
7347
7481
|
var lhs_expression = or(
|
|
7348
7482
|
simple_component_reference,
|
|
7349
|
-
seq(
|
|
7350
|
-
qualified_ident.collect(refIdent),
|
|
7351
|
-
opt(component_or_swizzle)
|
|
7352
|
-
),
|
|
7483
|
+
seq(qualified_ident.collect(refIdent), opt(component_or_swizzle)),
|
|
7353
7484
|
seq(
|
|
7354
7485
|
"(",
|
|
7355
7486
|
() => lhs_expression,
|
|
@@ -7365,7 +7496,12 @@ var variable_or_value_statement = tagScope(
|
|
|
7365
7496
|
or(
|
|
7366
7497
|
// Also covers the = expression case
|
|
7367
7498
|
local_variable_decl,
|
|
7368
|
-
seq(
|
|
7499
|
+
seq(
|
|
7500
|
+
"const",
|
|
7501
|
+
req_optionally_typed_ident,
|
|
7502
|
+
req("=", "invalid const declaration, expected '='"),
|
|
7503
|
+
expression
|
|
7504
|
+
),
|
|
7369
7505
|
seq(
|
|
7370
7506
|
"let",
|
|
7371
7507
|
req_optionally_typed_ident,
|
|
@@ -7384,22 +7520,24 @@ var variable_updating_statement = or(
|
|
|
7384
7520
|
seq("_", "=", expression)
|
|
7385
7521
|
);
|
|
7386
7522
|
var fn_decl = seq(
|
|
7387
|
-
tagScope(
|
|
7388
|
-
|
|
7389
|
-
)
|
|
7523
|
+
tagScope(opt_attributes.collect((cc) => cc.tags.attribute || [])).ctag(
|
|
7524
|
+
"fn_attributes"
|
|
7525
|
+
),
|
|
7390
7526
|
text("fn"),
|
|
7391
7527
|
req(fnNameDecl, "invalid fn, expected function name"),
|
|
7392
7528
|
seq(
|
|
7393
|
-
req(fnParamList, "invalid fn, expected function parameters").collect(
|
|
7394
|
-
|
|
7395
|
-
"
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7529
|
+
req(fnParamList, "invalid fn, expected function parameters").collect(
|
|
7530
|
+
scopeCollect,
|
|
7531
|
+
"header_scope"
|
|
7532
|
+
),
|
|
7533
|
+
opt(
|
|
7534
|
+
seq(
|
|
7535
|
+
"->",
|
|
7536
|
+
opt_attributes.collect((cc) => cc.tags.attribute, "return_attributes"),
|
|
7537
|
+
type_specifier.ctag("return_type").collect(scopeCollect, "return_scope")
|
|
7538
|
+
)
|
|
7539
|
+
),
|
|
7540
|
+
req(unscoped_compound_statement, "invalid fn, expected function body").ctag("body_statement").collect(scopeCollect, "body_scope")
|
|
7403
7541
|
)
|
|
7404
7542
|
).collect(partialScopeCollect, "fn_partial_scope").collect(fnCollect);
|
|
7405
7543
|
var global_value_decl = or(
|
|
@@ -7420,11 +7558,20 @@ var global_value_decl = or(
|
|
|
7420
7558
|
).collect(collectVarLike("const"))
|
|
7421
7559
|
).collect(partialScopeCollect);
|
|
7422
7560
|
var global_alias = seq(
|
|
7423
|
-
weslExtension(opt_attributes).collect(
|
|
7561
|
+
weslExtension(opt_attributes).collect(
|
|
7562
|
+
(cc) => cc.tags.attribute,
|
|
7563
|
+
"attributes"
|
|
7564
|
+
),
|
|
7424
7565
|
"alias",
|
|
7425
|
-
req(word, "invalid alias, expected name").collect(
|
|
7566
|
+
req(word, "invalid alias, expected name").collect(
|
|
7567
|
+
globalDeclCollect,
|
|
7568
|
+
"alias_name"
|
|
7569
|
+
),
|
|
7426
7570
|
req("=", "invalid alias, expected '='"),
|
|
7427
|
-
req(type_specifier, "invalid alias, expected type").collect(
|
|
7571
|
+
req(type_specifier, "invalid alias, expected type").collect(
|
|
7572
|
+
scopeCollect,
|
|
7573
|
+
"alias_scope"
|
|
7574
|
+
),
|
|
7428
7575
|
req(";", "invalid alias, expected ';'")
|
|
7429
7576
|
).collect(aliasCollect);
|
|
7430
7577
|
var const_assert = tagScope(
|
|
@@ -7562,17 +7709,17 @@ function makeUnaryExpression([operator, expression2]) {
|
|
|
7562
7709
|
}
|
|
7563
7710
|
function makeRepeatingBinaryExpression([start, repeating]) {
|
|
7564
7711
|
let result = start;
|
|
7565
|
-
for (const [op,
|
|
7566
|
-
result = makeBinaryExpression([result, op,
|
|
7712
|
+
for (const [op, left3] of repeating) {
|
|
7713
|
+
result = makeBinaryExpression([result, op, left3]);
|
|
7567
7714
|
}
|
|
7568
7715
|
return result;
|
|
7569
7716
|
}
|
|
7570
|
-
function makeBinaryExpression([
|
|
7717
|
+
function makeBinaryExpression([left3, operator, right3]) {
|
|
7571
7718
|
return {
|
|
7572
7719
|
kind: "binary-expression",
|
|
7573
7720
|
operator,
|
|
7574
|
-
left:
|
|
7575
|
-
right:
|
|
7721
|
+
left: left3,
|
|
7722
|
+
right: right3
|
|
7576
7723
|
};
|
|
7577
7724
|
}
|
|
7578
7725
|
if (tracing) {
|
|
@@ -7639,91 +7786,6 @@ if (tracing) {
|
|
|
7639
7786
|
});
|
|
7640
7787
|
}
|
|
7641
7788
|
|
|
7642
|
-
// ../wesl/src/vlq/vlq.ts
|
|
7643
|
-
var char_to_integer = {};
|
|
7644
|
-
var integer_to_char = {};
|
|
7645
|
-
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split("").forEach(function(char, i) {
|
|
7646
|
-
char_to_integer[char] = i;
|
|
7647
|
-
integer_to_char[i] = char;
|
|
7648
|
-
});
|
|
7649
|
-
function encodeVlq(value) {
|
|
7650
|
-
if (typeof value === "number") {
|
|
7651
|
-
return encode_integer(value);
|
|
7652
|
-
}
|
|
7653
|
-
let result = "";
|
|
7654
|
-
for (let i = 0; i < value.length; i += 1) {
|
|
7655
|
-
result += encode_integer(value[i]);
|
|
7656
|
-
}
|
|
7657
|
-
return result;
|
|
7658
|
-
}
|
|
7659
|
-
function encode_integer(num) {
|
|
7660
|
-
let result = "";
|
|
7661
|
-
if (num < 0) {
|
|
7662
|
-
num = -num << 1 | 1;
|
|
7663
|
-
} else {
|
|
7664
|
-
num <<= 1;
|
|
7665
|
-
}
|
|
7666
|
-
do {
|
|
7667
|
-
let clamped = num & 31;
|
|
7668
|
-
num >>>= 5;
|
|
7669
|
-
if (num > 0) {
|
|
7670
|
-
clamped |= 32;
|
|
7671
|
-
}
|
|
7672
|
-
result += integer_to_char[clamped];
|
|
7673
|
-
} while (num > 0);
|
|
7674
|
-
return result;
|
|
7675
|
-
}
|
|
7676
|
-
|
|
7677
|
-
// ../wesl/src/WeslDevice.ts
|
|
7678
|
-
function throwClickableError({
|
|
7679
|
-
url,
|
|
7680
|
-
text: text2,
|
|
7681
|
-
lineNumber,
|
|
7682
|
-
lineColumn,
|
|
7683
|
-
length,
|
|
7684
|
-
error
|
|
7685
|
-
}) {
|
|
7686
|
-
let mappings = encodeVlq([
|
|
7687
|
-
0,
|
|
7688
|
-
0,
|
|
7689
|
-
Math.max(0, lineNumber - 1),
|
|
7690
|
-
Math.max(0, lineColumn - 1)
|
|
7691
|
-
]) + "," + // Sadly no browser makes use of this info to map the error properly
|
|
7692
|
-
encodeVlq([
|
|
7693
|
-
18,
|
|
7694
|
-
// Arbitrary number that is high enough
|
|
7695
|
-
0,
|
|
7696
|
-
Math.max(0, lineNumber - 1),
|
|
7697
|
-
Math.max(0, lineColumn - 1) + length
|
|
7698
|
-
]);
|
|
7699
|
-
const sourceMap = {
|
|
7700
|
-
version: 3,
|
|
7701
|
-
file: null,
|
|
7702
|
-
sources: [url],
|
|
7703
|
-
sourcesContent: [text2 ?? null],
|
|
7704
|
-
names: [],
|
|
7705
|
-
mappings
|
|
7706
|
-
};
|
|
7707
|
-
let generatedCode = `throw new Error(${JSON.stringify(error.message + "")})`;
|
|
7708
|
-
generatedCode += "\n//# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
|
|
7709
|
-
generatedCode += "\n//# sourceURL=" + sourceMap.sources[0];
|
|
7710
|
-
let oldLimit = 0;
|
|
7711
|
-
if ("stackTraceLimit" in Error) {
|
|
7712
|
-
oldLimit = Error.stackTraceLimit;
|
|
7713
|
-
Error.stackTraceLimit = 1;
|
|
7714
|
-
}
|
|
7715
|
-
try {
|
|
7716
|
-
(0, eval)(generatedCode);
|
|
7717
|
-
} catch (e) {
|
|
7718
|
-
if ("stackTraceLimit" in Error) {
|
|
7719
|
-
Error.stackTraceLimit = oldLimit;
|
|
7720
|
-
}
|
|
7721
|
-
error.message = "";
|
|
7722
|
-
e.cause = error;
|
|
7723
|
-
throw e;
|
|
7724
|
-
}
|
|
7725
|
-
}
|
|
7726
|
-
|
|
7727
7789
|
// ../wesl/src/ParseWESL.ts
|
|
7728
7790
|
var WeslParseError = class extends Error {
|
|
7729
7791
|
constructor(opts) {
|
|
@@ -7864,36 +7926,25 @@ function stdEnumerant(name2) {
|
|
|
7864
7926
|
}
|
|
7865
7927
|
|
|
7866
7928
|
// ../wesl/src/BindIdents.ts
|
|
7867
|
-
function
|
|
7868
|
-
const { rootAst, registry, virtuals, accumulateUnbound } = params;
|
|
7869
|
-
const { conditions = {}, mangler = minimalMangle } = params;
|
|
7870
|
-
const { rootScope } = rootAst;
|
|
7871
|
-
const globalNames = /* @__PURE__ */ new Set();
|
|
7872
|
-
const knownDecls = /* @__PURE__ */ new Set();
|
|
7873
|
-
const validRootDecls = findValidRootDecls(rootScope, conditions);
|
|
7874
|
-
validRootDecls.forEach((decl) => {
|
|
7875
|
-
decl.mangledName = decl.originalName;
|
|
7876
|
-
globalNames.add(decl.originalName);
|
|
7877
|
-
knownDecls.add(decl);
|
|
7878
|
-
});
|
|
7879
|
-
const unbound = accumulateUnbound ? [] : void 0;
|
|
7880
|
-
const globalStatements = /* @__PURE__ */ new Map();
|
|
7929
|
+
function findUnboundIdents(registry) {
|
|
7881
7930
|
const bindContext = {
|
|
7882
7931
|
registry,
|
|
7883
|
-
conditions,
|
|
7884
|
-
knownDecls,
|
|
7932
|
+
conditions: {},
|
|
7933
|
+
knownDecls: /* @__PURE__ */ new Set(),
|
|
7885
7934
|
foundScopes: /* @__PURE__ */ new Set(),
|
|
7886
|
-
globalNames,
|
|
7887
|
-
globalStatements,
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
7935
|
+
globalNames: /* @__PURE__ */ new Set(),
|
|
7936
|
+
globalStatements: /* @__PURE__ */ new Map(),
|
|
7937
|
+
mangler: minimalMangle,
|
|
7938
|
+
unbound: [],
|
|
7939
|
+
dontFollowDecls: true
|
|
7891
7940
|
};
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7941
|
+
Object.entries(registry.modules).map(([module, ast]) => {
|
|
7942
|
+
const rootDecls = findValidRootDecls(ast.rootScope, {});
|
|
7943
|
+
const declEntries = rootDecls.map((d) => [d.originalName, d]);
|
|
7944
|
+
const liveDecls = { decls: new Map(declEntries), parent: null };
|
|
7945
|
+
bindIdentsRecursive(ast.rootScope, bindContext, liveDecls, true);
|
|
7946
|
+
});
|
|
7947
|
+
return bindContext.unbound;
|
|
7897
7948
|
}
|
|
7898
7949
|
function findValidRootDecls(rootScope, conditions) {
|
|
7899
7950
|
const found = [];
|
|
@@ -7910,7 +7961,7 @@ function findValidRootDecls(rootScope, conditions) {
|
|
|
7910
7961
|
return found;
|
|
7911
7962
|
}
|
|
7912
7963
|
function bindIdentsRecursive(scope, bindContext, liveDecls, isRoot = false) {
|
|
7913
|
-
const {
|
|
7964
|
+
const { dontFollowDecls, foundScopes } = bindContext;
|
|
7914
7965
|
if (foundScopes.has(scope)) return [];
|
|
7915
7966
|
foundScopes.add(scope);
|
|
7916
7967
|
const newGlobals = [];
|
|
@@ -7930,7 +7981,12 @@ function bindIdentsRecursive(scope, bindContext, liveDecls, isRoot = false) {
|
|
|
7930
7981
|
}
|
|
7931
7982
|
}
|
|
7932
7983
|
});
|
|
7933
|
-
const newFromRefs = newGlobals
|
|
7984
|
+
const newFromRefs = dontFollowDecls ? [] : handleDecls(newGlobals, bindContext);
|
|
7985
|
+
return [newGlobals, newFromChildren, newFromRefs].flat();
|
|
7986
|
+
}
|
|
7987
|
+
function handleDecls(newGlobals, bindContext) {
|
|
7988
|
+
const { conditions } = bindContext;
|
|
7989
|
+
return newGlobals.flatMap((decl) => {
|
|
7934
7990
|
const foundsScope = decl.dependentScope;
|
|
7935
7991
|
if (foundsScope) {
|
|
7936
7992
|
const rootDecls = globalDeclToRootLiveDecls(decl, conditions);
|
|
@@ -7941,7 +7997,6 @@ function bindIdentsRecursive(scope, bindContext, liveDecls, isRoot = false) {
|
|
|
7941
7997
|
}
|
|
7942
7998
|
return [];
|
|
7943
7999
|
});
|
|
7944
|
-
return [newGlobals, newFromChildren, newFromRefs].flat();
|
|
7945
8000
|
}
|
|
7946
8001
|
function handleRef(ident2, liveDecls, bindContext) {
|
|
7947
8002
|
const { registry, conditions, unbound } = bindContext;
|
|
@@ -7954,7 +8009,7 @@ function handleRef(ident2, liveDecls, bindContext) {
|
|
|
7954
8009
|
} else if (stdWgsl(ident2.originalName)) {
|
|
7955
8010
|
ident2.std = true;
|
|
7956
8011
|
} else if (!unbound) {
|
|
7957
|
-
|
|
8012
|
+
failIdent(ident2, `unresolved identifier '${ident2.originalName}'`);
|
|
7958
8013
|
}
|
|
7959
8014
|
}
|
|
7960
8015
|
}
|
|
@@ -8003,16 +8058,6 @@ function globalDeclToRootLiveDecls(decl, conditions) {
|
|
|
8003
8058
|
root._scopeDecls = liveDecls;
|
|
8004
8059
|
return liveDecls;
|
|
8005
8060
|
}
|
|
8006
|
-
function failMissingIdent(ident2) {
|
|
8007
|
-
const { refIdentElem } = ident2;
|
|
8008
|
-
if (refIdentElem) {
|
|
8009
|
-
const { srcModule, start, end } = refIdentElem;
|
|
8010
|
-
const { debugFilePath: filePath } = srcModule;
|
|
8011
|
-
const msg = `unresolved identifier '${ident2.originalName}' in file: ${filePath}`;
|
|
8012
|
-
srcLog(srcModule.src, [start, end], msg);
|
|
8013
|
-
throw new Error(msg);
|
|
8014
|
-
}
|
|
8015
|
-
}
|
|
8016
8061
|
function setMangledName(proposedName, decl, globalNames, srcModule, mangler) {
|
|
8017
8062
|
if (!decl.mangledName) {
|
|
8018
8063
|
let mangledName;
|
|
@@ -8058,8 +8103,8 @@ function findQualifiedImport(refIdent2, parsed, conditions, virtuals, unbound) {
|
|
|
8058
8103
|
if (unbound) {
|
|
8059
8104
|
unbound.push(modulePathParts);
|
|
8060
8105
|
} else {
|
|
8061
|
-
const msg = `
|
|
8062
|
-
|
|
8106
|
+
const msg = `module not found for '${modulePathParts.join("::")}'`;
|
|
8107
|
+
failIdent(refIdent2, msg);
|
|
8063
8108
|
}
|
|
8064
8109
|
}
|
|
8065
8110
|
return result;
|
|
@@ -8195,16 +8240,22 @@ var multiNames = matchOneOf(multisampledTextureTypes);
|
|
|
8195
8240
|
// raw-loader:/Users/lee/wesl-js/tools/packages/wesl/src/WeslBundle.ts?raw
|
|
8196
8241
|
var WeslBundle_default = 'export interface WeslBundle {\n /** name of the package, e.g. random_wgsl */\n name: string;\n\n /** wesl edition of the code e.g. unstable_2025_1 */\n edition: string;\n\n /** map of wesl/wgsl modules:\n * keys are file paths, relative to package root (e.g. "./lib.wgsl")\n * values are wgsl/wesl code strings\n */\n modules: Record<string, string>;\n\n /** packages referenced by this package */\n dependencies?: WeslBundle[];\n}\n';
|
|
8197
8242
|
|
|
8198
|
-
// src/ParseDependencies.ts
|
|
8243
|
+
// ../wesl-tooling/src/ParseDependencies.ts
|
|
8199
8244
|
import { resolve as resolve5 } from "import-meta-resolve";
|
|
8200
8245
|
import path from "node:path";
|
|
8201
8246
|
import { pathToFileURL } from "node:url";
|
|
8202
8247
|
function parseDependencies(weslSrc, projectDir) {
|
|
8203
8248
|
const registry = parsedRegistry();
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8249
|
+
try {
|
|
8250
|
+
parseIntoRegistry(weslSrc, registry);
|
|
8251
|
+
} catch (e) {
|
|
8252
|
+
if (e.cause instanceof WeslParseError) {
|
|
8253
|
+
console.error(e.message, "\n");
|
|
8254
|
+
} else {
|
|
8255
|
+
throw e;
|
|
8256
|
+
}
|
|
8257
|
+
}
|
|
8258
|
+
const unbound = findUnboundIdents(registry);
|
|
8208
8259
|
if (!unbound) return [];
|
|
8209
8260
|
const pkgRefs = unbound.filter((modulePath) => modulePath.length > 1);
|
|
8210
8261
|
if (pkgRefs.length === 0) return [];
|
|
@@ -8218,18 +8269,161 @@ function parseDependencies(weslSrc, projectDir) {
|
|
|
8218
8269
|
return uniqueDeps;
|
|
8219
8270
|
}
|
|
8220
8271
|
function unboundToDependency(mPath, importerURL) {
|
|
8221
|
-
|
|
8272
|
+
return exportSubpaths(mPath).find(
|
|
8273
|
+
(subPath) => (
|
|
8274
|
+
// Note that we're not checking here that the resolved file exists.
|
|
8275
|
+
// The file (a weslBundle.js file somewhere in dist) may not have been built yet.
|
|
8276
|
+
// LATER we could do save these paths and check that the resolved files exist.
|
|
8277
|
+
tryResolve(subPath, importerURL)
|
|
8278
|
+
)
|
|
8279
|
+
);
|
|
8280
|
+
}
|
|
8281
|
+
function tryResolve(path3, importerURL) {
|
|
8282
|
+
try {
|
|
8283
|
+
return resolve5(path3, importerURL);
|
|
8284
|
+
} catch (e) {
|
|
8285
|
+
return void 0;
|
|
8286
|
+
}
|
|
8287
|
+
}
|
|
8288
|
+
function* exportSubpaths(mPath) {
|
|
8289
|
+
const longest = mPath.length - 1;
|
|
8290
|
+
for (let i = longest; i >= 0; i--) {
|
|
8222
8291
|
const subPath = mPath.slice(0, i).join("/");
|
|
8223
|
-
|
|
8224
|
-
resolve5(subPath, importerURL);
|
|
8225
|
-
return subPath;
|
|
8226
|
-
} catch {
|
|
8227
|
-
continue;
|
|
8228
|
-
}
|
|
8292
|
+
yield subPath;
|
|
8229
8293
|
}
|
|
8230
|
-
return void 0;
|
|
8231
8294
|
}
|
|
8232
8295
|
|
|
8296
|
+
// ../../node_modules/.pnpm/berry-pretty@0.0.4/node_modules/berry-pretty/dist/index.js
|
|
8297
|
+
var spaces2 = memoize2((nesting) => {
|
|
8298
|
+
return " ".repeat(nesting);
|
|
8299
|
+
});
|
|
8300
|
+
var defaultCallerSize2 = 20;
|
|
8301
|
+
var multiLinePad2 = "\n" + spaces2(defaultCallerSize2 + 3);
|
|
8302
|
+
function memoize2(fn2) {
|
|
8303
|
+
const cache = /* @__PURE__ */ new Map();
|
|
8304
|
+
return function(...args) {
|
|
8305
|
+
const key = JSON.stringify(args);
|
|
8306
|
+
if (cache.has(key)) {
|
|
8307
|
+
return cache.get(key);
|
|
8308
|
+
} else {
|
|
8309
|
+
const value = fn2(...args);
|
|
8310
|
+
cache.set(key, value);
|
|
8311
|
+
return value;
|
|
8312
|
+
}
|
|
8313
|
+
};
|
|
8314
|
+
}
|
|
8315
|
+
if (typeof DOMRect === "undefined") {
|
|
8316
|
+
globalThis.DOMRect = function() {
|
|
8317
|
+
};
|
|
8318
|
+
}
|
|
8319
|
+
|
|
8320
|
+
// ../../node_modules/.pnpm/thimbleberry@0.2.9/node_modules/thimbleberry/dist/thimbleberry.js
|
|
8321
|
+
function memoMemo(fn2, options) {
|
|
8322
|
+
const memoizer = options?.memoCache || persistentMemoCache;
|
|
8323
|
+
const keyFn = options?.keyFn || defaultKeyFn;
|
|
8324
|
+
const cache = memoizer();
|
|
8325
|
+
return function(...args) {
|
|
8326
|
+
const key = keyFn(...args);
|
|
8327
|
+
const found = cache.get(key);
|
|
8328
|
+
if (found !== void 0) {
|
|
8329
|
+
return found;
|
|
8330
|
+
} else {
|
|
8331
|
+
const value = fn2(...args);
|
|
8332
|
+
cache.set(key, value);
|
|
8333
|
+
return value;
|
|
8334
|
+
}
|
|
8335
|
+
};
|
|
8336
|
+
}
|
|
8337
|
+
function persistentMemoCache() {
|
|
8338
|
+
return /* @__PURE__ */ new Map();
|
|
8339
|
+
}
|
|
8340
|
+
function defaultKeyFn(...args) {
|
|
8341
|
+
return JSON.stringify(args[0] ?? "");
|
|
8342
|
+
}
|
|
8343
|
+
function memoizeWithDevice(fn2) {
|
|
8344
|
+
const keyFn = cacheKeyWithDevice;
|
|
8345
|
+
let memoFn;
|
|
8346
|
+
return function(paramsObj, memoCache) {
|
|
8347
|
+
if (!memoFn) {
|
|
8348
|
+
memoFn = memoMemo(fn2, { keyFn, memoCache });
|
|
8349
|
+
}
|
|
8350
|
+
return memoFn(paramsObj);
|
|
8351
|
+
};
|
|
8352
|
+
}
|
|
8353
|
+
function cacheKeyWithDevice(paramsObj) {
|
|
8354
|
+
const deviceStr = `device: ${paramsObj.device?.label ?? "."}`;
|
|
8355
|
+
const withoutDevice = { ...paramsObj };
|
|
8356
|
+
delete withoutDevice["device"];
|
|
8357
|
+
const mainStr = JSON.stringify({ ...withoutDevice });
|
|
8358
|
+
const result = `${mainStr}; ${deviceStr}`;
|
|
8359
|
+
return result;
|
|
8360
|
+
}
|
|
8361
|
+
function filledGPUBuffer(device, data, usage2 = GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST | GPUBufferUsage.STORAGE, label, ArrayConstructor = Float32Array) {
|
|
8362
|
+
const buffer = device.createBuffer({
|
|
8363
|
+
label,
|
|
8364
|
+
size: data.length * ArrayConstructor.BYTES_PER_ELEMENT,
|
|
8365
|
+
usage: usage2,
|
|
8366
|
+
mappedAtCreation: true
|
|
8367
|
+
});
|
|
8368
|
+
new ArrayConstructor(buffer.getMappedRange()).set(data);
|
|
8369
|
+
buffer.unmap();
|
|
8370
|
+
return buffer;
|
|
8371
|
+
}
|
|
8372
|
+
var [top2, bottom2] = [1, -1];
|
|
8373
|
+
var [left2, right2] = [-1, 1];
|
|
8374
|
+
var fullFrameTriangleStrip = [
|
|
8375
|
+
[left2, bottom2],
|
|
8376
|
+
[left2, top2],
|
|
8377
|
+
[right2, top2],
|
|
8378
|
+
// upper left triangle
|
|
8379
|
+
[right2, bottom2],
|
|
8380
|
+
[left2, bottom2]
|
|
8381
|
+
// lower right triangle
|
|
8382
|
+
];
|
|
8383
|
+
var resources = /* @__PURE__ */ new WeakMap();
|
|
8384
|
+
var autoContextStack = [];
|
|
8385
|
+
var trackCount = 0;
|
|
8386
|
+
function trackUse(target, context) {
|
|
8387
|
+
const refCount = resources.get(target) || 0;
|
|
8388
|
+
if (refCount === 0) {
|
|
8389
|
+
trackCount++;
|
|
8390
|
+
}
|
|
8391
|
+
resources.set(target, refCount + 1);
|
|
8392
|
+
last3(autoContextStack)?._addRef(target);
|
|
8393
|
+
context?._addRef(target);
|
|
8394
|
+
return target;
|
|
8395
|
+
}
|
|
8396
|
+
function last3(a) {
|
|
8397
|
+
return a[a.length - 1];
|
|
8398
|
+
}
|
|
8399
|
+
var fullFrameVertexBuffer = memoizeWithDevice(createFrameVertexBuffer);
|
|
8400
|
+
function createFrameVertexBuffer(params) {
|
|
8401
|
+
const { device } = params;
|
|
8402
|
+
const verts = fullFrameTriangleStrip.flat();
|
|
8403
|
+
const usage2 = GPUBufferUsage.VERTEX;
|
|
8404
|
+
const buffer = filledGPUBuffer(device, verts, usage2, "full-screen-verts", Float32Array);
|
|
8405
|
+
trackUse(buffer);
|
|
8406
|
+
return buffer;
|
|
8407
|
+
}
|
|
8408
|
+
var placeholderTexture = memoMemo(makePlaceholderTexture);
|
|
8409
|
+
function makePlaceholderTexture(device) {
|
|
8410
|
+
return device.createTexture({
|
|
8411
|
+
label: "placeholder texture",
|
|
8412
|
+
size: [50, 50],
|
|
8413
|
+
format: "rgba8unorm",
|
|
8414
|
+
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC
|
|
8415
|
+
});
|
|
8416
|
+
}
|
|
8417
|
+
var prefix = /\s*/.source;
|
|
8418
|
+
var findUnquoted = /(?<findUnquoted>[\w-<>.]+)/.source;
|
|
8419
|
+
var findQuoted = /"(?<findQuoted>[^=]+)"/.source;
|
|
8420
|
+
var replaceKey = /\s*(?<replaceKey>[\w-]+)/.source;
|
|
8421
|
+
var replaceValue = /\s*"(?<replaceValue>[^"]+)"/.source;
|
|
8422
|
+
var parseRule = new RegExp(
|
|
8423
|
+
`${prefix}(${findUnquoted}|${findQuoted})=(${replaceKey}|${replaceValue})`,
|
|
8424
|
+
"g"
|
|
8425
|
+
);
|
|
8426
|
+
|
|
8233
8427
|
// src/PackageWesl.ts
|
|
8234
8428
|
var biome = await setupBiome();
|
|
8235
8429
|
async function packageWgsl(args) {
|
|
@@ -8271,7 +8465,8 @@ async function updatePackageJson(projectDir, outDir, multiBundle) {
|
|
|
8271
8465
|
};
|
|
8272
8466
|
}
|
|
8273
8467
|
pkgJson.exports = exports;
|
|
8274
|
-
|
|
8468
|
+
const jsonString = JSON.stringify(pkgJson, null, 2).concat("\n");
|
|
8469
|
+
await fs.writeFile(pkgJsonPath, jsonString);
|
|
8275
8470
|
}
|
|
8276
8471
|
async function writeMultiBundle(modules, name2, edition, projectDir, outDir) {
|
|
8277
8472
|
for (const [moduleName, moduleSrc] of Object.entries(modules)) {
|
|
@@ -8372,11 +8567,12 @@ async function setupBiome() {
|
|
|
8372
8567
|
// src/PackagerCli.ts
|
|
8373
8568
|
var cliArgs;
|
|
8374
8569
|
async function packagerCli(rawArgs2) {
|
|
8375
|
-
cliArgs = parseArgs(rawArgs2);
|
|
8570
|
+
cliArgs = await parseArgs(rawArgs2);
|
|
8376
8571
|
await packageWgsl(cliArgs);
|
|
8377
8572
|
}
|
|
8378
|
-
function parseArgs(args) {
|
|
8379
|
-
|
|
8573
|
+
async function parseArgs(args) {
|
|
8574
|
+
const appVersion = await versionFromPackageJson();
|
|
8575
|
+
return yargs_default(args).command("$0", "create an npm package from WGSL/WESL files").version(appVersion).option("src", {
|
|
8380
8576
|
type: "string",
|
|
8381
8577
|
default: "./shaders/*.w[eg]sl",
|
|
8382
8578
|
describe: "WGSL/WESL files to bundle in the package (glob syntax)"
|
|
@@ -8404,7 +8600,13 @@ function parseArgs(args) {
|
|
|
8404
8600
|
type: "string",
|
|
8405
8601
|
default: "dist",
|
|
8406
8602
|
describe: "where to put bundled output files (relative to projectDir)"
|
|
8407
|
-
}).help().
|
|
8603
|
+
}).help().parse();
|
|
8604
|
+
}
|
|
8605
|
+
async function versionFromPackageJson() {
|
|
8606
|
+
const pkgJsonPath = new URL("../package.json", import.meta.url);
|
|
8607
|
+
const pkgModule = await import(pkgJsonPath.href, { with: { type: "json" } });
|
|
8608
|
+
const version = pkgModule.default.version;
|
|
8609
|
+
return version;
|
|
8408
8610
|
}
|
|
8409
8611
|
|
|
8410
8612
|
// src/main.ts
|
|
@@ -8425,26 +8627,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
8425
8627
|
/*! Bundled license information:
|
|
8426
8628
|
|
|
8427
8629
|
yargs-parser/build/lib/string-utils.js:
|
|
8428
|
-
(**
|
|
8429
|
-
* @license
|
|
8430
|
-
* Copyright (c) 2016, Contributors
|
|
8431
|
-
* SPDX-License-Identifier: ISC
|
|
8432
|
-
*)
|
|
8433
|
-
|
|
8434
8630
|
yargs-parser/build/lib/tokenize-arg-string.js:
|
|
8435
|
-
(**
|
|
8436
|
-
* @license
|
|
8437
|
-
* Copyright (c) 2016, Contributors
|
|
8438
|
-
* SPDX-License-Identifier: ISC
|
|
8439
|
-
*)
|
|
8440
|
-
|
|
8441
8631
|
yargs-parser/build/lib/yargs-parser-types.js:
|
|
8442
|
-
(**
|
|
8443
|
-
* @license
|
|
8444
|
-
* Copyright (c) 2016, Contributors
|
|
8445
|
-
* SPDX-License-Identifier: ISC
|
|
8446
|
-
*)
|
|
8447
|
-
|
|
8448
8632
|
yargs-parser/build/lib/yargs-parser.js:
|
|
8449
8633
|
(**
|
|
8450
8634
|
* @license
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wesl-packager",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"bin"
|
|
@@ -9,16 +9,18 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@biomejs/js-api": "^0.7.1",
|
|
11
11
|
"@biomejs/wasm-nodejs": "^1.9.4",
|
|
12
|
-
"glob": "^11.0.
|
|
13
|
-
"import-meta-resolve": "^4.1.0"
|
|
12
|
+
"glob": "^11.0.2",
|
|
13
|
+
"import-meta-resolve": "^4.1.0",
|
|
14
|
+
"wesl-tooling": "0.6.2"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
|
-
"@types/diff": "^7.0.
|
|
17
|
-
"@types/node": "^22.
|
|
17
|
+
"@types/diff": "^7.0.2",
|
|
18
|
+
"@types/node": "^22.15.17",
|
|
19
|
+
"dependent_package": "x",
|
|
18
20
|
"diff": "^7.0.0",
|
|
19
21
|
"dir-compare": "^5.0.0",
|
|
20
22
|
"picocolors": "^1.1.1",
|
|
21
|
-
"wesl": "0.6.
|
|
23
|
+
"wesl": "0.6.2"
|
|
22
24
|
},
|
|
23
25
|
"scripts": {
|
|
24
26
|
"echo": "echo",
|