chocola 1.6.0 → 2.0.0-next.10
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 +34 -36
- package/compiler/chalk.js +34 -0
- package/compiler/component-processor.js +526 -398
- package/compiler/config.js +3 -56
- package/compiler/dom-processor.js +12 -75
- package/compiler/fs.js +0 -11
- package/compiler/index.js +126 -254
- package/compiler/module-graph.js +210 -0
- package/compiler/pipeline.js +54 -196
- package/compiler/render.js +181 -0
- package/compiler/runtime-generator.js +20 -15
- package/compiler/utils.js +79 -126
- package/dev/index.js +28 -11
- package/index.js +0 -31
- package/package.json +11 -13
- package/parser/component.js +268 -0
- package/parser/context.js +59 -0
- package/parser/css.js +96 -0
- package/parser/index.js +5 -0
- package/parser/template.js +120 -0
- package/parser/utils.js +32 -0
- package/runtime/index.js +312 -0
- package/server/index.js +402 -0
- package/utils.js +41 -6
package/README.md
CHANGED
|
@@ -1,45 +1,43 @@
|
|
|
1
|
-
|
|
1
|
+
<picture>
|
|
2
|
+
<source media="(prefers-color-scheme: dark)" srcset="assets/banner_dark.jpg">
|
|
3
|
+
<img src="assets/banner.jpg" alt="Chocola • The sweetest way to build the web" />
|
|
4
|
+
</picture>
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
## What is Chocola
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
Chocola is a new and sweeter way to build your web apps.
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
No bundler config. No virtual DOM. No hydration ceremony. Just `.html` files with `<template>`, `<script>`, and `<style>` compiled to HTML with scoped CSS the browser already understands, and optional runtime when you need it.
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
<!-- counter.html -->
|
|
11
|
-
<div>
|
|
12
|
-
<button title={title}>{text}</button>
|
|
13
|
-
|
|
14
|
-
<div class="main">
|
|
15
|
-
<div class="number">{count}</div>
|
|
16
|
-
</div>
|
|
17
|
-
</div>
|
|
18
|
-
```
|
|
12
|
+
Import components. Instantiate them. Mount, update, remove. Client-side or server-side. Same file, minimal overhead.
|
|
19
13
|
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
14
|
+
```html
|
|
15
|
+
<script>
|
|
16
|
+
import CoolButton from './CoolButton.html';
|
|
17
|
+
|
|
18
|
+
let self;
|
|
19
|
+
let input;
|
|
20
|
+
|
|
21
|
+
export let title = "Hello";
|
|
22
|
+
|
|
23
|
+
function $runtime() {
|
|
24
|
+
input.focus();
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<div>
|
|
30
|
+
<h1>{title}</h1>
|
|
31
|
+
<input bind:self="input" type="text" placeholder="Your name">
|
|
32
|
+
<CoolButton label="Not lame button"></CoolButton>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<style>
|
|
37
|
+
h1 { color: chocolate; }
|
|
38
|
+
</style>
|
|
41
39
|
```
|
|
42
40
|
|
|
43
41
|
## Documentation
|
|
44
42
|
|
|
45
|
-
|
|
43
|
+
https://github.com/chocolajs/chocola/tree/main/documentation
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const ansi = {
|
|
2
|
+
bold: "\x1b[1m",
|
|
3
|
+
underline: "\x1b[4m",
|
|
4
|
+
red: "\x1b[31m",
|
|
5
|
+
green: "\x1b[32m",
|
|
6
|
+
yellow: "\x1b[33m",
|
|
7
|
+
blue: "\x1b[36m",
|
|
8
|
+
dim: "\x1b[90m"
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const reset = "\x1b[0m";
|
|
12
|
+
|
|
13
|
+
function hexToAnsi(h) {
|
|
14
|
+
const r = parseInt(h.slice(1, 3), 16);
|
|
15
|
+
const g = parseInt(h.slice(3, 5), 16);
|
|
16
|
+
const b = parseInt(h.slice(5, 7), 16);
|
|
17
|
+
return `\x1b[38;2;${r};${g};${b}m`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function makeChalk(stack) {
|
|
21
|
+
const fn = (s) => {
|
|
22
|
+
if (stack.length === 0) return s;
|
|
23
|
+
return stack.map(n => ansi[n] || hexToAnsi(n)).join("") + s + reset;
|
|
24
|
+
};
|
|
25
|
+
return new Proxy(fn, {
|
|
26
|
+
get(_, prop) {
|
|
27
|
+
if (prop === "hex") return (h) => makeChalk([...stack, h]);
|
|
28
|
+
return makeChalk([...stack, prop]);
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const chalk = makeChalk([]);
|
|
34
|
+
export default chalk;
|