hclang 0.20.2 → 0.20.3
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/README.md +1 -1
- package/esm/cli/hc.js +6 -6
- package/esm/lib/bundle/hc-bundle.js +35 -0
- package/esm/lib/bundle/hc-sources.js +3795 -0
- package/esm/lib/execute/resource-import.js +90 -5
- package/esm/lib/version.js +1 -1
- package/package.json +1 -1
- package/esm/lib/modules/standard-modules.js +0 -36
- package/esm/lib/modules/standard-sources.js +0 -366
package/README.md
CHANGED
|
@@ -111,7 +111,7 @@ The root `deno.json` provides several tasks:
|
|
|
111
111
|
|
|
112
112
|
### BitScheme
|
|
113
113
|
|
|
114
|
-
[BitScheme](
|
|
114
|
+
[BitScheme](hc/BitScheme.hc) is a specialized scripting language for
|
|
115
115
|
declaratively parsing, manipulating, and generating binary data. It includes
|
|
116
116
|
executable documentation that can be tested:
|
|
117
117
|
|
package/esm/cli/hc.js
CHANGED
|
@@ -9,7 +9,7 @@ import { parseArgs } from "../deps/jsr.io/@std/cli/1.0.32/parse_args.js";
|
|
|
9
9
|
import { runfile } from "./runfile.js";
|
|
10
10
|
import { Prompt } from "./prompt.js";
|
|
11
11
|
import { DenoFileStore } from "./resource-store.js";
|
|
12
|
-
import {
|
|
12
|
+
import { withHCBundle } from "../lib/bundle/hc-bundle.js";
|
|
13
13
|
import { CLOCK_SCHEME, ClockHandler, Frame, FrameResource, RealClock, RESOURCE_ROOT_KEY, ResourceHandlers, } from "../lib/frames.js";
|
|
14
14
|
/**
|
|
15
15
|
* @module hc
|
|
@@ -47,8 +47,8 @@ export function getOptions(args) {
|
|
|
47
47
|
* identifier resolves against a fresh temp directory rather than against the
|
|
48
48
|
* working directory. That is a narrowing: the process still holds whatever the
|
|
49
49
|
* harness granted it, and the root binding is the ceiling the language enforces
|
|
50
|
-
* inside it. The root also overlays the read-only
|
|
51
|
-
* `'./
|
|
50
|
+
* inside it. The root also overlays the bundled, read-only `hc/` files, so
|
|
51
|
+
* `'./hc/figures.hc'` reads the shipped Figures source and nothing else
|
|
52
52
|
* widens.
|
|
53
53
|
*
|
|
54
54
|
* @param env - An object containing key-value pairs of environment variables.
|
|
@@ -63,8 +63,8 @@ export function getEval(env, out) {
|
|
|
63
63
|
/**
|
|
64
64
|
* Builds this harness's host namespace, root binding included.
|
|
65
65
|
*
|
|
66
|
-
* The root is a fresh temp directory with the read-only
|
|
67
|
-
* over it, so a program can import them without reaching anything else.
|
|
66
|
+
* The root is a fresh temp directory with the bundled, read-only `hc/` files
|
|
67
|
+
* laid over it, so a program can import them without reaching anything else.
|
|
68
68
|
*
|
|
69
69
|
* Exported so a test can run a source unit under the authority the CLI actually
|
|
70
70
|
* grants, rather than under an empty namespace that would make the resource
|
|
@@ -78,7 +78,7 @@ export function getHost(context = {}) {
|
|
|
78
78
|
// logger holds the same one: the root binding belongs to the host namespace
|
|
79
79
|
// and nowhere else.
|
|
80
80
|
const host = new Frame({ ...context });
|
|
81
|
-
host.set(RESOURCE_ROOT_KEY, FrameResource.root(
|
|
81
|
+
host.set(RESOURCE_ROOT_KEY, FrameResource.root(withHCBundle(new DenoFileStore()), getHandlers()));
|
|
82
82
|
return host;
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The HC files this package ships, served read-only under the root.
|
|
3
|
+
*
|
|
4
|
+
* Every `hc/*.hc` in the repository is ordinary HC source, and the package
|
|
5
|
+
* bundles all of it under the same path, so a session can include one with
|
|
6
|
+
* `<-`: `Figures <- './hc/figures.hc'` reads `hc/figures.hc`. Nothing is in
|
|
7
|
+
* scope until a program imports it. The path is root-relative like every other
|
|
8
|
+
* path, so it names a location inside the root binding, never one beside a
|
|
9
|
+
* source file or the working directory. A host lays the bundle over its root's
|
|
10
|
+
* store as fixed entries: reading one answers the shipped source, writing one is
|
|
11
|
+
* refused, and every other path, a sibling under `hc/` included, still resolves
|
|
12
|
+
* inside that root. No permission flag and no root widens, so a program gains
|
|
13
|
+
* these reads and nothing else.
|
|
14
|
+
*
|
|
15
|
+
* The sources are compiled into the program from the generated
|
|
16
|
+
* `lib/bundle/hc-sources.ts` (`deno task bundle:embed`, checked by
|
|
17
|
+
* `deno task bundle:check`), so the CLI, the compiled binary, the npm package,
|
|
18
|
+
* `HCLang`, and the browser playground serve the same text without reading a
|
|
19
|
+
* file at run time.
|
|
20
|
+
*
|
|
21
|
+
* @module
|
|
22
|
+
*/
|
|
23
|
+
import { ResourceMapStore, } from "../frames/resource-store.js";
|
|
24
|
+
import { HC_SOURCES } from "./hc-sources.js";
|
|
25
|
+
/** Checked and copied once, so a host start or `reset()` only wraps a store. */
|
|
26
|
+
const overlayHCBundle = ResourceMapStore.overlay(HC_SOURCES);
|
|
27
|
+
/**
|
|
28
|
+
* Lays the bundled HC files over a store as read-only entries.
|
|
29
|
+
*
|
|
30
|
+
* @param store The root's store, which keeps every other path.
|
|
31
|
+
* @returns A store that serves the bundle and delegates the rest.
|
|
32
|
+
*/
|
|
33
|
+
export function withHCBundle(store) {
|
|
34
|
+
return overlayHCBundle(store);
|
|
35
|
+
}
|