@barefootjs/hono 0.18.3 → 0.18.5
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/adapter/hono-adapter.d.ts.map +1 -1
- package/dist/adapter/index.js +15 -5
- package/dist/build.js +15 -5
- package/dist/index.js +15 -5
- package/package.json +1 -1
- package/src/adapter/hono-adapter.ts +47 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/hono-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,MAAM,EAIX,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAElB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,UAAU,EAEf,UAAU,EAMX,MAAM,iBAAiB,CAAA;AAExB;;;;;GAKG;AACH,KAAK,aAAa,GAAG;IACnB,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,CAAA;AAGD,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAuBD,qBAAa,WAAY,SAAQ,UAAW,YAAW,aAAa,CAAC,aAAa,CAAC;IACjF,IAAI,SAAS;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IAYzB,OAAO,CAAC,0BAA0B;CAwBnC;AAGD,eAAO,MAAM,WAAW,aAAoB,CAAA"}
|
package/dist/adapter/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
emitAttrValue,
|
|
8
8
|
buildLoopChainExpr
|
|
9
9
|
} from "@barefootjs/jsx";
|
|
10
|
-
import { BF_SCOPE, BF_HOST, BF_AT, BF_ROOT, BF_PROPS, BF_REGION } from "@barefootjs/shared";
|
|
10
|
+
import { BF_SCOPE, BF_HOST, BF_AT, BF_ROOT, BF_PROPS, BF_REGION, escapeHtml } from "@barefootjs/shared";
|
|
11
11
|
function applyHonoLoopChain(loop) {
|
|
12
12
|
return buildLoopChainExpr({
|
|
13
13
|
base: loop.array,
|
|
@@ -397,7 +397,7 @@ export default ${this.componentName}` : "";
|
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
renderText(text) {
|
|
400
|
-
return text.value;
|
|
400
|
+
return escapeHtml(text.value).replace(/\{/g, "{").replace(/\}/g, "}");
|
|
401
401
|
}
|
|
402
402
|
renderExpression(expr) {
|
|
403
403
|
if (expr.expr === "null" || expr.expr === "undefined") {
|
|
@@ -478,6 +478,15 @@ export default ${this.componentName}` : "";
|
|
|
478
478
|
} else if (loop.iterationShape === "keys") {
|
|
479
479
|
chainedArray = `[...${chainedArray}.keys()]`;
|
|
480
480
|
callbackParam = `(${loop.param}${paramAnnotation})`;
|
|
481
|
+
} else if (loop.objectIteration === "entries") {
|
|
482
|
+
chainedArray = `Object.entries(${chainedArray})`;
|
|
483
|
+
callbackParam = loop.index ? `([${loop.index}${indexAnnotation}, ${loop.param}${paramAnnotation}])` : `(${loop.param}${paramAnnotation}${indexParam})`;
|
|
484
|
+
} else if (loop.objectIteration === "keys") {
|
|
485
|
+
chainedArray = `Object.keys(${chainedArray})`;
|
|
486
|
+
callbackParam = `(${loop.param}${paramAnnotation})`;
|
|
487
|
+
} else if (loop.objectIteration === "values") {
|
|
488
|
+
chainedArray = `Object.values(${chainedArray})`;
|
|
489
|
+
callbackParam = `(${loop.param}${paramAnnotation})`;
|
|
481
490
|
} else {
|
|
482
491
|
callbackParam = `(${loop.param}${paramAnnotation}${indexParam})`;
|
|
483
492
|
}
|
|
@@ -570,7 +579,7 @@ export default ${this.componentName}` : "";
|
|
|
570
579
|
return `<>{bfComment(\`scope:\${__scopeId}${hostExpr}${propsExpr}\`)}${body}</>`;
|
|
571
580
|
}
|
|
572
581
|
elementAttrEmitter = {
|
|
573
|
-
emitLiteral: (value, name) => `${name}="${value.value}"`,
|
|
582
|
+
emitLiteral: (value, name) => `${name}="${escapeHtml(value.value)}"`,
|
|
574
583
|
emitExpression: (value, name) => {
|
|
575
584
|
if (isBooleanAttr(name) || value.presenceOrUndefined) {
|
|
576
585
|
return `${name}={(${value.expr}) || undefined}`;
|
|
@@ -584,7 +593,7 @@ export default ${this.componentName}` : "";
|
|
|
584
593
|
emitJsxChildren: () => ""
|
|
585
594
|
};
|
|
586
595
|
componentPropEmitter = {
|
|
587
|
-
emitLiteral: (value, name) => `${name}="${value.value}"`,
|
|
596
|
+
emitLiteral: (value, name) => `${name}="${escapeHtml(value.value)}"`,
|
|
588
597
|
emitExpression: (value, name) => `${name}={${value.expr}}`,
|
|
589
598
|
emitBooleanAttr: (_value, name) => name,
|
|
590
599
|
emitBooleanShorthand: (_value, name) => name,
|
|
@@ -600,7 +609,8 @@ export default ${this.componentName}` : "";
|
|
|
600
609
|
for (const attr of element.attrs) {
|
|
601
610
|
if (attr.clientOnly)
|
|
602
611
|
continue;
|
|
603
|
-
const
|
|
612
|
+
const jsxName = attr.name === "class" ? "className" : attr.name;
|
|
613
|
+
const lowered = emitAttrValue(attr.value, this.elementAttrEmitter, jsxName);
|
|
604
614
|
if (lowered)
|
|
605
615
|
parts.push(lowered);
|
|
606
616
|
}
|
package/dist/build.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
emitAttrValue,
|
|
8
8
|
buildLoopChainExpr
|
|
9
9
|
} from "@barefootjs/jsx";
|
|
10
|
-
import { BF_SCOPE, BF_HOST, BF_AT, BF_ROOT, BF_PROPS, BF_REGION } from "@barefootjs/shared";
|
|
10
|
+
import { BF_SCOPE, BF_HOST, BF_AT, BF_ROOT, BF_PROPS, BF_REGION, escapeHtml } from "@barefootjs/shared";
|
|
11
11
|
function applyHonoLoopChain(loop) {
|
|
12
12
|
return buildLoopChainExpr({
|
|
13
13
|
base: loop.array,
|
|
@@ -397,7 +397,7 @@ export default ${this.componentName}` : "";
|
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
renderText(text) {
|
|
400
|
-
return text.value;
|
|
400
|
+
return escapeHtml(text.value).replace(/\{/g, "{").replace(/\}/g, "}");
|
|
401
401
|
}
|
|
402
402
|
renderExpression(expr) {
|
|
403
403
|
if (expr.expr === "null" || expr.expr === "undefined") {
|
|
@@ -478,6 +478,15 @@ export default ${this.componentName}` : "";
|
|
|
478
478
|
} else if (loop.iterationShape === "keys") {
|
|
479
479
|
chainedArray = `[...${chainedArray}.keys()]`;
|
|
480
480
|
callbackParam = `(${loop.param}${paramAnnotation})`;
|
|
481
|
+
} else if (loop.objectIteration === "entries") {
|
|
482
|
+
chainedArray = `Object.entries(${chainedArray})`;
|
|
483
|
+
callbackParam = loop.index ? `([${loop.index}${indexAnnotation}, ${loop.param}${paramAnnotation}])` : `(${loop.param}${paramAnnotation}${indexParam})`;
|
|
484
|
+
} else if (loop.objectIteration === "keys") {
|
|
485
|
+
chainedArray = `Object.keys(${chainedArray})`;
|
|
486
|
+
callbackParam = `(${loop.param}${paramAnnotation})`;
|
|
487
|
+
} else if (loop.objectIteration === "values") {
|
|
488
|
+
chainedArray = `Object.values(${chainedArray})`;
|
|
489
|
+
callbackParam = `(${loop.param}${paramAnnotation})`;
|
|
481
490
|
} else {
|
|
482
491
|
callbackParam = `(${loop.param}${paramAnnotation}${indexParam})`;
|
|
483
492
|
}
|
|
@@ -570,7 +579,7 @@ export default ${this.componentName}` : "";
|
|
|
570
579
|
return `<>{bfComment(\`scope:\${__scopeId}${hostExpr}${propsExpr}\`)}${body}</>`;
|
|
571
580
|
}
|
|
572
581
|
elementAttrEmitter = {
|
|
573
|
-
emitLiteral: (value, name) => `${name}="${value.value}"`,
|
|
582
|
+
emitLiteral: (value, name) => `${name}="${escapeHtml(value.value)}"`,
|
|
574
583
|
emitExpression: (value, name) => {
|
|
575
584
|
if (isBooleanAttr(name) || value.presenceOrUndefined) {
|
|
576
585
|
return `${name}={(${value.expr}) || undefined}`;
|
|
@@ -584,7 +593,7 @@ export default ${this.componentName}` : "";
|
|
|
584
593
|
emitJsxChildren: () => ""
|
|
585
594
|
};
|
|
586
595
|
componentPropEmitter = {
|
|
587
|
-
emitLiteral: (value, name) => `${name}="${value.value}"`,
|
|
596
|
+
emitLiteral: (value, name) => `${name}="${escapeHtml(value.value)}"`,
|
|
588
597
|
emitExpression: (value, name) => `${name}={${value.expr}}`,
|
|
589
598
|
emitBooleanAttr: (_value, name) => name,
|
|
590
599
|
emitBooleanShorthand: (_value, name) => name,
|
|
@@ -600,7 +609,8 @@ export default ${this.componentName}` : "";
|
|
|
600
609
|
for (const attr of element.attrs) {
|
|
601
610
|
if (attr.clientOnly)
|
|
602
611
|
continue;
|
|
603
|
-
const
|
|
612
|
+
const jsxName = attr.name === "class" ? "className" : attr.name;
|
|
613
|
+
const lowered = emitAttrValue(attr.value, this.elementAttrEmitter, jsxName);
|
|
604
614
|
if (lowered)
|
|
605
615
|
parts.push(lowered);
|
|
606
616
|
}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
emitAttrValue,
|
|
8
8
|
buildLoopChainExpr
|
|
9
9
|
} from "@barefootjs/jsx";
|
|
10
|
-
import { BF_SCOPE, BF_HOST, BF_AT, BF_ROOT, BF_PROPS, BF_REGION } from "@barefootjs/shared";
|
|
10
|
+
import { BF_SCOPE, BF_HOST, BF_AT, BF_ROOT, BF_PROPS, BF_REGION, escapeHtml } from "@barefootjs/shared";
|
|
11
11
|
function applyHonoLoopChain(loop) {
|
|
12
12
|
return buildLoopChainExpr({
|
|
13
13
|
base: loop.array,
|
|
@@ -397,7 +397,7 @@ export default ${this.componentName}` : "";
|
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
renderText(text) {
|
|
400
|
-
return text.value;
|
|
400
|
+
return escapeHtml(text.value).replace(/\{/g, "{").replace(/\}/g, "}");
|
|
401
401
|
}
|
|
402
402
|
renderExpression(expr) {
|
|
403
403
|
if (expr.expr === "null" || expr.expr === "undefined") {
|
|
@@ -478,6 +478,15 @@ export default ${this.componentName}` : "";
|
|
|
478
478
|
} else if (loop.iterationShape === "keys") {
|
|
479
479
|
chainedArray = `[...${chainedArray}.keys()]`;
|
|
480
480
|
callbackParam = `(${loop.param}${paramAnnotation})`;
|
|
481
|
+
} else if (loop.objectIteration === "entries") {
|
|
482
|
+
chainedArray = `Object.entries(${chainedArray})`;
|
|
483
|
+
callbackParam = loop.index ? `([${loop.index}${indexAnnotation}, ${loop.param}${paramAnnotation}])` : `(${loop.param}${paramAnnotation}${indexParam})`;
|
|
484
|
+
} else if (loop.objectIteration === "keys") {
|
|
485
|
+
chainedArray = `Object.keys(${chainedArray})`;
|
|
486
|
+
callbackParam = `(${loop.param}${paramAnnotation})`;
|
|
487
|
+
} else if (loop.objectIteration === "values") {
|
|
488
|
+
chainedArray = `Object.values(${chainedArray})`;
|
|
489
|
+
callbackParam = `(${loop.param}${paramAnnotation})`;
|
|
481
490
|
} else {
|
|
482
491
|
callbackParam = `(${loop.param}${paramAnnotation}${indexParam})`;
|
|
483
492
|
}
|
|
@@ -570,7 +579,7 @@ export default ${this.componentName}` : "";
|
|
|
570
579
|
return `<>{bfComment(\`scope:\${__scopeId}${hostExpr}${propsExpr}\`)}${body}</>`;
|
|
571
580
|
}
|
|
572
581
|
elementAttrEmitter = {
|
|
573
|
-
emitLiteral: (value, name) => `${name}="${value.value}"`,
|
|
582
|
+
emitLiteral: (value, name) => `${name}="${escapeHtml(value.value)}"`,
|
|
574
583
|
emitExpression: (value, name) => {
|
|
575
584
|
if (isBooleanAttr(name) || value.presenceOrUndefined) {
|
|
576
585
|
return `${name}={(${value.expr}) || undefined}`;
|
|
@@ -584,7 +593,7 @@ export default ${this.componentName}` : "";
|
|
|
584
593
|
emitJsxChildren: () => ""
|
|
585
594
|
};
|
|
586
595
|
componentPropEmitter = {
|
|
587
|
-
emitLiteral: (value, name) => `${name}="${value.value}"`,
|
|
596
|
+
emitLiteral: (value, name) => `${name}="${escapeHtml(value.value)}"`,
|
|
588
597
|
emitExpression: (value, name) => `${name}={${value.expr}}`,
|
|
589
598
|
emitBooleanAttr: (_value, name) => name,
|
|
590
599
|
emitBooleanShorthand: (_value, name) => name,
|
|
@@ -600,7 +609,8 @@ export default ${this.componentName}` : "";
|
|
|
600
609
|
for (const attr of element.attrs) {
|
|
601
610
|
if (attr.clientOnly)
|
|
602
611
|
continue;
|
|
603
|
-
const
|
|
612
|
+
const jsxName = attr.name === "class" ? "className" : attr.name;
|
|
613
|
+
const lowered = emitAttrValue(attr.value, this.elementAttrEmitter, jsxName);
|
|
604
614
|
if (lowered)
|
|
605
615
|
parts.push(lowered);
|
|
606
616
|
}
|
package/package.json
CHANGED
|
@@ -47,7 +47,7 @@ type HonoRenderCtx = {
|
|
|
47
47
|
isInsideLoop?: boolean
|
|
48
48
|
isLoopItemRoot?: boolean
|
|
49
49
|
}
|
|
50
|
-
import { BF_SCOPE, BF_HOST, BF_AT, BF_ROOT, BF_PROPS, BF_REGION } from '@barefootjs/shared'
|
|
50
|
+
import { BF_SCOPE, BF_HOST, BF_AT, BF_ROOT, BF_PROPS, BF_REGION, escapeHtml } from '@barefootjs/shared'
|
|
51
51
|
|
|
52
52
|
export interface HonoAdapterOptions {
|
|
53
53
|
/**
|
|
@@ -731,7 +731,13 @@ export class HonoAdapter extends JsxAdapter implements IRNodeEmitter<HonoRenderC
|
|
|
731
731
|
}
|
|
732
732
|
|
|
733
733
|
private renderText(text: IRText): string {
|
|
734
|
-
|
|
734
|
+
// IRText carries the entity-DECODED value (Phase 1 decodes JSX
|
|
735
|
+
// character references). Re-encode for JSX SOURCE text: the shared
|
|
736
|
+
// HTML escape covers `< > & "` (the JSX parser decodes them right
|
|
737
|
+
// back; raw `'` is legal JSX text), and `{`/`}` — JSX expression delimiters with no named
|
|
738
|
+
// entity — go numeric. Rendering then re-escapes with Hono's own
|
|
739
|
+
// set, so output bytes match the pre-decode pipeline.
|
|
740
|
+
return escapeHtml(text.value).replace(/\{/g, '{').replace(/\}/g, '}')
|
|
735
741
|
}
|
|
736
742
|
|
|
737
743
|
renderExpression(expr: IRExpression): string {
|
|
@@ -899,6 +905,27 @@ export class HonoAdapter extends JsxAdapter implements IRNodeEmitter<HonoRenderC
|
|
|
899
905
|
} else if (loop.iterationShape === 'keys') {
|
|
900
906
|
chainedArray = `[...${chainedArray}.keys()]`
|
|
901
907
|
callbackParam = `(${loop.param}${paramAnnotation})`
|
|
908
|
+
} else if (loop.objectIteration === 'entries') {
|
|
909
|
+
// `objectIteration` (#2168 object-entries-map): reconstruct the
|
|
910
|
+
// STATIC `Object.entries(x)` call the IR stripped off (`x` is
|
|
911
|
+
// `chainedArray` here — a plain object, not an array). Unlike the
|
|
912
|
+
// array `iterationShape === 'entries'` case above, this does NOT
|
|
913
|
+
// require `loop.index` to be truthy: an elided/nested destructure
|
|
914
|
+
// (`([, cfg]) => …`) leaves `index` null and falls to the generic
|
|
915
|
+
// `paramAnnotation`/`loop.param` fallback below, where `loop.param`
|
|
916
|
+
// is already the raw (valid) destructure-pattern text — only the
|
|
917
|
+
// ARRAY needs wrapping in that case, matching the analogous split
|
|
918
|
+
// in `applyIterationShape` (`ir-to-client-js/html-template.ts`).
|
|
919
|
+
chainedArray = `Object.entries(${chainedArray})`
|
|
920
|
+
callbackParam = loop.index
|
|
921
|
+
? `([${loop.index}${indexAnnotation}, ${loop.param}${paramAnnotation}])`
|
|
922
|
+
: `(${loop.param}${paramAnnotation}${indexParam})`
|
|
923
|
+
} else if (loop.objectIteration === 'keys') {
|
|
924
|
+
chainedArray = `Object.keys(${chainedArray})`
|
|
925
|
+
callbackParam = `(${loop.param}${paramAnnotation})`
|
|
926
|
+
} else if (loop.objectIteration === 'values') {
|
|
927
|
+
chainedArray = `Object.values(${chainedArray})`
|
|
928
|
+
callbackParam = `(${loop.param}${paramAnnotation})`
|
|
902
929
|
} else {
|
|
903
930
|
callbackParam = `(${loop.param}${paramAnnotation}${indexParam})`
|
|
904
931
|
}
|
|
@@ -1076,7 +1103,10 @@ export class HonoAdapter extends JsxAdapter implements IRNodeEmitter<HonoRenderC
|
|
|
1076
1103
|
* AttrValue kind becomes a TS compile error here (#1290 step 2).
|
|
1077
1104
|
*/
|
|
1078
1105
|
private readonly elementAttrEmitter: AttrValueEmitter = {
|
|
1079
|
-
|
|
1106
|
+
// The decoded static value re-encodes for the JSX attr string (the
|
|
1107
|
+
// JSX parser decodes entities in quoted attribute values, so the
|
|
1108
|
+
// runtime sees the decoded string and escapes it on render).
|
|
1109
|
+
emitLiteral: (value, name) => `${name}="${escapeHtml(value.value)}"`,
|
|
1080
1110
|
emitExpression: (value, name) => {
|
|
1081
1111
|
// Boolean attrs / presence-folded expressions: pass `undefined` when
|
|
1082
1112
|
// falsy so Hono omits the attribute. Wrap in parens to keep `??`
|
|
@@ -1106,9 +1136,11 @@ export class HonoAdapter extends JsxAdapter implements IRNodeEmitter<HonoRenderC
|
|
|
1106
1136
|
private readonly componentPropEmitter: AttrValueEmitter = {
|
|
1107
1137
|
emitLiteral: (value, name) =>
|
|
1108
1138
|
// IR-authoritative string literal: `<X fill="var(--c)" />`.
|
|
1109
|
-
// Emitting
|
|
1110
|
-
// (`var(...)`, `url(...)`,
|
|
1111
|
-
|
|
1139
|
+
// Emitting as a plain JSX attr string (not a JS expression) is what
|
|
1140
|
+
// distinguishes a CSS-shaped value (`var(...)`, `url(...)`,
|
|
1141
|
+
// `calc(...)`) from a JS expression. The decoded value re-encodes
|
|
1142
|
+
// so the JSX parser hands the component the same decoded string.
|
|
1143
|
+
`${name}="${escapeHtml(value.value)}"`,
|
|
1112
1144
|
emitExpression: (value, name) => `${name}={${value.expr}}`,
|
|
1113
1145
|
emitBooleanAttr: (_value, name) => name,
|
|
1114
1146
|
emitBooleanShorthand: (_value, name) => name,
|
|
@@ -1132,7 +1164,15 @@ export class HonoAdapter extends JsxAdapter implements IRNodeEmitter<HonoRenderC
|
|
|
1132
1164
|
// mismatch where the server renders an attribute the client would
|
|
1133
1165
|
// re-derive on mount. #1966
|
|
1134
1166
|
if (attr.clientOnly) continue
|
|
1135
|
-
|
|
1167
|
+
// The IR carries the canonical HTML attribute name (#2172:
|
|
1168
|
+
// `processAttributes` normalizes `className`→`class`, `htmlFor`→
|
|
1169
|
+
// `for`, camelCase aliases → lowercase). This adapter's target
|
|
1170
|
+
// language is JSX typed against `@barefootjs/jsx` html-types,
|
|
1171
|
+
// whose vocabulary is those same lowercase HTML names with ONE
|
|
1172
|
+
// JSX-ism: `className` (`class?: never`, #773). Map it back at
|
|
1173
|
+
// emit — the JSX-language equivalent of Go emitting `{{.X}}`.
|
|
1174
|
+
const jsxName = attr.name === 'class' ? 'className' : attr.name
|
|
1175
|
+
const lowered = emitAttrValue(attr.value, this.elementAttrEmitter, jsxName)
|
|
1136
1176
|
if (lowered) parts.push(lowered)
|
|
1137
1177
|
}
|
|
1138
1178
|
|