tina4-nodejs 3.13.163 → 3.13.164
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 +12 -8
- package/package.json +1 -1
- package/packages/cli/dist/bin.js +175 -48
- package/packages/cli/src/bin.ts +8 -3
- package/packages/core/dist/index.js +144 -45
- package/packages/core/src/devAdmin.ts +8 -3
- package/packages/core/src/portTakeover.ts +44 -10
- package/packages/core/src/server.ts +79 -5
- package/packages/frond/dist/index.js +66 -19
- package/packages/frond/src/engine.ts +74 -23
- package/packages/orm/dist/index.js +144 -45
- package/types/core/src/portTakeover.d.ts +3 -1
- package/types/frond/src/engine.d.ts +31 -2
|
@@ -7288,8 +7288,14 @@ var init_engine = __esm({
|
|
|
7288
7288
|
// and every future ``new Frond()`` inherits it automatically.
|
|
7289
7289
|
// Mirrors Python's _class_globals / _class_filters / _class_tests.
|
|
7290
7290
|
static classFilters = /* @__PURE__ */ new Map();
|
|
7291
|
-
|
|
7291
|
+
// Globals are read LIVE at render time (not copied at construction), so a
|
|
7292
|
+
// Frond.addGlobal() made after an engine exists still reaches it. A plain
|
|
7293
|
+
// object rather than a Map so render() can spread it in one step.
|
|
7294
|
+
static classGlobals = {};
|
|
7292
7295
|
static classTests = /* @__PURE__ */ new Map();
|
|
7296
|
+
// Bumped on every class-level filter/test change, so an engine knows when
|
|
7297
|
+
// to rebuild its merged filter/test maps (see syncRegistries).
|
|
7298
|
+
static classRegistryVersion = 0;
|
|
7293
7299
|
// ── Live-block registries (server-rendered {% live %} regions) ──
|
|
7294
7300
|
// A {% live %} block registers three things when its page first renders:
|
|
7295
7301
|
// liveFragments[name] -> the raw body source, re-rendered on every
|
|
@@ -7309,20 +7315,27 @@ var init_engine = __esm({
|
|
|
7309
7315
|
static liveBroadcaster = null;
|
|
7310
7316
|
/**
|
|
7311
7317
|
* Register a custom filter at the class level — available to every
|
|
7312
|
-
*
|
|
7318
|
+
* instance, existing ones included: an engine merges the class filters
|
|
7319
|
+
* again at its next render (ADR-0107). Callable as ``Frond.addFilter()``
|
|
7313
7320
|
* (static) or ``frond.addFilter()`` (instance). See instance method
|
|
7314
7321
|
* below for the dual-call semantics.
|
|
7315
7322
|
*/
|
|
7316
7323
|
static addFilter(name, fn) {
|
|
7317
7324
|
_Frond.classFilters.set(name, fn);
|
|
7325
|
+
_Frond.classRegistryVersion++;
|
|
7318
7326
|
}
|
|
7319
7327
|
/**
|
|
7320
7328
|
* Register a global variable available in all templates of every
|
|
7321
|
-
*
|
|
7329
|
+
* instance, existing ones included: class globals are read at render time
|
|
7330
|
+
* (ADR-0106). Callable as ``Frond.addGlobal()`` (static) or
|
|
7322
7331
|
* ``frond.addGlobal()`` (instance).
|
|
7323
7332
|
*/
|
|
7324
7333
|
static addGlobal(name, value) {
|
|
7325
|
-
_Frond.classGlobals
|
|
7334
|
+
_Frond.classGlobals[name] = value;
|
|
7335
|
+
}
|
|
7336
|
+
/** True when a class-level global with this name is registered. */
|
|
7337
|
+
static hasGlobal(name) {
|
|
7338
|
+
return Object.prototype.hasOwnProperty.call(_Frond.classGlobals, name);
|
|
7326
7339
|
}
|
|
7327
7340
|
/**
|
|
7328
7341
|
* Register a custom test (``{% if x is positive %}``) at the class
|
|
@@ -7331,6 +7344,7 @@ var init_engine = __esm({
|
|
|
7331
7344
|
*/
|
|
7332
7345
|
static addTest(name, fn) {
|
|
7333
7346
|
_Frond.classTests.set(name, fn);
|
|
7347
|
+
_Frond.classRegistryVersion++;
|
|
7334
7348
|
}
|
|
7335
7349
|
/**
|
|
7336
7350
|
* Clear the class-level globals/filters/tests registries.
|
|
@@ -7340,15 +7354,25 @@ var init_engine = __esm({
|
|
|
7340
7354
|
*/
|
|
7341
7355
|
static clearRegistry() {
|
|
7342
7356
|
_Frond.classFilters.clear();
|
|
7343
|
-
_Frond.classGlobals
|
|
7357
|
+
_Frond.classGlobals = {};
|
|
7344
7358
|
_Frond.classTests.clear();
|
|
7359
|
+
_Frond.classRegistryVersion++;
|
|
7345
7360
|
_Frond.liveFragments.clear();
|
|
7346
7361
|
_Frond.liveSources.clear();
|
|
7347
7362
|
_Frond.liveWsPaths.clear();
|
|
7348
7363
|
}
|
|
7349
7364
|
templateDir;
|
|
7350
|
-
filters
|
|
7365
|
+
/** Effective filters: built-in < class < instance (see syncRegistries). */
|
|
7366
|
+
filters = {};
|
|
7367
|
+
/** Filters / tests registered on THIS instance only (ADR-0052). */
|
|
7368
|
+
localFilters = {};
|
|
7369
|
+
localTests = {};
|
|
7370
|
+
/** The class-registry version `filters` / `tests` were last merged at. */
|
|
7371
|
+
registryVersion = -1;
|
|
7372
|
+
/** Globals registered on THIS instance only (ADR-0052). */
|
|
7351
7373
|
globals;
|
|
7374
|
+
/** Built-in globals (formToken, range, dump, csp_nonce, ...). */
|
|
7375
|
+
builtinGlobals;
|
|
7352
7376
|
tests;
|
|
7353
7377
|
_sandbox;
|
|
7354
7378
|
_allowedFilters;
|
|
@@ -7378,9 +7402,10 @@ var init_engine = __esm({
|
|
|
7378
7402
|
}
|
|
7379
7403
|
constructor(templateDir = "src/templates") {
|
|
7380
7404
|
this.templateDir = resolve2(templateDir);
|
|
7381
|
-
this.filters = { ...BUILTIN_FILTERS };
|
|
7382
7405
|
this.globals = {};
|
|
7406
|
+
this.builtinGlobals = {};
|
|
7383
7407
|
this.tests = {};
|
|
7408
|
+
this.syncRegistries();
|
|
7384
7409
|
this._sandbox = false;
|
|
7385
7410
|
this._allowedFilters = null;
|
|
7386
7411
|
this._allowedTags = null;
|
|
@@ -7428,16 +7453,25 @@ var init_engine = __esm({
|
|
|
7428
7453
|
return { output, next };
|
|
7429
7454
|
}
|
|
7430
7455
|
};
|
|
7431
|
-
this.
|
|
7432
|
-
this.
|
|
7433
|
-
this.
|
|
7434
|
-
this.
|
|
7435
|
-
this.
|
|
7436
|
-
this.
|
|
7437
|
-
this.
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7456
|
+
this.builtinGlobals.formToken = (descriptor) => _generateFormToken(descriptor || "");
|
|
7457
|
+
this.builtinGlobals.form_token = (descriptor) => _generateFormToken(descriptor || "");
|
|
7458
|
+
this.builtinGlobals.formTokenValue = (descriptor) => _generateFormTokenValue(descriptor || "");
|
|
7459
|
+
this.builtinGlobals.form_token_value = (descriptor) => _generateFormTokenValue(descriptor || "");
|
|
7460
|
+
this.builtinGlobals.range = frondRange;
|
|
7461
|
+
this.builtinGlobals.dump = (value) => renderDump(value);
|
|
7462
|
+
this.builtinGlobals.csp_nonce = () => _cspNonceProvider();
|
|
7463
|
+
}
|
|
7464
|
+
/**
|
|
7465
|
+
* Rebuild the merged filter/test maps when the class registry changed.
|
|
7466
|
+
* Same layering as globals -- built-ins < class < this instance. Filter
|
|
7467
|
+
* lookup is on the hot path, so the merge is a plain object rebuilt only
|
|
7468
|
+
* when the class-registry version moves, never a per-lookup chain.
|
|
7469
|
+
*/
|
|
7470
|
+
syncRegistries() {
|
|
7471
|
+
if (this.registryVersion === _Frond.classRegistryVersion) return;
|
|
7472
|
+
this.filters = { ...BUILTIN_FILTERS, ...Object.fromEntries(_Frond.classFilters), ...this.localFilters };
|
|
7473
|
+
this.tests = { ...Object.fromEntries(_Frond.classTests), ...this.localTests };
|
|
7474
|
+
this.registryVersion = _Frond.classRegistryVersion;
|
|
7441
7475
|
}
|
|
7442
7476
|
sandbox(filters, tags, vars) {
|
|
7443
7477
|
this._sandbox = true;
|
|
@@ -7458,6 +7492,7 @@ var init_engine = __esm({
|
|
|
7458
7492
|
* for process-global registration. tina4: ADR-0052.
|
|
7459
7493
|
*/
|
|
7460
7494
|
addFilter(name, fn) {
|
|
7495
|
+
this.localFilters[name] = fn;
|
|
7461
7496
|
this.filters[name] = fn;
|
|
7462
7497
|
}
|
|
7463
7498
|
/**
|
|
@@ -7470,6 +7505,7 @@ var init_engine = __esm({
|
|
|
7470
7505
|
* Register a custom test on this instance only.
|
|
7471
7506
|
*/
|
|
7472
7507
|
addTest(name, fn) {
|
|
7508
|
+
this.localTests[name] = fn;
|
|
7473
7509
|
this.tests[name] = fn;
|
|
7474
7510
|
}
|
|
7475
7511
|
/**
|
|
@@ -7485,8 +7521,19 @@ var init_engine = __esm({
|
|
|
7485
7521
|
const n = parseInt(raw, 10);
|
|
7486
7522
|
return isNaN(n) || n < 0 ? 0 : n;
|
|
7487
7523
|
}
|
|
7524
|
+
/**
|
|
7525
|
+
* Layer the globals under the render data: built-ins < class globals (read
|
|
7526
|
+
* live, so registration order never matters) < this instance's own globals
|
|
7527
|
+
* < the data passed to render(). Every render starts here, so this is also
|
|
7528
|
+
* where the filter/test maps catch up with any class registration made
|
|
7529
|
+
* since the last render.
|
|
7530
|
+
*/
|
|
7531
|
+
withGlobals(data) {
|
|
7532
|
+
this.syncRegistries();
|
|
7533
|
+
return { ...this.builtinGlobals, ..._Frond.classGlobals, ...this.globals, ...data || {} };
|
|
7534
|
+
}
|
|
7488
7535
|
render(template, data) {
|
|
7489
|
-
const context =
|
|
7536
|
+
const context = this.withGlobals(data);
|
|
7490
7537
|
const filePath = join5(this.templateDir, template);
|
|
7491
7538
|
if (!existsSync5(filePath)) {
|
|
7492
7539
|
throw new Error(`Template not found: ${filePath}`);
|
|
@@ -7509,7 +7556,7 @@ var init_engine = __esm({
|
|
|
7509
7556
|
return this.executeWithSource(source, tokens, context);
|
|
7510
7557
|
}
|
|
7511
7558
|
renderString(source, data) {
|
|
7512
|
-
const context =
|
|
7559
|
+
const context = this.withGlobals(data);
|
|
7513
7560
|
const key = createHash3("md5").update(source).digest("hex");
|
|
7514
7561
|
const ttlMs = this.cacheTtlSeconds() * 1e3;
|
|
7515
7562
|
const cached = this.compiledStrings.get(key);
|
|
@@ -10856,27 +10903,33 @@ function sleepSync(ms) {
|
|
|
10856
10903
|
if (ms <= 0) return;
|
|
10857
10904
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
10858
10905
|
}
|
|
10859
|
-
function
|
|
10906
|
+
function bindable(host, port) {
|
|
10907
|
+
try {
|
|
10908
|
+
execFileSync(process.execPath, ["-e", BIND_PROBE, host, String(port)], { stdio: "ignore", timeout: 5e3 });
|
|
10909
|
+
return true;
|
|
10910
|
+
} catch {
|
|
10911
|
+
return false;
|
|
10912
|
+
}
|
|
10913
|
+
}
|
|
10914
|
+
function refusal(port, dev, noTakeover, host) {
|
|
10915
|
+
if (dev && !noTakeover) return null;
|
|
10916
|
+
if (host !== void 0 && bindable(host, port)) {
|
|
10917
|
+
return { status: TAKEOVER_NOTHING, port, killed: [], message: "" };
|
|
10918
|
+
}
|
|
10919
|
+
if (noTakeover) {
|
|
10920
|
+
return { status: TAKEOVER_REFUSED_OPTOUT, port, killed: [], message: `Port ${port} is in use and takeover is disabled (TINA4_NO_TAKEOVER/--no-kill) -- free it or choose another port.` };
|
|
10921
|
+
}
|
|
10922
|
+
return { status: TAKEOVER_REFUSED_PROD, port, killed: [], message: `Port ${port} is in use; takeover is disabled outside dev mode -- free it or choose another port.` };
|
|
10923
|
+
}
|
|
10924
|
+
function takeOverPort(port, dev, noTakeover, baseDir, grace = 500, host) {
|
|
10860
10925
|
const make = (status2, killed2 = [], message = "") => ({
|
|
10861
10926
|
status: status2,
|
|
10862
10927
|
port,
|
|
10863
10928
|
killed: killed2,
|
|
10864
10929
|
message
|
|
10865
10930
|
});
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
-
TAKEOVER_REFUSED_OPTOUT,
|
|
10869
|
-
[],
|
|
10870
|
-
`Port ${port} is in use and takeover is disabled (TINA4_NO_TAKEOVER/--no-kill) -- free it or choose another port.`
|
|
10871
|
-
);
|
|
10872
|
-
}
|
|
10873
|
-
if (!dev) {
|
|
10874
|
-
return make(
|
|
10875
|
-
TAKEOVER_REFUSED_PROD,
|
|
10876
|
-
[],
|
|
10877
|
-
`Port ${port} is in use; takeover is disabled outside dev mode -- free it or choose another port.`
|
|
10878
|
-
);
|
|
10879
|
-
}
|
|
10931
|
+
const early = refusal(port, dev, noTakeover, host);
|
|
10932
|
+
if (early !== null) return early;
|
|
10880
10933
|
if (inContainer()) return make(TAKEOVER_SKIPPED_CONTAINER);
|
|
10881
10934
|
const tokens = portHolders(port);
|
|
10882
10935
|
if (tokens.length === 0) return make(TAKEOVER_NOTHING);
|
|
@@ -10908,7 +10961,7 @@ function takeOverPort(port, dev, noTakeover, baseDir, grace = 500) {
|
|
|
10908
10961
|
`Reclaimed port ${port} from Tina4 dev server (PID: ${killed.join(", ")}).`
|
|
10909
10962
|
);
|
|
10910
10963
|
}
|
|
10911
|
-
var TAKEOVER_NOTHING, TAKEOVER_KILLED, TAKEOVER_REFUSED_FOREIGN, TAKEOVER_REFUSED_OPTOUT, TAKEOVER_REFUSED_PROD, TAKEOVER_SKIPPED_CONTAINER, TAKEOVER_REFUSALS;
|
|
10964
|
+
var TAKEOVER_NOTHING, TAKEOVER_KILLED, TAKEOVER_REFUSED_FOREIGN, TAKEOVER_REFUSED_OPTOUT, TAKEOVER_REFUSED_PROD, TAKEOVER_SKIPPED_CONTAINER, TAKEOVER_REFUSALS, BIND_PROBE;
|
|
10912
10965
|
var init_portTakeover = __esm({
|
|
10913
10966
|
"../core/src/portTakeover.ts"() {
|
|
10914
10967
|
"use strict";
|
|
@@ -10923,6 +10976,7 @@ var init_portTakeover = __esm({
|
|
|
10923
10976
|
TAKEOVER_REFUSED_OPTOUT,
|
|
10924
10977
|
TAKEOVER_REFUSED_PROD
|
|
10925
10978
|
];
|
|
10979
|
+
BIND_PROBE = 'const s = require("node:net").createServer();s.on("error", () => process.exit(1));s.listen({ host: process.argv[1], port: Number(process.argv[2]) }, () => s.close(() => process.exit(0)));';
|
|
10926
10980
|
}
|
|
10927
10981
|
});
|
|
10928
10982
|
|
|
@@ -27187,6 +27241,7 @@ var init_devAdmin = __esm({
|
|
|
27187
27241
|
const mem = process.memoryUsage();
|
|
27188
27242
|
const heapUsedMb = Math.round(mem.heapUsed / 1048576);
|
|
27189
27243
|
const rssMb = Math.round(mem.rss / 1048576);
|
|
27244
|
+
const peakRssMb = Math.round(process.resourceUsage().maxRSS / 1024);
|
|
27190
27245
|
let dbTableCount;
|
|
27191
27246
|
let dbConnected = false;
|
|
27192
27247
|
try {
|
|
@@ -27203,12 +27258,14 @@ var init_devAdmin = __esm({
|
|
|
27203
27258
|
architecture: process.arch,
|
|
27204
27259
|
os: `${process.platform} ${process.arch}`,
|
|
27205
27260
|
pid: process.pid,
|
|
27206
|
-
|
|
27261
|
+
// The dashboard's "Memory": the process's current RSS, as tina4-python
|
|
27262
|
+
// reports it. V8's heapUsed (below) leaves out Buffers and native memory.
|
|
27263
|
+
memory_mb: rssMb,
|
|
27207
27264
|
db_tables: dbTableCount !== void 0 ? dbTableCount : "N/A",
|
|
27208
27265
|
db_connected: dbConnected,
|
|
27209
27266
|
memory: {
|
|
27210
|
-
current_mb:
|
|
27211
|
-
peak_mb:
|
|
27267
|
+
current_mb: rssMb,
|
|
27268
|
+
peak_mb: peakRssMb,
|
|
27212
27269
|
limit: "V8 default",
|
|
27213
27270
|
rss: `${rssMb} MB`,
|
|
27214
27271
|
heapUsed: `${heapUsedMb} MB`,
|
|
@@ -30184,6 +30241,32 @@ function swaggerAdvertised() {
|
|
|
30184
30241
|
}
|
|
30185
30242
|
return TRUTHY3.includes(raw);
|
|
30186
30243
|
}
|
|
30244
|
+
function stripUrlCredentials(text) {
|
|
30245
|
+
return text.replace(/:\/\/[^/\s]*@/g, "://");
|
|
30246
|
+
}
|
|
30247
|
+
function isModuleNotFound(err) {
|
|
30248
|
+
const code = err?.code;
|
|
30249
|
+
return code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND";
|
|
30250
|
+
}
|
|
30251
|
+
function reportOrmBootFailure(stage, err, dbConfig) {
|
|
30252
|
+
const message = stripUrlCredentials(err instanceof Error ? err.message : String(err));
|
|
30253
|
+
if (stage === "connect") {
|
|
30254
|
+
const url = (process.env.TINA4_DATABASE_URL ?? "").trim();
|
|
30255
|
+
const target = url ? stripUrlCredentials(url) : `${dbConfig.type ?? "sqlite"} ${dbConfig.path ?? "./data/tina4.db"}`;
|
|
30256
|
+
bootDbConnectError = message;
|
|
30257
|
+
console.warn(`
|
|
30258
|
+
Database could not be reached (${target}): ${message}`);
|
|
30259
|
+
} else if (stage === "import" && isModuleNotFound(err)) {
|
|
30260
|
+
console.warn(`
|
|
30261
|
+
ORM not available (install @tina4/orm to enable): ${message}`);
|
|
30262
|
+
} else if (stage === "import") {
|
|
30263
|
+
console.warn(`
|
|
30264
|
+
ORM failed to load:`, err);
|
|
30265
|
+
} else {
|
|
30266
|
+
console.warn(`
|
|
30267
|
+
ORM model setup failed:`, err);
|
|
30268
|
+
}
|
|
30269
|
+
}
|
|
30187
30270
|
async function autoMigrateOnStartup(migrationDir = "migrations", base = process.cwd()) {
|
|
30188
30271
|
const dir = resolve15(base, migrationDir);
|
|
30189
30272
|
if (!existsSync23(dir)) return;
|
|
@@ -30202,9 +30285,20 @@ async function autoMigrateOnStartup(migrationDir = "migrations", base = process.
|
|
|
30202
30285
|
let orm;
|
|
30203
30286
|
try {
|
|
30204
30287
|
orm = await Promise.resolve().then(() => (init_index(), index_exports));
|
|
30288
|
+
} catch (err) {
|
|
30289
|
+
Log.debug(`Startup migrations skipped (ORM not available): ${stripUrlCredentials(err instanceof Error ? err.message : String(err))}`);
|
|
30290
|
+
return;
|
|
30291
|
+
}
|
|
30292
|
+
try {
|
|
30205
30293
|
orm.getAdapter();
|
|
30206
30294
|
} catch (err) {
|
|
30207
|
-
|
|
30295
|
+
const configuredUrl = (process.env.TINA4_DATABASE_URL ?? "").trim();
|
|
30296
|
+
const cause = stripUrlCredentials(bootDbConnectError ?? (err instanceof Error ? err.message : String(err)));
|
|
30297
|
+
if (configuredUrl) {
|
|
30298
|
+
Log.debug(`Startup migrations skipped (database configured but could not connect to ${stripUrlCredentials(configuredUrl)}): ${cause}`);
|
|
30299
|
+
} else {
|
|
30300
|
+
Log.debug(`Startup migrations skipped (no database configured): ${cause}`);
|
|
30301
|
+
}
|
|
30208
30302
|
return;
|
|
30209
30303
|
}
|
|
30210
30304
|
try {
|
|
@@ -31127,9 +31221,10 @@ function wireLocaleGlobal(frondEngine, base) {
|
|
|
31127
31221
|
if (!existsSync23(localeDir)) return;
|
|
31128
31222
|
try {
|
|
31129
31223
|
const localeFiles = readdirSync15(localeDir).filter((file) => file.endsWith(".json"));
|
|
31130
|
-
|
|
31224
|
+
const FrondClass = frondEngine.constructor;
|
|
31225
|
+
if (localeFiles.length === 0 || FrondClass.hasGlobal("t") || frondEngine.globals?.t) return;
|
|
31131
31226
|
const i18nInstance = new I18n(process.env.TINA4_LOCALE ?? "en", localeDir);
|
|
31132
|
-
|
|
31227
|
+
FrondClass.addGlobal("t", (key, params) => i18nInstance.t(key, params));
|
|
31133
31228
|
} catch {
|
|
31134
31229
|
}
|
|
31135
31230
|
}
|
|
@@ -31462,13 +31557,17 @@ async function initializeOrm(config, router, base, ormDir, modelsDir) {
|
|
|
31462
31557
|
const hasOrmDir = existsSync23(ormDir);
|
|
31463
31558
|
const hasModelsDir = existsSync23(modelsDir);
|
|
31464
31559
|
if (hasOrmDir || hasModelsDir) {
|
|
31560
|
+
let ormStage = "import";
|
|
31561
|
+
const dbConfig = config?.database ?? {};
|
|
31465
31562
|
try {
|
|
31466
31563
|
const orm = await Promise.resolve().then(() => (init_index(), index_exports));
|
|
31467
|
-
|
|
31564
|
+
ormStage = "connect";
|
|
31565
|
+
bootDbConnectError = null;
|
|
31468
31566
|
await orm.initDatabase({
|
|
31469
31567
|
type: dbConfig.type ?? "sqlite",
|
|
31470
31568
|
path: dbConfig.path ?? "./data/tina4.db"
|
|
31471
31569
|
});
|
|
31570
|
+
ormStage = "models";
|
|
31472
31571
|
let models = hasOrmDir ? await orm.discoverModels(ormDir) : [];
|
|
31473
31572
|
if (hasModelsDir) {
|
|
31474
31573
|
const extraModels = await orm.discoverModels(modelsDir);
|
|
@@ -31503,8 +31602,7 @@ async function initializeOrm(config, router, base, ormDir, modelsDir) {
|
|
|
31503
31602
|
}
|
|
31504
31603
|
}
|
|
31505
31604
|
} catch (err) {
|
|
31506
|
-
|
|
31507
|
-
ORM not available (install @tina4/orm to enable):`, err);
|
|
31605
|
+
reportOrmBootFailure(ormStage, err, dbConfig);
|
|
31508
31606
|
}
|
|
31509
31607
|
await autoMigrateOnStartup("migrations", base);
|
|
31510
31608
|
}
|
|
@@ -31542,7 +31640,7 @@ async function configureSwagger(router, ormDir, modelsDir) {
|
|
|
31542
31640
|
}
|
|
31543
31641
|
return enabled;
|
|
31544
31642
|
}
|
|
31545
|
-
var __filename, __dirname, BUILTIN_ERROR_TEMPLATES_DIR, BUILTIN_PUBLIC_DIR, swaggerAssetsEnabled, DEFAULT_SHUTDOWN_TIMEOUT_SECONDS, frondCache, _LEGACY_ENV_VARS, CI_ENVIRONMENT_VARIABLES, CI_NOT_SET_VALUES, portDeprecationWarned, TEMPLATE_PAGES_DIR, HTTP_REASON_PHRASES, templateCache, _dispatchFn, _liveDispatchContext, _serverHandle, LOOP_WATCHDOG_TICK_MS, FALLBACK_STAGES;
|
|
31643
|
+
var __filename, __dirname, BUILTIN_ERROR_TEMPLATES_DIR, BUILTIN_PUBLIC_DIR, swaggerAssetsEnabled, DEFAULT_SHUTDOWN_TIMEOUT_SECONDS, bootDbConnectError, frondCache, _LEGACY_ENV_VARS, CI_ENVIRONMENT_VARIABLES, CI_NOT_SET_VALUES, portDeprecationWarned, TEMPLATE_PAGES_DIR, HTTP_REASON_PHRASES, templateCache, _dispatchFn, _liveDispatchContext, _serverHandle, LOOP_WATCHDOG_TICK_MS, FALLBACK_STAGES;
|
|
31546
31644
|
var init_server = __esm({
|
|
31547
31645
|
"../core/src/server.ts"() {
|
|
31548
31646
|
"use strict";
|
|
@@ -31577,6 +31675,7 @@ var init_server = __esm({
|
|
|
31577
31675
|
BUILTIN_PUBLIC_DIR = resolve15(__dirname, "..", "public");
|
|
31578
31676
|
swaggerAssetsEnabled = false;
|
|
31579
31677
|
DEFAULT_SHUTDOWN_TIMEOUT_SECONDS = 30;
|
|
31678
|
+
bootDbConnectError = null;
|
|
31580
31679
|
frondCache = /* @__PURE__ */ new Map();
|
|
31581
31680
|
_LEGACY_ENV_VARS = {
|
|
31582
31681
|
DATABASE_URL: "TINA4_DATABASE_URL",
|
|
@@ -46,5 +46,7 @@ export declare function removePidfile(port: number, baseDir?: string): void;
|
|
|
46
46
|
* guarded path for both the CLI (`tina4 serve`) and the runtime bind-failure
|
|
47
47
|
* fallback. `dev`/`noTakeover` are passed in so this stays pure and directly
|
|
48
48
|
* testable; callers resolve them from isDev() / noTakeoverOptedOut().
|
|
49
|
+
* Before a bind, the caller passes the `host` it will bind, so a free port is
|
|
50
|
+
* reported as nothing rather than refused as "in use".
|
|
49
51
|
*/
|
|
50
|
-
export declare function takeOverPort(port: number, dev: boolean, noTakeover: boolean, baseDir?: string, grace?: number): TakeoverResult;
|
|
52
|
+
export declare function takeOverPort(port: number, dev: boolean, noTakeover: boolean, baseDir?: string, grace?: number, host?: string): TakeoverResult;
|
|
@@ -90,23 +90,28 @@ export declare class Frond {
|
|
|
90
90
|
private static classFilters;
|
|
91
91
|
private static classGlobals;
|
|
92
92
|
private static classTests;
|
|
93
|
+
private static classRegistryVersion;
|
|
93
94
|
private static liveFragments;
|
|
94
95
|
private static liveSources;
|
|
95
96
|
private static liveWsPaths;
|
|
96
97
|
private static liveBroadcaster;
|
|
97
98
|
/**
|
|
98
99
|
* Register a custom filter at the class level — available to every
|
|
99
|
-
*
|
|
100
|
+
* instance, existing ones included: an engine merges the class filters
|
|
101
|
+
* again at its next render (ADR-0107). Callable as ``Frond.addFilter()``
|
|
100
102
|
* (static) or ``frond.addFilter()`` (instance). See instance method
|
|
101
103
|
* below for the dual-call semantics.
|
|
102
104
|
*/
|
|
103
105
|
static addFilter(name: string, fn: FilterFn): void;
|
|
104
106
|
/**
|
|
105
107
|
* Register a global variable available in all templates of every
|
|
106
|
-
*
|
|
108
|
+
* instance, existing ones included: class globals are read at render time
|
|
109
|
+
* (ADR-0106). Callable as ``Frond.addGlobal()`` (static) or
|
|
107
110
|
* ``frond.addGlobal()`` (instance).
|
|
108
111
|
*/
|
|
109
112
|
static addGlobal(name: string, value: unknown): void;
|
|
113
|
+
/** True when a class-level global with this name is registered. */
|
|
114
|
+
static hasGlobal(name: string): boolean;
|
|
110
115
|
/**
|
|
111
116
|
* Register a custom test (``{% if x is positive %}``) at the class
|
|
112
117
|
* level. Callable as ``Frond.addTest()`` (static) or
|
|
@@ -121,8 +126,17 @@ export declare class Frond {
|
|
|
121
126
|
*/
|
|
122
127
|
static clearRegistry(): void;
|
|
123
128
|
private templateDir;
|
|
129
|
+
/** Effective filters: built-in < class < instance (see syncRegistries). */
|
|
124
130
|
private filters;
|
|
131
|
+
/** Filters / tests registered on THIS instance only (ADR-0052). */
|
|
132
|
+
private localFilters;
|
|
133
|
+
private localTests;
|
|
134
|
+
/** The class-registry version `filters` / `tests` were last merged at. */
|
|
135
|
+
private registryVersion;
|
|
136
|
+
/** Globals registered on THIS instance only (ADR-0052). */
|
|
125
137
|
private globals;
|
|
138
|
+
/** Built-in globals (formToken, range, dump, csp_nonce, ...). */
|
|
139
|
+
private builtinGlobals;
|
|
126
140
|
private tests;
|
|
127
141
|
private _sandbox;
|
|
128
142
|
private _allowedFilters;
|
|
@@ -149,6 +163,13 @@ export declare class Frond {
|
|
|
149
163
|
private readonly _applyFiltersBound;
|
|
150
164
|
getTemplateDir(): string;
|
|
151
165
|
constructor(templateDir?: string);
|
|
166
|
+
/**
|
|
167
|
+
* Rebuild the merged filter/test maps when the class registry changed.
|
|
168
|
+
* Same layering as globals -- built-ins < class < this instance. Filter
|
|
169
|
+
* lookup is on the hot path, so the merge is a plain object rebuilt only
|
|
170
|
+
* when the class-registry version moves, never a per-lookup chain.
|
|
171
|
+
*/
|
|
172
|
+
private syncRegistries;
|
|
152
173
|
sandbox(filters?: string[], tags?: string[], vars?: string[]): Frond;
|
|
153
174
|
unsandbox(): Frond;
|
|
154
175
|
/**
|
|
@@ -172,6 +193,14 @@ export declare class Frond {
|
|
|
172
193
|
* isn't a reliable freshness signal.
|
|
173
194
|
*/
|
|
174
195
|
private cacheTtlSeconds;
|
|
196
|
+
/**
|
|
197
|
+
* Layer the globals under the render data: built-ins < class globals (read
|
|
198
|
+
* live, so registration order never matters) < this instance's own globals
|
|
199
|
+
* < the data passed to render(). Every render starts here, so this is also
|
|
200
|
+
* where the filter/test maps catch up with any class registration made
|
|
201
|
+
* since the last render.
|
|
202
|
+
*/
|
|
203
|
+
private withGlobals;
|
|
175
204
|
render(template: string, data?: Record<string, unknown>): string;
|
|
176
205
|
renderString(source: string, data?: Record<string, unknown>): string;
|
|
177
206
|
/** Clear all compiled template caches. */
|