@barefootjs/test 0.35.2 → 0.35.3
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/dist/index.js +32 -14
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -189624,6 +189624,8 @@ function isNonValuePosition(n, parent) {
|
|
|
189624
189624
|
return true;
|
|
189625
189625
|
if ((import_typescript7.default.isParameter(parent) || import_typescript7.default.isVariableDeclaration(parent) || import_typescript7.default.isBindingElement(parent)) && parent.name === n)
|
|
189626
189626
|
return true;
|
|
189627
|
+
if (import_typescript7.default.isBindingElement(parent) && parent.propertyName === n)
|
|
189628
|
+
return true;
|
|
189627
189629
|
if (import_typescript7.default.isTypeReferenceNode(parent))
|
|
189628
189630
|
return true;
|
|
189629
189631
|
return false;
|
|
@@ -189637,25 +189639,32 @@ function collectAstPropRefs(node, propNames, out) {
|
|
|
189637
189639
|
out.add(n.text);
|
|
189638
189640
|
});
|
|
189639
189641
|
}
|
|
189640
|
-
function
|
|
189642
|
+
function rewriteScopedValueRefs(text, names, replacementFor, opts) {
|
|
189641
189643
|
const prefix = "(";
|
|
189642
|
-
|
|
189644
|
+
let sf = import_typescript7.default.createSourceFile("__bf_scoped_rewrite.ts", `${prefix}${text}
|
|
189643
189645
|
)`, import_typescript7.default.ScriptTarget.Latest, true);
|
|
189644
|
-
|
|
189645
|
-
|
|
189646
|
-
|
|
189646
|
+
let parseDiagnostics = sf.parseDiagnostics;
|
|
189647
|
+
let usedPrefix = prefix;
|
|
189648
|
+
if (parseDiagnostics && parseDiagnostics.length > 0) {
|
|
189649
|
+
if (!opts?.allowStatements)
|
|
189650
|
+
return null;
|
|
189651
|
+
sf = import_typescript7.default.createSourceFile("__bf_scoped_rewrite.ts", text, import_typescript7.default.ScriptTarget.Latest, true);
|
|
189652
|
+
parseDiagnostics = sf.parseDiagnostics;
|
|
189653
|
+
if (parseDiagnostics && parseDiagnostics.length > 0)
|
|
189654
|
+
return null;
|
|
189655
|
+
usedPrefix = "";
|
|
189656
|
+
}
|
|
189647
189657
|
const edits = [];
|
|
189648
189658
|
walkWithScope(sf, (n, parent, shadowed) => {
|
|
189649
|
-
if (shadowed || !
|
|
189659
|
+
if (shadowed || !names.has(n.text))
|
|
189650
189660
|
return;
|
|
189651
189661
|
if (isNonValuePosition(n, parent))
|
|
189652
189662
|
return;
|
|
189653
|
-
const start = n.getStart(sf) -
|
|
189654
|
-
const end = n.getEnd() -
|
|
189663
|
+
const start = n.getStart(sf) - usedPrefix.length;
|
|
189664
|
+
const end = n.getEnd() - usedPrefix.length;
|
|
189655
189665
|
if (start < 0 || end > text.length)
|
|
189656
189666
|
return;
|
|
189657
|
-
const
|
|
189658
|
-
const value = replacementFor ? replacementFor(n.text, callerKey) : `${PROPS_PARAM}.${callerKey}`;
|
|
189667
|
+
const value = replacementFor(n.text);
|
|
189659
189668
|
if (parent && import_typescript7.default.isShorthandPropertyAssignment(parent) && parent.name === n) {
|
|
189660
189669
|
edits.push({ start, end, replacement: `${n.text}: ${value}` });
|
|
189661
189670
|
return;
|
|
@@ -189670,6 +189679,12 @@ function applyScopedPropRefRewrite(text, propRefs, propAliases, replacementFor)
|
|
|
189670
189679
|
}
|
|
189671
189680
|
return result;
|
|
189672
189681
|
}
|
|
189682
|
+
function applyScopedPropRefRewrite(text, propRefs, propAliases, replacementFor) {
|
|
189683
|
+
return rewriteScopedValueRefs(text, propRefs, (name) => {
|
|
189684
|
+
const callerKey = propAliases?.get(name) ?? name;
|
|
189685
|
+
return replacementFor ? replacementFor(name, callerKey) : `${PROPS_PARAM}.${callerKey}`;
|
|
189686
|
+
});
|
|
189687
|
+
}
|
|
189673
189688
|
function applyRegexPropRefRewrite(text, propRefs, propAliases, replacementFor) {
|
|
189674
189689
|
const { protect, restore } = createTemplateAwareStringProtector();
|
|
189675
189690
|
let result = protect(text);
|
|
@@ -198919,6 +198934,9 @@ function inferExpressionType(_node, _ctx) {
|
|
|
198919
198934
|
function replaceBranchLocalRefs(text, branchNames, resolve2) {
|
|
198920
198935
|
if (branchNames.length === 0)
|
|
198921
198936
|
return text;
|
|
198937
|
+
const astResult = rewriteScopedValueRefs(text, new Set(branchNames), resolve2, { allowStatements: true });
|
|
198938
|
+
if (astResult !== null)
|
|
198939
|
+
return astResult;
|
|
198922
198940
|
const pattern = new RegExp(`(?<![\\w$])(${branchNames.join("|")})(?![\\w$])`, "g");
|
|
198923
198941
|
return replaceInExprContexts(text, pattern, (_match, name) => resolve2(name));
|
|
198924
198942
|
}
|
|
@@ -199362,8 +199380,11 @@ function formatDateLocalNames(metadata) {
|
|
|
199362
199380
|
// ../jsx/src/ir-to-client-js/prune-unused-prop-extractions.ts
|
|
199363
199381
|
var import_typescript19 = __toESM(require_typescript(), 1);
|
|
199364
199382
|
|
|
199365
|
-
// ../jsx/src/ir-to-client-js/
|
|
199383
|
+
// ../jsx/src/ir-to-client-js/emit-reactive.ts
|
|
199366
199384
|
var import_typescript20 = __toESM(require_typescript(), 1);
|
|
199385
|
+
|
|
199386
|
+
// ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
|
|
199387
|
+
var import_typescript21 = __toESM(require_typescript(), 1);
|
|
199367
199388
|
var NO_PREAMBLE = {
|
|
199368
199389
|
lazySafe: true,
|
|
199369
199390
|
facts: { declaredNames: new Set, freeNames: new Set }
|
|
@@ -199412,9 +199433,6 @@ var INERT_BINDING_GLOBALS = new Set([
|
|
|
199412
199433
|
"decodeURI"
|
|
199413
199434
|
]);
|
|
199414
199435
|
|
|
199415
|
-
// ../jsx/src/ir-to-client-js/emit-reactive.ts
|
|
199416
|
-
var import_typescript21 = __toESM(require_typescript(), 1);
|
|
199417
|
-
|
|
199418
199436
|
// ../jsx/src/ir-to-client-js/control-flow/stringify/event-delegation.ts
|
|
199419
199437
|
var NON_BUBBLING_EVENTS = new Set([
|
|
199420
199438
|
"blur",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/test",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.3",
|
|
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.35.
|
|
42
|
+
"@barefootjs/jsx": "0.35.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"typescript": "^5.0.0"
|