Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | 39x 83x 83x 37x 46x 46x 1196x 46x 1192x 46x 298x 4x 9x 46x 46x 46x 46x 85x 85x 1x 84x 1x 1x 83x 83x 83x 4x 83x 83x 83x 83x 83x 83x 4x 4x 4x 83x 83x 80x 3x 3x 39x 65x 65x 63x 63x 63x 24x 39x 39x 24x 24x 22x 22x 22x 12x 12x 10x 48x 48x 48x 48x 48x 48x 48x 19x 38x 19x 19x 29x 48x 48x 25x 25x 25x 56x 56x 56x 56x 56x 56x 56x 25x 25x 23x 2x 2x 2x 2x 5x 5x 5x 5x 5x 5x 5x 2x 2x 21x 18x 18x 18x 18x 37x 37x 37x 37x 33x 33x 4x 37x 37x 37x 37x 37x 18x 18x 3x 3x 3x | 'use strict';
/* istanbul ignore next */
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
/* istanbul ignore next */
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
/* istanbul ignore next */
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
/* istanbul ignore next */
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
/* istanbul ignore next */
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
/* istanbul ignore next */
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
/* istanbul ignore next */
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
/* istanbul ignore next */
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
/* istanbul ignore next */
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
/* istanbul ignore next */
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
/* istanbul ignore next */
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
/* istanbul ignore next */
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
import "core-js/modules/es.symbol.js";
import "core-js/modules/es.symbol.description.js";
import "core-js/modules/es.symbol.iterator.js";
import "core-js/modules/es.array.concat.js";
import "core-js/modules/es.array.filter.js";
import "core-js/modules/es.array.from.js";
import "core-js/modules/es.array.includes.js";
import "core-js/modules/es.array.is-array.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.array.join.js";
import "core-js/modules/es.array.map.js";
import "core-js/modules/es.array.slice.js";
import "core-js/modules/es.date.to-string.js";
import "core-js/modules/es.function.name.js";
import "core-js/modules/es.map.js";
import "core-js/modules/es.object.entries.js";
import "core-js/modules/es.object.keys.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.regexp.exec.js";
import "core-js/modules/es.regexp.to-string.js";
import "core-js/modules/es.string.includes.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.string.trim.js";
import "core-js/modules/esnext.global-this.js";
import "core-js/modules/web.dom-collections.iterator.js";
import { getProp, isBlockedExpression } from './utils';
import { processNode } from './processing';
import { updateAttributePlaceholders, updateTextNodePlaceholders } from './placeholders';
import { logError } from './logger';
import { createExpressionContext, evaluateTemplateExpression } from './helpers';
// Expression evaluation cache and utilities
var expressionCache = new Map();
function compileExpression(expr, methodNames, builtinNames, pointerNames) {
var cacheKey = expr + '|' + methodNames.join(',') + '|' + builtinNames.join(',') + '|' + (pointerNames || []).join(',');
if (expressionCache.has(cacheKey)) {
return expressionCache.get(cacheKey);
}
// new Function with strict mode and scoped parameters
// Shadow all common globals unless explicitly allowed
var commonGlobals = ['Math', 'Date', 'Object', 'Array', 'String', 'Number', 'Boolean', 'RegExp', 'JSON', 'Promise', 'Set', 'Map', 'WeakMap', 'WeakSet', 'Symbol', 'Proxy', 'Reflect', 'Error', 'TypeError', 'ReferenceError', 'window', 'document', 'globalThis', 'console', 'setTimeout', 'setInterval'];
var disallowedGlobals = commonGlobals.filter(function (name) {
return !builtinNames.includes(name);
});
var shadowDefs = disallowedGlobals.map(function (g) {
return "const ".concat(g, " = undefined;");
}).join('');
// Make methods, builtins, and pointers available in scope
var scopeDefs = [].concat(_toConsumableArray(methodNames.map(function (k) {
return "const ".concat(k, " = methods.").concat(k, ";");
})), _toConsumableArray(builtinNames.map(function (k) {
return "const ".concat(k, " = builtins.").concat(k, ";");
})), _toConsumableArray((pointerNames || []).map(function (k) {
return "const ".concat(k, " = pointers.").concat(k, ";");
}))).join('');
var body = "\"use strict\"; ".concat(shadowDefs, " ").concat(scopeDefs, " return (").concat(expr, ");");
var fn = new Function('data', 'methods', 'builtins', 'pointers', body);
expressionCache.set(cacheKey, fn);
return fn;
}
function evaluateToBoolean(expr, ctx, allowBuiltins, logWarning) {
expr = expr.trim();
if (expr === '') {
return false; // empty expression is false
}
if (isBlockedExpression(expr)) {
logWarning('Expression contains blocked constructs: ' + expr);
return false; // for c-if
}
try {
var methodNames = Object.keys(ctx.methods);
var builtinNames = allowBuiltins.filter(function (name) {
return name in globalThis;
});
var pointerNames = ctx.pointers ? Object.keys(ctx.pointers) : [];
var fn = compileExpression(expr, methodNames, builtinNames, pointerNames);
var builtins = {};
// Populate builtins object with allowed globals
var _iterator = _createForOfIteratorHelper(builtinNames),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var name = _step.value;
Eif (name in globalThis) {
builtins[name] = globalThis[name];
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
var result = fn.call(null, ctx.data, ctx.methods, builtins, ctx.pointers || {});
return !!result; // truthiness
} catch (err) {
logWarning('Expression evaluation error: ' + err.message + ' in: ' + expr);
return false;
}
}
// If and For directives
export var directives = {
'c-if': function cIf(comp, node, pointers, cache) {
var attr = node.getAttribute('c-if');
if (!attr) return true; // no attribute, keep
// Use new expression evaluator with pointers support
var ctx = createExpressionContext(comp, pointers);
var decision = evaluateToBoolean(attr, ctx, ctx.allowBuiltins, ctx.logWarning);
if (!decision) {
return false;
} else {
node.removeAttribute('c-if');
return true;
}
},
// Calls c-if directive and reverses the result.
'c-ifnot': function cIfnot(comp, node, pointers, cache) {
var attr = node.getAttribute('c-ifnot');
if (!attr) return true;
// Expression with pointers support
var ctx = createExpressionContext(comp, pointers);
var decision = evaluateToBoolean(attr, ctx, ctx.allowBuiltins, ctx.logWarning);
if (!decision) {
// was false, invert to true
node.removeAttribute('c-ifnot');
return true;
} else {
// was true, invert to false
return false;
}
},
'c-for': function cFor(comp, node, pointers, cache) {
var attr = node.getAttribute('c-for');
var parts = attr.split(' in ');
var leftSide = parts[0].trim();
var iterableExpr = parts[1].trim();
Iif (pointers === undefined) pointers = {};
// Parse pointer declaration - detect single vs dual pointer
var isDualPointer = leftSide.includes(',');
var keyPointer, valuePointer;
if (isDualPointer) {
var pointerParts = leftSide.split(',').map(function (p) {
return p.trim();
});
keyPointer = pointerParts[0];
valuePointer = pointerParts[1];
} else {
valuePointer = leftSide;
}
var iterable = evaluateTemplateExpression(comp, pointers, node, iterableExpr, cache);
// Type detection: Arrays (highest priority)
if (Array.isArray(iterable)) {
node.removeAttribute('c-for');
var parentNode = node.parentNode;
for (var i = 0; i < iterable.length; i++) {
var item = iterable[i];
// For arrays, use valuePointer (second pointer in dual syntax, or only pointer)
pointers[valuePointer] = item;
var newNode = node.cloneNode(true);
processNode(comp, newNode, pointers, cache);
updateAttributePlaceholders(comp, newNode, pointers, cache);
updateTextNodePlaceholders(comp, newNode, pointers, cache);
parentNode.appendChild(newNode);
}
node.remove();
return true;
}
// Type detection: Iterables (Map, Set, etc.)
else if (iterable && typeof iterable[Symbol.iterator] === 'function') {
node.removeAttribute('c-for');
var _parentNode = node.parentNode;
var arr = Array.from(iterable);
for (var _i = 0; _i < arr.length; _i++) {
var _item = arr[_i];
pointers[valuePointer] = _item;
var _newNode = node.cloneNode(true);
processNode(comp, _newNode, pointers, cache);
updateAttributePlaceholders(comp, _newNode, pointers, cache);
updateTextNodePlaceholders(comp, _newNode, pointers, cache);
_parentNode.appendChild(_newNode);
}
node.remove();
return true;
}
// Type detection: Plain Objects (NEW)
else if (iterable && _typeof(iterable) === 'object' && iterable !== null) {
node.removeAttribute('c-for');
var _parentNode2 = node.parentNode;
var entries = Object.entries(iterable);
for (var _i2 = 0; _i2 < entries.length; _i2++) {
var _entries$_i = _slicedToArray(entries[_i2], 2),
key = _entries$_i[0],
value = _entries$_i[1];
// Assign based on pointer count
if (isDualPointer) {
pointers[keyPointer] = key;
pointers[valuePointer] = value;
} else {
// Single pointer with object gets value only
pointers[valuePointer] = value;
}
var _newNode2 = node.cloneNode(true);
processNode(comp, _newNode2, pointers, cache);
updateAttributePlaceholders(comp, _newNode2, pointers, cache);
updateTextNodePlaceholders(comp, _newNode2, pointers, cache);
_parentNode2.appendChild(_newNode2);
}
node.remove();
return true;
}
// Not iterable
else {
Eif (iterable !== undefined && iterable !== null) {
logError(comp, "[method-call-error] ".concat(iterableExpr, " : Result is not iterable"));
}
return false;
}
}
}; |