@fraczak/k 6.8.0 → 6.10.1

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 (45) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/CLAUDE.md +1 -1
  3. package/DOCS/BIG_PICTURE.md +3 -5
  4. package/DOCS/CODECS.md +80 -181
  5. package/DOCS/CODEC_ARCHITECTURE.md +194 -0
  6. package/DOCS/REPL.md +69 -51
  7. package/Examples/arithmetics.k +1 -0
  8. package/Examples/poly.k +46 -0
  9. package/backends/llvm/runtime/krt.c +4 -0
  10. package/backends/llvm/src/kvm2llvm.mjs +2 -2
  11. package/backends/llvm/tests/test-llvm.mjs +19 -0
  12. package/backends/wasm/src/kvm2wasm.mjs +4 -0
  13. package/backends/wasm/tests/test-wasm.mjs +4 -0
  14. package/browser/repl-browser.mjs +131 -779
  15. package/browser/shims/process.mjs +7 -0
  16. package/browser/tree-view.mjs +5 -2
  17. package/browser/vfs-data.mjs +14 -14
  18. package/codecs/README.md +7 -0
  19. package/codecs/ieee.mjs +50 -75
  20. package/codecs/int.mjs +83 -62
  21. package/codecs/json-codec.mjs +5 -77
  22. package/codecs/json.mjs +12 -56
  23. package/codecs/k-parse.mjs +3 -19
  24. package/codecs/runtime/codec-sdk.mjs +94 -0
  25. package/codecs/runtime/pattern-k.mjs +45 -0
  26. package/codecs/string-codec.mjs +48 -74
  27. package/codecs/unit.mjs +13 -61
  28. package/codecs/utf16.mjs +13 -56
  29. package/codecs/utf8.mjs +11 -55
  30. package/package.json +1 -1
  31. package/patterns/from-k.mjs +2 -22
  32. package/repl-codecs.mjs +69 -196
  33. package/repl.mjs +177 -281
  34. package/scripts/build-repl-html.mjs +114 -385
  35. package/scripts/run-tests.mjs +1 -0
  36. package/tests/test-codecs.mjs +186 -0
  37. package/tests/test-poly.mjs +44 -0
  38. package/tests/test-repl-html.mjs +163 -68
  39. package/tests/test-repl.mjs +210 -156
  40. package/tests/test-structural-values.mjs +17 -0
  41. package/tests/test-tree-view.mjs +3 -0
  42. package/codecs/example-pipeline.mjs +0 -163
  43. package/codecs/runtime/ieee-pattern.mjs +0 -30
  44. package/codecs/runtime/test-codec.mjs +0 -89
  45. package/codecs/runtime/typeFromValue.mjs +0 -34
@@ -17,6 +17,12 @@ export const stdout = {
17
17
  }
18
18
  };
19
19
 
20
+ export const stderr = {
21
+ write(chunk) {
22
+ console.error(chunk);
23
+ }
24
+ };
25
+
20
26
  export const hrtime = function() {
21
27
  const now = performance.now();
22
28
  const sec = Math.floor(now / 1000);
@@ -33,6 +39,7 @@ export const processShim = {
33
39
  exit,
34
40
  stdin,
35
41
  stdout,
42
+ stderr,
36
43
  hrtime,
37
44
  versions: { wabt_browser: "1.0" }
38
45
  };
@@ -482,7 +482,7 @@ export function createOutputEntryElement({
482
482
  // Value Section
483
483
  const valSection = document.createElement("details");
484
484
  valSection.className = "k-tree-section k-tree-value-section";
485
- valSection.open = true;
485
+ valSection.open = false;
486
486
 
487
487
  const valSummary = document.createElement("summary");
488
488
  valSummary.className = "k-tree-section-summary";
@@ -500,7 +500,7 @@ export function createOutputEntryElement({
500
500
  if (value && value.pattern) {
501
501
  const patSection = document.createElement("details");
502
502
  patSection.className = "k-tree-section k-tree-pat-section";
503
- patSection.open = true;
503
+ patSection.open = false;
504
504
 
505
505
  const patSummary = document.createElement("summary");
506
506
  patSummary.className = "k-tree-section-summary";
@@ -587,6 +587,9 @@ export function createOutputEntryElement({
587
587
  };
588
588
 
589
589
  collapseAllBtn.onclick = () => {
590
+ valSection.open = false;
591
+ const patSec = treeWrapper.querySelector(".k-tree-pat-section");
592
+ if (patSec) patSec.open = false;
590
593
  valBody.innerHTML = "";
591
594
  valBody.appendChild(renderValueNode(value, 1, 3));
592
595
  if (value && value.pattern && patBody) {