@fraczak/k 6.10.5 → 6.10.6
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/CHANGELOG.md +29 -0
- package/browser/repl-browser.mjs +40 -22
- package/browser/shims/fs.mjs +7 -10
- package/browser/vfs-data.mjs +6 -6
- package/core.k +6 -85
- package/package.json +1 -1
- package/scripts/build-repl-html.mjs +10 -11
- package/tests/test-repl-html.mjs +81 -7
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,35 @@ All notable changes to this project will be documented here.
|
|
|
5
5
|
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
6
6
|
This project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [6.10.6] — 2026-10-08 — Minimal Core Schema and REPL VFS Uploads
|
|
9
|
+
|
|
10
|
+
### Core Schema & Language
|
|
11
|
+
|
|
12
|
+
- **Minimal `core.k` Schema**:
|
|
13
|
+
- Streamlined `core.k` to focus strictly on structural type schemas
|
|
14
|
+
and pattern foundations.
|
|
15
|
+
- Removed legacy bit arithmetic (`succ`, `plus`, `times`, constants
|
|
16
|
+
`2`..`10`, and helpers `inv`, `concat`), achieving a 39% reduction
|
|
17
|
+
in file size.
|
|
18
|
+
- Retained `$bit`, `$bits`, `_`, `0`, `1`, `$string`, `$unicode`, and
|
|
19
|
+
`$pattern` definitions intact for type derivation and codecs.
|
|
20
|
+
|
|
21
|
+
### Web REPL & VFS
|
|
22
|
+
|
|
23
|
+
- **VFS Namespace Flattening**:
|
|
24
|
+
- Flattened VFS back to root filenames (`int.mjs`, `json.mjs`,
|
|
25
|
+
`utf8.mjs`, `unit.mjs`, `ieee.mjs`), ensuring consistent resolution
|
|
26
|
+
across browser and CLI environments.
|
|
27
|
+
- **Upload File Directly to VFS**:
|
|
28
|
+
- Updated "Upload" action to strictly add uploaded files into the VFS
|
|
29
|
+
without auto-loading or evaluating them as K code.
|
|
30
|
+
- Enables uploading JavaScript codecs, JSON payloads, and test vectors.
|
|
31
|
+
- Expanded file picker `accept` filter to allow `.mjs`, `.js`, and
|
|
32
|
+
`.json` files.
|
|
33
|
+
- Supported `:codec load` for `.js` codecs in the VFS explorer modal.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
8
37
|
## [6.10.5] — 2026-10-08 — Adaptive Division and VFS Codecs
|
|
9
38
|
|
|
10
39
|
### Arithmetic & Algorithms
|
package/browser/repl-browser.mjs
CHANGED
|
@@ -477,7 +477,7 @@ function showVfsFilePreview(filename) {
|
|
|
477
477
|
function loadPreviewedFile() {
|
|
478
478
|
if (!currentPreviewFile) return;
|
|
479
479
|
closeVfsModal();
|
|
480
|
-
if (currentPreviewFile.endsWith(".mjs") || currentPreviewFile.startsWith("codecs/")) {
|
|
480
|
+
if (currentPreviewFile.endsWith(".mjs") || currentPreviewFile.endsWith(".js") || currentPreviewFile.startsWith("codecs/")) {
|
|
481
481
|
executeCommand(`:codec load ${currentPreviewFile}`);
|
|
482
482
|
} else {
|
|
483
483
|
executeCommand(`:load ${currentPreviewFile}`);
|
|
@@ -498,32 +498,49 @@ function downloadPreviewedFile() {
|
|
|
498
498
|
URL.revokeObjectURL(url);
|
|
499
499
|
}
|
|
500
500
|
|
|
501
|
-
// File Upload Handler
|
|
501
|
+
// File Upload Handler (adds file to VFS without auto-loading)
|
|
502
502
|
function handleFileUpload(file) {
|
|
503
|
-
|
|
504
|
-
|
|
503
|
+
return new Promise((resolve, reject) => {
|
|
504
|
+
const reader = new FileReader();
|
|
505
|
+
const isBinary = file.name.endsWith(".klib") ||
|
|
506
|
+
file.name.endsWith(".ko") ||
|
|
507
|
+
file.name.endsWith(".wasm");
|
|
508
|
+
|
|
509
|
+
reader.onload = (e) => {
|
|
510
|
+
let data;
|
|
511
|
+
if (isBinary) {
|
|
512
|
+
data = new Uint8Array(e.target.result);
|
|
513
|
+
} else {
|
|
514
|
+
data = e.target.result;
|
|
515
|
+
}
|
|
516
|
+
setVfsFile(file.name, data);
|
|
517
|
+
appendSystemMessage(
|
|
518
|
+
`📁 Uploaded <b>${escapeHtml(file.name)}</b> into VFS (` +
|
|
519
|
+
`${(data.length / 1024).toFixed(1)} KB).`,
|
|
520
|
+
false,
|
|
521
|
+
true
|
|
522
|
+
);
|
|
523
|
+
if (vfsModal && vfsModal.classList.contains("open")) {
|
|
524
|
+
renderVfsFileList();
|
|
525
|
+
showVfsFilePreview(file.name);
|
|
526
|
+
}
|
|
527
|
+
resolve();
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
reader.onerror = () => {
|
|
531
|
+
appendSystemMessage(
|
|
532
|
+
`❌ Error reading file: ${file.name}`,
|
|
533
|
+
true
|
|
534
|
+
);
|
|
535
|
+
reject(reader.error || new Error("Failed to read file"));
|
|
536
|
+
};
|
|
505
537
|
|
|
506
|
-
reader.onload = (e) => {
|
|
507
|
-
let data;
|
|
508
538
|
if (isBinary) {
|
|
509
|
-
|
|
539
|
+
reader.readAsArrayBuffer(file);
|
|
510
540
|
} else {
|
|
511
|
-
|
|
541
|
+
reader.readAsText(file);
|
|
512
542
|
}
|
|
513
|
-
|
|
514
|
-
appendSystemMessage(`📁 Uploaded <b>${escapeHtml(file.name)}</b> into VFS (${(data.length / 1024).toFixed(1)} KB).`);
|
|
515
|
-
if (file.name.endsWith("-codec.mjs") || file.name.endsWith("-codec.js") || file.name.includes("codec")) {
|
|
516
|
-
executeCommand(`:codec load ${file.name}`);
|
|
517
|
-
} else {
|
|
518
|
-
executeCommand(`:load ${file.name}`);
|
|
519
|
-
}
|
|
520
|
-
};
|
|
521
|
-
|
|
522
|
-
if (isBinary) {
|
|
523
|
-
reader.readAsArrayBuffer(file);
|
|
524
|
-
} else {
|
|
525
|
-
reader.readAsText(file);
|
|
526
|
-
}
|
|
543
|
+
});
|
|
527
544
|
}
|
|
528
545
|
|
|
529
546
|
// Export State as .klib
|
|
@@ -993,6 +1010,7 @@ if (typeof window !== "undefined") {
|
|
|
993
1010
|
getVfsFile,
|
|
994
1011
|
setVfsFile,
|
|
995
1012
|
getAllVfsFiles,
|
|
1013
|
+
handleFileUpload,
|
|
996
1014
|
openCodecsModal,
|
|
997
1015
|
registerCodec,
|
|
998
1016
|
unregisterCodec
|
package/browser/shims/fs.mjs
CHANGED
|
@@ -25,10 +25,7 @@ function cleanPath(p) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export function setVfsFile(path, content) {
|
|
28
|
-
|
|
29
|
-
if (cleaned.endsWith(".mjs") && !cleaned.startsWith("codecs/")) {
|
|
30
|
-
cleaned = `codecs/${cleaned}`;
|
|
31
|
-
}
|
|
28
|
+
const cleaned = cleanPath(path);
|
|
32
29
|
vfs.set(cleaned, content);
|
|
33
30
|
}
|
|
34
31
|
|
|
@@ -58,11 +55,11 @@ const CURATED_VFS_FILES = [
|
|
|
58
55
|
"ieee.k",
|
|
59
56
|
"poly.k",
|
|
60
57
|
"karatsuba-mult.k",
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
58
|
+
"json.mjs",
|
|
59
|
+
"utf8.mjs",
|
|
60
|
+
"int.mjs",
|
|
61
|
+
"unit.mjs",
|
|
62
|
+
"ieee.mjs"
|
|
66
63
|
];
|
|
67
64
|
|
|
68
65
|
export function getAllVfsFiles() {
|
|
@@ -74,7 +71,7 @@ export function getAllVfsFiles() {
|
|
|
74
71
|
}
|
|
75
72
|
for (const key of vfs.keys()) {
|
|
76
73
|
if (key.endsWith("runtime.wat") || key.startsWith("backends/")) continue;
|
|
77
|
-
if (key.startsWith("Examples/")) continue;
|
|
74
|
+
if (key.startsWith("Examples/") || key.startsWith("codecs/")) continue;
|
|
78
75
|
result.add(key);
|
|
79
76
|
}
|
|
80
77
|
return Array.from(result);
|