@barefootjs/go-template 0.4.0 → 0.5.1

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.
@@ -30,6 +30,7 @@ export interface GoTemplateAdapterOptions {
30
30
  export declare class GoTemplateAdapter extends BaseAdapter implements ParsedExprEmitter, IRNodeEmitter<GoRenderCtx> {
31
31
  name: string;
32
32
  extension: string;
33
+ importMapInjection: 'html-snippet';
33
34
  private filterExprDepth;
34
35
  private filterExprUnsupported;
35
36
  /**
@@ -618,6 +619,13 @@ export declare class GoTemplateAdapter extends BaseAdapter implements ParsedExpr
618
619
  private convertConditionToGo;
619
620
  private renderConditionExpr;
620
621
  renderLoop(loop: IRLoop): string;
622
+ /**
623
+ * Per-item `<!--bf-loop-i-->` / `<!--bf-loop-i:KEY-->` start marker emitted
624
+ * inside a `{{range}}` body. Multi-root Fragment items (#1212) get the bare
625
+ * anchor; whole-item conditional items (#1665) get the key-bearing anchor so
626
+ * the client's `mapArrayAnchored` can hydrate items that render no element.
627
+ */
628
+ private loopItemMarker;
621
629
  /**
622
630
  * Find the first component child in a list of nodes
623
631
  */
@@ -1 +1 @@
1
- {"version":3,"file":"go-template-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/go-template-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAAa,EACb,MAAM,EAEN,WAAW,EACX,UAAU,EACV,MAAM,EAMN,UAAU,EAEV,cAAc,EACd,YAAY,EACZ,aAAa,EACb,UAAU,EACV,OAAO,EACP,yBAAyB,EAC1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAE3B,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,UAA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,UAAU;IAMlB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAMjC;IAED,OAAO,CAAC,cAAc;IAItB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAyElC;IAED,OAAO,CAAC,gBAAgB;IAsBxB;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,0BAA0B;IA4BlC;;;;;;;;OAQG;IACH,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,0BAA0B;IAiClC,iBAAiB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAKjD;IAED,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvC;IAED,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvC;IAED,OAAO,CAAC,kBAAkB;CAmB3B;AAED,eAAO,MAAM,iBAAiB,mBAA0B,CAAA"}
@@ -45,9 +45,11 @@ function wrapIfMultiToken(rendered) {
45
45
  return rendered;
46
46
  }
47
47
  function emitBfSort(recv, c) {
48
- const keyKind = c.key.kind;
49
- const keyName = c.key.kind === "field" ? capitalize(c.key.field) : "";
50
- return `bf_sort ${wrapIfMultiToken(recv)} "${keyKind}" "${keyName}" "${c.type}" "${c.direction}"`;
48
+ const groups = c.keys.map((k) => {
49
+ const keyName = k.key.kind === "field" ? capitalize(k.key.field) : "";
50
+ return `"${k.key.kind}" "${keyName}" "${k.type}" "${k.direction}"`;
51
+ });
52
+ return `bf_sort ${wrapIfMultiToken(recv)} ${groups.join(" ")}`;
51
53
  }
52
54
  function capitalize(s) {
53
55
  return s.length === 0 ? s : s[0].toUpperCase() + s.slice(1);
@@ -72,6 +74,7 @@ var GO_TEMPLATE_PRIMITIVES = {
72
74
  class GoTemplateAdapter extends BaseAdapter {
73
75
  name = "go-template";
74
76
  extension = ".tmpl";
77
+ importMapInjection = "html-snippet";
75
78
  filterExprDepth = 0;
76
79
  filterExprUnsupported = false;
77
80
  templatePrimitives = Object.fromEntries(Object.entries(GO_TEMPLATE_PRIMITIVES).map(([k, v]) => [k, v.emit]));
@@ -2499,6 +2502,7 @@ Options:
2499
2502
  }
2500
2503
  }
2501
2504
  const children = this.renderChildren(loop.children);
2505
+ const itemMarker = this.loopItemMarker(loop);
2502
2506
  for (const v of addedLoopVars) {
2503
2507
  const rc = (this.loopVarRefCount.get(v) ?? 1) - 1;
2504
2508
  if (rc <= 0)
@@ -2520,12 +2524,18 @@ Options:
2520
2524
  } else {
2521
2525
  filterCond = "true";
2522
2526
  }
2523
- const itemMarker2 = loop.bodyIsMultiRoot ? `{{bfComment "bf-loop-i"}}` : "";
2524
- return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}{{if ${filterCond}}}${itemMarker2}${children}{{end}}{{end}}{{bfComment "/loop:${loop.markerId}"}}`;
2527
+ return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}{{if ${filterCond}}}${itemMarker}${children}{{end}}{{end}}{{bfComment "/loop:${loop.markerId}"}}`;
2525
2528
  }
2526
- const itemMarker = loop.bodyIsMultiRoot ? `{{bfComment "bf-loop-i"}}` : "";
2527
2529
  return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}${itemMarker}${children}{{end}}{{bfComment "/loop:${loop.markerId}"}}`;
2528
2530
  }
2531
+ loopItemMarker(loop) {
2532
+ if (loop.bodyIsMultiRoot)
2533
+ return `{{bfComment "bf-loop-i"}}`;
2534
+ if (loop.bodyIsItemConditional && loop.key) {
2535
+ return `{{bfComment (printf "loop-i:%v" ${this.convertExpressionToGo(loop.key)})}}`;
2536
+ }
2537
+ return "";
2538
+ }
2529
2539
  findChildComponent(nodes) {
2530
2540
  for (const node of nodes) {
2531
2541
  if (node.type === "component") {
package/dist/build.js CHANGED
@@ -385,9 +385,11 @@ function wrapIfMultiToken(rendered) {
385
385
  return rendered;
386
386
  }
387
387
  function emitBfSort(recv, c) {
388
- const keyKind = c.key.kind;
389
- const keyName = c.key.kind === "field" ? capitalize(c.key.field) : "";
390
- return `bf_sort ${wrapIfMultiToken(recv)} "${keyKind}" "${keyName}" "${c.type}" "${c.direction}"`;
388
+ const groups = c.keys.map((k) => {
389
+ const keyName = k.key.kind === "field" ? capitalize(k.key.field) : "";
390
+ return `"${k.key.kind}" "${keyName}" "${k.type}" "${k.direction}"`;
391
+ });
392
+ return `bf_sort ${wrapIfMultiToken(recv)} ${groups.join(" ")}`;
391
393
  }
392
394
  function capitalize(s) {
393
395
  return s.length === 0 ? s : s[0].toUpperCase() + s.slice(1);
@@ -412,6 +414,7 @@ var GO_TEMPLATE_PRIMITIVES = {
412
414
  class GoTemplateAdapter extends BaseAdapter {
413
415
  name = "go-template";
414
416
  extension = ".tmpl";
417
+ importMapInjection = "html-snippet";
415
418
  filterExprDepth = 0;
416
419
  filterExprUnsupported = false;
417
420
  templatePrimitives = Object.fromEntries(Object.entries(GO_TEMPLATE_PRIMITIVES).map(([k, v]) => [k, v.emit]));
@@ -2839,6 +2842,7 @@ Options:
2839
2842
  }
2840
2843
  }
2841
2844
  const children = this.renderChildren(loop.children);
2845
+ const itemMarker = this.loopItemMarker(loop);
2842
2846
  for (const v of addedLoopVars) {
2843
2847
  const rc = (this.loopVarRefCount.get(v) ?? 1) - 1;
2844
2848
  if (rc <= 0)
@@ -2860,12 +2864,18 @@ Options:
2860
2864
  } else {
2861
2865
  filterCond = "true";
2862
2866
  }
2863
- const itemMarker2 = loop.bodyIsMultiRoot ? `{{bfComment "bf-loop-i"}}` : "";
2864
- return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}{{if ${filterCond}}}${itemMarker2}${children}{{end}}{{end}}{{bfComment "/loop:${loop.markerId}"}}`;
2867
+ return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}{{if ${filterCond}}}${itemMarker}${children}{{end}}{{end}}{{bfComment "/loop:${loop.markerId}"}}`;
2865
2868
  }
2866
- const itemMarker = loop.bodyIsMultiRoot ? `{{bfComment "bf-loop-i"}}` : "";
2867
2869
  return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}${itemMarker}${children}{{end}}{{bfComment "/loop:${loop.markerId}"}}`;
2868
2870
  }
2871
+ loopItemMarker(loop) {
2872
+ if (loop.bodyIsMultiRoot)
2873
+ return `{{bfComment "bf-loop-i"}}`;
2874
+ if (loop.bodyIsItemConditional && loop.key) {
2875
+ return `{{bfComment (printf "loop-i:%v" ${this.convertExpressionToGo(loop.key)})}}`;
2876
+ }
2877
+ return "";
2878
+ }
2869
2879
  findChildComponent(nodes) {
2870
2880
  for (const node of nodes) {
2871
2881
  if (node.type === "component") {
package/dist/index.js CHANGED
@@ -45,9 +45,11 @@ function wrapIfMultiToken(rendered) {
45
45
  return rendered;
46
46
  }
47
47
  function emitBfSort(recv, c) {
48
- const keyKind = c.key.kind;
49
- const keyName = c.key.kind === "field" ? capitalize(c.key.field) : "";
50
- return `bf_sort ${wrapIfMultiToken(recv)} "${keyKind}" "${keyName}" "${c.type}" "${c.direction}"`;
48
+ const groups = c.keys.map((k) => {
49
+ const keyName = k.key.kind === "field" ? capitalize(k.key.field) : "";
50
+ return `"${k.key.kind}" "${keyName}" "${k.type}" "${k.direction}"`;
51
+ });
52
+ return `bf_sort ${wrapIfMultiToken(recv)} ${groups.join(" ")}`;
51
53
  }
52
54
  function capitalize(s) {
53
55
  return s.length === 0 ? s : s[0].toUpperCase() + s.slice(1);
@@ -72,6 +74,7 @@ var GO_TEMPLATE_PRIMITIVES = {
72
74
  class GoTemplateAdapter extends BaseAdapter {
73
75
  name = "go-template";
74
76
  extension = ".tmpl";
77
+ importMapInjection = "html-snippet";
75
78
  filterExprDepth = 0;
76
79
  filterExprUnsupported = false;
77
80
  templatePrimitives = Object.fromEntries(Object.entries(GO_TEMPLATE_PRIMITIVES).map(([k, v]) => [k, v.emit]));
@@ -2499,6 +2502,7 @@ Options:
2499
2502
  }
2500
2503
  }
2501
2504
  const children = this.renderChildren(loop.children);
2505
+ const itemMarker = this.loopItemMarker(loop);
2502
2506
  for (const v of addedLoopVars) {
2503
2507
  const rc = (this.loopVarRefCount.get(v) ?? 1) - 1;
2504
2508
  if (rc <= 0)
@@ -2520,12 +2524,18 @@ Options:
2520
2524
  } else {
2521
2525
  filterCond = "true";
2522
2526
  }
2523
- const itemMarker2 = loop.bodyIsMultiRoot ? `{{bfComment "bf-loop-i"}}` : "";
2524
- return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}{{if ${filterCond}}}${itemMarker2}${children}{{end}}{{end}}{{bfComment "/loop:${loop.markerId}"}}`;
2527
+ return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}{{if ${filterCond}}}${itemMarker}${children}{{end}}{{end}}{{bfComment "/loop:${loop.markerId}"}}`;
2525
2528
  }
2526
- const itemMarker = loop.bodyIsMultiRoot ? `{{bfComment "bf-loop-i"}}` : "";
2527
2529
  return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}${itemMarker}${children}{{end}}{{bfComment "/loop:${loop.markerId}"}}`;
2528
2530
  }
2531
+ loopItemMarker(loop) {
2532
+ if (loop.bodyIsMultiRoot)
2533
+ return `{{bfComment "bf-loop-i"}}`;
2534
+ if (loop.bodyIsItemConditional && loop.key) {
2535
+ return `{{bfComment (printf "loop-i:%v" ${this.convertExpressionToGo(loop.key)})}}`;
2536
+ }
2537
+ return "";
2538
+ }
2529
2539
  findChildComponent(nodes) {
2530
2540
  for (const node of nodes) {
2531
2541
  if (node.type === "component") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/go-template",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
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",
@@ -54,6 +54,6 @@
54
54
  },
55
55
  "devDependencies": {
56
56
  "@barefootjs/adapter-tests": "0.1.0",
57
- "@barefootjs/jsx": "0.4.0"
57
+ "@barefootjs/jsx": "0.5.1"
58
58
  }
59
59
  }
@@ -36,6 +36,18 @@ runAdapterConformanceTests({
36
36
  // template syntax (#1266).
37
37
  skipJsx: [
38
38
  'return-map',
39
+ // #1665 whole-item loop conditional. The Go adapter correctly emits the
40
+ // per-item `<!--bf-loop-i:KEY-->` anchor, `data-key`, and conditional
41
+ // markers (verified by template-structure tests), but the array signal's
42
+ // initial value is not baked into the generated `NewXxxProps` constructor
43
+ // (`Items: nil`, unlike scalar signals such as `Sel: "b"`), so the Go SSR
44
+ // renders an empty loop. Populating signal-array initial values into the
45
+ // SSR data context is a separate pre-existing Go limitation — every other
46
+ // signal-loop fixture sidesteps it with an empty initial array. The
47
+ // anchored SSR shape with rendered items is covered by Hono + CSR
48
+ // conformance and the runtime hydration tests. Remove this skip once the
49
+ // Go limitation is fixed: https://github.com/piconic-ai/barefootjs/issues/1672
50
+ 'loop-item-conditional',
39
51
  // #1297 fixed the harness-side IR emission gate (multi-component
40
52
  // sources now emit one `ir` file per component, and the harness
41
53
  // picks the entry-point IR). The remaining gap is adapter-side:
@@ -1833,6 +1845,8 @@ import { fixture as arraySortFieldAscFixture } from '../../../adapter-tests/fixt
1833
1845
  import { fixture as arraySortFieldDescFixture } from '../../../adapter-tests/fixtures/methods/array-sort-field-desc'
1834
1846
  import { fixture as arraySortPrimitiveFixture } from '../../../adapter-tests/fixtures/methods/array-sort-primitive'
1835
1847
  import { fixture as arraySortLocaleFixture } from '../../../adapter-tests/fixtures/methods/array-sort-locale'
1848
+ import { fixture as arraySortMultiKeyFixture } from '../../../adapter-tests/fixtures/methods/array-sort-multikey'
1849
+ import { fixture as arraySortTernaryFixture } from '../../../adapter-tests/fixtures/methods/array-sort-ternary'
1836
1850
  import { fixture as arrayToSortedFixture } from '../../../adapter-tests/fixtures/methods/array-toSorted'
1837
1851
  // #1448 Tier B — .entries / .keys / .values iteration shapes.
1838
1852
  import { fixture as arrayEntriesFixture } from '../../../adapter-tests/fixtures/methods/array-entries'
@@ -1867,6 +1881,11 @@ describe('GoTemplateAdapter - #1448 Tier A/B fixture-driven lowering pins', () =
1867
1881
  { fixture: arraySortFieldDescFixture, expect: 'bf_sort .Items "field" "Price" "numeric" "desc"' },
1868
1882
  { fixture: arraySortPrimitiveFixture, expect: 'bf_sort .Nums "self" "" "numeric" "asc"' },
1869
1883
  { fixture: arraySortLocaleFixture, expect: 'bf_sort .Names "self" "" "string" "asc"' },
1884
+ // Multi-key (`||`-chain): one 4-string group per comparison key,
1885
+ // applied in priority order as tie-breakers.
1886
+ { fixture: arraySortMultiKeyFixture, expect: 'bf_sort .Items "field" "Price" "numeric" "asc" "field" "Name" "string" "asc"' },
1887
+ // Relational-ternary comparator lowers to a single `auto` key.
1888
+ { fixture: arraySortTernaryFixture, expect: 'bf_sort .Items "field" "Rank" "auto" "asc"' },
1870
1889
  { fixture: arrayToSortedFixture, expect: 'bf_sort .Nums "self" "" "numeric" "asc"' },
1871
1890
  // #1448 Tier B — iteration shapes. These are loop-level
1872
1891
  // patterns (range binding order), not helper function calls.
@@ -1890,3 +1909,172 @@ describe('GoTemplateAdapter - #1448 Tier A/B fixture-driven lowering pins', () =
1890
1909
  })
1891
1910
  }
1892
1911
  })
1912
+
1913
+ // =============================================================================
1914
+ // #1448 — `/* @client */` escape hatch for STILL-UNSUPPORTED methods
1915
+ // =============================================================================
1916
+ //
1917
+ // The catalogue in #1448 documents `/* @client */` as the universal
1918
+ // workaround for any Array/String method shape the template adapters
1919
+ // can't lower. This block pins that contract for the Go adapter: for
1920
+ // every remaining unsupported entry, wrapping the expression in
1921
+ // `/* @client */` must (a) clear the BF021/BF101 build error the bare
1922
+ // form raises and (b) emit a client-only placeholder so the Go SSR
1923
+ // pass renders valid template that the client runtime fills at
1924
+ // hydration.
1925
+ //
1926
+ // Why this matters beyond "no error": the unsupported *string* methods
1927
+ // are a silent footgun. Unlike the unsupported array methods (which
1928
+ // surface BF101 at build time), bare `.startsWith` / `.repeat` / …
1929
+ // lower to a Go method-call expression (`{{.Name.StartsWith "a"}}`)
1930
+ // that passes the adapter's gate with NO diagnostic — then explodes at
1931
+ // `go run` time with `can't evaluate field StartsWith in type string`.
1932
+ // `/* @client */` is the only escape hatch, so these tests pin it.
1933
+ describe('GoTemplateAdapter - #1448 @client escape hatch (unsupported methods)', () => {
1934
+ // Compile a single expression placed in `<div>` text position, with
1935
+ // and without the directive, and return both the build errors and
1936
+ // the emitted template.
1937
+ function emit(expr: string, client: boolean) {
1938
+ const marker = client ? '/* @client */ ' : ''
1939
+ const adapter = new GoTemplateAdapter()
1940
+ const ir = compileToIR(`
1941
+ "use client"
1942
+ import { createSignal } from "@barefootjs/client"
1943
+ export function C() {
1944
+ const [items, setItems] = createSignal<{ name: string; n: number; tags: string[] }[]>([])
1945
+ const [name, setName] = createSignal("x")
1946
+ const myCmp = (a: { n: number }, b: { n: number }) => a.n - b.n
1947
+ return <div>{${marker}${expr}}</div>
1948
+ }
1949
+ `, adapter)
1950
+ const template = adapter.generate(ir).template ?? ''
1951
+ return { errors: adapter.errors ?? [], template }
1952
+ }
1953
+
1954
+ // Same shape but the expression is a `.map()` chain that renders a
1955
+ // loop (sort follow-ups land here). The client placeholder is a
1956
+ // loop comment rather than a text comment.
1957
+ function emitLoop(chain: string, client: boolean) {
1958
+ const marker = client ? '/* @client */ ' : ''
1959
+ const adapter = new GoTemplateAdapter()
1960
+ const ir = compileToIR(`
1961
+ "use client"
1962
+ import { createSignal } from "@barefootjs/client"
1963
+ export function C() {
1964
+ const [items, setItems] = createSignal<{ name: string; n: number }[]>([])
1965
+ const myCmp = (a: { n: number }, b: { n: number }) => a.n - b.n
1966
+ return <ul>{${marker}${chain}}</ul>
1967
+ }
1968
+ `, adapter)
1969
+ const template = adapter.generate(ir).template ?? ''
1970
+ return { errors: adapter.errors ?? [], template }
1971
+ }
1972
+
1973
+ // Tier C array methods — bare form raises BF101 at build time.
1974
+ const unsupportedArray: Array<[string, string]> = [
1975
+ ['reduce', `items().reduce((a, b) => a + b.n, 0)`],
1976
+ ['flatMap', `items().flatMap(i => i.tags)`],
1977
+ ['flat', `items().flat()`],
1978
+ ]
1979
+ for (const [name, expr] of unsupportedArray) {
1980
+ test(`array .${name}: bare raises BF101, @client clears it + emits client placeholder`, () => {
1981
+ const bare = emit(expr, false)
1982
+ expect(bare.errors.some(e => e.code === 'BF101')).toBe(true)
1983
+
1984
+ const guarded = emit(expr, true)
1985
+ expect(guarded.errors).toEqual([])
1986
+ // Client-only text slot → `{{bfComment "client:sN"}}` placeholder.
1987
+ expect(guarded.template).toMatch(/bfComment "client:s\d+"/)
1988
+ // The unlowerable expression must NOT survive into the template.
1989
+ expect(guarded.template).not.toContain('.Reduce')
1990
+ expect(guarded.template).not.toContain('.FlatMap')
1991
+ })
1992
+ }
1993
+
1994
+ // Tier B/C string methods — bare form emits an INVALID Go method
1995
+ // call with NO build error (the silent footgun). `@client` is the
1996
+ // only thing that prevents the render-time crash.
1997
+ const unsupportedString: Array<[string, string, string]> = [
1998
+ ['split', `name().split(",")`, '.Name.Split'],
1999
+ ['startsWith', `name().startsWith("a")`, '.Name.StartsWith'],
2000
+ ['endsWith', `name().endsWith("z")`, '.Name.EndsWith'],
2001
+ ['replace', `name().replace("a", "b")`, '.Name.Replace'],
2002
+ ['repeat', `name().repeat(3)`, '.Name.Repeat'],
2003
+ ['padStart', `name().padStart(5, "0")`, '.Name.PadStart'],
2004
+ ['padEnd', `name().padEnd(5, "0")`, '.Name.PadEnd'],
2005
+ ['charAt', `name().charAt(0)`, '.Name.CharAt'],
2006
+ ]
2007
+ for (const [name, expr, badEmit] of unsupportedString) {
2008
+ test(`string .${name}: bare emits invalid Go method call, @client emits client placeholder`, () => {
2009
+ const bare = emit(expr, false)
2010
+ // Documents the footgun: no BF101 guard, invalid template emitted.
2011
+ expect(bare.errors.filter(e => e.code === 'BF101')).toEqual([])
2012
+ expect(bare.template).toContain(badEmit)
2013
+
2014
+ const guarded = emit(expr, true)
2015
+ expect(guarded.errors).toEqual([])
2016
+ expect(guarded.template).toMatch(/bfComment "client:s\d+"/)
2017
+ expect(guarded.template).not.toContain(badEmit)
2018
+ })
2019
+ }
2020
+
2021
+ // Tier B `.sort` / `.toSorted` follow-ups still refused with BF021.
2022
+ const unsupportedSort: Array<[string, string]> = [
2023
+ ['function-reference comparator', `items().toSorted(myCmp).map(x => <li key={x.name}>{x.name}</li>)`],
2024
+ ['localeCompare locale/options arg', `items().toSorted((a, b) => a.name.localeCompare(b.name, "ja", { numeric: true })).map(x => <li key={x.name}>{x.name}</li>)`],
2025
+ ]
2026
+ for (const [label, chain] of unsupportedSort) {
2027
+ test(`sort follow-up (${label}): bare raises BF021, @client clears it`, () => {
2028
+ const bare = compileJSX(`
2029
+ "use client"
2030
+ import { createSignal } from "@barefootjs/client"
2031
+ export function C() {
2032
+ const [items, setItems] = createSignal<{ name: string; n: number }[]>([])
2033
+ const myCmp = (a: { n: number }, b: { n: number }) => a.n - b.n
2034
+ return <ul>{${chain}}</ul>
2035
+ }
2036
+ `.trimStart(), 'test.tsx', { adapter: new GoTemplateAdapter() })
2037
+ expect(bare.errors?.some(e => e.code === 'BF021')).toBe(true)
2038
+
2039
+ const guarded = emitLoop(chain, true)
2040
+ expect(guarded.errors).toEqual([])
2041
+ // Client-only loop → `{{bfComment "loop:lN"}}…{{bfComment "/loop:lN"}}`.
2042
+ expect(guarded.template).toMatch(/bfComment "loop:l\d+"/)
2043
+ })
2044
+ }
2045
+
2046
+ // End-to-end proof via `go run`: the bare unsupported form crashes
2047
+ // the Go template execution, while the `@client` form renders a
2048
+ // `<!--bf-client:sN-->` placeholder. Skipped on hosts without Go.
2049
+ test('e2e: bare string method crashes go render, @client renders placeholder', async () => {
2050
+ const guarded = `
2051
+ "use client"
2052
+ import { createSignal } from "@barefootjs/client"
2053
+ export function C() {
2054
+ const [name, setName] = createSignal("hello")
2055
+ return <div>{/* @client */ name().repeat(3)}</div>
2056
+ }
2057
+ `
2058
+ const bareSrc = guarded.replace('/* @client */ ', '')
2059
+ try {
2060
+ const html = await renderGoTemplateComponent({
2061
+ source: guarded.trimStart(),
2062
+ adapter: new GoTemplateAdapter(),
2063
+ })
2064
+ expect(html).toContain('<!--bf-client:s0-->')
2065
+ } catch (err) {
2066
+ if (err instanceof GoNotAvailableError) {
2067
+ console.log('Skipping #1448 @client e2e: go command not found')
2068
+ return
2069
+ }
2070
+ throw err
2071
+ }
2072
+ // Bare form must fail Go template execution (no @client guard).
2073
+ await expect(
2074
+ renderGoTemplateComponent({
2075
+ source: bareSrc.trimStart(),
2076
+ adapter: new GoTemplateAdapter(),
2077
+ }),
2078
+ ).rejects.toThrow(/can't evaluate field Repeat in type string/)
2079
+ })
2080
+ })
@@ -179,21 +179,32 @@ function wrapIfMultiToken(rendered: string): string {
179
179
  * takes 4 string operands so a future `nulls` knob can grow on the
180
180
  * end without rewriting either call site (#1448 Tier B):
181
181
  *
182
- * bf_sort <recv> <keyKind> <keyName> <compareType> <direction>
182
+ * bf_sort <recv> (<keyKind> <keyName> <compareType> <direction>)+
183
183
  *
184
184
  * keyKind: "self" | "field"
185
185
  * keyName: "" when keyKind=self; capitalised field name otherwise
186
- * compareType: "numeric" | "string"
186
+ * compareType: "numeric" | "string" | "auto"
187
187
  * direction: "asc" | "desc"
188
188
  *
189
+ * The 4-string group repeats once per comparison key: a simple
190
+ * comparator emits one group; a `||`-chained multi-key comparator
191
+ * emits one per operand, applied in order as tie-breakers by the
192
+ * variadic `bf_sort` runtime.
193
+ *
189
194
  * The capitalisation mirrors the Go-side struct-field convention
190
195
  * (`bf_sort .Items "field" "Price" "numeric" "asc"`) so the runtime
191
196
  * helper's reflect lookup matches without a recapitalise step.
192
197
  */
193
198
  function emitBfSort(recv: string, c: SortComparator): string {
194
- const keyKind = c.key.kind
195
- const keyName = c.key.kind === 'field' ? capitalize(c.key.field) : ''
196
- return `bf_sort ${wrapIfMultiToken(recv)} "${keyKind}" "${keyName}" "${c.type}" "${c.direction}"`
199
+ // One 4-string group per comparison key (keyKind, keyName,
200
+ // compareType, direction). A single-key comparator emits exactly the
201
+ // pre-multi-key shape; `||`-chained keys append further groups, which
202
+ // `bf_sort`'s variadic runtime applies in order as tie-breakers.
203
+ const groups = c.keys.map((k) => {
204
+ const keyName = k.key.kind === 'field' ? capitalize(k.key.field) : ''
205
+ return `"${k.key.kind}" "${keyName}" "${k.type}" "${k.direction}"`
206
+ })
207
+ return `bf_sort ${wrapIfMultiToken(recv)} ${groups.join(' ')}`
197
208
  }
198
209
 
199
210
  function capitalize(s: string): string {
@@ -239,6 +250,9 @@ const GO_TEMPLATE_PRIMITIVES: Record<string, PrimitiveSpec> = {
239
250
  export class GoTemplateAdapter extends BaseAdapter implements ParsedExprEmitter, IRNodeEmitter<GoRenderCtx> {
240
251
  name = 'go-template'
241
252
  extension = '.tmpl'
253
+ // Template-string target with no component layer: `bf build` emits a static
254
+ // `barefoot-importmap.html` to `{{ template }}` into the page <head> (#1644).
255
+ importMapInjection = 'html-snippet' as const
242
256
 
243
257
  // Recursion-scoped state for `renderFilterExpr`. `filterExprDepth`
244
258
  // tracks nesting so the outer call resets `filterExprUnsupported`
@@ -3969,6 +3983,11 @@ export class GoTemplateAdapter extends BaseAdapter implements ParsedExprEmitter,
3969
3983
  }
3970
3984
  }
3971
3985
  const children = this.renderChildren(loop.children)
3986
+ // Build the per-item anchor marker while the loop param is still on the
3987
+ // stack, so a `bodyIsItemConditional` key expression (#1665) resolves
3988
+ // against the range item (`.` context) like `data-key` does — popping
3989
+ // first would rewrite `t.id` to `.T.ID` instead of `.ID`.
3990
+ const itemMarker = this.loopItemMarker(loop)
3972
3991
  for (const v of addedLoopVars) {
3973
3992
  const rc = (this.loopVarRefCount.get(v) ?? 1) - 1
3974
3993
  if (rc <= 0) this.loopVarRefCount.delete(v)
@@ -4006,15 +4025,29 @@ export class GoTemplateAdapter extends BaseAdapter implements ParsedExprEmitter,
4006
4025
  filterCond = 'true'
4007
4026
  }
4008
4027
 
4009
- // Per-item start marker for multi-root Fragment items (#1212).
4010
- const itemMarker = loop.bodyIsMultiRoot ? `{{bfComment "bf-loop-i"}}` : ''
4011
4028
  return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}{{if ${filterCond}}}${itemMarker}${children}{{end}}{{end}}{{bfComment "/loop:${loop.markerId}"}}`
4012
4029
  }
4013
4030
 
4014
- const itemMarker = loop.bodyIsMultiRoot ? `{{bfComment "bf-loop-i"}}` : ''
4015
4031
  return `{{bfComment "loop:${loop.markerId}"}}{{range $${rangeIndex}, $${rangeValue} := ${goArray}}}${itemMarker}${children}{{end}}{{bfComment "/loop:${loop.markerId}"}}`
4016
4032
  }
4017
4033
 
4034
+ /**
4035
+ * Per-item `<!--bf-loop-i-->` / `<!--bf-loop-i:KEY-->` start marker emitted
4036
+ * inside a `{{range}}` body. Multi-root Fragment items (#1212) get the bare
4037
+ * anchor; whole-item conditional items (#1665) get the key-bearing anchor so
4038
+ * the client's `mapArrayAnchored` can hydrate items that render no element.
4039
+ */
4040
+ private loopItemMarker(loop: { bodyIsMultiRoot?: boolean; bodyIsItemConditional?: boolean; key?: string | null }): string {
4041
+ if (loop.bodyIsMultiRoot) return `{{bfComment "bf-loop-i"}}`
4042
+ if (loop.bodyIsItemConditional && loop.key) {
4043
+ // `bfComment` prepends `bf-`, so `printf "loop-i:%v"` yields
4044
+ // `<!--bf-loop-i:KEY-->`. The key expression resolves against the
4045
+ // current range item (`.` context), matching `data-key`'s emission.
4046
+ return `{{bfComment (printf "loop-i:%v" ${this.convertExpressionToGo(loop.key)})}}`
4047
+ }
4048
+ return ''
4049
+ }
4050
+
4018
4051
  /**
4019
4052
  * Find the first component child in a list of nodes
4020
4053
  */