@hatchingpoint/point 0.0.5 → 0.0.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/README.md +18 -5
- package/package.json +1 -1
- package/src/core/ast.ts +40 -2
- package/src/core/check.ts +178 -67
- package/src/core/cli.ts +332 -51
- package/src/core/context.ts +213 -36
- package/src/core/emit-javascript.ts +124 -0
- package/src/core/emit-typescript.ts +38 -5
- package/src/core/format.ts +4 -102
- package/src/core/incremental.ts +53 -0
- package/src/core/index.ts +5 -0
- package/src/core/lexer.ts +11 -6
- package/src/core/parser.ts +11 -612
- package/src/core/semantic-source.ts +26 -0
- package/src/core/serialize.ts +18 -0
- package/src/core/test-only/core-text-parser.ts +415 -0
- package/src/core/test-only/format-core.ts +120 -0
- package/src/core/test-only/index.ts +3 -0
- package/src/core/test-only/legacy-lowering.ts +1047 -0
- package/src/semantic/ast.ts +230 -0
- package/src/semantic/callables.ts +51 -0
- package/src/semantic/context.ts +347 -0
- package/src/semantic/desugar.ts +665 -0
- package/src/semantic/expressions.ts +347 -0
- package/src/semantic/format.ts +222 -0
- package/src/semantic/index.ts +10 -0
- package/src/semantic/metadata.ts +37 -0
- package/src/semantic/naming.ts +33 -0
- package/src/semantic/parse.ts +945 -0
- package/src/semantic/serialize.ts +18 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
|
|
4
|
+
const CACHE_DIR = ".point-cache";
|
|
5
|
+
const MANIFEST = "manifest.json";
|
|
6
|
+
|
|
7
|
+
export interface PointBuildCacheEntry {
|
|
8
|
+
sourceHash: string;
|
|
9
|
+
checkedAt: string;
|
|
10
|
+
ok: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface PointBuildCacheManifest {
|
|
14
|
+
schemaVersion: "point.cache.v1";
|
|
15
|
+
entries: Record<string, PointBuildCacheEntry>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function hashPointSource(source: string): string {
|
|
19
|
+
return createHash("sha256").update(source).digest("hex");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function readBuildCache(cwd = process.cwd()): Promise<PointBuildCacheManifest> {
|
|
23
|
+
const path = resolve(cwd, CACHE_DIR, MANIFEST);
|
|
24
|
+
if (!(await Bun.file(path).exists())) {
|
|
25
|
+
return { schemaVersion: "point.cache.v1", entries: {} };
|
|
26
|
+
}
|
|
27
|
+
return Bun.file(path).json();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function writeBuildCache(manifest: PointBuildCacheManifest, cwd = process.cwd()): Promise<void> {
|
|
31
|
+
const path = resolve(cwd, CACHE_DIR, MANIFEST);
|
|
32
|
+
await Bun.$`mkdir -p ${resolve(cwd, CACHE_DIR)}`.quiet();
|
|
33
|
+
await Bun.write(path, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isIncrementalEnabled(): boolean {
|
|
37
|
+
return process.env.POINT_INCREMENTAL === "1" || process.env.POINT_INCREMENTAL === "true";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function isCacheHit(manifest: PointBuildCacheManifest, input: string, source: string): boolean {
|
|
41
|
+
const entry = manifest.entries[input];
|
|
42
|
+
return Boolean(entry && entry.sourceHash === hashPointSource(source) && entry.ok);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function recordCacheEntry(manifest: PointBuildCacheManifest, input: string, source: string, ok: boolean): PointBuildCacheManifest {
|
|
46
|
+
return {
|
|
47
|
+
...manifest,
|
|
48
|
+
entries: {
|
|
49
|
+
...manifest.entries,
|
|
50
|
+
[input]: { sourceHash: hashPointSource(source), checkedAt: new Date().toISOString(), ok },
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
package/src/core/index.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
export * from "./ast.ts";
|
|
2
2
|
export * from "./check.ts";
|
|
3
|
+
export { findRunEntryName } from "./cli.ts";
|
|
3
4
|
export * from "./context.ts";
|
|
4
5
|
export * from "./emit-typescript.ts";
|
|
6
|
+
export * from "./emit-javascript.ts";
|
|
7
|
+
export * from "./incremental.ts";
|
|
8
|
+
export * from "./serialize.ts";
|
|
9
|
+
export * from "../semantic/index.ts";
|
|
5
10
|
export * from "./format.ts";
|
|
6
11
|
export * from "./lexer.ts";
|
|
7
12
|
export * from "./parser.ts";
|
package/src/core/lexer.ts
CHANGED
|
@@ -13,8 +13,9 @@ export type PointCoreTokenType =
|
|
|
13
13
|
| "comma"
|
|
14
14
|
| "colon"
|
|
15
15
|
| "dot"
|
|
16
|
-
| "equals"
|
|
17
|
-
| "plusEquals"
|
|
16
|
+
| "equals"
|
|
17
|
+
| "plusEquals"
|
|
18
|
+
| "minusEquals"
|
|
18
19
|
| "equalsEquals"
|
|
19
20
|
| "bangEquals"
|
|
20
21
|
| "less"
|
|
@@ -136,10 +137,14 @@ class CoreLexer {
|
|
|
136
137
|
this.push("plus", this.advance());
|
|
137
138
|
continue;
|
|
138
139
|
}
|
|
139
|
-
if (char === "-") {
|
|
140
|
-
this.
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
if (char === "-") {
|
|
141
|
+
if (this.peek(1) === "=") {
|
|
142
|
+
this.push("minusEquals", `${this.advance()}${this.advance()}`);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
this.push("minus", this.advance());
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
143
148
|
if (char === "*") {
|
|
144
149
|
this.push("star", this.advance());
|
|
145
150
|
continue;
|