chocola 2.0.0-next.5 → 2.0.0-next.7
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 +4 -5
- package/compiler/chalk.js +32 -32
- package/compiler/component-processor.js +459 -667
- package/compiler/dom-processor.js +3 -20
- package/compiler/index.js +13 -4
- package/compiler/runtime-generator.js +22 -5
- package/compiler/utils.js +8 -35
- package/package.json +1 -1
- package/parser/component.js +129 -0
- package/parser/context.js +29 -0
- package/parser/css.js +96 -0
- package/parser/index.js +5 -0
- package/parser/template.js +120 -0
- package/parser/utils.js +13 -0
- package/runtime/index.js +309 -0
- package/utils.js +15 -0
package/README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
# chocola
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**The sweetest way to build the web.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
No bundler config. No virtual DOM. No hydration ceremony. Just `.html` files with `<template>`, `<script>`, and `<style>` — compiled to static HTML with scoped CSS, and optional runtime when you need it.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Import components. Instantiate them. Mount, update, remove. All client-side. Same file, zero overhead.
|
|
8
8
|
|
|
9
9
|
```html
|
|
10
|
-
<!-- Greeting.html -->
|
|
11
10
|
<script>
|
|
12
11
|
let self = new HTMLDivElement;
|
|
13
12
|
let input = new HTMLInputElement;
|
|
@@ -33,4 +32,4 @@ Chocola is a JavaScript library for creating web user interfaces.
|
|
|
33
32
|
|
|
34
33
|
## Documentation
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
https://github.com/chocolajs/chocola/wiki/Overview
|
package/compiler/chalk.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
const ansi = {
|
|
2
|
-
bold: "\x1b[1m",
|
|
3
|
-
underline: "\x1b[4m",
|
|
4
|
-
red: "\x1b[31m",
|
|
5
|
-
green: "\x1b[32m",
|
|
6
|
-
yellow: "\x1b[33m",
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const reset = "\x1b[0m";
|
|
10
|
-
|
|
11
|
-
function hexToAnsi(h) {
|
|
12
|
-
const r = parseInt(h.slice(1, 3), 16);
|
|
13
|
-
const g = parseInt(h.slice(3, 5), 16);
|
|
14
|
-
const b = parseInt(h.slice(5, 7), 16);
|
|
15
|
-
return `\x1b[38;2;${r};${g};${b}m`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function makeChalk(stack) {
|
|
19
|
-
const fn = (s) => {
|
|
20
|
-
if (stack.length === 0) return s;
|
|
21
|
-
return stack.map(n => ansi[n] || hexToAnsi(n)).join("") + s + reset;
|
|
22
|
-
};
|
|
23
|
-
return new Proxy(fn, {
|
|
24
|
-
get(_, prop) {
|
|
25
|
-
if (prop === "hex") return (h) => makeChalk([...stack, h]);
|
|
26
|
-
return makeChalk([...stack, prop]);
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const chalk = makeChalk([]);
|
|
32
|
-
export default chalk;
|
|
1
|
+
const ansi = {
|
|
2
|
+
bold: "\x1b[1m",
|
|
3
|
+
underline: "\x1b[4m",
|
|
4
|
+
red: "\x1b[31m",
|
|
5
|
+
green: "\x1b[32m",
|
|
6
|
+
yellow: "\x1b[33m",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const reset = "\x1b[0m";
|
|
10
|
+
|
|
11
|
+
function hexToAnsi(h) {
|
|
12
|
+
const r = parseInt(h.slice(1, 3), 16);
|
|
13
|
+
const g = parseInt(h.slice(3, 5), 16);
|
|
14
|
+
const b = parseInt(h.slice(5, 7), 16);
|
|
15
|
+
return `\x1b[38;2;${r};${g};${b}m`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function makeChalk(stack) {
|
|
19
|
+
const fn = (s) => {
|
|
20
|
+
if (stack.length === 0) return s;
|
|
21
|
+
return stack.map(n => ansi[n] || hexToAnsi(n)).join("") + s + reset;
|
|
22
|
+
};
|
|
23
|
+
return new Proxy(fn, {
|
|
24
|
+
get(_, prop) {
|
|
25
|
+
if (prop === "hex") return (h) => makeChalk([...stack, h]);
|
|
26
|
+
return makeChalk([...stack, prop]);
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const chalk = makeChalk([]);
|
|
32
|
+
export default chalk;
|