lightview 1.4.8-b → 1.6.2-b
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 +1 -1
- package/components/chart.html +76 -0
- package/components/gauge.html +57 -0
- package/examples/chart.html +64 -0
- package/examples/counter.html +3 -10
- package/examples/counter.test.mjs +47 -0
- package/examples/directives.html +2 -2
- package/examples/foreign.html +36 -0
- package/examples/{remoteform.html → forgeinform.html} +3 -3
- package/examples/form.html +9 -15
- package/examples/gauge.html +16 -0
- package/examples/invalid-template-literals.html +45 -0
- package/examples/message.html +1 -1
- package/examples/remote-server.js +51 -0
- package/examples/remote.html +24 -28
- package/examples/remote.json +1 -0
- package/examples/sensors/index.html +30 -0
- package/examples/sensors/sensor-server.js +30 -0
- package/examples/template.html +33 -0
- package/examples/types.html +93 -0
- package/examples/xor.html +3 -3
- package/lightview.js +238 -223
- package/package.json +36 -36
- package/test/basic.html +29 -20
- package/test/basic.test.mjs +98 -21
- package/types.js +445 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<title>Template</title>
|
|
6
|
+
<template id="local-component">
|
|
7
|
+
<p>
|
|
8
|
+
<button l-on:click="click">Click Me</button>
|
|
9
|
+
</p>
|
|
10
|
+
<p>
|
|
11
|
+
${message ? message : ""}
|
|
12
|
+
</p>
|
|
13
|
+
<script type="lightview/module">
|
|
14
|
+
self.variables({message: "string"}, {reactive});
|
|
15
|
+
|
|
16
|
+
self.click = (event) => {
|
|
17
|
+
message = "Hi there!";
|
|
18
|
+
};
|
|
19
|
+
</script>
|
|
20
|
+
</template>
|
|
21
|
+
<script src="../lightview.js"></script>
|
|
22
|
+
<script>
|
|
23
|
+
Lightview.createComponent("x-hello", document.getElementById("local-component"));
|
|
24
|
+
</script>
|
|
25
|
+
</head>
|
|
26
|
+
|
|
27
|
+
<body>
|
|
28
|
+
<div style="margin:20px">
|
|
29
|
+
<x-hello></x-hello>
|
|
30
|
+
</div>
|
|
31
|
+
</body>
|
|
32
|
+
|
|
33
|
+
</html>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<title>Types</title>
|
|
6
|
+
<script src="../lightview.js?as=x-body"></script>
|
|
7
|
+
</head>
|
|
8
|
+
|
|
9
|
+
<body>
|
|
10
|
+
<div style="margin:20px">
|
|
11
|
+
<p>
|
|
12
|
+
<button l-on:click="run">Run</button>
|
|
13
|
+
<button l-on:click="clear">Clear</button>
|
|
14
|
+
</p>
|
|
15
|
+
<p id="console"></p>
|
|
16
|
+
</div>
|
|
17
|
+
<script type="lightview/module">
|
|
18
|
+
const {string} = await import("../types.js");
|
|
19
|
+
self.run = () => {
|
|
20
|
+
self.variables({
|
|
21
|
+
err: Error,
|
|
22
|
+
astring: "string",
|
|
23
|
+
asdvancedstring: string({maxlength:10}),
|
|
24
|
+
aDate: Date,
|
|
25
|
+
});
|
|
26
|
+
try {
|
|
27
|
+
self.variables({
|
|
28
|
+
badvariable: string({maxlength:"10"}),
|
|
29
|
+
});
|
|
30
|
+
} catch(e) {
|
|
31
|
+
err = e;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
astring = "my string";
|
|
35
|
+
} catch (e) {
|
|
36
|
+
err = e;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
asdvancedstring = "my string";
|
|
40
|
+
} catch (e) {
|
|
41
|
+
err = e;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
asdvancedstring = "my long string";
|
|
45
|
+
} catch (e) {
|
|
46
|
+
err = e;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
astring = 1;
|
|
50
|
+
} catch (e) {
|
|
51
|
+
err = e;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
aDate = new Date();
|
|
55
|
+
} catch (e) {
|
|
56
|
+
err = e;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
aDate = 1;
|
|
60
|
+
} catch (e) {
|
|
61
|
+
err = e;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
err = 1;
|
|
65
|
+
} catch (e) {
|
|
66
|
+
err = e;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// demo instrumentation
|
|
71
|
+
self.clear = () => {
|
|
72
|
+
const cnsl = self.getElementById("console");
|
|
73
|
+
while (cnsl.lastChild) cnsl.lastChild.remove();
|
|
74
|
+
};
|
|
75
|
+
addEventListener("change", ({
|
|
76
|
+
variableName,
|
|
77
|
+
value
|
|
78
|
+
}) => {
|
|
79
|
+
const cnsl = self.getElementById("console");
|
|
80
|
+
if (cnsl) {
|
|
81
|
+
const message = document.createElement("div");
|
|
82
|
+
if (variableName === "err") {
|
|
83
|
+
message.innerHTML = `<b>></b> ${value}<br>`;
|
|
84
|
+
} else {
|
|
85
|
+
message.innerHTML = `<b>></b> ${variableName} = ${value}<br>`;
|
|
86
|
+
}
|
|
87
|
+
cnsl.appendChild(message);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
</script>
|
|
91
|
+
</body>
|
|
92
|
+
|
|
93
|
+
</html>
|
package/examples/xor.html
CHANGED
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
<script type="lightview/module">
|
|
11
11
|
self.variables({
|
|
12
|
-
run: boolean
|
|
12
|
+
run: "boolean"
|
|
13
13
|
},{reactive});
|
|
14
14
|
self.variables({
|
|
15
|
-
name: string
|
|
15
|
+
name: "string"
|
|
16
16
|
}, {
|
|
17
17
|
imported
|
|
18
18
|
});
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
}) => {
|
|
23
23
|
if (variableName === "run" && value === true) {
|
|
24
24
|
self.siblings.forEach((sibling) => {
|
|
25
|
-
sibling.
|
|
25
|
+
sibling.setVariableValue(variableName, false);
|
|
26
26
|
})
|
|
27
27
|
}
|
|
28
28
|
})
|