@loadbare/app 0.4.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.
Files changed (171) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +95 -0
  3. package/dist/build/assemble.d.ts +31 -0
  4. package/dist/build/assemble.d.ts.map +1 -0
  5. package/dist/build/assemble.js +53 -0
  6. package/dist/build/cli.d.ts +30 -0
  7. package/dist/build/cli.d.ts.map +1 -0
  8. package/dist/build/cli.js +107 -0
  9. package/dist/build/elements.d.ts +61 -0
  10. package/dist/build/elements.d.ts.map +1 -0
  11. package/dist/build/elements.js +158 -0
  12. package/dist/build/expand.d.ts +45 -0
  13. package/dist/build/expand.d.ts.map +1 -0
  14. package/dist/build/expand.js +386 -0
  15. package/dist/build/format.d.ts +28 -0
  16. package/dist/build/format.d.ts.map +1 -0
  17. package/dist/build/format.js +42 -0
  18. package/dist/build/locations.d.ts +87 -0
  19. package/dist/build/locations.d.ts.map +1 -0
  20. package/dist/build/locations.js +173 -0
  21. package/dist/build/package-root.d.ts +9 -0
  22. package/dist/build/package-root.d.ts.map +1 -0
  23. package/dist/build/package-root.js +24 -0
  24. package/dist/build/pages.d.ts +25 -0
  25. package/dist/build/pages.d.ts.map +1 -0
  26. package/dist/build/pages.js +54 -0
  27. package/dist/build/styles.d.ts +13 -0
  28. package/dist/build/styles.d.ts.map +1 -0
  29. package/dist/build/styles.js +18 -0
  30. package/dist/client.js +522 -0
  31. package/dist/core/lb-constants.d.ts +23 -0
  32. package/dist/core/lb-constants.d.ts.map +1 -0
  33. package/dist/core/lb-constants.js +95 -0
  34. package/dist/core/lb-types.d.ts +88 -0
  35. package/dist/core/lb-types.d.ts.map +1 -0
  36. package/dist/core/lb-types.js +5 -0
  37. package/dist/demo-static/src/widgets/app-box.d.ts +15 -0
  38. package/dist/demo-static/src/widgets/app-box.d.ts.map +1 -0
  39. package/dist/demo-static/src/widgets/app-box.js +19 -0
  40. package/dist/hub/lb-apply.d.ts +13 -0
  41. package/dist/hub/lb-apply.d.ts.map +1 -0
  42. package/dist/hub/lb-apply.js +77 -0
  43. package/dist/hub/lb-hub.d.ts +2 -0
  44. package/dist/hub/lb-hub.d.ts.map +1 -0
  45. package/dist/hub/lb-hub.js +242 -0
  46. package/dist/hub/lb-rows.d.ts +18 -0
  47. package/dist/hub/lb-rows.d.ts.map +1 -0
  48. package/dist/hub/lb-rows.js +106 -0
  49. package/dist/server/lb-express.d.ts +28 -0
  50. package/dist/server/lb-express.d.ts.map +1 -0
  51. package/dist/server/lb-express.js +77 -0
  52. package/dist/server/lb-server.d.ts +174 -0
  53. package/dist/server/lb-server.d.ts.map +1 -0
  54. package/dist/server/lb-server.js +79 -0
  55. package/dist/tests/assemble.test.d.ts +8 -0
  56. package/dist/tests/assemble.test.d.ts.map +1 -0
  57. package/dist/tests/assemble.test.js +51 -0
  58. package/dist/tests/elements.test.d.ts +8 -0
  59. package/dist/tests/elements.test.d.ts.map +1 -0
  60. package/dist/tests/elements.test.js +111 -0
  61. package/dist/tests/expand.test.d.ts +10 -0
  62. package/dist/tests/expand.test.d.ts.map +1 -0
  63. package/dist/tests/expand.test.js +226 -0
  64. package/dist/tests/fixtures/elements/collision/elements.d.ts +5 -0
  65. package/dist/tests/fixtures/elements/collision/elements.d.ts.map +1 -0
  66. package/dist/tests/fixtures/elements/collision/elements.js +3 -0
  67. package/dist/tests/fixtures/elements/collision/widgets/acme-widget.d.ts +2 -0
  68. package/dist/tests/fixtures/elements/collision/widgets/acme-widget.d.ts.map +1 -0
  69. package/dist/tests/fixtures/elements/collision/widgets/acme-widget.js +1 -0
  70. package/dist/tests/fixtures/elements/local/widgets/app-box.d.ts +2 -0
  71. package/dist/tests/fixtures/elements/local/widgets/app-box.d.ts.map +1 -0
  72. package/dist/tests/fixtures/elements/local/widgets/app-box.js +1 -0
  73. package/dist/tests/fixtures/elements/manifest/elements.d.ts +5 -0
  74. package/dist/tests/fixtures/elements/manifest/elements.d.ts.map +1 -0
  75. package/dist/tests/fixtures/elements/manifest/elements.js +3 -0
  76. package/dist/tests/fixtures/elements/manifest-bad-tag/elements.d.ts +5 -0
  77. package/dist/tests/fixtures/elements/manifest-bad-tag/elements.d.ts.map +1 -0
  78. package/dist/tests/fixtures/elements/manifest-bad-tag/elements.js +3 -0
  79. package/dist/tests/fixtures/elements/manifest-bad-value/elements.d.ts +5 -0
  80. package/dist/tests/fixtures/elements/manifest-bad-value/elements.d.ts.map +1 -0
  81. package/dist/tests/fixtures/elements/manifest-bad-value/elements.js +3 -0
  82. package/dist/tests/golden.test.d.ts +19 -0
  83. package/dist/tests/golden.test.d.ts.map +1 -0
  84. package/dist/tests/golden.test.js +60 -0
  85. package/dist/tests/helpers/console.d.ts +20 -0
  86. package/dist/tests/helpers/console.d.ts.map +1 -0
  87. package/dist/tests/helpers/console.js +28 -0
  88. package/dist/tests/helpers/dom.d.ts +18 -0
  89. package/dist/tests/helpers/dom.d.ts.map +1 -0
  90. package/dist/tests/helpers/dom.js +22 -0
  91. package/dist/tests/helpers/window.d.ts +43 -0
  92. package/dist/tests/helpers/window.d.ts.map +1 -0
  93. package/dist/tests/helpers/window.js +78 -0
  94. package/dist/tests/lb-apply.test.d.ts +8 -0
  95. package/dist/tests/lb-apply.test.d.ts.map +1 -0
  96. package/dist/tests/lb-apply.test.js +153 -0
  97. package/dist/tests/lb-express.test.d.ts +14 -0
  98. package/dist/tests/lb-express.test.d.ts.map +1 -0
  99. package/dist/tests/lb-express.test.js +238 -0
  100. package/dist/tests/lb-input.test.d.ts +9 -0
  101. package/dist/tests/lb-input.test.d.ts.map +1 -0
  102. package/dist/tests/lb-input.test.js +78 -0
  103. package/dist/tests/lb-list.test.d.ts +12 -0
  104. package/dist/tests/lb-list.test.d.ts.map +1 -0
  105. package/dist/tests/lb-list.test.js +44 -0
  106. package/dist/tests/lb-options.test.d.ts +10 -0
  107. package/dist/tests/lb-options.test.d.ts.map +1 -0
  108. package/dist/tests/lb-options.test.js +121 -0
  109. package/dist/tests/lb-picker.test.d.ts +14 -0
  110. package/dist/tests/lb-picker.test.d.ts.map +1 -0
  111. package/dist/tests/lb-picker.test.js +59 -0
  112. package/dist/tests/lb-rows.test.d.ts +12 -0
  113. package/dist/tests/lb-rows.test.d.ts.map +1 -0
  114. package/dist/tests/lb-rows.test.js +336 -0
  115. package/dist/tests/lb-select.test.d.ts +9 -0
  116. package/dist/tests/lb-select.test.d.ts.map +1 -0
  117. package/dist/tests/lb-select.test.js +71 -0
  118. package/dist/tests/lb-server.test.d.ts +9 -0
  119. package/dist/tests/lb-server.test.d.ts.map +1 -0
  120. package/dist/tests/lb-server.test.js +495 -0
  121. package/dist/tests/lb-table.test.d.ts +15 -0
  122. package/dist/tests/lb-table.test.d.ts.map +1 -0
  123. package/dist/tests/lb-table.test.js +205 -0
  124. package/dist/tests/pages.test.d.ts +6 -0
  125. package/dist/tests/pages.test.d.ts.map +1 -0
  126. package/dist/tests/pages.test.js +98 -0
  127. package/dist/tests/styles.test.d.ts +7 -0
  128. package/dist/tests/styles.test.d.ts.map +1 -0
  129. package/dist/tests/styles.test.js +73 -0
  130. package/dist/widgets/index.d.ts +7 -0
  131. package/dist/widgets/index.d.ts.map +1 -0
  132. package/dist/widgets/index.js +6 -0
  133. package/dist/widgets/lb-input.d.ts +2 -0
  134. package/dist/widgets/lb-input.d.ts.map +1 -0
  135. package/dist/widgets/lb-input.js +48 -0
  136. package/dist/widgets/lb-list.d.ts +2 -0
  137. package/dist/widgets/lb-list.d.ts.map +1 -0
  138. package/dist/widgets/lb-list.js +17 -0
  139. package/dist/widgets/lb-options.d.ts +26 -0
  140. package/dist/widgets/lb-options.d.ts.map +1 -0
  141. package/dist/widgets/lb-options.js +72 -0
  142. package/dist/widgets/lb-picker.d.ts +2 -0
  143. package/dist/widgets/lb-picker.d.ts.map +1 -0
  144. package/dist/widgets/lb-picker.js +25 -0
  145. package/dist/widgets/lb-select.d.ts +2 -0
  146. package/dist/widgets/lb-select.d.ts.map +1 -0
  147. package/dist/widgets/lb-select.js +43 -0
  148. package/dist/widgets/lb-table.d.ts +2 -0
  149. package/dist/widgets/lb-table.d.ts.map +1 -0
  150. package/dist/widgets/lb-table.js +113 -0
  151. package/docs/application-chrome.md +36 -0
  152. package/docs/building-html-pages.md +130 -0
  153. package/docs/getting-started.md +120 -0
  154. package/docs/guide.md +1164 -0
  155. package/docs/hosting.md +218 -0
  156. package/docs/latent-risks.md +20 -0
  157. package/docs/theory.md +226 -0
  158. package/package.json +85 -0
  159. package/widgets/index.ts +6 -0
  160. package/widgets/lb-input.html +1 -0
  161. package/widgets/lb-input.ts +64 -0
  162. package/widgets/lb-list.html +1 -0
  163. package/widgets/lb-list.ts +21 -0
  164. package/widgets/lb-options.html +4 -0
  165. package/widgets/lb-options.ts +88 -0
  166. package/widgets/lb-picker.html +7 -0
  167. package/widgets/lb-picker.ts +27 -0
  168. package/widgets/lb-select.html +4 -0
  169. package/widgets/lb-select.ts +55 -0
  170. package/widgets/lb-table.html +8 -0
  171. package/widgets/lb-table.ts +126 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # Loadbare App
2
+
3
+ > **This project is being refactored.** While @loadbare/db is highly mature
4
+ > and in use reliably by the author, this ui project is being built from
5
+ > scratch. We know what it will do, but everything has to be built.
6
+
7
+ ## Purpose
8
+
9
+ Loadbare App is a web app framework built specifically to deliver high performance
10
+ to the user for server-bound applications.
11
+
12
+ Loadbare App has two twin primary goals
13
+ - To follow the loadbare philosophy of reducing accidental complexity
14
+ to near zero, so the app developer is spending maximum time on the app
15
+ instead of the tooling.
16
+ - To give the developer a fighting chance to provide complete server round
17
+ trips, from request to final paint, in 300ms or less
18
+
19
+ ## Current WIP
20
+
21
+ Restructuring the docs. Right now "getting started"
22
+ and other docs are very limited because they only document what we've
23
+ tested and proven. Once the build is doing everything it needs to,
24
+ then we can write the docs to flow more like:
25
+ - setting up your infra:
26
+ - add the package
27
+ - chrome
28
+ - express server
29
+ - writing a page with mock db access
30
+ - wiring express to call our handler
31
+ - the html
32
+ - hooks and handlers
33
+ - plugging in your database, just replace mock with your
34
+ own adapter.
35
+
36
+
37
+ ## SLOP LINE
38
+
39
+ Below here is LLM-generated slop, not yet edited to conform to our rules
40
+ against LLM-generated markdown docs.
41
+
42
+
43
+ ## Ideals
44
+
45
+ Loadbare App should be fully inspectable. "View Source" should show the source, and
46
+ what it shows should be what the developer tools show. Frameworks commonly
47
+ lose this property as a side effect of how they generate markup; Loadbare App treats
48
+ keeping it as a requirement.
49
+
50
+ Stated precisely, because two things legitimately differ: no markup exists in
51
+ the DOM that is not in view-source, and the difference between view-source and
52
+ the developer tools is exactly the dynamic half. Navigation moves markup that
53
+ is already in the document, and data lands on it as attributes. Neither
54
+ invents markup.
55
+
56
+ Some widgets, an enriched table being the obvious one, must clone a template
57
+ once per row, and the number of rows is not known until the data arrives. That
58
+ cloning is allowable: the markup is in view-source, and only the count comes
59
+ from the data. Where the boundary of that allowance sits is stated in
60
+ [Theory of Loadbare App](./docs/theory.md).
61
+
62
+ Nothing here is about protecting the HTML, which is visible in the developer
63
+ tools regardless. It is about the technology being open to inspection by
64
+ whoever wants to look.
65
+
66
+ ## Documentation
67
+
68
+ [`docs/theory.md`](./docs/theory.md) states what Loadbare App is and
69
+ why. It is authoritative; where any other document disagrees with it, the other
70
+ document is wrong.
71
+
72
+ - [Programmer's Guide](./docs/guide.md) — how to build an application with
73
+ Loadbare App. Each section is marked with whether the code does it yet.
74
+ - [Hosting a Loadbare App Application](./docs/hosting.md) — registering pages,
75
+ assembling the shell, navigation, and serving the two endpoints from
76
+ Express. Everything you do once per application rather than once per page.
77
+ - [Theory of Loadbare App](./docs/theory.md) — scope, the performance budget,
78
+ the thesis, and what is settled so far.
79
+ - [Communication channels](./docs-llm-slop/communication-channels.md) — what
80
+ the host/data split means on the wire.
81
+ - [Data binding](./docs-llm-slop/data-binding.md) — the addressing vocabulary
82
+ and how a data fragment lands on a widget.
83
+ - [Requests](./docs-llm-slop/requests.md) — how a widget reaches the server,
84
+ and what the server may trust.
85
+ - [Bundling](./docs-llm-slop/bundling.md) — how the static half is packaged
86
+ and shipped.
87
+ - [Expansion](./docs-llm-slop/expansion.md) — how one authored tag becomes the
88
+ tree it stands for, and why the definition language has no control flow.
89
+ - [Coming from other frameworks](./docs-llm-slop/coming-from-other-frameworks.md)
90
+ — what changes if you already know React, Angular, htmx or Datastar.
91
+ - [Prior art](./docs-llm-slop/prior-art.md) — what has been done before, and
92
+ why nothing was adopted off the shelf.
93
+
94
+ The guide states the API as it should be and marks each section with whether
95
+ the code does it yet. Where the two disagree, the code is what moves.
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Assembling one document out of a chrome file and a set of pages.
3
+ *
4
+ * Every `.html` file in play — the chrome and each page — goes through the
5
+ * same `expand()` (see build/expand.ts) against the same definitions: the
6
+ * built-in widgets and whatever definitions were found in the caller's own
7
+ * source tree. `expand()` only ever sees a fragment, so the chrome's own is
8
+ * the text between its `<body>` tags; a page's is the whole file. A page's
9
+ * expanded host is wrapped in `<template id="page-<name>">` and, together
10
+ * with the chrome's own expanded body content, spliced back into the
11
+ * chrome's `<body>`. The result is the one document a server has to serve
12
+ * for every route — see docs/getting-started.md and docs/application-chrome.md.
13
+ *
14
+ * Every path here is a parameter, resolved once by build/locations.ts — this
15
+ * module never reconstructs one of its own, and never reads a directory
16
+ * looking for pages or widgets; it is handed exactly which files those are.
17
+ */
18
+ import type { PageFile, WidgetSource } from "./locations.js";
19
+ export interface AssembleOptions {
20
+ chromeFile: string;
21
+ pages: PageFile[];
22
+ widgets: Map<string, WidgetSource>;
23
+ builtinWidgetsDir: string;
24
+ }
25
+ export interface Assembled {
26
+ html: string;
27
+ /** Every custom element tag left in the document once expansion is done. */
28
+ usedTags: Set<string>;
29
+ }
30
+ export declare function assemble({ chromeFile, pages, widgets, builtinWidgetsDir, }: AssembleOptions): Promise<Assembled>;
31
+ //# sourceMappingURL=assemble.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assemble.d.ts","sourceRoot":"","sources":["../../build/assemble.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAWH,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE7D,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACnC,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACvB;AAED,wBAAsB,QAAQ,CAAC,EAC7B,UAAU,EACV,KAAK,EACL,OAAO,EACP,iBAAiB,GAClB,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,CA2CtC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Assembling one document out of a chrome file and a set of pages.
3
+ *
4
+ * Every `.html` file in play — the chrome and each page — goes through the
5
+ * same `expand()` (see build/expand.ts) against the same definitions: the
6
+ * built-in widgets and whatever definitions were found in the caller's own
7
+ * source tree. `expand()` only ever sees a fragment, so the chrome's own is
8
+ * the text between its `<body>` tags; a page's is the whole file. A page's
9
+ * expanded host is wrapped in `<template id="page-<name>">` and, together
10
+ * with the chrome's own expanded body content, spliced back into the
11
+ * chrome's `<body>`. The result is the one document a server has to serve
12
+ * for every route — see docs/getting-started.md and docs/application-chrome.md.
13
+ *
14
+ * Every path here is a parameter, resolved once by build/locations.ts — this
15
+ * module never reconstructs one of its own, and never reads a directory
16
+ * looking for pages or widgets; it is handed exactly which files those are.
17
+ */
18
+ import { readFile } from "node:fs/promises";
19
+ import { addDefinitions, customElementTags, expand, loadDefinitions, } from "./expand.js";
20
+ import { formatHtml } from "./format.js";
21
+ import { PAGE_TEMPLATE_PREFIX } from "../core/lb-constants.js";
22
+ export async function assemble({ chromeFile, pages, widgets, builtinWidgetsDir, }) {
23
+ const widgetHtmlFiles = new Map();
24
+ for (const [tag, source] of widgets) {
25
+ if (source.html)
26
+ widgetHtmlFiles.set(tag, source.html);
27
+ }
28
+ const defs = await addDefinitions(await loadDefinitions([builtinWidgetsDir]), widgetHtmlFiles);
29
+ const templates = [];
30
+ for (const { name, file } of pages) {
31
+ const authored = await readFile(file, "utf-8");
32
+ const host = expand(authored, defs);
33
+ templates.push(`<template id="${PAGE_TEMPLATE_PREFIX}${name}">${host}</template>`);
34
+ }
35
+ let chromeSource;
36
+ try {
37
+ chromeSource = await readFile(chromeFile, "utf-8");
38
+ }
39
+ catch {
40
+ throw new Error(`assemble: no chrome file at '${chromeFile}'`);
41
+ }
42
+ const body = /<body([^>]*)>([\s\S]*)<\/body>/i.exec(chromeSource);
43
+ if (!body) {
44
+ throw new Error(`assemble: '${chromeFile}' has no <body>...</body> to expand`);
45
+ }
46
+ const [whole, bodyAttrs, bodyContent] = body;
47
+ const expandedBody = expand(bodyContent, defs);
48
+ const withPages = chromeSource.replace(whole, () => `<body${bodyAttrs}>${expandedBody}\n${templates.join("\n")}\n</body>`);
49
+ return {
50
+ html: await formatHtml(withPages),
51
+ usedTags: customElementTags(withPages),
52
+ };
53
+ }
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * loadbare-app-build — assemble a chrome file and its pages into one HTML
4
+ * document, and bundle the client script for exactly the custom elements
5
+ * that document uses. See docs/getting-started.md.
6
+ *
7
+ * loadbare-app-build [--src src] [--out dist] [--watch]
8
+ *
9
+ * `--src` names the tree scanned for everything: the one `*.chrome.html`
10
+ * file, every `*.page.html` page, every other `.html`/`.ts` as a widget,
11
+ * `*.hooks.ts`/`*.queries.ts` pairs, and `elements.ts` if there is one — see
12
+ * build/locations.ts for how a file's name says what it is. The assembled
13
+ * document is written to `<out>/app.html`; the client bundle to
14
+ * `<out>/client.js`, by way of a generated `<out>/client-entry.ts` — see
15
+ * build/elements.ts for how a tag is resolved to the script that registers
16
+ * it. When any page has a hooks or queries file, the hub registry that used
17
+ * to be hand-maintained is written to `<out>/pages.ts` — see build/pages.ts.
18
+ * Every `.css` file anywhere under `<src>` is concatenated, in the order
19
+ * described in build/locations.ts, and written to `<out>/app.css` — see
20
+ * build/styles.ts.
21
+ *
22
+ * Without `--watch`, this runs once and exits. With it, every `.html`,
23
+ * `.ts` and `.css` file under `<src>` is watched — a page, a widget's
24
+ * markup, a widget's class, a stylesheet, and `elements.ts` all feed the
25
+ * same build — and a rebuild that throws is reported without stopping the
26
+ * watch. There is no dev server and no browser reload here, only the files
27
+ * on disk staying current for the next manual refresh.
28
+ */
29
+ export {};
30
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../build/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG"}
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * loadbare-app-build — assemble a chrome file and its pages into one HTML
4
+ * document, and bundle the client script for exactly the custom elements
5
+ * that document uses. See docs/getting-started.md.
6
+ *
7
+ * loadbare-app-build [--src src] [--out dist] [--watch]
8
+ *
9
+ * `--src` names the tree scanned for everything: the one `*.chrome.html`
10
+ * file, every `*.page.html` page, every other `.html`/`.ts` as a widget,
11
+ * `*.hooks.ts`/`*.queries.ts` pairs, and `elements.ts` if there is one — see
12
+ * build/locations.ts for how a file's name says what it is. The assembled
13
+ * document is written to `<out>/app.html`; the client bundle to
14
+ * `<out>/client.js`, by way of a generated `<out>/client-entry.ts` — see
15
+ * build/elements.ts for how a tag is resolved to the script that registers
16
+ * it. When any page has a hooks or queries file, the hub registry that used
17
+ * to be hand-maintained is written to `<out>/pages.ts` — see build/pages.ts.
18
+ * Every `.css` file anywhere under `<src>` is concatenated, in the order
19
+ * described in build/locations.ts, and written to `<out>/app.css` — see
20
+ * build/styles.ts.
21
+ *
22
+ * Without `--watch`, this runs once and exits. With it, every `.html`,
23
+ * `.ts` and `.css` file under `<src>` is watched — a page, a widget's
24
+ * markup, a widget's class, a stylesheet, and `elements.ts` all feed the
25
+ * same build — and a rebuild that throws is reported without stopping the
26
+ * watch. There is no dev server and no browser reload here, only the files
27
+ * on disk staying current for the next manual refresh.
28
+ */
29
+ import { parseArgs } from "node:util";
30
+ import { mkdir, watch, writeFile } from "node:fs/promises";
31
+ import path from "node:path";
32
+ import * as esbuild from "esbuild";
33
+ import { assemble } from "./assemble.js";
34
+ import { clientEntrySource, resolveElements } from "./elements.js";
35
+ import { resolveLocations } from "./locations.js";
36
+ import { pagesSource } from "./pages.js";
37
+ import { stylesSource } from "./styles.js";
38
+ const { values } = parseArgs({
39
+ options: {
40
+ src: { type: "string", default: "src" },
41
+ out: { type: "string", default: "dist" },
42
+ watch: { type: "boolean", default: false },
43
+ },
44
+ });
45
+ const srcDir = values.src;
46
+ async function build() {
47
+ const locations = await resolveLocations({ src: srcDir, out: values.out });
48
+ const outFile = path.join(locations.outDir, "app.html");
49
+ const entryFile = path.join(locations.outDir, "client-entry.ts");
50
+ const clientFile = path.join(locations.outDir, "client.js");
51
+ const { html, usedTags } = await assemble(locations);
52
+ await mkdir(locations.outDir, { recursive: true });
53
+ await writeFile(outFile, html, "utf-8");
54
+ const { resolved } = await resolveElements({ used: usedTags, ...locations });
55
+ await writeFile(entryFile, clientEntrySource(resolved, locations.outDir), "utf-8");
56
+ await esbuild.build({
57
+ entryPoints: [entryFile],
58
+ bundle: true,
59
+ format: "iife",
60
+ outfile: clientFile,
61
+ });
62
+ const generatedPages = pagesSource(locations.pages, locations.pageSources, locations.outDir, locations.packageName);
63
+ let pagesMessage = "";
64
+ if (generatedPages) {
65
+ const pagesFile = path.join(locations.outDir, "pages.ts");
66
+ await writeFile(pagesFile, generatedPages, "utf-8");
67
+ pagesMessage = ` and ${pagesFile}`;
68
+ }
69
+ const generatedCss = await stylesSource(locations.cssFiles);
70
+ let cssMessage = "";
71
+ if (generatedCss) {
72
+ const cssFile = path.join(locations.outDir, "app.css");
73
+ await writeFile(cssFile, generatedCss, "utf-8");
74
+ cssMessage = ` and ${cssFile}`;
75
+ }
76
+ console.log(`loadbare-app-build: wrote ${outFile} and ${clientFile}${pagesMessage}${cssMessage} ` +
77
+ `(${resolved.size} custom element${resolved.size === 1 ? "" : "s"})`);
78
+ }
79
+ async function main() {
80
+ try {
81
+ await build();
82
+ }
83
+ catch (err) {
84
+ console.error(`loadbare-app-build: ${err.message}`);
85
+ if (!values.watch) {
86
+ process.exitCode = 1;
87
+ return;
88
+ }
89
+ }
90
+ if (!values.watch)
91
+ return;
92
+ console.log(`loadbare-app-build: watching ${srcDir}`);
93
+ const watcher = watch(srcDir, { recursive: true });
94
+ for await (const event of watcher) {
95
+ if (!event.filename?.endsWith(".html") &&
96
+ !event.filename?.endsWith(".ts") &&
97
+ !event.filename?.endsWith(".css"))
98
+ continue;
99
+ try {
100
+ await build();
101
+ }
102
+ catch (err) {
103
+ console.error(`loadbare-app-build: ${err.message}`);
104
+ }
105
+ }
106
+ }
107
+ void main();
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Validating that a custom element a build actually uses can do something —
3
+ * and finding the script to import for it when it can.
4
+ *
5
+ * A used tag is valid if it has a script, a definition, or both:
6
+ * - a script registers the class that upgrades it. It can come from a
7
+ * built-in source (this package's own widgets/ or hub/ — hub/ is where
8
+ * lb-hub itself lives, discovered exactly the same way as any built-in
9
+ * widget, no special case for it here), an application's own — found
10
+ * anywhere in its source tree by build/locations.ts, not confined to a
11
+ * directory — or a third party's, declared by tag in `elements.ts`.
12
+ * - a definition (an `.html` file, built-in or local) expands the tag's
13
+ * content at build time. A widget with only a definition and no script
14
+ * is markup only: expansion already gave it everything it will ever
15
+ * have, and the tag survives just as an inert wrapper (see expand.ts).
16
+ *
17
+ * A tag with neither — no script anywhere and no definition — would do
18
+ * nothing were it ever to reach the browser, so that is an error.
19
+ *
20
+ * Every directory and file here is a parameter, resolved once by
21
+ * build/locations.ts — this module never reconstructs one of its own, and
22
+ * the application's own widgets are handed over already found, not scanned
23
+ * again here.
24
+ */
25
+ import { type WidgetSource } from "./locations.js";
26
+ /** The shape of an `elements.ts` module's default export. */
27
+ export type ElementManifest = Record<string, string>;
28
+ /** A resolved tag: a bare specifier to import, or a local file to import by relative path. */
29
+ export type Resolved = {
30
+ kind: "specifier";
31
+ value: string;
32
+ } | {
33
+ kind: "file";
34
+ value: string;
35
+ };
36
+ /**
37
+ * `elements.ts`, executed rather than parsed — it runs through the same
38
+ * loader as the rest of the build, so it is ordinary TypeScript, not a data
39
+ * format with its own rules.
40
+ */
41
+ export declare function loadElementManifest(file: string): Promise<ElementManifest>;
42
+ export interface ResolveOptions {
43
+ used: Set<string>;
44
+ widgets: Map<string, WidgetSource>;
45
+ elementsFile?: string;
46
+ builtinWidgetsDir: string;
47
+ builtinHubDir: string;
48
+ packageName: string;
49
+ }
50
+ export interface ResolveResult {
51
+ resolved: Map<string, Resolved>;
52
+ }
53
+ export declare function resolveElements({ used, widgets, elementsFile, builtinWidgetsDir, builtinHubDir, packageName, }: ResolveOptions): Promise<ResolveResult>;
54
+ /**
55
+ * The generated client entry point — every custom element the assembled
56
+ * document actually uses, and nothing else. Written to `outDir` so a
57
+ * relative import to a local widget resolves the ordinary way; a specifier
58
+ * (built-in or third-party) is written as the bare string it is.
59
+ */
60
+ export declare function clientEntrySource(resolved: Map<string, Resolved>, outDir: string): string;
61
+ //# sourceMappingURL=elements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../build/elements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEvE,6DAA6D;AAC7D,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAErD,8FAA8F;AAC9F,MAAM,MAAM,QAAQ,GAClB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAmCzE;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,eAAe,CAAC,CA4B1B;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CACjC;AAED,wBAAsB,eAAe,CAAC,EACpC,IAAI,EACJ,OAAO,EACP,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,WAAW,GACZ,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAoEzC;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,EAC/B,MAAM,EAAE,MAAM,GACb,MAAM,CAcR"}