@barefootjs/test 0.18.5 → 0.18.7

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 +187 -79
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -189250,6 +189250,32 @@ var VOID_ELEMENTS = new Set([
189250
189250
  "track",
189251
189251
  "wbr"
189252
189252
  ]);
189253
+ var SKELETON_PATH_HAZARD_TAGS = new Set([
189254
+ "table",
189255
+ "thead",
189256
+ "tbody",
189257
+ "tfoot",
189258
+ "caption",
189259
+ "colgroup",
189260
+ "col",
189261
+ "select",
189262
+ "optgroup",
189263
+ "p",
189264
+ "pre",
189265
+ "textarea",
189266
+ "listing",
189267
+ "template",
189268
+ "math"
189269
+ ]);
189270
+ var SKELETON_PATH_FORCE_CLOSE_GROUPS = [
189271
+ new Set(["a"]),
189272
+ new Set(["button"]),
189273
+ new Set(["form"]),
189274
+ new Set(["option"]),
189275
+ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]),
189276
+ new Set(["dd", "dt"]),
189277
+ new Set(["li"])
189278
+ ];
189253
189279
 
189254
189280
  // ../jsx/src/prop-rewrite.ts
189255
189281
  function collectAstPropRefs(node, propNames, out) {
@@ -189777,6 +189803,8 @@ function needsTypeBasedDetection(source) {
189777
189803
  return true;
189778
189804
  if (/\.map\s*\(/.test(source))
189779
189805
  return true;
189806
+ if (source.includes("createSelector"))
189807
+ return true;
189780
189808
  return false;
189781
189809
  }
189782
189810
  function findBrandPackageImportLoc(sourceFile, filePath) {
@@ -190753,6 +190781,7 @@ var CLIENT_EXPORTS = new Set([
190753
190781
  "createEffect",
190754
190782
  "createDisposableEffect",
190755
190783
  "createMemo",
190784
+ "createSelector",
190756
190785
  "createRoot",
190757
190786
  "onCleanup",
190758
190787
  "onMount",
@@ -192705,9 +192734,15 @@ function exprHasFunctionCalls(expr) {
192705
192734
  return found;
192706
192735
  }
192707
192736
  function rewriteBarePropRefs2(text, expr, ctx) {
192708
- const propNames = getDestructuredPropNames(ctx);
192737
+ let propNames = getDestructuredPropNames(ctx);
192709
192738
  if (!propNames)
192710
192739
  return;
192740
+ if (ctx.loopParams.size > 0) {
192741
+ const filtered = new Set([...propNames].filter((n) => !ctx.loopParams.has(n)));
192742
+ if (filtered.size === 0)
192743
+ return;
192744
+ propNames = filtered;
192745
+ }
192711
192746
  const extraPropRefs = collectBranchLocalPropRefsViaSubstitution(expr, ctx);
192712
192747
  return rewriteBarePropRefs(text, expr, propNames, extraPropRefs);
192713
192748
  }
@@ -192873,26 +192908,29 @@ function makeBindingEnv(ctx) {
192873
192908
  function parseValueExpr(trimmed) {
192874
192909
  return parseExpression(trimmed.startsWith("{") ? `(${trimmed})` : trimmed);
192875
192910
  }
192876
- function attachParsedExpressions(node) {
192911
+ var EMPTY_BOUND = new Set;
192912
+ function attachParsedExpressions(node, analyzer, bound = EMPTY_BOUND) {
192913
+ const parse2 = (trimmed) => resolveCallbackMethodFunctionReferences(parseExpression(trimmed), analyzer, bound);
192914
+ const parseValue = (trimmed) => resolveCallbackMethodFunctionReferences(parseValueExpr(trimmed), analyzer, bound);
192877
192915
  if (node.type === "expression") {
192878
192916
  const trimmed = node.expr.trim();
192879
192917
  if (trimmed)
192880
- node.parsed = parseExpression(trimmed);
192918
+ node.parsed = parse2(trimmed);
192881
192919
  } else if (node.type === "conditional" || node.type === "if-statement") {
192882
192920
  const trimmed = node.condition.trim();
192883
192921
  if (trimmed)
192884
- node.parsedCondition = parseExpression(trimmed);
192922
+ node.parsedCondition = parse2(trimmed);
192885
192923
  }
192886
192924
  if (node.type === "element") {
192887
192925
  for (const attr of node.attrs) {
192888
192926
  if (attr.value.kind === "expression") {
192889
192927
  const trimmed = attr.value.expr.trim();
192890
192928
  if (trimmed)
192891
- attr.value.parsed = parseValueExpr(trimmed);
192929
+ attr.value.parsed = parseValue(trimmed);
192892
192930
  } else if (attr.value.kind === "spread") {
192893
192931
  const trimmed = attr.value.expr.trim();
192894
192932
  if (trimmed)
192895
- attr.value.parsed = parseExpression(trimmed);
192933
+ attr.value.parsed = parse2(trimmed);
192896
192934
  }
192897
192935
  }
192898
192936
  } else if (node.type === "component") {
@@ -192900,14 +192938,14 @@ function attachParsedExpressions(node) {
192900
192938
  if (prop.value.kind === "expression") {
192901
192939
  const trimmed = prop.value.expr.trim();
192902
192940
  if (trimmed)
192903
- prop.value.parsed = parseValueExpr(trimmed);
192941
+ prop.value.parsed = parseValue(trimmed);
192904
192942
  }
192905
192943
  }
192906
192944
  } else if (node.type === "provider") {
192907
192945
  if (node.valueProp.value.kind === "expression") {
192908
192946
  const trimmed = node.valueProp.value.expr.trim();
192909
192947
  if (trimmed)
192910
- node.valueProp.value.parsed = parseValueExpr(trimmed);
192948
+ node.valueProp.value.parsed = parseValue(trimmed);
192911
192949
  }
192912
192950
  }
192913
192951
  switch (node.type) {
@@ -192916,47 +192954,51 @@ function attachParsedExpressions(node) {
192916
192954
  case "fragment":
192917
192955
  case "provider":
192918
192956
  for (const child of node.children)
192919
- attachParsedExpressions(child);
192957
+ attachParsedExpressions(child, analyzer, bound);
192920
192958
  break;
192921
192959
  case "async":
192922
- attachParsedExpressions(node.fallback);
192960
+ attachParsedExpressions(node.fallback, analyzer, bound);
192923
192961
  for (const child of node.children)
192924
- attachParsedExpressions(child);
192962
+ attachParsedExpressions(child, analyzer, bound);
192925
192963
  break;
192926
192964
  case "loop": {
192927
192965
  const trimmedArray = node.array.trim();
192928
192966
  if (trimmedArray)
192929
- node.arrayParsed = parseExpression(trimmedArray);
192967
+ node.arrayParsed = parse2(trimmedArray);
192968
+ const loopBound = new Set(bound);
192969
+ loopBound.add(node.param);
192970
+ if (node.index)
192971
+ loopBound.add(node.index);
192930
192972
  for (const child of node.children)
192931
- attachParsedExpressions(child);
192973
+ attachParsedExpressions(child, analyzer, loopBound);
192932
192974
  if (node.childComponent) {
192933
192975
  for (const child of node.childComponent.children)
192934
- attachParsedExpressions(child);
192976
+ attachParsedExpressions(child, analyzer, loopBound);
192935
192977
  }
192936
192978
  for (const nested of node.nestedComponents ?? []) {
192937
192979
  for (const child of nested.children)
192938
- attachParsedExpressions(child);
192980
+ attachParsedExpressions(child, analyzer, loopBound);
192939
192981
  }
192940
192982
  for (const frag of node.flatMapCallback?.fragments ?? []) {
192941
- attachParsedExpressions(frag.ir);
192983
+ attachParsedExpressions(frag.ir, analyzer, loopBound);
192942
192984
  }
192943
192985
  break;
192944
192986
  }
192945
192987
  case "conditional":
192946
- attachParsedExpressions(node.whenTrue);
192947
- attachParsedExpressions(node.whenFalse);
192988
+ attachParsedExpressions(node.whenTrue, analyzer, bound);
192989
+ attachParsedExpressions(node.whenFalse, analyzer, bound);
192948
192990
  break;
192949
192991
  case "if-statement":
192950
- attachParsedExpressions(node.consequent);
192992
+ attachParsedExpressions(node.consequent, analyzer, bound);
192951
192993
  if (node.alternate)
192952
- attachParsedExpressions(node.alternate);
192994
+ attachParsedExpressions(node.alternate, analyzer, bound);
192953
192995
  break;
192954
192996
  }
192955
192997
  }
192956
192998
  function jsxToIR(analyzer) {
192957
192999
  const root = buildIRRoot(analyzer);
192958
193000
  if (root)
192959
- attachParsedExpressions(root);
193001
+ attachParsedExpressions(root, analyzer);
192960
193002
  return root;
192961
193003
  }
192962
193004
  function buildIRRoot(analyzer) {
@@ -194043,8 +194085,8 @@ function extractSortComparator(callback, _method, ctx) {
194043
194085
  };
194044
194086
  }
194045
194087
  function resolveSortComparatorIdentifier(name, ctx) {
194046
- const constInfo = findLocalConst(name, ctx);
194047
- const fnInfo = findLocalFunction(name, ctx);
194088
+ const constInfo = findLocalConst(name, ctx.analyzer);
194089
+ const fnInfo = findLocalFunction(name, ctx.analyzer);
194048
194090
  if (constInfo && fnInfo)
194049
194091
  return null;
194050
194092
  if (constInfo) {
@@ -194057,6 +194099,72 @@ function resolveSortComparatorIdentifier(name, ctx) {
194057
194099
  }
194058
194100
  return null;
194059
194101
  }
194102
+ function resolveCallbackMethodFunctionReferenceIdentifier(name, analyzer) {
194103
+ const constInfo = findLocalConst(name, analyzer);
194104
+ const fnInfo = findLocalFunction(name, analyzer);
194105
+ if (constInfo && fnInfo)
194106
+ return null;
194107
+ if (constInfo) {
194108
+ const ast = parseConstInitializer(constInfo);
194109
+ return ast && (import_typescript11.default.isArrowFunction(ast) || import_typescript11.default.isFunctionExpression(ast)) ? ast : null;
194110
+ }
194111
+ if (fnInfo) {
194112
+ const ast = parseFunctionInfoAsExpr(fnInfo);
194113
+ return ast && (import_typescript11.default.isArrowFunction(ast) || import_typescript11.default.isFunctionExpression(ast)) ? ast : null;
194114
+ }
194115
+ return null;
194116
+ }
194117
+ function resolveCallbackMethodFunctionReferences(expr, analyzer, bound = EMPTY_BOUND) {
194118
+ function visit2(e, bound2) {
194119
+ switch (e.kind) {
194120
+ case "literal":
194121
+ case "identifier":
194122
+ case "regex":
194123
+ case "unsupported":
194124
+ return e;
194125
+ case "call": {
194126
+ const callee = visit2(e.callee, bound2);
194127
+ const args = e.args.map((a) => visit2(a, bound2));
194128
+ if (callee.kind === "member" && !callee.computed && CALLBACK_METHODS.has(callee.property) && args[0]?.kind === "identifier" && !bound2.has(args[0].name)) {
194129
+ const resolved = resolveCallbackMethodFunctionReferenceIdentifier(args[0].name, analyzer);
194130
+ const arrow = resolved ? tsNodeToParsedExpr(resolved) : null;
194131
+ if (arrow && arrow.kind === "arrow")
194132
+ args[0] = arrow;
194133
+ }
194134
+ return { ...e, callee, args };
194135
+ }
194136
+ case "member":
194137
+ return { ...e, object: visit2(e.object, bound2) };
194138
+ case "index-access":
194139
+ return { ...e, object: visit2(e.object, bound2), index: visit2(e.index, bound2) };
194140
+ case "binary":
194141
+ case "logical":
194142
+ return { ...e, left: visit2(e.left, bound2), right: visit2(e.right, bound2) };
194143
+ case "unary":
194144
+ return { ...e, argument: visit2(e.argument, bound2) };
194145
+ case "conditional":
194146
+ return { ...e, test: visit2(e.test, bound2), consequent: visit2(e.consequent, bound2), alternate: visit2(e.alternate, bound2) };
194147
+ case "template-literal":
194148
+ return { ...e, parts: e.parts.map((p) => p.type === "expression" ? { ...p, expr: visit2(p.expr, bound2) } : p) };
194149
+ case "array-literal":
194150
+ return { ...e, elements: e.elements.map((el) => visit2(el, bound2)) };
194151
+ case "array-method":
194152
+ return {
194153
+ ...e,
194154
+ object: visit2(e.object, bound2),
194155
+ args: e.args.map((a) => visit2(a, bound2)),
194156
+ ...e.method === "flat" && e.depthExpr ? { depthExpr: visit2(e.depthExpr, bound2) } : {}
194157
+ };
194158
+ case "object-literal":
194159
+ return { ...e, properties: e.properties.map((p) => ({ ...p, value: visit2(p.value, bound2) })) };
194160
+ case "arrow": {
194161
+ const inner = e.params.length === 0 ? bound2 : new Set([...bound2, ...e.params]);
194162
+ return { ...e, body: visit2(e.body, inner) };
194163
+ }
194164
+ }
194165
+ }
194166
+ return visit2(expr, bound);
194167
+ }
194060
194168
  function extractFilterPredicate(callback, ctx) {
194061
194169
  if (!import_typescript11.default.isArrowFunction(callback))
194062
194170
  return { result: null };
@@ -194524,13 +194632,11 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
194524
194632
  setArray(innerSort.array);
194525
194633
  }
194526
194634
  } else {
194527
- array = ctx.getJS(filterInfo.array);
194528
- arrayExpr = filterInfo.array;
194635
+ setArray(filterInfo.array);
194529
194636
  }
194530
194637
  }
194531
194638
  } else {
194532
- array = ctx.getJS(chainSource);
194533
- arrayExpr = chainSource;
194639
+ setArray(chainSource);
194534
194640
  }
194535
194641
  const callback = node.arguments[0];
194536
194642
  let param = "item";
@@ -195080,7 +195186,7 @@ function parseTemplateLiteral(expr, ctx) {
195080
195186
  }
195081
195187
  function tryResolveTemplateSpanFromConst(expr, ctx) {
195082
195188
  if (import_typescript11.default.isIdentifier(expr)) {
195083
- const constInfo = findLocalConst(expr.text, ctx);
195189
+ const constInfo = findLocalConst(expr.text, ctx.analyzer);
195084
195190
  if (!constInfo)
195085
195191
  return null;
195086
195192
  const ast = parseConstInitializer(constInfo);
@@ -195094,7 +195200,7 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
195094
195200
  if (import_typescript11.default.isElementAccessExpression(expr)) {
195095
195201
  if (!import_typescript11.default.isIdentifier(expr.expression))
195096
195202
  return null;
195097
- const constInfo = findLocalConst(expr.expression.text, ctx);
195203
+ const constInfo = findLocalConst(expr.expression.text, ctx.analyzer);
195098
195204
  if (!constInfo)
195099
195205
  return null;
195100
195206
  const ast = parseConstInitializer(constInfo);
@@ -195120,16 +195226,16 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
195120
195226
  }
195121
195227
  return null;
195122
195228
  }
195123
- function findLocalConst(name, ctx) {
195124
- const matches = ctx.analyzer.localConstants.filter((c) => c.name === name);
195229
+ function findLocalConst(name, analyzer) {
195230
+ const matches = analyzer.localConstants.filter((c) => c.name === name);
195125
195231
  if (matches.length === 0)
195126
195232
  return;
195127
195233
  const fnScoped = matches.filter((c) => !c.isModule);
195128
195234
  const pool = fnScoped.length > 0 ? fnScoped : matches;
195129
195235
  return pool[pool.length - 1];
195130
195236
  }
195131
- function findLocalFunction(name, ctx) {
195132
- const matches = ctx.analyzer.localFunctions.filter((f) => f.name === name);
195237
+ function findLocalFunction(name, analyzer) {
195238
+ const matches = analyzer.localFunctions.filter((f) => f.name === name);
195133
195239
  if (matches.length === 0)
195134
195240
  return;
195135
195241
  const fnScoped = matches.filter((f) => !f.isModule);
@@ -195171,7 +195277,9 @@ function hasDynamicTagBinding(name, sourceFile) {
195171
195277
  return found;
195172
195278
  }
195173
195279
  function tryResolveIdentifierAsTemplateLiteral(ident, ctx) {
195174
- const constInfo = findLocalConst(ident.text, ctx);
195280
+ if (ctx.loopParams.has(ident.text))
195281
+ return null;
195282
+ const constInfo = findLocalConst(ident.text, ctx.analyzer);
195175
195283
  if (!constInfo)
195176
195284
  return null;
195177
195285
  const ast = parseConstInitializer(constInfo);
@@ -195268,8 +195376,8 @@ function tryDesugarInterleaveTaggedTemplate(expr, ctx) {
195268
195376
  return rewritten ?? expr;
195269
195377
  }
195270
195378
  function resolveInterleaveTagIdentifier(name, ctx) {
195271
- const constInfo = findLocalConst(name, ctx);
195272
- const fnInfo = findLocalFunction(name, ctx);
195379
+ const constInfo = findLocalConst(name, ctx.analyzer);
195380
+ const fnInfo = findLocalFunction(name, ctx.analyzer);
195273
195381
  if (constInfo && fnInfo)
195274
195382
  return null;
195275
195383
  if (constInfo) {
@@ -195794,6 +195902,49 @@ function buildIfStatementChain(analyzer, ctx) {
195794
195902
  return alternate;
195795
195903
  }
195796
195904
 
195905
+ // ../jsx/src/ir-to-client-js/control-flow/stringify/template-parse.ts
195906
+ var SVG_ROOT_TAGS = new Set([
195907
+ "svg",
195908
+ "path",
195909
+ "circle",
195910
+ "rect",
195911
+ "line",
195912
+ "polyline",
195913
+ "polygon",
195914
+ "ellipse",
195915
+ "text",
195916
+ "tspan",
195917
+ "textPath",
195918
+ "g",
195919
+ "defs",
195920
+ "use",
195921
+ "symbol",
195922
+ "switch",
195923
+ "clipPath",
195924
+ "mask",
195925
+ "marker",
195926
+ "pattern",
195927
+ "linearGradient",
195928
+ "radialGradient",
195929
+ "stop",
195930
+ "image",
195931
+ "foreignObject",
195932
+ "filter",
195933
+ "feBlend",
195934
+ "feColorMatrix",
195935
+ "feComposite",
195936
+ "feFlood",
195937
+ "feGaussianBlur",
195938
+ "feMerge",
195939
+ "feMergeNode",
195940
+ "feMorphology",
195941
+ "feOffset",
195942
+ "feTurbulence",
195943
+ "animate",
195944
+ "animateTransform",
195945
+ "animateMotion"
195946
+ ]);
195947
+
195797
195948
  // ../jsx/src/ir-to-client-js/collect-elements.ts
195798
195949
  var EMPTY_RENDER_EXPRS = new Set(["null", "undefined", "false", "''", '""', "``"]);
195799
195950
 
@@ -196009,49 +196160,6 @@ var QUERY_HREF_SOURCES = new Set([
196009
196160
  "@barefootjs/client/runtime"
196010
196161
  ]);
196011
196162
 
196012
- // ../jsx/src/ir-to-client-js/control-flow/stringify/template-parse.ts
196013
- var SVG_ROOT_TAGS = new Set([
196014
- "svg",
196015
- "path",
196016
- "circle",
196017
- "rect",
196018
- "line",
196019
- "polyline",
196020
- "polygon",
196021
- "ellipse",
196022
- "text",
196023
- "tspan",
196024
- "textPath",
196025
- "g",
196026
- "defs",
196027
- "use",
196028
- "symbol",
196029
- "switch",
196030
- "clipPath",
196031
- "mask",
196032
- "marker",
196033
- "pattern",
196034
- "linearGradient",
196035
- "radialGradient",
196036
- "stop",
196037
- "image",
196038
- "foreignObject",
196039
- "filter",
196040
- "feBlend",
196041
- "feColorMatrix",
196042
- "feComposite",
196043
- "feFlood",
196044
- "feGaussianBlur",
196045
- "feMerge",
196046
- "feMergeNode",
196047
- "feMorphology",
196048
- "feOffset",
196049
- "feTurbulence",
196050
- "animate",
196051
- "animateTransform",
196052
- "animateMotion"
196053
- ]);
196054
-
196055
196163
  // ../jsx/src/ir-to-client-js/control-flow/stringify/event-delegation.ts
196056
196164
  var NON_BUBBLING_EVENTS = new Set([
196057
196165
  "blur",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/test",
3
- "version": "0.18.5",
3
+ "version": "0.18.7",
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.18.5"
42
+ "@barefootjs/jsx": "0.18.7"
43
43
  },
44
44
  "devDependencies": {
45
45
  "typescript": "^5.0.0"