@barefootjs/test 0.5.2 → 0.6.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 +69 -15
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -190460,14 +190460,7 @@ var UNSUPPORTED_METHODS = new Set([
190460
190460
  "forEach",
190461
190461
  "flatMap",
190462
190462
  "flat",
190463
- "split",
190464
- "startsWith",
190465
- "endsWith",
190466
- "replace",
190467
190463
  "replaceAll",
190468
- "repeat",
190469
- "padStart",
190470
- "padEnd",
190471
190464
  "charAt",
190472
190465
  "charCodeAt",
190473
190466
  "codePointAt",
@@ -190478,6 +190471,12 @@ var UNSUPPORTED_METHODS = new Set([
190478
190471
  "matchAll",
190479
190472
  "search"
190480
190473
  ]);
190474
+ var LOWERED_ARRAY_METHODS = new Set([
190475
+ "includes",
190476
+ "indexOf",
190477
+ "lastIndexOf",
190478
+ "concat"
190479
+ ]);
190481
190480
  function parseExpression(expr) {
190482
190481
  const trimmed = expr.trim();
190483
190482
  if (!trimmed) {
@@ -190538,7 +190537,7 @@ function convertNode(node, raw) {
190538
190537
  }
190539
190538
  }
190540
190539
  if (callee.kind === "member" && !callee.computed) {
190541
- if (callee.property === "join" && args.length === 1) {
190540
+ if (callee.property === "join") {
190542
190541
  return { kind: "array-method", method: "join", object: callee.object, args };
190543
190542
  }
190544
190543
  if (callee.property === "includes" && args.length === 1) {
@@ -190547,27 +190546,77 @@ function convertNode(node, raw) {
190547
190546
  if ((callee.property === "indexOf" || callee.property === "lastIndexOf") && args.length === 1) {
190548
190547
  return { kind: "array-method", method: callee.property, object: callee.object, args };
190549
190548
  }
190550
- if (callee.property === "at" && args.length === 1) {
190549
+ if (callee.property === "at") {
190551
190550
  return { kind: "array-method", method: "at", object: callee.object, args };
190552
190551
  }
190553
- if (callee.property === "concat" && args.length === 1) {
190552
+ if (callee.property === "concat" && args.length <= 1) {
190554
190553
  return { kind: "array-method", method: "concat", object: callee.object, args };
190555
190554
  }
190556
- if (callee.property === "slice" && (args.length === 1 || args.length === 2)) {
190555
+ if (callee.property === "slice") {
190557
190556
  return { kind: "array-method", method: "slice", object: callee.object, args };
190558
190557
  }
190559
- if ((callee.property === "reverse" || callee.property === "toReversed") && args.length === 0) {
190558
+ if (callee.property === "reverse" || callee.property === "toReversed") {
190560
190559
  return { kind: "array-method", method: callee.property, object: callee.object, args };
190561
190560
  }
190562
- if (callee.property === "toLowerCase" && args.length === 0) {
190561
+ if (callee.property === "toLowerCase") {
190563
190562
  return { kind: "array-method", method: "toLowerCase", object: callee.object, args };
190564
190563
  }
190565
- if (callee.property === "toUpperCase" && args.length === 0) {
190564
+ if (callee.property === "toUpperCase") {
190566
190565
  return { kind: "array-method", method: "toUpperCase", object: callee.object, args };
190567
190566
  }
190568
- if (callee.property === "trim" && args.length === 0) {
190567
+ if (callee.property === "trim") {
190569
190568
  return { kind: "array-method", method: "trim", object: callee.object, args };
190570
190569
  }
190570
+ if (callee.property === "split") {
190571
+ return { kind: "array-method", method: "split", object: callee.object, args };
190572
+ }
190573
+ if (LOWERED_ARRAY_METHODS.has(callee.property)) {
190574
+ const argName = callee.property === "concat" ? "other" : "x";
190575
+ const detail = callee.property === "concat" ? "the variadic `.concat(a, b, …)` form" : `\`.${callee.property}(…)\` with ${args.length} argument(s)`;
190576
+ return {
190577
+ kind: "unsupported",
190578
+ raw,
190579
+ reason: `${detail} is not yet lowered to the Go/Mojo template adapters. Use the single-argument \`.${callee.property}(${argName})\` form, or pre-compute the value before the template.`
190580
+ };
190581
+ }
190582
+ if (callee.property === "startsWith" || callee.property === "endsWith") {
190583
+ if (args.length === 0) {
190584
+ return {
190585
+ kind: "unsupported",
190586
+ raw,
190587
+ reason: `\`.${callee.property}()\` with no search string is not lowered — JS coerces the missing argument to the string "undefined", a degenerate result. Pass an explicit search string, or pre-compute the value before the template.`
190588
+ };
190589
+ }
190590
+ return { kind: "array-method", method: callee.property, object: callee.object, args };
190591
+ }
190592
+ if (callee.property === "replace") {
190593
+ if (args.length < 2) {
190594
+ return {
190595
+ kind: "unsupported",
190596
+ raw,
190597
+ reason: `\`.replace(${args.length === 0 ? "" : "pattern"})\` needs both a pattern and a replacement — JS coerces the missing argument to the string "undefined", a degenerate result. Pass both arguments, or pre-compute the value before the template.`
190598
+ };
190599
+ }
190600
+ const patternNode = node.arguments[0];
190601
+ if (patternNode && import_typescript8.default.isRegularExpressionLiteral(patternNode)) {
190602
+ return {
190603
+ kind: "unsupported",
190604
+ raw,
190605
+ reason: "String.prototype.replace supports only a string pattern + string replacement (the regex form is deferred); use a string pattern or wrap the expression in /* @client */"
190606
+ };
190607
+ }
190608
+ const badArg = args[0].kind === "unsupported" ? args[0] : args[1].kind === "unsupported" ? args[1] : undefined;
190609
+ if (badArg && badArg.kind === "unsupported") {
190610
+ return { kind: "unsupported", raw, reason: badArg.reason };
190611
+ }
190612
+ return { kind: "array-method", method: "replace", object: callee.object, args };
190613
+ }
190614
+ if (callee.property === "repeat") {
190615
+ return { kind: "array-method", method: "repeat", object: callee.object, args };
190616
+ }
190617
+ if (callee.property === "padStart" || callee.property === "padEnd") {
190618
+ return { kind: "array-method", method: callee.property, object: callee.object, args };
190619
+ }
190571
190620
  if ((callee.property === "sort" || callee.property === "toSorted") && node.arguments.length === 1) {
190572
190621
  const comparator = extractSortComparatorFromTS(node.arguments[0], callee.property);
190573
190622
  if (comparator) {
@@ -194528,6 +194577,9 @@ function buildIfStatementChain(analyzer, ctx) {
194528
194577
  return alternate;
194529
194578
  }
194530
194579
 
194580
+ // ../jsx/src/ir-to-client-js/collect-elements.ts
194581
+ var EMPTY_RENDER_EXPRS = new Set(["null", "undefined", "false", "''", '""', "``"]);
194582
+
194531
194583
  // ../jsx/src/ir-to-client-js/identifiers.ts
194532
194584
  var KEYWORDS_AND_GLOBALS = new Set([
194533
194585
  "true",
@@ -194862,6 +194914,8 @@ var CLIENT_PACKAGE_SOURCES = new Set([
194862
194914
  "@barefootjs/client",
194863
194915
  "@barefootjs/client/runtime"
194864
194916
  ]);
194917
+ // ../jsx/src/combine-client-js.ts
194918
+ var import_typescript18 = __toESM(require_typescript(), 1);
194865
194919
  // ../jsx/src/debug.ts
194866
194920
  function escapeForIdBoundary(name) {
194867
194921
  return name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/test",
3
- "version": "0.5.2",
3
+ "version": "0.6.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.5.2"
42
+ "@barefootjs/jsx": "0.6.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "typescript": "^5.0.0"