lightview 1.7.2-b → 1.8.2
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 +15 -16
- package/docs/CNAME +1 -0
- package/docs/api.html +674 -0
- package/docs/blank.html +10 -0
- package/docs/comparedto.html +89 -0
- package/docs/components/chart-repl.html +69 -0
- package/docs/components/chart.html +17 -0
- package/{components → docs/components}/components.js +31 -11
- package/docs/components/contents.html +17 -0
- package/docs/components/gantt-repl.html +61 -0
- package/docs/components/gantt.html +42 -0
- package/docs/components/gauge-repl.html +66 -0
- package/docs/components/gauge.html +20 -0
- package/docs/components/orgchart-repl.html +64 -0
- package/docs/components/orgchart.html +41 -0
- package/docs/components/repl-as-src.html +17 -0
- package/docs/components/repl-repl.html +95 -0
- package/docs/components/repl.html +527 -0
- package/docs/components/timeline-repl.html +72 -0
- package/docs/components/timeline.html +44 -0
- package/docs/components.html +14 -0
- package/docs/css/highlightjs.min.css +9 -0
- package/docs/css/tutorial.css +35 -0
- package/docs/examples/anchor.html +11 -0
- package/{components/chart/example.html → docs/examples/chart.html} +6 -4
- package/docs/examples/counter.html +26 -0
- package/{examples → docs/examples}/counter.test.mjs +0 -0
- package/docs/examples/counter2.html +26 -0
- package/{examples → docs/examples}/directives.html +20 -18
- package/{examples → docs/examples}/foreign.html +1 -1
- package/docs/examples/forgeinform.html +98 -0
- package/docs/examples/form.html +61 -0
- package/{examples → docs/examples}/gauge.html +4 -2
- package/{examples → docs/examples}/invalid-template-literals.html +6 -4
- package/{examples → docs/examples}/medium/remote.html +1 -1
- package/docs/examples/message.html +18 -0
- package/{examples → docs/examples}/nested.html +2 -2
- package/docs/examples/object-bound-form.html +34 -0
- package/{examples → docs/examples}/remote-server.js +0 -0
- package/docs/examples/remote.html +34 -0
- package/{examples → docs/examples}/remote.json +0 -0
- package/{examples → docs/examples}/scratch.html +1 -1
- package/docs/examples/sensors/index.html +44 -0
- package/{examples → docs/examples}/sensors/sensor-server.js +0 -0
- package/docs/examples/shared.html +41 -0
- package/{examples → docs/examples}/template.html +1 -1
- package/{examples → docs/examples}/timeline.html +2 -2
- package/docs/examples/todo.html +40 -0
- package/docs/examples/top.html +10 -0
- package/{examples → docs/examples}/types.html +1 -1
- package/{examples → docs/examples}/xor.html +22 -20
- package/docs/examples.html +25 -0
- package/docs/index.html +44 -0
- package/docs/javascript/codejar.min.js +8 -0
- package/docs/javascript/highlightjs.min.js +1173 -0
- package/docs/javascript/isomorphic-git.js +9 -0
- package/docs/javascript/json5.min.js +1 -0
- package/docs/javascript/lightning-fs.js +1 -0
- package/docs/javascript/lightview.js +1285 -0
- package/docs/javascript/marked.min.js +6 -0
- package/docs/javascript/peerjs.min.js +70 -0
- package/docs/javascript/turndown.js +973 -0
- package/docs/javascript/types.js +606 -0
- package/docs/javascript/utils.js +45 -0
- package/docs/lightview.html +63 -0
- package/docs/old_index.html +965 -0
- package/docs/old_index.md +1132 -0
- package/docs/slidein.html +51 -0
- package/docs/tutorial/0-getting-started.html +67 -0
- package/docs/tutorial/1-intro-to-variables.html +103 -0
- package/docs/tutorial/10-template-components.html +80 -0
- package/docs/tutorial/11-linked-components.html +76 -0
- package/docs/tutorial/12-imported-components.html +67 -0
- package/docs/tutorial/13-input-binding.html +94 -0
- package/docs/tutorial/14-automatic-variable-creation.html +74 -0
- package/docs/tutorial/15-form-binding.html +110 -0
- package/docs/tutorial/16-if-directive.html +60 -0
- package/docs/tutorial/17-loop-directives.html +83 -0
- package/docs/tutorial/18-sanitizing-and-escaping-input.html +79 -0
- package/docs/tutorial/2-imported-and-exported-variables.html +80 -0
- package/docs/tutorial/3-data-types.html +89 -0
- package/docs/tutorial/4-extended-data-types.html +83 -0
- package/docs/tutorial/5-extended-functional-types.html +96 -0
- package/docs/tutorial/5.1-extended-functional-types.html +79 -0
- package/docs/tutorial/5.2-extended-functional-types.html +70 -0
- package/docs/tutorial/6-conventional-javascript.html +75 -0
- package/docs/tutorial/7-monitoring-with-observers.html +107 -0
- package/docs/tutorial/8-event-listeners.html +65 -0
- package/docs/tutorial/9-intro-to-components.html +91 -0
- package/docs/tutorial/contents.html +32 -0
- package/docs/tutorial/my-component.html +29 -0
- package/docs/tutorial/remote-value.json +4 -0
- package/docs/websiterepl.html +46 -0
- package/lightview.js +499 -363
- package/lightview.min.js +1 -0
- package/lightview_good.js +1267 -0
- package/lightview_optimized.js +1274 -0
- package/package.json +7 -2
- package/repl_hold.html +320 -0
- package/test/basic.html +29 -17
- package/test/basic.test.mjs +1 -11
- package/test/extended.html +16 -19
- package/types.js +118 -36
- package/unsplash.key +1 -0
- package/components/chart/chart.html +0 -15
- package/components/chart.html +0 -81
- package/components/gantt/example.html +0 -27
- package/components/gantt/gantt.html +0 -34
- package/components/gauge/example.html +0 -28
- package/components/gauge/guage.html +0 -19
- package/components/gauge.html +0 -57
- package/components/timeline.html +0 -81
- package/examples/chart.html +0 -66
- package/examples/counter.html +0 -24
- package/examples/forgeinform.html +0 -96
- package/examples/form.html +0 -59
- package/examples/message.html +0 -12
- package/examples/object-bound-form.html +0 -32
- package/examples/remote.html +0 -32
- package/examples/sensors/index.html +0 -30
- package/examples/todo.html +0 -38
- package/examples/top.html +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lightview",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"description": "Small, simple, powerful web UI and micro front end creation ... Great ideas from Svelte, React, Vue and Riot combined.",
|
|
5
5
|
"main": "lightview.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,9 +28,14 @@
|
|
|
28
28
|
"bugs": {
|
|
29
29
|
"url": "https://github.com/anywhichway/lightview/issues"
|
|
30
30
|
},
|
|
31
|
-
"homepage": "https://
|
|
31
|
+
"homepage": "https://lightview.dev",
|
|
32
32
|
"devDependencies": {
|
|
33
|
+
"@editorjs/editorjs": "^2.16.0",
|
|
34
|
+
"editorjs-inline-tool": "^0.4.0",
|
|
33
35
|
"jest": "^27.5.1",
|
|
34
36
|
"jest-puppeteer": "^6.1.0"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"froala-editor": "^4.0.11"
|
|
35
40
|
}
|
|
36
41
|
}
|
package/repl_hold.html
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Lightview:REPL</title>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/styles/default.min.css">
|
|
9
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
|
10
|
+
<div id="content" style="flex:auto;min-height:100%;width:750px;max-width:750px;height:100%;border:1px solid;padding:10px;margin:0 auto">
|
|
11
|
+
<div style="display:flex;flex-direction:column;">
|
|
12
|
+
<div id="tabs" style="flex-grow:0;width:100%;border:1px;padding-bottom:5px;text-align:center">
|
|
13
|
+
<span style="padding-right:10px"><label for="headhtml" l-on:click="${onTabClick}">HTML Head</label><input for="headhtml" value="${headhtmlPinned}" type="checkbox" l-on:click="${onPinClick}"></span>
|
|
14
|
+
<span style="padding-right:10px"><label for="bodyhtml" l-on:click="${onTabClick}">HTML Body</label><input for="bodyhtml" value="${bodyhtmlPinned}" type="checkbox" l-on:click="${onPinClick}" checked></span>
|
|
15
|
+
<!--span style="padding-right:10px"><label for="markdown" l-on:click="${onTabClick}">Markdown (Body)</label><input for="markdown" value="${markdownPinned}" type="checkbox" l-on:click="${onPinClick}"></span-->
|
|
16
|
+
<span style="padding-right:10px"><label for="css" l-on:click="${onTabClick}">Style</label><input for="css" value="${cssPinned}" type="checkbox" l-on:click="${onPinClick}"></span>
|
|
17
|
+
<span style="padding-right:10px"><label for="script" l-on:click="${onTabClick}">Script</label><input for="script" value="${scriptPinned}" type="checkbox" l-on:click="${onPinClick}"></span>
|
|
18
|
+
<span style="padding-right:10px"><label for="preview" l-on:click="${onTabClick}">Preview</label><input for="preview" value="${previewPinned}" type="checkbox" l-on:click="${onPinClick}"></span>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
<div id="headhtml" style="display:none;margin:10px" class="language-html"><head><slot name="head"></slot></head></div>
|
|
22
|
+
<div id="bodyhtml" style="margin:10px" class="language-html"><body><slot name="body"></slot></body></div>
|
|
23
|
+
<!--textarea id="markdown" style="margin-right:2px;display:none">${markdown}</textarea-->
|
|
24
|
+
<div id="css" style="display:none;margin:10px" class="language-css"><style><slot name="css"></slot></style></div>
|
|
25
|
+
<div id="script" style="display:none;margin:10px" class="language-javascript"><script><slot name="script"></slot></script></div>
|
|
26
|
+
<iframe id="preview" style="max-width:99%;width:99%;margin:10px;display:none" src="./blank.html"></iframe>
|
|
27
|
+
</div>
|
|
28
|
+
<div style="width:100%;text-align:center">
|
|
29
|
+
<div style="padding:5px">${source}</div>
|
|
30
|
+
<button l-on:click="${doSave}">Save</button>
|
|
31
|
+
<button l-if="${!source.trim().startsWith('http')}" l-on:click="${doReset}">Reset</button>
|
|
32
|
+
</div>
|
|
33
|
+
<style id="style">
|
|
34
|
+
label:hover {
|
|
35
|
+
text-decoration: underline
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
38
|
+
<script id="lightview">
|
|
39
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
40
|
+
const {CodeJar} = await import("https://cdn.jsdelivr.net/npm/codejar@3.6.0/codejar.min.js");
|
|
41
|
+
const turndownService = new TurndownService({
|
|
42
|
+
headingStyle: "atx",
|
|
43
|
+
codeBlockStyle: "fenced",
|
|
44
|
+
emDelimiter: "*"
|
|
45
|
+
});
|
|
46
|
+
turndownService.keep(() => true);
|
|
47
|
+
|
|
48
|
+
const {html, css, script} = await import("../types.js");
|
|
49
|
+
self.variables({
|
|
50
|
+
onTabClick: "function",
|
|
51
|
+
onPinClick: "function",
|
|
52
|
+
doSave: "function",
|
|
53
|
+
doReset: "function"
|
|
54
|
+
});
|
|
55
|
+
self.variables({
|
|
56
|
+
wysiwygPinned: "boolean",
|
|
57
|
+
bodyhtmlPinned: "boolean",
|
|
58
|
+
bodyhtml: html,
|
|
59
|
+
markdownPinned: "boolean",
|
|
60
|
+
markdown: "string",
|
|
61
|
+
cssPinned: "boolean",
|
|
62
|
+
cssText: css,
|
|
63
|
+
scriptPinned: "boolean",
|
|
64
|
+
scriptText: script,
|
|
65
|
+
headhtmlPinned: "boolean",
|
|
66
|
+
headhtml: html,
|
|
67
|
+
previewPinned: "boolean",
|
|
68
|
+
source: "string",
|
|
69
|
+
}, {reactive});
|
|
70
|
+
self.variables({
|
|
71
|
+
src: "string",
|
|
72
|
+
}, {imported});
|
|
73
|
+
|
|
74
|
+
bodyhtmlPinned = true;
|
|
75
|
+
|
|
76
|
+
const loadFromFile = async () => {
|
|
77
|
+
const html = await fs.readFile(url.pathname, {encoding: "utf8"});
|
|
78
|
+
source = `IndexedDB://${url.hostname + "_repl"}${url.pathname}`;
|
|
79
|
+
return html;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const loadFromServer = async () => {
|
|
83
|
+
const response = await fetch(url.href);
|
|
84
|
+
const html = await response.text();
|
|
85
|
+
source = url.href;
|
|
86
|
+
return html;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const parseFullHTML = (fullHTML) => {
|
|
90
|
+
const parser = new DOMParser(),
|
|
91
|
+
fragment = parser.parseFromString(fullHTML, "text/html"),
|
|
92
|
+
body_el = fragment?.querySelector("body"),
|
|
93
|
+
style_el = fragment?.querySelector("style"),
|
|
94
|
+
script_el = body_el?.querySelector("script");
|
|
95
|
+
if (style_el) {
|
|
96
|
+
cssText = style_el?.innerHTML.trim();
|
|
97
|
+
style_el.remove();
|
|
98
|
+
} else {
|
|
99
|
+
cssText = "";
|
|
100
|
+
}
|
|
101
|
+
if (script_el) {
|
|
102
|
+
scriptText = script_el?.innerHTML.trim(),
|
|
103
|
+
script_el.remove();
|
|
104
|
+
} else {
|
|
105
|
+
scriptText = "";
|
|
106
|
+
}
|
|
107
|
+
headhtml = (fragment?.head.innerHTML || "").trim();
|
|
108
|
+
bodyhtml = body_el?.innerHTML.trim();
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
let fs,
|
|
112
|
+
url;
|
|
113
|
+
if (src) {
|
|
114
|
+
url = new URL(src, window.location.href);
|
|
115
|
+
fs = new LightningFS(url.hostname + "_repl").promises;
|
|
116
|
+
try {
|
|
117
|
+
parseFullHTML(await loadFromFile());
|
|
118
|
+
} catch (e) {
|
|
119
|
+
try {
|
|
120
|
+
parseFullHTML(await loadFromServer());
|
|
121
|
+
} catch (e) {
|
|
122
|
+
fullHTML = e.message;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
url = new URL(window.location.href);
|
|
127
|
+
fs = new LightningFS(url.hostname + "_repl").promises;
|
|
128
|
+
bodyhtml = "";
|
|
129
|
+
headhtml = "";
|
|
130
|
+
scriptText = "";
|
|
131
|
+
cssText = "";
|
|
132
|
+
}
|
|
133
|
+
;
|
|
134
|
+
|
|
135
|
+
// initialize variables
|
|
136
|
+
markdown = "";
|
|
137
|
+
|
|
138
|
+
const tabs = [...self.querySelectorAll("label[for]")]
|
|
139
|
+
.map((label) => {
|
|
140
|
+
const id = label.getAttribute("for");
|
|
141
|
+
return [id, self.getElementById(id), label];
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const showTab = (targetid) => {
|
|
145
|
+
tabs.forEach(([id, el, label]) => {
|
|
146
|
+
if (id === targetid || self.varsProxy[`${id}Pinned`]) {
|
|
147
|
+
el.style.display = "block";
|
|
148
|
+
} else if (!self.varsProxy[`${id}Pinned`]) {
|
|
149
|
+
el.style.display = "none";
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const hideTab = (targetid) => {
|
|
155
|
+
tabs.forEach(([id, el, label]) => {
|
|
156
|
+
if (id === targetid) el.style.display = "none";
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
onTabClick = (event) => {
|
|
161
|
+
showTab(event.target.getAttribute("for"));
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
onPinClick = (event) => {
|
|
165
|
+
const id = event.target.getAttribute("for"),
|
|
166
|
+
checked = self.varsProxy[`${id}Pinned`] = event.target.checked;
|
|
167
|
+
if (checked) onTabClick(event);
|
|
168
|
+
else hideTab(id);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
doSave = async () => {
|
|
172
|
+
const parts = url.pathname.split("/");
|
|
173
|
+
let dir = "";
|
|
174
|
+
parts.shift();
|
|
175
|
+
parts.pop();
|
|
176
|
+
for (const part of parts) {
|
|
177
|
+
dir = dir + "/" + part;
|
|
178
|
+
try {
|
|
179
|
+
await fs.mkdir(dir);
|
|
180
|
+
} catch (e) {
|
|
181
|
+
if (e.message === "EEXIST") break;
|
|
182
|
+
throw e;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
fs.writeFile(url.pathname, doPreview(), {encoding: "utf8"}, () => {
|
|
186
|
+
});
|
|
187
|
+
source = `IndexedDB://${url.hostname + "_repl"}${url.pathname}`;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
doReset = async () => {
|
|
191
|
+
try {
|
|
192
|
+
await fs.unlink(url.pathname);
|
|
193
|
+
} catch (e) {
|
|
194
|
+
|
|
195
|
+
}
|
|
196
|
+
if (src) {
|
|
197
|
+
try {
|
|
198
|
+
parseFullHTML(await loadFromServer());
|
|
199
|
+
doPreview();
|
|
200
|
+
} catch (e) {
|
|
201
|
+
previewEl.innerHTML = fullHTML = e.message;
|
|
202
|
+
}
|
|
203
|
+
} else {
|
|
204
|
+
bodyhtml = "";
|
|
205
|
+
headhtml = "";
|
|
206
|
+
scriptText = "";
|
|
207
|
+
cssText = "";
|
|
208
|
+
previewEl.innerHTML = "";
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
const doPreview = () => {
|
|
213
|
+
// not quite write, createComponent needs to be reworked to handle a head and import its links
|
|
214
|
+
/*const template = document.createElement("template");
|
|
215
|
+
template.innerHTML = bodyhtml +
|
|
216
|
+
"<style>" + cssText + "</style>" +
|
|
217
|
+
'<script id="lightview">' + scriptText + "<" + "/script>";
|
|
218
|
+
const component = window.customElements.get("x-preview");
|
|
219
|
+
if (component) {
|
|
220
|
+
component.setTemplateNode(template);
|
|
221
|
+
} else {
|
|
222
|
+
Lightview.createComponent("x-preview", template);
|
|
223
|
+
}
|
|
224
|
+
previewEl.innerHTML = "<x-preview></x-preview>";
|
|
225
|
+
return "<html><head>" + headhtml + "</head><body>" + template.innerHTML + "<body></html>"*/
|
|
226
|
+
const str =
|
|
227
|
+
"<html>" +
|
|
228
|
+
"<head>" + headhtml.replace("./lightview.js",new URL("./lightview.js",window.location.href).href) +" </head>" +
|
|
229
|
+
"<body>" + bodyhtml +
|
|
230
|
+
"<style>" + cssText + "</style>" +
|
|
231
|
+
'<script id="lightview">debugger;' + scriptText + "<" + "/script>" +
|
|
232
|
+
"</body>" +
|
|
233
|
+
"</html>",
|
|
234
|
+
blob = new Blob([str], {type : 'text/html'}),
|
|
235
|
+
newurl = window.URL.createObjectURL(blob);
|
|
236
|
+
previewEl.src = newurl;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const tabsEl = self.getElementById("tabs"),
|
|
240
|
+
headhtmlEl = document.body.querySelector('[slot="head"]'),
|
|
241
|
+
bodyhtmlEl = document.body.querySelector('[slot="body"]'),
|
|
242
|
+
markdownEl = self.getElementById("markdown"),
|
|
243
|
+
cssEl = document.body.querySelector('[slot="css"]'),
|
|
244
|
+
scriptEl = document.body.querySelector('[slot="script"]'),
|
|
245
|
+
previewEl = self.getElementById("preview");
|
|
246
|
+
|
|
247
|
+
const highlight = (el,...args) => {
|
|
248
|
+
hljs.highlightElement(el,...args);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if(headhtmlEl) {
|
|
252
|
+
headhtmlEl.className = "language-html";
|
|
253
|
+
const bodyJar = CodeJar(headhtmlEl, highlight);
|
|
254
|
+
bodyJar.updateCode(headhtml);
|
|
255
|
+
bodyJar.onUpdate(code => {
|
|
256
|
+
headhtml = code;
|
|
257
|
+
doPreview();
|
|
258
|
+
})
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if(bodyhtmlEl) {
|
|
262
|
+
bodyhtmlEl.className = "language-html";
|
|
263
|
+
const bodyJar = CodeJar(bodyhtmlEl, highlight);
|
|
264
|
+
bodyJar.updateCode(bodyhtml);
|
|
265
|
+
bodyJar.onUpdate(code => {
|
|
266
|
+
bodyhtml = code;
|
|
267
|
+
doPreview();
|
|
268
|
+
})
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if(cssEl) {
|
|
272
|
+
cssEl.className = "language-css";
|
|
273
|
+
const bodyJar = CodeJar(cssEl, highlight);
|
|
274
|
+
bodyJar.updateCode(cssText);
|
|
275
|
+
bodyJar.onUpdate(code => {
|
|
276
|
+
cssText = code;
|
|
277
|
+
doPreview();
|
|
278
|
+
})
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if(scriptEl) {
|
|
282
|
+
scriptEl.className = "language-javascript";
|
|
283
|
+
const bodyJar = CodeJar(scriptEl, highlight);
|
|
284
|
+
bodyJar.updateCode(scriptText);
|
|
285
|
+
bodyJar.onUpdate(code => {
|
|
286
|
+
scriptText = code;
|
|
287
|
+
doPreview();
|
|
288
|
+
})
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
doPreview();
|
|
292
|
+
|
|
293
|
+
/*let prevmarkdown; // prevents indirect recursion
|
|
294
|
+
observe(() => {
|
|
295
|
+
const text = turndownService.turndown(bodyhtml).trim();
|
|
296
|
+
if (text && text !== prevtext) {
|
|
297
|
+
markdown = markdownEl.innerHTML = prevmarkdown = text;
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
let prevbodyhtml; // prevents indirect recursion
|
|
302
|
+
observe(() => {
|
|
303
|
+
const html = marked.parse(markdown).trim();
|
|
304
|
+
if (html && html !== prevbodyhtml) {
|
|
305
|
+
bodyhtml = bodyhtmlEl.innerText = prevbodyhtml = html;
|
|
306
|
+
}
|
|
307
|
+
});*/
|
|
308
|
+
|
|
309
|
+
const initEditor = () => {
|
|
310
|
+
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
self.addEventListener("mounted", () => {
|
|
314
|
+
initEditor();
|
|
315
|
+
doPreview();
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
</script>
|
|
319
|
+
</body>
|
|
320
|
+
</html>
|
package/test/basic.html
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
<title>Basic</title>
|
|
6
6
|
<template id="x-test" name="joe" open="true" count=1 children='["mary"]' l-on:click="${bump}">
|
|
7
7
|
|
|
8
|
-
<
|
|
9
|
-
|
|
8
|
+
<input id="iuntyped" value="${iuntyped}">
|
|
10
9
|
<input id="idatetime" type="datetime" value="${idatetime}">
|
|
11
10
|
|
|
11
|
+
<span id="children">${children}</span>
|
|
12
|
+
|
|
12
13
|
<span id="name">${name}</span>
|
|
13
14
|
<span id="open">${open}</span>
|
|
14
15
|
<span id="count">${count}</span>
|
|
@@ -18,7 +19,7 @@
|
|
|
18
19
|
<span id="age">${age}</span>
|
|
19
20
|
<span id="hamburger">${hamburger}</span>
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
|
|
22
23
|
<input id="itext" type="text" value="${itext}">
|
|
23
24
|
<input id="itel" type="tel" value="${itel}">
|
|
24
25
|
<input id="iemail" type="email" value="${iemail}">
|
|
@@ -32,16 +33,26 @@
|
|
|
32
33
|
<input id="inumber" type="number" value="${inumber}">
|
|
33
34
|
<input id="irange" type="range" value="${irange}">
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
36
|
<input id="icheckbox" type="checkbox" value="${icheckbox}">
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
self.variables(
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
</template>
|
|
38
|
+
<script>
|
|
39
|
+
document.getElementById("x-test").mount = async (self) => {
|
|
40
|
+
// debugger;
|
|
41
|
+
self.variables(
|
|
42
|
+
{
|
|
43
|
+
shared:"function"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
constant: (await import("../types.js")).shared
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
self.variables({name: "string", open: "boolean", count: "number", children: Array}, {imported, reactive});
|
|
50
|
+
self.variables({color: "string", checked: "boolean", age: "number", hamburger: Array}, {
|
|
51
|
+
exported,
|
|
52
|
+
reactive
|
|
53
|
+
});
|
|
54
|
+
self.variables({counter: "number"}, {reactive});
|
|
55
|
+
self.variables({myshare: "number"}, {shared});
|
|
45
56
|
|
|
46
57
|
color = "green";
|
|
47
58
|
checked = true;
|
|
@@ -50,7 +61,8 @@
|
|
|
50
61
|
counter = 0;
|
|
51
62
|
myshare = 1;
|
|
52
63
|
|
|
53
|
-
self.addEventListener("
|
|
64
|
+
self.addEventListener("mounted", ({target}) => {
|
|
65
|
+
debugger;
|
|
54
66
|
iuntyped = "test";
|
|
55
67
|
itext = "test";
|
|
56
68
|
itel = "test";
|
|
@@ -63,7 +75,6 @@
|
|
|
63
75
|
|
|
64
76
|
inumber = 1;
|
|
65
77
|
irange = 1;
|
|
66
|
-
|
|
67
78
|
idatetime = new Date();
|
|
68
79
|
|
|
69
80
|
icheckbox = true;
|
|
@@ -74,13 +85,14 @@
|
|
|
74
85
|
counter++;
|
|
75
86
|
};
|
|
76
87
|
|
|
77
|
-
addEventListener("change",({variableName,value}) => {
|
|
88
|
+
addEventListener("change", ({variableName, value}) => {
|
|
78
89
|
self[variableName] = value;
|
|
79
90
|
});
|
|
80
|
-
|
|
81
|
-
</
|
|
91
|
+
}
|
|
92
|
+
</script>
|
|
82
93
|
<script src="../lightview.js"></script>
|
|
83
94
|
<script>
|
|
95
|
+
Lightview.createInputVariables = true;
|
|
84
96
|
Lightview.createComponent("x-test",document.getElementById("x-test"));
|
|
85
97
|
</script>
|
|
86
98
|
</head>
|
package/test/basic.test.mjs
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import 'expect-puppeteer';
|
|
2
2
|
|
|
3
|
-
describe('Google', () => {
|
|
4
|
-
beforeAll(async () => {
|
|
5
|
-
await page.goto('https://google.com');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
test('should be titled "Google"', async () => {
|
|
9
|
-
await expect(page.title()).resolves.toMatch('Google');
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
|
|
13
3
|
describe('Lightview - Variables', () => {
|
|
14
4
|
beforeAll(async () => {
|
|
15
5
|
await page.goto('http://localhost:8080/test/basic.html');
|
|
@@ -174,7 +164,7 @@ describe('Lightview - Variables', () => {
|
|
|
174
164
|
});
|
|
175
165
|
|
|
176
166
|
test('untyped input - iuntyped should be "test"', async () => {
|
|
177
|
-
const result = await page.evaluate(
|
|
167
|
+
const result = await page.evaluate(() => {
|
|
178
168
|
const el = document.getElementById("test"),
|
|
179
169
|
result = el.getElementById("iuntyped")
|
|
180
170
|
return result.getAttribute("value");
|
package/test/extended.html
CHANGED
|
@@ -6,27 +6,24 @@
|
|
|
6
6
|
<script src="../lightview.js?as=x-body"></script>
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
9
|
-
<script
|
|
10
|
-
|
|
9
|
+
<script>
|
|
10
|
+
document.body.mount = async (self) => {
|
|
11
|
+
const {array,boolean,number,object,string} = await import("../types.js");
|
|
11
12
|
|
|
12
|
-
self.variables({strictarray:array},{set:[]});
|
|
13
|
-
self.variables({strictboolean:boolean},{set:true});
|
|
14
|
-
self.variables({strictnumber:number},{set:0});
|
|
15
|
-
self.variables({strictobject:object},{set:{}});
|
|
16
|
-
self.variables({strictstring:string},{set:"test"});
|
|
17
|
-
self.variables({extendedarray:array({required:true,minlength:2,maxlength:3})});
|
|
18
|
-
self.variables({extendedboolean:boolean({required:true})});
|
|
19
|
-
self.variables({extendednumber:number({required:true,min:1,max:4,step:2,allowNaN:false})});
|
|
20
|
-
self.variables({extendedobject:object({required:true})});
|
|
21
|
-
self.variables({extendedstring:string({required:true,minlength:2,maxlength:4})});
|
|
22
|
-
|
|
23
|
-
self.variables({allowNaNnumber:number({min:null,max:null,step:null})});
|
|
24
|
-
self.variables({noNaNnumber:number({allowNaN:false})});
|
|
25
|
-
|
|
26
|
-
//debugger;
|
|
27
|
-
//self.setVariableValue("extendedarray",[]);
|
|
28
|
-
//console.log(typeof(extendedarray),extendedarray);
|
|
13
|
+
self.variables({strictarray:array},{set:[]});
|
|
14
|
+
self.variables({strictboolean:boolean},{set:true});
|
|
15
|
+
self.variables({strictnumber:number},{set:0});
|
|
16
|
+
self.variables({strictobject:object},{set:{}});
|
|
17
|
+
self.variables({strictstring:string},{set:"test"});
|
|
18
|
+
self.variables({extendedarray:array({required:true,minlength:2,maxlength:3})});
|
|
19
|
+
self.variables({extendedboolean:boolean({required:true})});
|
|
20
|
+
self.variables({extendednumber:number({required:true,min:1,max:4,step:2,allowNaN:false})});
|
|
21
|
+
self.variables({extendedobject:object({required:true})});
|
|
22
|
+
self.variables({extendedstring:string({required:true,minlength:2,maxlength:4})});
|
|
29
23
|
|
|
24
|
+
self.variables({allowNaNnumber:number({min:null,max:null,step:null})});
|
|
25
|
+
self.variables({noNaNnumber:number({allowNaN:false})});
|
|
26
|
+
}
|
|
30
27
|
</script>
|
|
31
28
|
</body>
|
|
32
29
|
</html>
|