@barefootjs/xslate 0.16.0 → 0.17.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 (50) hide show
  1. package/dist/adapter/analysis/component-tree.d.ts +30 -0
  2. package/dist/adapter/analysis/component-tree.d.ts.map +1 -0
  3. package/dist/adapter/emit-context.d.ts +94 -0
  4. package/dist/adapter/emit-context.d.ts.map +1 -0
  5. package/dist/adapter/expr/array-method.d.ts +63 -0
  6. package/dist/adapter/expr/array-method.d.ts.map +1 -0
  7. package/dist/adapter/expr/emitters.d.ts +97 -0
  8. package/dist/adapter/expr/emitters.d.ts.map +1 -0
  9. package/dist/adapter/expr/operand.d.ts +25 -0
  10. package/dist/adapter/expr/operand.d.ts.map +1 -0
  11. package/dist/adapter/index.js +1428 -1326
  12. package/dist/adapter/lib/constants.d.ts +22 -0
  13. package/dist/adapter/lib/constants.d.ts.map +1 -0
  14. package/dist/adapter/lib/ir-scope.d.ts +34 -0
  15. package/dist/adapter/lib/ir-scope.d.ts.map +1 -0
  16. package/dist/adapter/lib/kolon-naming.d.ts +22 -0
  17. package/dist/adapter/lib/kolon-naming.d.ts.map +1 -0
  18. package/dist/adapter/lib/types.d.ts +27 -0
  19. package/dist/adapter/lib/types.d.ts.map +1 -0
  20. package/dist/adapter/memo/seed.d.ts +38 -0
  21. package/dist/adapter/memo/seed.d.ts.map +1 -0
  22. package/dist/adapter/props/prop-classes.d.ts +32 -0
  23. package/dist/adapter/props/prop-classes.d.ts.map +1 -0
  24. package/dist/adapter/spread/spread-codegen.d.ts +69 -0
  25. package/dist/adapter/spread/spread-codegen.d.ts.map +1 -0
  26. package/dist/adapter/value/parsed-literal.d.ts +32 -0
  27. package/dist/adapter/value/parsed-literal.d.ts.map +1 -0
  28. package/dist/adapter/xslate-adapter.d.ts +38 -92
  29. package/dist/adapter/xslate-adapter.d.ts.map +1 -1
  30. package/dist/build.js +1428 -1326
  31. package/dist/index.js +1428 -1326
  32. package/lib/BarefootJS/Backend/Xslate.pm +1 -1
  33. package/package.json +3 -3
  34. package/src/__tests__/query-href.test.ts +96 -0
  35. package/src/__tests__/xslate-adapter.test.ts +55 -0
  36. package/src/adapter/analysis/component-tree.ts +123 -0
  37. package/src/adapter/emit-context.ts +104 -0
  38. package/src/adapter/expr/array-method.ts +311 -0
  39. package/src/adapter/expr/emitters.ts +530 -0
  40. package/src/adapter/expr/operand.ts +35 -0
  41. package/src/adapter/lib/constants.ts +34 -0
  42. package/src/adapter/lib/ir-scope.ts +64 -0
  43. package/src/adapter/lib/kolon-naming.ts +27 -0
  44. package/src/adapter/lib/types.ts +30 -0
  45. package/src/adapter/memo/seed.ts +125 -0
  46. package/src/adapter/props/prop-classes.ts +64 -0
  47. package/src/adapter/spread/spread-codegen.ts +179 -0
  48. package/src/adapter/value/parsed-literal.ts +80 -0
  49. package/src/adapter/xslate-adapter.ts +169 -1233
  50. package/src/test-render.ts +3 -0
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Component-tree analysis for the Text::Xslate (Kolon) template adapter.
3
+ *
4
+ * Extracted from `xslate-adapter.ts` (domain-module refactor, issue #2018
5
+ * track D). Pure functions over the IR — they read no adapter instance
6
+ * state. `collectImportedLoopChildComponentErrors` returns its diagnostics
7
+ * instead of pushing onto the adapter's error list, so the adapter stays the
8
+ * sole owner of `errors`.
9
+ *
10
+ * SHARED CANDIDATE: `hasClientInteractivity` is byte-identical to the Mojo
11
+ * adapter's copy and adapter-agnostic; the BF103 loop-child check is the same
12
+ * structural walk in both, differing only in the Perl/Kolon diagnostic text —
13
+ * both are groundwork for a shared Perl-family codegen module (issue #2018
14
+ * track D).
15
+ */
16
+ import type { ComponentIR, CompilerError } from '@barefootjs/jsx';
17
+ /**
18
+ * Whether the component needs the client runtime — it owns reactive state
19
+ * (signals / effects / onMount) or the analyzer flagged it as needing init.
20
+ */
21
+ export declare function hasClientInteractivity(ir: ComponentIR): boolean;
22
+ /**
23
+ * Build a `BF103` diagnostic for every component reference inside a loop body
24
+ * whose name is imported from a relative-path module. Mirror of the Go
25
+ * adapter's check — the Xslate adapter has the same cross-template-registration
26
+ * constraint at request time. Returns the diagnostics so the caller pushes
27
+ * them onto its own error list.
28
+ */
29
+ export declare function collectImportedLoopChildComponentErrors(ir: ComponentIR, componentName: string): CompilerError[];
30
+ //# sourceMappingURL=component-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-tree.d.ts","sourceRoot":"","sources":["../../../src/adapter/analysis/component-tree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,WAAW,EAUX,aAAa,EACd,MAAM,iBAAiB,CAAA;AAExB;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAO/D;AAED;;;;;;GAMG;AACH,wBAAgB,uCAAuC,CACrD,EAAE,EAAE,WAAW,EACf,aAAa,EAAE,MAAM,GACpB,aAAa,EAAE,CAqEjB"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * The contract the extracted expression-emitter modules depend on instead of
3
+ * the concrete `XslateAdapter`.
4
+ *
5
+ * The Xslate adapter's top-level expression lowering is mutually recursive
6
+ * with the adapter's own const/record resolution and its filter-predicate
7
+ * emitter, so the extracted `XslateTopLevelEmitter` still needs to call back
8
+ * into shared per-compile state and recursive entry points. `XslateEmitContext`
9
+ * is that seam: the emitter takes a `XslateEmitContext` built by the adapter's
10
+ * private `emitCtx` getter (the adapter does NOT `implements` this interface,
11
+ * so the wrapped members stay private and off its exported public type —
12
+ * matching the Go adapter's `emitCtx`). The emitter depends on this narrow
13
+ * interface rather than the full ~2.5k-line class, so the coupling is explicit
14
+ * and it's unit-testable against a stub.
15
+ *
16
+ * Keep this surface minimal: add a member only when an extracted module
17
+ * genuinely needs it, so the seam documents the real cross-module coupling
18
+ * rather than re-exposing the whole adapter.
19
+ */
20
+ import type { ParsedExpr, CompilerError, IRMetadata } from '@barefootjs/jsx';
21
+ export interface XslateEmitContext {
22
+ /**
23
+ * (#1922) Local binding names the request-scoped `searchParams()` env signal
24
+ * is imported under. Non-empty enables the env-signal method-call lowering.
25
+ */
26
+ readonly _searchParamsLocals: Set<string>;
27
+ /**
28
+ * Inline a module-scope pure string-literal const by name as the resolved
29
+ * literal value, or null when the name is not such a const.
30
+ */
31
+ _resolveModuleStringConst(name: string): string | null;
32
+ /** Resolve a literal const (`const totalPages = 5`) to its Kolon value, or null. */
33
+ _resolveLiteralConst(name: string): string | null;
34
+ /**
35
+ * Resolve a static property access on a module object-literal const
36
+ * (`variantClasses.ghost`) to its Kolon value at compile time, or null.
37
+ */
38
+ _resolveStaticRecordLiteral(objectName: string, key: string): string | null;
39
+ /** Record a BF101 unsupported-expression diagnostic. */
40
+ _recordExprBF101(message: string, reason?: string): void;
41
+ /** Lower a filter/predicate body to its Kolon form, bound to `param`. */
42
+ _renderKolonFilterExprPublic(expr: ParsedExpr, param: string): string;
43
+ }
44
+ /**
45
+ * The contract the extracted object-literal / conditional-spread lowering
46
+ * (`spread/spread-codegen.ts`) depends on. The spread lowering recurses into
47
+ * the core expression lowering and records its own BF101 diagnostics, so it
48
+ * needs the recursive entry point plus the per-compile bookkeeping the
49
+ * adapter owns. Declared separately from `XslateEmitContext` so each
50
+ * extracted module's real coupling is documented precisely.
51
+ */
52
+ export interface XslateSpreadContext {
53
+ /** Component name, for diagnostic source locations. */
54
+ readonly componentName: string;
55
+ /** Per-compile diagnostic list the spread lowering appends to. */
56
+ readonly errors: CompilerError[];
57
+ /** Local-constant metadata, for resolving `Record[key]` spread values. */
58
+ readonly localConstants: IRMetadata['localConstants'];
59
+ /** Prop params, for classifying a bare-identifier index as a prop. */
60
+ readonly propsParams: {
61
+ name: string;
62
+ }[];
63
+ /**
64
+ * Lower a JS expression to its Kolon form (the core recursive entry).
65
+ *
66
+ * When the IR already carries a structured `ParsedExpr` tree, pass it as
67
+ * `preParsed` so the converter threads it straight through instead of
68
+ * re-parsing `expr` — mirrors go-template's
69
+ * `convertExpressionToGo(jsExpr, out?, preParsed?)`. With `preParsed` set,
70
+ * `expr` is unused for parsing (the converter derives any diagnostic text
71
+ * from the tree), so callers may pass `''`.
72
+ */
73
+ convertExpressionToKolon(expr: string, preParsed?: ParsedExpr): string;
74
+ }
75
+ /**
76
+ * The contract the extracted in-template memo / context seeding
77
+ * (`memo/seed.ts`) depends on. The seed lowering recurses into the core
78
+ * expression lowering to compute a derived signal/memo value or a context
79
+ * default; that recursive entry is its only adapter coupling.
80
+ */
81
+ export interface XslateMemoContext {
82
+ /**
83
+ * Lower a JS expression to its Kolon form (the core recursive entry).
84
+ *
85
+ * When the IR already carries a structured `ParsedExpr` tree, pass it as
86
+ * `preParsed` so the converter threads it straight through instead of
87
+ * re-parsing `expr` — mirrors go-template's
88
+ * `convertExpressionToGo(jsExpr, out?, preParsed?)`. With `preParsed` set,
89
+ * `expr` is unused for parsing (the converter derives any diagnostic text
90
+ * from the tree), so callers may pass `''`.
91
+ */
92
+ convertExpressionToKolon(expr: string, preParsed?: ParsedExpr): string;
93
+ }
94
+ //# sourceMappingURL=emit-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit-context.d.ts","sourceRoot":"","sources":["../../src/adapter/emit-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5E,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAEzC;;;OAGG;IACH,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAEtD,oFAAoF;IACpF,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAEjD;;;OAGG;IACH,2BAA2B,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAE3E,wDAAwD;IACxD,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAExD,yEAAyE;IACzE,4BAA4B,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CACtE;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAClC,uDAAuD;IACvD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAE9B,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,CAAA;IAEhC,0EAA0E;IAC1E,QAAQ,CAAC,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAA;IAErD,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAExC;;;;;;;;;OASG;IACH,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,UAAU,GAAG,MAAM,CAAA;CACvE;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;;OASG;IACH,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,UAAU,GAAG,MAAM,CAAA;CACvE"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Array / string method lowering for the Text::Xslate (Kolon) template adapter.
3
+ *
4
+ * Extracted from `xslate-adapter.ts` (domain-module refactor, issue #2018
5
+ * track D). Pure free functions shared by both the filter-context emitter and
6
+ * the top-level emitter — they take an `emit` callback for receiver / argument
7
+ * recursion and read no adapter instance state.
8
+ *
9
+ * The receiver/array helpers are the same runtime methods the Mojo adapter
10
+ * calls, invoked as `$bf.NAME(...)` on the Kolon `$bf` object instead of
11
+ * `bf->NAME`.
12
+ */
13
+ import type { ParsedExpr, ArrayMethod, SortComparator, FlatDepth } from '@barefootjs/jsx';
14
+ export declare function renderArrayMethod(method: ArrayMethod, object: ParsedExpr, args: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
15
+ /**
16
+ * Emit a `.sort(cmp)` / `.toSorted(cmp)` via the runtime evaluator (#2018):
17
+ * the comparator body travels as serialized-ParsedExpr JSON, evaluated per
18
+ * comparison against `{paramA, paramB, …captured}`. Returns null when the
19
+ * body is outside the evaluator surface (e.g. a `localeCompare` comparator —
20
+ * `serializeParsedExpr` refuses it), so the caller falls back to the
21
+ * structured `$bf.sort`. `params` are the comparator arrow's two params
22
+ * (`[paramA, paramB]`).
23
+ */
24
+ export declare function renderSortEval(recv: string, body: ParsedExpr, params: string[], emit: (e: ParsedExpr) => string): string | null;
25
+ /**
26
+ * Emit a `.reduce(fn, init)` / `.reduceRight(fn, init)` via the runtime
27
+ * evaluator (#2018): the reducer body travels as serialized-ParsedExpr JSON,
28
+ * folded over the receiver from `init` in `direction` order. `params` are the
29
+ * reducer arrow's params (`[paramAcc, paramItem]`); `init` is the initial-value
30
+ * `ParsedExpr` from the call's trailing argument. Returns null when the body is
31
+ * outside the evaluator surface, or when `init` is not a literal string/number
32
+ * (→ caller refuses with BF101). A numeric seed passes through as a bare Perl
33
+ * number; a string seed as a single-quoted literal.
34
+ */
35
+ export declare function renderReduceEval(recv: string, body: ParsedExpr, params: string[], init: ParsedExpr, direction: 'left' | 'right', emit: (e: ParsedExpr) => string): string | null;
36
+ /**
37
+ * Emit a higher-order predicate call via the runtime evaluator (#2018, P2):
38
+ * `$bf.filter_eval` / `$bf.every_eval` / `$bf.some_eval` / `$bf.find_eval` /
39
+ * `$bf.find_index_eval`, carrying the serialized predicate body + captured env
40
+ * hashref. Generalizes the Kolon-lambda `$bf.filter` lowering to the same
41
+ * JS-faithful evaluator the Go adapter uses (cross-adapter isomorphism).
42
+ * Returns null when the predicate is outside the evaluator surface (e.g. a
43
+ * method-call predicate — `serializeParsedExpr` refuses it), so the caller
44
+ * falls back to the lambda form. `forward` (find / findIndex family only)
45
+ * selects the search direction — `false` = findLast / findLastIndex.
46
+ */
47
+ export declare function renderPredicateEval(funcName: string, recv: string, predicate: ParsedExpr, param: string, emit: (e: ParsedExpr) => string, forward?: boolean): string | null;
48
+ /**
49
+ * Emit a `.flatMap(proj)` via the runtime evaluator (#2018, P3): the projection
50
+ * body serializes to JSON and `$bf.flat_map_eval` projects + flattens one
51
+ * level. `param` is the projection arrow's single param. Returns null when the
52
+ * projection is outside the evaluator surface (→ caller refuses with BF101).
53
+ */
54
+ export declare function renderFlatMapEval(recv: string, body: ParsedExpr, param: string, emit: (e: ParsedExpr) => string): string | null;
55
+ /**
56
+ * Shared Kolon emit for `.sort(cmp)` / `.toSorted(cmp)`. Used by both the
57
+ * filter-context emitter and the top-level emitter, plus the loop-array
58
+ * wrap in `renderLoop`. The runtime `$bf.sort` accepts a hashref opts bag and
59
+ * returns a fresh array ref.
60
+ */
61
+ export declare function renderSortMethod(recv: string, c: SortComparator): string;
62
+ export declare function renderFlatMethod(recv: string, depth: FlatDepth): string;
63
+ //# sourceMappingURL=array-method.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array-method.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/array-method.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,cAAc,EACd,SAAS,EACV,MAAM,iBAAiB,CAAA;AAExB,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,EAAE,EAClB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CA4HR;AA6BD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EAAE,EAChB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,GAAG,IAAI,CAUf;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EAAE,EAChB,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,MAAM,GAAG,OAAO,EAC3B,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,GAAG,IAAI,CAkBf;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,UAAU,EACrB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,EAC/B,OAAO,CAAC,EAAE,OAAO,GAChB,MAAM,GAAG,IAAI,CAMf;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,GAAG,IAAI,CAKf;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,cAAc,GAAG,MAAM,CASxE;AAGD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,MAAM,CAGvE"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * ParsedExpr → Kolon emitters for the Text::Xslate template adapter.
3
+ *
4
+ * Extracted from `xslate-adapter.ts` (domain-module refactor, issue #2018
5
+ * track D). Two `ParsedExprEmitter` implementations:
6
+ *
7
+ * - `XslateFilterEmitter` — filter/predicate context (loop param + local
8
+ * aliases + bare `$name` signal fallback); self-contained, reads no
9
+ * adapter state.
10
+ * - `XslateTopLevelEmitter` — top-level / per-render-var context; depends on
11
+ * the adapter only through the narrow `XslateEmitContext` seam.
12
+ */
13
+ import { type ParsedExprEmitter, type ArrayMethod, type LiteralType, type ParsedExpr, type ObjectLiteralProperty, type FlatDepth, type TemplatePart } from '@barefootjs/jsx';
14
+ import type { XslateEmitContext } from '../emit-context.ts';
15
+ /**
16
+ * Lowering for the predicate body of a filter / every / some / find, plus the
17
+ * same shape used by `renderBlockBodyCondition` for complex block-body
18
+ * filters. Higher-order predicates are emitted using Kolon's own scalar
19
+ * comparison operators (which delegate to Perl semantics).
20
+ *
21
+ * NOTE: Kolon has no `grep { } @{...}` form, so nested higher-order chains
22
+ * (`x.tags.filter(...).length`) inside a predicate route through the
23
+ * top-level emitter's `$bf`-helper higher-order lowering. This emitter keeps
24
+ * the scalar-comparison surface the predicates the adapter accepts actually
25
+ * use; richer nested shapes fall back to the helper or surface as BF101 via
26
+ * the top-level emitter.
27
+ */
28
+ export declare class XslateFilterEmitter implements ParsedExprEmitter {
29
+ private readonly param;
30
+ private readonly localVarMap;
31
+ private readonly isStringName;
32
+ constructor(param: string, localVarMap: Map<string, string>, isStringName?: (n: string) => boolean);
33
+ identifier(name: string): string;
34
+ literal(value: string | number | boolean | null, literalType: LiteralType): string;
35
+ member(object: ParsedExpr, property: string, _computed: boolean, emit: (e: ParsedExpr) => string): string;
36
+ indexAccess(object: ParsedExpr, index: ParsedExpr, emit: (e: ParsedExpr) => string): string;
37
+ call(callee: ParsedExpr, args: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
38
+ unary(op: string, argument: ParsedExpr, emit: (e: ParsedExpr) => string): string;
39
+ binary(op: string, left: ParsedExpr, right: ParsedExpr, emit: (e: ParsedExpr) => string): string;
40
+ logical(op: '&&' | '||' | '??', left: ParsedExpr, right: ParsedExpr, emit: (e: ParsedExpr) => string): string;
41
+ callbackMethod(method: string, object: ParsedExpr, _arrow: Extract<ParsedExpr, {
42
+ kind: 'arrow';
43
+ }>, _restArgs: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
44
+ arrayLiteral(elements: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
45
+ arrayMethod(method: ArrayMethod, object: ParsedExpr, args: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
46
+ flatMethod(object: ParsedExpr, depth: FlatDepth, emit: (e: ParsedExpr) => string): string;
47
+ conditional(_test: ParsedExpr, _consequent: ParsedExpr, _alternate: ParsedExpr): string;
48
+ templateLiteral(_parts: TemplatePart[]): string;
49
+ arrow(_params: string[], _body: ParsedExpr): string;
50
+ regex(_raw: string): string;
51
+ unsupported(_raw: string, _reason: string): string;
52
+ objectLiteral(_properties: ObjectLiteralProperty[], _raw: string, _emit: (e: ParsedExpr) => string): string;
53
+ }
54
+ /**
55
+ * Lowering for top-level expressions whose identifiers resolve against the
56
+ * Kolon template's per-render vars (signals, props, locals introduced by `:
57
+ * my $x = ...` lines). Differs from the filter emitter mainly in
58
+ * - `.length` → `.size()` (Kolon array length),
59
+ * - `conditional` is supported (filter predicates can't return ternaries),
60
+ * - higher-order methods route through `$bf` array helpers.
61
+ */
62
+ export declare class XslateTopLevelEmitter implements ParsedExprEmitter {
63
+ private readonly ctx;
64
+ constructor(ctx: XslateEmitContext);
65
+ identifier(name: string): string;
66
+ literal(value: string | number | boolean | null, literalType: LiteralType): string;
67
+ member(object: ParsedExpr, property: string, _computed: boolean, emit: (e: ParsedExpr) => string): string;
68
+ indexAccess(object: ParsedExpr, index: ParsedExpr, emit: (e: ParsedExpr) => string): string;
69
+ call(callee: ParsedExpr, args: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
70
+ unary(op: string, argument: ParsedExpr, emit: (e: ParsedExpr) => string): string;
71
+ binary(op: string, left: ParsedExpr, right: ParsedExpr, emit: (e: ParsedExpr) => string): string;
72
+ logical(op: '&&' | '||' | '??', left: ParsedExpr, right: ParsedExpr, emit: (e: ParsedExpr) => string): string;
73
+ callbackMethod(method: string, object: ParsedExpr, arrow: Extract<ParsedExpr, {
74
+ kind: 'arrow';
75
+ }>, restArgs: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
76
+ /**
77
+ * Lower a boolean-predicate callback (`filter` / `find*` / `every` / `some`),
78
+ * extracted from the pre-#2018-P5 `higherOrder` arm. Higher-order array
79
+ * methods all take a JS arrow predicate, lowered to a Kolon lambda
80
+ * `-> $param { PRED }` (callable from Perl as a code ref), and go through the
81
+ * runtime object — consistent with the other array helpers ($bf.includes /
82
+ * $bf.slice / ...). `.find*` map to snake_case runtime methods. The
83
+ * `.filter(...).map(...)` *loop* form is handled separately by renderLoop's
84
+ * inline predicate.
85
+ */
86
+ private _emitPredicateCallback;
87
+ arrayLiteral(elements: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
88
+ arrayMethod(method: ArrayMethod, object: ParsedExpr, args: ParsedExpr[], emit: (e: ParsedExpr) => string): string;
89
+ flatMethod(object: ParsedExpr, depth: FlatDepth, emit: (e: ParsedExpr) => string): string;
90
+ conditional(test: ParsedExpr, consequent: ParsedExpr, alternate: ParsedExpr, emit: (e: ParsedExpr) => string): string;
91
+ templateLiteral(parts: TemplatePart[], emit: (e: ParsedExpr) => string): string;
92
+ arrow(_params: string[], _body: ParsedExpr): string;
93
+ regex(_raw: string): string;
94
+ unsupported(_raw: string, _reason: string): string;
95
+ objectLiteral(_properties: ObjectLiteralProperty[], _raw: string, _emit: (e: ParsedExpr) => string): string;
96
+ }
97
+ //# sourceMappingURL=emitters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emitters.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/emitters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,YAAY,EAIlB,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAA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EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;IAED,aAAa,CAAC,WAAW,EAAE,qBAAqB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAAG,MAAM,CAO1G;CACF"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Operand-type classification for the Text::Xslate (Kolon) template adapter.
3
+ *
4
+ * Extracted from `xslate-adapter.ts` (domain-module refactor, issue #2018
5
+ * track D). Pure function over `ParsedExpr` taking an `isStringName`
6
+ * predicate rather than reading adapter instance state.
7
+ *
8
+ * NOTE: unlike the Mojo adapter, Kolon's `==`/`!=` are value-equality
9
+ * operators that compare strings and numbers correctly, so the Kolon
10
+ * emitters never need to steer string comparisons onto `eq`/`ne`. This
11
+ * helper is therefore not consumed by the Kolon lowering today — it is kept
12
+ * as the parallel of the Mojo adapter's `expr/operand.ts` (groundwork for a
13
+ * future shared Perl-evaluator surface, issue #2018 track D).
14
+ */
15
+ import type { ParsedExpr } from '@barefootjs/jsx';
16
+ /**
17
+ * Whether a comparison operand is string-typed. In the Mojo adapter this
18
+ * selects Perl `eq`/`ne` over numeric `==`/`!=` for a `===`/`!==` against a
19
+ * string operand. The Kolon emitters do NOT consume it — Kolon's `==`/`!=`
20
+ * are value-equality operators that compare strings and numbers correctly, so
21
+ * `===`/`!==` always map to `==`/`!=` here (see the file header). Kept only as
22
+ * the parallel of the Mojo helper.
23
+ */
24
+ export declare function isStringTypedOperand(expr: ParsedExpr, isStringName: (n: string) => boolean): boolean;
25
+ //# sourceMappingURL=operand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operand.d.ts","sourceRoot":"","sources":["../../../src/adapter/expr/operand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CASpG"}