@barefootjs/test 0.33.6 → 0.34.0

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/dist/index.js +60 -38
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -187295,6 +187295,29 @@ var import_typescript10 = __toESM(require_typescript(), 1);
187295
187295
 
187296
187296
  // ../jsx/src/expression-parser.ts
187297
187297
  var import_typescript = __toESM(require_typescript(), 1);
187298
+
187299
+ // ../jsx/src/lowering-registry.ts
187300
+ var plugins = [];
187301
+ function registerLoweringPlugin(plugin) {
187302
+ const existing = plugins.findIndex((p) => p.name === plugin.name);
187303
+ if (existing >= 0)
187304
+ plugins[existing] = plugin;
187305
+ else
187306
+ plugins.push(plugin);
187307
+ }
187308
+ function loweringNodeChildren(node) {
187309
+ if (node.kind === "helper-call")
187310
+ return [...node.args];
187311
+ const children = [node.base];
187312
+ for (const t of node.triples) {
187313
+ if (t.guard)
187314
+ children.push(t.guard);
187315
+ children.push(t.value);
187316
+ }
187317
+ return children;
187318
+ }
187319
+
187320
+ // ../jsx/src/expression-parser.ts
187298
187321
  var UNSUPPORTED_METHODS = new Set([
187299
187322
  "filter",
187300
187323
  "map",
@@ -187454,7 +187477,7 @@ function convertNode(node, raw) {
187454
187477
  }
187455
187478
  if (n === undefined || Number.isNaN(n)) {
187456
187479
  const parsedDepth = convertNode(depthNode, raw);
187457
- if (checkSupport(parsedDepth, "rendered").supported) {
187480
+ if (checkSupport(parsedDepth, "rendered", []).supported) {
187458
187481
  depthExpr = parsedDepth;
187459
187482
  flatDepth = 1;
187460
187483
  } else {
@@ -188232,10 +188255,10 @@ function getUnaryOperatorString(op) {
188232
188255
  return "unknown";
188233
188256
  }
188234
188257
  }
188235
- function isSupported(expr) {
188236
- return checkSupport(expr, "rendered");
188258
+ function isSupported(expr, opts) {
188259
+ return checkSupport(expr, "rendered", opts?.loweringMatchers ?? []);
188237
188260
  }
188238
- function checkSupport(expr, pos) {
188261
+ function checkSupport(expr, pos, matchers) {
188239
188262
  switch (expr.kind) {
188240
188263
  case "unsupported":
188241
188264
  return { supported: false, reason: expr.reason };
@@ -188244,7 +188267,7 @@ function checkSupport(expr, pos) {
188244
188267
  return { supported: false, reason: "Unsupported syntax: ObjectLiteralExpression" };
188245
188268
  }
188246
188269
  for (const prop of expr.properties) {
188247
- const propSupport = checkSupport(prop.kind === "spread" ? prop.expr : prop.value, pos);
188270
+ const propSupport = checkSupport(prop.kind === "spread" ? prop.expr : prop.value, pos, matchers);
188248
188271
  if (!propSupport.supported)
188249
188272
  return propSupport;
188250
188273
  }
@@ -188259,7 +188282,7 @@ function checkSupport(expr, pos) {
188259
188282
  return { supported: false, reason: "Standalone arrow functions / regex literals are not supported" };
188260
188283
  case "array-literal": {
188261
188284
  for (const el of expr.elements) {
188262
- const elSupport = checkSupport(el, pos);
188285
+ const elSupport = checkSupport(el, pos, matchers);
188263
188286
  if (!elSupport.supported)
188264
188287
  return elSupport;
188265
188288
  }
@@ -188272,28 +188295,39 @@ function checkSupport(expr, pos) {
188272
188295
  reason: `String.prototype.${expr.method} supports only a string pattern + string replacement (the regex form is deferred); use a string pattern or wrap the expression in /* @client */`
188273
188296
  };
188274
188297
  }
188275
- const objSupport = checkSupport(expr.object, pos);
188298
+ const objSupport = checkSupport(expr.object, pos, matchers);
188276
188299
  if (!objSupport.supported)
188277
188300
  return objSupport;
188278
188301
  for (const arg of expr.args) {
188279
- const argSupport = checkSupport(arg, pos);
188302
+ const argSupport = checkSupport(arg, pos, matchers);
188280
188303
  if (!argSupport.supported)
188281
188304
  return argSupport;
188282
188305
  }
188283
188306
  if (expr.method === "flat" && expr.depthExpr) {
188284
- const depthSupport = checkSupport(expr.depthExpr, pos);
188307
+ const depthSupport = checkSupport(expr.depthExpr, pos, matchers);
188285
188308
  if (!depthSupport.supported)
188286
188309
  return depthSupport;
188287
188310
  }
188288
188311
  return { supported: true, level: "L2" };
188289
188312
  }
188290
188313
  case "call": {
188314
+ for (const matcher of matchers) {
188315
+ const node = matcher(expr.callee, expr.args);
188316
+ if (!node)
188317
+ continue;
188318
+ for (const child of loweringNodeChildren(node)) {
188319
+ const childSupport = checkSupport(child, pos, matchers);
188320
+ if (!childSupport.supported)
188321
+ return childSupport;
188322
+ }
188323
+ return { supported: true, level: "L2" };
188324
+ }
188291
188325
  const cb = asCallbackMethodCall(expr);
188292
188326
  if (cb) {
188293
- const objSupport = checkSupport(cb.object, pos);
188327
+ const objSupport = checkSupport(cb.object, pos, matchers);
188294
188328
  if (!objSupport.supported)
188295
188329
  return objSupport;
188296
- const bodySupport = checkSupport(cb.arrow.body, pos);
188330
+ const bodySupport = checkSupport(cb.arrow.body, pos, matchers);
188297
188331
  if (!bodySupport.supported) {
188298
188332
  return {
188299
188333
  supported: false,
@@ -188302,13 +188336,13 @@ function checkSupport(expr, pos) {
188302
188336
  };
188303
188337
  }
188304
188338
  for (const rest of cb.args) {
188305
- const restSupport = checkSupport(rest, pos);
188339
+ const restSupport = checkSupport(rest, pos, matchers);
188306
188340
  if (!restSupport.supported)
188307
188341
  return restSupport;
188308
188342
  }
188309
188343
  return { supported: true, level: "L5" };
188310
188344
  }
188311
- const calleeSupport = checkSupport(expr.callee, pos);
188345
+ const calleeSupport = checkSupport(expr.callee, pos, matchers);
188312
188346
  if (!calleeSupport.supported) {
188313
188347
  return calleeSupport;
188314
188348
  }
@@ -188327,7 +188361,7 @@ function checkSupport(expr, pos) {
188327
188361
  return { supported: true, level: "L1" };
188328
188362
  }
188329
188363
  for (const arg of expr.args) {
188330
- const argSupport = checkSupport(arg, pos);
188364
+ const argSupport = checkSupport(arg, pos, matchers);
188331
188365
  if (!argSupport.supported) {
188332
188366
  return argSupport;
188333
188367
  }
@@ -188335,7 +188369,7 @@ function checkSupport(expr, pos) {
188335
188369
  return { supported: true, level: "L2" };
188336
188370
  }
188337
188371
  case "member": {
188338
- const objSupport = checkSupport(expr.object, pos);
188372
+ const objSupport = checkSupport(expr.object, pos, matchers);
188339
188373
  if (!objSupport.supported) {
188340
188374
  return objSupport;
188341
188375
  }
@@ -188345,19 +188379,19 @@ function checkSupport(expr, pos) {
188345
188379
  return { supported: true, level: "L2" };
188346
188380
  }
188347
188381
  case "index-access": {
188348
- const objSupport = checkSupport(expr.object, pos);
188382
+ const objSupport = checkSupport(expr.object, pos, matchers);
188349
188383
  if (!objSupport.supported)
188350
188384
  return objSupport;
188351
- const indexSupport = checkSupport(expr.index, pos);
188385
+ const indexSupport = checkSupport(expr.index, pos, matchers);
188352
188386
  if (!indexSupport.supported)
188353
188387
  return indexSupport;
188354
188388
  return { supported: true, level: "L2" };
188355
188389
  }
188356
188390
  case "binary": {
188357
- const leftSupport = checkSupport(expr.left, pos);
188391
+ const leftSupport = checkSupport(expr.left, pos, matchers);
188358
188392
  if (!leftSupport.supported)
188359
188393
  return leftSupport;
188360
- const rightSupport = checkSupport(expr.right, pos);
188394
+ const rightSupport = checkSupport(expr.right, pos, matchers);
188361
188395
  if (!rightSupport.supported)
188362
188396
  return rightSupport;
188363
188397
  if (["===", "==", "!==", "!=", ">", "<", ">=", "<="].includes(expr.op)) {
@@ -188369,7 +188403,7 @@ function checkSupport(expr, pos) {
188369
188403
  return { supported: false, reason: `Unknown operator: ${expr.op}` };
188370
188404
  }
188371
188405
  case "unary": {
188372
- const argSupport = checkSupport(expr.argument, pos);
188406
+ const argSupport = checkSupport(expr.argument, pos, matchers);
188373
188407
  if (!argSupport.supported)
188374
188408
  return argSupport;
188375
188409
  if (expr.op === "!") {
@@ -188381,25 +188415,25 @@ function checkSupport(expr, pos) {
188381
188415
  return { supported: false, reason: `Unsupported unary operator: ${expr.op}` };
188382
188416
  }
188383
188417
  case "logical": {
188384
- const leftSupport = checkSupport(expr.left, pos);
188418
+ const leftSupport = checkSupport(expr.left, pos, matchers);
188385
188419
  if (!leftSupport.supported)
188386
188420
  return leftSupport;
188387
188421
  if (expr.op === "??" && expr.right.kind === "object-literal" && expr.right.properties.length === 0) {
188388
188422
  return { supported: true, level: "L4" };
188389
188423
  }
188390
- const rightSupport = checkSupport(expr.right, pos);
188424
+ const rightSupport = checkSupport(expr.right, pos, matchers);
188391
188425
  if (!rightSupport.supported)
188392
188426
  return rightSupport;
188393
188427
  return { supported: true, level: "L4" };
188394
188428
  }
188395
188429
  case "conditional": {
188396
- const testSupport = checkSupport(expr.test, pos);
188430
+ const testSupport = checkSupport(expr.test, pos, matchers);
188397
188431
  if (!testSupport.supported)
188398
188432
  return testSupport;
188399
- const consSupport = checkSupport(expr.consequent, pos);
188433
+ const consSupport = checkSupport(expr.consequent, pos, matchers);
188400
188434
  if (!consSupport.supported)
188401
188435
  return consSupport;
188402
- const altSupport = checkSupport(expr.alternate, pos);
188436
+ const altSupport = checkSupport(expr.alternate, pos, matchers);
188403
188437
  if (!altSupport.supported)
188404
188438
  return altSupport;
188405
188439
  return { supported: true, level: "L4" };
@@ -188407,7 +188441,7 @@ function checkSupport(expr, pos) {
188407
188441
  case "template-literal": {
188408
188442
  for (const part of expr.parts) {
188409
188443
  if (part.type === "expression") {
188410
- const partSupport = checkSupport(part.expr, pos);
188444
+ const partSupport = checkSupport(part.expr, pos, matchers);
188411
188445
  if (!partSupport.supported)
188412
188446
  return partSupport;
188413
188447
  }
@@ -199072,18 +199106,6 @@ var import_typescript16 = __toESM(require_typescript(), 1);
199072
199106
 
199073
199107
  // ../jsx/src/relocate.ts
199074
199108
  var import_typescript18 = __toESM(require_typescript(), 1);
199075
-
199076
- // ../jsx/src/lowering-registry.ts
199077
- var plugins = [];
199078
- function registerLoweringPlugin(plugin) {
199079
- const existing = plugins.findIndex((p) => p.name === plugin.name);
199080
- if (existing >= 0)
199081
- plugins[existing] = plugin;
199082
- else
199083
- plugins.push(plugin);
199084
- }
199085
-
199086
- // ../jsx/src/relocate.ts
199087
199109
  var REGISTRY_SAFE_BINDING_KINDS = new Set([
199088
199110
  "global",
199089
199111
  "module-import",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/test",
3
- "version": "0.33.6",
3
+ "version": "0.34.0",
4
4
  "description": "Test utilities for BarefootJS - IR-based component testing without a browser",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -39,7 +39,7 @@
39
39
  "directory": "packages/test"
40
40
  },
41
41
  "dependencies": {
42
- "@barefootjs/jsx": "0.33.6"
42
+ "@barefootjs/jsx": "0.34.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "typescript": "^5.0.0"