@lmjs/core 2.3.0 → 2.4.0
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/lumenjs-core.js +6 -6
- package/package.json +1 -1
- package/src/_re.js +29 -28
- package/src/dom-shim.js +10 -10
- package/src/lstnrs.js +5 -5
- package/src/reactive.js +15 -0
- package/vendor/reconnecting-websocket.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmjs/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "LumenJS reactive core runtime — the reactive engine, HTML/JS AST compiler, realtime socket client, and delegated event listeners powering LumenJS applications.",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/",
|
package/src/_re.js
CHANGED
|
@@ -2658,30 +2658,12 @@ class _lm {
|
|
|
2658
2658
|
(par.view._slots ?? (par.view._slots = {}))[slotName] = childs;
|
|
2659
2659
|
}
|
|
2660
2660
|
} else if (doc.attrs && (doc.attrs.hasOwnProperty('tpl') || doc.attrs.hasOwnProperty('comp'))) {
|
|
2661
|
-
//
|
|
2662
|
-
//
|
|
2663
|
-
// rendered inline, in THIS engine and scope, so the
|
|
2664
|
-
// host's reactive vars keep driving it. :data needs no
|
|
2665
|
-
// runtime handling — fcs.js's linkTemplateReactiveVars()
|
|
2666
|
-
// already made those names reactive in the host view.
|
|
2661
|
+
// tpl= only works on a :for loop element (decided 2026-10-02); comp= is removed. Render the
|
|
2662
|
+
// element itself, without template content, and say exactly what to change.
|
|
2667
2663
|
let _elAttrs = Object.assign({}, doc.attrs);
|
|
2668
2664
|
delete _elAttrs['tpl']; delete _elAttrs['comp']; delete _elAttrs[':data'];
|
|
2669
2665
|
el = par.createEl(doc.name, _elAttrs, [], doc.evs, doc);
|
|
2670
|
-
|
|
2671
|
-
if (_tplEntry) {
|
|
2672
|
-
for (const rv of (_tplEntry.reactiveVars || [])) {
|
|
2673
|
-
if (Array.isArray(par.reactiveVariables) && par.reactiveVariables.indexOf(rv) === -1) par.reactiveVariables.push(rv);
|
|
2674
|
-
}
|
|
2675
|
-
let childs = [];
|
|
2676
|
-
for (const dc of _tplEntry.hst) {
|
|
2677
|
-
let chils = par.walk(dc, el);
|
|
2678
|
-
if (chils) {
|
|
2679
|
-
if (Array.isArray(chils)) { if (chils.length) childs = [...childs, ...chils]; }
|
|
2680
|
-
else childs.push(chils);
|
|
2681
|
-
}
|
|
2682
|
-
}
|
|
2683
|
-
childs.length ? el.append(...childs) : null;
|
|
2684
|
-
}
|
|
2666
|
+
_reportTplMisuse(doc, par);
|
|
2685
2667
|
} else {
|
|
2686
2668
|
el = par.createEl(doc.name, doc.attrs, [], doc.evs, doc);
|
|
2687
2669
|
|
|
@@ -3245,21 +3227,36 @@ const _V1_DEFAULT_LAYOUT = {
|
|
|
3245
3227
|
// so each attribute checks its own folder first and the other as fallback.
|
|
3246
3228
|
function _resolveTemplateEntry(attrs) {
|
|
3247
3229
|
let _payload = (typeof _vcD !== 'undefined' && _vcD) || (typeof _vcData !== 'undefined' ? _vcData : undefined);
|
|
3248
|
-
let
|
|
3249
|
-
let name = String(isComp ? attrs['comp'] : attrs['tpl']).replace(/^\/+/, '');
|
|
3250
|
-
let folders = isComp ? ['comps', 'tpls'] : ['tpls', 'comps'];
|
|
3230
|
+
let name = String(attrs['tpl']).replace(/^\/+/, '');
|
|
3251
3231
|
let bucket = _payload && _payload.tpls;
|
|
3252
|
-
|
|
3232
|
+
// src/tpls/ first; src/comps/ still holds templates in V1 projects, so a tpl= name may live there.
|
|
3233
|
+
for (const f of ['tpls', 'comps']) {
|
|
3253
3234
|
let entry = bucket && bucket[btoa("src/" + f + "/" + name + ".tpl")];
|
|
3254
3235
|
if (entry) return entry;
|
|
3255
3236
|
}
|
|
3256
3237
|
reportLumenError({
|
|
3257
3238
|
stage: 'tpl',
|
|
3258
|
-
error: new Error(
|
|
3239
|
+
error: new Error('tpl="' + name + '" — no such file at src/tpls/' + name + '.tpl'),
|
|
3259
3240
|
});
|
|
3260
3241
|
return null;
|
|
3261
3242
|
}
|
|
3262
3243
|
|
|
3244
|
+
// tpl= renders a template once per :for row, in the row's scope: `<li :for="items as item" tpl="row"></li>`.
|
|
3245
|
+
// Anywhere else it renders nothing (V1 also allowed it on plain elements and had comp=; both removed in V2,
|
|
3246
|
+
// decided 2026-10-02). Reported once per element so a migrating site sees exactly which markup to change.
|
|
3247
|
+
function _reportTplMisuse(doc, par) {
|
|
3248
|
+
if (doc._tplReported) return;
|
|
3249
|
+
try { Object.defineProperty(doc, '_tplReported', { value: true, enumerable: false }); } catch (e) { }
|
|
3250
|
+
let view = (par && par.view && par.view.name) ? ' in "' + par.view.name + '"' : '';
|
|
3251
|
+
let msg;
|
|
3252
|
+
if (doc.attrs.hasOwnProperty('comp')) {
|
|
3253
|
+
msg = 'comp="' + doc.attrs['comp'] + '"' + view + ' is no longer supported. Put the :for on the element and use tpl=, e.g. <' + doc.name + ' :for="items as item" tpl="' + String(doc.attrs['comp']).replace(/^\/+/, '') + '">, and move the template\'s own :for out of the .tpl file.';
|
|
3254
|
+
} else {
|
|
3255
|
+
msg = 'tpl="' + doc.attrs['tpl'] + '"' + view + ' only works on a :for loop element, e.g. <' + doc.name + ' :for="items as item" tpl="' + String(doc.attrs['tpl']).replace(/^\/+/, '') + '">. It was ignored on this <' + doc.name + '>; move the template\'s :for onto this element.';
|
|
3256
|
+
}
|
|
3257
|
+
reportLumenError({ stage: 'tpl', error: new Error(msg) });
|
|
3258
|
+
}
|
|
3259
|
+
|
|
3263
3260
|
async function renderSection(tx, doc, par, k, sectionsData) {
|
|
3264
3261
|
if (tx.node.isConnected) {
|
|
3265
3262
|
if (k) {
|
|
@@ -3281,8 +3278,12 @@ async function renderSection(tx, doc, par, k, sectionsData) {
|
|
|
3281
3278
|
// everything else here (this section already has its own vx/vrs —
|
|
3282
3279
|
// no separate scope, no isolated instance, just this item's content).
|
|
3283
3280
|
if (doc.attrs && (doc.attrs.hasOwnProperty('tpl') || doc.attrs.hasOwnProperty('comp'))) {
|
|
3284
|
-
|
|
3285
|
-
|
|
3281
|
+
if (doc.type === 'sections' && doc.attrs.hasOwnProperty('tpl') && !doc.attrs.hasOwnProperty('comp')) {
|
|
3282
|
+
let _tplEntry = _resolveTemplateEntry(doc.attrs);
|
|
3283
|
+
if (_tplEntry) hst = _tplEntry.hst;
|
|
3284
|
+
} else {
|
|
3285
|
+
_reportTplMisuse(doc, par);
|
|
3286
|
+
}
|
|
3286
3287
|
}
|
|
3287
3288
|
|
|
3288
3289
|
// 2026-09-17: real bug found and fixed — a subview mounted INSIDE a
|
package/src/dom-shim.js
CHANGED
|
@@ -942,17 +942,17 @@
|
|
|
942
942
|
}
|
|
943
943
|
var real = EVENT_NAME_MAP[evt] || evt;
|
|
944
944
|
listen(real, function (e) {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
945
|
+
// Like jQuery (which V1 always ran on): a delegated handler fires for EVERY matching element
|
|
946
|
+
// from the target up, nearest first, until one stops propagation or returns false — not just
|
|
947
|
+
// the nearest match, which silently dropped a parent's @click inside a clickable child.
|
|
948
|
+
if (atAttr || (selector && _isNode(node))) {
|
|
949
|
+
for (var el = e.target; el && el.nodeType === 1 && node.contains(el); el = el.parentElement) {
|
|
950
|
+
var hit = atAttr ? _hasAnyAt(el) : (el.matches && el.matches(selector));
|
|
951
|
+
if (!hit) continue;
|
|
952
|
+
var ret = _callHandler(handler, el, e);
|
|
953
|
+
if (ret === false) { e.preventDefault(); e.stopPropagation(); }
|
|
954
|
+
if (e.cancelBubble) break;
|
|
951
955
|
}
|
|
952
|
-
if (match && node.contains(match)) _callHandler(handler, match, e);
|
|
953
|
-
} else if (selector && _isNode(node)) {
|
|
954
|
-
var match2 = e.target.closest(selector);
|
|
955
|
-
if (match2 && node.contains(match2)) _callHandler(handler, match2, e);
|
|
956
956
|
} else {
|
|
957
957
|
_callHandler(handler, node, e);
|
|
958
958
|
}
|
package/src/lstnrs.js
CHANGED
|
@@ -570,7 +570,7 @@ function evalEvAttr(_v, ev, el, n, arg1, arg2, arg3) {
|
|
|
570
570
|
}
|
|
571
571
|
|
|
572
572
|
function processEv(ev, el, n, arg1, arg2, arg3) {
|
|
573
|
-
if (el.
|
|
573
|
+
if (el.hasAttr("stop")) ev.stopPropagation();
|
|
574
574
|
if (n == "focusin") n = "focus";
|
|
575
575
|
else if (n == "focusout") n = "blur";
|
|
576
576
|
if (!el.hasAttr("@" + n)) return;
|
|
@@ -819,7 +819,7 @@ $("body").on("click touch", "[close-modal]", function (ev) {
|
|
|
819
819
|
var element_to_remove = $("#" + id).get(0);
|
|
820
820
|
var index = $.inArray(element_to_remove, popups.modals);
|
|
821
821
|
var modalOwner = $("[modal][data-modal=" + id + "]");
|
|
822
|
-
if (el.
|
|
822
|
+
if (el.hasAttr("stop")) ev.stopPropagation();
|
|
823
823
|
ev.preventDefault();
|
|
824
824
|
if (modalOwner.hasAttr("@modal-beforeclose")) {
|
|
825
825
|
try {
|
|
@@ -1280,7 +1280,7 @@ $("body").on("click touch", "[actv]", function (e) {
|
|
|
1280
1280
|
let el = $(this);
|
|
1281
1281
|
if (el.attr("actv") != "") $(el.attr("actv")).removeClass("active");
|
|
1282
1282
|
el.addClass("active");
|
|
1283
|
-
if (el.
|
|
1283
|
+
if (el.hasAttr("stop")) e.stopPropagation();
|
|
1284
1284
|
});
|
|
1285
1285
|
|
|
1286
1286
|
$("body").on("click touch", "[actvt]", function (e) {
|
|
@@ -1288,7 +1288,7 @@ $("body").on("click touch", "[actvt]", function (e) {
|
|
|
1288
1288
|
if (el.attr("actvt") != "") $(el.attr("actvt")).removeClass("active");
|
|
1289
1289
|
if (el.hasClass("active")) el.removeClass("active");
|
|
1290
1290
|
else el.addClass("active");
|
|
1291
|
-
if (el.
|
|
1291
|
+
if (el.hasAttr("stop")) e.stopPropagation();
|
|
1292
1292
|
});
|
|
1293
1293
|
|
|
1294
1294
|
$("body").on("click touch", "[close-notify]", function (e) {
|
|
@@ -1296,7 +1296,7 @@ $("body").on("click touch", "[close-notify]", function (e) {
|
|
|
1296
1296
|
tis.fadeOut(function () {
|
|
1297
1297
|
tis.remove();
|
|
1298
1298
|
});
|
|
1299
|
-
if ($(this).
|
|
1299
|
+
if ($(this).hasAttr("stop")) e.stopPropagation();
|
|
1300
1300
|
});
|
|
1301
1301
|
|
|
1302
1302
|
let _keyInt;
|
package/src/reactive.js
CHANGED
|
@@ -174,6 +174,7 @@ function _rxCompileNode(n, ptag, rvSet) {
|
|
|
174
174
|
if (ms.mss.length) res.ax[an] = ms.mss;
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
+
_rxOrderIfFor(res);
|
|
177
178
|
if (!res.isV) {
|
|
178
179
|
var kids = n.childNodes;
|
|
179
180
|
for (var c = 0; c < kids.length; c++) {
|
|
@@ -185,6 +186,20 @@ function _rxCompileNode(n, ptag, rvSet) {
|
|
|
185
186
|
return res;
|
|
186
187
|
}
|
|
187
188
|
|
|
189
|
+
// Same rule as the server compiler (fcs.js hst_orderIfFor): `:if` and `:for` on one element apply in written
|
|
190
|
+
// order — `:if` first gates the whole loop, `:for` first makes the `:if` a per-row condition.
|
|
191
|
+
function _rxOrderIfFor(res) {
|
|
192
|
+
if (!res || !res.attrs || !res.forX || !Object.prototype.hasOwnProperty.call(res.attrs, ":if")) return;
|
|
193
|
+
var keys = Object.keys(res.attrs);
|
|
194
|
+
var cond = String(res.attrs[":if"]);
|
|
195
|
+
if (keys.indexOf(":if") < keys.indexOf(":for")) res.forX.js = "(" + cond + ") ? (" + res.forX.js + ") : []";
|
|
196
|
+
else res.attrs[":for-if"] = res.attrs[":for-if"] ? "(" + res.attrs[":for-if"] + ") && (" + cond + ")" : cond;
|
|
197
|
+
res.type = "sections";
|
|
198
|
+
delete res.cond;
|
|
199
|
+
delete res.attrs[":if"];
|
|
200
|
+
if (res.ax) delete res.ax[":if"];
|
|
201
|
+
}
|
|
202
|
+
|
|
188
203
|
function _rxCompileHost(host) {
|
|
189
204
|
var rvSet = {}, hst = [], kids = host.childNodes;
|
|
190
205
|
for (var i = 0; i < kids.length; i++) {
|
|
@@ -755,12 +755,12 @@ function iterateConditions(text) {
|
|
|
755
755
|
return results;
|
|
756
756
|
}
|
|
757
757
|
|
|
758
|
+
// Pause / resume rendering only. The loader is the developer's to show (`_loader.show()`), never implied here
|
|
759
|
+
// (decided 2026-10-02; canonical V1 core.js does the same — only a 2023 V1 variant showed it).
|
|
758
760
|
function wait() {
|
|
759
|
-
_loader.show();
|
|
760
761
|
_initialized = false;
|
|
761
762
|
}
|
|
762
763
|
function resume() {
|
|
763
|
-
_loader.hide();
|
|
764
764
|
_initialized = true;
|
|
765
765
|
}
|
|
766
766
|
|