lego-dom 0.0.7 → 0.0.8
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/.github/workflows/deploy-docs.yml +56 -0
- package/LICENSE +21 -0
- package/README.md +122 -0
- package/docs/.vitepress/config.js +107 -0
- package/docs/.vitepress/dist/404.html +22 -0
- package/docs/.vitepress/dist/api/define.html +35 -0
- package/docs/.vitepress/dist/api/directives.html +32 -0
- package/docs/.vitepress/dist/api/globals.html +27 -0
- package/docs/.vitepress/dist/api/index.html +25 -0
- package/docs/.vitepress/dist/api/lifecycle.html +38 -0
- package/docs/.vitepress/dist/api/route.html +34 -0
- package/docs/.vitepress/dist/api/vite-plugin.html +37 -0
- package/docs/.vitepress/dist/assets/api_define.md.UA-ygUnQ.js +11 -0
- package/docs/.vitepress/dist/assets/api_define.md.UA-ygUnQ.lean.js +1 -0
- package/docs/.vitepress/dist/assets/api_directives.md.BV-D251p.js +8 -0
- package/docs/.vitepress/dist/assets/api_directives.md.BV-D251p.lean.js +1 -0
- package/docs/.vitepress/dist/assets/api_globals.md.DOjt7AV0.js +3 -0
- package/docs/.vitepress/dist/assets/api_globals.md.DOjt7AV0.lean.js +1 -0
- package/docs/.vitepress/dist/assets/api_index.md.OS6h01ct.js +1 -0
- package/docs/.vitepress/dist/assets/api_index.md.OS6h01ct.lean.js +1 -0
- package/docs/.vitepress/dist/assets/api_lifecycle.md.Ccm5xw6-.js +14 -0
- package/docs/.vitepress/dist/assets/api_lifecycle.md.Ccm5xw6-.lean.js +1 -0
- package/docs/.vitepress/dist/assets/api_route.md.CAHf_KNp.js +10 -0
- package/docs/.vitepress/dist/assets/api_route.md.CAHf_KNp.lean.js +1 -0
- package/docs/.vitepress/dist/assets/api_vite-plugin.md.DNn9VhL5.js +13 -0
- package/docs/.vitepress/dist/assets/api_vite-plugin.md.DNn9VhL5.lean.js +1 -0
- package/docs/.vitepress/dist/assets/app.BG5s3B0P.js +1 -0
- package/docs/.vitepress/dist/assets/chunks/@localSearchIndexroot.DQmuWC2Z.js +1 -0
- package/docs/.vitepress/dist/assets/chunks/VPLocalSearchBox.BO-PSxt1.js +9 -0
- package/docs/.vitepress/dist/assets/chunks/framework.B7OFBR9X.js +19 -0
- package/docs/.vitepress/dist/assets/chunks/theme.DA-iSa9B.js +2 -0
- package/docs/.vitepress/dist/assets/examples_form.md.B3stGKbu.js +34 -0
- package/docs/.vitepress/dist/assets/examples_form.md.B3stGKbu.lean.js +1 -0
- package/docs/.vitepress/dist/assets/examples_index.md.BDEG_D4J.js +30 -0
- package/docs/.vitepress/dist/assets/examples_index.md.BDEG_D4J.lean.js +1 -0
- package/docs/.vitepress/dist/assets/examples_routing.md.bqZ9DjDK.js +338 -0
- package/docs/.vitepress/dist/assets/examples_routing.md.bqZ9DjDK.lean.js +1 -0
- package/docs/.vitepress/dist/assets/examples_sfc-showcase.md.DLXaUiop.js +13 -0
- package/docs/.vitepress/dist/assets/examples_sfc-showcase.md.DLXaUiop.lean.js +1 -0
- package/docs/.vitepress/dist/assets/examples_todo-app.md.D5RhZoo5.js +297 -0
- package/docs/.vitepress/dist/assets/examples_todo-app.md.D5RhZoo5.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_cdn-usage.md.CAjf03Lr.js +182 -0
- package/docs/.vitepress/dist/assets/guide_cdn-usage.md.CAjf03Lr.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_components.md.BIFWF1Hc.js +174 -0
- package/docs/.vitepress/dist/assets/guide_components.md.BIFWF1Hc.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_contributing.md.BgbUN-Mr.js +1 -0
- package/docs/.vitepress/dist/assets/guide_contributing.md.BgbUN-Mr.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_directives.md.Bi3ynu1d.js +140 -0
- package/docs/.vitepress/dist/assets/guide_directives.md.Bi3ynu1d.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_getting-started.md.2Nr1lp2z.js +107 -0
- package/docs/.vitepress/dist/assets/guide_getting-started.md.2Nr1lp2z.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_index.md.GvZq_Yf2.js +2 -0
- package/docs/.vitepress/dist/assets/guide_index.md.GvZq_Yf2.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_lifecycle.md.B28j1OzS.js +304 -0
- package/docs/.vitepress/dist/assets/guide_lifecycle.md.B28j1OzS.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_quick-start.md.CNk3VGTF.js +33 -0
- package/docs/.vitepress/dist/assets/guide_quick-start.md.CNk3VGTF.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_reactivity.md.CVsaMaPv.js +135 -0
- package/docs/.vitepress/dist/assets/guide_reactivity.md.CVsaMaPv.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_routing.md.DSpDP25o.js +193 -0
- package/docs/.vitepress/dist/assets/guide_routing.md.DSpDP25o.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_sfc.md.CVUP66tS.js +187 -0
- package/docs/.vitepress/dist/assets/guide_sfc.md.CVUP66tS.lean.js +1 -0
- package/docs/.vitepress/dist/assets/guide_templating.md.BgCGe4aa.js +119 -0
- package/docs/.vitepress/dist/assets/guide_templating.md.BgCGe4aa.lean.js +1 -0
- package/docs/.vitepress/dist/assets/index.md.xV1taCED.js +23 -0
- package/docs/.vitepress/dist/assets/index.md.xV1taCED.lean.js +1 -0
- package/docs/.vitepress/dist/assets/inter-italic-cyrillic-ext.r48I6akx.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-cyrillic.By2_1cv3.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-greek-ext.1u6EdAuj.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-greek.DJ8dCoTZ.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-latin-ext.CN1xVJS-.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-latin.C2AdPX0b.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-italic-vietnamese.BSbpV94h.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-cyrillic-ext.BBPuwvHQ.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-cyrillic.C5lxZ8CY.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-greek-ext.CqjqNYQ-.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-greek.BBVDIX6e.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-latin-ext.4ZJIpNVo.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-latin.Di8DUHzh.woff2 +0 -0
- package/docs/.vitepress/dist/assets/inter-roman-vietnamese.BjW4sHH5.woff2 +0 -0
- package/docs/.vitepress/dist/assets/style.eycE2Jhw.css +1 -0
- package/docs/.vitepress/dist/examples/form.html +58 -0
- package/docs/.vitepress/dist/examples/index.html +368 -0
- package/docs/.vitepress/dist/examples/routing.html +362 -0
- package/docs/.vitepress/dist/examples/sfc-showcase.html +37 -0
- package/docs/.vitepress/dist/examples/todo-app.html +321 -0
- package/docs/.vitepress/dist/guide/cdn-usage.html +206 -0
- package/docs/.vitepress/dist/guide/components.html +198 -0
- package/docs/.vitepress/dist/guide/contributing.html +25 -0
- package/docs/.vitepress/dist/guide/directives.html +164 -0
- package/docs/.vitepress/dist/guide/getting-started.html +131 -0
- package/docs/.vitepress/dist/guide/index.html +26 -0
- package/docs/.vitepress/dist/guide/lifecycle.html +328 -0
- package/docs/.vitepress/dist/guide/quick-start.html +57 -0
- package/docs/.vitepress/dist/guide/reactivity.html +159 -0
- package/docs/.vitepress/dist/guide/routing.html +217 -0
- package/docs/.vitepress/dist/guide/sfc.html +211 -0
- package/docs/.vitepress/dist/guide/templating.html +143 -0
- package/docs/.vitepress/dist/hashmap.json +1 -0
- package/docs/.vitepress/dist/index.html +47 -0
- package/docs/.vitepress/dist/logo.svg +38 -0
- package/docs/.vitepress/dist/vp-icons.css +1 -0
- package/docs/api/define.md +31 -0
- package/docs/api/directives.md +42 -0
- package/docs/api/globals.md +29 -0
- package/docs/api/index.md +29 -0
- package/docs/api/lifecycle.md +40 -0
- package/docs/api/route.md +37 -0
- package/docs/api/vite-plugin.md +58 -0
- package/docs/examples/form.md +42 -0
- package/docs/examples/index.md +104 -0
- package/docs/examples/routing.md +409 -0
- package/docs/examples/sfc-showcase.md +34 -0
- package/docs/examples/todo-app.md +383 -0
- package/docs/guide/cdn-usage.md +320 -0
- package/docs/guide/components.md +394 -0
- package/docs/guide/contributing.md +32 -0
- package/docs/guide/directives.md +430 -0
- package/docs/guide/getting-started.md +233 -0
- package/docs/guide/index.md +88 -0
- package/docs/guide/lifecycle.md +493 -0
- package/docs/guide/quick-start.md +46 -0
- package/docs/guide/reactivity.md +394 -0
- package/docs/guide/routing.md +373 -0
- package/docs/guide/sfc.md +381 -0
- package/docs/guide/templating.md +383 -0
- package/docs/index.md +126 -0
- package/docs/public/logo.svg +38 -0
- package/examples/vite-app/README.md +71 -0
- package/examples/vite-app/index.html +45 -0
- package/examples/vite-app/package.json +16 -0
- package/examples/vite-app/src/components/greeting-card.lego +41 -0
- package/examples/vite-app/src/components/sample-component.lego +75 -0
- package/examples/vite-app/src/main.js +11 -0
- package/examples/vite-app/vite.config.js +16 -0
- package/examples.js +99 -0
- package/package.json +33 -5
- package/parse-lego.js +119 -0
- package/parse-lego.test.js +107 -0
- package/vite-plugin.js +133 -0
- package/.ignore/auto.html +0 -135
- package/.ignore/test.html +0 -73
package/.ignore/auto.html
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>Lego JS | Test Suite</title>
|
|
6
|
-
<script src="./main.js"></script>
|
|
7
|
-
<style>
|
|
8
|
-
body { font-family: system-ui; line-height: 1.5; padding: 2rem; background: #f4f4f9; }
|
|
9
|
-
.test-card { background: white; padding: 1rem; margin-bottom: 1rem; border-radius: 8px; border-left: 5px solid #ccc; shadow: 0 2px 4px rgba(0,0,0,0.1); }
|
|
10
|
-
.pass { border-left-color: #22c55e; }
|
|
11
|
-
.fail { border-left-color: #ef4444; background: #fee2e2; }
|
|
12
|
-
.hidden { display: none; }
|
|
13
|
-
h1 { color: #1e293b; }
|
|
14
|
-
.stats { margin-bottom: 2rem; font-weight: bold; }
|
|
15
|
-
</style>
|
|
16
|
-
</head>
|
|
17
|
-
<body>
|
|
18
|
-
|
|
19
|
-
<h1>Lego JS Test Runner</h1>
|
|
20
|
-
<div id="stats" class="stats">Running tests...</div>
|
|
21
|
-
<div id="test-results"></div>
|
|
22
|
-
|
|
23
|
-
<!-- Test Sandbox (Hidden) -->
|
|
24
|
-
<div id="sandbox" class="hidden"></div>
|
|
25
|
-
|
|
26
|
-
<!-- Test Templates -->
|
|
27
|
-
<template lego-block="test-basic">
|
|
28
|
-
<span id="output">{{text}}</span>
|
|
29
|
-
</template>
|
|
30
|
-
|
|
31
|
-
<template lego-block="test-events">
|
|
32
|
-
<button id="btn" @click="count++">Click</button>
|
|
33
|
-
<input id="input" @keyup="lastUsedKey = event.key">
|
|
34
|
-
<span id="display">{{count}}</span>
|
|
35
|
-
<span id="key-display">{{lastUsedKey}}</span>
|
|
36
|
-
</template>
|
|
37
|
-
|
|
38
|
-
<template lego-block="test-loops">
|
|
39
|
-
<div l-for="item in items">
|
|
40
|
-
<span class="item">{{item.name}}</span>
|
|
41
|
-
</div>
|
|
42
|
-
</template>
|
|
43
|
-
|
|
44
|
-
<script>
|
|
45
|
-
const resultsContainer = document.getElementById('test-results');
|
|
46
|
-
const sandbox = document.getElementById('sandbox');
|
|
47
|
-
const statsEl = document.getElementById('stats');
|
|
48
|
-
let passed = 0;
|
|
49
|
-
let failed = 0;
|
|
50
|
-
|
|
51
|
-
function assert(condition, message) {
|
|
52
|
-
const card = document.createElement('div');
|
|
53
|
-
card.className = 'test-card ' + (condition ? 'pass' : 'fail');
|
|
54
|
-
card.innerHTML = `<strong>${condition ? 'PASS' : 'FAIL'}</strong>: ${message}`;
|
|
55
|
-
resultsContainer.appendChild(card);
|
|
56
|
-
if (condition) passed++; else failed++;
|
|
57
|
-
updateStats();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function updateStats() {
|
|
61
|
-
statsEl.textContent = `Total: ${passed + failed} | Passed: ${passed} | Failed: ${failed}`;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async function wait(ms = 50) {
|
|
65
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// --- TEST SUITE ---
|
|
69
|
-
|
|
70
|
-
async function runTests() {
|
|
71
|
-
// 1. Basic Reactivity & Interpolation
|
|
72
|
-
const t1 = document.createElement('test-basic');
|
|
73
|
-
t1.setAttribute('l-studs', "{ text: 'Initial' }");
|
|
74
|
-
sandbox.appendChild(t1);
|
|
75
|
-
await wait();
|
|
76
|
-
|
|
77
|
-
const out1 = t1.shadowRoot.getElementById('output');
|
|
78
|
-
assert(out1.textContent === 'Initial', 'Initial text interpolation works');
|
|
79
|
-
|
|
80
|
-
t1._studs.text = 'Updated';
|
|
81
|
-
await wait(); // Wait for requestAnimationFrame batching
|
|
82
|
-
assert(out1.textContent === 'Updated', 'Reactive update reflects in DOM');
|
|
83
|
-
|
|
84
|
-
// 2. Dynamic Event Listeners (@click, @keyup)
|
|
85
|
-
const t2 = document.createElement('test-events');
|
|
86
|
-
t2.setAttribute('l-studs', "{ count: 0, lastUsedKey: '' }");
|
|
87
|
-
sandbox.appendChild(t2);
|
|
88
|
-
await wait();
|
|
89
|
-
|
|
90
|
-
const btn = t2.shadowRoot.getElementById('btn');
|
|
91
|
-
const display = t2.shadowRoot.getElementById('display');
|
|
92
|
-
btn.click();
|
|
93
|
-
await wait();
|
|
94
|
-
assert(display.textContent === '1', 'Universal @click listener works');
|
|
95
|
-
|
|
96
|
-
const input = t2.shadowRoot.getElementById('input');
|
|
97
|
-
const keyDisplay = t2.shadowRoot.getElementById('key-display');
|
|
98
|
-
input.dispatchEvent(new KeyboardEvent('keyup', { key: 'Enter' }));
|
|
99
|
-
await wait();
|
|
100
|
-
assert(keyDisplay.textContent === 'Enter', 'Universal @keyup listener works');
|
|
101
|
-
|
|
102
|
-
// 3. List Rendering (l-for)
|
|
103
|
-
const t3 = document.createElement('test-loops');
|
|
104
|
-
t3.setAttribute('l-studs', "{ items: [{name: 'A'}, {name: 'B'}] }");
|
|
105
|
-
sandbox.appendChild(t3);
|
|
106
|
-
await wait();
|
|
107
|
-
|
|
108
|
-
let items = t3.shadowRoot.querySelectorAll('.item');
|
|
109
|
-
assert(items.length === 2 && items[0].textContent === 'A', 'l-for renders initial list');
|
|
110
|
-
|
|
111
|
-
t3._studs.items.push({name: 'C'});
|
|
112
|
-
await wait();
|
|
113
|
-
items = t3.shadowRoot.querySelectorAll('.item');
|
|
114
|
-
assert(items.length === 3, 'l-for reactively handles array push');
|
|
115
|
-
|
|
116
|
-
// 4. Security: HTML Escaping
|
|
117
|
-
const t4 = document.createElement('test-basic');
|
|
118
|
-
t4.setAttribute('l-studs', "{ text: '<img src=x onerror=alert(1)>' }");
|
|
119
|
-
sandbox.appendChild(t4);
|
|
120
|
-
await wait();
|
|
121
|
-
const out4 = t4.shadowRoot.getElementById('output');
|
|
122
|
-
assert(out4.innerHTML.includes('<img'), 'HTML is properly escaped to prevent XSS');
|
|
123
|
-
|
|
124
|
-
// 5. Lego.define (Programmatic API)
|
|
125
|
-
Lego.define('js-comp', '<h1>JS Component</h1>');
|
|
126
|
-
const t5 = document.createElement('js-comp');
|
|
127
|
-
sandbox.appendChild(t5);
|
|
128
|
-
await wait();
|
|
129
|
-
assert(t5.shadowRoot.querySelector('h1').textContent === 'JS Component', 'Lego.define works programmatically');
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
window.onload = runTests;
|
|
133
|
-
</script>
|
|
134
|
-
</body>
|
|
135
|
-
</html>
|
package/.ignore/test.html
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
<html lang="en">
|
|
2
|
-
<head>
|
|
3
|
-
<meta charset="UTF-8">
|
|
4
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
5
|
-
<title>Lego JS Test</title>
|
|
6
|
-
<script src="./main.js"></script>
|
|
7
|
-
</head>
|
|
8
|
-
<body @todo-added="() => {console.log('Todo added!')}" >
|
|
9
|
-
<template b-id="todo-list">
|
|
10
|
-
<style>
|
|
11
|
-
:host { display: block; font-family: system-ui, sans-serif; padding: 20px; }
|
|
12
|
-
.done { text-decoration: line-through; color: #888; }
|
|
13
|
-
.input { padding: .4em; border: 1px solid #ccc; border-radius: 0.1em; }
|
|
14
|
-
.item-row { margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
|
|
15
|
-
button { cursor: pointer; border: none; padding: 5px 10px; border-radius: 0px; background-color: #404; color: #fff; }
|
|
16
|
-
h3 { color: #318d8d; margin-top: 0; }
|
|
17
|
-
</style>
|
|
18
|
-
|
|
19
|
-
<h3>{{title}}</h3>
|
|
20
|
-
<p>{{ items.filter(t => !t.done).length }} of {{ items.length }} items remaining</p>
|
|
21
|
-
<div style="margin-bottom: 20px;">
|
|
22
|
-
<input b-sync="newItem" placeholder="Add task..." class="input" @keydown="() => {
|
|
23
|
-
}">
|
|
24
|
-
<button @click="() => {
|
|
25
|
-
if(!newItem.trim()) return;
|
|
26
|
-
items.push({text: `${newItem} - ${items.length + 1} - ${$ancestors('user-card').name}`, done: false});
|
|
27
|
-
newItem = '';
|
|
28
|
-
$emit('todo-added', { item: newItem });
|
|
29
|
-
}">Add</button>
|
|
30
|
-
</div>
|
|
31
|
-
|
|
32
|
-
<div b-for="todo in items">
|
|
33
|
-
<div class="item-row {{todo.done ? 'done' : ''}}">
|
|
34
|
-
<input type="checkbox" b-sync="todo.done">
|
|
35
|
-
<span>{{todo.text}}</span>
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
</template>
|
|
39
|
-
|
|
40
|
-
<template b-id="user-card">
|
|
41
|
-
<style>
|
|
42
|
-
:host { display: block; font-family: system-ui, sans-serif; padding: 20px; border: 1px solid #ccc; border-radius: 8px; }
|
|
43
|
-
h3 { color: #62318d; margin-top: 0; }
|
|
44
|
-
</style>
|
|
45
|
-
|
|
46
|
-
<h3>{{name}}</h3>
|
|
47
|
-
<p>{{bio}}</p>
|
|
48
|
-
<slot></slot>
|
|
49
|
-
</template>
|
|
50
|
-
|
|
51
|
-
<user-card b-data="{
|
|
52
|
-
name: 'John Doe',
|
|
53
|
-
bio: 'Software Engineer'
|
|
54
|
-
}">
|
|
55
|
-
<p>Additional content here</p>
|
|
56
|
-
<todo-list b-data="{
|
|
57
|
-
title: 'Enterprise Todo List',
|
|
58
|
-
items: [{text: 'Fix b-for strikethrough', done: true}],
|
|
59
|
-
newItem: '',
|
|
60
|
-
mounted() {
|
|
61
|
-
console.log('THis lego block has been mounted!');
|
|
62
|
-
},
|
|
63
|
-
updated() {
|
|
64
|
-
console.log('This lego block has been updated!');
|
|
65
|
-
},
|
|
66
|
-
unmounted() {
|
|
67
|
-
console.log('This lego block has been unmounted!');
|
|
68
|
-
}
|
|
69
|
-
}">
|
|
70
|
-
</todo-list>
|
|
71
|
-
</user-card>
|
|
72
|
-
</body>
|
|
73
|
-
</html>
|