tova 0.8.2 → 0.9.4
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/bin/tova.js +1128 -137
- package/package.json +14 -2
- package/src/analyzer/analyzer.js +405 -9
- package/src/analyzer/browser-analyzer.js +56 -8
- package/src/analyzer/scope.js +7 -0
- package/src/analyzer/server-analyzer.js +33 -1
- package/src/codegen/base-codegen.js +137 -13
- package/src/codegen/browser-codegen.js +725 -20
- package/src/codegen/codegen.js +67 -5
- package/src/codegen/server-codegen.js +54 -6
- package/src/codegen/theme-codegen.js +69 -0
- package/src/config/module-path.js +34 -2
- package/src/config/resolve.js +9 -0
- package/src/config/toml.js +13 -1
- package/src/deploy/provision.js +6 -2
- package/src/diagnostics/security-scorecard.js +111 -0
- package/src/lexer/lexer.js +18 -3
- package/src/parser/animate-ast.js +45 -0
- package/src/parser/ast.js +15 -0
- package/src/parser/browser-ast.js +19 -1
- package/src/parser/browser-parser.js +221 -4
- package/src/parser/parser.js +21 -2
- package/src/parser/theme-ast.js +29 -0
- package/src/parser/theme-parser.js +70 -0
- package/src/registry/plugins/theme-plugin.js +20 -0
- package/src/registry/register-all.js +2 -0
- package/src/runtime/charts.js +547 -0
- package/src/runtime/embedded.js +6 -2
- package/src/runtime/reactivity.js +60 -0
- package/src/runtime/router.js +703 -295
- package/src/runtime/table.js +606 -33
- package/src/stdlib/inline.js +330 -7
- package/src/stdlib/string.js +84 -2
- package/src/stdlib/validation.js +1 -1
- package/src/version.js +1 -1
package/src/stdlib/string.js
CHANGED
|
@@ -190,6 +190,88 @@ export function unescape_html(s) {
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
export function fmt(template, ...args) {
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
var named = args.length === 1 && args[0] !== null && typeof args[0] === 'object' && !Array.isArray(args[0]) && !(args[0] instanceof Date);
|
|
194
|
+
var obj = named ? args[0] : null;
|
|
195
|
+
var ai = 0, result = '', pos = 0, len = template.length;
|
|
196
|
+
while (pos < len) {
|
|
197
|
+
if (pos + 1 < len && template[pos] === '{' && template[pos + 1] === '{') { result += '{'; pos += 2; continue; }
|
|
198
|
+
if (pos + 1 < len && template[pos] === '}' && template[pos + 1] === '}') { result += '}'; pos += 2; continue; }
|
|
199
|
+
if (template[pos] === '{') {
|
|
200
|
+
var close = template.indexOf('}', pos + 1);
|
|
201
|
+
if (close === -1) { result += template[pos]; pos++; continue; }
|
|
202
|
+
var inner = template.substring(pos + 1, close);
|
|
203
|
+
pos = close + 1;
|
|
204
|
+
var colonIdx = inner.indexOf(':');
|
|
205
|
+
var key = colonIdx >= 0 ? inner.substring(0, colonIdx) : inner;
|
|
206
|
+
var spec = colonIdx >= 0 ? inner.substring(colonIdx + 1) : '';
|
|
207
|
+
var val;
|
|
208
|
+
if (named && key.length > 0) {
|
|
209
|
+
val = obj[key]; if (val === undefined) { result += '{' + inner + '}'; continue; }
|
|
210
|
+
} else if (key.length === 0) {
|
|
211
|
+
if (ai < args.length) { val = args[ai++]; } else { result += '{}'; continue; }
|
|
212
|
+
} else {
|
|
213
|
+
if (ai < args.length) { val = args[ai++]; } else { result += '{' + inner + '}'; continue; }
|
|
214
|
+
}
|
|
215
|
+
if (!spec) { result += String(val); continue; }
|
|
216
|
+
var si = 0, fill = ' ', align = '', sign = '', comma = false, width = 0, hasWidth = false, precision = -1, type = '';
|
|
217
|
+
if (si + 1 < spec.length && (spec[si + 1] === '<' || spec[si + 1] === '>' || spec[si + 1] === '^')) { fill = spec[si]; align = spec[si + 1]; si += 2; }
|
|
218
|
+
else if (si < spec.length && (spec[si] === '<' || spec[si] === '>' || spec[si] === '^')) { align = spec[si]; si += 1; }
|
|
219
|
+
if (si < spec.length && (spec[si] === '+' || spec[si] === '-' || spec[si] === ' ')) { sign = spec[si]; si += 1; }
|
|
220
|
+
while (si < spec.length && spec[si] >= '0' && spec[si] <= '9') { width = width * 10 + (spec.charCodeAt(si) - 48); hasWidth = true; si += 1; }
|
|
221
|
+
if (si < spec.length && spec[si] === ',') { comma = true; si += 1; }
|
|
222
|
+
if (si < spec.length && spec[si] === '.') { si += 1; precision = 0; while (si < spec.length && spec[si] >= '0' && spec[si] <= '9') { precision = precision * 10 + (spec.charCodeAt(si) - 48); si += 1; } }
|
|
223
|
+
if (si < spec.length) { type = spec[si]; }
|
|
224
|
+
var formatted, numVal = typeof val === 'number' ? val : Number(val);
|
|
225
|
+
switch (type) {
|
|
226
|
+
case 'b': formatted = (numVal >>> 0).toString(2); if (numVal === 0) formatted = '0'; break;
|
|
227
|
+
case 'o': formatted = (numVal >>> 0).toString(8); if (numVal === 0) formatted = '0'; break;
|
|
228
|
+
case 'x': formatted = (numVal >>> 0).toString(16); if (numVal === 0) formatted = '0'; break;
|
|
229
|
+
case 'X': formatted = (numVal >>> 0).toString(16).toUpperCase(); if (numVal === 0) formatted = '0'; break;
|
|
230
|
+
case 'f': formatted = numVal.toFixed(precision >= 0 ? precision : 6); break;
|
|
231
|
+
case '%': {
|
|
232
|
+
var pct = numVal * 100;
|
|
233
|
+
formatted = precision >= 0 ? pct.toFixed(precision) + '%' : (Math.round(pct * 1e10) / 1e10).toString() + '%';
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
case '$': {
|
|
237
|
+
var abs = Math.abs(numVal), dollars = abs.toFixed(2), dotIdx2 = dollars.indexOf('.'), intPart2 = dollars.substring(0, dotIdx2), decPart2 = dollars.substring(dotIdx2);
|
|
238
|
+
var withCommas2 = '';
|
|
239
|
+
for (var j2 = 0; j2 < intPart2.length; j2++) { if (j2 > 0 && (intPart2.length - j2) % 3 === 0) withCommas2 += ','; withCommas2 += intPart2[j2]; }
|
|
240
|
+
formatted = (numVal < 0 ? '-' : '') + '$' + withCommas2 + decPart2;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
case 's': formatted = String(val); if (precision >= 0) formatted = formatted.substring(0, precision); break;
|
|
244
|
+
default:
|
|
245
|
+
if (typeof val === 'number' && precision >= 0 && !type) formatted = numVal.toFixed(precision);
|
|
246
|
+
else formatted = String(val);
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
if (comma && type !== '$') {
|
|
250
|
+
var dIdx = formatted.indexOf('.'), iPart = dIdx >= 0 ? formatted.substring(0, dIdx) : formatted, dPart = dIdx >= 0 ? formatted.substring(dIdx) : '';
|
|
251
|
+
var signChar = '', digits = iPart;
|
|
252
|
+
if (digits[0] === '-' || digits[0] === '+') { signChar = digits[0]; digits = digits.substring(1); }
|
|
253
|
+
var withC = '';
|
|
254
|
+
for (var j = 0; j < digits.length; j++) { if (j > 0 && (digits.length - j) % 3 === 0) withC += ','; withC += digits[j]; }
|
|
255
|
+
formatted = signChar + withC + dPart;
|
|
256
|
+
}
|
|
257
|
+
if (sign && type !== '$' && type !== '%') {
|
|
258
|
+
if (typeof val === 'number') {
|
|
259
|
+
var s = formatted;
|
|
260
|
+
if (s[0] === '-' || s[0] === '+') { s = s.substring(1); }
|
|
261
|
+
if (numVal >= 0) { if (sign === '+') formatted = '+' + s; else if (sign === ' ') formatted = ' ' + s; else formatted = s; }
|
|
262
|
+
else { formatted = '-' + s; }
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (hasWidth && formatted.length < width) {
|
|
266
|
+
var pad = width - formatted.length, a = align || '>';
|
|
267
|
+
if (a === '<') formatted = formatted + fill.repeat(pad);
|
|
268
|
+
else if (a === '^') { var left = Math.floor(pad / 2); formatted = fill.repeat(left) + formatted + fill.repeat(pad - left); }
|
|
269
|
+
else formatted = fill.repeat(pad) + formatted;
|
|
270
|
+
}
|
|
271
|
+
result += formatted;
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
result += template[pos]; pos++;
|
|
275
|
+
}
|
|
276
|
+
return result;
|
|
195
277
|
}
|
package/src/stdlib/validation.js
CHANGED
|
@@ -9,7 +9,7 @@ export function is_url(s) {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function is_numeric(s) {
|
|
12
|
-
return typeof s === 'string' && s.length > 0 && !isNaN(Number(s));
|
|
12
|
+
return typeof s === 'string' && s.length > 0 && s.trim().length > 0 && !isNaN(Number(s));
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export function is_alpha(s) {
|
package/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Auto-generated by scripts/embed-runtime.js — do not edit
|
|
2
|
-
export const VERSION = "0.
|
|
2
|
+
export const VERSION = "0.9.4";
|