@u84u/gl 0.0.0-stage → 0.1.0

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.
@@ -0,0 +1,19 @@
1
+ import { S as SourceResolver, a as SourceModule } from '../resolver-Fn4_IKEu.js';
2
+
3
+ /**
4
+ * Node.js filesystem source resolver. Resolves `.gl` import specifiers
5
+ * relative to the importing module's directory on disk.
6
+ *
7
+ * All file I/O is confined to this adapter; the compiler core never imports
8
+ * `fs` or `path`.
9
+ */
10
+ declare class NodeFileSourceResolver implements SourceResolver {
11
+ /** Root directory used to validate that resolved paths stay within bounds. */
12
+ readonly rootDir: string;
13
+ constructor(
14
+ /** Root directory used to validate that resolved paths stay within bounds. */
15
+ rootDir: string);
16
+ resolve(specifier: string, importer: SourceModule): Promise<SourceModule>;
17
+ }
18
+
19
+ export { NodeFileSourceResolver };
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/node/resolver.ts
4
+ import { readFile, realpath } from "fs/promises";
5
+ import { resolve, dirname, relative, isAbsolute, sep } from "path";
6
+ var NodeFileSourceResolver = class {
7
+ constructor(rootDir) {
8
+ this.rootDir = rootDir;
9
+ }
10
+ rootDir;
11
+ async resolve(specifier, importer) {
12
+ const importerDir = dirname(importer.id);
13
+ const resolvedPath = resolve(importerDir, specifier);
14
+ const canonicalRoot = await realpath(resolve(this.rootDir)).catch(() => resolve(this.rootDir));
15
+ let canonicalTarget;
16
+ try {
17
+ canonicalTarget = await realpath(resolvedPath);
18
+ } catch {
19
+ canonicalTarget = resolvedPath;
20
+ }
21
+ const rel = relative(canonicalRoot, canonicalTarget);
22
+ if (rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
23
+ throw new Error(
24
+ `Import "${specifier}" resolves outside configured root ${this.rootDir}`
25
+ );
26
+ }
27
+ let source;
28
+ try {
29
+ source = await readFile(resolvedPath, "utf-8");
30
+ } catch (err) {
31
+ throw new Error(
32
+ `Failed to read imported module "${specifier}" from ${resolvedPath}: ${err instanceof Error ? err.message : String(err)}`
33
+ );
34
+ }
35
+ return {
36
+ id: resolvedPath,
37
+ displayName: specifier,
38
+ source
39
+ };
40
+ }
41
+ };
42
+ export {
43
+ NodeFileSourceResolver
44
+ };
@@ -0,0 +1,17 @@
1
+ interface SourceModule {
2
+ id: string;
3
+ displayName: string;
4
+ source: string;
5
+ }
6
+ interface SourceResolver {
7
+ resolve(specifier: string, importer: SourceModule): Promise<SourceModule>;
8
+ }
9
+ declare class MemorySourceResolver implements SourceResolver {
10
+ private modules;
11
+ set(id: string, source: string, displayName?: string): void;
12
+ get(id: string): SourceModule | undefined;
13
+ resolve(specifier: string, importer: SourceModule): Promise<SourceModule>;
14
+ ids(): string[];
15
+ }
16
+
17
+ export { MemorySourceResolver as M, type SourceResolver as S, type SourceModule as a };
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "@u84u/gl",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Compiler for the gl shading language, transpiling to GLSL (450, ES 3.00) and WGSL",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "bin": {
8
+ "gl": "dist/cli.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "./node": {
19
+ "types": "./dist/node/resolver.d.ts",
20
+ "default": "./dist/node/resolver.js"
21
+ },
22
+ "./browser": {
23
+ "types": "./dist/browser/resolver.d.ts",
24
+ "default": "./dist/browser/resolver.js"
25
+ },
26
+ "./cli": {
27
+ "types": "./dist/cli.d.ts",
28
+ "default": "./dist/cli.js"
29
+ }
30
+ },
31
+ "scripts": {
32
+ "build": "tsup",
33
+ "dev": "tsup --watch",
34
+ "typecheck": "tsc --noEmit",
35
+ "test": "vitest run",
36
+ "coverage": "vitest run --coverage",
37
+ "build:validate": "tsx scripts/validate.ts build",
38
+ "validate": "tsx scripts/validate.ts validate",
39
+ "lsp": "tsx src/lsp/server.ts",
40
+ "prepack": "npm run build"
41
+ },
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/u84u/gl.git"
45
+ },
46
+ "keywords": [
47
+ "glsl",
48
+ "wgsl",
49
+ "shader",
50
+ "compiler",
51
+ "transpiler"
52
+ ],
53
+ "author": "u84u",
54
+ "license": "CC-BY-4.0",
55
+ "type": "module",
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
59
+ "engines": {
60
+ "node": ">=18.0.0"
61
+ },
62
+ "devDependencies": {
63
+ "@types/node": "^24.0.0",
64
+ "@vitest/coverage-v8": "^5.1.0",
65
+ "commander": "^13.0.0",
66
+ "tsup": "^8.4.0",
67
+ "tsx": "^4.23.15",
68
+ "typescript": "^5.8.0",
69
+ "vitest": "^5.1.0"
70
+ }
71
+ }