@barefootjs/xslate 0.8.0 → 0.9.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.
- package/LICENSE +21 -0
- package/dist/adapter/index.js +187506 -57
- package/dist/adapter/xslate-adapter.d.ts +60 -0
- package/dist/adapter/xslate-adapter.d.ts.map +1 -1
- package/dist/build.js +187506 -57
- package/dist/index.js +187506 -57
- package/lib/BarefootJS/Backend/Xslate.pm +10 -2
- package/package.json +11 -24
- package/src/__tests__/xslate-adapter.test.ts +131 -0
- package/src/__tests__/xslate-spread-attrs.test.ts +218 -0
- package/src/adapter/xslate-adapter.ts +356 -50
- package/src/test-render.ts +661 -0
|
@@ -66,6 +66,30 @@ export declare class XslateAdapter extends BaseAdapter implements IRNodeEmitter<
|
|
|
66
66
|
* string-vs-numeric distinction the Mojo adapter makes applies here.
|
|
67
67
|
*/
|
|
68
68
|
private stringValueNames;
|
|
69
|
+
/**
|
|
70
|
+
* Module-scope pure-string consts (`const x = 'literal'`), keyed by name →
|
|
71
|
+
* unescaped value. A className template literal that references such a const
|
|
72
|
+
* (`className={`${x} ${className}`}`) must inline the literal: the const is
|
|
73
|
+
* module-scope, so it never reaches the per-render template stash and a bare
|
|
74
|
+
* `$x` reference would render empty. Mirrors the Mojo adapter's
|
|
75
|
+
* `moduleStringConsts` fix.
|
|
76
|
+
*/
|
|
77
|
+
private moduleStringConsts;
|
|
78
|
+
/**
|
|
79
|
+
* Local + module constants from the IR, used by the conditional-spread and
|
|
80
|
+
* `Record<staticKeys, scalar>[propKey]` lowering paths (#textarea / #checkbox).
|
|
81
|
+
* Stashed at `generate()` entry so `emitSpread` can resolve a bare local
|
|
82
|
+
* const (`const sizeAttrs = size ? {…} : {}`) to its initializer text.
|
|
83
|
+
*/
|
|
84
|
+
private localConstants;
|
|
85
|
+
/**
|
|
86
|
+
* Optional, no-default props that are `undef` when the caller omits them.
|
|
87
|
+
* Their bare-reference attribute emission is guarded with Kolon `defined` so
|
|
88
|
+
* the attribute DROPS rather than rendering `attr=""` (Hono-style nullish
|
|
89
|
+
* omission, e.g. textarea's `rows`). The filter excludes destructure-
|
|
90
|
+
* defaulted, rest, and concrete-primitive props.
|
|
91
|
+
*/
|
|
92
|
+
private nullableOptionalProps;
|
|
69
93
|
constructor(options?: XslateAdapterOptions);
|
|
70
94
|
generate(ir: ComponentIR, options?: AdapterGenerateOptions): AdapterOutput;
|
|
71
95
|
private generateScriptRegistrations;
|
|
@@ -158,6 +182,35 @@ export declare class XslateAdapter extends BaseAdapter implements IRNodeEmitter<
|
|
|
158
182
|
* when the shape was rejected (caller should drop the attribute).
|
|
159
183
|
*/
|
|
160
184
|
private refuseUnsupportedAttrExpression;
|
|
185
|
+
/**
|
|
186
|
+
* Lower a conditional inline-object spread
|
|
187
|
+
* `COND ? { 'aria-describedby': describedBy } : {}`
|
|
188
|
+
* to a Kolon inline ternary of hashrefs
|
|
189
|
+
* `$describedBy ? { 'aria-describedby' => $describedBy } : {}`.
|
|
190
|
+
* Both branches must be object literals; the condition + values route through
|
|
191
|
+
* `convertExpressionToKolon`. Returns `null` for any other shape so the caller
|
|
192
|
+
* falls back to its normal lowering. Mirror of `conditionalSpreadToPerl`.
|
|
193
|
+
*/
|
|
194
|
+
private conditionalSpreadToKolon;
|
|
195
|
+
/**
|
|
196
|
+
* Convert a static object literal into a Kolon hashref string for a
|
|
197
|
+
* conditional spread. Only static string/identifier keys are allowed; values
|
|
198
|
+
* resolve via `convertExpressionToKolon` (or the `Record[propKey]` index
|
|
199
|
+
* lowering). Returns `null` for any computed/spread/dynamic key. Empty object
|
|
200
|
+
* → `{}`. Mirror of `objectLiteralToPerlHashref`.
|
|
201
|
+
*/
|
|
202
|
+
private objectLiteralToKolonHashref;
|
|
203
|
+
/**
|
|
204
|
+
* Lower a spread-object VALUE of the form `IDENT[KEY]` (CheckIcon's
|
|
205
|
+
* `sizeMap[size]`) to an inline indexed Kolon hashref
|
|
206
|
+
* `{ 'sm' => 16, 'md' => 20, ... }[$size]`.
|
|
207
|
+
* Reuses the shared structural parse (`parseRecordIndexAccess`); this wrapper
|
|
208
|
+
* only does the single-quote escaping + Kolon index emit. NB: Kolon indexes a
|
|
209
|
+
* hashref literal with bracket syntax `{…}[$key]`, NOT Perl's arrow-deref
|
|
210
|
+
* `{…}->{$key}` (which Kolon's parser rejects) — this is the one divergence
|
|
211
|
+
* from the Mojo `recordIndexAccessToPerl` emit.
|
|
212
|
+
*/
|
|
213
|
+
private recordIndexAccessToKolon;
|
|
161
214
|
private convertExpressionToKolon;
|
|
162
215
|
/**
|
|
163
216
|
* Render a full ParsedExpr tree to Kolon for top-level (non-filter)
|
|
@@ -167,6 +220,13 @@ export declare class XslateAdapter extends BaseAdapter implements IRNodeEmitter<
|
|
|
167
220
|
/** Whether `name` (a signal getter or prop) holds a string value, so an
|
|
168
221
|
* equality comparison against it should use Perl `eq`/`ne`. */
|
|
169
222
|
_isStringValueName(name: string): boolean;
|
|
223
|
+
/**
|
|
224
|
+
* Resolve an identifier to its inlined Kolon single-quoted literal when it
|
|
225
|
+
* names a module pure-string const, else `null` (caller falls back to the
|
|
226
|
+
* normal `$name` stash lowering). Loop-bound names shadow module consts, so
|
|
227
|
+
* never inline inside a loop body. Returns `'<escaped>'`.
|
|
228
|
+
*/
|
|
229
|
+
_resolveModuleStringConst(name: string): string | null;
|
|
170
230
|
_recordExprBF101(message: string, reason?: string): void;
|
|
171
231
|
/** Internal hook for higher-order: predicate body re-uses the filter emitter. */
|
|
172
232
|
_renderKolonFilterExprPublic(expr: ParsedExpr, param: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xslate-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/xslate-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAAa,EACb,MAAM,EACN,WAAW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