tova 0.7.0 → 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.
Files changed (59) hide show
  1. package/bin/tova.js +1312 -139
  2. package/package.json +8 -1
  3. package/src/analyzer/analyzer.js +539 -11
  4. package/src/analyzer/browser-analyzer.js +56 -8
  5. package/src/analyzer/deploy-analyzer.js +44 -0
  6. package/src/analyzer/scope.js +7 -0
  7. package/src/analyzer/server-analyzer.js +33 -1
  8. package/src/codegen/base-codegen.js +1296 -23
  9. package/src/codegen/browser-codegen.js +725 -20
  10. package/src/codegen/codegen.js +87 -5
  11. package/src/codegen/deploy-codegen.js +49 -0
  12. package/src/codegen/server-codegen.js +54 -6
  13. package/src/codegen/shared-codegen.js +5 -0
  14. package/src/codegen/theme-codegen.js +69 -0
  15. package/src/codegen/wasm-codegen.js +6 -0
  16. package/src/config/edit-toml.js +6 -2
  17. package/src/config/git-resolver.js +128 -0
  18. package/src/config/lock-file.js +57 -0
  19. package/src/config/module-cache.js +58 -0
  20. package/src/config/module-entry.js +37 -0
  21. package/src/config/module-path.js +63 -0
  22. package/src/config/pkg-errors.js +62 -0
  23. package/src/config/resolve.js +26 -0
  24. package/src/config/resolver.js +139 -0
  25. package/src/config/search.js +28 -0
  26. package/src/config/semver.js +72 -0
  27. package/src/config/toml.js +61 -6
  28. package/src/deploy/deploy.js +217 -0
  29. package/src/deploy/infer.js +218 -0
  30. package/src/deploy/provision.js +315 -0
  31. package/src/diagnostics/security-scorecard.js +111 -0
  32. package/src/lexer/lexer.js +18 -3
  33. package/src/lsp/server.js +482 -0
  34. package/src/parser/animate-ast.js +45 -0
  35. package/src/parser/ast.js +39 -0
  36. package/src/parser/browser-ast.js +19 -1
  37. package/src/parser/browser-parser.js +221 -4
  38. package/src/parser/concurrency-ast.js +15 -0
  39. package/src/parser/concurrency-parser.js +236 -0
  40. package/src/parser/deploy-ast.js +37 -0
  41. package/src/parser/deploy-parser.js +132 -0
  42. package/src/parser/parser.js +42 -5
  43. package/src/parser/select-ast.js +39 -0
  44. package/src/parser/theme-ast.js +29 -0
  45. package/src/parser/theme-parser.js +70 -0
  46. package/src/registry/plugins/concurrency-plugin.js +32 -0
  47. package/src/registry/plugins/deploy-plugin.js +33 -0
  48. package/src/registry/plugins/theme-plugin.js +20 -0
  49. package/src/registry/register-all.js +6 -0
  50. package/src/runtime/charts.js +547 -0
  51. package/src/runtime/embedded.js +6 -2
  52. package/src/runtime/reactivity.js +60 -0
  53. package/src/runtime/router.js +703 -295
  54. package/src/runtime/table.js +606 -33
  55. package/src/stdlib/inline.js +365 -10
  56. package/src/stdlib/runtime-bridge.js +152 -0
  57. package/src/stdlib/string.js +84 -2
  58. package/src/stdlib/validation.js +1 -1
  59. package/src/version.js +1 -1
@@ -28,6 +28,27 @@ let flushing = false;
28
28
  // Reusable array for flush cycle — avoids allocation on every flush
29
29
  let _flushBuf = [];
30
30
 
31
+ // Reset module-level mutable state for test isolation.
32
+ // Bun runs all test files in a single process, so Maps like __tovaStyleRefs
33
+ // accumulate entries across files. Call this between tests to prevent pollution.
34
+ export function __resetForTesting() {
35
+ if (typeof __tovaStyleRefs !== 'undefined') __tovaStyleRefs.clear();
36
+ if (typeof __tovaFontRefs !== 'undefined') __tovaFontRefs.clear();
37
+ __cspNonce = null;
38
+ __tovaHeadTags.length = 0;
39
+ pendingEffects.clear();
40
+ currentEffect = null;
41
+ currentOwner = null;
42
+ effectStack.length = 0;
43
+ ownerStack.length = 0;
44
+ batchDepth = 0;
45
+ flushing = false;
46
+ _flushBuf.length = 0;
47
+ __devtools_hooks = null;
48
+ __errorBoundaryIdCounter = 0;
49
+ currentErrorHandler = null;
50
+ }
51
+
31
52
  function flush() {
32
53
  if (flushing) return; // prevent re-entrant flush
33
54
  flushing = true;
@@ -960,6 +981,45 @@ export function tova_inject_css(id, css) {
960
981
  }
961
982
  }
962
983
 
984
+ // Load a remote font stylesheet with reference counting.
985
+ // When the last component using a font unmounts, the <link> is removed.
986
+ const __tovaFontRefs = new Map(); // id → { el, count }
987
+ export function __tova_load_font(id, url) {
988
+ const ref = __tovaFontRefs.get(id);
989
+ if (ref) {
990
+ ref.count++;
991
+ } else {
992
+ const link = document.createElement('link');
993
+ link.rel = 'stylesheet';
994
+ link.href = url;
995
+ link.dataset.tovaFont = id;
996
+ document.head.appendChild(link);
997
+ __tovaFontRefs.set(id, { el: link, count: 1 });
998
+ }
999
+ // Register cleanup on the current owner so unmount decrements the ref count
1000
+ if (currentOwner) {
1001
+ let cleaned = false;
1002
+ const cleanup = () => {
1003
+ if (cleaned) return;
1004
+ cleaned = true;
1005
+ const r = __tovaFontRefs.get(id);
1006
+ if (r) {
1007
+ r.count--;
1008
+ if (r.count <= 0) {
1009
+ if (typeof r.el.remove === 'function') {
1010
+ r.el.remove();
1011
+ } else if (r.el.parentNode && typeof r.el.parentNode.removeChild === 'function') {
1012
+ r.el.parentNode.removeChild(r.el);
1013
+ }
1014
+ __tovaFontRefs.delete(id);
1015
+ }
1016
+ }
1017
+ };
1018
+ if (!currentOwner._cleanups) currentOwner._cleanups = [];
1019
+ currentOwner._cleanups.push(cleanup);
1020
+ }
1021
+ }
1022
+
963
1023
  export function tova_el(tag, props = {}, children = []) {
964
1024
  return { __tova: true, tag, props, children };
965
1025
  }