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/package.json CHANGED
@@ -1,36 +1,36 @@
1
- {
2
- "name": "lightview",
3
- "version": "1.4.8b",
4
- "description": "Small, simple, powerful web UI and micro front end creation ... Great ideas from Svelte, React, Vue and Riot combined.",
5
- "main": "lightview.js",
6
- "scripts": {
7
- "test": "set NODE_OPTIONS=--experimental-vm-modules && jest ./test"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/anywhichway/lightview.git"
12
- },
13
- "keywords": [
14
- "svelte",
15
- "react",
16
- "angular",
17
- "riot",
18
- "vue",
19
- "moon",
20
- "hyperapp",
21
- "hyperhtml",
22
- "micro front end",
23
- "custom elements",
24
- "web components"
25
- ],
26
- "author": "Simon Y. Blackwell",
27
- "license": "MIT",
28
- "bugs": {
29
- "url": "https://github.com/anywhichway/lightview/issues"
30
- },
31
- "homepage": "https://github.com/anywhichway/lightview#readme",
32
- "devDependencies": {
33
- "jest": "^27.5.1",
34
- "jest-puppeteer": "^6.1.0"
35
- }
36
- }
1
+ {
2
+ "name": "lightview",
3
+ "version": "1.6.2b",
4
+ "description": "Small, simple, powerful web UI and micro front end creation ... Great ideas from Svelte, React, Vue and Riot combined.",
5
+ "main": "lightview.js",
6
+ "scripts": {
7
+ "test": "set NODE_OPTIONS=--experimental-vm-modules && jest ./test"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/anywhichway/lightview.git"
12
+ },
13
+ "keywords": [
14
+ "svelte",
15
+ "react",
16
+ "angular",
17
+ "riot",
18
+ "vue",
19
+ "moon",
20
+ "hyperapp",
21
+ "hyperhtml",
22
+ "micro front end",
23
+ "custom elements",
24
+ "web components"
25
+ ],
26
+ "author": "Simon Y. Blackwell",
27
+ "license": "MIT",
28
+ "bugs": {
29
+ "url": "https://github.com/anywhichway/lightview/issues"
30
+ },
31
+ "homepage": "https://github.com/anywhichway/lightview#readme",
32
+ "devDependencies": {
33
+ "jest": "^27.5.1",
34
+ "jest-puppeteer": "^6.1.0"
35
+ }
36
+ }
package/test/basic.html CHANGED
@@ -4,6 +4,7 @@
4
4
  <meta charset="UTF-8">
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
  <span id="name">${name}</span>
8
9
  <span id="open">${open}</span>
9
10
  <span id="count">${count}</span>
@@ -18,8 +19,9 @@
18
19
  <input id="itel" type="tel" value="${itel}">
19
20
  <input id="iemail" type="email" value="${iemail}">
20
21
  <input id="iurl" type="url" value="${iurl}">
22
+ <input id="iradio" type="radio" name="iradio" value="test">
21
23
  <input id="isearch" type="search" value="${isearch}">
22
- <input id="iradio" type="radio" value="${iradio}">
24
+
23
25
  <input id="icolor" type="color" value="${icolor}">
24
26
  <input id="ipassword" type="password" value="${ipassword}">
25
27
 
@@ -31,11 +33,11 @@
31
33
  <input id="icheckbox" type="checkbox" value="${icheckbox}">
32
34
 
33
35
  <script type="lightview/module">
34
- debugger;
35
- self.variables({name:string,open:boolean,count:number,children:Array},{imported,reactive});
36
- self.variables({color:string,checked:boolean,age:number,hamburger:Array},{exported,reactive});
37
- self.variables({counter:number},{reactive});
38
- self.variables({myshare:number},{shared});
36
+ //debugger;
37
+ self.variables({name:"string",open:"boolean",count:"number",children:Array},{imported,reactive});
38
+ self.variables({color:"string",checked:"boolean",age:"number",hamburger:Array},{exported,reactive});
39
+ self.variables({counter:"number"},{reactive});
40
+ self.variables({myshare:"number"},{shared});
39
41
 
40
42
  color = "green";
41
43
  checked = true;
@@ -44,26 +46,33 @@
44
46
  counter = 0;
45
47
  myshare = 1;
46
48
 
47
- iuntyped = "test";
48
- itext = "test";
49
- itel = "test";
50
- iemail = "test";
51
- iurl = "test";
52
- isearch = "test";
53
- iradio = "test";
54
- icolor = "test";
55
- ipassword = "test";
49
+ addEventListener("connected", ({target}) => {
50
+ iuntyped = "test";
51
+ itext = "test";
52
+ itel = "test";
53
+ iemail = "test";
54
+ iurl = "test";
55
+ isearch = "test";
56
+ iradio = "test";
57
+ icolor = "test";
58
+ ipassword = "test";
56
59
 
57
- inumber = 1;
58
- irange = 1;
60
+ inumber = 1;
61
+ irange = 1;
59
62
 
60
- idatetime = new Date();
63
+ idatetime = new Date();
61
64
 
62
- icheckbox = true;
65
+ icheckbox = true;
66
+ target.testId = target.id;
67
+ });
63
68
 
64
69
  self.bump = () => {
65
70
  counter++;
66
- };
71
+ };
72
+
73
+ addEventListener("change",({variableName,value}) => {
74
+ self[variableName] = value;
75
+ });
67
76
  </script>
68
77
  </template>
69
78
  <script src="../lightview.js"></script>
@@ -10,7 +10,7 @@ describe('Google', () => {
10
10
  });
11
11
  });
12
12
 
13
- describe('Lightview', () => {
13
+ describe('Lightview - Variables', () => {
14
14
  beforeAll(async () => {
15
15
  await page.goto('http://localhost:8080/test/basic.html');
16
16
  });
@@ -22,7 +22,7 @@ describe('Lightview', () => {
22
22
  test('boolean - open should be imported', async () => {
23
23
  const result = await page.evaluate(() => {
24
24
  const el = document.getElementById("test");
25
- return JSON.parse(el.getValue("open"));
25
+ return JSON.parse(el.getVariableValue("open"));
26
26
  });
27
27
  expect(result).toBe(true);
28
28
  });
@@ -30,7 +30,7 @@ describe('Lightview', () => {
30
30
  test('number - count should be imported', async () => {
31
31
  const result = await page.evaluate(() => {
32
32
  const el = document.getElementById("test");
33
- return JSON.parse(el.getValue("count"));
33
+ return JSON.parse(el.getVariableValue("count"));
34
34
  });
35
35
  expect(result).toBe(1);
36
36
  });
@@ -38,7 +38,7 @@ describe('Lightview', () => {
38
38
  test('string - name should be imported', async () => {
39
39
  const result = await page.evaluate(() => {
40
40
  const el = document.getElementById("test");
41
- return el.getValue("name");
41
+ return el.getVariableValue("name");
42
42
  });
43
43
  expect(result).toBe("joe");
44
44
  });
@@ -46,7 +46,7 @@ describe('Lightview', () => {
46
46
  test('object - children should be imported', async () => {
47
47
  const result = await page.evaluate(() => {
48
48
  const el = document.getElementById("test");
49
- return el.getValue("children").toJSON();
49
+ return el.getVariableValue("children").toJSON();
50
50
  });
51
51
  expect(Array.isArray(result)).toBe(true);
52
52
  expect(result[0]).toBe("mary");
@@ -167,7 +167,7 @@ describe('Lightview', () => {
167
167
  const result = await page.evaluate(async () => {
168
168
  const el0 = document.getElementById("test"),
169
169
  el1 = document.getElementById("test1")
170
- return [el0.getValue("myshare"),el1.getValue("myshare")];
170
+ return [el0.getVariableValue("myshare"),el1.getVariableValue("myshare")];
171
171
  });
172
172
  expect(Array.isArray(result)).toBe(true);
173
173
  expect(result[0]).toBe(result[1]);
@@ -182,21 +182,78 @@ describe('Lightview', () => {
182
182
  expect(result).toBe("test");
183
183
  });
184
184
 
185
- // "tel", "email", "url", "search", "radio", "color", "password"
186
- ["text","tel","email", "url", "search", "radio", "color", "password"].forEach((type) => {
187
- const f = Function(`return async () => {
185
+
186
+ test('text input - itext should be test', async () => {
188
187
  const result = await page.evaluate(async () => {
189
188
  const el = document.getElementById("test"),
190
- result = el.getElementById("i${type}");
191
- return {value:result.getAttribute("value"),variable:el.vars["i${type}"]};
189
+ result = el.getElementById(`itext`);
190
+ return result.getAttribute("value");
192
191
  });
193
- const {value,variable} = result;
194
- expect(value).toBe("test");
195
- expect(variable.name).toBe("i${type}");
196
- expect(variable.type).toBe("string");
197
- expect(variable.value).toBe(value);
198
- }`)();
199
- test(`${type} input - i${type} should be "test"`,f);
192
+ expect(result).toBe("test");
193
+ });
194
+
195
+
196
+ test('tel input - itel should be test', async () => {
197
+ const result = await page.evaluate(async () => {
198
+ const el = document.getElementById("test"),
199
+ result = el.getElementById("itel");
200
+ return result.getAttribute("value");
201
+ });
202
+ expect(result).toBe("test");
203
+ });
204
+
205
+ test('email input - email should be test', async () => {
206
+ const result = await page.evaluate(async () => {
207
+ const el = document.getElementById("test"),
208
+ result = el.getElementById("iemail");
209
+ return result.getAttribute("value");
210
+ });
211
+ expect(result).toBe("test");
212
+ });
213
+
214
+ test('url input - url should be test', async () => {
215
+ const result = await page.evaluate(async () => {
216
+ const el = document.getElementById("test"),
217
+ result = el.getElementById("iurl");
218
+ return result.getAttribute("value");
219
+ });
220
+ expect(result).toBe("test");
221
+ });
222
+
223
+ test('search input - search should be test', async () => {
224
+ const result = await page.evaluate(async () => {
225
+ const el = document.getElementById("test"),
226
+ result = el.getElementById("isearch");
227
+ return result.getAttribute("value");
228
+ });
229
+ expect(result).toBe("test");
230
+ });
231
+
232
+ test('radio input - radio should be test', async () => {
233
+ const result = await page.evaluate(async () => {
234
+ const el = document.getElementById("test"),
235
+ result = el.getElementById("iradio");
236
+ return result.checked;
237
+ });
238
+ expect(result).toBe(true);
239
+ });
240
+
241
+ test('color input - color should be test', async () => {
242
+ const result = await page.evaluate(async () => {
243
+ const el = document.getElementById("test"),
244
+ result = el.getElementById("icolor");
245
+ return result.getAttribute("value");
246
+ });
247
+ expect(result).toBe("test");
248
+ });
249
+
250
+ test('password input - password should be test', async () => {
251
+ const result = await page.evaluate(async () => {
252
+ const el = document.getElementById("test"),
253
+ result = el.getElementById("ipassword");
254
+ return result.getAttribute("value");
255
+ });
256
+ expect(result).toBe("test");
200
257
  });
201
258
 
202
259
  test('number input - inumber should be 1', async () => {
@@ -232,17 +289,37 @@ describe('Lightview', () => {
232
289
  const result = await page.evaluate(async () => {
233
290
  const el = document.getElementById("test"),
234
291
  result = el.getElementById("icheckbox")
235
- return JSON.parse(result.getAttribute("value"));
292
+ return result.checked;
236
293
  });
237
294
  expect(result).toBe(true);
238
295
  });
296
+ });
239
297
 
298
+ describe("Lightview - on: directive", () => {
240
299
  test('on:<handler> - count should be bumped', async () => {
241
300
  await page.click("#test",{waitUntil:"load"});
242
301
  const result = await page.evaluate(async () => {
243
302
  const el = document.getElementById("test");
244
- return JSON.parse(el.getValue("counter"));
303
+ return JSON.parse(el.getVariableValue("counter"));
245
304
  });
246
305
  expect(result).toBe(1);
247
306
  });
248
- });
307
+ })
308
+
309
+ describe("Lightview - lifecycle", () => {
310
+ test('connected should be called', async () => {
311
+ const result = await page.evaluate(async () => {
312
+ const el = document.getElementById("test");
313
+ return el.testId;
314
+ });
315
+ expect(result).toBe("test");
316
+ });
317
+ test('change should be called', async () => {
318
+ await page.click("#test",{waitUntil:"load"});
319
+ const result = await page.evaluate(async () => {
320
+ const el = document.getElementById("test");
321
+ return el.counter;
322
+ });
323
+ expect(result).toBe(2);
324
+ });
325
+ })