as-test 1.0.16 → 1.1.1

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/types.js CHANGED
@@ -60,6 +60,7 @@ export class Runtime {
60
60
  }
61
61
  export class ModeConfig {
62
62
  constructor() {
63
+ this.default = true;
63
64
  this.config = new Config();
64
65
  }
65
66
  }
package/bin/util.js CHANGED
@@ -175,7 +175,7 @@ const FUZZ_OPTION_KEYS = new Set([
175
175
  "corpusDir",
176
176
  "crashDir",
177
177
  ]);
178
- const MODE_KEYS = new Set([...TOP_LEVEL_KEYS].filter((key) => key != "modes"));
178
+ const MODE_KEYS = new Set([...TOP_LEVEL_KEYS, "default"].filter((key) => key != "modes"));
179
179
  function validateConfig(raw, configPath) {
180
180
  const issues = [];
181
181
  validateUnknownKeys(raw, TOP_LEVEL_KEYS, "$", issues);
@@ -653,6 +653,13 @@ function validateModesField(raw, key, pathPrefix, issues) {
653
653
  validateUnknownKeys(modeObj, MODE_KEYS, modePath, issues);
654
654
  validateStringField(modeObj, "$schema", modePath, issues);
655
655
  validateInputField(modeObj, "input", modePath, issues);
656
+ if ("default" in modeObj && typeof modeObj.default != "boolean") {
657
+ issues.push({
658
+ path: `${modePath}.default`,
659
+ message: "must be a boolean",
660
+ fix: 'set "default" to true or false',
661
+ });
662
+ }
656
663
  validateOutputField(modeObj, "output", modePath, issues);
657
664
  validateStringField(modeObj, "outDir", modePath, issues);
658
665
  validateStringField(modeObj, "logs", modePath, issues);
@@ -799,6 +806,9 @@ function parseModes(raw, configDir) {
799
806
  }
800
807
  if (!value || typeof value != "object" || Array.isArray(value))
801
808
  continue;
809
+ mode.default =
810
+ !("default" in value) ||
811
+ Boolean(value.default);
802
812
  mode.config = parseConfigRaw(value, join(configDir, `__mode__.${name}.json`));
803
813
  out[name] = mode;
804
814
  }
@@ -1172,6 +1182,11 @@ export function resolveModeNames(rawArgs) {
1172
1182
  }
1173
1183
  return [...new Set(names)];
1174
1184
  }
1185
+ export function getDefaultModeNames(config) {
1186
+ return Object.entries(config.modes)
1187
+ .filter(([, mode]) => mode.default !== false)
1188
+ .map(([name]) => name);
1189
+ }
1175
1190
  function appendModeTokens(out, value) {
1176
1191
  for (const token of value.split(",")) {
1177
1192
  const mode = token.trim();
package/bin/wipc.js CHANGED
@@ -31,8 +31,12 @@ export class Channel {
31
31
  return;
32
32
  const idx = this.buffer.indexOf(Channel.MAGIC);
33
33
  if (idx === -1) {
34
- this.onPassthrough(this.buffer);
35
- this.buffer = Buffer.alloc(0);
34
+ const keep = Math.min(this.buffer.length, Channel.MAGIC_PREFIX_MAX);
35
+ const flushLength = this.buffer.length - keep;
36
+ if (flushLength > 0) {
37
+ this.onPassthrough(this.buffer.subarray(0, flushLength));
38
+ this.buffer = this.buffer.subarray(flushLength);
39
+ }
36
40
  return;
37
41
  }
38
42
  if (idx > 0) {
@@ -77,3 +81,4 @@ export class Channel {
77
81
  }
78
82
  Channel.MAGIC = Buffer.from("WIPC");
79
83
  Channel.HEADER_SIZE = 9;
84
+ Channel.MAGIC_PREFIX_MAX = Channel.MAGIC.length - 1;
@@ -0,0 +1 @@
1
+ export declare function instantiate(imports: WebAssembly.Imports): Promise<WebAssembly.Instance>;