@loadbare/app 0.5.5 → 0.6.0
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 +3 -4
- package/dist/build/assemble.d.ts +1 -1
- package/dist/build/assemble.d.ts.map +1 -1
- package/dist/build/assemble.js +80 -7
- package/dist/build/cli.d.ts +2 -2
- package/dist/build/cli.js +2 -2
- package/dist/build/expand.d.ts.map +1 -1
- package/dist/build/expand.js +30 -34
- package/dist/build/locations.d.ts +3 -3
- package/dist/build/locations.d.ts.map +1 -1
- package/dist/build/locations.js +15 -3
- package/dist/build/origins.d.ts +0 -13
- package/dist/build/origins.d.ts.map +1 -1
- package/dist/build/origins.js +32 -8
- package/dist/build/pages.d.ts +3 -3
- package/dist/build/pages.d.ts.map +1 -1
- package/dist/build/pages.js +9 -7
- package/dist/core/lb-constants.d.ts +17 -12
- package/dist/core/lb-constants.d.ts.map +1 -1
- package/dist/core/lb-constants.js +106 -43
- package/dist/core/lb-types.d.ts +103 -62
- package/dist/core/lb-types.d.ts.map +1 -1
- package/dist/core/lb-types.js +11 -3
- package/dist/hub/lb-apply.d.ts +18 -4
- package/dist/hub/lb-apply.d.ts.map +1 -1
- package/dist/hub/lb-apply.js +184 -34
- package/dist/hub/lb-hub.browser.d.ts +1 -1
- package/dist/hub/lb-hub.browser.d.ts.map +1 -1
- package/dist/hub/lb-hub.browser.js +165 -83
- package/dist/server/lb-express.d.ts +7 -4
- package/dist/server/lb-express.d.ts.map +1 -1
- package/dist/server/lb-express.js +45 -33
- package/dist/server/lb-server.d.ts +67 -45
- package/dist/server/lb-server.d.ts.map +1 -1
- package/dist/server/lb-server.js +55 -18
- package/dist/tests/assemble.test.js +154 -2
- package/dist/tests/expand.test.js +30 -3
- package/dist/tests/helpers/hub.d.ts +73 -0
- package/dist/tests/helpers/hub.d.ts.map +1 -0
- package/dist/tests/helpers/hub.js +151 -0
- package/dist/tests/lb-apply.test.js +86 -62
- package/dist/tests/lb-express.test.d.ts +1 -1
- package/dist/tests/lb-express.test.js +43 -38
- package/dist/tests/lb-hub.test.d.ts +14 -0
- package/dist/tests/lb-hub.test.d.ts.map +1 -0
- package/dist/tests/lb-hub.test.js +319 -0
- package/dist/tests/{lb-rows.test.d.ts → lb-list.test.d.ts} +1 -1
- package/dist/tests/lb-list.test.d.ts.map +1 -0
- package/dist/tests/{lb-rows.test.js → lb-list.test.js} +109 -106
- package/dist/tests/lb-server.test.js +151 -100
- package/dist/tests/origins.test.js +19 -1
- package/dist/tests/pages.test.d.ts +1 -1
- package/dist/tests/pages.test.js +64 -14
- package/docs/TECHREF-1.0.md +1000 -0
- package/docs/reference/builder.md +4 -4
- package/docs/reference/chrome.md +56 -5
- package/docs/reference/custom-elements.md +59 -36
- package/docs/reference/data-binding.md +142 -84
- package/docs/reference/overview.md +1 -1
- package/docs/reference/page-files.md +64 -49
- package/docs/reference/server.md +7 -6
- package/docs/reference/widgets.md +43 -32
- package/docs/roadmap.md +68 -22
- package/docs/testing.md +47 -17
- package/docs/theory.md +2 -2
- package/docs/tutorials/010-pages-and-navigation.md +14 -8
- package/docs/tutorials/040-displaying-data.md +9 -9
- package/docs/tutorials/050-actions.md +5 -5
- package/docs/tutorials/060-custom-element-code.md +1 -1
- package/docs/tutorials/065-conditional-rendering.md +4 -4
- package/docs/tutorials/070-displaying-a-list.md +24 -47
- package/docs/tutorials/072-inserting-into-a-list.md +17 -17
- package/docs/tutorials/074-deleting-from-a-list.md +15 -17
- package/docs/tutorials/076-updating-a-list-item.md +20 -22
- package/docs/tutorials/080-widget-requests.md +27 -23
- package/docs/tutorials/090-using-widget-libraries.md +23 -1
- package/package.json +1 -2
- package/dist/hub/lb-rows.d.ts +0 -18
- package/dist/hub/lb-rows.d.ts.map +0 -1
- package/dist/hub/lb-rows.js +0 -106
- package/dist/tests/lb-rows.test.d.ts.map +0 -1
package/dist/tests/pages.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Discovering `*.
|
|
2
|
+
* Discovering `*.requests.ts`/`*.queries.ts` pairs (build/locations.ts) and
|
|
3
3
|
* generating the hub registry from them (build/pages.ts).
|
|
4
4
|
*/
|
|
5
5
|
import assert from "node:assert/strict";
|
|
@@ -19,12 +19,12 @@ async function tree(files) {
|
|
|
19
19
|
}
|
|
20
20
|
return dir;
|
|
21
21
|
}
|
|
22
|
-
describe("discovering
|
|
23
|
-
it("pairs a *.
|
|
22
|
+
describe("discovering requests and queries", () => {
|
|
23
|
+
it("pairs a *.requests.ts and *.queries.ts with the page sharing their basename", async () => {
|
|
24
24
|
const src = await tree({
|
|
25
25
|
"chrome.html": CHROME,
|
|
26
26
|
"pages/hello.page.html": `<p>hi</p>`,
|
|
27
|
-
"pages/hello.
|
|
27
|
+
"pages/hello.requests.ts": `export const requests = {};`,
|
|
28
28
|
"pages/hello.queries.ts": `export const queries = {};`,
|
|
29
29
|
});
|
|
30
30
|
try {
|
|
@@ -33,7 +33,7 @@ describe("discovering hooks and queries", () => {
|
|
|
33
33
|
out: `${src}/dist`,
|
|
34
34
|
});
|
|
35
35
|
const hello = pageSources.get("hello");
|
|
36
|
-
assert.ok(hello?.
|
|
36
|
+
assert.ok(hello?.requests?.endsWith("hello.requests"));
|
|
37
37
|
assert.ok(hello?.queries?.endsWith("hello.queries"));
|
|
38
38
|
}
|
|
39
39
|
finally {
|
|
@@ -52,17 +52,64 @@ describe("discovering hooks and queries", () => {
|
|
|
52
52
|
out: `${src}/dist`,
|
|
53
53
|
});
|
|
54
54
|
const counter = pageSources.get("counter");
|
|
55
|
-
assert.equal(counter?.
|
|
55
|
+
assert.equal(counter?.requests, undefined);
|
|
56
56
|
assert.ok(counter?.queries?.endsWith("counter.queries"));
|
|
57
57
|
}
|
|
58
58
|
finally {
|
|
59
59
|
await rm(src, { recursive: true, force: true });
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
|
-
it("throws when
|
|
62
|
+
it("throws when no chrome file is found", async () => {
|
|
63
|
+
const src = await tree({ "pages/hello.page.html": `<p>hi</p>` });
|
|
64
|
+
try {
|
|
65
|
+
await assert.rejects(() => resolveLocations({ src, out: `${src}/dist` }), /no chrome\.html file found/);
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
await rm(src, { recursive: true, force: true });
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
it("throws when two chrome files are found", async () => {
|
|
72
|
+
const src = await tree({
|
|
73
|
+
"chrome.html": CHROME,
|
|
74
|
+
"other/chrome.html": CHROME,
|
|
75
|
+
});
|
|
76
|
+
try {
|
|
77
|
+
await assert.rejects(() => resolveLocations({ src, out: `${src}/dist` }), /more than one chrome\.html file found/);
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
await rm(src, { recursive: true, force: true });
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
it("throws when two imports.ts files are found", async () => {
|
|
84
|
+
const src = await tree({
|
|
85
|
+
"chrome.html": CHROME,
|
|
86
|
+
"imports.ts": `export default [];`,
|
|
87
|
+
"widgets/imports.ts": `export default [];`,
|
|
88
|
+
});
|
|
89
|
+
try {
|
|
90
|
+
await assert.rejects(() => resolveLocations({ src, out: `${src}/dist` }), /more than one imports\.ts found/);
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
await rm(src, { recursive: true, force: true });
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
it("throws when two page files in different directories share a stub", async () => {
|
|
97
|
+
const src = await tree({
|
|
98
|
+
"chrome.html": CHROME,
|
|
99
|
+
"pages/members.page.html": `<p>one</p>`,
|
|
100
|
+
"admin/members.page.html": `<p>two</p>`,
|
|
101
|
+
});
|
|
102
|
+
try {
|
|
103
|
+
await assert.rejects(() => resolveLocations({ src, out: `${src}/dist` }), /more than one 'members\.page\.html'/);
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
await rm(src, { recursive: true, force: true });
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
it("throws when a requests or queries file has no matching page", async () => {
|
|
63
110
|
const src = await tree({
|
|
64
111
|
"chrome.html": CHROME,
|
|
65
|
-
"pages/orphan.
|
|
112
|
+
"pages/orphan.requests.ts": `export const requests = {};`,
|
|
66
113
|
});
|
|
67
114
|
try {
|
|
68
115
|
await assert.rejects(() => resolveLocations({ src, out: `${src}/dist` }), /no 'orphan\.page\.html'/);
|
|
@@ -73,7 +120,7 @@ describe("discovering hooks and queries", () => {
|
|
|
73
120
|
});
|
|
74
121
|
});
|
|
75
122
|
describe("pagesSource", () => {
|
|
76
|
-
it("returns undefined when no page has
|
|
123
|
+
it("returns undefined when no page has requests or queries", () => {
|
|
77
124
|
assert.equal(pagesSource([{ name: "hello", file: "/src/hello.page.html" }], new Map(), "/out", "@loadbare/app"), undefined);
|
|
78
125
|
});
|
|
79
126
|
it("generates one import per file found and one entry per page", () => {
|
|
@@ -82,17 +129,20 @@ describe("pagesSource", () => {
|
|
|
82
129
|
{ name: "counter", file: "/src/counter.page.html" },
|
|
83
130
|
];
|
|
84
131
|
const pageSources = new Map([
|
|
85
|
-
[
|
|
132
|
+
[
|
|
133
|
+
"hello",
|
|
134
|
+
{ requests: "/src/hello.requests", queries: "/src/hello.queries" },
|
|
135
|
+
],
|
|
86
136
|
["counter", { queries: "/src/counter.queries" }],
|
|
87
137
|
]);
|
|
88
138
|
const out = pagesSource(pages, pageSources, "/out", "@loadbare/app");
|
|
89
139
|
assert.match(out, /import \{ createHub \} from "@loadbare\/app\/server";/);
|
|
90
|
-
assert.match(out, /import \{
|
|
140
|
+
assert.match(out, /import \{ requests as page_hello_Requests \} from "\.\.\/src\/hello\.requests";/);
|
|
91
141
|
assert.match(out, /import \{ queries as page_hello_Queries \} from "\.\.\/src\/hello\.queries";/);
|
|
92
142
|
assert.match(out, /import \{ queries as page_counter_Queries \} from "\.\.\/src\/counter\.queries";/);
|
|
93
|
-
assert.doesNotMatch(out, /
|
|
94
|
-
assert.match(out, /"hello": \{
|
|
95
|
-
assert.match(out, /"counter": \{
|
|
143
|
+
assert.doesNotMatch(out, /page_counter_Requests/);
|
|
144
|
+
assert.match(out, /"hello": \{ requests: page_hello_Requests, queries: page_hello_Queries \}/);
|
|
145
|
+
assert.match(out, /"counter": \{ requests: \{\}, queries: page_counter_Queries \}/);
|
|
96
146
|
assert.match(out, /export const hub = createHub\(\{/);
|
|
97
147
|
});
|
|
98
148
|
});
|