tina4-nodejs 3.13.156 → 3.13.158
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/CLAUDE.md +4 -3
- package/package.json +3 -3
- package/packages/cli/dist/bin.js +1304 -616
- package/packages/core/dist/index.js +1313 -616
- package/packages/core/public/bundled-component-provenance.json +2 -2
- package/packages/core/public/js/frond.js +26 -7
- package/packages/core/public/js/frond.min.js +1 -1
- package/packages/core/src/index.ts +18 -0
- package/packages/core/src/middleware.ts +10 -4
- package/packages/core/src/queue.ts +42 -32
- package/packages/core/src/queueBackends/kafkaBackend.ts +687 -544
- package/packages/core/src/server.ts +19 -3
- package/packages/core/src/tcp.ts +484 -0
- package/packages/frond/dist/index.js +118 -4
- package/packages/frond/src/engine.ts +87 -8
- package/packages/frond/src/index.ts +1 -1
- package/packages/orm/dist/index.js +1306 -618
- package/packages/orm/src/queryBuilder.ts +38 -0
- package/types/core/src/index.d.ts +2 -0
- package/types/core/src/queue.d.ts +1 -1
- package/types/core/src/queueBackends/kafkaBackend.d.ts +48 -54
- package/types/core/src/tcp.d.ts +165 -0
- package/types/frond/src/engine.d.ts +9 -0
- package/types/frond/src/index.d.ts +1 -1
- package/types/orm/src/queryBuilder.d.ts +28 -0
|
@@ -1691,6 +1691,77 @@ function toOutputString(value: unknown): string {
|
|
|
1691
1691
|
return String(value);
|
|
1692
1692
|
}
|
|
1693
1693
|
|
|
1694
|
+
/**
|
|
1695
|
+
* Thrown when a Frond template is malformed and cannot be rendered safely
|
|
1696
|
+
* (ADR-0104) — an unclosed `{% block %}` or a cut-short `{% endblock %` whose
|
|
1697
|
+
* closing `%}` is missing. Failing loud surfaces the real cause to a developer
|
|
1698
|
+
* (or an AI agent) instead of a page served 200 with its body quietly dropped.
|
|
1699
|
+
*/
|
|
1700
|
+
export class FrondSyntaxError extends Error {
|
|
1701
|
+
constructor(message: string) {
|
|
1702
|
+
super(message);
|
|
1703
|
+
this.name = "FrondSyntaxError";
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
const PHP_MONTHS = [
|
|
1708
|
+
"January", "February", "March", "April", "May", "June",
|
|
1709
|
+
"July", "August", "September", "October", "November", "December",
|
|
1710
|
+
];
|
|
1711
|
+
// getDay(): 0 == Sunday .. 6 == Saturday
|
|
1712
|
+
const PHP_DAYS = [
|
|
1713
|
+
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",
|
|
1714
|
+
];
|
|
1715
|
+
|
|
1716
|
+
/**
|
|
1717
|
+
* Format a Date with Twig/PHP date() letters (English names) — ADR-0103.
|
|
1718
|
+
*
|
|
1719
|
+
* Letters are mapped character by character; a backslash escapes the next
|
|
1720
|
+
* character, and any unmapped character is emitted literally (PHP's rule).
|
|
1721
|
+
* English month/day names are hardcoded so the output matches every other Tina4
|
|
1722
|
+
* framework regardless of the host locale.
|
|
1723
|
+
*/
|
|
1724
|
+
function phpDate(dt: Date, fmt: string): string {
|
|
1725
|
+
const pad = (n: number) => String(n).padStart(2, "0");
|
|
1726
|
+
const hours = dt.getHours();
|
|
1727
|
+
const h12 = hours % 12 || 12;
|
|
1728
|
+
const dow = dt.getDay(); // 0 == Sunday .. 6 == Saturday
|
|
1729
|
+
const iso = dow === 0 ? 7 : dow; // ISO day of week: 1 == Monday .. 7 == Sunday
|
|
1730
|
+
let out = "";
|
|
1731
|
+
for (let i = 0; i < fmt.length; i++) {
|
|
1732
|
+
const c = fmt[i];
|
|
1733
|
+
if (c === "\\" && i + 1 < fmt.length) {
|
|
1734
|
+
out += fmt[i + 1];
|
|
1735
|
+
i++;
|
|
1736
|
+
continue;
|
|
1737
|
+
}
|
|
1738
|
+
switch (c) {
|
|
1739
|
+
case "Y": out += String(dt.getFullYear()); break;
|
|
1740
|
+
case "y": out += pad(dt.getFullYear() % 100); break;
|
|
1741
|
+
case "m": out += pad(dt.getMonth() + 1); break;
|
|
1742
|
+
case "n": out += String(dt.getMonth() + 1); break;
|
|
1743
|
+
case "d": out += pad(dt.getDate()); break;
|
|
1744
|
+
case "j": out += String(dt.getDate()); break;
|
|
1745
|
+
case "H": out += pad(hours); break;
|
|
1746
|
+
case "G": out += String(hours); break;
|
|
1747
|
+
case "h": out += pad(h12); break;
|
|
1748
|
+
case "g": out += String(h12); break;
|
|
1749
|
+
case "i": out += pad(dt.getMinutes()); break;
|
|
1750
|
+
case "s": out += pad(dt.getSeconds()); break;
|
|
1751
|
+
case "A": out += hours < 12 ? "AM" : "PM"; break;
|
|
1752
|
+
case "a": out += hours < 12 ? "am" : "pm"; break;
|
|
1753
|
+
case "D": out += PHP_DAYS[dow].slice(0, 3); break;
|
|
1754
|
+
case "l": out += PHP_DAYS[dow]; break;
|
|
1755
|
+
case "M": out += PHP_MONTHS[dt.getMonth()].slice(0, 3); break;
|
|
1756
|
+
case "F": out += PHP_MONTHS[dt.getMonth()]; break;
|
|
1757
|
+
case "N": out += String(iso); break;
|
|
1758
|
+
case "w": out += String(dow); break;
|
|
1759
|
+
default: out += c;
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
return out;
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1694
1765
|
function dateFilter(value: unknown, fmt: string): string {
|
|
1695
1766
|
let dt: Date;
|
|
1696
1767
|
if (value instanceof Date) {
|
|
@@ -1704,6 +1775,10 @@ function dateFilter(value: unknown, fmt: string): string {
|
|
|
1704
1775
|
return String(value);
|
|
1705
1776
|
}
|
|
1706
1777
|
|
|
1778
|
+
// A strftime-style format (any with %) stays strftime — back-compatible;
|
|
1779
|
+
// any other format is treated as Twig/PHP date() letters (ADR-0103).
|
|
1780
|
+
if (!fmt.includes("%")) return phpDate(dt, fmt);
|
|
1781
|
+
|
|
1707
1782
|
// Python strftime format to manual conversion
|
|
1708
1783
|
return fmt
|
|
1709
1784
|
.replace(/%Y/g, String(dt.getFullYear()))
|
|
@@ -2507,8 +2582,13 @@ export class Frond {
|
|
|
2507
2582
|
}
|
|
2508
2583
|
|
|
2509
2584
|
if (depth > 0) {
|
|
2510
|
-
//
|
|
2511
|
-
|
|
2585
|
+
// Unclosed {% block %} (or a cut-short {% endblock % whose %} is
|
|
2586
|
+
// missing, so the close regex never matches) — fail loud
|
|
2587
|
+
// (tina4#286/#290) rather than silently dropping the body. Still
|
|
2588
|
+
// bounded: we throw, we never loop (tina4#271).
|
|
2589
|
+
throw new FrondSyntaxError(
|
|
2590
|
+
`{% block ${name} %} is never closed (missing or malformed {% endblock %})`,
|
|
2591
|
+
);
|
|
2512
2592
|
}
|
|
2513
2593
|
}
|
|
2514
2594
|
return blocks;
|
|
@@ -2587,12 +2667,11 @@ export class Frond {
|
|
|
2587
2667
|
}
|
|
2588
2668
|
|
|
2589
2669
|
if (!closeMatch) {
|
|
2590
|
-
//
|
|
2591
|
-
//
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
break;
|
|
2670
|
+
// Unclosed {% block %} — fail loud (tina4#286/#290), matching
|
|
2671
|
+
// extractBlocks, rather than silently keeping the rest verbatim.
|
|
2672
|
+
throw new FrondSyntaxError(
|
|
2673
|
+
`{% block ${name} %} is never closed (missing or malformed {% endblock %})`,
|
|
2674
|
+
);
|
|
2596
2675
|
}
|
|
2597
2676
|
|
|
2598
2677
|
const parentContent = source.slice(contentStart, closeMatch.index);
|
|
@@ -6,5 +6,5 @@ License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
6
6
|
file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
export { Frond, escapeHtml, setCspNonceProvider, setFormTokenSessionProvider } from "./engine.js";
|
|
9
|
+
export { Frond, FrondSyntaxError, escapeHtml, setCspNonceProvider, setFormTokenSessionProvider } from "./engine.js";
|
|
10
10
|
export type { FilterFn, TestFn, LiveProvider, LiveRequest, LiveResponse, LiveBroadcaster } from "./engine.js";
|