@bytefaceinc/web-lang 0.1.1
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/LICENSE +21 -0
- package/README.md +277 -0
- package/bin/web.js +10 -0
- package/compiler.js +4602 -0
- package/docs/cli.md +657 -0
- package/docs/compiler.md +1433 -0
- package/docs/error-handling.md +863 -0
- package/docs/getting-started.md +805 -0
- package/docs/language-guide.md +945 -0
- package/lib/cli/commands/compile.js +127 -0
- package/lib/cli/commands/init.js +172 -0
- package/lib/cli/commands/screenshot.js +257 -0
- package/lib/cli/commands/watch.js +458 -0
- package/lib/cli/compile-service.js +19 -0
- package/lib/cli/compile-worker.js +32 -0
- package/lib/cli/compiler-runner.js +37 -0
- package/lib/cli/index.js +154 -0
- package/lib/cli/init-service.js +204 -0
- package/lib/cli/screenshot-artifacts.js +81 -0
- package/lib/cli/screenshot-service.js +153 -0
- package/lib/cli/shared.js +261 -0
- package/lib/cli/targets.js +199 -0
- package/lib/cli/watch-settings.js +37 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 WEB Lang contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/theRegex/web-lang/main/assets/logo-w.png" alt="WEB Lang logo" width="180" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">WEB Lang</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>.web is a power doc for rich website layouts.</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
Write structure, styling, metadata, responsive behavior, and small compile-time helpers in one language, then initialize starter projects, compile to standard HTML and CSS, render polished screenshots, or keep a live watch session running while you iterate.
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<img src="https://raw.githubusercontent.com/theRegex/web-lang/main/assets/banner-illustrated.png" alt="WEB Lang banner"/>
|
|
16
|
+
|
|
17
|
+
## What WEB Lang Is
|
|
18
|
+
|
|
19
|
+
WEB Lang is a compiler and CLI for `.web` files.
|
|
20
|
+
|
|
21
|
+
A `.web` file is designed to feel like a power doc:
|
|
22
|
+
|
|
23
|
+
- one source file for the page
|
|
24
|
+
- one mental model for structure and styling
|
|
25
|
+
- one place to express semantic layout, attributes, metadata, states, and responsive rules
|
|
26
|
+
- normal web-native output at the end
|
|
27
|
+
|
|
28
|
+
That means you author in one language, but ship plain HTML and CSS.
|
|
29
|
+
|
|
30
|
+
## Philosophy
|
|
31
|
+
|
|
32
|
+
WEB Lang is built around a simple idea:
|
|
33
|
+
|
|
34
|
+
> Rich website layouts should be easy to author without splitting design thinking across too many files too early.
|
|
35
|
+
|
|
36
|
+
The philosophy behind `.web` is:
|
|
37
|
+
|
|
38
|
+
- design and implementation should stay close together
|
|
39
|
+
- semantic structure should be easy to read at a glance
|
|
40
|
+
- shared styles should be reusable without a framework requirement
|
|
41
|
+
- HTML attributes and document metadata should stay explicit
|
|
42
|
+
- the final output should still be portable, reviewable, and standards-based
|
|
43
|
+
|
|
44
|
+
In practice, `.web` gives designers and developers a common source of truth for a page.
|
|
45
|
+
|
|
46
|
+
## Highlights
|
|
47
|
+
|
|
48
|
+
- Initialize a new WEB project with `web init`.
|
|
49
|
+
- Author `.web` source and compile to HTML and CSS.
|
|
50
|
+
- Render a compiled page to JPG or PNG with `web screenshot`.
|
|
51
|
+
- Keep a live watch session running with `web watch`.
|
|
52
|
+
- Use semantic type declarations such as `Main`, `Section`, `Heading1`, and `Link`.
|
|
53
|
+
- Define reusable tokens and shared style families in one top-level `define { ... }` block.
|
|
54
|
+
- Add real HTML attributes with `::attrs`.
|
|
55
|
+
- Add head metadata with `::head`.
|
|
56
|
+
- Emit browser scripts with `::script`.
|
|
57
|
+
- Add states with pseudo blocks like `::hover`.
|
|
58
|
+
- Add responsive behavior with `::media`.
|
|
59
|
+
- Use compile-time `js` literals for small generated values.
|
|
60
|
+
- Keep an escape hatch with `raw` for targeted CSS that does not fit the core language.
|
|
61
|
+
- Run the package as a CLI with `web`.
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
Install globally:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm install -g @bytefaceinc/web-lang
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Then run:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
web init
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Or scaffold into a named directory:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
web init website
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Or compile an existing file:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
web home.web
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Or render a screenshot:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
web screenshot home.web
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Or watch for changes:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
web watch home.web
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
For local development in a checkout:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npm link
|
|
105
|
+
web init
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
npm link
|
|
110
|
+
web home.web
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
WEB Lang supports Node.js `18+`.
|
|
114
|
+
|
|
115
|
+
## Quick Start
|
|
116
|
+
|
|
117
|
+
Initialize a starter project in a clean directory:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
web init
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Initialize the current directory explicitly:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
web init .
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Initialize a new `website` folder and create it if it does not exist yet:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
web init website
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
That creates:
|
|
136
|
+
|
|
137
|
+
- `index.web`
|
|
138
|
+
- `index.html`
|
|
139
|
+
- `index.css`
|
|
140
|
+
- `web-lang-agents.md`
|
|
141
|
+
|
|
142
|
+
The generated `web-lang-agents.md` combines the packaged getting-started guide, CLI guide, and compiler reference into one local file so coding agents can load the current WEB context quickly.
|
|
143
|
+
|
|
144
|
+
Compile one `.web` file:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
web home.web
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Compile the same file without writing the extension:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
web home
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Compile every `.web` file in the current directory:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
web .
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Compile matching files from another directory:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
web ./code/*
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Render a full-page screenshot at the default width:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
web screenshot home.web
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Render a viewport-sized JPG with an explicit device scale factor:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
web screenshot home.web --jpg 1080 1080 2
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Keep a file compiling automatically while you work:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
web watch home.web
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Keep a watch session running and capture a baseline screenshot plus timed snapshots every 5 minutes:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
web watch home.web -s
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Each source file compiles to matching output files next to the source:
|
|
193
|
+
|
|
194
|
+
- `home.web` -> `home.html`
|
|
195
|
+
- `home.web` -> `home.css`
|
|
196
|
+
|
|
197
|
+
Screenshots are written into a screenshot workspace rooted at the current working directory:
|
|
198
|
+
|
|
199
|
+
- `web screenshot home.web` -> `web-lang-screenshots/home-YYYY-MM-DD_HH-mm-ss-SSS.jpg`
|
|
200
|
+
- `web screenshot pages/about.web` -> `web-lang-screenshots/pages/about-YYYY-MM-DD_HH-mm-ss-SSS.jpg`
|
|
201
|
+
|
|
202
|
+
The CLI creates `./web-lang-screenshots` automatically the first time it needs it, and appends a human-readable local timestamp to each screenshot filename so repeated captures do not overwrite each other.
|
|
203
|
+
|
|
204
|
+
When `web watch <source> -s` is enabled, the watch session uses the same screenshot workspace and filename format. Watch sessions stop automatically after 1 hour of no recent source activity and print a verbose exit summary explaining why the process closed.
|
|
205
|
+
|
|
206
|
+
When `web init` runs, it writes `web-lang-agents.md` into the chosen project root. That file bundles `docs/getting-started.md`, `docs/cli.md`, and `docs/compiler.md` in that order so local agents have one up-to-date context document to read. If you pass a directory like `website`, WEB creates that directory first when needed.
|
|
207
|
+
|
|
208
|
+
## Programmatic API
|
|
209
|
+
|
|
210
|
+
WEB Lang can also be used as a Node module:
|
|
211
|
+
|
|
212
|
+
```js
|
|
213
|
+
const { compileFile, compileSource, resolveCompileOutputPaths } = require('@bytefaceinc/web-lang');
|
|
214
|
+
|
|
215
|
+
const result = compileFile('./home.web');
|
|
216
|
+
|
|
217
|
+
console.log(result.htmlPath);
|
|
218
|
+
console.log(result.cssPath);
|
|
219
|
+
console.log(result.stats);
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
The package exports:
|
|
223
|
+
|
|
224
|
+
- `compileFile(inputPath, options)`
|
|
225
|
+
- `compileSource(source, options)`
|
|
226
|
+
- `resolveCompileOutputPaths(inputPath, options)`
|
|
227
|
+
- `CompilerError`
|
|
228
|
+
|
|
229
|
+
## Documentation
|
|
230
|
+
|
|
231
|
+
Start here:
|
|
232
|
+
|
|
233
|
+
- [Getting Started](./docs/getting-started.md)
|
|
234
|
+
- [Language Guide](./docs/language-guide.md)
|
|
235
|
+
- [CLI Guide](./docs/cli.md)
|
|
236
|
+
- [Compiler Reference](./docs/compiler.md)
|
|
237
|
+
- [Error Handling](./docs/error-handling.md)
|
|
238
|
+
|
|
239
|
+
## Agent Support
|
|
240
|
+
|
|
241
|
+
This repo includes committed agent-facing context for the major repository instruction surfaces used by current coding agents:
|
|
242
|
+
|
|
243
|
+
- [AGENTS.md](./AGENTS.md) for repo-wide instructions, with scoped overrides in `docs/`, `lib/cli/`, and `syntax_highlighter/`
|
|
244
|
+
- [CLAUDE.md](./CLAUDE.md) plus `.claude/rules/` for Claude Code
|
|
245
|
+
- `.github/copilot-instructions.md`, `.github/instructions/`, and `.github/agents/` for GitHub Copilot
|
|
246
|
+
- [web-lang-agents.md](./web-lang-agents.md) and [docs/agents/README.md](./docs/agents/README.md) for deeper WEB Lang maintainer context
|
|
247
|
+
|
|
248
|
+
Generated projects created by `web init` still receive their own local `web-lang-agents.md` context file bundled from the packaged getting-started, CLI, and compiler docs.
|
|
249
|
+
|
|
250
|
+
## Why It Feels Different
|
|
251
|
+
|
|
252
|
+
Many tools ask you to split a page into separate structure, style, metadata, and behavior files very early.
|
|
253
|
+
|
|
254
|
+
WEB Lang intentionally starts from a different place:
|
|
255
|
+
|
|
256
|
+
- a page is a document
|
|
257
|
+
- a document can still be expressive
|
|
258
|
+
- structure and styling are easier to reason about when they live close together
|
|
259
|
+
|
|
260
|
+
That is why `.web` is a power doc: it is not only a template format and not only a styling language. It is a single authoring surface for rich website layouts.
|
|
261
|
+
|
|
262
|
+
## Publishing Notes
|
|
263
|
+
|
|
264
|
+
This package is structured for public distribution with:
|
|
265
|
+
|
|
266
|
+
- a public-ready `package.json`
|
|
267
|
+
- a CLI binary entry in `bin`
|
|
268
|
+
- a documented Node API export
|
|
269
|
+
- a curated `files` list for clean package contents
|
|
270
|
+
- a license file
|
|
271
|
+
- package-local docs and branding assets
|
|
272
|
+
|
|
273
|
+
To preview the published package contents:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
npm pack --dry-run
|
|
277
|
+
```
|
package/bin/web.js
ADDED