chocola 2.0.0-next.2 → 2.0.0-next.5
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 +36 -45
- package/compiler/chalk.js +32 -0
- package/compiler/component-processor.js +667 -489
- package/compiler/config.js +1 -54
- package/compiler/dom-processor.js +5 -54
- package/compiler/fs.js +0 -11
- package/compiler/index.js +85 -107
- package/compiler/pipeline.js +34 -188
- package/compiler/runtime-generator.js +0 -6
- package/compiler/utils.js +9 -105
- package/dev/index.js +1 -1
- package/package.json +4 -9
- package/utils.js +0 -5
package/README.md
CHANGED
|
@@ -1,45 +1,36 @@
|
|
|
1
|
-
# chocola
|
|
2
|
-
|
|
3
|
-
Chocola is a JavaScript library for creating web user interfaces.
|
|
4
|
-
|
|
5
|
-
`chocola` only contains the functionality to build and serve web static builds. For production you may want to implement `chocola` to your workflow with other frameworks
|
|
6
|
-
|
|
7
|
-
## Usage
|
|
8
|
-
|
|
9
|
-
```html
|
|
10
|
-
<!--
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
styles,
|
|
38
|
-
script: RUNTIME
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Documentation
|
|
44
|
-
|
|
45
|
-
See https://github.com/sad-gabi/chocola/wiki
|
|
1
|
+
# chocola
|
|
2
|
+
|
|
3
|
+
Chocola is a JavaScript library for creating web user interfaces.
|
|
4
|
+
|
|
5
|
+
`chocola` only contains the functionality to build and serve web static builds. For production you may want to implement `chocola` to your workflow with other frameworks until official workflows are provided.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<!-- Greeting.html -->
|
|
11
|
+
<script>
|
|
12
|
+
let self = new HTMLDivElement;
|
|
13
|
+
let input = new HTMLInputElement;
|
|
14
|
+
|
|
15
|
+
export let title = "Hello";
|
|
16
|
+
|
|
17
|
+
function $runtime() {
|
|
18
|
+
input.focus();
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<div>
|
|
24
|
+
<h1>{title}</h1>
|
|
25
|
+
<input bind:self="input" type="text" placeholder="Your name">
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<style>
|
|
30
|
+
h1 { color: chocolate; }
|
|
31
|
+
</style>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Documentation
|
|
35
|
+
|
|
36
|
+
See https://github.com/chocolajs/chocola/wiki/Overview
|
|
@@ -0,0 +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;
|