wgsl-edit 0.0.2
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/.turbo/turbo-build.log +19 -0
- package/.turbo/turbo-typecheck.log +5 -0
- package/README.md +168 -0
- package/bin/wgsl-edit +2 -0
- package/demo/index.html +68 -0
- package/demo/main.ts +22 -0
- package/demo/style.css +114 -0
- package/dist/Language.d.mts +30 -0
- package/dist/Language.mjs +127 -0
- package/dist/WgslEdit-D62UKrqG.mjs +649 -0
- package/dist/WgslEdit.d.mts +118 -0
- package/dist/WgslEdit.mjs +4 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +8 -0
- package/package.json +34 -0
- package/site/assets/index-1yVlrenS.js +134 -0
- package/site/assets/index-oyrhrEUu.css +1 -0
- package/site/index.html +68 -0
- package/src/Cli.ts +115 -0
- package/src/Language.ts +204 -0
- package/src/WgslEdit.css +168 -0
- package/src/WgslEdit.ts +783 -0
- package/src/index.ts +8 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +3 -0
- package/tsdown.config.ts +28 -0
- package/vite.config.ts +11 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { LinkParams } from "wesl";
|
|
2
|
+
|
|
3
|
+
//#region src/WgslEdit.d.ts
|
|
4
|
+
type WeslProject = Pick<LinkParams, "weslSrc" | "rootModuleName" | "conditions" | "constants" | "libs" | "packageName">;
|
|
5
|
+
type Theme = "light" | "dark" | "auto";
|
|
6
|
+
type LintMode = "on" | "off";
|
|
7
|
+
declare class WgslEdit extends HTMLElement {
|
|
8
|
+
static observedAttributes: string[];
|
|
9
|
+
private editorView;
|
|
10
|
+
private editorContainer;
|
|
11
|
+
private tabBar;
|
|
12
|
+
private snackbar;
|
|
13
|
+
private readonlyCompartment;
|
|
14
|
+
private themeCompartment;
|
|
15
|
+
private lintCompartment;
|
|
16
|
+
private lineNumbersCompartment;
|
|
17
|
+
private _pendingSource;
|
|
18
|
+
private _theme;
|
|
19
|
+
private _mediaQuery;
|
|
20
|
+
private _lineNumbers;
|
|
21
|
+
private _files;
|
|
22
|
+
private _activeFile;
|
|
23
|
+
private _tabs;
|
|
24
|
+
private _lint;
|
|
25
|
+
private _conditions;
|
|
26
|
+
private _packageName;
|
|
27
|
+
private _libs;
|
|
28
|
+
private _ignorePackages;
|
|
29
|
+
private _fetchingPkgs;
|
|
30
|
+
private _snackTimer;
|
|
31
|
+
private _externalDiagnostics;
|
|
32
|
+
private _lintFromEl;
|
|
33
|
+
/** Bound listeners for lint-from element's compile events. */
|
|
34
|
+
private _boundCompileError;
|
|
35
|
+
private _boundCompileSuccess;
|
|
36
|
+
constructor();
|
|
37
|
+
connectedCallback(): void;
|
|
38
|
+
disconnectedCallback(): void;
|
|
39
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
40
|
+
/** Active file content (backward compatible). */
|
|
41
|
+
get source(): string;
|
|
42
|
+
/** Set active file content (backward compatible). */
|
|
43
|
+
set source(value: string);
|
|
44
|
+
/** All file contents keyed by module path (e.g., "package::main"). */
|
|
45
|
+
get sources(): Record<string, string>;
|
|
46
|
+
/** Set all files (replaces existing). */
|
|
47
|
+
set sources(value: Record<string, string>);
|
|
48
|
+
/** Load a full project config (sources, conditions, packageName, etc.). */
|
|
49
|
+
set project(value: WeslProject);
|
|
50
|
+
/** Currently active file name. */
|
|
51
|
+
get activeFile(): string;
|
|
52
|
+
/** Switch to a file by name. */
|
|
53
|
+
set activeFile(name: string);
|
|
54
|
+
/** List of file names in order. */
|
|
55
|
+
get fileNames(): string[];
|
|
56
|
+
/** Tab bar visibility. */
|
|
57
|
+
get tabs(): boolean;
|
|
58
|
+
set tabs(value: boolean);
|
|
59
|
+
/** Lint mode: "on" (default) or "off". */
|
|
60
|
+
get lint(): LintMode;
|
|
61
|
+
set lint(value: LintMode);
|
|
62
|
+
/** Line numbers visibility (default: true). */
|
|
63
|
+
get lineNumbers(): boolean;
|
|
64
|
+
set lineNumbers(value: boolean);
|
|
65
|
+
/** Whether the editor is currently loading content. */
|
|
66
|
+
get loading(): boolean;
|
|
67
|
+
set loading(value: boolean);
|
|
68
|
+
/** Show the snackbar with a message. Auto-hides after `ms` if provided. */
|
|
69
|
+
private showSnack;
|
|
70
|
+
private hideSnack;
|
|
71
|
+
get readonly(): boolean;
|
|
72
|
+
set readonly(value: boolean);
|
|
73
|
+
get theme(): Theme;
|
|
74
|
+
set theme(value: Theme);
|
|
75
|
+
get shaderRoot(): string | null;
|
|
76
|
+
set shaderRoot(value: string | null);
|
|
77
|
+
/** Add a new file. */
|
|
78
|
+
addFile(name: string, content?: string): void;
|
|
79
|
+
/** Remove a file. */
|
|
80
|
+
removeFile(name: string): void;
|
|
81
|
+
/** Rename a file. */
|
|
82
|
+
renameFile(oldName: string, newName: string): void;
|
|
83
|
+
/** Switch to a file, saving current state and restoring target state. */
|
|
84
|
+
private switchToFile;
|
|
85
|
+
/** Save current editor state to the active file. */
|
|
86
|
+
private saveCurrentFileState;
|
|
87
|
+
private dispatchFileChange;
|
|
88
|
+
private initEditor;
|
|
89
|
+
private readInitialAttributes;
|
|
90
|
+
private buildExtensions;
|
|
91
|
+
private resolveTheme;
|
|
92
|
+
private updateTheme;
|
|
93
|
+
private updateReadonly;
|
|
94
|
+
private resolveLint;
|
|
95
|
+
/** Fetch missing library packages, deduplicating in-flight requests. */
|
|
96
|
+
private fetchLibsOnDemand;
|
|
97
|
+
private updateLint;
|
|
98
|
+
/** Listen for compile-error/compile-success events from a lint source element. */
|
|
99
|
+
private connectLintSource;
|
|
100
|
+
private onCompileError;
|
|
101
|
+
private onCompileSuccess;
|
|
102
|
+
private resolveLineNumbers;
|
|
103
|
+
private updateLineNumbers;
|
|
104
|
+
/** Parse script tags into _files. Supports single or multi-file via data-name. */
|
|
105
|
+
private parseInlineContent;
|
|
106
|
+
/** Render tab bar based on files and visibility mode. */
|
|
107
|
+
private renderTabs;
|
|
108
|
+
/** Create a tab button for a file. */
|
|
109
|
+
private createTab;
|
|
110
|
+
/** Create the "+" button for adding new files. */
|
|
111
|
+
private createAddButton;
|
|
112
|
+
/** Start inline rename of a tab. */
|
|
113
|
+
private startRenameTab;
|
|
114
|
+
private loadFromUrl;
|
|
115
|
+
private loadInitialContent;
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
export { WeslProject, WgslEdit };
|
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { wesl, weslLanguage } from "./Language.mjs";
|
|
2
|
+
import { t as WgslEdit } from "./WgslEdit-D62UKrqG.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
if (!customElements.get("wgsl-edit")) customElements.define("wgsl-edit", WgslEdit);
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { WgslEdit, wesl, weslLanguage };
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "wgsl-edit",
|
|
3
|
+
"description": "Web component for editing WGSL/WESL with CodeMirror",
|
|
4
|
+
"version": "0.0.2",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./src/index.ts",
|
|
8
|
+
"./element": "./src/WgslEdit.ts",
|
|
9
|
+
"./language": "./src/Language.ts"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@codemirror/language": "^6.11.2",
|
|
13
|
+
"@codemirror/lint": "^6.0.0",
|
|
14
|
+
"@codemirror/state": "^6.0.0",
|
|
15
|
+
"@codemirror/view": "^6.0.0",
|
|
16
|
+
"@lezer/highlight": "^1.2.1",
|
|
17
|
+
"codemirror": "^6.0.0",
|
|
18
|
+
"wesl-fetch": "0.0.2",
|
|
19
|
+
"wesl": "0.7.15",
|
|
20
|
+
"lezer-wesl": "0.6.37"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"open": "^10.0.0",
|
|
24
|
+
"vite": "^7.3.0",
|
|
25
|
+
"wgsl-play": "x",
|
|
26
|
+
"yargs": "^18.0.0"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsdown",
|
|
30
|
+
"build:demo": "vite build --config vite.config.ts demo",
|
|
31
|
+
"dev": "vite demo",
|
|
32
|
+
"typecheck": "tsgo"
|
|
33
|
+
}
|
|
34
|
+
}
|