@barefootjs/go-template 0.33.1 → 0.33.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/vite.js CHANGED
@@ -5,7 +5,7 @@ import { barefoot as coreBarefoot } from "@barefootjs/vite";
5
5
  import { devModuleUrl, loadManifest, resolveDevOrigin, resolveScriptAssets, toPosixRelative } from "@barefootjs/vite";
6
6
 
7
7
  // ../jsx/src/compiler.ts
8
- import ts24 from "typescript";
8
+ import ts25 from "typescript";
9
9
 
10
10
  // ../jsx/src/analyzer.ts
11
11
  import ts9 from "typescript";
@@ -2157,6 +2157,15 @@ function isBooleanAttr(name) {
2157
2157
  function escapeHtml(text) {
2158
2158
  return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
2159
2159
  }
2160
+ // ../shared/src/jsx-children-prop.ts
2161
+ function resolveJsxChildrenProp(props) {
2162
+ const prop = props.find((p) => p.name === "children");
2163
+ if (!prop)
2164
+ return [];
2165
+ if (prop.value.kind !== "jsx-children")
2166
+ return [];
2167
+ return prop.value.children ?? [];
2168
+ }
2160
2169
  // ../jsx/src/ir-to-client-js/csr-substitute.ts
2161
2170
  import ts4 from "typescript";
2162
2171
  function extractFreeIdentifiersFromText(text) {
@@ -3078,6 +3087,10 @@ var EMPTY_BOUND = new Set;
3078
3087
  var constInitializerCache = new WeakMap;
3079
3088
  var functionInfoExprCache = new WeakMap;
3080
3089
 
3090
+ // ../jsx/src/ir-to-client-js/prop-handling.ts
3091
+ var _localConstantValuesCache = new WeakMap;
3092
+ var _restSpreadNamesCache = new WeakMap;
3093
+
3081
3094
  // ../jsx/src/ir-to-client-js/control-flow/stringify/template-parse.ts
3082
3095
  var SVG_ROOT_TAGS = new Set([
3083
3096
  "svg",
@@ -3199,11 +3212,14 @@ var KEYWORDS_AND_GLOBALS = new Set([
3199
3212
  // ../jsx/src/ir-to-client-js/walk-prop-accesses.ts
3200
3213
  import ts14 from "typescript";
3201
3214
 
3215
+ // ../jsx/src/ir-to-client-js/imports.ts
3216
+ import ts16 from "typescript";
3217
+
3202
3218
  // ../jsx/src/value-references.ts
3203
3219
  import ts15 from "typescript";
3204
3220
 
3205
3221
  // ../jsx/src/relocate.ts
3206
- import ts16 from "typescript";
3222
+ import ts17 from "typescript";
3207
3223
 
3208
3224
  // ../jsx/src/lowering-registry.ts
3209
3225
  var plugins = [];
@@ -3399,10 +3415,10 @@ function formatDateLocalNames(metadata) {
3399
3415
  }
3400
3416
 
3401
3417
  // ../jsx/src/ir-to-client-js/prune-unused-prop-extractions.ts
3402
- import ts17 from "typescript";
3418
+ import ts18 from "typescript";
3403
3419
 
3404
3420
  // ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
3405
- import ts18 from "typescript";
3421
+ import ts19 from "typescript";
3406
3422
  var NO_PREAMBLE = {
3407
3423
  lazySafe: true,
3408
3424
  facts: { declaredNames: new Set, freeNames: new Set }
@@ -3452,7 +3468,7 @@ var INERT_BINDING_GLOBALS = new Set([
3452
3468
  ]);
3453
3469
 
3454
3470
  // ../jsx/src/ir-to-client-js/emit-reactive.ts
3455
- import ts19 from "typescript";
3471
+ import ts20 from "typescript";
3456
3472
 
3457
3473
  // ../jsx/src/ir-to-client-js/control-flow/stringify/event-delegation.ts
3458
3474
  var NON_BUBBLING_EVENTS = new Set([
@@ -3467,7 +3483,7 @@ var NON_BUBBLING_EVENTS = new Set([
3467
3483
  ]);
3468
3484
 
3469
3485
  // ../jsx/src/ir-to-client-js/rewrite-props-object.ts
3470
- import ts20 from "typescript";
3486
+ import ts21 from "typescript";
3471
3487
 
3472
3488
  // ../jsx/src/ir-to-client-js/source-map.ts
3473
3489
  var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -3558,15 +3574,15 @@ class SourceMapGenerator {
3558
3574
  }
3559
3575
 
3560
3576
  // ../jsx/src/preprocess-inline-jsx-callbacks.ts
3561
- import ts21 from "typescript";
3577
+ import ts22 from "typescript";
3562
3578
 
3563
3579
  // ../jsx/src/ssr-defaults.ts
3564
- import ts22 from "typescript";
3580
+ import ts23 from "typescript";
3565
3581
  var UNRESOLVED = Symbol("unresolved");
3566
3582
  var NO_RETURN = Symbol("no-return");
3567
3583
 
3568
3584
  // ../jsx/src/augment-inherited-props.ts
3569
- import ts23 from "typescript";
3585
+ import ts24 from "typescript";
3570
3586
  function collectContextConsumers(metadata) {
3571
3587
  const constants = metadata.localConstants ?? [];
3572
3588
  const contextDefaults = new Map;
@@ -3598,47 +3614,47 @@ function collectContextConsumers(metadata) {
3598
3614
  }
3599
3615
  function parseUseContextArg(source) {
3600
3616
  const expr = parseSingleExpression(source);
3601
- if (!expr || !ts23.isCallExpression(expr))
3617
+ if (!expr || !ts24.isCallExpression(expr))
3602
3618
  return null;
3603
- if (!ts23.isIdentifier(expr.expression) || expr.expression.text !== "useContext")
3619
+ if (!ts24.isIdentifier(expr.expression) || expr.expression.text !== "useContext")
3604
3620
  return null;
3605
3621
  if (expr.arguments.length !== 1)
3606
3622
  return null;
3607
3623
  const arg = expr.arguments[0];
3608
- return ts23.isIdentifier(arg) ? arg.text : null;
3624
+ return ts24.isIdentifier(arg) ? arg.text : null;
3609
3625
  }
3610
3626
  function parseCreateContextDefault(source) {
3611
3627
  const expr = parseSingleExpression(source);
3612
- if (!expr || !ts23.isCallExpression(expr))
3628
+ if (!expr || !ts24.isCallExpression(expr))
3613
3629
  return null;
3614
3630
  if (expr.arguments.length === 0)
3615
3631
  return null;
3616
3632
  const arg = expr.arguments[0];
3617
- if (ts23.isStringLiteral(arg) || ts23.isNoSubstitutionTemplateLiteral(arg))
3633
+ if (ts24.isStringLiteral(arg) || ts24.isNoSubstitutionTemplateLiteral(arg))
3618
3634
  return arg.text;
3619
- if (ts23.isNumericLiteral(arg))
3635
+ if (ts24.isNumericLiteral(arg))
3620
3636
  return Number(arg.text);
3621
- if (arg.kind === ts23.SyntaxKind.TrueKeyword)
3637
+ if (arg.kind === ts24.SyntaxKind.TrueKeyword)
3622
3638
  return true;
3623
- if (arg.kind === ts23.SyntaxKind.FalseKeyword)
3639
+ if (arg.kind === ts24.SyntaxKind.FalseKeyword)
3624
3640
  return false;
3625
3641
  return null;
3626
3642
  }
3627
3643
  function isObjectLiteralCreateContextDefault(source) {
3628
3644
  const expr = parseSingleExpression(source);
3629
- if (!expr || !ts23.isCallExpression(expr))
3645
+ if (!expr || !ts24.isCallExpression(expr))
3630
3646
  return false;
3631
3647
  if (expr.arguments.length === 0)
3632
3648
  return false;
3633
- return ts23.isObjectLiteralExpression(expr.arguments[0]);
3649
+ return ts24.isObjectLiteralExpression(expr.arguments[0]);
3634
3650
  }
3635
3651
  function parseSingleExpression(source) {
3636
- const sf = ts23.createSourceFile("__ctx.ts", `(${source})`, ts23.ScriptTarget.Latest, false);
3652
+ const sf = ts24.createSourceFile("__ctx.ts", `(${source})`, ts24.ScriptTarget.Latest, false);
3637
3653
  const stmt = sf.statements[0];
3638
- if (!stmt || !ts23.isExpressionStatement(stmt))
3654
+ if (!stmt || !ts24.isExpressionStatement(stmt))
3639
3655
  return null;
3640
3656
  let e = stmt.expression;
3641
- while (ts23.isParenthesizedExpression(e))
3657
+ while (ts24.isParenthesizedExpression(e))
3642
3658
  e = e.expression;
3643
3659
  return e;
3644
3660
  }
@@ -3663,25 +3679,25 @@ function augmentInheritedPropAccesses(ir) {
3663
3679
  const pinCoalesceLiterals = (s) => {
3664
3680
  if (!s || !s.includes(propsObj))
3665
3681
  return;
3666
- const sf = ts23.createSourceFile("__aug.ts", `(${s})`, ts23.ScriptTarget.Latest, false);
3682
+ const sf = ts24.createSourceFile("__aug.ts", `(${s})`, ts24.ScriptTarget.Latest, false);
3667
3683
  const visit = (n) => {
3668
- if (ts23.isBinaryExpression(n) && (n.operatorToken.kind === ts23.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts23.SyntaxKind.BarBarToken)) {
3684
+ if (ts24.isBinaryExpression(n) && (n.operatorToken.kind === ts24.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts24.SyntaxKind.BarBarToken)) {
3669
3685
  let left = n.left;
3670
- while (ts23.isParenthesizedExpression(left))
3686
+ while (ts24.isParenthesizedExpression(left))
3671
3687
  left = left.expression;
3672
- if (ts23.isPropertyAccessExpression(left) && ts23.isIdentifier(left.expression) && left.expression.text === propsObj) {
3688
+ if (ts24.isPropertyAccessExpression(left) && ts24.isIdentifier(left.expression) && left.expression.text === propsObj) {
3673
3689
  const name = left.name.text;
3674
3690
  let right = n.right;
3675
- while (ts23.isParenthesizedExpression(right))
3691
+ while (ts24.isParenthesizedExpression(right))
3676
3692
  right = right.expression;
3677
- if (ts23.isPrefixUnaryExpression(right))
3693
+ if (ts24.isPrefixUnaryExpression(right))
3678
3694
  right = right.operand;
3679
- const kind = ts23.isNumericLiteral(right) ? "number" : right.kind === ts23.SyntaxKind.TrueKeyword || right.kind === ts23.SyntaxKind.FalseKeyword ? "boolean" : ts23.isStringLiteralLike(right) ? "string" : null;
3695
+ const kind = ts24.isNumericLiteral(right) ? "number" : right.kind === ts24.SyntaxKind.TrueKeyword || right.kind === ts24.SyntaxKind.FalseKeyword ? "boolean" : ts24.isStringLiteralLike(right) ? "string" : null;
3680
3696
  if (kind && !coalesceLiteralTypes.has(name))
3681
3697
  coalesceLiteralTypes.set(name, kind);
3682
3698
  }
3683
3699
  }
3684
- ts23.forEachChild(n, visit);
3700
+ ts24.forEachChild(n, visit);
3685
3701
  };
3686
3702
  visit(sf);
3687
3703
  };
@@ -3792,33 +3808,33 @@ function augmentInheritedPropAccesses(ir) {
3792
3808
  }
3793
3809
  }
3794
3810
  function parseStaticStringConst(source) {
3795
- const sf = ts23.createSourceFile("__const.ts", `const __x = (${source});`, ts23.ScriptTarget.Latest, false);
3811
+ const sf = ts24.createSourceFile("__const.ts", `const __x = (${source});`, ts24.ScriptTarget.Latest, false);
3796
3812
  const stmt = sf.statements[0];
3797
- if (!stmt || !ts23.isVariableStatement(stmt))
3813
+ if (!stmt || !ts24.isVariableStatement(stmt))
3798
3814
  return null;
3799
3815
  let init = stmt.declarationList.declarations[0]?.initializer;
3800
- while (init && ts23.isParenthesizedExpression(init))
3816
+ while (init && ts24.isParenthesizedExpression(init))
3801
3817
  init = init.expression;
3802
3818
  if (!init)
3803
3819
  return null;
3804
- if (ts23.isStringLiteral(init) || ts23.isNoSubstitutionTemplateLiteral(init)) {
3820
+ if (ts24.isStringLiteral(init) || ts24.isNoSubstitutionTemplateLiteral(init)) {
3805
3821
  return init.text;
3806
3822
  }
3807
3823
  return evalStringArrayJoin(source);
3808
3824
  }
3809
3825
  function evalTemplateOfStringConsts(source, resolved) {
3810
- const sf = ts23.createSourceFile("__const.ts", `const __x = (${source});`, ts23.ScriptTarget.Latest, false);
3826
+ const sf = ts24.createSourceFile("__const.ts", `const __x = (${source});`, ts24.ScriptTarget.Latest, false);
3811
3827
  const stmt = sf.statements[0];
3812
- if (!stmt || !ts23.isVariableStatement(stmt))
3828
+ if (!stmt || !ts24.isVariableStatement(stmt))
3813
3829
  return null;
3814
3830
  let init = stmt.declarationList.declarations[0]?.initializer;
3815
- while (init && ts23.isParenthesizedExpression(init))
3831
+ while (init && ts24.isParenthesizedExpression(init))
3816
3832
  init = init.expression;
3817
- if (!init || !ts23.isTemplateExpression(init))
3833
+ if (!init || !ts24.isTemplateExpression(init))
3818
3834
  return null;
3819
3835
  let out = init.head.text;
3820
3836
  for (const span of init.templateSpans) {
3821
- if (!ts23.isIdentifier(span.expression))
3837
+ if (!ts24.isIdentifier(span.expression))
3822
3838
  return null;
3823
3839
  const value = resolved.get(span.expression.text);
3824
3840
  if (value === undefined)
@@ -3846,28 +3862,28 @@ function collectModuleStringConsts(constants) {
3846
3862
  return map;
3847
3863
  }
3848
3864
  function evalStringArrayJoin(source) {
3849
- const sf = ts23.createSourceFile("__join.ts", `const __x = (${source});`, ts23.ScriptTarget.Latest, false);
3865
+ const sf = ts24.createSourceFile("__join.ts", `const __x = (${source});`, ts24.ScriptTarget.Latest, false);
3850
3866
  const stmt = sf.statements[0];
3851
- if (!stmt || !ts23.isVariableStatement(stmt))
3867
+ if (!stmt || !ts24.isVariableStatement(stmt))
3852
3868
  return null;
3853
3869
  let node = stmt.declarationList.declarations[0]?.initializer;
3854
- while (node && ts23.isParenthesizedExpression(node))
3870
+ while (node && ts24.isParenthesizedExpression(node))
3855
3871
  node = node.expression;
3856
- if (!node || !ts23.isCallExpression(node))
3872
+ if (!node || !ts24.isCallExpression(node))
3857
3873
  return null;
3858
3874
  const callee = node.expression;
3859
- if (!ts23.isPropertyAccessExpression(callee))
3875
+ if (!ts24.isPropertyAccessExpression(callee))
3860
3876
  return null;
3861
3877
  if (callee.name.text !== "join")
3862
3878
  return null;
3863
3879
  let recv = callee.expression;
3864
- while (ts23.isParenthesizedExpression(recv))
3880
+ while (ts24.isParenthesizedExpression(recv))
3865
3881
  recv = recv.expression;
3866
- if (!ts23.isArrayLiteralExpression(recv))
3882
+ if (!ts24.isArrayLiteralExpression(recv))
3867
3883
  return null;
3868
3884
  const parts = [];
3869
3885
  for (const el of recv.elements) {
3870
- if (ts23.isStringLiteral(el) || ts23.isNoSubstitutionTemplateLiteral(el)) {
3886
+ if (ts24.isStringLiteral(el) || ts24.isNoSubstitutionTemplateLiteral(el)) {
3871
3887
  parts.push(el.text);
3872
3888
  } else {
3873
3889
  return null;
@@ -3876,7 +3892,7 @@ function evalStringArrayJoin(source) {
3876
3892
  let sep = ",";
3877
3893
  if (node.arguments.length >= 1) {
3878
3894
  const arg = node.arguments[0];
3879
- if (ts23.isStringLiteral(arg) || ts23.isNoSubstitutionTemplateLiteral(arg))
3895
+ if (ts24.isStringLiteral(arg) || ts24.isNoSubstitutionTemplateLiteral(arg))
3880
3896
  sep = arg.text;
3881
3897
  else
3882
3898
  return null;
@@ -3884,11 +3900,11 @@ function evalStringArrayJoin(source) {
3884
3900
  return parts.join(sep);
3885
3901
  }
3886
3902
  function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
3887
- if (!ts23.isElementAccessExpression(val))
3903
+ if (!ts24.isElementAccessExpression(val))
3888
3904
  return null;
3889
3905
  const obj = val.expression;
3890
3906
  const arg = val.argumentExpression;
3891
- if (!ts23.isIdentifier(obj) || !ts23.isIdentifier(arg))
3907
+ if (!ts24.isIdentifier(obj) || !ts24.isIdentifier(arg))
3892
3908
  return null;
3893
3909
  let indexPropName;
3894
3910
  let defaultKey;
@@ -3904,35 +3920,35 @@ function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
3904
3920
  const constInfo = localConstants.find((c) => c.name === obj.text && c.isModule);
3905
3921
  if (constInfo?.value === undefined)
3906
3922
  return null;
3907
- const sf = ts23.createSourceFile("__rec.ts", `(${constInfo.value})`, ts23.ScriptTarget.Latest, true);
3923
+ const sf = ts24.createSourceFile("__rec.ts", `(${constInfo.value})`, ts24.ScriptTarget.Latest, true);
3908
3924
  if (sf.statements.length !== 1)
3909
3925
  return null;
3910
3926
  const stmt = sf.statements[0];
3911
- if (!ts23.isExpressionStatement(stmt))
3927
+ if (!ts24.isExpressionStatement(stmt))
3912
3928
  return null;
3913
3929
  let parsed = stmt.expression;
3914
- while (ts23.isParenthesizedExpression(parsed))
3930
+ while (ts24.isParenthesizedExpression(parsed))
3915
3931
  parsed = parsed.expression;
3916
- if (!ts23.isObjectLiteralExpression(parsed))
3932
+ if (!ts24.isObjectLiteralExpression(parsed))
3917
3933
  return null;
3918
3934
  const entries = [];
3919
3935
  for (const prop of parsed.properties) {
3920
- if (!ts23.isPropertyAssignment(prop))
3936
+ if (!ts24.isPropertyAssignment(prop))
3921
3937
  return null;
3922
3938
  let key;
3923
- if (ts23.isIdentifier(prop.name)) {
3939
+ if (ts24.isIdentifier(prop.name)) {
3924
3940
  key = prop.name.text;
3925
- } else if (ts23.isStringLiteral(prop.name) || ts23.isNoSubstitutionTemplateLiteral(prop.name)) {
3941
+ } else if (ts24.isStringLiteral(prop.name) || ts24.isNoSubstitutionTemplateLiteral(prop.name)) {
3926
3942
  key = prop.name.text;
3927
3943
  } else {
3928
3944
  return null;
3929
3945
  }
3930
3946
  let v = prop.initializer;
3931
- while (ts23.isParenthesizedExpression(v))
3947
+ while (ts24.isParenthesizedExpression(v))
3932
3948
  v = v.expression;
3933
- if (ts23.isNumericLiteral(v)) {
3949
+ if (ts24.isNumericLiteral(v)) {
3934
3950
  entries.push({ key, value: { kind: "number", text: v.text } });
3935
- } else if (ts23.isStringLiteral(v) || ts23.isNoSubstitutionTemplateLiteral(v)) {
3951
+ } else if (ts24.isStringLiteral(v) || ts24.isNoSubstitutionTemplateLiteral(v)) {
3936
3952
  entries.push({ key, value: { kind: "string", text: v.text } });
3937
3953
  } else {
3938
3954
  return null;
@@ -4021,7 +4037,7 @@ function computeSsrSeedPlan(metadata) {
4021
4037
  // ../jsx/src/rich-type-refusal.ts
4022
4038
  var EMPTY_BINDINGS2 = new Map;
4023
4039
  // ../jsx/src/shared-program.ts
4024
- import ts25 from "typescript";
4040
+ import ts26 from "typescript";
4025
4041
  // ../jsx/src/adapters/interface.ts
4026
4042
  class BaseAdapter {
4027
4043
  renderChildren(children) {
@@ -4303,7 +4319,7 @@ class JsxAdapter extends BaseAdapter {
4303
4319
  }
4304
4320
 
4305
4321
  // ../jsx/src/adapters/template-imports.ts
4306
- import ts26 from "typescript";
4322
+ import ts27 from "typescript";
4307
4323
  var CLIENT_PACKAGE_SOURCES = new Set([
4308
4324
  "@barefootjs/client",
4309
4325
  "@barefootjs/client/runtime"
@@ -5076,7 +5092,7 @@ function dangerousInnerHtmlDiagnostic(expr, loc, reason) {
5076
5092
  };
5077
5093
  }
5078
5094
  // ../jsx/src/combine-client-js.ts
5079
- import ts27 from "typescript";
5095
+ import ts28 from "typescript";
5080
5096
  // ../jsx/src/loop-destructure.ts
5081
5097
  function isLowerableLoopDestructure(loop) {
5082
5098
  const bindings = loop.paramBindings;
@@ -5216,9 +5232,9 @@ function escapeRe(s) {
5216
5232
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5217
5233
  }
5218
5234
  // ../jsx/src/debug.ts
5219
- import ts28 from "typescript";
5220
- // ../jsx/src/profiler.ts
5221
5235
  import ts29 from "typescript";
5236
+ // ../jsx/src/profiler.ts
5237
+ import ts30 from "typescript";
5222
5238
 
5223
5239
  // ../jsx/src/index.ts
5224
5240
  registerBuiltinLoweringPlugins();
@@ -5474,31 +5490,6 @@ function goLiteral(value) {
5474
5490
  return `"${value}"`;
5475
5491
  }
5476
5492
 
5477
- // src/adapter/lib/ir-scope.ts
5478
- function collectRootScopeNodes(node) {
5479
- const out = new Set;
5480
- const visit = (n) => {
5481
- if (!n)
5482
- return;
5483
- if (n.type === "element") {
5484
- out.add(n);
5485
- return;
5486
- }
5487
- if (n.type === "if-statement") {
5488
- const s = n;
5489
- visit(s.consequent);
5490
- visit(s.alternate);
5491
- return;
5492
- }
5493
- if (n.type === "fragment") {
5494
- for (const c of n.children)
5495
- visit(c);
5496
- }
5497
- };
5498
- visit(node);
5499
- return out;
5500
- }
5501
-
5502
5493
  // src/adapter/lib/constants.ts
5503
5494
  var GO_TEMPLATE_PRIMITIVES = {
5504
5495
  "JSON.stringify": { arity: 1, emit: (args) => `bf_json ${wrapGoArg(args[0])}` },
@@ -5540,7 +5531,6 @@ class CompileState {
5540
5531
  textConsumedPropNames = new Set;
5541
5532
  presenceCheckedPropNames = new Set;
5542
5533
  stringValueNames = new Set;
5543
- rootScopeNodes = new Set;
5544
5534
  memoBackedLoopSlice = new Map;
5545
5535
  usesHtmlTemplate = false;
5546
5536
  usesFmt = false;
@@ -6885,7 +6875,7 @@ function computeObjectMemoInitialValue(ctx, memo) {
6885
6875
  }
6886
6876
 
6887
6877
  // src/adapter/memo/template-interp.ts
6888
- import ts30 from "typescript";
6878
+ import ts31 from "typescript";
6889
6879
  function computeTemplateLiteralMemoInitialValue(ctx, memo, propsParams) {
6890
6880
  const localKeyBindings = new Map;
6891
6881
  let templateValue;
@@ -7524,7 +7514,7 @@ function collectPropsReadByCtorInit(body, propsObjectName, propNames) {
7524
7514
  }
7525
7515
 
7526
7516
  // src/adapter/spread/spread-codegen.ts
7527
- import ts31 from "typescript";
7517
+ import ts32 from "typescript";
7528
7518
  function collectSpreadSlots(ctx, node) {
7529
7519
  const result = [];
7530
7520
  collectSpreadSlotsRecursive(ctx, node, result);
@@ -7763,7 +7753,7 @@ function recordIndexAccessToGoMap(ctx, val, ir) {
7763
7753
  if (val.kind !== "index-access" || val.object.kind !== "identifier" || val.index.kind !== "identifier") {
7764
7754
  return null;
7765
7755
  }
7766
- const tsVal = ts31.factory.createElementAccessExpression(ts31.factory.createIdentifier(val.object.name), ts31.factory.createIdentifier(val.index.name));
7756
+ const tsVal = ts32.factory.createElementAccessExpression(ts32.factory.createIdentifier(val.object.name), ts32.factory.createIdentifier(val.index.name));
7767
7757
  const parsed = parseRecordIndexAccess(tsVal, ir.metadata.localConstants ?? [], ir.metadata.propsParams);
7768
7758
  if (!parsed)
7769
7759
  return null;
@@ -8082,7 +8072,6 @@ class GoTemplateAdapter extends BaseAdapter {
8082
8072
  inLoop = false;
8083
8073
  bakedStaticChildLoopCache = new Map;
8084
8074
  scope = BindingScope.EMPTY;
8085
- loopKeyDepthStack = [];
8086
8075
  loopScalarItemStack = [];
8087
8076
  loopWrapperStack = [];
8088
8077
  loopVarRefCount = new Map;
@@ -8149,7 +8138,6 @@ class GoTemplateAdapter extends BaseAdapter {
8149
8138
  const hasInteractivity = hasClientInteractivity(ir);
8150
8139
  const isRootComponent = ir.root.type === "component";
8151
8140
  const isIfStatement = ir.root.type === "if-statement";
8152
- this.state.rootScopeNodes = collectRootScopeNodes(ir.root);
8153
8141
  this.state.memoBackedLoopSlice = new Map;
8154
8142
  for (const nested of findNestedComponents(ir.root)) {
8155
8143
  const memoName = this.extractMemoNameFromLoopArray(nested.loopArray);
@@ -9588,13 +9576,6 @@ ${goFields.join(`
9588
9576
  }
9589
9577
  return out;
9590
9578
  }
9591
- jsxChildrenPropNodes(props) {
9592
- for (const p of props) {
9593
- if (p.value.kind === "jsx-children")
9594
- return p.value.children;
9595
- }
9596
- return [];
9597
- }
9598
9579
  extractHtmlChildren(children) {
9599
9580
  if (children.length === 0)
9600
9581
  return null;
@@ -9605,12 +9586,20 @@ ${goFields.join(`
9605
9586
  return null;
9606
9587
  return html;
9607
9588
  }
9589
+ bakingStaticChildren = false;
9608
9590
  extractScopedHtmlChildren(children) {
9609
9591
  if (children.length === 0)
9610
9592
  return null;
9611
9593
  if (children.every((c) => c.type === "text"))
9612
9594
  return null;
9613
- const html = this.renderChildren(children);
9595
+ const prevBaking = this.bakingStaticChildren;
9596
+ this.bakingStaticChildren = true;
9597
+ let html;
9598
+ try {
9599
+ html = this.renderChildren(children);
9600
+ } finally {
9601
+ this.bakingStaticChildren = prevBaking;
9602
+ }
9614
9603
  const marker = this.renderScopeMarker(".ScopeID");
9615
9604
  const withSentinel = html.split(marker).join(`bf-s="${GoTemplateAdapter.SCOPE_SENTINEL}"`);
9616
9605
  if (!withSentinel.includes(GoTemplateAdapter.SCOPE_SENTINEL))
@@ -9630,7 +9619,7 @@ ${goFields.join(`
9630
9619
  }
9631
9620
  if (comp.name !== "Portal" && !inLoop && comp.slotId) {
9632
9621
  const suffix = slotIdToFieldSuffix(comp.slotId);
9633
- const effectiveChildren = comp.children.length > 0 ? comp.children : this.jsxChildrenPropNodes(comp.props);
9622
+ const effectiveChildren = comp.children.length > 0 ? comp.children : resolveJsxChildrenProp(comp.props);
9634
9623
  result.push({
9635
9624
  name: comp.name,
9636
9625
  slotId: comp.slotId,
@@ -10071,8 +10060,14 @@ ${goFields.join(`
10071
10060
  if (element.needsScope) {
10072
10061
  hydrationAttrs += ` ${this.renderScopeMarker(".ScopeID")}`;
10073
10062
  }
10074
- if (this.state.rootScopeNodes.has(element) && element.needsScope) {
10075
- hydrationAttrs += `{{if .BfDataKey}} data-key="{{.BfDataKey}}"{{end}}`;
10063
+ if (element.keyAttr) {
10064
+ if (element.keyAttr.value !== undefined) {
10065
+ const lowered = emitAttrValue({ kind: "expression", expr: element.keyAttr.value }, this.elementAttrEmitter, element.keyAttr.name);
10066
+ if (lowered)
10067
+ hydrationAttrs += ` ${lowered}`;
10068
+ } else if (!this.bakingStaticChildren) {
10069
+ hydrationAttrs += `{{if .BfDataKey}} data-key="{{.BfDataKey}}"{{end}}`;
10070
+ }
10076
10071
  }
10077
10072
  if (element.slotId) {
10078
10073
  hydrationAttrs += ` ${this.renderSlotMarker(element.slotId)}`;
@@ -11650,10 +11645,8 @@ ${goFields.join(`
11650
11645
  }
11651
11646
  this.loopScalarItemStack.push(this.scalarLiteralLoopGoType(loop.arrayParsed, loop.itemType) !== null);
11652
11647
  this.loopWrapperStack.push(!!loop.childComponent);
11653
- this.loopKeyDepthStack.push(loop.depth);
11654
11648
  const preambleAssignments = (loop.preamble?.declarations ?? []).map((d) => `{{$${d.name} := ${this.renderParsedExpr(d.valueParsed)}}}`).join("");
11655
11649
  const children = this.renderChildren(loop.children);
11656
- this.loopKeyDepthStack.pop();
11657
11650
  this.loopWrapperStack.pop();
11658
11651
  this.loopScalarItemStack.pop();
11659
11652
  const itemMarker = this.loopItemMarker(loop);
@@ -11694,7 +11687,6 @@ ${goFields.join(`
11694
11687
  const wasInLoopOuter = this.inLoop;
11695
11688
  this.inLoop = true;
11696
11689
  this.loopWrapperStack.push(false);
11697
- this.loopKeyDepthStack.push(loop.depth);
11698
11690
  this.loopScalarItemStack.push(this.scalarLiteralLoopGoType(loop.arrayParsed, loop.itemType) !== null);
11699
11691
  const prevScope = this.scope;
11700
11692
  this.scope = prevScope.enterLoopRow(loop);
@@ -11719,7 +11711,6 @@ ${goFields.join(`
11719
11711
  }
11720
11712
  this.scope = prevScope;
11721
11713
  this.loopScalarItemStack.pop();
11722
- this.loopKeyDepthStack.pop();
11723
11714
  this.loopWrapperStack.pop();
11724
11715
  this.inLoop = wasInLoopOuter;
11725
11716
  return `{{bfComment "loop:${loop.markerId}"}}${body}{{bfComment "/loop:${loop.markerId}"}}`;
@@ -11733,7 +11724,7 @@ ${goFields.join(`
11733
11724
  return "";
11734
11725
  }
11735
11726
  queueDynamicChildrenDefine(comp) {
11736
- const effectiveChildren = comp.children.length > 0 ? comp.children : this.jsxChildrenPropNodes(comp.props);
11727
+ const effectiveChildren = comp.children.length > 0 ? comp.children : resolveJsxChildrenProp(comp.props);
11737
11728
  if (effectiveChildren.length === 0)
11738
11729
  return null;
11739
11730
  if (this.extractTextChildren(effectiveChildren) !== null)
@@ -11752,7 +11743,7 @@ ${goFields.join(`
11752
11743
  return name;
11753
11744
  }
11754
11745
  queueLoopBodyChildrenDefine(comp) {
11755
- const effectiveChildren = comp.children.length > 0 ? comp.children : this.jsxChildrenPropNodes(comp.props);
11746
+ const effectiveChildren = comp.children.length > 0 ? comp.children : resolveJsxChildrenProp(comp.props);
11756
11747
  if (effectiveChildren.length === 0)
11757
11748
  return null;
11758
11749
  if (this.extractTextChildren(effectiveChildren) !== null)
@@ -11925,14 +11916,9 @@ ${children}`;
11925
11916
  continue;
11926
11917
  if (isDangerousInnerHtmlAttr(attr))
11927
11918
  continue;
11928
- let attrName;
11929
- if (attr.name === "className")
11930
- attrName = "class";
11931
- else if (attr.name === "key") {
11932
- const depth = this.loopKeyDepthStack.at(-1) ?? 0;
11933
- attrName = depth > 0 ? `data-key-${depth}` : "data-key";
11934
- } else
11935
- attrName = attr.name;
11919
+ if (attr.name === "key")
11920
+ continue;
11921
+ const attrName = attr.name === "className" ? "class" : attr.name;
11936
11922
  const lowered = emitAttrValue(attr.value, this.elementAttrEmitter, attrName);
11937
11923
  if (lowered)
11938
11924
  parts.push(lowered);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/go-template",
3
- "version": "0.33.1",
3
+ "version": "0.33.3",
4
4
  "description": "Go html/template adapter for BarefootJS - generates Go template files from IR",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -49,7 +49,7 @@
49
49
  "directory": "packages/adapter-go-template"
50
50
  },
51
51
  "dependencies": {
52
- "@barefootjs/shared": "0.33.1"
52
+ "@barefootjs/shared": "0.33.3"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@barefootjs/jsx": ">=0.2.0",
@@ -67,9 +67,9 @@
67
67
  },
68
68
  "devDependencies": {
69
69
  "@barefootjs/adapter-tests": "0.1.0",
70
- "@barefootjs/client": "0.33.1",
71
- "@barefootjs/jsx": "0.33.1",
72
- "@barefootjs/vite": "0.33.1",
70
+ "@barefootjs/client": "0.33.3",
71
+ "@barefootjs/jsx": "0.33.3",
72
+ "@barefootjs/vite": "0.33.3",
73
73
  "vite": "^6.0.0"
74
74
  }
75
75
  }
@@ -125,7 +125,14 @@ runAdapterConformanceTests({
125
125
  // with the `renderDivergences` entry, not an independent gap.
126
126
  'jsx-element-prop-fragment-conditional',
127
127
  ]),
128
- skipDataPoints: new Set<string>(),
128
+ skipDataPoints: new Set<string>([
129
+ // #2743: html/template's URL-context autoescape percent-encodes the
130
+ // queryHref BASE in href position (`日本語` → `%e6%97%a5…`); the JS
131
+ // reference only HTML-escapes. The bf_query helper itself is faithful —
132
+ // the divergence is Go's contextual escaper on the whole href value.
133
+ 'query-href:gen:base:markup',
134
+ 'query-href:gen:base:multibyte',
135
+ ]),
129
136
  onRenderError: (err, id) => {
130
137
  if (err instanceof GoNotAvailableError) {
131
138
  console.log(`Skipping [${id}]: ${err.message}`)