@barefootjs/jsx 0.18.3 → 0.18.4
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/adapters/parsed-expr-emitter.d.ts +39 -0
- package/dist/adapters/parsed-expr-emitter.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -5
- package/dist/jsx-to-ir.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +1 -1
- package/src/__tests__/ir-const-resolution.test.ts +1 -1
- package/src/__tests__/ir-provider.test.ts +2 -2
- package/src/__tests__/tagged-template-interleave.test.ts +2 -2
- package/src/adapters/parsed-expr-emitter.ts +66 -0
- package/src/index.ts +1 -1
- package/src/jsx-to-ir.ts +19 -5
|
@@ -103,6 +103,45 @@ export interface ParsedExprEmitter {
|
|
|
103
103
|
}, emit: (e: ParsedExpr) => string): string;
|
|
104
104
|
unsupported(raw: string, reason: string): string;
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Whether an operand is string-typed, as far as the ParsedExpr tree can
|
|
108
|
+
* tell: a string literal, a template literal, a zero-arg getter call /
|
|
109
|
+
* `props.x` member whose name the adapter knows to be string-valued
|
|
110
|
+
* (`isStringName`, from adapter state), or a `+` chain that is itself a
|
|
111
|
+
* string concatenation. Promoted from the Mojo/Xslate adapters' local
|
|
112
|
+
* copies (their file header marked it a shared candidate) and extended
|
|
113
|
+
* with the template-literal and nested-`+` arms.
|
|
114
|
+
*
|
|
115
|
+
* Consumed by `===`/`!==` lowering on backends whose `==` is numeric
|
|
116
|
+
* (Perl `eq`/`ne`) and by `isStringConcatBinary` below.
|
|
117
|
+
*/
|
|
118
|
+
export declare function isStringTypedOperand(expr: ParsedExpr, isStringName: (n: string) => boolean): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Whether a `binary` node is JS STRING concatenation rather than numeric
|
|
121
|
+
* addition: `+` with at least one string-typed operand (#2176). JS `+`
|
|
122
|
+
* overloads on operand type; backends whose `+` is numeric-only coerce
|
|
123
|
+
* the strings — Perl renders `'Hello, ' + name` as 0, PHP fatals with
|
|
124
|
+
* "Unsupported operand types" — so their emitters must pick the
|
|
125
|
+
* language's concat operator (`.` / `~`) when this returns true. The
|
|
126
|
+
* decision is shared-layer semantics; each adapter only maps true to
|
|
127
|
+
* its own operator.
|
|
128
|
+
*/
|
|
129
|
+
export declare function isStringConcatBinary(op: string, left: ParsedExpr, right: ParsedExpr, isStringName: (n: string) => boolean): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Wrap an emitted binary/logical/ternary OPERAND in parentheses so the
|
|
132
|
+
* source grouping the `ParsedExpr` tree encodes survives infix
|
|
133
|
+
* re-emission (#2173). `(count() + 2) * 3` parses as
|
|
134
|
+
* `binary{*, binary{+}, 3}` — the tree is unambiguous, but an emitter
|
|
135
|
+
* that joins operands textually (`${l} ${op} ${r}`) re-exposes the
|
|
136
|
+
* text to the TARGET language's precedence, silently computing
|
|
137
|
+
* `count + 2 * 3`. Grouping is decided here, in the shared layer
|
|
138
|
+
* (the semantics), so adapters just call this on each operand — no
|
|
139
|
+
* per-language precedence table needed: parenthesizing a compound
|
|
140
|
+
* operand is universally valid, and leaf operands (identifiers,
|
|
141
|
+
* literals, calls, members) stay unwrapped so simple emissions remain
|
|
142
|
+
* byte-identical.
|
|
143
|
+
*/
|
|
144
|
+
export declare function groupBinaryOperand(operand: ParsedExpr, emitted: string): string;
|
|
106
145
|
/**
|
|
107
146
|
* Single point of dispatch from `ParsedExpr.kind` to the adapter's
|
|
108
147
|
* method. Adapters call this once at their entry point; the recursion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsed-expr-emitter.d.ts","sourceRoot":"","sources":["../../src/adapters/parsed-expr-emitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE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U,EAAE,qBAAqB,EAAE,EACnC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CAAA;IACT,WAAW,CACT,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,EAAE,EAClB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CAAA;IAkBT,UAAU,CACR,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,SAAS,GAAG;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,EACvC,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,GAC9B,MAAM,CAAA;IACT,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;CACjD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAapG;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,UAAU,EACjB,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GACnC,OAAO,CAET;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAI/E;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAsDnF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type { TemplateAdapter, AdapterOutput, AdapterGenerateOptions, TemplateSe
|
|
|
20
20
|
export { JsxAdapter } from './adapters/jsx-adapter.ts';
|
|
21
21
|
export type { JsxAdapterConfig } from './adapters/jsx-adapter.ts';
|
|
22
22
|
export { rewriteImportsForTemplate } from './adapters/template-imports.ts';
|
|
23
|
-
export { emitParsedExpr } from './adapters/parsed-expr-emitter.ts';
|
|
23
|
+
export { emitParsedExpr, groupBinaryOperand, isStringTypedOperand, isStringConcatBinary } from './adapters/parsed-expr-emitter.ts';
|
|
24
24
|
export type { ParsedExprEmitter, HigherOrderMethod, ArrayMethod, SortMethod, LiteralType } from './adapters/parsed-expr-emitter.ts';
|
|
25
25
|
export { importsSearchParams, searchParamsLocalNames, envSignalLocalNames, envSignalReaderFor, ENV_SIGNAL_READERS, queryHrefLocalNames, matchSearchParamsMethodCall } from './adapters/env-signal.ts';
|
|
26
26
|
export type { EnvSignalReader } from './adapters/env-signal.ts';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACzD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,yBAAyB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAGzG,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAGnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGlE,YAAY,EACV,WAAW,EACX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAAa,EACb,MAAM,EACN,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,WAAW,EACX,UAAU,EACV,MAAM,EACN,aAAa,EACb,UAAU,EACV,OAAO,EACP,UAAU,EACV,SAAS,EACT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ClB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,eAAe,EACf,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,UAAU,EACV,SAAS,EACT,UAAU,GACX,MAAM,eAAe,CAAA;AAItB,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,GACd,MAAM,oBAAoB,CAAA;AAC3B,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,WAAW,EACX,gBAAgB,GACjB,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGlE,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACvM,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAGxG,YAAY,EAEV,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAGlB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAGlB,mBAAmB,EACnB,kBAAkB,EAGlB,wBAAwB,EACxB,uBAAuB,EACvB,yBAAyB,EAGzB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,iBAAiB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -8034,6 +8034,7 @@ function resolveFreeRefs(node, env) {
|
|
|
8034
8034
|
}
|
|
8035
8035
|
|
|
8036
8036
|
// src/jsx-to-ir.ts
|
|
8037
|
+
import { toHTMLAttrName } from "@barefootjs/shared";
|
|
8037
8038
|
var CLIENT_DIRECTIVE_INTERIOR_RE2 = /^\s*@client\s*$/;
|
|
8038
8039
|
var BLOCK_COMMENT_RE2 = /\/\*([\s\S]*?)\*\//g;
|
|
8039
8040
|
function hasLeadingClientDirective(expr, sourceFile) {
|
|
@@ -10310,27 +10311,28 @@ function processAttributes(attributes, ctx) {
|
|
|
10310
10311
|
}
|
|
10311
10312
|
if (!ts11.isJsxAttribute(attr))
|
|
10312
10313
|
continue;
|
|
10313
|
-
const
|
|
10314
|
-
if (
|
|
10314
|
+
const rawName = attr.name.getText(ctx.sourceFile);
|
|
10315
|
+
if (rawName === "ref") {
|
|
10315
10316
|
if (attr.initializer && ts11.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
10316
10317
|
reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
|
|
10317
10318
|
ref = ctx.getJS(attr.initializer.expression);
|
|
10318
10319
|
}
|
|
10319
10320
|
continue;
|
|
10320
10321
|
}
|
|
10321
|
-
if (/^on[A-Z]/.test(
|
|
10322
|
+
if (/^on[A-Z]/.test(rawName)) {
|
|
10322
10323
|
if (attr.initializer && ts11.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
10323
|
-
const eventName =
|
|
10324
|
+
const eventName = rawName.slice(2).toLowerCase();
|
|
10324
10325
|
reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
|
|
10325
10326
|
events.push({
|
|
10326
10327
|
name: eventName,
|
|
10327
|
-
originalAttr:
|
|
10328
|
+
originalAttr: rawName,
|
|
10328
10329
|
handler: ctx.getJS(attr.initializer.expression),
|
|
10329
10330
|
loc: getSourceLocation(attr, ctx.sourceFile, ctx.filePath)
|
|
10330
10331
|
});
|
|
10331
10332
|
}
|
|
10332
10333
|
continue;
|
|
10333
10334
|
}
|
|
10335
|
+
const name = toHTMLAttrName(rawName);
|
|
10334
10336
|
let value = getAttributeValue(attr, ctx);
|
|
10335
10337
|
let clientOnly;
|
|
10336
10338
|
if (attr.initializer && ts11.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
@@ -20006,6 +20008,28 @@ export default ${this.componentName}` : "";
|
|
|
20006
20008
|
}
|
|
20007
20009
|
var testAdapter = new TestAdapter;
|
|
20008
20010
|
// src/adapters/parsed-expr-emitter.ts
|
|
20011
|
+
function isStringTypedOperand(expr, isStringName) {
|
|
20012
|
+
if (expr.kind === "literal" && expr.literalType === "string")
|
|
20013
|
+
return true;
|
|
20014
|
+
if (expr.kind === "template-literal")
|
|
20015
|
+
return true;
|
|
20016
|
+
if (expr.kind === "call" && expr.callee.kind === "identifier" && expr.args.length === 0) {
|
|
20017
|
+
return isStringName(expr.callee.name);
|
|
20018
|
+
}
|
|
20019
|
+
if (expr.kind === "member" && expr.object.kind === "identifier" && expr.object.name === "props") {
|
|
20020
|
+
return isStringName(expr.property);
|
|
20021
|
+
}
|
|
20022
|
+
if (expr.kind === "binary" && expr.op === "+") {
|
|
20023
|
+
return isStringTypedOperand(expr.left, isStringName) || isStringTypedOperand(expr.right, isStringName);
|
|
20024
|
+
}
|
|
20025
|
+
return false;
|
|
20026
|
+
}
|
|
20027
|
+
function isStringConcatBinary(op, left, right, isStringName) {
|
|
20028
|
+
return op === "+" && (isStringTypedOperand(left, isStringName) || isStringTypedOperand(right, isStringName));
|
|
20029
|
+
}
|
|
20030
|
+
function groupBinaryOperand(operand, emitted) {
|
|
20031
|
+
return operand.kind === "binary" || operand.kind === "logical" || operand.kind === "conditional" ? `(${emitted})` : emitted;
|
|
20032
|
+
}
|
|
20009
20033
|
function emitParsedExpr(expr, emitter) {
|
|
20010
20034
|
const emit = (child) => emitParsedExpr(child, emitter);
|
|
20011
20035
|
switch (expr.kind) {
|
|
@@ -23068,11 +23092,14 @@ export {
|
|
|
23068
23092
|
joinProfilerEvents,
|
|
23069
23093
|
isValidHelperId,
|
|
23070
23094
|
isSupported,
|
|
23095
|
+
isStringTypedOperand,
|
|
23096
|
+
isStringConcatBinary,
|
|
23071
23097
|
isLowerableObjectRestDestructure,
|
|
23072
23098
|
isLowerableLoopDestructure,
|
|
23073
23099
|
isBooleanAttr,
|
|
23074
23100
|
importsSearchParams,
|
|
23075
23101
|
identifierPath,
|
|
23102
|
+
groupBinaryOperand,
|
|
23076
23103
|
graphToJSON,
|
|
23077
23104
|
getLoweringPlugins,
|
|
23078
23105
|
getCompilerCounters,
|
package/dist/jsx-to-ir.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-to-ir.d.ts","sourceRoot":"","sources":["../src/jsx-to-ir.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,KAAK,MAAM,EA0BZ,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,KAAK,eAAe,EAA0E,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"jsx-to-ir.d.ts","sourceRoot":"","sources":["../src/jsx-to-ir.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,KAAK,MAAM,EA0BZ,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,KAAK,eAAe,EAA0E,MAAM,uBAAuB,CAAA;AAunBpI,wBAAgB,OAAO,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,CAIhE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/jsx",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.4",
|
|
4
4
|
"description": "JSX compiler for BarefootJS - transforms JSX to server HTML + client JS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"directory": "packages/jsx"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@barefootjs/shared": "0.18.
|
|
56
|
+
"@barefootjs/shared": "0.18.4"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@barefootjs/client": ">=0.2.0",
|
|
@@ -3090,7 +3090,7 @@ export function initExample(__scope, _p = {}) {
|
|
|
3090
3090
|
initChild('DialogTrigger', _s0, { asChild: true })
|
|
3091
3091
|
}
|
|
3092
3092
|
|
|
3093
|
-
hydrate('Example', { init: initExample, template: (_p) => \`<div>\${renderChild('DialogTrigger', {asChild: true, children: \`<span role="button" \${(0) != null ? '
|
|
3093
|
+
hydrate('Example', { init: initExample, template: (_p) => \`<div>\${renderChild('DialogTrigger', {asChild: true, children: \`<span role="button" \${(0) != null ? 'tabindex="' + escapeAttr(0) + '"' : ''}>Open</span>\`}, undefined, 's0')}</div>\` })
|
|
3094
3094
|
export function Example(_p, __bfKey) { return createComponent('Example', _p, __bfKey) }"
|
|
3095
3095
|
`;
|
|
3096
3096
|
|
|
@@ -26,7 +26,7 @@ function findClassNameValue(node: IRNode): AttrValue | null {
|
|
|
26
26
|
if (node.type === 'element') {
|
|
27
27
|
const el = node as IRElement
|
|
28
28
|
for (const attr of el.attrs) {
|
|
29
|
-
if (attr.name === '
|
|
29
|
+
if (attr.name === 'class') return attr.value
|
|
30
30
|
}
|
|
31
31
|
for (const child of el.children) {
|
|
32
32
|
const v = findClassNameValue(child)
|
|
@@ -83,8 +83,8 @@ describe('Context.Provider JSX', () => {
|
|
|
83
83
|
contextName: 'Ctx',
|
|
84
84
|
valueProp: { name: 'value', value: { kind: 'expression', expr: '{ active, setActive }' } },
|
|
85
85
|
children: [
|
|
86
|
-
{ type: 'element', tag: 'div', attrs: [{ name: '
|
|
87
|
-
{ type: 'element', tag: 'div', attrs: [{ name: '
|
|
86
|
+
{ type: 'element', tag: 'div', attrs: [{ name: 'class', value: { kind: 'literal', value: 'tabs-header' } }] },
|
|
87
|
+
{ type: 'element', tag: 'div', attrs: [{ name: 'class', value: { kind: 'literal', value: 'tabs-body' } }] },
|
|
88
88
|
],
|
|
89
89
|
})
|
|
90
90
|
})
|
|
@@ -41,7 +41,7 @@ function classAttrValue(source: string, filename = 'TagDemo.tsx') {
|
|
|
41
41
|
expect(ir).not.toBeNull()
|
|
42
42
|
expect(ir!.type).toBe('element')
|
|
43
43
|
const el = ir as IRElement
|
|
44
|
-
const attr = el.attrs.find(a => a.name === '
|
|
44
|
+
const attr = el.attrs.find(a => a.name === 'class')
|
|
45
45
|
expect(attr).toBeDefined()
|
|
46
46
|
return attr!.value
|
|
47
47
|
}
|
|
@@ -256,7 +256,7 @@ describe('tagged-template interleave-tag recognition (#2092)', () => {
|
|
|
256
256
|
const ir = jsxToIR(ctx)
|
|
257
257
|
expect(ir).not.toBeNull()
|
|
258
258
|
const el = ir as IRElement
|
|
259
|
-
const attr = el.attrs.find(a => a.name === '
|
|
259
|
+
const attr = el.attrs.find(a => a.name === 'class')
|
|
260
260
|
expect(attr).toBeDefined()
|
|
261
261
|
// The desugar still applies (the client-only directive doesn't block
|
|
262
262
|
// recognition — it's read independently from the original node), and
|
|
@@ -198,6 +198,72 @@ export interface ParsedExprEmitter {
|
|
|
198
198
|
unsupported(raw: string, reason: string): string
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
/**
|
|
202
|
+
* Whether an operand is string-typed, as far as the ParsedExpr tree can
|
|
203
|
+
* tell: a string literal, a template literal, a zero-arg getter call /
|
|
204
|
+
* `props.x` member whose name the adapter knows to be string-valued
|
|
205
|
+
* (`isStringName`, from adapter state), or a `+` chain that is itself a
|
|
206
|
+
* string concatenation. Promoted from the Mojo/Xslate adapters' local
|
|
207
|
+
* copies (their file header marked it a shared candidate) and extended
|
|
208
|
+
* with the template-literal and nested-`+` arms.
|
|
209
|
+
*
|
|
210
|
+
* Consumed by `===`/`!==` lowering on backends whose `==` is numeric
|
|
211
|
+
* (Perl `eq`/`ne`) and by `isStringConcatBinary` below.
|
|
212
|
+
*/
|
|
213
|
+
export function isStringTypedOperand(expr: ParsedExpr, isStringName: (n: string) => boolean): boolean {
|
|
214
|
+
if (expr.kind === 'literal' && expr.literalType === 'string') return true
|
|
215
|
+
if (expr.kind === 'template-literal') return true
|
|
216
|
+
if (expr.kind === 'call' && expr.callee.kind === 'identifier' && expr.args.length === 0) {
|
|
217
|
+
return isStringName(expr.callee.name)
|
|
218
|
+
}
|
|
219
|
+
if (expr.kind === 'member' && expr.object.kind === 'identifier' && expr.object.name === 'props') {
|
|
220
|
+
return isStringName(expr.property)
|
|
221
|
+
}
|
|
222
|
+
if (expr.kind === 'binary' && expr.op === '+') {
|
|
223
|
+
return isStringTypedOperand(expr.left, isStringName) || isStringTypedOperand(expr.right, isStringName)
|
|
224
|
+
}
|
|
225
|
+
return false
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Whether a `binary` node is JS STRING concatenation rather than numeric
|
|
230
|
+
* addition: `+` with at least one string-typed operand (#2176). JS `+`
|
|
231
|
+
* overloads on operand type; backends whose `+` is numeric-only coerce
|
|
232
|
+
* the strings — Perl renders `'Hello, ' + name` as 0, PHP fatals with
|
|
233
|
+
* "Unsupported operand types" — so their emitters must pick the
|
|
234
|
+
* language's concat operator (`.` / `~`) when this returns true. The
|
|
235
|
+
* decision is shared-layer semantics; each adapter only maps true to
|
|
236
|
+
* its own operator.
|
|
237
|
+
*/
|
|
238
|
+
export function isStringConcatBinary(
|
|
239
|
+
op: string,
|
|
240
|
+
left: ParsedExpr,
|
|
241
|
+
right: ParsedExpr,
|
|
242
|
+
isStringName: (n: string) => boolean,
|
|
243
|
+
): boolean {
|
|
244
|
+
return op === '+' && (isStringTypedOperand(left, isStringName) || isStringTypedOperand(right, isStringName))
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Wrap an emitted binary/logical/ternary OPERAND in parentheses so the
|
|
249
|
+
* source grouping the `ParsedExpr` tree encodes survives infix
|
|
250
|
+
* re-emission (#2173). `(count() + 2) * 3` parses as
|
|
251
|
+
* `binary{*, binary{+}, 3}` — the tree is unambiguous, but an emitter
|
|
252
|
+
* that joins operands textually (`${l} ${op} ${r}`) re-exposes the
|
|
253
|
+
* text to the TARGET language's precedence, silently computing
|
|
254
|
+
* `count + 2 * 3`. Grouping is decided here, in the shared layer
|
|
255
|
+
* (the semantics), so adapters just call this on each operand — no
|
|
256
|
+
* per-language precedence table needed: parenthesizing a compound
|
|
257
|
+
* operand is universally valid, and leaf operands (identifiers,
|
|
258
|
+
* literals, calls, members) stay unwrapped so simple emissions remain
|
|
259
|
+
* byte-identical.
|
|
260
|
+
*/
|
|
261
|
+
export function groupBinaryOperand(operand: ParsedExpr, emitted: string): string {
|
|
262
|
+
return operand.kind === 'binary' || operand.kind === 'logical' || operand.kind === 'conditional'
|
|
263
|
+
? `(${emitted})`
|
|
264
|
+
: emitted
|
|
265
|
+
}
|
|
266
|
+
|
|
201
267
|
/**
|
|
202
268
|
* Single point of dispatch from `ParsedExpr.kind` to the adapter's
|
|
203
269
|
* method. Adapters call this once at their entry point; the recursion
|
package/src/index.ts
CHANGED
|
@@ -85,7 +85,7 @@ export type {
|
|
|
85
85
|
export { JsxAdapter } from './adapters/jsx-adapter.ts'
|
|
86
86
|
export type { JsxAdapterConfig } from './adapters/jsx-adapter.ts'
|
|
87
87
|
export { rewriteImportsForTemplate } from './adapters/template-imports.ts'
|
|
88
|
-
export { emitParsedExpr } from './adapters/parsed-expr-emitter.ts'
|
|
88
|
+
export { emitParsedExpr, groupBinaryOperand, isStringTypedOperand, isStringConcatBinary } from './adapters/parsed-expr-emitter.ts'
|
|
89
89
|
export type { ParsedExprEmitter, HigherOrderMethod, ArrayMethod, SortMethod, LiteralType } from './adapters/parsed-expr-emitter.ts'
|
|
90
90
|
export { importsSearchParams, searchParamsLocalNames, envSignalLocalNames, envSignalReaderFor, ENV_SIGNAL_READERS, queryHrefLocalNames, matchSearchParamsMethodCall } from './adapters/env-signal.ts'
|
|
91
91
|
export type { EnvSignalReader } from './adapters/env-signal.ts'
|
package/src/jsx-to-ir.ts
CHANGED
|
@@ -48,6 +48,7 @@ import { resolveFreeRefs, isNameBound as isNameBoundInEnv, type BindingEnvironme
|
|
|
48
48
|
import { computeFileScope } from './ir-to-client-js/component-scope.ts'
|
|
49
49
|
import { extractFreeIdentifiersFromNode, initializerShapeContainsJsx } from './analyzer.ts'
|
|
50
50
|
import { iterateJsTokens, replaceInExprContexts } from './scanner/js-scanner.ts'
|
|
51
|
+
import { toHTMLAttrName } from '@barefootjs/shared'
|
|
51
52
|
|
|
52
53
|
// =============================================================================
|
|
53
54
|
// Transform Context
|
|
@@ -4066,13 +4067,13 @@ function processAttributes(
|
|
|
4066
4067
|
|
|
4067
4068
|
if (!ts.isJsxAttribute(attr)) continue
|
|
4068
4069
|
|
|
4069
|
-
const
|
|
4070
|
+
const rawName = attr.name.getText(ctx.sourceFile)
|
|
4070
4071
|
|
|
4071
4072
|
// ref is captured separately (not pushed into `attrs`) because it never
|
|
4072
4073
|
// appears in the rendered HTML — it's a compile-time binding from the
|
|
4073
4074
|
// JSX call site to the runtime DOM element, surfaced via the IRElement
|
|
4074
4075
|
// `ref` field for the client-JS emitter.
|
|
4075
|
-
if (
|
|
4076
|
+
if (rawName === 'ref') {
|
|
4076
4077
|
if (attr.initializer && ts.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
4077
4078
|
reportJsxBranchLocalInCallback(attr.initializer.expression, ctx)
|
|
4078
4079
|
ref = ctx.getJS(attr.initializer.expression)
|
|
@@ -4084,13 +4085,13 @@ function processAttributes(
|
|
|
4084
4085
|
// they're wired up at hydration time (delegated event registration) and
|
|
4085
4086
|
// must not leak into rendered HTML. The DOM event name is lowercase
|
|
4086
4087
|
// (`click`, not `Click`), so strip the `on` prefix and downcase.
|
|
4087
|
-
if (/^on[A-Z]/.test(
|
|
4088
|
+
if (/^on[A-Z]/.test(rawName)) {
|
|
4088
4089
|
if (attr.initializer && ts.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
4089
|
-
const eventName =
|
|
4090
|
+
const eventName = rawName.slice(2).toLowerCase()
|
|
4090
4091
|
reportJsxBranchLocalInCallback(attr.initializer.expression, ctx)
|
|
4091
4092
|
events.push({
|
|
4092
4093
|
name: eventName,
|
|
4093
|
-
originalAttr:
|
|
4094
|
+
originalAttr: rawName,
|
|
4094
4095
|
handler: ctx.getJS(attr.initializer.expression),
|
|
4095
4096
|
loc: getSourceLocation(attr, ctx.sourceFile, ctx.filePath),
|
|
4096
4097
|
})
|
|
@@ -4098,6 +4099,19 @@ function processAttributes(
|
|
|
4098
4099
|
continue
|
|
4099
4100
|
}
|
|
4100
4101
|
|
|
4102
|
+
// Normalize the JSX prop spelling to the HTML/SVG attribute name ONCE,
|
|
4103
|
+
// here in Phase 1, so IRAttribute.name is already the name every
|
|
4104
|
+
// adapter emits verbatim (#2172): React-style HTML camelCase aliases
|
|
4105
|
+
// lower (`htmlFor` → `for`, `tabIndex` → `tabindex`, `readOnly` →
|
|
4106
|
+
// the BOOLEAN_ATTRS member `readonly`), SVG presentation attrs
|
|
4107
|
+
// kebab-case (`strokeWidth` → `stroke-width`), case-sensitive SVG XML
|
|
4108
|
+
// names (`viewBox`) and everything unknown (`data-*`, custom-element
|
|
4109
|
+
// attrs) pass through. Previously each adapter re-derived (at most)
|
|
4110
|
+
// `className` → `class` itself and every other alias leaked into the
|
|
4111
|
+
// emitted HTML as an unknown attribute the browser ignores. Intrinsic
|
|
4112
|
+
// elements only — component props (IRProp) keep the user's API names.
|
|
4113
|
+
const name = toHTMLAttrName(rawName)
|
|
4114
|
+
|
|
4101
4115
|
let value = getAttributeValue(attr, ctx)
|
|
4102
4116
|
let clientOnly: boolean | undefined
|
|
4103
4117
|
if (attr.initializer && ts.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|