@e280/sly 0.2.0-3 → 0.2.0-31

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 (304) hide show
  1. package/README.md +624 -97
  2. package/package.json +13 -6
  3. package/s/base/element.ts +76 -0
  4. package/s/base/index.ts +6 -0
  5. package/s/{views → base}/use.ts +25 -16
  6. package/s/base/utils/attr-watcher.ts +22 -0
  7. package/s/base/utils/reactor.ts +32 -0
  8. package/s/base/utils/states.ts +49 -0
  9. package/s/base/utils/use-attrs.ts +36 -0
  10. package/s/demo/demo.bundle.ts +9 -5
  11. package/s/demo/views/counter.ts +21 -24
  12. package/s/demo/views/demo.ts +10 -6
  13. package/s/demo/views/fastcount.ts +29 -0
  14. package/s/demo/views/loaders.ts +7 -7
  15. package/s/dom/attrs/attrs.ts +21 -0
  16. package/s/dom/attrs/parts/attr-fns.ts +68 -0
  17. package/s/dom/attrs/parts/attr-proxies.ts +35 -0
  18. package/s/dom/attrs/parts/attr-spec.ts +29 -0
  19. package/s/dom/attrs/parts/on-attrs.ts +8 -0
  20. package/s/dom/dom.ts +22 -38
  21. package/s/dom/index.ts +4 -0
  22. package/s/dom/parts/dom-scope.ts +46 -0
  23. package/s/dom/parts/el.ts +14 -0
  24. package/s/dom/parts/elmer.ts +38 -0
  25. package/s/dom/parts/eve.ts +24 -0
  26. package/s/dom/parts/mk.ts +9 -0
  27. package/s/dom/parts/queries.ts +26 -0
  28. package/s/dom/{register.ts → parts/register.ts} +2 -7
  29. package/s/dom/types.ts +42 -0
  30. package/s/index.html.ts +4 -2
  31. package/s/index.ts +7 -19
  32. package/s/loaders/index.barrel.ts +10 -0
  33. package/s/loaders/index.ts +4 -0
  34. package/s/loaders/make.ts +14 -0
  35. package/s/loaders/mock.ts +11 -0
  36. package/s/{ops/loaders → loaders}/parts/anims.ts +1 -1
  37. package/s/{ops/loaders → loaders}/parts/ascii-anim.ts +6 -5
  38. package/s/{ops/loaders → loaders}/parts/error-display.ts +2 -2
  39. package/s/loaders/types.ts +6 -0
  40. package/s/loot/drag-and-drops.ts +82 -0
  41. package/s/loot/{drop.ts → drops.ts} +8 -17
  42. package/s/loot/helpers.ts +3 -3
  43. package/s/loot/index.barrel.ts +5 -0
  44. package/s/loot/index.ts +2 -3
  45. package/s/ops/index.ts +5 -0
  46. package/s/ops/op.ts +1 -0
  47. package/s/spa/index.barrel.ts +6 -0
  48. package/s/spa/index.ts +4 -0
  49. package/s/spa/plumbing/braces.ts +76 -0
  50. package/s/spa/plumbing/primitives.ts +85 -0
  51. package/s/spa/plumbing/router-core.ts +49 -0
  52. package/s/spa/plumbing/types.ts +45 -0
  53. package/s/spa/router.ts +49 -0
  54. package/s/spa/spa.test.ts +91 -0
  55. package/s/tests.test.ts +4 -1
  56. package/s/view/index.ts +7 -0
  57. package/s/view/types.ts +39 -0
  58. package/s/view/utils/contextualize.ts +45 -0
  59. package/s/view/utils/make-component.ts +34 -0
  60. package/s/view/utils/make-view.ts +48 -0
  61. package/s/view/utils/parts/capsule.ts +67 -0
  62. package/s/view/utils/parts/chain.ts +40 -0
  63. package/s/view/utils/parts/context.ts +11 -0
  64. package/s/view/utils/parts/directive.ts +29 -0
  65. package/s/view/utils/parts/sly-view.ts +15 -0
  66. package/s/view/view.ts +24 -0
  67. package/x/base/css-reset.js.map +1 -0
  68. package/x/base/element.d.ts +19 -0
  69. package/x/base/element.js +52 -0
  70. package/x/base/element.js.map +1 -0
  71. package/x/base/index.d.ts +4 -0
  72. package/x/base/index.js +5 -0
  73. package/x/base/index.js.map +1 -0
  74. package/x/{views → base}/use.d.ts +8 -4
  75. package/x/{views → base}/use.js +15 -9
  76. package/x/base/use.js.map +1 -0
  77. package/x/base/utils/apply-styles.js.map +1 -0
  78. package/x/base/utils/attr-watcher.d.ts +8 -0
  79. package/x/base/utils/attr-watcher.js +20 -0
  80. package/x/base/utils/attr-watcher.js.map +1 -0
  81. package/x/base/utils/mounts.js.map +1 -0
  82. package/x/base/utils/reactor.d.ts +5 -0
  83. package/x/base/utils/reactor.js +25 -0
  84. package/x/base/utils/reactor.js.map +1 -0
  85. package/x/base/utils/states.d.ts +13 -0
  86. package/x/base/utils/states.js +41 -0
  87. package/x/base/utils/states.js.map +1 -0
  88. package/x/base/utils/use-attrs.d.ts +11 -0
  89. package/x/base/utils/use-attrs.js +18 -0
  90. package/x/base/utils/use-attrs.js.map +1 -0
  91. package/x/demo/demo.bundle.js +8 -4
  92. package/x/demo/demo.bundle.js.map +1 -1
  93. package/x/demo/demo.bundle.min.js +19 -22
  94. package/x/demo/demo.bundle.min.js.map +4 -4
  95. package/x/demo/views/counter.d.ts +374 -1
  96. package/x/demo/views/counter.js +19 -22
  97. package/x/demo/views/counter.js.map +1 -1
  98. package/x/demo/views/demo.d.ts +4 -1
  99. package/x/demo/views/demo.js +10 -5
  100. package/x/demo/views/demo.js.map +1 -1
  101. package/x/demo/views/fastcount.d.ts +12 -0
  102. package/x/demo/views/fastcount.js +21 -0
  103. package/x/demo/views/fastcount.js.map +1 -0
  104. package/x/demo/views/loaders.js +6 -6
  105. package/x/demo/views/loaders.js.map +1 -1
  106. package/x/dom/attrs/attrs.d.ts +23 -0
  107. package/x/dom/attrs/attrs.js +17 -0
  108. package/x/dom/attrs/attrs.js.map +1 -0
  109. package/x/dom/attrs/parts/attr-fns.d.ts +16 -0
  110. package/x/dom/attrs/parts/attr-fns.js +64 -0
  111. package/x/dom/attrs/parts/attr-fns.js.map +1 -0
  112. package/x/dom/attrs/parts/attr-proxies.d.ts +8 -0
  113. package/x/dom/attrs/parts/attr-proxies.js +21 -0
  114. package/x/dom/attrs/parts/attr-proxies.js.map +1 -0
  115. package/x/dom/attrs/parts/attr-spec.d.ts +3 -0
  116. package/x/dom/attrs/parts/attr-spec.js +21 -0
  117. package/x/dom/attrs/parts/attr-spec.js.map +1 -0
  118. package/x/dom/attrs/parts/on-attrs.d.ts +2 -0
  119. package/x/dom/attrs/parts/on-attrs.js +7 -0
  120. package/x/dom/attrs/parts/on-attrs.js.map +1 -0
  121. package/x/dom/dom.d.ts +15 -16
  122. package/x/dom/dom.js +21 -34
  123. package/x/dom/dom.js.map +1 -1
  124. package/x/dom/index.d.ts +2 -0
  125. package/x/dom/index.js +3 -0
  126. package/x/dom/index.js.map +1 -0
  127. package/x/dom/parts/dashify.js.map +1 -0
  128. package/x/dom/parts/dom-scope.d.ts +15 -0
  129. package/x/dom/parts/dom-scope.js +35 -0
  130. package/x/dom/parts/dom-scope.js.map +1 -0
  131. package/x/dom/parts/el.d.ts +2 -0
  132. package/x/dom/parts/el.js +7 -0
  133. package/x/dom/parts/el.js.map +1 -0
  134. package/x/dom/parts/elmer.d.ts +11 -0
  135. package/x/dom/parts/elmer.js +32 -0
  136. package/x/dom/parts/elmer.js.map +1 -0
  137. package/x/dom/parts/eve.d.ts +7 -0
  138. package/x/dom/parts/eve.js +16 -0
  139. package/x/dom/parts/eve.js.map +1 -0
  140. package/x/dom/parts/mk.d.ts +2 -0
  141. package/x/dom/parts/mk.js +7 -0
  142. package/x/dom/parts/mk.js.map +1 -0
  143. package/x/dom/parts/queries.d.ts +4 -0
  144. package/x/dom/parts/queries.js +13 -0
  145. package/x/dom/parts/queries.js.map +1 -0
  146. package/x/dom/{register.d.ts → parts/register.d.ts} +2 -6
  147. package/x/dom/parts/register.js.map +1 -0
  148. package/x/dom/types.d.ts +15 -0
  149. package/x/index.d.ts +7 -16
  150. package/x/index.html +6 -4
  151. package/x/index.html.js +4 -2
  152. package/x/index.html.js.map +1 -1
  153. package/x/index.js +7 -16
  154. package/x/index.js.map +1 -1
  155. package/x/loaders/index.barrel.d.ts +7 -0
  156. package/x/loaders/index.barrel.js +7 -0
  157. package/x/loaders/index.barrel.js.map +1 -0
  158. package/x/loaders/index.d.ts +2 -0
  159. package/x/loaders/index.js +2 -0
  160. package/x/loaders/index.js.map +1 -0
  161. package/x/loaders/make.d.ts +3 -0
  162. package/x/loaders/make.js +6 -0
  163. package/x/loaders/make.js.map +1 -0
  164. package/x/loaders/mock.d.ts +2 -0
  165. package/x/loaders/mock.js +8 -0
  166. package/x/loaders/mock.js.map +1 -0
  167. package/x/{ops/loaders → loaders}/parts/anims.d.ts +1 -1
  168. package/x/loaders/parts/anims.js.map +1 -0
  169. package/x/{ops/loaders → loaders}/parts/ascii-anim.d.ts +2 -2
  170. package/x/{ops/loaders → loaders}/parts/ascii-anim.js +4 -4
  171. package/x/loaders/parts/ascii-anim.js.map +1 -0
  172. package/x/loaders/parts/error-display.d.ts +1 -0
  173. package/x/{ops/loaders → loaders}/parts/error-display.js +2 -2
  174. package/x/loaders/parts/error-display.js.map +1 -0
  175. package/x/loaders/types.d.ts +3 -0
  176. package/x/loaders/types.js.map +1 -0
  177. package/x/loot/drag-and-drops.d.ts +30 -0
  178. package/x/loot/drag-and-drops.js +63 -0
  179. package/x/loot/drag-and-drops.js.map +1 -0
  180. package/x/loot/{drop.d.ts → drops.d.ts} +3 -5
  181. package/x/loot/drops.js +25 -0
  182. package/x/loot/drops.js.map +1 -0
  183. package/x/loot/helpers.d.ts +3 -3
  184. package/x/loot/helpers.js +3 -3
  185. package/x/loot/helpers.js.map +1 -1
  186. package/x/loot/index.barrel.d.ts +3 -0
  187. package/x/loot/index.barrel.js +4 -0
  188. package/x/loot/index.barrel.js.map +1 -0
  189. package/x/loot/index.d.ts +2 -3
  190. package/x/loot/index.js +1 -3
  191. package/x/loot/index.js.map +1 -1
  192. package/x/ops/index.d.ts +3 -0
  193. package/x/ops/index.js +4 -0
  194. package/x/ops/index.js.map +1 -0
  195. package/x/ops/op.js +1 -0
  196. package/x/ops/op.js.map +1 -1
  197. package/x/spa/index.barrel.d.ts +4 -0
  198. package/x/spa/index.barrel.js +3 -0
  199. package/x/spa/index.barrel.js.map +1 -0
  200. package/x/spa/index.d.ts +2 -0
  201. package/x/spa/index.js +2 -0
  202. package/x/spa/index.js.map +1 -0
  203. package/x/spa/plumbing/braces.d.ts +12 -0
  204. package/x/spa/plumbing/braces.js +55 -0
  205. package/x/spa/plumbing/braces.js.map +1 -0
  206. package/x/spa/plumbing/primitives.d.ts +22 -0
  207. package/x/spa/plumbing/primitives.js +65 -0
  208. package/x/spa/plumbing/primitives.js.map +1 -0
  209. package/x/spa/plumbing/router-core.d.ts +13 -0
  210. package/x/spa/plumbing/router-core.js +38 -0
  211. package/x/spa/plumbing/router-core.js.map +1 -0
  212. package/x/spa/plumbing/types.d.ts +35 -0
  213. package/x/spa/plumbing/types.js +2 -0
  214. package/x/spa/plumbing/types.js.map +1 -0
  215. package/x/spa/router.d.ts +16 -0
  216. package/x/spa/router.js +39 -0
  217. package/x/spa/router.js.map +1 -0
  218. package/x/spa/spa.test.d.ts +15 -0
  219. package/x/spa/spa.test.js +78 -0
  220. package/x/spa/spa.test.js.map +1 -0
  221. package/x/tests.test.js +4 -1
  222. package/x/tests.test.js.map +1 -1
  223. package/x/view/index.d.ts +5 -0
  224. package/x/view/index.js +6 -0
  225. package/x/view/index.js.map +1 -0
  226. package/x/view/types.d.ts +21 -0
  227. package/x/view/types.js +2 -0
  228. package/x/{views → view}/types.js.map +1 -1
  229. package/x/view/utils/contextualize.d.ts +13 -0
  230. package/x/view/utils/contextualize.js +18 -0
  231. package/x/view/utils/contextualize.js.map +1 -0
  232. package/x/view/utils/make-component.d.ts +5 -0
  233. package/x/view/utils/make-component.js +17 -0
  234. package/x/view/utils/make-component.js.map +1 -0
  235. package/x/view/utils/make-view.d.ts +2 -0
  236. package/x/view/utils/make-view.js +24 -0
  237. package/x/view/utils/make-view.js.map +1 -0
  238. package/x/view/utils/parts/capsule.d.ts +13 -0
  239. package/x/view/utils/parts/capsule.js +49 -0
  240. package/x/view/utils/parts/capsule.js.map +1 -0
  241. package/x/view/utils/parts/chain.d.ts +13 -0
  242. package/x/view/utils/parts/chain.js +26 -0
  243. package/x/view/utils/parts/chain.js.map +1 -0
  244. package/x/view/utils/parts/context.d.ts +9 -0
  245. package/x/view/utils/parts/context.js +10 -0
  246. package/x/view/utils/parts/context.js.map +1 -0
  247. package/x/view/utils/parts/directive.d.ts +5 -0
  248. package/x/view/utils/parts/directive.js +18 -0
  249. package/x/view/utils/parts/directive.js.map +1 -0
  250. package/x/view/utils/parts/sly-view.d.ts +5 -0
  251. package/x/view/utils/parts/sly-view.js +13 -0
  252. package/x/view/utils/parts/sly-view.js.map +1 -0
  253. package/x/view/view.d.ts +11 -0
  254. package/x/view/view.js +15 -0
  255. package/x/view/view.js.map +1 -0
  256. package/s/loot/drag-drop.ts +0 -76
  257. package/s/ops/loaders/make-loader.ts +0 -18
  258. package/s/views/attributes.ts +0 -89
  259. package/s/views/types.ts +0 -40
  260. package/s/views/utils/apply-attrs.ts +0 -33
  261. package/s/views/view.ts +0 -150
  262. package/x/dom/dashify.js.map +0 -1
  263. package/x/dom/register.js.map +0 -1
  264. package/x/loot/drag-drop.d.ts +0 -29
  265. package/x/loot/drag-drop.js +0 -54
  266. package/x/loot/drag-drop.js.map +0 -1
  267. package/x/loot/drop.js +0 -32
  268. package/x/loot/drop.js.map +0 -1
  269. package/x/ops/loaders/make-loader.d.ts +0 -5
  270. package/x/ops/loaders/make-loader.js +0 -7
  271. package/x/ops/loaders/make-loader.js.map +0 -1
  272. package/x/ops/loaders/parts/anims.js.map +0 -1
  273. package/x/ops/loaders/parts/ascii-anim.js.map +0 -1
  274. package/x/ops/loaders/parts/error-display.d.ts +0 -1
  275. package/x/ops/loaders/parts/error-display.js.map +0 -1
  276. package/x/views/attributes.d.ts +0 -10
  277. package/x/views/attributes.js +0 -46
  278. package/x/views/attributes.js.map +0 -1
  279. package/x/views/css-reset.js.map +0 -1
  280. package/x/views/types.d.ts +0 -31
  281. package/x/views/use.js.map +0 -1
  282. package/x/views/utils/apply-attrs.d.ts +0 -2
  283. package/x/views/utils/apply-attrs.js +0 -21
  284. package/x/views/utils/apply-attrs.js.map +0 -1
  285. package/x/views/utils/apply-styles.js.map +0 -1
  286. package/x/views/utils/mounts.js.map +0 -1
  287. package/x/views/view.d.ts +0 -9
  288. package/x/views/view.js +0 -116
  289. package/x/views/view.js.map +0 -1
  290. /package/s/{views → base}/css-reset.ts +0 -0
  291. /package/s/{views → base}/utils/apply-styles.ts +0 -0
  292. /package/s/{views → base}/utils/mounts.ts +0 -0
  293. /package/s/dom/{dashify.ts → parts/dashify.ts} +0 -0
  294. /package/x/{views → base}/css-reset.d.ts +0 -0
  295. /package/x/{views → base}/css-reset.js +0 -0
  296. /package/x/{views → base}/utils/apply-styles.d.ts +0 -0
  297. /package/x/{views → base}/utils/apply-styles.js +0 -0
  298. /package/x/{views → base}/utils/mounts.d.ts +0 -0
  299. /package/x/{views → base}/utils/mounts.js +0 -0
  300. /package/x/dom/{dashify.d.ts → parts/dashify.d.ts} +0 -0
  301. /package/x/dom/{dashify.js → parts/dashify.js} +0 -0
  302. /package/x/dom/{register.js → parts/register.js} +0 -0
  303. /package/x/{ops/loaders → loaders}/parts/anims.js +0 -0
  304. /package/x/{views → loaders}/types.js +0 -0
@@ -0,0 +1,65 @@
1
+ import { ev, ob } from "@e280/stz";
2
+ import { Op } from "../../ops/op.js";
3
+ export function eraseWindowHash() {
4
+ const { pathname, search } = window.location;
5
+ history.replaceState(null, "", pathname + search);
6
+ }
7
+ export function normalizeHash(hash) {
8
+ const homeEquivalents = [/^$/, /^#$/, /^#\/$/];
9
+ return (homeEquivalents.some(regex => regex.test(hash)))
10
+ ? "#/"
11
+ : hash;
12
+ }
13
+ export class HashNormalizer {
14
+ location;
15
+ constructor(location) {
16
+ this.location = location;
17
+ }
18
+ get hash() {
19
+ const hash = normalizeHash(this.location.hash);
20
+ if (hash === "#/")
21
+ eraseWindowHash();
22
+ return hash;
23
+ }
24
+ set hash(hash) {
25
+ this.location.hash = hash;
26
+ }
27
+ }
28
+ export class Navigable {
29
+ route;
30
+ isActive;
31
+ go;
32
+ static all(routes, getRoute, navigate) {
33
+ return ob(routes).map(route => new this(route, () => (getRoute() === route), async (...params) => navigate(route.hasher.make(...params))));
34
+ }
35
+ constructor(route, isActive, go) {
36
+ this.route = route;
37
+ this.isActive = isActive;
38
+ this.go = go;
39
+ }
40
+ get active() {
41
+ return this.isActive();
42
+ }
43
+ hash(...params) {
44
+ return this.route.hasher.make(...params);
45
+ }
46
+ }
47
+ export function resolveRoute(hash, routes) {
48
+ for (const key in routes) {
49
+ const route = routes[key];
50
+ const params = route.hasher.parse(hash);
51
+ if (params) {
52
+ return {
53
+ key,
54
+ route,
55
+ params,
56
+ op: Op.promise(route.fn(...params))
57
+ };
58
+ }
59
+ }
60
+ return null;
61
+ }
62
+ export function onHashChange(fn) {
63
+ return ev(window, { hashchange: fn });
64
+ }
65
+ //# sourceMappingURL=primitives.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitives.js","sourceRoot":"","sources":["../../../s/spa/plumbing/primitives.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,EAAE,EAAE,EAAE,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,EAAC,EAAE,EAAC,MAAM,iBAAiB,CAAA;AAGlC,MAAM,UAAU,eAAe;IAC9B,MAAM,EAAC,QAAQ,EAAE,MAAM,EAAC,GAAG,MAAM,CAAC,QAAQ,CAAA;IAC1C,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAA;AAClD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAY;IACzC,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;IAC9C,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,IAAI,CAAA;AACR,CAAC;AAED,MAAM,OAAO,cAAc;IACP;IAAnB,YAAmB,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAAG,CAAC;IAEzC,IAAI,IAAI;QACP,MAAM,IAAI,GAAG,aAAa,CAAC,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AA;QACvC,IAAI,MAAM,EAAE,CAAC;YACZ,OAAO;gBACN,GAAG;gBACH,KAAK;gBACL,MAAM;gBACN,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;aACnC,CAAA;QACF,CAAC;IACF,CAAC;IAED,OAAO,IAAI,CAAA;AACZ,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,EAAoC;IAChE,OAAO,EAAE,CAAC,MAAM,EAAE,EAAC,UAAU,EAAE,EAAE,EAAC,CAAC,CAAA;AACpC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Content } from "../../view/types.js";
2
+ import { Hashbearer, Navigables, ResolvedRoute, Routes } from "./types.js";
3
+ export declare class RouterCore<R extends Routes> {
4
+ readonly routes: R;
5
+ readonly location: Hashbearer;
6
+ readonly nav: Navigables<R>;
7
+ readonly $resolved: import("@e280/strata").SignalFn<ResolvedRoute | null>;
8
+ constructor(routes: R, location: Hashbearer);
9
+ get hash(): string;
10
+ get content(): Content | null;
11
+ get route(): import("./types.js").Route<any[]> | null;
12
+ refresh(hash?: string): Promise<ResolvedRoute | null>;
13
+ }
@@ -0,0 +1,38 @@
1
+ import { signal } from "@e280/strata";
2
+ import { Navigable, normalizeHash, resolveRoute } from "./primitives.js";
3
+ export class RouterCore {
4
+ routes;
5
+ location;
6
+ nav;
7
+ $resolved = signal(null);
8
+ constructor(routes, location) {
9
+ this.routes = routes;
10
+ this.location = location;
11
+ this.nav = Navigable.all(routes, () => this.route, async (hash) => {
12
+ this.location.hash = hash;
13
+ const resolved = await this.refresh();
14
+ if (!resolved)
15
+ throw new Error(`route failed "${hash}"`);
16
+ return resolved;
17
+ });
18
+ }
19
+ get hash() {
20
+ return normalizeHash(this.location.hash);
21
+ }
22
+ get content() {
23
+ return this.$resolved.get()?.op.value ?? null;
24
+ }
25
+ get route() {
26
+ return this.$resolved.get()?.route ?? null;
27
+ }
28
+ async refresh(hash) {
29
+ if (hash !== undefined)
30
+ this.location.hash = hash;
31
+ hash = this.hash;
32
+ const resolved = resolveRoute(hash, this.routes);
33
+ await this.$resolved.set(resolved);
34
+ await resolved?.op;
35
+ return resolved;
36
+ }
37
+ }
38
+ //# sourceMappingURL=router-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router-core.js","sourceRoot":"","sources":["../../../s/spa/plumbing/router-core.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAC,SAAS,EAAE,aAAa,EAAE,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAGtE,MAAM,OAAO,UAAU;IAKJ;IACA;IALT,GAAG,CAAe;IAClB,SAAS,GAAG,MAAM,CAAuB,IAAI,CAAC,CAAA;IAEvD,YACkB,MAAS,EACT,QAAoB;QADpB,WAAM,GAAN,MAAM,CAAG;QACT,aAAQ,GAAR,QAAQ,CAAY;QAGrC,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,CACvB,MAAM,EACN,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAChB,KAAK,EAAC,IAAI,EAAC,EAAE;YACZ,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAA;YACzB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;YACrC,IAAI,CAAC,QAAQ;gBAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,GAAG,CAAC,CAAA;YACxD,OAAO,QAAQ,CAAA;QAChB,CAAC,CACD,CAAA;IACF,CAAC;IAED,IAAI,IAAI;QACP,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACzC,CAAC;IAED,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI,CAAA;IAC9C,CAAC;IAED,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,IAAI,IAAI,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAa;QAC1B,IAAI,IAAI,KAAK,SAAS;YAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAA;QACjD,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;QAChB,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAChD,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAClC,MAAM,QAAQ,EAAE,EAAE,CAAA;QAClB,OAAO,QAAQ,CAAA;IAChB,CAAC;CACD"}
@@ -0,0 +1,35 @@
1
+ import type { Op } from "../../ops/op.js";
2
+ import type { Navigable } from "./primitives.js";
3
+ import type { Content } from "../../view/types.js";
4
+ import type { Loader } from "../../loaders/types.js";
5
+ export type RouterOptions<R extends Routes> = {
6
+ routes: R;
7
+ auto?: boolean;
8
+ location?: Hashbearer;
9
+ loader?: Loader;
10
+ notFound?: () => Content;
11
+ };
12
+ export type Hashbearer = {
13
+ hash: string;
14
+ };
15
+ export type Hasher<Params extends any[]> = {
16
+ parse: (hash: string) => (Params | null);
17
+ make: (...params: Params) => string;
18
+ };
19
+ export type Route<P extends any[] = any[]> = {
20
+ hasher: Hasher<P>;
21
+ fn: (...params: P) => Promise<Content>;
22
+ };
23
+ export type Routes = {
24
+ [key: string]: Route;
25
+ };
26
+ export type Params<X extends (Route | Navigable)> = (X extends Route<infer P> ? P : X extends Navigable<infer P> ? P : never);
27
+ export type ResolvedRoute<P extends any[] = any[]> = {
28
+ key: string;
29
+ route: Route<P>;
30
+ params: P;
31
+ op: Op<Content>;
32
+ };
33
+ export type Navigables<R extends Routes> = {
34
+ [K in keyof R]: Navigable<Params<R[K]>>;
35
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../s/spa/plumbing/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { Content } from "../view/types.js";
2
+ import { Loader } from "../loaders/types.js";
3
+ import { RouterCore } from "./plumbing/router-core.js";
4
+ import { RouterOptions, Routes } from "./plumbing/types.js";
5
+ export declare class Router<R extends Routes> extends RouterCore<R> {
6
+ #private;
7
+ loader: Loader;
8
+ notFound: () => Content;
9
+ readonly dispose: {
10
+ (): void;
11
+ schedule(fn: () => void): any;
12
+ };
13
+ constructor(options: RouterOptions<R>);
14
+ render(): Content;
15
+ listen(): () => void;
16
+ }
@@ -0,0 +1,39 @@
1
+ import { disposer } from "@e280/stz";
2
+ import { loaders } from "../loaders/index.js";
3
+ import { RouterCore } from "./plumbing/router-core.js";
4
+ import { HashNormalizer, onHashChange } from "./plumbing/primitives.js";
5
+ export class Router extends RouterCore {
6
+ loader;
7
+ notFound;
8
+ dispose = disposer();
9
+ #lastHash;
10
+ constructor(options) {
11
+ super(options.routes, options.location ?? new HashNormalizer(window.location));
12
+ const { auto = true } = options;
13
+ this.loader = options.loader ?? loaders.make();
14
+ this.notFound = options.notFound ?? (() => null);
15
+ this.#lastHash = this.hash;
16
+ if (auto) {
17
+ this.listen();
18
+ this.refresh();
19
+ }
20
+ }
21
+ render() {
22
+ const resolved = this.$resolved.get();
23
+ return resolved === null
24
+ ? this.notFound()
25
+ : this.loader(resolved.op, content => content);
26
+ }
27
+ listen() {
28
+ const dispose = onHashChange(() => {
29
+ const hash = this.hash;
30
+ const isChanged = hash !== this.#lastHash;
31
+ this.#lastHash = hash;
32
+ if (isChanged)
33
+ this.refresh();
34
+ });
35
+ this.dispose.schedule(dispose);
36
+ return dispose;
37
+ }
38
+ }
39
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../s/spa/router.ts"],"names":[],"mappings":"AACA,OAAO,E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ACjC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;YACtB,MAAM,SAAS,GAAG,IAAI,KAAK,IAAI,CAAC,SAAS,CAAA;YACzC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA;YACrB,IAAI,SAAS;gBAAE,IAAI,CAAC,OAAO,EAAE,CAAA;QAC9B,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC9B,OAAO,OAAO,CAAA;IACf,CAAC;CACD"}
@@ -0,0 +1,15 @@
1
+ import { Science } from "@e280/science";
2
+ declare const _default: {
3
+ inits: {
4
+ "#/": Science.Test;
5
+ "#/hello/world": Science.Test;
6
+ "#/item/a123": Science.Test;
7
+ "#/item/a123/lol should miss": Science.Test;
8
+ "#/left/{mid}/right extraction": Science.Test;
9
+ "#/not-found-lol": Science.Test;
10
+ };
11
+ nav: {
12
+ "home to item and back": Science.Test;
13
+ };
14
+ };
15
+ export default _default;
@@ -0,0 +1,78 @@
1
+ import { Science, test, expect } from "@e280/science";
2
+ import { route } from "./plumbing/braces.js";
3
+ import { RouterCore } from "./plumbing/router-core.js";
4
+ async function setup(routes) {
5
+ const location = { hash: "" };
6
+ const router = new RouterCore(routes, location);
7
+ return { location, router };
8
+ }
9
+ export default Science.suite({
10
+ inits: Science.suite({
11
+ "#/": test(async () => {
12
+ const { location, router } = await setup({
13
+ home: route("#/", async () => "123"),
14
+ });
15
+ expect(router.content).is(null);
16
+ location.hash = "#/";
17
+ await router.refresh();
18
+ expect(router.content).is("123");
19
+ }),
20
+ "#/hello/world": test(async () => {
21
+ const { location, router } = await setup({
22
+ helloWorld: route("#/hello/world", async () => "123"),
23
+ });
24
+ expect(router.content).is(null);
25
+ location.hash = "#/hello/world";
26
+ await router.refresh();
27
+ expect(router.content).is("123");
28
+ }),
29
+ "#/item/a123": test(async () => {
30
+ const { location, router } = await setup({
31
+ item: route("#/item/{id}", async ({ id }) => `content ${id}`),
32
+ });
33
+ location.hash = "#/item/a123";
34
+ await router.refresh();
35
+ expect(router.content).is("content a123");
36
+ }),
37
+ "#/item/a123/lol should miss": test(async () => {
38
+ const { location, router } = await setup({
39
+ item: route("#/item/{id}", async ({ id }) => `content ${id}`),
40
+ });
41
+ location.hash = "#/item/a123/lol";
42
+ await router.refresh();
43
+ expect(router.content).is(null);
44
+ }),
45
+ "#/left/{mid}/right extraction": test(async () => {
46
+ const { location, router } = await setup({
47
+ item: route("#/left/{mid}/right", async ({ mid }) => `content ${mid}`),
48
+ });
49
+ location.hash = "#/left/middle/right";
50
+ await router.refresh();
51
+ expect(router.content).is("content middle");
52
+ }),
53
+ "#/not-found-lol": test(async () => {
54
+ const { location, router } = await setup({
55
+ helloWorld: route("#/hello/world", async () => "123"),
56
+ });
57
+ location.hash = "#/not-found-lol";
58
+ await router.refresh();
59
+ expect(router.content).is(null);
60
+ }),
61
+ }),
62
+ nav: Science.suite({
63
+ "home to item and back": test(async () => {
64
+ const { location, router } = await setup({
65
+ home: route("#/", async () => `home`),
66
+ item: route("#/item/{id}", async ({ id }) => `item ${id}`),
67
+ });
68
+ location.hash = "#/";
69
+ await router.refresh();
70
+ expect(router.content).is("home");
71
+ await router.nav.item.go({ id: "x234" });
72
+ expect(router.content).is("item x234");
73
+ await router.nav.home.go();
74
+ expect(router.content).is("home");
75
+ }),
76
+ }),
77
+ });
78
+ //# sourceMappingURL=spa.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spa.test.js","sourceRoot":"","sources":["../../s/spa/spa.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAC,MAAM,eAAe,CAAA;AACnD,OAAO,EAAC,KAAK,EAAC,MAAM,sBAAsB,CAAA;AAE1C,OAAO,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAA;AAEpD,KAAK,UAAU,KAAK,CAAmB,MAAS;IAC/C,MAAM,QAAQ,GAAG,EAAC,IAAI,EAAE,EAAE,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M,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAA;QAClC,CAAC,CAAC;KACF,CAAC;CACF,CAAC,CAAA"}
package/x/tests.test.js CHANGED
@@ -1,3 +1,6 @@
1
1
  import { Science } from "@e280/science";
2
- await Science.run({});
2
+ import spa from "./spa/spa.test.js";
3
+ await Science.run({
4
+ spa,
5
+ });
3
6
  //# sourceMappingURL=tests.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tests.test.js","sourceRoot":"","sources":["../s/tests.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AAErC,MAAM,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA"}
1
+ {"version":3,"file":"tests.test.js","sourceRoot":"","sources":["../s/tests.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AACrC,OAAO,GAAG,MAAM,mBAAmB,CAAA;AAEnC,MAAM,OAAO,CAAC,GAAG,CAAC;IACjB,GAAG;CACH,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ export * from "./utils/parts/chain.js";
2
+ export * from "./utils/parts/sly-view.js";
3
+ export * from "./utils/contextualize.js";
4
+ export * from "./types.js";
5
+ export * from "./view.js";
@@ -0,0 +1,6 @@
1
+ export * from "./utils/parts/chain.js";
2
+ export * from "./utils/parts/sly-view.js";
3
+ export * from "./utils/contextualize.js";
4
+ export * from "./types.js";
5
+ export * from "./view.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../s/view/index.ts"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
@@ -0,0 +1,21 @@
1
+ import { TemplateResult } from "lit";
2
+ import { Constructor } from "@e280/stz";
3
+ import { DirectiveResult } from "lit/directive.js";
4
+ import { Use } from "../base/use.js";
5
+ import { BaseElement } from "../base/element.js";
6
+ import { ViewChain } from "./utils/parts/chain.js";
7
+ export type Content = TemplateResult | DirectiveResult | HTMLElement | string | null | undefined | void | Content[];
8
+ export type ViewFn<Props extends any[]> = ((use: Use) => (...props: Props) => Content);
9
+ export type View<Props extends any[]> = {
10
+ (...props: Props): DirectiveResult;
11
+ props: (...props: Props) => ViewChain<Props>;
12
+ transmute: <PropsB extends any[]>(convert: (...propsB: PropsB) => Props) => View<PropsB>;
13
+ component: <B extends Constructor<BaseElement>>(Base?: B) => {
14
+ props: (propFn: (component: InstanceType<B>) => Props) => (ComponentClass<B, Props>);
15
+ };
16
+ };
17
+ export type ViewProps<V extends View<any>> = (V extends View<infer Props> ? Props : never);
18
+ export type ComponentClass<B extends Constructor<BaseElement>, Props extends any[]> = {
19
+ view: View<Props>;
20
+ new (): InstanceType<B>;
21
+ } & B;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../s/views/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../s/view/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { DropFirst } from "@e280/stz";
2
+ import { ComponentClass, View, ViewProps } from "../types.js";
3
+ export declare function contextualizeView<C, V extends View<any>>(context: C, view: V): View<DropFirst<ViewProps<V>>>;
4
+ export declare function contextualizeViews<C, Vs extends Record<string, View<any>>>(context: C, views: Vs): {
5
+ [K in keyof Vs]: View<DropFirst<ViewProps<Vs[K]>>>;
6
+ };
7
+ export declare function getViews<Cs extends Record<string, ComponentClass<any, any>>>(components: Cs): { [K in keyof Cs]: Cs[K]["view"]; };
8
+ export declare function contextualizeComponents<C, Cs extends Record<string, ComponentClass<any, any>>>(context: C, originalComponents: Cs): { [K in keyof Cs]: {
9
+ view: View<DropFirst<ViewProps<Cs[K]["view"]>>>;
10
+ new (): InstanceType<{
11
+ context: C;
12
+ } & Cs[K]>;
13
+ } & Cs[K]; };
@@ -0,0 +1,18 @@
1
+ import { ob } from "@e280/stz";
2
+ export function contextualizeView(context, view) {
3
+ return view.transmute((...p) => [context, ...p]);
4
+ }
5
+ export function contextualizeViews(context, views) {
6
+ return ob(views)
7
+ .map(view => contextualizeView(context, view));
8
+ }
9
+ export function getViews(components) {
10
+ return ob(components).map(C => C.view);
11
+ }
12
+ export function contextualizeComponents(context, originalComponents) {
13
+ return ob(originalComponents).map((Cons) => class extends Cons {
14
+ context = context;
15
+ static view = contextualizeView(context, super.view);
16
+ });
17
+ }
18
+ //# sourceMappingURL=contextualize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contextualize.js","sourceRoot":"","sources":["../../../s/view/utils/contextualize.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,EAAE,EAAC,MAAM,WAAW,CAAA;AAGvC,MAAM,UAAU,iBAAiB,CAC/B,OAAU,EACV,IAAO;IAER,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAQ,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAQ,CAAA;AAC/D,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,OAAU,EACV,KAAS;IAGV,OAAO,EAAE,CAAC,KAAK,CAAC;SACd,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;AAChD,CAAC;AAED,MAAM,UAAU,QAAQ,CAErB,UAAc;IAEhB,OAAO,EAAE,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAW,CAE3C,CAAA;AACF,CAAC;AAED,MAAM,UAAU,uBAAuB,CAGpC,OAAU,EAAE,kBAAsB;IAEpC,OAAO,EAAE,CAAC,kBAAkB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,KAAM,SAAQ,IAAI;QAClE,OAAO,GAAG,OAAO,CAAA;QACjB,MAAM,CAAC,IAAI,GAAG,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAQ,CAAA;KAC3D,CAKA,CAAA;AACF,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Constructor } from "@e280/stz";
2
+ import { BaseElement } from "../../base/element.js";
3
+ import { ComponentClass, ViewFn } from "../types.js";
4
+ /** make a component from a BaseElement and a view. */
5
+ export declare function makeComponent<B extends Constructor<BaseElement>, Props extends any[]>(settings: ShadowRootInit, Base: B, propFn: (component: InstanceType<B>) => Props, viewFn: ViewFn<Props>): ComponentClass<B, Props>;
@@ -0,0 +1,17 @@
1
+ import { makeView } from "./make-view.js";
2
+ import { Reactor } from "../../base/utils/reactor.js";
3
+ /** make a component from a BaseElement and a view. */
4
+ export function makeComponent(settings, Base, propFn, viewFn) {
5
+ return class Component extends Base {
6
+ static view = makeView(viewFn, settings);
7
+ #reactor = new Reactor();
8
+ createShadow() {
9
+ return this.attachShadow(settings);
10
+ }
11
+ render(use) {
12
+ // reactor is tracking the propFn
13
+ return viewFn(use)(...this.#reactor.effect(() => propFn(this), () => this.update()));
14
+ }
15
+ };
16
+ }
17
+ //# sourceMappingURL=make-component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make-component.js","sourceRoot":"","sources":["../../../s/view/utils/make-component.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AAEvC,OAAO,EAAC,OAAO,EAAC,MAAM,6BAA6B,CAAA;AAGnD,sDAAsD;AACtD,MAAM,UAAU,aAAa,CAC3B,QAAwB,EACxB,IAAO,EACP,MAA6C,EAC7C,MAAqB;IAGtB,OAAO,MAAM,SAAU,SAAQ,IAAI;QAClC,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QACxC,QAAQ,GAAG,IAAI,OAAO,EAAE,CAAA;QAExB,YAAY;YACX,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;QACnC,CAAC;QAED,MAAM,CAAC,GAAQ;YACd,iCAAiC;YACjC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CACzC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAW,CAAC,EACzB,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CACnB,CAAC,CAAA;QACH,CAAC;KACkC,CAAA;AACrC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { View, ViewFn } from "../types.js";
2
+ export declare function makeView<Props extends any[]>(viewFn: ViewFn<Props>, settings: ShadowRootInit): View<Props>;
@@ -0,0 +1,24 @@
1
+ import { ViewChain } from "./parts/chain.js";
2
+ import { BaseElement } from "../../base/element.js";
3
+ import { ViewContext } from "./parts/context.js";
4
+ import { makeComponent } from "./make-component.js";
5
+ import { makeViewDirective } from "./parts/directive.js";
6
+ export function makeView(viewFn, settings) {
7
+ const renderDirective = makeViewDirective(viewFn, settings);
8
+ function v(...props) {
9
+ return renderDirective(new ViewContext(props));
10
+ }
11
+ v.props = (...props) => new ViewChain(new ViewContext(props), renderDirective);
12
+ v.transmute = (convert) => {
13
+ const viewFnB = use => {
14
+ const viewFnA2 = viewFn(use);
15
+ return (...propsB) => viewFnA2(...convert(...propsB));
16
+ };
17
+ return makeView(viewFnB, settings);
18
+ };
19
+ v.component = (Base = BaseElement) => ({
20
+ props: (propFn) => (makeComponent(settings, Base, propFn, viewFn))
21
+ });
22
+ return v;
23
+ }
24
+ //# sourceMappingURL=make-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make-view.js","sourceRoot":"","sources":["../../../s/view/utils/make-view.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAA;A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2
+ import { SlyView } from "./sly-view.js";
3
+ import { ViewContext } from "./context.js";
4
+ /** controls the rendering of view context into an element. */
5
+ export declare class ViewCapsule<Props extends any[]> {
6
+ #private;
7
+ private viewFn;
8
+ private settings;
9
+ constructor(viewFn: ViewFn<Props>, settings: ShadowRootInit);
10
+ update(context: ViewContext<Props>): SlyView;
11
+ disconnected(): void;
12
+ reconnected(): void;
13
+ }
@@ -0,0 +1,49 @@
1
+ import { debounce } from "@e280/stz";
2
+ import { SlyView } from "./sly-view.js";
3
+ import { dom } from "../../../dom/dom.js";
4
+ import { Reactor } from "../../../base/utils/reactor.js";
5
+ import { attrSet } from "../../../dom/attrs/parts/attr-fns.js";
6
+ import { AttrWatcher } from "../../../base/utils/attr-watcher.js";
7
+ import { _disconnect, _reconnect, _wrap, Use } from "../../../base/use.js";
8
+ /** controls the rendering of view context into an element. */
9
+ export class ViewCapsule {
10
+ viewFn;
11
+ settings;
12
+ #element = SlyView.make();
13
+ #reactor = new Reactor();
14
+ #use;
15
+ #shadow;
16
+ #context;
17
+ #attrWatcher = new AttrWatcher(this.#element, () => this.#renderDebounced());
18
+ constructor(viewFn, settings) {
19
+ this.viewFn = viewFn;
20
+ this.settings = settings;
21
+ this.#shadow = this.#element.attachShadow(this.settings);
22
+ this.#use = new Use(this.#element, this.#shadow, this.#renderNow, this.#renderDebounced);
23
+ }
24
+ update(context) {
25
+ this.#context = context;
26
+ this.#renderNow();
27
+ return this.#element;
28
+ }
29
+ #renderNow = () => {
30
+ this.#use[_wrap](() => {
31
+ const content = this.#reactor.effect(() => this.viewFn(this.#use)(...this.#context.props), () => this.#renderDebounced());
32
+ attrSet.entries(this.#element, this.#context.attrs);
33
+ dom.render(this.#shadow, content);
34
+ dom.render(this.#element, this.#context.children);
35
+ this.#attrWatcher.start();
36
+ });
37
+ };
38
+ #renderDebounced = debounce(0, this.#renderNow);
39
+ disconnected() {
40
+ this.#use[_disconnect]();
41
+ this.#reactor.clear();
42
+ this.#attrWatcher.stop();
43
+ }
44
+ reconnected() {
45
+ this.#use[_reconnect]();
46
+ this.#attrWatcher.start();
47
+ }
48
+ }
49
+ //# sourceMappingURL=capsule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capsule.js","sourceRoot":"","sources":["../../../../s/view/utils/parts/capsule.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAA;AAElC,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AACrC,OAAO,EAAC,GAAG,EAAC,MAAM,qBAAqB,CAAA;AAEvC,OAAO,EAAC,OAAO,EAAC,MAAM,gCAAgC,CAAA;AACtD,OAAO,EAAC,OAAO,EAAC,MAAM,sCAAsC,CAAA;AAC5D,OAAO,EAAC,WAAW,EAAC,MAAM,qCAAqC,CAAA;AAC/D,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,EAAC,MAAM,sBAAsB,CAAA;AAExE,8DAA8D;AAC9D,MAAM,OAAO,WAAW;IAUb;IACA;IAVV,QAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,CAAA;IACzB,QAAQ,GAAG,IAAI,OAAO,EAAE,CAAA;IAExB,IAAI,CAAK;IACT,OAAO,CAAY;IACnB,QAAQ,CAAqB;IAC7B,YAAY,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAA;IAE5E,YACU,MAAqB,EACrB,QAAwB;QADxB,WAAM,GAAN,MAAM,CAAe;QACrB,aAAQ,GAAR,QAAQ,CAAgB;QAEjC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACxD,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,CAClB,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,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AA;IAC1B,CAAC;CACD"}
@@ -0,0 +1,13 @@
1
+ import { Content } from "../../types.js";
2
+ import { ViewContext } from "./context.js";
3
+ import { AttrValue } from "../../../dom/types.js";
4
+ import { DirectiveResult } from "lit/async-directive.js";
5
+ /** provides fluent chaining interface for adding context to rendering a view, think view.props().attr().children().render() */
6
+ export declare class ViewChain<Props extends any[]> {
7
+ #private;
8
+ constructor(context: ViewContext<Props>, renderDirective: (context: ViewContext<Props>) => DirectiveResult);
9
+ attr(key: string, value?: AttrValue): this;
10
+ attrs(record: Record<string, AttrValue>): this;
11
+ children(...contents: Content[]): this;
12
+ render(): DirectiveResult<import("lit-html/directive.js").DirectiveClass>;
13
+ }
@@ -0,0 +1,26 @@
1
+ /** provides fluent chaining interface for adding context to rendering a view, think view.props().attr().children().render() */
2
+ export class ViewChain {
3
+ #render;
4
+ #context;
5
+ constructor(context, renderDirective) {
6
+ this.#context = context;
7
+ this.#render = renderDirective;
8
+ }
9
+ attr(key, value = true) {
10
+ this.#context.attrs.set(key, value);
11
+ return this;
12
+ }
13
+ attrs(record) {
14
+ for (const [key, value] of Object.entries(record))
15
+ this.#context.attrs.set(key, value);
16
+ return this;
17
+ }
18
+ children(...contents) {
19
+ this.#context.children.push(...contents);
20
+ return this;
21
+ }
22
+ render() {
23
+ return this.#render(this.#context);
24
+ }
25
+ }
26
+ //# sourceMappingURL=chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../../s/view/utils/parts/chain.ts"],"names":[],"mappings":"AAMA,+HAA+H;AAC/H,MAAM,OAAO,SAAS;IACrB,OAAO,CAAkD;IACzD,QAAQ,CAAoB;IAE5B,YACE,OAA2B,EAC3B,eAAiE;QAElE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,IAAI,CAAC,OAAO,GAAG,eAAe,CAAA;IAC/B,CAAC;IAED,IAAI,CAAC,GAAW,EAAE,QAAmB,IAAI;QACxC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACnC,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,KAAK,CAAC,MAAiC;QACtC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;YAChD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACpC,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,QAAQ,CAAC,GAAG,QAAmB;QAC9B,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAA;QACxC,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,MAAM;QACL,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACnC,CAAC;CACD"}
@@ -0,0 +1,9 @@
1
+ import { Content } from "../../types.js";
2
+ import { AttrValue } from "../../../dom/types.js";
3
+ /** the information we need to render a view. */
4
+ export declare class ViewContext<Props extends any[]> {
5
+ props: Props;
6
+ attrs: Map<string, AttrValue>;
7
+ children: Content[];
8
+ constructor(props: Props);
9
+ }