tina4-nodejs 3.13.157 → 3.13.159
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 +1384 -639
- package/packages/cli/src/commands/generate.ts +72 -23
- package/packages/core/dist/index.js +1393 -639
- 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 +41 -4
- 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 +1386 -641
- package/packages/orm/src/migration.ts +34 -0
- 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/migration.d.ts +0 -24
- package/types/orm/src/queryBuilder.d.ts +28 -0
|
@@ -1313,6 +1313,116 @@ function isEscapableStructured(value) {
|
|
|
1313
1313
|
function toOutputString(value) {
|
|
1314
1314
|
return String(value);
|
|
1315
1315
|
}
|
|
1316
|
+
var FrondSyntaxError = class extends Error {
|
|
1317
|
+
constructor(message) {
|
|
1318
|
+
super(message);
|
|
1319
|
+
this.name = "FrondSyntaxError";
|
|
1320
|
+
}
|
|
1321
|
+
};
|
|
1322
|
+
var PHP_MONTHS = [
|
|
1323
|
+
"January",
|
|
1324
|
+
"February",
|
|
1325
|
+
"March",
|
|
1326
|
+
"April",
|
|
1327
|
+
"May",
|
|
1328
|
+
"June",
|
|
1329
|
+
"July",
|
|
1330
|
+
"August",
|
|
1331
|
+
"September",
|
|
1332
|
+
"October",
|
|
1333
|
+
"November",
|
|
1334
|
+
"December"
|
|
1335
|
+
];
|
|
1336
|
+
var PHP_DAYS = [
|
|
1337
|
+
"Sunday",
|
|
1338
|
+
"Monday",
|
|
1339
|
+
"Tuesday",
|
|
1340
|
+
"Wednesday",
|
|
1341
|
+
"Thursday",
|
|
1342
|
+
"Friday",
|
|
1343
|
+
"Saturday"
|
|
1344
|
+
];
|
|
1345
|
+
function phpDate(dt, fmt) {
|
|
1346
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
1347
|
+
const hours = dt.getHours();
|
|
1348
|
+
const h12 = hours % 12 || 12;
|
|
1349
|
+
const dow = dt.getDay();
|
|
1350
|
+
const iso = dow === 0 ? 7 : dow;
|
|
1351
|
+
let out = "";
|
|
1352
|
+
for (let i = 0; i < fmt.length; i++) {
|
|
1353
|
+
const c = fmt[i];
|
|
1354
|
+
if (c === "\\" && i + 1 < fmt.length) {
|
|
1355
|
+
out += fmt[i + 1];
|
|
1356
|
+
i++;
|
|
1357
|
+
continue;
|
|
1358
|
+
}
|
|
1359
|
+
switch (c) {
|
|
1360
|
+
case "Y":
|
|
1361
|
+
out += String(dt.getFullYear());
|
|
1362
|
+
break;
|
|
1363
|
+
case "y":
|
|
1364
|
+
out += pad(dt.getFullYear() % 100);
|
|
1365
|
+
break;
|
|
1366
|
+
case "m":
|
|
1367
|
+
out += pad(dt.getMonth() + 1);
|
|
1368
|
+
break;
|
|
1369
|
+
case "n":
|
|
1370
|
+
out += String(dt.getMonth() + 1);
|
|
1371
|
+
break;
|
|
1372
|
+
case "d":
|
|
1373
|
+
out += pad(dt.getDate());
|
|
1374
|
+
break;
|
|
1375
|
+
case "j":
|
|
1376
|
+
out += String(dt.getDate());
|
|
1377
|
+
break;
|
|
1378
|
+
case "H":
|
|
1379
|
+
out += pad(hours);
|
|
1380
|
+
break;
|
|
1381
|
+
case "G":
|
|
1382
|
+
out += String(hours);
|
|
1383
|
+
break;
|
|
1384
|
+
case "h":
|
|
1385
|
+
out += pad(h12);
|
|
1386
|
+
break;
|
|
1387
|
+
case "g":
|
|
1388
|
+
out += String(h12);
|
|
1389
|
+
break;
|
|
1390
|
+
case "i":
|
|
1391
|
+
out += pad(dt.getMinutes());
|
|
1392
|
+
break;
|
|
1393
|
+
case "s":
|
|
1394
|
+
out += pad(dt.getSeconds());
|
|
1395
|
+
break;
|
|
1396
|
+
case "A":
|
|
1397
|
+
out += hours < 12 ? "AM" : "PM";
|
|
1398
|
+
break;
|
|
1399
|
+
case "a":
|
|
1400
|
+
out += hours < 12 ? "am" : "pm";
|
|
1401
|
+
break;
|
|
1402
|
+
case "D":
|
|
1403
|
+
out += PHP_DAYS[dow].slice(0, 3);
|
|
1404
|
+
break;
|
|
1405
|
+
case "l":
|
|
1406
|
+
out += PHP_DAYS[dow];
|
|
1407
|
+
break;
|
|
1408
|
+
case "M":
|
|
1409
|
+
out += PHP_MONTHS[dt.getMonth()].slice(0, 3);
|
|
1410
|
+
break;
|
|
1411
|
+
case "F":
|
|
1412
|
+
out += PHP_MONTHS[dt.getMonth()];
|
|
1413
|
+
break;
|
|
1414
|
+
case "N":
|
|
1415
|
+
out += String(iso);
|
|
1416
|
+
break;
|
|
1417
|
+
case "w":
|
|
1418
|
+
out += String(dow);
|
|
1419
|
+
break;
|
|
1420
|
+
default:
|
|
1421
|
+
out += c;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
return out;
|
|
1425
|
+
}
|
|
1316
1426
|
function dateFilter(value, fmt) {
|
|
1317
1427
|
let dt;
|
|
1318
1428
|
if (value instanceof Date) {
|
|
@@ -1325,6 +1435,7 @@ function dateFilter(value, fmt) {
|
|
|
1325
1435
|
} else {
|
|
1326
1436
|
return String(value);
|
|
1327
1437
|
}
|
|
1438
|
+
if (!fmt.includes("%")) return phpDate(dt, fmt);
|
|
1328
1439
|
return fmt.replace(/%Y/g, String(dt.getFullYear())).replace(/%m/g, String(dt.getMonth() + 1).padStart(2, "0")).replace(/%d/g, String(dt.getDate()).padStart(2, "0")).replace(/%H/g, String(dt.getHours()).padStart(2, "0")).replace(/%M/g, String(dt.getMinutes()).padStart(2, "0")).replace(/%S/g, String(dt.getSeconds()).padStart(2, "0")).replace(/%I/g, String(dt.getHours() % 12 || 12).padStart(2, "0")).replace(/%p/g, dt.getHours() >= 12 ? "PM" : "AM").replace(/%B/g, dt.toLocaleString("en-US", { month: "long" })).replace(/%b/g, dt.toLocaleString("en-US", { month: "short" })).replace(/%A/g, dt.toLocaleString("en-US", { weekday: "long" })).replace(/%a/g, dt.toLocaleString("en-US", { weekday: "short" }));
|
|
1329
1440
|
}
|
|
1330
1441
|
function wordwrap(text, width) {
|
|
@@ -1955,7 +2066,9 @@ var Frond = class _Frond {
|
|
|
1955
2066
|
}
|
|
1956
2067
|
}
|
|
1957
2068
|
if (depth > 0) {
|
|
1958
|
-
|
|
2069
|
+
throw new FrondSyntaxError(
|
|
2070
|
+
`{% block ${name} %} is never closed (missing or malformed {% endblock %})`
|
|
2071
|
+
);
|
|
1959
2072
|
}
|
|
1960
2073
|
}
|
|
1961
2074
|
return blocks;
|
|
@@ -2022,9 +2135,9 @@ var Frond = class _Frond {
|
|
|
2022
2135
|
}
|
|
2023
2136
|
}
|
|
2024
2137
|
if (!closeMatch) {
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2138
|
+
throw new FrondSyntaxError(
|
|
2139
|
+
`{% block ${name} %} is never closed (missing or malformed {% endblock %})`
|
|
2140
|
+
);
|
|
2028
2141
|
}
|
|
2029
2142
|
const parentContent = source.slice(contentStart, closeMatch.index);
|
|
2030
2143
|
const blockSource = blocks[name] ?? parentContent;
|
|
@@ -2979,6 +3092,7 @@ var Frond = class _Frond {
|
|
|
2979
3092
|
};
|
|
2980
3093
|
export {
|
|
2981
3094
|
Frond,
|
|
3095
|
+
FrondSyntaxError,
|
|
2982
3096
|
escapeHtml,
|
|
2983
3097
|
setCspNonceProvider,
|
|
2984
3098
|
setFormTokenSessionProvider
|
|
@@ -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";
|